haiku_gadget 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2a15537f69f3e149171a2514415edb876eab3510
4
- data.tar.gz: bd8706dfbb15420681f2faeaed23cfddd5b03b14
3
+ metadata.gz: ea8e5beb816d1856ea38d9ef4e43d962de94337a
4
+ data.tar.gz: 9d9438f59eabee07b148650ac2eeda7433ac9338
5
5
  SHA512:
6
- metadata.gz: 323b3add5c00b3a07b77855ace907b81520cb7956385e322d56910c3df208265572566ef174aaf8d93eb984a10c68dd6e88094cf099c93505f9e469f08c847db
7
- data.tar.gz: aff4b7a9ef98cd22d1d71df7f5ddc2de9d48a476a4397ee1ed6bf5482d3403deb12d3ef8d4e175f8320666d3be345e8c3f04158236e1d2bd795b00ede0f97173
6
+ metadata.gz: 32c847c4f65cddce03d8a8d56b6ae52252067972a97a11101ecdec0d66ca41e0113e57598aae03bf6c3a4697b3b6fbe8632e9dbbcdb7aa680036f8721bbf037a
7
+ data.tar.gz: c35d4991dcceeb1ba12a1d6400f2b1c29aa165e2ac130b2f97c1f2d650becbd162d056f5cc7ab6623a3c4d565d74386b1808d3a6c722124a001f8aecab954865
@@ -46,6 +46,7 @@ module HaikuGadget
46
46
  # get a random template defined for the current row
47
47
  word_templates = HaikuTemplate.new.template_matrix[row_index]
48
48
  end
49
+
49
50
  # generate a HaikuTemplate object that only contains a single line with the desired template
50
51
  haiku_template = HaikuTemplate.new [word_templates]
51
52
  haiku_template.generate[0]
@@ -16,15 +16,15 @@ module HaikuGadget
16
16
  HaikuTemplate.random_template(LineTemplates::ALL_BOTTOM_LINES)
17
17
  ]
18
18
  end
19
- # clone the two-dimensional array (so syllable counts can be changed)
20
- @template_matrix = template_matrix.map { |tm| tm.map { |wt| wt.clone } }
19
+ # clone the two-dimensional array (so syllable counts can be changed safely)
20
+ @template_matrix = template_matrix.map { |lt| lt.clone }
21
21
  complete_template
22
22
  end
23
23
 
24
24
  def generate
25
25
  lines = []
26
- @template_matrix.each do |word_templates|
27
- words = HaikuTemplate.real_words_from_templates word_templates
26
+ @template_matrix.each do |line_template|
27
+ words = line_template.real_words
28
28
  lines << words.join(' ')
29
29
  end
30
30
  lines
@@ -38,112 +38,25 @@ module HaikuGadget
38
38
  end
39
39
 
40
40
  def complete_template_plurality
41
- @template_matrix.each do |word_templates|
42
- obj_pluralities = []
43
- word_templates.each do |word_template|
44
- if word_template.plurality == :any
45
- # need to pick a plurality for this word
46
- if word_template.obj_num > 0
47
- # this word is referencing an object, and its plurality can be randomized
48
- unless obj_pluralities[word_template.obj_num]
49
- # this word's plurality has not already been determined via another word on this line
50
- obj_pluralities[word_template.obj_num] = [:singular, :plural].sample
51
- end
52
- word_template.plurality = obj_pluralities[word_template.obj_num]
53
- else
54
- word_template.plurality = [:singular, :plural].sample
55
- end
56
- end
57
- end
41
+ @template_matrix.each do |line_template|
42
+ line_template.complete_plurality
58
43
  end
59
44
  end
60
45
 
61
46
  def complete_template_syllables
62
47
  syllables = [5, 7, 5]
63
48
  @template_matrix.each_index do |i|
