Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Faker::JapaneseMedia namespace #1420

Merged
merged 4 commits into from
Oct 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
- [PR #1310](https://github.com/stympy/faker/pull/1310) Add alias for middle_name and remove locale [@vbrazo](https://github.com/vbrazo)

### Chores
- [PR #1420](https://github.com/stympy/faker/pull/1420) Add Faker::JapaneseMedia namespace [@boardfish](https://github.com/boardfish)
- [PR #1411](https://github.com/stympy/faker/pull/1411) Add several missing locales [@vbrazo](https://github.com/vbrazo)
- [PR #1403](https://github.com/stympy/faker/pull/1403) Faker::SouthPark => Faker::Movies::SouthPark [@vbrazo](https://github.com/vbrazo)
- [PR #1401](https://github.com/stympy/faker/pull/1401) Faker::GratefulDead => Faker::Movies::GratefulDead [@vbrazo](https://github.com/vbrazo)
Expand All @@ -24,6 +25,8 @@
- [PR #372](https://github.com/stympy/faker/pull/372) Add test_password_could_achieve_max_length [@oleksii-ti](https://github.com/oleksii-ti)

### Deprecation
- [PR #1420](https://github.com/stympy/faker/pull/1420) Add Faker::JapaneseMedia namespace [@boardfish](https://github.com/boardfish)
- Deprecates `::DragonBall`, `::OnePiece` and `::SwordArtOnline`
- [PR #803](https://github.com/stympy/faker/pull/803) Modify Faker::Educator, Fix #576 [@ghbooth12](https://github.com/ghbooth12)

### Documentation
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ Contents
- [Faker::Dog](doc/dog.md)
- [Faker::Dota](doc/dota.md)
- [Faker::DrWho](doc/dr_who.md)
- [Faker::DragonBall](doc/dragon_ball.md)
- [Faker::DumbAndDumber](doc/dumb_and_dumber.md)
- [Faker::Dune](doc/dune.md)
- [Faker::Educator](doc/educator.md)
Expand Down Expand Up @@ -103,6 +102,9 @@ Contents
- [Faker::IndustrySegments](doc/industry_segments.md)
- [Faker::Internet](doc/internet.md)
- [Faker::Invoice](doc/invoice.md)
- [Faker::JapaneseMedia::DragonBall](doc/dragon_ball.md)
- [Faker::JapaneseMedia::OnePiece](doc/one_piece.md)
- [Faker::JapaneseMedia::SwordArtOnline](doc/sword_art_online.md)
- [Faker::Job](doc/job.md)
- [Faker::Json](doc/json.md)
- [Faker::Kpop](doc/kpop.md)
Expand Down Expand Up @@ -132,7 +134,6 @@ Contents
- [Faker::NationalHealthService](doc/national_health_service.md)
- [Faker::Number](doc/number.md)
- [Faker::Omniauth](doc/omniauth.md)
- [Faker::OnePiece](doc/one_piece.md)
- [Faker::Overwatch](doc/overwatch.md)
- [Faker::ParksAndRec](doc/parks_and_rec.md)
- [Faker::PhoneNumber](doc/phone_number.md)
Expand Down Expand Up @@ -161,7 +162,6 @@ Contents
- [Faker::String](doc/string.md)
- [Faker::Stripe](doc/stripe.md)
- [Faker::Superhero](doc/superhero.md)
- [Faker::SwordArtOnline](doc/sword_art_online.md)
- [Faker::Team](doc/team.md)
- [Faker::Tezos](doc/tezos.md)
- [Faker::TheFreshPrinceOfBelAir](doc/the_fresh_prince_of_bel_air.md)
Expand Down
4 changes: 2 additions & 2 deletions doc/dragon_ball.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Faker::DragonBall
# Faker::JapaneseMedia::DragonBall

Available since version 1.8.0.

```ruby
Faker::DragonBall.character #=> "Goku"
Faker::JapaneseMedia::DragonBall.character #=> "Goku"
```
14 changes: 7 additions & 7 deletions doc/one_piece.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# Faker::OnePiece
# Faker::JapaneseMedia::OnePiece

```ruby
Faker::OnePiece.character #=> "Monkey D. Luffy"
Faker::JapaneseMedia::OnePiece.character #=> "Monkey D. Luffy"

Faker::OnePiece.sea #=> "East Blue"
Faker::JapaneseMedia::OnePiece.sea #=> "East Blue"

Faker::OnePiece.island #=> "Laftel"
Faker::JapaneseMedia::OnePiece.island #=> "Laftel"

Faker::OnePiece.location #=> "Foosha Village"
Faker::JapaneseMedia::OnePiece.location #=> "Foosha Village"

Faker::OnePiece.quote #=> "ONE PIECE IS REAL!"
Faker::JapaneseMedia::OnePiece.quote #=> "ONE PIECE IS REAL!"

Faker::OnePiece.akuma_no_mi #=> "Gomu Gomu no Mi"
Faker::JapaneseMedia::OnePiece.akuma_no_mi #=> "Gomu Gomu no Mi"
```
10 changes: 5 additions & 5 deletions doc/sword_art_online.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# Faker::SwordArtOnline
# Faker::JapaneseMedia::SwordArtOnline

Available since version 1.9.0.

```ruby
# Random Sword Art Online real name
Faker::SwordArtOnline.real_name #=> "Kirigaya Kazuto"
Faker::JapaneseMedia::SwordArtOnline.real_name #=> "Kirigaya Kazuto"

# Random Sword Art Online game name
Faker::SwordArtOnline.game_name #=> "Silica"
Faker::JapaneseMedia::SwordArtOnline.game_name #=> "Silica"

# Random Sword Art Online location
Faker::SwordArtOnline.location #=> "Ruby Palace"
Faker::JapaneseMedia::SwordArtOnline.location #=> "Ruby Palace"

# Random Sword Art Online item
Faker::SwordArtOnline.item #=> "Blackwyrm Coat"
Faker::JapaneseMedia::SwordArtOnline.item #=> "Blackwyrm Coat"

```
2 changes: 1 addition & 1 deletion lib/faker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,6 @@ def disable_enforce_available_locales
end
end

%w[faker faker/creature faker/games faker/movies].each do |path|
%w[faker faker/creature faker/games faker/movies faker/japanese_media].each do |path|
Dir.glob(File.join(File.dirname(__FILE__), path, '*.rb')).sort.each { |file| require file }
end
8 changes: 6 additions & 2 deletions lib/faker/dragon_ball.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
# frozen_string_literal: true

module Faker
class DragonBall < Base
module DragonBall
class << self
extend Gem::Deprecate

def character
fetch('dragon_ball.characters')
Faker::JapaneseMedia::DragonBall.character
end

deprecate :character, 'Faker::JapaneseMedia::DragonBall.character', 2018, 10
end
end
end
6 changes: 6 additions & 0 deletions lib/faker/japanese_media.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# frozen_string_literal: true

module Faker
module JapaneseMedia
end
end
13 changes: 13 additions & 0 deletions lib/faker/japanese_media/dragon_ball.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

module Faker
module JapaneseMedia
class DragonBall < Base
class << self
def character
fetch('dragon_ball.characters')
end
end
end
end
end
33 changes: 33 additions & 0 deletions lib/faker/japanese_media/one_piece.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# frozen_string_literal: true

module Faker
module JapaneseMedia
class OnePiece < Base
class << self
def character
fetch('one_piece.characters')
end

def sea
fetch('one_piece.seas')
end

def island
fetch('one_piece.islands')
end

def location
fetch('one_piece.locations')
end

def quote
fetch('one_piece.quotes')
end

def akuma_no_mi
fetch('one_piece.akumas_no_mi')
end
end
end
end
end
25 changes: 25 additions & 0 deletions lib/faker/japanese_media/sword_art_online.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# frozen_string_literal: true

module Faker
module JapaneseMedia
class SwordArtOnline < Base
class << self
def real_name
fetch('sword_art_online.real_name')
end

def game_name
fetch('sword_art_online.game_name')
end

def location
fetch('sword_art_online.location')
end

def item
fetch('sword_art_online.item')
end
end
end
end
end
23 changes: 16 additions & 7 deletions lib/faker/one_piece.rb
Original file line number Diff line number Diff line change
@@ -1,31 +1,40 @@
# frozen_string_literal: true

module Faker
class OnePiece < Base
module OnePiece
class << self
extend Gem::Deprecate

def character
fetch('one_piece.characters')
Faker::JapaneseMedia::OnePiece.character
end

def sea
fetch('one_piece.seas')
Faker::JapaneseMedia::OnePiece.sea
end

def island
fetch('one_piece.islands')
Faker::JapaneseMedia::OnePiece.island
end

def location
fetch('one_piece.locations')
Faker::JapaneseMedia::OnePiece.location
end

def quote
fetch('one_piece.quotes')
Faker::JapaneseMedia::OnePiece.quote
end

def akuma_no_mi
fetch('one_piece.akumas_no_mi')
Faker::JapaneseMedia::OnePiece.akuma_no_mi
end

deprecate :character, 'Faker::JapaneseMedia::OnePiece.character', 2018, 10
deprecate :sea, 'Faker::JapaneseMedia::OnePiece.sea', 2018, 10
deprecate :island, 'Faker::JapaneseMedia::OnePiece.island', 2018, 10
deprecate :location, 'Faker::JapaneseMedia::OnePiece.location', 2018, 10
deprecate :quote, 'Faker::JapaneseMedia::OnePiece.quote', 2018, 10
deprecate :akuma_no_mi, 'Faker::JapaneseMedia::OnePiece.akuma_no_mi', 2018, 10
end
end
end
17 changes: 12 additions & 5 deletions lib/faker/sword_art_online.rb
Original file line number Diff line number Diff line change
@@ -1,23 +1,30 @@
# frozen_string_literal: true

module Faker
class SwordArtOnline < Base
module SwordArtOnline
class << self
extend Gem::Deprecate

def real_name
fetch('sword_art_online.real_name')
Faker::JapaneseMedia::SwordArtOnline.real_name
end

def game_name
fetch('sword_art_online.game_name')
Faker::JapaneseMedia::SwordArtOnline.game_name
end

def location
fetch('sword_art_online.location')
Faker::JapaneseMedia::SwordArtOnline.location
end

def item
fetch('sword_art_online.item')
Faker::JapaneseMedia::SwordArtOnline.item
end

deprecate :real_name, 'Faker::JapaneseMedia::SwordArtOnline.real_name', 2018, 10
deprecate :game_name, 'Faker::JapaneseMedia::SwordArtOnline.game_name', 2018, 10
deprecate :location, 'Faker::JapaneseMedia::SwordArtOnline.location', 2018, 10
deprecate :item, 'Faker::JapaneseMedia::SwordArtOnline.item', 2018, 10
end
end
end
13 changes: 13 additions & 0 deletions test/test_deprecate_dragon_ball.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

require_relative 'test_helper'

class TestFakerDragonBall < Test::Unit::TestCase
def setup
@tester = Faker::DragonBall
end

def test_character
assert @tester.character.match(/\w+/)
end
end
33 changes: 33 additions & 0 deletions test/test_deprecate_one_piece.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# frozen_string_literal: true

require_relative 'test_helper'

class TestFakerOnePiece < Test::Unit::TestCase
def setup
@tester = Faker::OnePiece
end

def test_character
assert @tester.character.match(/\w+/)
end

def test_sea
assert @tester.sea.match(/\w+/)
end

def test_island
assert @tester.island.match(/\w+/)
end

def test_location
assert @tester.location.match(/\w+/)
end

def test_quote
assert @tester.quote.match(/\w+/)
end

def test_akuma_no_mi
assert @tester.akuma_no_mi.match(/\w+/)
end
end
25 changes: 25 additions & 0 deletions test/test_deprecate_sword_art_online.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# frozen_string_literal: true

require_relative 'test_helper'

class TestFakerSwordArtOnline < Test::Unit::TestCase
def setup
@tester = Faker::SwordArtOnline
end

def test_real_name
assert @tester.real_name.match(/\w+\.?/)
end

def test_game_name
assert @tester.game_name.match(/\w+\.?/)
end

def test_location
assert @tester.location.match(/\w+\.?/)
end

def test_item
assert @tester.item.match(/\w+\.?/)
end
end
2 changes: 1 addition & 1 deletion test/test_determinism.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def all_methods

def subclasses
Faker.constants.delete_if do |subclass|
%i[Base Bank Char Base58 ChileRut Config Creature Date Games GamesHalfLife Internet Movies Time VERSION].include?(subclass)
%i[Base Bank Char Base58 ChileRut Config Creature Date DragonBall Games GamesHalfLife Internet JapaneseMedia Movies OnePiece SwordArtOnline Time VERSION].include?(subclass)
end.sort
end

Expand Down
2 changes: 1 addition & 1 deletion test/test_faker_dragon_ball.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class TestFakerDragonBall < Test::Unit::TestCase
def setup
@tester = Faker::DragonBall
@tester = Faker::JapaneseMedia::DragonBall
end

def test_character
Expand Down
2 changes: 1 addition & 1 deletion test/test_faker_one_piece.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class TestFakerOnePiece < Test::Unit::TestCase
def setup
@tester = Faker::OnePiece
@tester = Faker::JapaneseMedia::OnePiece
end

def test_character
Expand Down
Loading