Skip to content

Commit

Permalink
Add Faker::Construction (#1341)
Browse files Browse the repository at this point in the history
* add materials

* add subcontract_category

* add docs

* Update CHANGELOG.md

* Update test_faker_construction.rb
  • Loading branch information
benwyrosdick authored and vbrazo committed Aug 28, 2018
1 parent 86a9fcf commit 153321d
Show file tree
Hide file tree
Showing 6 changed files with 114 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
### Feature Request
- [PR #1342](https://github.com/stympy/faker/pull/1342) Added Faker::CryptoCoin scope [@jacksonpires](https://github.com/jacksonpires)
- [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::CryptoCoin](doc/crypto_coin.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

```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

0 comments on commit 153321d

Please sign in to comment.