64
- while HaikuTemplate.row_syllables(@template_matrix[i]) < syllables[i]
65
- increased_syllable_index = HaikuTemplate.increase_row_syllable(@template_matrix[i])
66
- break if increased_syllable_index.nil?
67
- end
68
- end
69
- end
70
-
71
- def self.real_words_from_templates(word_templates)
72
- words = []
73
- word_templates.each do |word_template|
74
- if word_template.syllables > 0
75
- word = word_template.word_type.get_word(
76
- word_template.syllables,
77
- word_template.plurality
78
- )
79
- words << word
80
- end
81
- end
82
- HaikuTemplate.convert_a_to_an words
83
- words
84
- end
85
-
86
- # where necessary, convert 'a' to 'an'
87
- def self.convert_a_to_an(words)
88
- words.each_index do |i|
89
- if words[i] == 'a' && (i < (words.length - 1)) && %w(a e i o u).include?(words[i + 1].slice(0))
90
- # current word is 'a', there are more words after this one, and the next one starts with a, e, i, o or u
91
- words[i] = 'an'
92
- end
93
- end
94
- end
95
-
96
- def self.row_syllables(word_templates)
97
- word_templates.map { |w| w.syllables }.inject(:+)
98
- end
99
-
100
- def self.increase_row_syllable(word_templates)
101
- valid_word_indices = HaikuTemplate.get_valid_word_indices word_templates
102
-
103
- increase_syllable_index = nil
104
- loop do
105
- increase_syllable_index = HaikuTemplate.increased_row_syllable_index(word_templates, valid_word_indices)
106
- break if increase_syllable_index || valid_word_indices.length == 0
107
- end
108
- if increase_syllable_index
109
- word_templates[increase_syllable_index].syllables += 1
110
- increase_syllable_index
111
- else
112
- nil
113
- end
114
- end
115
-
116
- def self.get_valid_word_indices(word_templates)
117
- out = []
118
- word_templates.each_index do |i|
119
- out << i unless word_templates[i].word_type.base_symbol == :custom
120
- end
121
- out
122
- end
123
-
124
- # returns the word index where another syllable can be added (and where dictionary words are available)
125
- def self.increased_row_syllable_index(word_templates, valid_word_indices)
126
- if valid_word_indices.length > 0
127
- word_index = valid_word_indices.sample
128
- if word_templates[word_index].word_type.words?(
129
- word_templates[word_index].syllables + 1,
130
- word_templates[word_index].plurality
131
- )
132
- word_index
133
- else
134
- # dictionary has no words of this type, remove this index so it isn't checked in the future
135
- valid_word_indices.delete word_index
136
- nil
137
- end
49
+ @template_matrix[i].complete_syllables syllables[i]
138
50
  end
139
51
  end
140
52
 
141
53
  def self.random_template(templates)
142
54
  template_or_array = templates.sample
143
- if template_or_array[0].is_a? Array
55
+ if template_or_array.is_a? Array
144
56
  # if NESTED object is an array, recurse
145
57
  HaikuTemplate.random_template template_or_array
146
58
  else
59
+ # current object should be of type LineTemplate
147
60
  template_or_array
148
61
  end
149
62
  end
