From d3e89299cfcb3f5596f9555d07028c1b88ab516c Mon Sep 17 00:00:00 2001 From: Koichi ITO Date: Thu, 4 Jun 2020 19:14:30 +0900 Subject: [PATCH] Deprecate `HeroesOfTheStorm.class` Fixes https://github.com/faker-ruby/faker/issues/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. --- doc/games/heroes_of_the_storm.md | 2 +- lib/faker/games/heroes_of_the_storm.rb | 21 ++++++++++++++----- lib/locales/en/heroes_of_the_storm.yml | 2 +- .../games/test_faker_heroes_of_the_storm.rb | 4 ++-- 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/doc/games/heroes_of_the_storm.md b/doc/games/heroes_of_the_storm.md index c460132b9c..d7079d5fa6 100644 --- a/doc/games/heroes_of_the_storm.md +++ b/doc/games/heroes_of_the_storm.md @@ -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" diff --git a/lib/faker/games/heroes_of_the_storm.rb b/lib/faker/games/heroes_of_the_storm.rb index ba3ad91b1c..9c549c5448 100644 --- a/lib/faker/games/heroes_of_the_storm.rb +++ b/lib/faker/games/heroes_of_the_storm.rb @@ -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 ## diff --git a/lib/locales/en/heroes_of_the_storm.yml b/lib/locales/en/heroes_of_the_storm.yml index 52ec397c54..4f767c3682 100644 --- a/lib/locales/en/heroes_of_the_storm.yml +++ b/lib/locales/en/heroes_of_the_storm.yml @@ -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."] diff --git a/test/faker/games/test_faker_heroes_of_the_storm.rb b/test/faker/games/test_faker_heroes_of_the_storm.rb index 2cd41b3822..cbe6198d56 100644 --- a/test/faker/games/test_faker_heroes_of_the_storm.rb +++ b/test/faker/games/test_faker_heroes_of_the_storm.rb @@ -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