diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d8cf18a91..b8b3aacef9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/README.md b/README.md index 38566f9914..987f71d31d 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/doc/military.md b/doc/military.md new file mode 100644 index 0000000000..5510e5fc63 --- /dev/null +++ b/doc/military.md @@ -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" +``` diff --git a/lib/faker/military.rb b/lib/faker/military.rb new file mode 100644 index 0000000000..03c873a962 --- /dev/null +++ b/lib/faker/military.rb @@ -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 diff --git a/lib/locales/en/military.yml b/lib/locales/en/military.yml new file mode 100644 index 0000000000..ac0a6cfc57 --- /dev/null +++ b/lib/locales/en/military.yml @@ -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"] diff --git a/test/test_faker_military.rb b/test/test_faker_military.rb new file mode 100644 index 0000000000..b0007748eb --- /dev/null +++ b/test/test_faker_military.rb @@ -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