@@ -0,0 +1,115 @@
1
+ require File.expand_path('haiku_template.rb', File.dirname(__FILE__))
2
+ require File.expand_path('word_template.rb', File.dirname(__FILE__))
3
+
4
+ module HaikuGadget
5
+
6
+ class LineTemplate
7
+
8
+ attr_reader :word_templates
9
+
10
+ def initialize(*word_templates)
11
+ @word_templates = word_templates.flatten
12
+ end
13
+
14
+ def clone
15
+ LineTemplate.new @word_templates.map{ |wt| wt.clone }
16
+ end
17
+
18
+ def current_syllables
19
+ @word_templates.map { |w| w.syllables }.inject(:+)
20
+ end
21
+
22
+ def get_valid_word_indices
23
+ out = []
24
+ @word_templates.each_index do |i|
25
+ out << i unless @word_templates[i].word_type.base_symbol == :custom
26
+ end
27
+ out
28
+ end
29
+
30
+ def increase_row_syllable
31
+ valid_word_indices = get_valid_word_indices
32
+
33
+ increase_syllable_index = nil
34
+ loop do
35
+ increase_syllable_index = increased_row_syllable_index valid_word_indices
36
+ break if increase_syllable_index || valid_word_indices.length == 0
37
+ end
38
+ if increase_syllable_index
39
+ @word_templates[increase_syllable_index].syllables += 1
40
+ increase_syllable_index
41
+ else
42
+ nil
43
+ end
44
+ end
45
+
46
+ def increased_row_syllable_index(valid_word_indices)
47
+ if valid_word_indices.length > 0
48
+ word_index = valid_word_indices.sample
49
+ if @word_templates[word_index].word_type.words?(
50
+ @word_templates[word_index].syllables + 1,
51
+ @word_templates[word_index].plurality
52
+ )
53
+ word_index
54
+ else
55
+ # dictionary has no words of this type, remove this index so it isn't checked in the future
56
+ valid_word_indices.delete word_index
57
+ nil
58
+ end
59
+ end
60
+ end
61
+
62
+ def complete_syllables(required_syllables)
63
+ while current_syllables < required_syllables
64
+ increased_syllable_index = increase_row_syllable
65
+ break if increased_syllable_index.nil?
66
+ end
67
+ end
68
+
69
+ def complete_plurality
70
+ obj_pluralities = []
71
+ @word_templates.each do |word_template|
72
+ if word_template.plurality == :any
73
+ # need to pick a plurality for this word
74
+ if word_template.obj_num > 0
75
+ # this word is referencing an object, and its plurality can be randomized
76
+ unless obj_pluralities[word_template.obj_num]
77
+ # this word's plurality has not already been determined via another word on this line
78
+ obj_pluralities[word_template.obj_num] = [:singular, :plural].sample
79
+ end
80
+ word_template.plurality = obj_pluralities[word_template.obj_num]
81
+ else
82
+ word_template.plurality = [:singular, :plural].sample
83
+ end
84
+ end
85
+ end
86
+ end
87
+
88
+ def real_words
89
+ words = []
90
+ @word_templates.each do |word_template|
91
+ if word_template.syllables > 0
92
+ word = word_template.word_type.get_word(
93
+ word_template.syllables,
94
+ word_template.plurality
95
+ )
96
+ words << word
97
+ end
98
+ end
99
+ LineTemplate.convert_a_to_an words
100
+ words
101
+ end
102
+
103
+ # where necessary, convert 'a' to 'an'
104
+ def self.convert_a_to_an(words)
105
+ words.each_index do |i|
106
+ if words[i] == 'a' && (i < (words.length - 1)) && %w(a e i o u).include?(words[i + 1].slice(0))
107
+ # current word is 'a', there are more words after this one, and the next one starts with a, e, i, o or u
108
+ words[i] = 'an'
109
+ end
110
+ end
111
+ end
112
+
113
+ end
114
+
115
+ end
@@ -1,32 +1,40 @@
1
1
  require File.expand_path('word_template.rb', File.dirname(__FILE__))
2
+ require File.expand_path('line_template.rb', File.dirname(__FILE__))
2
3
 
3
4
  module HaikuGadget
4
5
 
5
6
  module LineTemplates
6
7
 
