roman-name-generator 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in roman-name-generator.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 James OKelly
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,29 @@
1
+ # RomanNameGenerator
2
+
3
+ I have been working on a web-based gladiator game and needed to generate roman names. I ended up pulling this gem out of the app at the request of a few friends who apparently, wanted a roman name!
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'roman-name-generator'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install roman-name-generator
18
+
19
+ ## Usage
20
+
21
+ full_name = RomanNameGenerator.Generator.new("male").result
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
3
+
4
+ require 'rubygems'
5
+ require 'rake'
6
+ require 'rake/testtask'
7
+
8
+
9
+ Rake::TestTask.new do |t|
10
+ t.libs.push "lib"
11
+ t.libs.push "test"
12
+ t.test_files = FileList['test/**/*_test.rb']
13
+ t.verbose = true
14
+ end
@@ -0,0 +1,90 @@
1
+ {
2
+ "praenomens":[
3
+ "Appius", "Aulus", "Caius", "Gnaeus", "Decimus", "Kaeso", "Lucius",
4
+ "Marcus", "Manius", "Mamercus", "Numerius", "Publius", "Quintus",
5
+ "Servius", "Sextus", "Spurius", "Titus", "Tiberius", "Vibius"
6
+ ],
7
+ "nomens": {
8
+ "male":[
9
+ "Acci", "Acili", "Aeli", "Aemili", "Afrani", "Anni", "Annae", "Antoni",
10
+ "Appulei", "Apusti", "Aquilli", "Atili", "Atti", "Aufidi", "Aureli",
11
+ "Caecili", "Caedici", "Calpurni", "Carvili", "Cassi", "Claudi", "Clodi",
12
+ "Coccei", "Coeli", "Corneli", "Cornifici", "Coruncani", "Cremuti",
13
+ "Curi", "Deci", "Didi", "Domiti", "Duili", "Enni", "Fabi", "Fabrici",
14
+ "Fanni", "Flamini", "Flavi", "Fufi", "Fulvi", "Fundani", "Furi",
15
+ "Gelli", "Genuci", "Gracch", "Helividi", "Hermini", "Hirti", "Horati",
16
+ "Hortensi", "Hostili", "Iuli", "Iuni", "Iuventi", "Labien", "Laeli",
17
+ "Larci", "Licini", "Livi", "Lucreti", "Lutati", "Macci", "Mamili",
18
+ "Manli", "Marci", "Mari", "Minuci", "Muci", "Mummi", "Munati", "Nauti",
19
+ "Norban", "Octavi", "Opeli", "Opimi", "Otacili", "Ovidi", "Papiri",
20
+ "Petilli", "Petroni", "Plini", "Pompei", "Pompili", "Popilli",
21
+ "Pomponi", "Porci", "Postumi", "Pupi", "Quincti", "Rupili", "Rutili",
22
+ "Salvi", "Scriboni", "Semproni", "Sergi", "Servili", "Sosi", "Sulpici",
23
+ "Tarquini", "Terenti", "Tituri", "Tulli", "Ulpi", "Valeri", "Vatini",
24
+ "Vibi", "Vipsani", "Virgili", "Volcaci", "Volumni", "Volusi"
25
+ ],
26
+ "female":[
27
+ "Acci", "Acili", "Aeli", "Aemili", "Afrani", "Anni", "Annae",
28
+ "Antoni", "Appulei", "Apusti", "Aquilli", "Atili", "Atti", "Aufidi",
29
+ "Aureli", "Caecili", "Caedici", "Calpurni", "Carvili", "Cassi",
30
+ "Claudi", "Clodi", "Coccei", "Coeli", "Corneli", "Cornifici",
31
+ "Coruncani", "Cremuti", "Curi", "Deci", "Didi", "Domiti", "Duili",
32
+ "Enni", "Fabi", "Fabrici", "Fanni", "Flamini", "Flavi", "Fufi",
33
+ "Fulvi", "Fundani", "Furi", "Gelli", "Genuci", "Gracch", "Helividi",
34
+ "Hermini", "Hirti", "Horati", "Hortensi", "Hostili", "Iuli", "Iuni",
35
+ "Iuventi", "Labien", "Laeli", "Larci", "Licini", "Livi", "Lucreti",
36
+ "Lutati", "Macci", "Mamili", "Manli", "Marci", "Mari", "Minuci",
37
+ "Muci", "Mummi", "Munati", "Nauti", "Norban", "Octavi", "Opeli",
38
+ "Opimi", "Otacili", "Ovidi", "Papiri", "Petilli", "Petroni", "Plini",
39
+ "Pompei", "Pompili", "Popilli", "Pomponi", "Porci", "Postumi", "Pupi",
40
+ "Quincti", "Rupili", "Rutili", "Salvi", "Scriboni", "Semproni",
41
+ "Sergi", "Servili", "Sosi", "Sulpici", "Tarquini", "Terenti",
42
+ "Tituri", "Tulli", "Ulpi", "Valeri", "Vatini", "Vibi", "Vipsani",
43
+ "Virgili", "Volcaci", "Volumni", "Volusi"
44
+ ]
45
+ },
46
+ "cognomens":{
47
+ "male":[
48
+ "Aemilianus", "Afer", "Africanus", "Agrippa", "Ahenobarbus", "Albinus",
49
+ "Alexander", "Aquila", "Arbiter", "Asina", "Atilius", "Atticus",
50
+ "Balbinus", "Barbula", "Bassianus", "Bassus", "Blaesus", "Blandus",
51
+ "Britannicus", "Brutus", "Caecus", "Caepio", "Caesar", "Caesoninus",
52
+ "Caligula", "Calvus", "Capito", "Carus", "Caracalla", "Carausius",
53
+ "Carbo", "Catalina", "Cato", "Catullus", "Catulus", "Caudinus", "Celer",
54
+ "Censorinus", "Centumalus", "Cethegus", "Cicero", "Cinna", "Classicus",
55
+ "Clarus", "Clodianus", "Constantinus", "Corvus", "Cotta", "Crassus",
56
+ "Crispinus", "Cunctator", "Curio", "Cursor", "Dentatus", "Diadematus",
57
+ "Drusus", "Eburnus", "Etruscus", "Fabatus", "Falco", "Ferox",
58
+ "Flaccus", "Flaminius", "Firmus", "Fundulus", "Galba", "Gallus",
59
+ "Geminus", "Germanicus", "Geta", "Glabrio", "Gracchus", "Hadrianus",
60
+ "Hispallus", "Hypsaeus", "Iunior", "Iustus", "Labeo", "Laevinus",
61
+ "Lentulus", "Lepidus", "Libo", "Licinius", "Ligus", "Livianus",
62
+ "Longinus", "Longus", "Lucanus", "Lucullus", "Lupus", "Luscinus",
63
+ "Macrinus", "Magnus", "Malleolus", "Mancinus", "Marcellus", "Martialis",
64
+ "Maro", "Maximus", "Megellus", "Merula", "Messalla", "Metellus",
65
+ "Milo", "Murena", "Nasica", "Naso", "Nepos", "Nero", "Nerva",
66
+ "Nobilior", "Octavianus", "Otho", "Pacilus", "Paetinus", "Paetus",
67
+ "Pansa", "Paterculus", "Paulus", "Philippus", "Philo", "Pictor", "Piso",
68
+ "Pius", "Plancus", "Plautus", "Pollio", "Porcina", "Priscus", "Pulcher",
69
+ "Pullus", "Purpurio", "Quietus", "Ravilla", "Regulus", "Rufinus",
70
+ "Rufus", "Rullianus", "Ruso", "Sabinus", "Salinator", "Saturninus",
71
+ "Scaevola", "Scipio", "Secundus", "Seneca", "Severus", "Servilianus",
72
+ "Silanus", "Sophus", "Sparsus", "Spurinus", "Strabo", "Sulla", "Sura",
73
+ "Tacitus", "Tamphilus", "Tappulus", "Tertullus", "Tiro", "Torquatus",
74
+ "Trajanus", "Tremulus", "Tranquillus", "Tullus", "Turrinus", "Ursus",
75
+ "Varro", "Varus", "Valens", "Verus", "Vespasianus", "Victorinus",
76
+ "Vulso"
77
+ ],
78
+ "female":[
79
+ "Agrippina", "Alfidia", "Alypia", "Attica", "Atia", "Aurelia",
80
+ "Baebiana", "Clara", "Caesonia", "Crispina", "Cornificia", "Domitia",
81
+ "Domitilla", "Domna", "Etruscilla", "Euphemia", "Eutropia", "Fadilla",
82
+ "Faustina", "Fausta", "Fannia", "Flacilla", "Fundania", "Galeria",
83
+ "Lepida", "Longina", "Lucilla", "Mamaea", "Matidia", "Metella",
84
+ "Messalina", "Orbiana", "Paulina", "Paetina", "Placidia", "Plancina",
85
+ "Popillia", "Poppaea", "Porcia", "Prisca", "Proba", "Primia",
86
+ "Quintilla", "Roscia", "Sabina", "Secundia", "Severa", "Severina",
87
+ "Supera", "Terentia", "Tertia", "Tertulla", "Titiana"
88
+ ]
89
+ }
90
+ }
@@ -0,0 +1,62 @@
1
+ require 'json'
2
+ require "version"
3
+
4
+ $:.unshift(File.dirname(__FILE__)+'/lib')
5
+
6
+ module RomanNameGenerator
7
+ class Generator
8
+ attr_accessor :name_data, :gender, :result, :type
9
+
10
+ def initialize(gender)
11
+ self.gender = gender
12
+ self.result = random_name.strip
13
+ end
14
+
15
+ private
16
+
17
+ def random_name
18
+ load_name_data if self.name_data.nil?
19
+ [random_first_name, random_middle_name, random_last_name].join(" ")
20
+ end
21
+
22
+ def random_first_name
23
+ case self.gender
24
+ when "male"
25
+ data = self.name_data['praenomens']
26
+ data[rand(data.length)]
27
+ when "female"
28
+ data = self.name_data['nomens']['female']
29
+ data[rand(data.length)]
30
+ end
31
+ end
32
+
33
+ def random_middle_name
34
+ case self.gender
35
+ when "male"
36
+ data = self.name_data['nomens']['male']
37
+ data[rand(data.length)]
38
+ when "female"
39
+ ""
40
+ end
41
+ end
42
+
43
+ def random_last_name
44
+ case self.gender
45
+ when "male"
46
+ data = self.name_data['cognomens']['male']
47
+ data[rand(data.length)]
48
+ when "female"
49
+ data = self.name_data['cognomens']['female']
50
+ data[rand(data.length)]
51
+ end
52
+ end
53
+
54
+ def load_name_data
55
+ self.name_data = JSON(
56
+ File.open(
57
+ File.expand_path("../data/names.json", __FILE__)
58
+ ).read
59
+ )
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,3 @@
1
+ module RomanNameGenerator
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["James OKelly"]
6
+ gem.email = ["james@rubyloves.me"]
7
+ gem.description = %q{A fun generator to generate ancient roman names}
8
+ gem.summary = %q{A fun generator to generate ancient roman names}
9
+ gem.homepage = ""
10
+
11
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
12
+ gem.files = `git ls-files`.split("\n")
13
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
14
+ gem.name = "roman-name-generator"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = RomanNameGenerator::VERSION
17
+
18
+ gem.add_development_dependency('rake')
19
+ gem.add_development_dependency('minitest')
20
+ gem.add_development_dependency('mocha')
21
+ gem.add_development_dependency('turn')
22
+ end
@@ -0,0 +1,41 @@
1
+ require 'minitest_helper'
2
+
3
+ shared_examples_for 'a male roman name' do
4
+ describe "Generator" do
5
+ before do
6
+ @subject = RomanNameGenerator::Generator.new("male")
7
+ end
8
+
9
+ describe "#load_name_data" do
10
+ it "must set name_data" do
11
+ @subject.send(:name_data=, nil)
12
+ @subject.send(:load_name_data)
13
+ @subject.send(:name_data)['praenomens'][0].must_equal "Appius"
14
+ end
15
+ end
16
+
17
+ describe "#random_first_name" do
18
+ it "must have a first_name" do
19
+ @subject.send(:random_first_name).size.must_be :>, 0
20
+ end
21
+ end
22
+
23
+ describe "#random_middle_name" do
24
+ it "must have a middle_name" do
25
+ @subject.send(:random_middle_name).size.must_be :>, 0
26
+ end
27
+ end
28
+
29
+ describe "#random_last_name" do
30
+ it "must have a last_name" do
31
+ @subject.send(:random_last_name).size.must_be :>, 0
32
+ end
33
+ end
34
+
35
+ describe "#random_name" do
36
+ it "must have 3 segments to the name" do
37
+ @subject.send(:random_name).split(" ").size.must_be :==, 3
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,7 @@
1
+ require 'minitest_helper'
2
+
3
+ describe RomanNameGenerator::Generator do
4
+
5
+ it_must_behave_like 'a male roman name'
6
+
7
+ end
@@ -0,0 +1,46 @@
1
+ require 'minitest/spec'
2
+ require 'minitest/autorun'
3
+ require 'mocha'
4
+ require 'turn'
5
+ require 'simplecov'
6
+ SimpleCov.start
7
+
8
+ $:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
9
+ $:.unshift File.join(File.dirname(__FILE__), '..', 'test')
10
+
11
+ require 'generator'
12
+
13
+ MiniTest::Spec.class_eval do
14
+ def self.shared_examples
15
+ @shared_examples ||= {}
16
+ end
17
+ end
18
+
19
+ module MiniTest::Spec::SharedExamples
20
+ def shared_examples_for(desc, &block)
21
+ MiniTest::Spec.shared_examples[desc] = block
22
+ end
23
+
24
+ def it_must_behave_like(desc)
25
+ self.instance_eval do
26
+ MiniTest::Spec.shared_examples[desc].call
27
+ end
28
+ end
29
+ end
30
+
31
+ Object.class_eval { include(MiniTest::Spec::SharedExamples) }
32
+
33
+ Turn.config do |c|
34
+ # use one of output formats:
35
+ # :outline - turn's original case/test outline mode [default]
36
+ # :progress - indicates progress with progress bar
37
+ # :dotted - test/unit's traditional dot-progress mode
38
+ # :pretty - new pretty reporter
39
+ # :marshal - dump output as YAML (normal run mode only)
40
+ # :cue - interactive testing
41
+ c.format = :outline
42
+ # turn on invoke/execute tracing, enable full backtrace
43
+ c.trace = true
44
+ # use humanized test names (works only with :outline format)
45
+ c.natural = true
46
+ end
metadata ADDED
@@ -0,0 +1,104 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: roman-name-generator
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - James OKelly
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-03-16 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rake
16
+ requirement: &2160960260 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *2160960260
25
+ - !ruby/object:Gem::Dependency
26
+ name: minitest
27
+ requirement: &2160959840 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *2160959840
36
+ - !ruby/object:Gem::Dependency
37
+ name: mocha
38
+ requirement: &2160959380 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *2160959380
47
+ - !ruby/object:Gem::Dependency
48
+ name: turn
49
+ requirement: &2160958940 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *2160958940
58
+ description: A fun generator to generate ancient roman names
59
+ email:
60
+ - james@rubyloves.me
61
+ executables: []
62
+ extensions: []
63
+ extra_rdoc_files: []
64
+ files:
65
+ - .gitignore
66
+ - Gemfile
67
+ - LICENSE
68
+ - README.md
69
+ - Rakefile
70
+ - lib/data/names.json
71
+ - lib/generator.rb
72
+ - lib/version.rb
73
+ - roman-name-generator.gemspec
74
+ - test/_shared_examples/male_roman_name_test.rb
75
+ - test/lib/generator_test.rb
76
+ - test/minitest_helper.rb
77
+ homepage: ''
78
+ licenses: []
79
+ post_install_message:
80
+ rdoc_options: []
81
+ require_paths:
82
+ - lib
83
+ required_ruby_version: !ruby/object:Gem::Requirement
84
+ none: false
85
+ requirements:
86
+ - - ! '>='
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ required_rubygems_version: !ruby/object:Gem::Requirement
90
+ none: false
91
+ requirements:
92
+ - - ! '>='
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ requirements: []
96
+ rubyforge_project:
97
+ rubygems_version: 1.8.10
98
+ signing_key:
99
+ specification_version: 3
100
+ summary: A fun generator to generate ancient roman names
101
+ test_files:
102
+ - test/_shared_examples/male_roman_name_test.rb
103
+ - test/lib/generator_test.rb
104
+ - test/minitest_helper.rb