Skip to content

Commit

Permalink
Deprecate HeroesOfTheStorm.class (#2031)
Browse files Browse the repository at this point in the history
Fixes #2006.

This PR solves an issue of overriding Ruby's built-in `Object#class` method.

I'd like to maintain `HeroesOfTheStorm.class`'s behavior for
a period of time.
But I chose to make a breaking change because it differs from
the expected behavior for built-in `Object#class` method.

I think that the warning for `HeroesOfTheStorm.class`
will be removed in near future.
  • Loading branch information
koic committed Jun 6, 2020
1 parent a7dc646 commit 47b45f3
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 9 deletions.
2 changes: 1 addition & 1 deletion doc/games/heroes_of_the_storm.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
```ruby
Faker::Games::HeroesOfTheStorm.battleground #=> "Towers of Doom"

Faker::Games::HeroesOfTheStorm.class #=> "Support"
Faker::Games::HeroesOfTheStorm.class_name #=> "Support"

Faker::Games::HeroesOfTheStorm.hero #=> "Illidan"

Expand Down
21 changes: 16 additions & 5 deletions lib/faker/games/heroes_of_the_storm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,27 @@ def battleground
end

##
# Produces a class from Heroes of the Storm.
# This method is deprecated. The implementation will be removed in a near future release.
# Use `HeroesOfTheStorm.class_name` instead.
#
# @deprecated Use {#class_name} instead.
def class
warn '`HeroesOfTheStorm.class` is deprecated. Use `HeroesOfTheStorm.class_name` instead.'

super
end

##
# Produces a class name from Heroes of the Storm.
#
# @return [String]
#
# @example
# Faker::Games::HeroesOfTheStorm.class #=> "Support"
# Faker::Games::HeroesOfTheStorm.class_name #=> "Support"
#
# @faker.version 1.9.2
def class
fetch('heroes_of_the_storm.classes')
# @faker.version next
def class_name
fetch('heroes_of_the_storm.class_names')
end

##
Expand Down
2 changes: 1 addition & 1 deletion lib/locales/en/heroes_of_the_storm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ en:
faker:
heroes_of_the_storm:
battlegrounds: ["Alterac Pass", "Battlefield of Eternity", "Blackheart's Bay", "Braxis Holdout", "Cursed Hollow", "Dragon Shire", "Garden of Terror", "Hanamura Temple", "Haunted Mines", "Infernal Shrines", "Sky Temple", "Tomb of the Spider Queen", "Towers of Doom", "Volskaya Foundry", "Warhead Junction"]
classes: ["Bruiser", "Healer", "Melee Assassin", "Ranged Assassin", "Support", "Tank"]
class_names: ["Bruiser", "Healer", "Melee Assassin", "Ranged Assassin", "Support", "Tank"]
heroes: ["Abathur", "Alarak", "Alexstrasza", "Ana", "Anduin", "Anub'arak", "Artanis", "Arthas", "Auriel", "Azmodan", "Blaze", "Brightwing", "Cassia", "Chen", "Cho", "Chromie", "D.Va", "Deckard", "Dehaka", "Diablo", "E.T.C.", "Falstad", "Fenix", "Gall", "Garrosh", "Gazlowe", "Genji", "Greymane", "Gul'dan", "Hanzo", "Illidan", "Imperius", "Jaina", "Johanna", "Junkrat", "Kael'thas", "Kel'Thuzad", "Kerrigan", "Kharazim", "Leoric", "Li Li", "Li-Ming", "Lt. Morales", "Lunara", "Lúcio", "Maiev", "Mal'Ganis", "Malfurion", "Malthael", "Medivh", "Mephisto", "Muradin", "Murky", "Nazeebo", "Nova", "Orphea", "Probius", "Ragnaros", "Raynor", "Rehgar", "Rexxar", "Samuro", "Sgt. Hammer", "Sonya", "Stitches", "Stukov", "Sylvanas", "Tassadar", "The Butcher", "The Lost Vikings", "Thrall", "Tracer", "Tychus", "Tyrael", "Tyrande", "Uther", "Valeera", "Valla", "Whitemane", "Xul", "Yrel", "Zagara", "Zarya", "Zeratul", "Zul'jin"]
quotes: ["Beat them like they owe you money!", "Careful wizard, your kind has upset the balance beforeo I become re-dead? Deader? ... Alive?", "Don't forget to check the pocket!", "Have you ever considered aiming anywhere other than the face?", "Hey, you look like the cover of E.T.C.s new album!", "Human words are hard to make together talking for expressing... things!", "I like happy things! Like puppies, and rainbows, and dead enemies!", "I must leave and I blame this failure upon you.", "Mrgrgrlrgrlgr!!!", "Oh my God, I can't believe I just killed a panda.", "Taunting life form; you are weak! And physically unappealing!", "Teammates. Much to improve. is a pretty good contender.", "That was easy! You were easy to kill!", "This will only hurt until you die.", "Ugh, I've known much better healers.", "We drink first blood!", "You look like you could actually be of use here!", "You might be a king, or just a street sweeper... yet sooner or later you dance with the reaper.", "You see this hero yes? Then kill them!", "You think us fools?", "You waste both my time and your breath, and the former has value."]
4 changes: 2 additions & 2 deletions test/faker/games/test_faker_heroes_of_the_storm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ def test_battleground
assert @tester.battleground.match(/\w+/)
end

def test_class
assert @tester.class.match(/\w+/)
def test_class_name
assert @tester.class_name.match(/\w+/)
end

def test_hero
Expand Down

0 comments on commit 47b45f3

Please sign in to comment.