diff --git a/README.md b/README.md index 02aaa8ce02..104c93f2e3 100644 --- a/README.md +++ b/README.md @@ -477,6 +477,12 @@ gem 'faker', :git => 'https://github.com/faker-ruby/faker.git', :branch => 'main - [Faker::TvShows::VentureBros](doc/tv_shows/venture_bros.md) +
+ Locations + + - [Faker::Locations::Australia](doc/locations/australia.md) +
+ ## Contributing **Note**: We are not accepting proposals for new generators and locales. The [Contributing](CONTRIBUTING.md) guide has a few notes about this decision. diff --git a/doc/locations/australia.md b/doc/locations/australia.md new file mode 100644 index 0000000000..efa06a13ea --- /dev/null +++ b/doc/locations/australia.md @@ -0,0 +1,9 @@ +# Faker::Locations::Australia + +```ruby +Faker::Locations::Australia.location # => "Sydney" + +Faker::Locations::Australia.animal # => "Kangaroo" + +Faker::Locations::Australia.state # => "New South Wales" +``` diff --git a/lib/faker/locations/australia.rb b/lib/faker/locations/australia.rb index c0aeadf597..56ae93c9d0 100644 --- a/lib/faker/locations/australia.rb +++ b/lib/faker/locations/australia.rb @@ -1,47 +1,52 @@ # frozen_string_literal: true module Faker - class Australia < Base - class << self - ## - # Produces a location in Australia - # - # @return [String] - # - # @example - # Faker::Australia.location - # #=> "Sydney" - # - # @faker.version next - def location - fetch('australia.locations') - end + extend Deprecator - # Produces an Australian animal - # - # @return [String] - # - # @example - # Faker::Australia.animal - # #=> "Dingo" - # - # @faker.version next - def animal - fetch('australia.animals') - end + class Locations + class Australia < Base + class << self + ## + # Produces a location in Australia + # + # @return [String] + # + # @example + # Faker::Locations::Australia.location + # #=> "Sydney" + # + # @faker.version next + def location + fetch('locations.australia.locations') + end + + # Produces an Australian animal + # + # @return [String] + # + # @example + # Faker::Locations::Australia.animal + # #=> "Dingo" + # + # @faker.version next + def animal + fetch('locations.australia.animals') + end - # Produces an Australian State or Territory - # - # @return [String] - # - # @example - # Faker::Australia.state - # #=> "New South Wales" - # - # @faker.version next - def state - fetch('australia.states') + # Produces an Australian State or Territory + # + # @return [String] + # + # @example + # Faker::Locations::Australia.state + # #=> "New South Wales" + # + # @faker.version next + def state + fetch('locations.australia.states') + end end end end + deprecate_generator('Australia', Locations::Australia) end diff --git a/lib/locales/en/australia.yml b/lib/locales/en/australia.yml index 69864857c0..eb64d5be7f 100644 --- a/lib/locales/en/australia.yml +++ b/lib/locales/en/australia.yml @@ -1,107 +1,108 @@ en: faker: - australia: - locations: - - Brisbane - - Sydney - - Melbourne - - Perth - - Adelaide - - Gold Coast - - Newcastle - - Canberra - - Central Coast - - Sunshine Coast - - Wollongong - - Geelong - - Hobart - - Townsville - - Cairns - - Toowoomba - - Darwin - - Ballarat - - Bendigo - - Albury - - Launceston - - Mackay - - Rockhampton - - Bunbury - - Coffs Harbour - - Bundaberg - - Melton - - Wagga Wagga - - Hervey Bay - - Mildura – Wentworth - - Shepparton – Mooroopna - - Port Macquarie - - Gladstone – Tannum Sands - - Tamworth - - Traralgon – Morwell - - Orange - - Bowral – Mittagong - - Busselton - - Geraldton - - Dubbo - - Nowra – Bomaderry - - Warragul – Drouin - - Bathurst - - Warrnambool - - Albany - - Kalgoorlie - - Devonport - - Mount Gambier - - Lismore - - Nelson Bay - animals: - - Koala - - Humpback Whale - - Australian Fur Seal - - Wallaby - - Platypus - - Kangaroo - - Wombat - - Sugar Glider - - Flying Fox - - Tasmanian Devil - - Quokka - - Dugong - - Luaner - - Echidna - - Magpie - - Cockatoo - - Tawny Frogmouth - - Galah - - Lorikeet - - Pelican - - Cassowary - - Kookaburra - - Emu - - Lyrebird - - Barramundi - - Grouper - - Murray Cod - - Green Tree Frog - - Cane Toad - - Redback Spider - - Funnel Web Spider - - Blue Ringed Octopus - - Fresh Water Crocodile - - Skink - - Thorny Devil - - King Brown Snake - - Carpet Python - - Tiger Snake - - Red Bellied Black Snake - - Blue Tongue Lizard - - Frilled Neck Lizard - - Saltwater Crocodile - - Eastern Brown Snake - states: - - New South Wales - - Queensland - - Western Australia - - Northern Territory - - South Australia - - Australian Capital Territory - - Victoria - - Tasmania + locations: + australia: + locations: + - Brisbane + - Sydney + - Melbourne + - Perth + - Adelaide + - Gold Coast + - Newcastle + - Canberra + - Central Coast + - Sunshine Coast + - Wollongong + - Geelong + - Hobart + - Townsville + - Cairns + - Toowoomba + - Darwin + - Ballarat + - Bendigo + - Albury + - Launceston + - Mackay + - Rockhampton + - Bunbury + - Coffs Harbour + - Bundaberg + - Melton + - Wagga Wagga + - Hervey Bay + - Mildura – Wentworth + - Shepparton – Mooroopna + - Port Macquarie + - Gladstone – Tannum Sands + - Tamworth + - Traralgon – Morwell + - Orange + - Bowral – Mittagong + - Busselton + - Geraldton + - Dubbo + - Nowra – Bomaderry + - Warragul – Drouin + - Bathurst + - Warrnambool + - Albany + - Kalgoorlie + - Devonport + - Mount Gambier + - Lismore + - Nelson Bay + animals: + - Koala + - Humpback Whale + - Australian Fur Seal + - Wallaby + - Platypus + - Kangaroo + - Wombat + - Sugar Glider + - Flying Fox + - Tasmanian Devil + - Quokka + - Dugong + - Luaner + - Echidna + - Magpie + - Cockatoo + - Tawny Frogmouth + - Galah + - Lorikeet + - Pelican + - Cassowary + - Kookaburra + - Emu + - Lyrebird + - Barramundi + - Grouper + - Murray Cod + - Green Tree Frog + - Cane Toad + - Redback Spider + - Funnel Web Spider + - Blue Ringed Octopus + - Fresh Water Crocodile + - Skink + - Thorny Devil + - King Brown Snake + - Carpet Python + - Tiger Snake + - Red Bellied Black Snake + - Blue Tongue Lizard + - Frilled Neck Lizard + - Saltwater Crocodile + - Eastern Brown Snake + states: + - New South Wales + - Queensland + - Western Australia + - Northern Territory + - South Australia + - Australian Capital Territory + - Victoria + - Tasmania diff --git a/test/faker/location/test_faker_australia.rb b/test/faker/location/test_faker_australia.rb deleted file mode 100644 index 795da19ad6..0000000000 --- a/test/faker/location/test_faker_australia.rb +++ /dev/null @@ -1,21 +0,0 @@ -# frozen_string_literal: true - -require_relative '../../test_helper' - -class TestFakerAustralia < Test::Unit::TestCase - def setup - @tester = Faker::Australia - end - - def test_location - assert_match(/\w+/, @tester.location) - end - - def test_animal - assert_match(/\w+/, @tester.animal) - end - - def test_state - assert_match(/\w+/, @tester.state) - end -end diff --git a/test/faker/locations/test_faker_australia.rb b/test/faker/locations/test_faker_australia.rb new file mode 100644 index 0000000000..4e78113d62 --- /dev/null +++ b/test/faker/locations/test_faker_australia.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +require_relative '../../test_helper' + +class TestFakerLocationsAustralia < Test::Unit::TestCase + def test_location + assert_match(/\w+/, Faker::Locations::Australia.location) + end + + def test_animal + assert_match(/\w+/, Faker::Locations::Australia.animal) + end + + def test_state + assert_match(/\w+/, Faker::Locations::Australia.state) + end +end + +class TestFakerAustralia < Test::Unit::TestCase + def test_deprecated_location + assert_match(/\w+/, Faker::Australia.location) + end + + def test_deprecated_animal + assert_match(/\w+/, Faker::Australia.animal) + end + + def test_state + assert_match(/\w+/, Faker::Australia.state) + end +end diff --git a/test/test_determinism.rb b/test/test_determinism.rb index 69ddf28979..0dd805d125 100644 --- a/test/test_determinism.rb +++ b/test/test_determinism.rb @@ -102,6 +102,7 @@ def skipped_classes Internet JapaneseMedia LeagueOfLegends + Locations Movies Myst Overwatch