7
8
  COMMON_LINES = [
8
- [
9
- # noun(s) act on mass/abstract noun
9
+
10
+ # noun(s) act on mass/abstract noun
11
+ LineTemplate.new(
10
12
  WordTemplate.new(:determiner, 0, :any, 1),
11
13
  WordTemplate.new(:noun, 1, :any, 1),
12
14
  WordTemplate.new(:verb, 1, :any, 1),
13
15
  WordTemplate.new(:mass_noun_determiner),
14
16
  WordTemplate.new(:mass_noun, 1)
15
- ], [
16
- # imperative action (command)
17
+ ),
18
+
19
+ # imperative action (command)
20
+ LineTemplate.new(
17
21
  WordTemplate.new(:adverb, 2),
18
22
  WordTemplate.new(:verb, 1, :plural),
19
23
  WordTemplate.new(:determiner, 0, :plural),
20
24
  WordTemplate.new(:adjective, 0, :plural),
21
25
  WordTemplate.new(:noun, 1, :plural)
22
- ], [
26
+ ),
27
+
28
+ LineTemplate.new(
23
29
  # mass/abstract noun is adj
24
30
  WordTemplate.new(:mass_noun_determiner),
25
31
  WordTemplate.new(:adjective, 0, :common),
26
32
  WordTemplate.new(:mass_noun, 1),
27
33
  WordTemplate.new(:to_be, 1, :singular),
28
34
  WordTemplate.new(:adjective, 1, :any)
29
- ], [
35
+ ),
36
+
37
+ LineTemplate.new(
30
38
  # noun(s) of mass/abstract noun acts
31
39
  WordTemplate.new(:determiner, 0, :any, 1),
32
40
  WordTemplate.new(:adjective, 0, :any, 1),
@@ -34,113 +42,135 @@ module HaikuGadget
34
42
  WordTemplate.custom('of', 1),
35
43
  WordTemplate.new(:mass_noun, 1),
36
44
  WordTemplate.new(:verb_self, 1, :any, 1)
37
- ], [
45
+ ),
46
+
47
+ LineTemplate.new(
38
48
  # adj noun is adj
39
49
  WordTemplate.new(:adjective, 0, :any, 1),
40
50
  WordTemplate.new(:noun, 1, :any, 1),
41
51
  WordTemplate.new(:to_be, 1, :any, 1),
42
52
  WordTemplate.new(:adjective, 1, :any, 1)
43
- ], [
44
- # metaphors
45
- [
53
+ ),
54
+
55
+ # metaphors
56
+ [
57
+ LineTemplate.new(
46
58
  WordTemplate.new(:adjective, 0, :common),
47
59
  WordTemplate.new(:mass_noun, 1),
48
60
  WordTemplate.custom('is like', 2),
49
61
  WordTemplate.new(:adjective, 0, :common),
50
62
  WordTemplate.new(:mass_noun, 1)
51
- ], [
63
+ ),
64
+
65
+ LineTemplate.new(
52
66
  WordTemplate.new(:adjective, 0, :plural),
53
67
  WordTemplate.new(:noun, 1, :plural),
54
68
  WordTemplate.custom('are like', 2),
55
69
  WordTemplate.new(:adjective, 0, :common),
56
70
  WordTemplate.new(:mass_noun, 1)
57
- ], [
58
- WordTemplate.new(:determiner, 1, :singular, 1),
71
+ ),
72
+
73
+ LineTemplate.new(
74
+ WordTemplate.new(:determiner, 0, :singular, 1),
59
75
  WordTemplate.new(:adjective, 0, :singular, 1),
60
76
  WordTemplate.new(:noun, 1, :singular, 1),
61
77
  WordTemplate.custom('is like', 2),
62
78
  WordTemplate.new(:determiner, 1, :singular, 2),
63
79
  WordTemplate.new(:adjective, 0, :singular, 2),
64
80
  WordTemplate.new(:noun, 1, :singular, 2)
65
- ], [
81
+ ),
82
+
83
+ LineTemplate.new(
66
84
  WordTemplate.new(:adjective, 0, :plural, 1),
67
85
  WordTemplate.new(:noun, 1, :plural, 1),
68
86
  WordTemplate.custom('are like', 2),
69
87
  WordTemplate.new(:adjective, 0, :plural, 2),
70
88
  WordTemplate.new(:noun, 1, :plural, 2)
71
- ]
72
- ], [
73
- # i/we/they act on noun(s)
74
- [
89
+ )
90
+ ],
91
+
92
+ # i/we/they act on noun(s)
93
+ [
94
+ LineTemplate.new(
75
95
  WordTemplate.custom(%w(i we they), 1),
76
96
  WordTemplate.new(:verb, 1, :plural),
77
97
  WordTemplate.new(:determiner, 1, :singular, 2),
78
98
  WordTemplate.new(:adjective, 0, :singular, 2),
79
99
  WordTemplate.new(:noun, 1, :singular, 2),
80
100
  WordTemplate.new(:adverb)
81
- ], [
101
+ ),
102
+
103
+ LineTemplate.new(
82
104
  WordTemplate.custom(%w(i we they), 1),
83
105
  WordTemplate.new(:verb, 1, :plural),
84
106
  WordTemplate.new(:determiner, 0, :plural, 2),
85
107
  WordTemplate.new(:adjective, 0, :plural, 2),
86
108
  WordTemplate.new(:noun, 1, :plural, 2),
87
109
  WordTemplate.new(:adverb)
88
- ]
89
- ], [
90
- # noun(s) act on noun(s)
91
- [
110
+ )
111
+ ],
112
+
113
+ # noun(s) act on noun(s)
114
+ [
115
+ LineTemplate.new(
92
116
  WordTemplate.new(:determiner, 0, :any, 1),
93
117
  WordTemplate.new(:noun, 1, :any, 1),
94
118
  WordTemplate.new(:verb, 1, :any, 1),
95
119
  WordTemplate.new(:determiner, 1, :singular, 2),
96
120
  WordTemplate.new(:noun, 1, :singular, 2)
97
- ], [
121
+ ),
122
+
123
+ LineTemplate.new(
98
124
  WordTemplate.new(:determiner, 0, :any, 1),
99
125
  WordTemplate.new(:noun, 1, :any, 1),
100
126
  WordTemplate.new(:verb, 1, :any, 1),
101
127
  WordTemplate.new(:determiner, 0, :plural, 2),
102
128
  WordTemplate.new(:noun, 1, :plural, 2)
103
- ]
129
+ )
104
130
  ]
105
131
  ]
106
132
 
107
133
  MIDDLE_LINES = [
134
+ # (and) noun(s) act
108
135
  [
109
- # (and) noun(s) act
110
- [
136
+ LineTemplate.new(
111
137
  WordTemplate.new(:transition_join),
112
138
  WordTemplate.new(:determiner, 1, :singular, 1),
113
139
  WordTemplate.new(:adjective, 0, :singular, 1),
114
140
  WordTemplate.new(:noun, 1, :singular, 1),
115
141
  WordTemplate.new(:verb_self, 1, :singularß, 1),
116
142
  WordTemplate.new(:adverb)
117
- ], [
143
+ ),
144
+
145
+ LineTemplate.new(
118
146
  WordTemplate.new(:transition_join),
119
147
  WordTemplate.new(:determiner, 0, :plural, 1),
120
148
  WordTemplate.new(:adjective, 0, :plural, 1),
121
149
  WordTemplate.new(:noun, 1, :plural, 1),
122
150
  WordTemplate.new(:verb_self, 1, :plural, 1),
123
151
  WordTemplate.new(:adverb)
124
- ]
152
+ )
125
153
  ]
126
154
  ]
127
155
 
128
156
  BOTTOM_LINES = [
157
+ # (and) noun(s) act
129
158
  [
130
- # (and) noun(s) act
131
- [
159
+ LineTemplate.new(
132
160
  WordTemplate.new(:transition_join),
133
161
  WordTemplate.new(:determiner, 1, :singular, 1),
134
162
  WordTemplate.new(:adjective, 0, :singular, 1),
135
163
  WordTemplate.new(:noun, 1, :singular, 1),
136
164
  WordTemplate.new(:verb_self, 1, :singular, 1)
137
- ], [
165
+ ),
166
+
167
+ LineTemplate.new(
138
168
  WordTemplate.new(:transition_join),
139
169
  WordTemplate.new(:determiner, 0, :plural, 1),
140
170
  WordTemplate.new(:adjective, 0, :plural, 1),
141
171
  WordTemplate.new(:noun, 1, :plural, 1),
142
172
  WordTemplate.new(:verb_self, 1, :plural, 1)
143
- ]
173
+ )
144
174
  ]
145
175
  ]
146
176
 
@@ -1,5 +1,5 @@
1
1
  module HaikuGadget
2
2
 
3
- VERSION = '1.0.2'
3
+ VERSION = '1.0.3'
4
4
 
5
5
  end
data/lib/words.yml CHANGED
@@ -74,12 +74,12 @@
74
74
  ]
