Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Faker::Construction #1341

Merged
merged 5 commits into from
Aug 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

### Feature Request
- [PR #1338](https://github.com/stympy/faker/pull/1338) Add new translations to the en-ZA locale [@bradleymarques](https://github.com/bradleymarques)
- [PR #1341](https://github.com/stympy/faker/pull/1341) Add Faker::Construction [@benwyrosdick](https://github.com/benwyrosdick)
- [PR #1130](https://github.com/stympy/faker/pull/1130) Faker::Vehicle API updates [@lucasqueiroz](https://github.com/lucasqueiroz)
- [PR #1324](https://github.com/stympy/faker/pull/1319) Add Faker::SouthAfrica [@bradleymarques](https://github.com/bradleymarques)
- [PR #1319](https://github.com/stympy/faker/pull/1319) Added Faker::DC Comics [@JoelLindow](https://github.com/JoelLindow)
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ Contents
- [Faker::Community](doc/community.md)
- [Faker::Company](doc/company.md)
- [Faker::Compass](doc/compass.md)
- [Faker::Construction](doc/construction.md)
- [Faker::Cosmere](doc/cosmere.md)
- [Faker::Crypto](doc/crypto.md)
- [Faker::Currency](doc/currency.md)
Expand Down
11 changes: 11 additions & 0 deletions doc/construction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Faker::Construction

Available in future versions of faker
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍


```ruby
# Random material
Faker::Construction.material #=> "Wood"

# Random subcontract category
Faker::Construction.subcontract_category #=> "Curb & Gutter"
```
13 changes: 13 additions & 0 deletions lib/faker/construction.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

module Faker
class Construction < Base
def self.material
fetch('construction.materials')
end

def self.subcontract_category
fetch('construction.subcontract_categories')
end
end
end
63 changes: 63 additions & 0 deletions lib/locales/en/construction.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
en:
faker:
construction:
materials: [
"Aluminum",
"Brass",
"Glass",
"Granite",
"Plastic",
"Plexiglass",
"Rubber",
"Steel",
"Stone",
"Vinyl",
"Wood"
]
subcontract_categories: [
"Asphalt Paving",
"Casework",
"Construction Clean and Final Clean",
"Curb & Gutter",
"Doors, Frames & Hardware",
"Drilled Shafts",
"Drywall & Acoustical (FED)",
"Drywall & Acoustical (MOB)",
"EIFS",
"Electrical and Fire Alarm",
"Electrical",
"Elevator",
"Epoxy Flooring",
"Exterior Signage",
"Fire Protection",
"Fire Sprinkler System",
"Framing (Steel)",
"Framing (Wood)",
"Glass & Glazing",
"Granite Surfaces",
"HVAC",
"Hard Tile & Stone",
"Landscaping & Irrigation",
"Marlite Panels (FED)",
"Masonry & Precast",
"Masonry",
"Ornamental Railings",
"Overhead Doors",
"Painting & Vinyl Wall Covering",
"Plumbing & Medical Gas",
"Prefabricated Aluminum Metal Canopies",
"RF Shielding",
"Rebar & Wire Mesh Install",
"Retaining Wall and Brick Pavers",
"Roofing (Asphalt)",
"Roofing (Metal)",
"Site Furnishings",
"Sitework & Site Utilities",
"Soft Flooring and Base",
"Structural & Misc Steel Erection",
"Structural and Misc Steel (Fabrication)",
"Temp Fencing, Decorative Fencing and Gates",
"Termite Control",
"Wall Protection",
"Waterproofing & Caulking"
]
25 changes: 25 additions & 0 deletions test/test_faker_construction.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# frozen_string_literal: true

require_relative 'test_helper'

class TestFakerConstruction < Test::Unit::TestCase
def setup
Faker::Config.locale = nil
end

def test_material
assert Faker::Construction.material.match(/[\w]+/)
end

def test_subcontract_category
assert Faker::Construction.material.match(/[\w]+/)
end

def test_locales
[nil, 'en'].each do |locale_name|
Faker::Config.locale = locale_name
assert Faker::Construction.material.is_a? String
assert Faker::Construction.subcontract_category.is_a? String
end
end
end