gitara 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/.yardopts +5 -0
- data/CHANGELOG.markdown +5 -0
- data/README.markdown +135 -99
- data/examples/tab-with-repeats.ly +117 -0
- data/examples/tab-with-repeats.rb +19 -0
- data/gitara.gemspec +3 -0
- data/lib/gitara.rb +5 -3
- data/lib/gitara/dsl.rb +13 -0
- data/lib/gitara/node/alternative.rb +14 -0
- data/lib/gitara/node/bar.rb +3 -1
- data/lib/gitara/node/base.rb +22 -24
- data/lib/gitara/node/base/chorded_version.rb +1 -4
- data/lib/gitara/node/base/node_version.rb +35 -0
- data/lib/gitara/node/base/stanza_version.rb +1 -4
- data/lib/gitara/node/base/voiced_version.rb +5 -6
- data/lib/gitara/node/repeat.rb +10 -0
- data/lib/gitara/node/tab.rb +3 -5
- data/lib/gitara/utilities.rb +8 -0
- data/lib/gitara/version.rb +1 -1
- data/lib/gitara/voice.rb +2 -0
- data/spec/factories.rb +6 -0
- data/spec/lib/gitara/app_spec.rb +12 -28
- data/spec/lib/gitara/dsl_spec.rb +218 -173
- data/spec/lib/gitara/node/alternative_spec.rb +15 -0
- data/spec/lib/gitara/node/bar/chorded_version_spec.rb +2 -2
- data/spec/lib/gitara/node/bar/stanza_version_spec.rb +2 -2
- data/spec/lib/gitara/node/bar/voiced_version_spec.rb +2 -2
- data/spec/lib/gitara/node/bar_spec.rb +7 -7
- data/spec/lib/gitara/node/base/chorded_version_spec.rb +1 -1
- data/spec/lib/gitara/node/base/node_version_spec.rb +66 -0
- data/spec/lib/gitara/node/base/voiced_version_spec.rb +5 -5
- data/spec/lib/gitara/node/base_spec.rb +36 -42
- data/spec/lib/gitara/node/chord_set/chorded_version_spec.rb +2 -2
- data/spec/lib/gitara/node/chord_set_spec.rb +1 -1
- data/spec/lib/gitara/node/note_set_spec.rb +1 -1
- data/spec/lib/gitara/node/repeat_spec.rb +15 -0
- data/spec/lib/gitara/node/stanza_spec.rb +2 -2
- data/spec/lib/gitara/node/tab_spec.rb +6 -6
- data/spec/lib/gitara/voice_spec.rb +9 -9
- data/spec/lib/gitara_spec.rb +3 -1
- data/spec/spec_helper.rb +1 -0
- data/spec/support/app_tester.rb +22 -0
- metadata +70 -29
- data/lib/gitara/is_node_version.rb +0 -23
- data/lib/gitara/pow/base.rb +0 -11
- data/spec/lib/gitara/is_node_version_spec.rb +0 -58
data/spec/lib/gitara/dsl_spec.rb
CHANGED
@@ -1,259 +1,304 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Gitara do
|
4
|
-
describe
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
dsl.node.own_children.should be_empty
|
3
|
+
describe Gitara::Dsl do
|
4
|
+
describe "#bar" do
|
5
|
+
it "should add a bar with the name" do
|
6
|
+
dsl = FactoryGirl.build(:dsl, :node => FactoryGirl.build(:tab, :children => []))
|
7
|
+
dsl.node.children.should be_empty
|
9
8
|
|
10
|
-
|
9
|
+
dsl.bar 'Intro'
|
11
10
|
|
12
|
-
|
11
|
+
dsl.node.children.should have(1).bar
|
13
12
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
13
|
+
bar = dsl.node.children[0]
|
14
|
+
bar.name.should == 'Intro'
|
15
|
+
bar.children.should be_empty
|
16
|
+
end
|
18
17
|
|
19
|
-
|
20
|
-
|
21
|
-
|
18
|
+
it "should add the definition_children declared in the block to the bar" do
|
19
|
+
dsl = FactoryGirl.build(:dsl, :node => FactoryGirl.build(:tab, :children => []))
|
20
|
+
dsl.node.children.should be_empty
|
22
21
|
|
23
|
-
|
22
|
+
note_set = FactoryGirl.build(:note_set)
|
24
23
|
|
25
|
-
|
26
|
-
|
27
|
-
|
24
|
+
dsl.bar 'Intro' do
|
25
|
+
add note_set
|
26
|
+
end
|
28
27
|
|
29
|
-
|
30
|
-
|
28
|
+
dsl.node.children.should have(1).bar
|
29
|
+
dsl.node.children[0].name.should == 'Intro'
|
31
30
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
end
|
31
|
+
bar = dsl.node.children[0]
|
32
|
+
bar.children.should have(1).note_set
|
33
|
+
bar.children[0].should == note_set
|
36
34
|
end
|
35
|
+
end
|
37
36
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
37
|
+
describe "#add" do
|
38
|
+
it "should add the child to the dsl's node" do
|
39
|
+
dsl = FactoryGirl.build(:dsl, :node => FactoryGirl.build(:tab, :children => []))
|
40
|
+
dsl.node.children.should be_empty
|
42
41
|
|
43
|
-
|
42
|
+
bar = FactoryGirl.build(:bar, :name => 'Intro')
|
44
43
|
|
45
|
-
|
44
|
+
dsl.add bar
|
46
45
|
|
47
|
-
|
48
|
-
|
49
|
-
|
46
|
+
dsl.node.children.should have(1).bar
|
47
|
+
dsl.node.children[0].should == bar
|
48
|
+
end
|
50
49
|
|
51
|
-
|
52
|
-
|
53
|
-
|
50
|
+
it "should add the definition_children in the block to the child" do
|
51
|
+
dsl = FactoryGirl.build(:dsl, :node => FactoryGirl.build(:tab, :children => []))
|
52
|
+
dsl.node.children.should be_empty
|
54
53
|
|
55
|
-
|
56
|
-
|
54
|
+
bar = FactoryGirl.build(:bar, :children => [])
|
55
|
+
note_set = FactoryGirl.build(:note_set)
|
57
56
|
|
58
|
-
|
59
|
-
|
60
|
-
|
57
|
+
dsl.add bar do
|
58
|
+
add note_set
|
59
|
+
end
|
61
60
|
|
62
|
-
|
63
|
-
|
61
|
+
dsl.node.children.should have(1).bar
|
62
|
+
dsl.node.children[0].should == bar
|
64
63
|
|
65
|
-
|
66
|
-
|
67
|
-
end
|
64
|
+
bar.children.should have(1).note_set
|
65
|
+
bar.children[0].should == note_set
|
68
66
|
end
|
67
|
+
end
|
69
68
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
69
|
+
describe "#notes" do
|
70
|
+
it "should add a note set with the value" do
|
71
|
+
dsl = FactoryGirl.build(:dsl, :node => FactoryGirl.build(:bar, :children => []))
|
72
|
+
dsl.node.children.should be_empty
|
74
73
|
|
75
|
-
|
74
|
+
dsl.notes 'test'
|
76
75
|
|
77
|
-
|
78
|
-
|
79
|
-
end
|
76
|
+
dsl.node.children.should have(1).note_set
|
77
|
+
dsl.node.children[0].value.should == 'test'
|
80
78
|
end
|
79
|
+
end
|
81
80
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
81
|
+
describe "#line" do
|
82
|
+
it "should add a line with the name" do
|
83
|
+
dsl = FactoryGirl.build(:dsl, :node => FactoryGirl.build(:tab, :children => []))
|
84
|
+
dsl.node.children.should be_empty
|
86
85
|
|
87
|
-
|
86
|
+
dsl.line 'Intro'
|
88
87
|
|
89
|
-
|
88
|
+
dsl.node.children.should have(1).line
|
90
89
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
90
|
+
line = dsl.node.children[0]
|
91
|
+
line.name.should == 'Intro'
|
92
|
+
line.children.should be_empty
|
93
|
+
end
|
95
94
|
|
96
|
-
|
97
|
-
|
98
|
-
|
95
|
+
it "should add the definition_children declared in the block to the line" do
|
96
|
+
dsl = FactoryGirl.build(:dsl, :node => FactoryGirl.build(:tab, :children => []))
|
97
|
+
dsl.node.children.should be_empty
|
99
98
|
|
100
|
-
|
99
|
+
bar = FactoryGirl.build(:bar)
|
101
100
|
|
102
|
-
|
103
|
-
|
104
|
-
|
101
|
+
dsl.line 'Intro' do
|
102
|
+
add bar
|
103
|
+
end
|
105
104
|
|
106
|
-
|
107
|
-
|
105
|
+
dsl.node.children.should have(1).line
|
106
|
+
dsl.node.children[0].name.should == 'Intro'
|
108
107
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
end
|
108
|
+
line = dsl.node.children[0]
|
109
|
+
line.children.should have(1).bar
|
110
|
+
line.children[0].should == bar
|
113
111
|
end
|
112
|
+
end
|
114
113
|
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
114
|
+
describe "#add_names" do
|
115
|
+
it "should add a node with o[:name] of o[:node_class] to the node" do
|
116
|
+
dsl = FactoryGirl.build(:dsl, :node => FactoryGirl.build(:tab, :children => []))
|
117
|
+
dsl.node.children.should be_empty
|
119
118
|
|
120
|
-
|
119
|
+
dsl.add_names :names => [:Intro, :Intro], :node_class => Node::Bar
|
121
120
|
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
end
|
121
|
+
dsl.node.children.should have(2).bars
|
122
|
+
dsl.node.children.each do |child|
|
123
|
+
child.should be_a(Node::Bar)
|
124
|
+
child.name.should == :Intro
|
127
125
|
end
|
126
|
+
end
|
128
127
|
|
129
|
-
|
130
|
-
|
131
|
-
|
128
|
+
it "should add a node with nil name if the o[:names] is blank" do
|
129
|
+
dsl = FactoryGirl.build(:dsl, :node => FactoryGirl.build(:tab, :children => []))
|
130
|
+
dsl.node.children.should be_empty
|
132
131
|
|
133
|
-
|
132
|
+
dsl.add_names :names => [], :node_class => Node::Bar
|
134
133
|
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
end
|
134
|
+
dsl.node.children.should have(1).bar
|
135
|
+
dsl.node.children[0].attributes[:name].should be_nil
|
136
|
+
dsl.node.children[0].should be_a(Node::Bar)
|
139
137
|
end
|
138
|
+
end
|
140
139
|
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
140
|
+
describe "#score" do
|
141
|
+
it "should add a score with the name" do
|
142
|
+
dsl = FactoryGirl.build(:dsl, :node => FactoryGirl.build(:tab, :children => []))
|
143
|
+
dsl.node.children.should be_empty
|
145
144
|
|
146
|
-
|
145
|
+
dsl.score
|
147
146
|
|
148
|
-
|
147
|
+
dsl.node.children.should have(1).score
|
149
148
|
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
149
|
+
score = dsl.node.children[0]
|
150
|
+
score.should be_a(Node::Score)
|
151
|
+
score.children.should be_empty
|
152
|
+
end
|
154
153
|
|
155
|
-
|
156
|
-
|
157
|
-
|
154
|
+
it "should add the definition_children declared in the block to the score" do
|
155
|
+
dsl = FactoryGirl.build(:dsl, :node => FactoryGirl.build(:tab, :children => []))
|
156
|
+
dsl.node.children.should be_empty
|
158
157
|
|
159
|
-
|
158
|
+
note_set = FactoryGirl.build(:note_set)
|
160
159
|
|
161
|
-
|
162
|
-
|
163
|
-
|
160
|
+
dsl.score do
|
161
|
+
add note_set
|
162
|
+
end
|
164
163
|
|
165
|
-
|
164
|
+
dsl.node.children.should have(1).score
|
166
165
|
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
end
|
166
|
+
score = dsl.node.children[0]
|
167
|
+
score.children.should have(1).note_set
|
168
|
+
score.children[0].should == note_set
|
171
169
|
end
|
170
|
+
end
|
171
|
+
|
172
|
+
describe "#stanza" do
|
173
|
+
it "should add a stanza with the name" do
|
174
|
+
dsl = FactoryGirl.build(:dsl, :node => FactoryGirl.build(:tab, :children => []))
|
175
|
+
dsl.node.children.should be_empty
|
172
176
|
|
173
|
-
|
174
|
-
it "should add a stanza with the name" do
|
175
|
-
dsl = FactoryGirl.build(:dsl, :node => FactoryGirl.build(:tab, :children => []))
|
176
|
-
dsl.node.own_children.should be_empty
|
177
|
+
dsl.stanza 'Intro'
|
177
178
|
|
178
|
-
|
179
|
+
dsl.node.children.should have(1).stanza
|
179
180
|
|
180
|
-
|
181
|
+
stanza = dsl.node.children[0]
|
182
|
+
stanza.name.should == 'Intro'
|
183
|
+
stanza.children.should be_empty
|
184
|
+
end
|
185
|
+
|
186
|
+
it "should add the definition_children declared in the block to the stanza" do
|
187
|
+
dsl = FactoryGirl.build(:dsl, :node => FactoryGirl.build(:tab, :children => []))
|
188
|
+
dsl.node.children.should be_empty
|
181
189
|
|
182
|
-
|
183
|
-
|
184
|
-
|
190
|
+
line = FactoryGirl.build(:line)
|
191
|
+
|
192
|
+
dsl.stanza 'Intro' do
|
193
|
+
add line
|
185
194
|
end
|
186
195
|
|
187
|
-
|
188
|
-
|
189
|
-
dsl.node.own_children.should be_empty
|
196
|
+
dsl.node.children.should have(1).stanza
|
197
|
+
dsl.node.children[0].name.should == 'Intro'
|
190
198
|
|
191
|
-
|
199
|
+
stanza = dsl.node.children[0]
|
200
|
+
stanza.children.should have(1).line
|
201
|
+
stanza.children[0].should == line
|
202
|
+
end
|
203
|
+
end
|
192
204
|
|
193
|
-
|
194
|
-
|
195
|
-
|
205
|
+
[:title, :composer, :arranger, :instrument, :key, :midi_instrument, :string_tunings, :tempo, :transposition].each do |property|
|
206
|
+
describe "##{property}" do
|
207
|
+
it "should set the #{property} of the tab to value" do
|
208
|
+
tab = FactoryGirl.build(:tab)
|
196
209
|
|
197
|
-
dsl.node
|
198
|
-
dsl.
|
210
|
+
dsl = FactoryGirl.build(:dsl, :node => tab)
|
211
|
+
dsl.send property, "test"
|
199
212
|
|
200
|
-
|
201
|
-
stanza.own_children.should have(1).line
|
202
|
-
stanza.own_children[0].should == line
|
213
|
+
tab.send(property).should == "test"
|
203
214
|
end
|
204
215
|
end
|
216
|
+
end
|
205
217
|
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
218
|
+
describe "#chords" do
|
219
|
+
it "should add a chord set with the name" do
|
220
|
+
dsl = FactoryGirl.build(:dsl, :node => FactoryGirl.build(:tab, :children => []))
|
221
|
+
dsl.node.children.should be_empty
|
210
222
|
|
211
|
-
|
212
|
-
dsl.send property, "test"
|
223
|
+
dsl.chords :Am, 'r4-"Am" r r r'
|
213
224
|
|
214
|
-
|
215
|
-
|
216
|
-
|
225
|
+
dsl.node.children.should have(1).chord_set
|
226
|
+
|
227
|
+
chord_set = dsl.node.children[0]
|
228
|
+
chord_set.name.should == :Am
|
229
|
+
chord_set.value.should == 'r4-"Am" r r r'
|
217
230
|
end
|
231
|
+
end
|
218
232
|
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
233
|
+
describe "#chords" do
|
234
|
+
it "should add a bar with the name" do
|
235
|
+
dsl = FactoryGirl.build(:dsl, :node => FactoryGirl.build(:tab, :children => []))
|
236
|
+
dsl.node.children.should be_empty
|
223
237
|
|
224
|
-
|
238
|
+
dsl.chords :Am
|
225
239
|
|
226
|
-
|
240
|
+
dsl.node.children.should have(1).chord_set
|
227
241
|
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
242
|
+
chord_set = dsl.node.children[0]
|
243
|
+
chord_set.name.should == :Am
|
244
|
+
end
|
245
|
+
end
|
246
|
+
|
247
|
+
describe "#partial" do
|
248
|
+
it "should set the specified duration of the bar node to duration" do
|
249
|
+
dsl = FactoryGirl.build(:dsl, :node => FactoryGirl.build(:bar))
|
250
|
+
dsl.node.specified_duration.should be_nil
|
251
|
+
|
252
|
+
dsl.partial 8
|
253
|
+
|
254
|
+
dsl.node.specified_duration.should == 8
|
232
255
|
end
|
256
|
+
end
|
233
257
|
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
dsl.node.own_children.should be_empty
|
258
|
+
describe "#repeat" do
|
259
|
+
it "should add a repeat with the value" do
|
260
|
+
dsl = FactoryGirl.build(:dsl, :node => FactoryGirl.build(:tab, :children => []))
|
238
261
|
|
239
|
-
|
262
|
+
dsl.repeat 2
|
240
263
|
|
241
|
-
|
264
|
+
dsl.node.children.should have(1).repeat
|
242
265
|
|
243
|
-
|
244
|
-
|
245
|
-
|
266
|
+
repeat = dsl.node.children[0]
|
267
|
+
repeat.value.should == 2
|
268
|
+
repeat.children.should be_empty
|
246
269
|
end
|
247
270
|
|
248
|
-
|
249
|
-
|
250
|
-
dsl = FactoryGirl.build(:dsl, :node => FactoryGirl.build(:bar))
|
251
|
-
dsl.node.specified_duration.should be_nil
|
271
|
+
it "should add the children declared in the block to the repeat" do
|
272
|
+
dsl = FactoryGirl.build(:dsl, :node => FactoryGirl.build(:tab, :children => []))
|
252
273
|
|
253
|
-
|
274
|
+
bar = FactoryGirl.build(:bar)
|
254
275
|
|
255
|
-
|
276
|
+
dsl.repeat 2 do
|
277
|
+
add bar
|
256
278
|
end
|
279
|
+
|
280
|
+
dsl.node.children.should have(1).repeat
|
281
|
+
|
282
|
+
repeat = dsl.node.children[0]
|
283
|
+
repeat.children.should have(1).child
|
284
|
+
repeat.children[0].should == bar
|
285
|
+
end
|
286
|
+
end
|
287
|
+
|
288
|
+
describe "#alternative" do
|
289
|
+
it "should add the children declared in the block to the alternative" do
|
290
|
+
dsl = FactoryGirl.build(:dsl, :node => FactoryGirl.build(:tab, :children => []))
|
291
|
+
bar = FactoryGirl.build(:bar)
|
292
|
+
|
293
|
+
dsl.alternative do
|
294
|
+
add bar
|
295
|
+
end
|
296
|
+
|
297
|
+
dsl.node.children.should have(1).alternative
|
298
|
+
|
299
|
+
alternative = dsl.node.children[0]
|
300
|
+
alternative.children.should have(1).child
|
301
|
+
alternative.children[0].should == bar
|
257
302
|
end
|
258
303
|
end
|
259
304
|
end
|