Skip to content

Commit

Permalink
Fix/Deprecate FmaBrotherhood Generator
Browse files Browse the repository at this point in the history
This commit fixes the naming discrpencies with the FmaBrotherhood (now
FullmetalAlchemistBrotherhood) class and its filename.  This adds
deprecation warnings for the old FmaBrotherhood class and also makes the
new FullmetalAlchemistBrotherhood class.

Fix:
  - #2853
  • Loading branch information
kirkkwang committed Nov 14, 2023
1 parent 1c8e604 commit 3fef6b3
Show file tree
Hide file tree
Showing 5 changed files with 168 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ gem 'faker', :git => 'https://github.com/faker-ruby/faker.git', :branch => 'main
- [Faker::JapaneseMedia::Naruto](doc/japanese_media/naruto.md)
- [Faker::JapaneseMedia::Doraemon](doc/japanese_media/doraemon.md)
- [Faker::JapaneseMedia::Conan](doc/japanese_media/conan.md)
- [Faker::JapaneseMedia::FmaBrotherhood](doc/japanese_media/fullmetal_alchemist_brotherhood.md)
- [Faker::JapaneseMedia::FullmetalAlchemistBrotherhood](doc/japanese_media/fullmetal_alchemist_brotherhood.md)
</details>

<details>
Expand Down
8 changes: 4 additions & 4 deletions doc/japanese_media/fullmetal_alchemist_brotherhood.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Faker::JapaneseMedia::FmaBrotherhood
# Faker::JapaneseMedia::FullmetalAchemistBrotherhood

```ruby
Faker::JapaneseMedia::FmaBrotherhood.character #=> "Edward Elric"
Faker::JapaneseMedia::FullmetalAchemistBrotherhood.character #=> "Edward Elric"

Faker::JapaneseMedia::FmaBrotherhood.city #=> "Central City"
Faker::JapaneseMedia::FullmetalAchemistBrotherhood.city #=> "Central City"

Faker::JapaneseMedia::FmaBrotherhood.country #=> "Xing"
Faker::JapaneseMedia::FullmetalAchemistBrotherhood.country #=> "Xing"
```
48 changes: 48 additions & 0 deletions lib/faker/japanese_media/fullmetal_alchemist_brotherhood.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ module Faker
class JapaneseMedia
class FmaBrotherhood < Base
class << self
extend Gem::Deprecate

##
# Produces a character from FmaBrotherhood.
#
Expand All @@ -16,6 +18,7 @@ class << self
def character
fetch('fma_brotherhood.characters')
end
deprecate :character, 'Faker::JapaneseMedia::FullmetalAlchemistBrotherhood.character', 2024, 02

##
# Produces a cities from FmaBrotherhood.
Expand All @@ -29,6 +32,7 @@ def character
def city
fetch('fma_brotherhood.cities')
end
deprecate :city, 'Faker::JapaneseMedia::FullmetalAlchemistBrotherhood.city', 2024, 02

##
# Produces a country from FmaBrotherhood.
Expand All @@ -42,6 +46,50 @@ def city
def country
fetch('fma_brotherhood.countries')
end
deprecate :country, 'Faker::JapaneseMedia::FullmetalAlchemistBrotherhood.country', 2024, 02
end
end

class FullmetalAlchemistBrotherhood < Base
class << self
##
# Produces a character from FullmetalAlchemistBrotherhood.
#
# @return [String]
#
# @example
# Faker::JapaneseMedia::FullmetalAlchemistBrotherhood.character #=> "Edward Elric"
#
# @faker.version next
def character
fetch('fullmetal_alchemist_brotherhood.characters')
end

##
# Produces a cities from FullmetalAlchemistBrotherhood.
#
# @return [String]
#
# @example
# Faker::JapaneseMedia::FullmetalAlchemistBrotherhood.city #=> "Central City"
#
# @faker.version next
def city
fetch('fullmetal_alchemist_brotherhood.cities')
end

##
# Produces a country from FullmetalAlchemistBrotherhood.
#
# @return [String]
#
# @example
# Faker::JapaneseMedia::FullmetalAlchemistBrotherhood.country #=> "Xing"
#
# @faker.version next
def country
fetch('fullmetal_alchemist_brotherhood.countries')
end
end
end
end
Expand Down
78 changes: 78 additions & 0 deletions lib/locales/en/fullmetal_alchemist_brotherhood.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
en:
faker:
fullmetal_alchemist_brotherhood:
characters:
- Edward Elric
- Alphonse Elric
- Roy Mustang
- Riza Hawkeye
- Scar
- Winry Rockbell
- May Chang
- Maes Hughes
- Alex Louis Armstrong
- Jean Havoc
- Heymans Breda
- Vato Fallman
- Kain Feury
- Führer King Bradley
- Maria Ross
- Denny Brosh
- Yoki
- Izumi Curtis
- Sig Curtis
- Pinako Rockbell
- Den The Dog
- Shou Tucker
- Tim Marco
- Lust
- Gluttony
- Envy
- Greed
- Sloth
- Pride
- Wrath
- Selim Bradley
- Roa
- Martel
- Dolceto
- Number 66
- Number 48
- Scar
- Father
- Dominic
- Garfield
- Giolio Comanche
- Basque Grand
- Isaac McDougal
- Solf J. Kimblee
- Van Hohenheim
- Fu
- Ling Yao
- Lan Fan
- Olivier Mira Armstrong
- Buccaneer
- Major Miles
- Trisha Elric
- Rose
- Nina
- Sheska
cities:
- East City
- Rush Valley
- Resembool
- Dublith
- Central City
- Ishval
- Youswell
- North City
- Lior
- Pendleton
- Riviere
countries:
- Amestris
- Aerugo
- Creta
- Drachma
- Xerxes
- Xing
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,47 @@

require_relative '../../test_helper'

class TestFakerFmaBrotherhood < Test::Unit::TestCase
class DeprecatedTestFakerFmaBrotherhood < Test::Unit::TestCase
def setup
@tester = Faker::JapaneseMedia::FmaBrotherhood
end

def test_character
actual_stdout, actual_stderr = capture_output do
@tester.character
end
expected_warning = /NOTE: Faker::JapaneseMedia::FmaBrotherhood.character is deprecated; use Faker::JapaneseMedia::FullmetalAlchemistBrotherhood.character instead. It will be removed on or after 2024-02.*\n/

assert_empty actual_stdout
assert_match(expected_warning, actual_stderr)
end

def test_city
actual_stdout, actual_stderr = capture_output do
@tester.city
end
expected_warning = /NOTE: Faker::JapaneseMedia::FmaBrotherhood.city is deprecated; use Faker::JapaneseMedia::FullmetalAlchemistBrotherhood.city instead. It will be removed on or after 2024-02.*\n/

assert_empty actual_stdout
assert_match(expected_warning, actual_stderr)
end

def test_country
actual_stdout, actual_stderr = capture_output do
@tester.country
end
expected_warning = /NOTE: Faker::JapaneseMedia::FmaBrotherhood.country is deprecated; use Faker::JapaneseMedia::FullmetalAlchemistBrotherhood.country instead. It will be removed on or after 2024-02.*\n/

assert_empty actual_stdout
assert_match(expected_warning, actual_stderr)
end
end

class TestFakerFullmetalAlchemistBrotherhood < Test::Unit::TestCase
def setup
@tester = Faker::JapaneseMedia::FullmetalAlchemistBrotherhood
end

def test_character
assert_match(/\w+/, @tester.character)
end
Expand Down

0 comments on commit 3fef6b3

Please sign in to comment.