75
75
  :verb_singular: [
76
76
  [soothes],
77
- [eases, nudges, uses, raises, slices, falls on, dreams of, jumps over, looks at, looks for, studies, tosses, touches, coaxes, pushes, reaches, punches, cares for, ties up, sticks to, goes to, swarms on, flails at, cooks for, kisses, smooches, speaks to, quests for, raves about, sits on, waves to, shines on, mixes, watches, copies, marries, senses, closes, sings to, smiles at, asks for, hopes for, toys with, plays with, floats on, lives with, steps on, jives with, hops on, washes, sounds like],
77
+ [eases, nudges, uses, raises, slices, falls on, dreams of, jumps over, looks at, looks for, studies, tosses, touches, coaxes, pushes, reaches, punches, cares for, ties up, sticks to, goes to, swarms on, flails at, cooks for, kisses, smooches, speaks to, quests for, raves about, sits on, waves to, shines on, mixes, watches, copies, marries, senses, closes, sings to, smiles at, asks for, hopes for, toys with, plays with, floats on, lives on, lives with, steps on, jives with, hops on, washes, sounds like],
78
78
  [amazes, cares about, notifies, objects to, condenses, beautifies, glorifies, liquefies, nullifies, occupies, purifies, satisfies, stupefies, wishes for, thinks about, writes about]
79
79
  ]
80
80
  :verb_plural: [
81
81
  [ease, nudge, use, raise, slice, study, toss, touch, coax, push, reach, punch, kiss, smooch, mix, watch, copy, sense, soothe, close, wash],
82
- [amaze, fall on, dream of, jump over, look at, look for, finish, care for, approach, tie up, stick to, go to, swarm on, flail at, cook for, dance with, dance for, speak to, quest for, rave about, sit on, wave to, shine on, condense, marry, advise, sing to, smile at, ask for, hope for, wish for, toy with, play with, think about, float on, lives on, step on, jive with, hop on, sound like],
82
+ [amaze, fall on, dream of, jump over, look at, look for, finish, care for, approach, tie up, stick to, go to, swarm on, flail at, cook for, dance with, dance for, speak to, quest for, rave about, sit on, wave to, shine on, condense, marry, advise, sing to, smile at, ask for, hope for, wish for, toy with, play with, think about, float on, live on, live with, step on, jive with, hop on, sound like],
83
83
  [care about, notify, object to, beautify, glorify, liquefy, nullify, occupy, purify, satisfy, stupefy, vandalize, vaporize, minimize, maximize, encourage, equalize, pulverize, write about]
84
84
  ]
