Skip to content

Commit

Permalink
Add Faker::Military (#1283)
Browse files Browse the repository at this point in the history
* Added US Military ranks

Added US military ranks for Army, Navy, Air Force, and Marines. Also the
DOD Pay scale.

Signed-off-by: JJ Asghar <jj@chef.io>

* Update CHANGELOG.md
  • Loading branch information
JJ Asghar authored and vbrazo committed Jun 13, 2018
1 parent 31ef196 commit a7c03e6
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 1 deletion.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# Change Log

## HEAD Unreleased
### Latest update: 2018-06-11
### Latest update: 2018-06-13

### Feature Request
- [PR #1283](https://github.com/stympy/faker/pull/1283) Add Faker::Military [@jjasghar](https://github.com/jjasghar)
- [PR #1279](https://github.com/stympy/faker/pull/1279) Add Faker::HarryPotter.spell [@A9u](https://github.com/A9u)
- [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)
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ Contents
- [Faker::Matz](doc/matz.md)
- [Faker::Measurement](doc/measurement.md)
- [Faker::MichaelScott](doc/michael_scott.md)
- [Faker::Military](doc/military.md)
- [Faker::MostInterestingManInTheWorld](doc/most_interesting_man_in_the_world.md)
- [Faker::Movie](doc/movie.md)
- [Faker::Music](doc/music.md)
Expand Down
15 changes: 15 additions & 0 deletions doc/military.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Faker::Military

It might be available in the next version.

```ruby
Faker::Military.army_rank #=> "Staff Sergeant"

Faker::Military.marines_rank #=> "Gunnery Sergeant"

Faker::Military.navy_rank #=> "Seaman"

Faker::Military.air_force_rank #=> "Captain"

Faker::Military.dod_paygrade #=> "E-6"
```
25 changes: 25 additions & 0 deletions lib/faker/military.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module Faker
class Military < Base
class << self
def army_rank
fetch('military.army_rank')
end

def marines_rank
fetch('military.marines_rank')
end

def navy_rank
fetch('military.navy_rank')
end

def air_force_rank
fetch('military.air_force_rank')
end

def dod_paygrade
fetch('military.dod_paygrade')
end
end
end
end
8 changes: 8 additions & 0 deletions lib/locales/en/military.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
en:
faker:
military:
army_rank: ["Private","Private First Class","Specialist","Corporal","Sergeant","Staff Sergeant","Sergeant First Class","Master Sergeant","First Sergeant","Sergeant Major","Command Sergeant Major","Sergeant Major of the Army","Second Lieutenant","First Lieutenant","Captain","Major","Lieutenant Colonel","Colonel","Brigadier General","Major General","Lieutenant General","General","General of the Army","General of the Armies"]
marines_rank: ["Private","Private First Class","Lance Corporal","Corporal","Sergeant","Staff Sergeant","Gunnery Sergeant","Master Sergeant","First Sergeant","Master Gunnery Sergeant","Sergeant Major","Sergeant Major of the Marine Corps","Second Lieutenant","First Lieutenant","Captain","Major","Lieutenant Colonel","Colonel","Brigadier General","Major General","Lieutenant General","General"]
navy_rank: ["Seaman Recruit","Fireman Recruit","Airman Recruit","Constructionman Recruit","Seaman Apprentice","Fireman Apprentice","Airman Apprentice","Constructionman Apprentice","Seaman","Fireman","Airman","Constructionman","Petty Officer Third Class","Petty Officer Second Class","Petty Officer First Class","Chief Petty Officer","Senior Petty Officer","Master Chief Petty Officer","Command Senior Chief Petty Officer","Command Master Chief Petty Officer","Fleet Master Chief Petty Officer","Master Chief Petty Officer of the Navy","Ensign","Lieutenant","Lieutenant Commander","Commander","Captain","Rear Admiral","Vice Admiral","Admiral","Fleet Admiral","Admiral of the Navy"]
air_force_rank: ["Airman Basic","Airman First Class","Senior Airman","Staff Sergeant","Technical Sergeant","Master Sergeant","Senior Master Sergeant","Chief Master Sergeant","Command Chief Master Sergeant","Chief Master Sergeant of the Air Force","Second Lieutenant","First Lieutenant","Captain","Major","Lieutenant Colonel","Colonel","Brigadier General","Major General","Lieutenant General","General","General of the Air Force"]
dod_paygrade: ["E-1","E-2","E-3","E-4","E-5","E-6","E-7","E-8","E-9","O-1","O-2","O-3","O-4","O-5","O-6","O-7","O-8","O-9","O-10","Special"]
27 changes: 27 additions & 0 deletions test/test_faker_military.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
require File.expand_path(File.dirname(__FILE__) + '/test_helper.rb')

class TestFakerMilitary < Test::Unit::TestCase
def setup
@tester = Faker::Military
end

def test_army_rank
assert @tester.army_rank.match(/\w/)
end

def test_marines_rank
assert @tester.marines_rank.match(/\w/)
end

def test_navy_rank
assert @tester.navy_rank.match(/\w/)
end

def test_air_force_rank
assert @tester.air_force_rank.match(/\w/)
end

def test_dod_paygrade
assert @tester.dod_paygrade.match(/\w/)
end
end

0 comments on commit a7c03e6

Please sign in to comment.