Skip to content

Commit

Permalink
Add Faker::ElectricalComponents (#799)
Browse files Browse the repository at this point in the history
* test setup added for electrical components, test is included in test utput when running rake task, all tests pass

* add require path to faker.rb, add elec component file in faker/, test assertion for active class added, implementation in progress

* test passes for active method, more additions to come

* add Electrical Components - active  to docs

* passive test passing, add passive components to en.yml

* add docs for passive

* add test and functionality for electromechanical components, all tests pass

* add docs for electromechanical

* remove unnecessary class << self code

* fix spacing and indentation

* Update changelog.md

* Update readme.md

* Minor change
  • Loading branch information
bheim6 authored and vbrazo committed Jun 11, 2018
1 parent c5c5e15 commit 15d2cf4
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
### Latest update: 2018-06-11

### Feature Request
- [PR #799](https://github.com/stympy/faker/pull/799) Faker::ElectricalComponents [@bheim6](https://github.com/bheim6)
- [PR #1050](https://github.com/stympy/faker/pull/1050) Add Faker::Invoice to generate valid bank slip references [@onnimonni](https://github.com/onnimonni)
- [PR #817](https://github.com/stympy/faker/pull/817) Faker::Lorem.multibyte for multibyte chars [@frankywahl](https://github.com/frankywahl)
- [PR #877](https://github.com/stympy/faker/pull/877) Add Canada SIN generator in Faker::Code [@gkunwar](https://github.com/gkunwar)
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ Contents
- [Faker::Dune](doc/dune.md)
- [Faker::Educator](doc/educator.md)
- [Faker::ElderScrolls](doc/elder_scrolls.md)
- [Faker::ElectricalComponents](doc/electrical_components.md)
- [Faker::Esport](doc/esport.md)
- [Faker::Fallout](doc/fallout.md)
- [Faker::FamilyGuy](doc/family_guy.md)
Expand Down
11 changes: 11 additions & 0 deletions doc/electrical_components.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Faker::ElectricalComponents

It might be available in the next version.

```ruby
Faker::ElectricalComponents.active #=> "Transistor"

Faker::ElectricalComponents.passive #=> "Resistor"

Faker::ElectricalComponents.electromechanical #=> "Toggle Switch"
```
19 changes: 19 additions & 0 deletions lib/faker/electrical_components.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module Faker
class ElectricalComponents < Base
flexible :electrical_components

class << self
def active
fetch('electrical_components.active')
end

def passive
fetch('electrical_components.passive')
end

def electromechanical
fetch('electrical_components.electromechanical')
end
end
end
end
6 changes: 6 additions & 0 deletions lib/locales/en/electrical_components.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
en:
faker:
electrical_components:
active: ["Diode", "LED", "Rectifier", "Transistor", "JFET", "MOSFET", "Integrated Circuit", "LCD", "Cathode Ray Tube", "Vacuum Tube", "Battery", "Fuel Cell", "Power Supply"]
passive: ["Resistor", "Potentiometer", "Trim Pot", "Varistor", "Capacitor", "Varicap Diode", "Inductor", "Transformer", "Generator", "Motor", "Solenoid", "Magnetic Amplifier", "Speaker", "Motion Sensor", "Accelerometer", "Thermocouple", "Antenna", "Oscillator", "Breadboard"]
electromechanical: ["Piezoelectric device", "crystal", "Ultrasonic Motor", "Terminal", "Socket", "Power Cord", "Toggle Switch", "Slide Switch", "DIP Switch", "Footswitch", "Keypad", "Circuit Breaker", "Fuse", "Printed Circuit Board"]
19 changes: 19 additions & 0 deletions test/test_faker_electrical_components.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
require File.expand_path(File.dirname(__FILE__) + '/test_helper.rb')

class TestFakerElectricalComponents < Test::Unit::TestCase
def setup
@tester = Faker::ElectricalComponents
end

def test_active
assert @tester.active.match(/\w+/)
end

def test_passive
assert @tester.passive.match(/\w+/)
end

def test_electromechanical
assert @tester.electromechanical.match(/\w+/)
end
end

0 comments on commit 15d2cf4

Please sign in to comment.