Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
lovro-bikic committed Apr 26, 2021
2 parents 66724d5 + aa31845 commit 21e90fe
Show file tree
Hide file tree
Showing 11 changed files with 1,888 additions and 8 deletions.
12 changes: 6 additions & 6 deletions Gemfile.lock
Expand Up @@ -17,7 +17,7 @@ GEM
method_source (1.0.0)
minitest (5.14.4)
parallel (1.20.1)
parser (3.0.0.0)
parser (3.0.1.0)
ast (~> 2.4.1)
power_assert (2.0.0)
pry (0.14.1)
Expand All @@ -26,8 +26,8 @@ GEM
rainbow (3.0.0)
rake (13.0.3)
regexp_parser (2.1.1)
rexml (3.2.4)
rubocop (1.12.1)
rexml (3.2.5)
rubocop (1.13.0)
parallel (~> 1.10)
parser (>= 3.0.0.0)
rainbow (>= 2.2.2, < 4.0)
Expand All @@ -44,7 +44,7 @@ GEM
json (>= 1.8, < 3)
simplecov-html (~> 0.10.0)
simplecov-html (0.10.2)
test-unit (3.4.0)
test-unit (3.4.1)
power_assert
timecop (0.9.4)
unicode-display_width (2.0.0)
Expand All @@ -58,9 +58,9 @@ DEPENDENCIES
minitest (= 5.14.4)
pry (= 0.14.1)
rake (= 13.0.3)
rubocop (= 1.12.1)
rubocop (= 1.13.0)
simplecov (= 0.17.1, < 0.18)
test-unit (= 3.4.0)
test-unit (= 3.4.1)
timecop (= 0.9.4)
yard (= 0.9.26)

Expand Down
2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -207,6 +207,7 @@ gem 'faker', :git => 'https://github.com/faker-ruby/faker.git', :branch => 'mast
- [Faker::Stripe](doc/default/stripe.md)
- [Faker::Subscription](doc/default/subscription.md)
- [Faker::Superhero](doc/default/superhero.md)
- [Faker::Tea](doc/default/tea.md)
- [Faker::Team](doc/default/team.md)
- [Faker::Time](doc/default/time.md)
- [Faker::Twitter](doc/default/twitter.md)
Expand All @@ -233,6 +234,7 @@ gem 'faker', :git => 'https://github.com/faker-ruby/faker.git', :branch => 'mast

### Creature
- [Faker::Creature::Animal](doc/creature/animal.md)
- [Faker::Creature::Bird](doc/creature/bird.md)
- [Faker::Creature::Cat](doc/creature/cat.md)
- [Faker::Creature::Dog](doc/creature/dog.md)
- [Faker::Creature::Horse](doc/creature/horse.md)
Expand Down
42 changes: 42 additions & 0 deletions doc/creature/bird.md
@@ -0,0 +1,42 @@
# Faker::Creature::Bird

```ruby
# Random common family name of a bird
Faker::Creature::Bird.common_family_name #=> "Owls"

# Random taxonomic order from the class Aves (ie. those are birds)
Faker::Creature::Bird.order #=> "Passeriformes" # Fun fact, 60% of birds are Passeriformes!

# Random bird anatomy word
Faker::Creature::Bird.anatomy #=> "rump"

# Random bird anatomy word, in the past tense
Faker::Creature::Bird.anatomy_past_tense #=> "breasted"

# Random bird geography word
Faker::Creature::Bird.geo #=> "Eurasian"

# Random bird color word
Faker::Creature::Bird.color #=> "ferruginous"

# Random bird adjective word
Faker::Creature::Bird.adjective #=> "common"

# Random emotional adjective NOT typically used in bird names
Faker::Creature::Bird.emotional_adjective #=> "cantankerous"

# Random silly adjective NOT used in bird names
Faker::Creature::Bird.silly_adjective #=> "drunk"

# Random common name for a bird
Faker::Creature::Bird.common_name #=> 'wren'

# Random plausible common name for a bird
Faker::Creature::Bird.plausible_common_name #=> 'Hellinger's Wren'

# Random implausible common name for a bird
Faker::Creature::Bird.implausible_common_name #=> 'Hellinger's Cantankerous Chickadee'

# Returns a random pair order / common name pair
Faker::Creature::Bird.order_with_common_name #=> {:order=>"Coliiformes", :common_name=>"Mousebird"}
```
15 changes: 15 additions & 0 deletions doc/default/tea.md
@@ -0,0 +1,15 @@
# Faker::Tea

Available since version next.

```ruby
# Get a tea variety
Faker::Tea.variety # => "Earl Grey"

# Get a tea variety, by type of tea. Accepted types:
# ['Black', 'Green', 'Herbal', 'Oolong', 'White']
Faker::Tea.variety(type: 'Green') #=> "Jasmine"

# Get a type of tea
Faker::Tea.type #=> "Herbal"
```
4 changes: 2 additions & 2 deletions faker.gemspec
Expand Up @@ -32,12 +32,12 @@ Gem::Specification.new do |spec|
spec.add_development_dependency('minitest', '5.14.4')
spec.add_development_dependency('pry', '0.14.1')
spec.add_development_dependency('rake', '13.0.3')
spec.add_development_dependency('rubocop', '1.12.1')
spec.add_development_dependency('rubocop', '1.13.0')
# Workaround for cc-test-reporter with SimpleCov 0.18.
# Stop upgrading SimpleCov until the following issue will be resolved.
# https://github.com/codeclimate/test-reporter/issues/418
spec.add_development_dependency('simplecov', '0.17.1', '< 0.18')
spec.add_development_dependency('test-unit', '3.4.0')
spec.add_development_dependency('test-unit', '3.4.1')
spec.add_development_dependency('timecop', '0.9.4')
spec.add_development_dependency('yard', '0.9.26')
end
203 changes: 203 additions & 0 deletions lib/faker/creature/bird.rb
@@ -0,0 +1,203 @@
# frozen_string_literal: true