85
85
 
@@ -58,20 +58,22 @@ module HaikuGadget
58
58
  dict_path = '../../spec/test_words_single.yml'
59
59
 
60
60
  haiku_template = HaikuTemplate.new [
61
- [
61
+ LineTemplate.new(
62
62
  WordTemplate.new(:adjective, 1, :singular, 1), # red
63
63
  WordTemplate.new(:noun, 1, :singular, 1), # thing
64
64
  WordTemplate.new(:verb_self, 3, :singular, 1) # meditates
65
- ], [
65
+ ),
66
+ LineTemplate.new(
66
67
  WordTemplate.new(:determiner, 1, :plural, 1), # the
67
68
  WordTemplate.new(:noun, 3, :plural, 1), # samurais
68
69
  WordTemplate.new(:verb, 1, :plural, 1), # see
69
70
  WordTemplate.new(:noun, 2, :singular, 2) # zombie
70
- ], [
71
+ ),
72
+ LineTemplate.new(
71
73
  WordTemplate.new(:adjective, 2, :any, 1), # orange
72
74
  WordTemplate.new(:noun, 2, :any, 1), # zombie(s)
73
75
  WordTemplate.new(:verb_self, 1, :any, 1) # fight(s)
74
- ]
76
+ )
75
77
  ]
76
78
 
77
79
  before(:each) do
@@ -127,9 +129,9 @@ module HaikuGadget
127
129
  it 'should return a haiku containing expected words' do
128
130
 
129
131
  haiku_template = HaikuTemplate.new [
130
- [WordTemplate.new(:mass_noun, 5)],
131
- [WordTemplate.new(:mass_noun, 7)],
132
- [WordTemplate.new(:mass_noun, 5)]
132
+ LineTemplate.new(WordTemplate.new :mass_noun, 5),
133
+ LineTemplate.new(WordTemplate.new :mass_noun, 7),
134
+ LineTemplate.new(WordTemplate.new :mass_noun, 5)
133
135
  ]
134
136
 
135
137
  haiku = HaikuGadget.haiku nil, haiku_template
@@ -146,6 +148,31 @@ module HaikuGadget
146
148
  end
147
149
 
148
150
  end
151
+
152
+ describe 'with built-in line templates' do
153
+
154
+ it 'should not have invalid syllable defaults' do
155
+
156
+ template_pairs = [
157
+ [LineTemplates::ALL_TOP_LINES.flatten, 5],
158
+ [LineTemplates::ALL_MIDDLE_LINES.flatten, 7],
159
+ [LineTemplates::ALL_BOTTOM_LINES.flatten, 5]
160
+ ]
161
+
162
+ template_pairs.each do |pair|
163
+ line_templates, syllables = pair
164
+
165
+ line_templates.each do |line_template|
166
+
167
+ expect(line_template.current_syllables).to be <= syllables
168
+
169
+ end
170
+
171
+ end
172
+
173
+ end
174
+
175
+ end
149
176
 
150
177
  end
151
178
 
data/test_haiku.rb CHANGED
@@ -1,8 +1,10 @@
1
1
  require File.expand_path('lib/haiku_gadget.rb', File.dirname(__FILE__))
2
2
 
3
- 10.times do
4
-
5
3
  puts HaikuGadget.haiku "\n"
4
+
6
5
  puts "\n"
7
6
 
8
- end
7
+ puts HaikuGadget.top_line
8
+ puts HaikuGadget.middle_line
9
+ puts HaikuGadget.bottom_line
10
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: haiku_gadget
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Balay
@@ -71,6 +71,7 @@ files:
71
71
  - lib/haiku_gadget/dictionary.rb
72
72
  - lib/haiku_gadget/haiku_gadget.rb
73
73
  - lib/haiku_gadget/haiku_template.rb
74
+ - lib/haiku_gadget/line_template.rb
74
75
  - lib/haiku_gadget/line_templates.rb
75
76
  - lib/haiku_gadget/version.rb
76
77
  - lib/haiku_gadget/word_template.rb