roman-name-generator 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.yardopts +1 -0
- data/Rakefile +1 -8
- data/lib/roman_name_generator.rb +31 -12
- data/lib/tasks/{console.rb → console.rake} +0 -0
- data/lib/tasks/doc.rake +4 -0
- data/lib/tasks/test.rake +6 -0
- data/lib/version.rb +1 -1
- data/roman-name-generator.gemspec +3 -0
- data/test/minitest_helper.rb +1 -1
- metadata +36 -10
data/.yardopts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--no-private --protected lib/**/*.rb - README.md LICENSE *.gemspec Rakefile Gemfile
|
data/Rakefile
CHANGED
@@ -5,12 +5,5 @@ require 'rubygems'
|
|
5
5
|
require 'rake'
|
6
6
|
require 'rake/testtask'
|
7
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
|
15
|
-
|
8
|
+
Dir.glob('lib/tasks/*.rake').each { |file| import file }
|
16
9
|
task :default => :test
|
data/lib/roman_name_generator.rb
CHANGED
@@ -3,28 +3,47 @@ require "version"
|
|
3
3
|
|
4
4
|
$:.unshift(File.dirname(__FILE__)+'/lib')
|
5
5
|
|
6
|
+
# The gems' namespace
|
6
7
|
module RomanNameGenerator
|
8
|
+
# The Generator class handles the loading and randomizing the json
|
9
|
+
# data store containing the roman name stub json. By default you only
|
10
|
+
# need to call the initializer, and as soon as it is instantiated,
|
11
|
+
# it builds a random roman name based on the gender given.
|
12
|
+
#
|
13
|
+
# To get a new name, either initialize a new generator, or call
|
14
|
+
# #regenerate
|
15
|
+
#
|
16
|
+
# Example:
|
17
|
+
# full_name = RomanNameGenerator::Generator.new("male").result
|
7
18
|
class Generator
|
8
19
|
|
9
|
-
|
10
|
-
"0.1.0"
|
11
|
-
end
|
12
|
-
|
13
|
-
attr_accessor :name_data, :gender, :result, :type
|
20
|
+
attr_accessor :name_data, :gender, :result
|
14
21
|
|
15
|
-
|
22
|
+
# Generates a random name and assigns it to #result
|
23
|
+
# @param [String] gender the name's gender, `male` or `female`, defaults to `male`
|
24
|
+
def initialize(gender="male")
|
16
25
|
self.gender = gender
|
17
|
-
|
26
|
+
generate
|
27
|
+
end
|
28
|
+
|
29
|
+
# Gives another random roman name based on the gender given in the
|
30
|
+
# constructor, assigns it to #result, and then returns #result
|
31
|
+
def regenerate
|
32
|
+
generate
|
18
33
|
end
|
19
34
|
|
20
35
|
private
|
36
|
+
|
37
|
+
def generate
|
38
|
+
self.result = random_name.strip
|
39
|
+
end
|
21
40
|
|
22
|
-
def random_name
|
41
|
+
def random_name
|
23
42
|
load_name_data if self.name_data.nil?
|
24
43
|
[random_first_name, random_middle_name, random_last_name].join(" ")
|
25
44
|
end
|
26
45
|
|
27
|
-
def random_first_name
|
46
|
+
def random_first_name
|
28
47
|
case self.gender
|
29
48
|
when "male"
|
30
49
|
data = self.name_data['praenomens']
|
@@ -35,7 +54,7 @@ module RomanNameGenerator
|
|
35
54
|
end
|
36
55
|
end
|
37
56
|
|
38
|
-
def random_middle_name
|
57
|
+
def random_middle_name
|
39
58
|
case self.gender
|
40
59
|
when "male"
|
41
60
|
data = self.name_data['nomens']['male']
|
@@ -45,7 +64,7 @@ module RomanNameGenerator
|
|
45
64
|
end
|
46
65
|
end
|
47
66
|
|
48
|
-
def random_last_name
|
67
|
+
def random_last_name
|
49
68
|
case self.gender
|
50
69
|
when "male"
|
51
70
|
data = self.name_data['cognomens']['male']
|
@@ -56,7 +75,7 @@ module RomanNameGenerator
|
|
56
75
|
end
|
57
76
|
end
|
58
77
|
|
59
|
-
def load_name_data
|
78
|
+
def load_name_data
|
60
79
|
self.name_data = JSON(
|
61
80
|
File.open(
|
62
81
|
File.expand_path("../data/names.json", __FILE__)
|
File without changes
|
data/lib/tasks/doc.rake
ADDED
data/lib/tasks/test.rake
ADDED
data/lib/version.rb
CHANGED
@@ -14,7 +14,10 @@ Gem::Specification.new do |gem|
|
|
14
14
|
gem.name = "roman-name-generator"
|
15
15
|
gem.require_paths = ["lib"]
|
16
16
|
gem.version = RomanNameGenerator::VERSION
|
17
|
+
gem.has_rdoc = 'yard'
|
17
18
|
|
19
|
+
gem.add_development_dependency('yard')
|
20
|
+
gem.add_development_dependency('redcarpet')
|
18
21
|
gem.add_development_dependency('minitest')
|
19
22
|
gem.add_development_dependency('mocha')
|
20
23
|
gem.add_development_dependency('turn')
|
data/test/minitest_helper.rb
CHANGED
@@ -40,7 +40,7 @@ Turn.config do |c|
|
|
40
40
|
# :pretty - new pretty reporter
|
41
41
|
# :marshal - dump output as YAML (normal run mode only)
|
42
42
|
# :cue - interactive testing
|
43
|
-
c.format = :
|
43
|
+
c.format = :cue
|
44
44
|
# turn on invoke/execute tracing, enable full backtrace
|
45
45
|
c.trace = true
|
46
46
|
# use humanized test names (works only with :outline format)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: roman-name-generator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,9 +11,31 @@ bindir: bin
|
|
11
11
|
cert_chain: []
|
12
12
|
date: 2012-03-16 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: yard
|
16
|
+
requirement: &2161015480 !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: *2161015480
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: redcarpet
|
27
|
+
requirement: &2161015060 !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: *2161015060
|
14
36
|
- !ruby/object:Gem::Dependency
|
15
37
|
name: minitest
|
16
|
-
requirement: &
|
38
|
+
requirement: &2161014640 !ruby/object:Gem::Requirement
|
17
39
|
none: false
|
18
40
|
requirements:
|
19
41
|
- - ! '>='
|
@@ -21,10 +43,10 @@ dependencies:
|
|
21
43
|
version: '0'
|
22
44
|
type: :development
|
23
45
|
prerelease: false
|
24
|
-
version_requirements: *
|
46
|
+
version_requirements: *2161014640
|
25
47
|
- !ruby/object:Gem::Dependency
|
26
48
|
name: mocha
|
27
|
-
requirement: &
|
49
|
+
requirement: &2161014220 !ruby/object:Gem::Requirement
|
28
50
|
none: false
|
29
51
|
requirements:
|
30
52
|
- - ! '>='
|
@@ -32,10 +54,10 @@ dependencies:
|
|
32
54
|
version: '0'
|
33
55
|
type: :development
|
34
56
|
prerelease: false
|
35
|
-
version_requirements: *
|
57
|
+
version_requirements: *2161014220
|
36
58
|
- !ruby/object:Gem::Dependency
|
37
59
|
name: turn
|
38
|
-
requirement: &
|
60
|
+
requirement: &2161013800 !ruby/object:Gem::Requirement
|
39
61
|
none: false
|
40
62
|
requirements:
|
41
63
|
- - ! '>='
|
@@ -43,10 +65,10 @@ dependencies:
|
|
43
65
|
version: '0'
|
44
66
|
type: :development
|
45
67
|
prerelease: false
|
46
|
-
version_requirements: *
|
68
|
+
version_requirements: *2161013800
|
47
69
|
- !ruby/object:Gem::Dependency
|
48
70
|
name: simplecov
|
49
|
-
requirement: &
|
71
|
+
requirement: &2161013380 !ruby/object:Gem::Requirement
|
50
72
|
none: false
|
51
73
|
requirements:
|
52
74
|
- - ! '>='
|
@@ -54,7 +76,7 @@ dependencies:
|
|
54
76
|
version: '0'
|
55
77
|
type: :development
|
56
78
|
prerelease: false
|
57
|
-
version_requirements: *
|
79
|
+
version_requirements: *2161013380
|
58
80
|
description: A fun generator to generate ancient roman names
|
59
81
|
email:
|
60
82
|
- james@rubyloves.me
|
@@ -63,13 +85,16 @@ extensions: []
|
|
63
85
|
extra_rdoc_files: []
|
64
86
|
files:
|
65
87
|
- .gitignore
|
88
|
+
- .yardopts
|
66
89
|
- Gemfile
|
67
90
|
- LICENSE
|
68
91
|
- README.md
|
69
92
|
- Rakefile
|
70
93
|
- lib/data/names.json
|
71
94
|
- lib/roman_name_generator.rb
|
72
|
-
- lib/tasks/console.
|
95
|
+
- lib/tasks/console.rake
|
96
|
+
- lib/tasks/doc.rake
|
97
|
+
- lib/tasks/test.rake
|
73
98
|
- lib/version.rb
|
74
99
|
- roman-name-generator.gemspec
|
75
100
|
- test/_shared_examples/male_roman_name_test.rb
|
@@ -105,3 +130,4 @@ test_files:
|
|
105
130
|
- test/lib/roman_name_generator_test.rb
|
106
131
|
- test/lib/version_test.rb
|
107
132
|
- test/minitest_helper.rb
|
133
|
+
has_rdoc: yard
|