module Faker
class Creature
class Bird < Base
flexible :bird

class << self
##
# Produces a random common family name of a bird.
#
# @return [String]
#
# @example
# Faker::Creature::Bird.common_family_name #=> "Owls"
#
# @faker.version next
def common_family_name
fetch('creature.bird.common_family_name')
end

##
# Produces a random common taxonomic order from the class Aves
#
# @return [String]
#
# @example
# Faker::Creature::Bird.order #=> "Passeriformes"
#
# @faker.version next
def order
orders = I18n.translate('faker.creature.bird.order_common_map').keys
sample(orders).to_s
end

##
# Produces a random bird anatomy word
#
# @return [String]
#
# @example
# Faker::Creature::Bird.anatomy #=> "rump"
#
# @faker.version next
def anatomy
fetch('creature.bird.anatomy')
end

##
# Produces a random, past tensed bird anatomy word
#
# @return [String]
#
# @example
# Faker::Creature::Bird.anatomy #=> "breasted"
#
# @faker.version next
def anatomy_past_tense
fetch('creature.bird.anatomy_past_tense')
end

##
# Produces a random geographical word used in describing birds
#
# @return [String]
#
# @example
# Faker::Creature::Bird.geo #=> "Eurasian"
#
# @faker.version next
def geo
fetch('creature.bird.geo')
end

##
# Produces a random color word used in describing birds
#
# @return [String]
#
# @example
# Faker::Creature::Bird.color #=> "ferruginous"
#
# @faker.version next
def color
fetch('creature.bird.colors')
end

##
# Produces a random adjective used to described birds
#
# @return [String]
#
# @example
# Faker::Creature::Bird.adjective #=> 'common'
#
# @faker.version next
def adjective
fetch('creature.bird.adjectives')
end

##
# Produces a random emotional adjective NOT used to described birds
# ...but could be
#
# @return [String]
#
# @example
# Faker::Creature::Bird.emotional_adjective #=> 'cantankerous'
#
# @faker.version next
def emotional_adjective
fetch('creature.bird.emotional_adjectives')
end

##
# Produces a random adjective NOT used to described birds
# ...but probably shouldn't
#
# @return [String]
#
# @example
# Faker::Creature::Bird.silly_adjective #=> 'drunk'
#
# @faker.version next
def silly_adjective
fetch('creature.bird.silly_adjectives')
end

##
# Produces a random common name for a bird
#
# @param [String | Symbol | nil] tax_order Tax
# @return [String]
# @raises TypeError If `tax_order` cannot be converted into a Symbol
# @raises ArgumentError If `tax_order` is not a valid taxonomic order
#
# @example
# Faker::Creature::Bird.common_name #=> 'wren'
#
# @faker.version next
def common_name(tax_order = nil)
map = translate('faker.creature.bird.order_common_map')
if tax_order.nil?
sample(map.values.flatten).downcase
else
raise TypeError, 'tax_order parameter must be symbolizable' \
unless tax_order.respond_to?(:to_sym)
raise ArgumentError, "#{tax_order} is not a valid taxonomic order" \
unless map.keys.include?(tax_order.to_sym)

the_order = translate('faker.creature.bird.order_common_map')[tax_order.to_sym]
sample(the_order).downcase
end
end

##
# Produces a random and plausible common name for a bird
#
# @return [String]
#
# @example
# Faker::Creature::Bird.plausible_common_name #=> 'Hellinger's Wren'
#
# @faker.version next
def plausible_common_name
parse('creature.bird.plausible_common_names').capitalize
end

##
# Produces a random and IMplausible common name for a bird
#
# @return [String]
#
# @example
# Faker::Creature::Bird.implausible_common_name #=> 'Hellinger's Cantankerous Chickadee'
#
# @faker.version next
def implausible_common_name
parse('creature.bird.implausible_common_names').capitalize
end

##
# Produces a hash entry with a random order and a random common name
# that is of that order
#
# @return [Hash<order,common_name>]
#
# @example
# Faker::Creature::Bird.order_with_common_name #=> {
# order: ''Accipitriformes',
# common_name: 'Osprey'
# }
#
# @faker.version next
def order_with_common_name(tax_order = nil)
map = I18n.translate('faker.creature.bird.order_common_map')
o = tax_order.nil? ? order : tax_order
{ order: o, common_name: sample(map[o.to_sym]) }
end
end
end
end
end
41 changes: 41 additions & 0 deletions lib/faker/default/tea.rb
@@ -0,0 +1,41 @@
# frozen_string_literal: true

module Faker
class Tea < Base
flexible :tea

class << self
##
# Produces a random variety or blend of tea.
#
# @param type [String, nil] the type of tea to query for (valid types: 'Black', 'Green', 'Oolong', 'White', and 'Herbal')
# @return [String] a variety of tea
#
# @example
# Faker::Tea.variety
# #=> "Earl Grey"
#
# @example
# Faker::Tea.variety(type: 'Green')
# #=> "Jasmine"
# @faker.version next
def variety(type: nil)
type ||= fetch('tea.type')
fetch "tea.variety.#{type.downcase}"
end

##
# Produces a random type of tea.
#
# @return [String] a type of tea
#
# @example
# Faker::Tea.type
# #=> "Green"
# @faker.version next
def type
fetch 'tea.type'
end
end
end
end

0 comments on commit 21e90fe

Please sign in to comment.