random-word 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY.markdown +4 -0
- data/VERSION +1 -1
- data/lib/random_word.rb +13 -6
- data/spec/random_word/machinist_spec.rb +20 -4
- data/spec/random_word_spec.rb +3 -0
- metadata +19 -19
data/HISTORY.markdown
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.2.0
|
data/lib/random_word.rb
CHANGED
@@ -38,20 +38,27 @@ module RandomWord
|
|
38
38
|
|
39
39
|
class << self
|
40
40
|
|
41
|
-
# Random noun enumerator
|
42
|
-
#
|
43
|
-
# @return [Enumerator]
|
41
|
+
# @return [Enumerator] Random noun enumerator
|
44
42
|
def nouns
|
45
43
|
@nouns ||= enumerator(load_word_list("nouns.dat"))
|
46
44
|
end
|
47
45
|
|
48
|
-
# Random adjective enumerator
|
49
|
-
#
|
50
|
-
# @return [Enumerator]
|
46
|
+
# @return [Enumerator] Random adjective enumerator
|
51
47
|
def adjs
|
52
48
|
@adjs ||= enumerator(load_word_list("adjs.dat"))
|
53
49
|
end
|
54
50
|
|
51
|
+
# @return [Enumerator] Random phrase enumerator
|
52
|
+
def phrases
|
53
|
+
@phrases ||= Enumerator.new(Class.new do
|
54
|
+
def each()
|
55
|
+
while true
|
56
|
+
yield "#{RandomWord.adjs.next} #{RandomWord.nouns.next}"
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end.new)
|
60
|
+
end
|
61
|
+
|
55
62
|
# Create a random, non-repeating enumerator for a list of words
|
56
63
|
# (or anything really).
|
57
64
|
def enumerator(word_list)
|
@@ -5,18 +5,34 @@ require 'machinist/lathe'
|
|
5
5
|
require 'random_word/machinist'
|
6
6
|
|
7
7
|
describe RandomWord::Machinist do
|
8
|
-
let(:klass){ Class.new(Struct.new(:name)) do
|
8
|
+
let(:klass){ Class.new(Struct.new(:name,:role)) do
|
9
9
|
extend Machinist::Machinable
|
10
10
|
end
|
11
11
|
}
|
12
12
|
|
13
13
|
it "allows the use of #sw in blue prints" do
|
14
14
|
klass.blueprint do
|
15
|
-
name
|
16
|
-
serial_word
|
17
|
-
end
|
15
|
+
name {sw}
|
18
16
|
end
|
19
17
|
klass.make.name.should_not be_nil
|
20
18
|
end
|
21
19
|
|
20
|
+
it "allows the use of #serial_word in blue prints" do
|
21
|
+
klass.blueprint do
|
22
|
+
name {serial_word}
|
23
|
+
end
|
24
|
+
klass.make.name.should_not be_nil
|
25
|
+
end
|
26
|
+
|
27
|
+
it "return same word for each call to serial_word" do
|
28
|
+
klass.blueprint do
|
29
|
+
name {serial_word}
|
30
|
+
role {serial_word}
|
31
|
+
end
|
32
|
+
|
33
|
+
klass.make.tap do |obj|
|
34
|
+
obj.name.should == obj.role
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
22
38
|
end
|
data/spec/random_word_spec.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: random-word
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,12 +9,12 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-
|
12
|
+
date: 2011-11-02 00:00:00.000000000 -06:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rspec
|
17
|
-
requirement: &
|
17
|
+
requirement: &2158885620 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ~>
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: 2.3.0
|
23
23
|
type: :development
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *2158885620
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: yard
|
28
|
-
requirement: &
|
28
|
+
requirement: &2158885140 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ~>
|
@@ -33,10 +33,10 @@ dependencies:
|
|
33
33
|
version: 0.6.0
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *2158885140
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: bundler
|
39
|
-
requirement: &
|
39
|
+
requirement: &2158884660 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
42
42
|
- - ~>
|
@@ -44,10 +44,10 @@ dependencies:
|
|
44
44
|
version: 1.0.0
|
45
45
|
type: :development
|
46
46
|
prerelease: false
|
47
|
-
version_requirements: *
|
47
|
+
version_requirements: *2158884660
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: jeweler
|
50
|
-
requirement: &
|
50
|
+
requirement: &2158884180 !ruby/object:Gem::Requirement
|
51
51
|
none: false
|
52
52
|
requirements:
|
53
53
|
- - ~>
|
@@ -55,10 +55,10 @@ dependencies:
|
|
55
55
|
version: 1.6.2
|
56
56
|
type: :development
|
57
57
|
prerelease: false
|
58
|
-
version_requirements: *
|
58
|
+
version_requirements: *2158884180
|
59
59
|
- !ruby/object:Gem::Dependency
|
60
60
|
name: rcov
|
61
|
-
requirement: &
|
61
|
+
requirement: &2158883700 !ruby/object:Gem::Requirement
|
62
62
|
none: false
|
63
63
|
requirements:
|
64
64
|
- - ! '>='
|
@@ -66,10 +66,10 @@ dependencies:
|
|
66
66
|
version: '0'
|
67
67
|
type: :development
|
68
68
|
prerelease: false
|
69
|
-
version_requirements: *
|
69
|
+
version_requirements: *2158883700
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: machinist
|
72
|
-
requirement: &
|
72
|
+
requirement: &2158883220 !ruby/object:Gem::Requirement
|
73
73
|
none: false
|
74
74
|
requirements:
|
75
75
|
- - ! '>='
|
@@ -77,10 +77,10 @@ dependencies:
|
|
77
77
|
version: 2.0.0.beta2
|
78
78
|
type: :development
|
79
79
|
prerelease: false
|
80
|
-
version_requirements: *
|
80
|
+
version_requirements: *2158883220
|
81
81
|
- !ruby/object:Gem::Dependency
|
82
82
|
name: activesupport
|
83
|
-
requirement: &
|
83
|
+
requirement: &2158882740 !ruby/object:Gem::Requirement
|
84
84
|
none: false
|
85
85
|
requirements:
|
86
86
|
- - ! '>='
|
@@ -88,10 +88,10 @@ dependencies:
|
|
88
88
|
version: '0'
|
89
89
|
type: :development
|
90
90
|
prerelease: false
|
91
|
-
version_requirements: *
|
91
|
+
version_requirements: *2158882740
|
92
92
|
- !ruby/object:Gem::Dependency
|
93
93
|
name: i18n
|
94
|
-
requirement: &
|
94
|
+
requirement: &2158882260 !ruby/object:Gem::Requirement
|
95
95
|
none: false
|
96
96
|
requirements:
|
97
97
|
- - ! '>='
|
@@ -99,7 +99,7 @@ dependencies:
|
|
99
99
|
version: '0'
|
100
100
|
type: :development
|
101
101
|
prerelease: false
|
102
|
-
version_requirements: *
|
102
|
+
version_requirements: *2158882260
|
103
103
|
description: A random word generator intended for use in test data factories. This
|
104
104
|
library uses a large list (the wordnet corpus) of english words and provides an
|
105
105
|
enumerator interface to that corpus that will return the words in a random order
|
@@ -145,7 +145,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
145
145
|
version: '0'
|
146
146
|
segments:
|
147
147
|
- 0
|
148
|
-
hash:
|
148
|
+
hash: -256185191954845220
|
149
149
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
150
150
|
none: false
|
151
151
|
requirements:
|