musicality 0.11.1 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. checksums.yaml +5 -5
  2. data/.coveralls.yml +1 -0
  3. data/.ruby-version +1 -1
  4. data/.travis.yml +4 -0
  5. data/ChangeLog.md +11 -0
  6. data/README.md +3 -0
  7. data/Rakefile +11 -3
  8. data/lib/musicality/composition/model/rhythm.rb +33 -0
  9. data/lib/musicality/composition/model/rhythm_class.rb +30 -0
  10. data/lib/musicality/composition/sequencing/drum_machine/drum_kit.rb +18 -0
  11. data/lib/musicality/composition/sequencing/drum_machine/drum_machine.rb +59 -0
  12. data/lib/musicality/composition/sequencing/drum_machine/drum_parts.rb +21 -0
  13. data/lib/musicality/composition/sequencing/drum_machine/drum_pattern.rb +66 -0
  14. data/lib/musicality/composition/sequencing/drum_machine/drum_patterns/pop_drum_patterns.rb +146 -0
  15. data/lib/musicality/composition/sequencing/note_array.rb +33 -0
  16. data/lib/musicality/composition/sequencing/note_fifo.rb +73 -0
  17. data/lib/musicality/composition/sequencing/sequenceable.rb +9 -0
  18. data/lib/musicality/composition/sequencing/sequencer.rb +35 -0
  19. data/lib/musicality/errors.rb +2 -2
  20. data/lib/musicality/notation/model/dynamics.rb +2 -2
  21. data/lib/musicality/notation/model/key.rb +42 -91
  22. data/lib/musicality/notation/model/keys.rb +35 -34
  23. data/lib/musicality/notation/model/note.rb +31 -9
  24. data/lib/musicality/notation/model/pitch.rb +2 -2
  25. data/lib/musicality/notation/parsing/convenience_methods.rb +23 -12
  26. data/lib/musicality/notation/parsing/duration_parsing.rb +3 -3
  27. data/lib/musicality/notation/parsing/key_parsing.rb +150 -0
  28. data/lib/musicality/notation/parsing/key_parsing.treetop +37 -0
  29. data/lib/musicality/notation/parsing/meter_parsing.rb +3 -3
  30. data/lib/musicality/notation/parsing/numbers/nonnegative_float_parsing.rb +3 -1
  31. data/lib/musicality/notation/parsing/numbers/nonnegative_integer_parsing.rb +1 -0
  32. data/lib/musicality/notation/parsing/numbers/nonnegative_rational_parsing.rb +1 -1
  33. data/lib/musicality/notation/parsing/numbers/positive_float_parsing.rb +4 -1
  34. data/lib/musicality/notation/parsing/numbers/positive_rational_parsing.rb +1 -1
  35. data/lib/musicality/notation/parsing/parseable.rb +13 -17
  36. data/lib/musicality/notation/parsing/pitch_parsing.rb +7 -0
  37. data/lib/musicality/notation/parsing/segment_parsing.rb +3 -0
  38. data/lib/musicality/performance/conversion/note_sequence_extractor.rb +82 -134
  39. data/lib/musicality/performance/model/note_sequence.rb +22 -3
  40. data/lib/musicality/performance/supercollider/performer.rb +2 -2
  41. data/lib/musicality/performance/supercollider/sc_drum_kits.rb +29 -0
  42. data/lib/musicality/performance/supercollider/synthdefs/bass.rb +211 -0
  43. data/lib/musicality/performance/supercollider/synthdefs/claps.rb +80 -0
  44. data/lib/musicality/performance/supercollider/synthdefs/cymbals.rb +57 -0
  45. data/lib/musicality/performance/supercollider/synthdefs/hihats.rb +67 -0
  46. data/lib/musicality/performance/supercollider/synthdefs/kicks.rb +158 -0
  47. data/lib/musicality/performance/supercollider/synthdefs/mario.rb +49 -0
  48. data/lib/musicality/performance/supercollider/{synthdefs.rb → synthdefs/other.rb} +0 -767
  49. data/lib/musicality/performance/supercollider/synthdefs/pianos.rb +46 -0
  50. data/lib/musicality/performance/supercollider/synthdefs/snares.rb +169 -0
  51. data/lib/musicality/performance/supercollider/synthdefs/toms.rb +25 -0
  52. data/lib/musicality/performance/supercollider/synthdefs/volume.rb +20 -0
  53. data/lib/musicality/pitch_class.rb +1 -1
  54. data/lib/musicality/pitch_classes.rb +3 -5
  55. data/lib/musicality/version.rb +1 -1
  56. data/lib/musicality.rb +25 -1
  57. data/musicality.gemspec +3 -2
  58. data/spec/composition/convenience_methods_spec.rb +8 -8
  59. data/spec/composition/generation/random_rhythm_generator_spec.rb +5 -5
  60. data/spec/composition/model/pitch_class_spec.rb +22 -16
  61. data/spec/composition/model/pitch_classes_spec.rb +5 -5
  62. data/spec/composition/model/rhythm_class_spec.rb +42 -0
  63. data/spec/composition/model/rhythm_spec.rb +43 -0
  64. data/spec/composition/model/scale_class_spec.rb +26 -26
  65. data/spec/composition/model/scale_spec.rb +38 -38
  66. data/spec/composition/sequencing/drum_machine/drum_machine_spec.rb +67 -0
  67. data/spec/composition/sequencing/drum_machine/drum_pattern_spec.rb +58 -0
  68. data/spec/composition/sequencing/note_array_spec.rb +94 -0
  69. data/spec/composition/sequencing/note_fifo_spec.rb +183 -0
  70. data/spec/composition/sequencing/sequencer_spec.rb +76 -0
  71. data/spec/composition/util/adding_sequence_spec.rb +33 -33
  72. data/spec/composition/util/compound_sequence_spec.rb +6 -6
  73. data/spec/composition/util/note_generation_spec.rb +34 -34
  74. data/spec/composition/util/probabilities_spec.rb +7 -7
  75. data/spec/composition/util/random_sampler_spec.rb +3 -3
  76. data/spec/composition/util/repeating_sequence_spec.rb +28 -28
  77. data/spec/musicality_spec.rb +1 -1
  78. data/spec/notation/conversion/change_conversion_spec.rb +87 -87
  79. data/spec/notation/conversion/note_time_converter_spec.rb +22 -22
  80. data/spec/notation/conversion/score_conversion_spec.rb +1 -1
  81. data/spec/notation/conversion/score_converter_spec.rb +31 -31
  82. data/spec/notation/conversion/tempo_conversion_spec.rb +11 -11
  83. data/spec/notation/model/change_spec.rb +80 -80
  84. data/spec/notation/model/key_spec.rb +135 -69
  85. data/spec/notation/model/link_spec.rb +27 -27
  86. data/spec/notation/model/meter_spec.rb +28 -28
  87. data/spec/notation/model/note_spec.rb +68 -47
  88. data/spec/notation/model/part_spec.rb +19 -19
  89. data/spec/notation/model/pitch_spec.rb +69 -68
  90. data/spec/notation/model/score_spec.rb +50 -47
  91. data/spec/notation/parsing/articulation_parsing_spec.rb +4 -4
  92. data/spec/notation/parsing/convenience_methods_spec.rb +49 -10
  93. data/spec/notation/parsing/duration_nodes_spec.rb +13 -13
  94. data/spec/notation/parsing/duration_parsing_spec.rb +10 -10
  95. data/spec/notation/parsing/key_parsing_spec.rb +19 -0
  96. data/spec/notation/parsing/link_nodes_spec.rb +7 -7
  97. data/spec/notation/parsing/link_parsing_spec.rb +4 -4
  98. data/spec/notation/parsing/meter_parsing_spec.rb +5 -5
  99. data/spec/notation/parsing/note_node_spec.rb +19 -19
  100. data/spec/notation/parsing/note_parsing_spec.rb +4 -4
  101. data/spec/notation/parsing/numbers/nonnegative_float_spec.rb +8 -8
  102. data/spec/notation/parsing/numbers/nonnegative_integer_spec.rb +2 -2
  103. data/spec/notation/parsing/numbers/nonnegative_rational_spec.rb +1 -1
  104. data/spec/notation/parsing/numbers/positive_float_spec.rb +8 -8
  105. data/spec/notation/parsing/numbers/positive_integer_spec.rb +6 -6
  106. data/spec/notation/parsing/numbers/positive_rational_spec.rb +6 -6
  107. data/spec/notation/parsing/pitch_node_spec.rb +7 -7
  108. data/spec/notation/parsing/pitch_parsing_spec.rb +2 -2
  109. data/spec/notation/parsing/segment_parsing_spec.rb +3 -3
  110. data/spec/notation/util/function_spec.rb +15 -15
  111. data/spec/notation/util/transition_spec.rb +12 -12
  112. data/spec/notation/util/value_computer_spec.rb +35 -36
  113. data/spec/performance/conversion/glissando_converter_spec.rb +24 -24
  114. data/spec/performance/conversion/note_sequence_extractor_spec.rb +39 -39
  115. data/spec/performance/conversion/portamento_converter_spec.rb +23 -23
  116. data/spec/performance/midi/midi_util_spec.rb +41 -41
  117. data/spec/performance/midi/part_sequencer_spec.rb +10 -10
  118. data/spec/performance/midi/score_sequencer_spec.rb +15 -15
  119. data/spec/performance/midi/score_sequencing_spec.rb +2 -2
  120. data/spec/performance/util/optimization_spec.rb +9 -9
  121. data/spec/printing/note_engraving_spec.rb +16 -16
  122. data/spec/printing/score_engraver_spec.rb +5 -5
  123. data/spec/spec_helper.rb +5 -0
  124. metadata +85 -30
@@ -9,7 +9,7 @@ class_cases = { Duration => {
9
9
  Note => {
10
10
  '/2' => Note::half,
11
11
  '99/10C2' => Note.new('99/10'.to_r, [C2]),
12
- '5/2Db4,Eb5.' => Note.new('5/2'.to_r, [Db4,Eb5], articulation:STACCATO)
12
+ '5/2Db4,Eb5.' => Note.new('5/2'.to_r, [Db4,Eb5], articulation:STACCATO)
13
13
  },
14
14
  Pitch => {
15
15
  'C2' => C2,
@@ -31,23 +31,23 @@ class_cases.each do |klass,cases|
31
31
  describe("#{klass}.parse") do
32
32
  it "should produce a single #{klass}" do
33
33
  cases.each do |str,tgt|
34
- klass.parse(str).should eq(tgt)
34
+ expect(klass.parse(str)).to eq(tgt)
35
35
  end
36
36
  end
37
37
  end
38
-
38
+
39
39
  describe("#{klass}.split_parse") do
40
40
  context 'joined with whitespace, using default pattern' do
41
41
  it "should produce multiple of #{klass}" do
42
42
  str = cases.keys.join(" ")
43
- klass.split_parse(str).should eq(cases.values)
43
+ expect(klass.split_parse(str)).to eq(cases.values)
44
44
  end
45
45
  end
46
-
46
+
47
47
  context 'joined by custom separator, using matching pattern' do
48
48
  it "should raise produce multiple of #{klass}" do
49
49
  str = cases.keys.join(";")
50
- klass.split_parse(str,";").should eq(cases.values)
50
+ expect(klass.split_parse(str,";")).to eq(cases.values)
51
51
  end
52
52
  end
53
53
  end
@@ -64,7 +64,7 @@ end
64
64
  describe "\##{method}" do
65
65
  it "should return a #{klass}" do
66
66
  class_cases[klass].each do |str,tgt|
67
- str.send(method).should eq(tgt)
67
+ expect(str.send(method)).to eq(tgt)
68
68
  end
69
69
  end
70
70
  end
@@ -72,6 +72,45 @@ end
72
72
  end
73
73
  end
74
74
 
75
+ # Failure cases
76
+ describe 'String' do
77
+ # Duration parsing
78
+ [:to_d, :to_dur, :to_duration].each do |method|
79
+ describe "\##{method}" do
80
+ it "should fail to parse 'A'" do
81
+ expect { 'A'.send(method) }.to raise_error(ParseError)
82
+ end
83
+ end
84
+ end
85
+
86
+ # Pitch parsing
87
+ [:to_p, :to_pitch].each do |method|
88
+ describe "\##{method}" do
89
+ it "should fail to parse '/2'" do
90
+ expect { '/2'.send(method) }.to raise_error(ParseError)
91
+ end
92
+ end
93
+ end
94
+
95
+ # Note parsing
96
+ [:to_n, :to_note].each do |method|
97
+ describe "\##{method}" do
98
+ it "should fail to parse 'A'" do
99
+ expect { 'A'.send(method) }.to raise_error(ParseError)
100
+ end
101
+ end
102
+ end
103
+
104
+ # Meter parsing
105
+ [:to_meter].each do |method|
106
+ describe "\##{method}" do
107
+ it "should fail to parse 'A'" do
108
+ expect { 'A'.send(method) }.to raise_error(ParseError)
109
+ end
110
+ end
111
+ end
112
+ end
113
+
75
114
  {
76
115
  Duration => [:to_ds, :to_durs, :to_durations],
77
116
  Pitch => [:to_ps, :to_pitches],
@@ -83,14 +122,14 @@ end
83
122
  context 'joined with whitespace' do
84
123
  it "should return multiple of #{klass}" do
85
124
  str = class_cases[klass].keys.join(" ")
86
- str.send(method).should eq(class_cases[klass].values)
125
+ expect(str.send(method)).to eq(class_cases[klass].values)
87
126
  end
88
127
  end
89
-
128
+
90
129
  context 'joined by custom separator, using matching pattern' do
91
130
  it "should raise produce multiple of #{klass}" do
92
131
  str = class_cases[klass].keys.join(";")
93
- str.send(method,";").should eq(class_cases[klass].values)
132
+ expect(str.send(method,";")).to eq(class_cases[klass].values)
94
133
  end
95
134
  end
96
135
  end
@@ -2,7 +2,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
2
 
3
3
  describe Parsing::NumDenNode do
4
4
  dur_parser = Parsing::DurationParser.new
5
-
5
+
6
6
  {
7
7
  '1/2' => Rational(1,2),
8
8
  '5/100' => Rational(5,100),
@@ -11,17 +11,17 @@ describe Parsing::NumDenNode do
11
11
  res = dur_parser.parse(str)
12
12
  context str do
13
13
  it 'should parse as NumDenNode' do
14
- res.should be_a Parsing::NumDenNode
14
+ expect(res).to be_a Parsing::NumDenNode
15
15
  end
16
16
 
17
17
  describe '#to_r' do
18
18
  r = res.to_r
19
19
  it 'should produce a Rational' do
20
- r.should be_a Rational
20
+ expect(r).to be_a Rational
21
21
  end
22
-
22
+
23
23
  it 'should produce value matching input str' do
24
- r.should eq tgt
24
+ expect(r).to eq tgt
25
25
  end
26
26
  end
27
27
  end
@@ -38,17 +38,17 @@ describe Parsing::NumOnlyNode do
38
38
  res = dur_parser.parse(str)
39
39
  context str do
40
40
  it 'should parse as NumOnlyNode' do
41
- res.should be_a Parsing::NumOnlyNode
41
+ expect(res).to be_a Parsing::NumOnlyNode
42
42
  end
43
43
 
44
44
  describe '#to_r' do
45
45
  r = res.to_r
46
46
  it 'should produce a Rational' do
47
- r.should be_a Rational
47
+ expect(r).to be_a Rational
48
48
  end
49
-
49
+
50
50
  it 'should produce value matching input str' do
51
- r.should eq tgt
51
+ expect(r).to eq tgt
52
52
  end
53
53
  end
54
54
  end
@@ -65,17 +65,17 @@ describe Parsing::DenOnlyNode do
65
65
  res = dur_parser.parse(str)
66
66
  context str do
67
67
  it 'should parse as DenOnlyNode' do
68
- res.should be_a Parsing::DenOnlyNode
68
+ expect(res).to be_a Parsing::DenOnlyNode
69
69
  end
70
70
 
71
71
  describe '#to_r' do
72
72
  r = res.to_r
73
73
  it 'should produce a Rational' do
74
- r.should be_a Rational
74
+ expect(r).to be_a Rational
75
75
  end
76
-
76
+
77
77
  it 'should produce value matching input str' do
78
- r.should eq tgt
78
+ expect(r).to eq tgt
79
79
  end
80
80
  end
81
81
  end
@@ -6,12 +6,12 @@ describe Parsing::DurationParser do
6
6
  @valid = {
7
7
  :numbers => [1,5,50,3999,01,0010,0000005050],
8
8
  }
9
-
9
+
10
10
  @invalid = {
11
11
  :numbers => [0,00],
12
- }
12
+ }
13
13
  end
14
-
14
+
15
15
  context 'valid (non-zero) numerator and denominator' do
16
16
  ["n","n/","n/d","/d"].each do |expr|
17
17
  it "should parse durations of the form #{expr}" do
@@ -19,7 +19,7 @@ describe Parsing::DurationParser do
19
19
  @valid[:numbers].each do |d|
20
20
  str = expr.gsub('n',"#{n}")
21
21
  str = str.gsub('d',"#{d}")
22
- dur_parser.parse(str).should_not be nil
22
+ expect(dur_parser.parse(str)).to_not be nil
23
23
  end
24
24
  end
25
25
  end
@@ -33,13 +33,13 @@ describe Parsing::DurationParser do
33
33
  @valid[:numbers].each do |d|
34
34
  str = expr.gsub('n',"#{n}")
35
35
  str = str.gsub('d',"#{d}")
36
- dur_parser.parse(str).should be nil
36
+ expect(dur_parser.parse(str)).to be nil
37
37
  end
38
38
  end
39
39
  end
40
40
  end
41
41
  end
42
-
42
+
43
43
  context 'valid numerator and invalid (zero) denominator' do
44
44
  ["n/d","/d"].each do |expr|
45
45
  it "should parse durations of the form #{expr}" do
@@ -47,13 +47,13 @@ describe Parsing::DurationParser do
47
47
  @invalid[:numbers].each do |d|
48
48
  str = expr.gsub('n',"#{n}")
49
49
  str = str.gsub('d',"#{d}")
50
- dur_parser.parse(str).should be nil
50
+ expect(dur_parser.parse(str)).to be nil
51
51
  end
52
52
  end
53
53
  end
54
54
  end
55
55
  end
56
-
56
+
57
57
  context 'invalid numerator and invalid denominator' do
58
58
  ["n","n/","n/d","/d"].each do |expr|
59
59
  it "should parse durations of the form #{expr}" do
@@ -61,10 +61,10 @@ describe Parsing::DurationParser do
61
61
  @invalid[:numbers].each do |d|
62
62
  str = expr.gsub('n',"#{n}")
63
63
  str = str.gsub('d',"#{d}")
64
- dur_parser.parse(str).should be nil
64
+ expect(dur_parser.parse(str)).to be nil
65
65
  end
66
66
  end
67
67
  end
68
68
  end
69
- end
69
+ end
70
70
  end
@@ -0,0 +1,19 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
+
3
+ describe Parsing::KeyParser do
4
+ before :all do
5
+ @parser = Parsing::KeyParser.new
6
+ end
7
+
8
+ {
9
+ "Cmaj" => Musicality::Keys::C_MAJOR,
10
+ "F#min" => Musicality::Keys::Fs_MINOR,
11
+ "Fmin" => Musicality::Keys::F_MINOR,
12
+ "Bbmaj" => Musicality::Keys::Bb_MAJOR
13
+ }.each do |str, key|
14
+ it "should parse #{str}" do
15
+ expect(@parser).to parse(str)
16
+ expect(str.to_key).to eq(key)
17
+ end
18
+ end
19
+ end
@@ -2,7 +2,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
2
 
3
3
  describe Parsing::LinkNode do
4
4
  parser = Parsing::LinkParser.new
5
-
5
+
6
6
  {
7
7
  LINK_SYMBOLS[Link::Tie] => Link::Tie.new,
8
8
  (LINK_SYMBOLS[Link::Glissando] + Db2.to_s) => Link::Glissando.new(Db2),
@@ -11,19 +11,19 @@ describe Parsing::LinkNode do
11
11
  res = parser.parse(str)
12
12
  context str do
13
13
  it 'should parse as LinkNode' do
14
- res.should be_a Parsing::LinkNode
14
+ expect(res).to be_a Parsing::LinkNode
15
15
  end
16
-
16
+
17
17
  describe '#to_pitch' do
18
18
  l = res.to_link
19
19
  it 'should produce a Link object' do
20
- l.should be_a Link
20
+ expect(l).to be_a Link
21
21
  end
22
-
22
+
23
23
  it 'should produce pitch matching input str' do
24
- l.should eq tgt
24
+ expect(l).to eq tgt
25
25
  end
26
26
  end
27
27
  end
28
- end
28
+ end
29
29
  end
@@ -4,16 +4,16 @@ describe Parsing::LinkParser do
4
4
  before :all do
5
5
  @parser = Parsing::LinkParser.new
6
6
  end
7
-
7
+
8
8
  it "should parse #{LINK_SYMBOLS[Link::Tie]}" do
9
- @parser.should parse(LINK_SYMBOLS[Link::Tie])
9
+ expect(@parser).to parse(LINK_SYMBOLS[Link::Tie])
10
10
  end
11
11
 
12
12
  it "should parse #{LINK_SYMBOLS[Link::Glissando]} with target pitch" do
13
- @parser.should parse(LINK_SYMBOLS[Link::Glissando] + C3.to_s)
13
+ expect(@parser).to parse(LINK_SYMBOLS[Link::Glissando] + C3.to_s)
14
14
  end
15
15
 
16
16
  it "should parse #{LINK_SYMBOLS[Link::Portamento]} with target pitch" do
17
- @parser.should parse(LINK_SYMBOLS[Link::Portamento] + C3.to_s)
17
+ expect(@parser).to parse(LINK_SYMBOLS[Link::Portamento] + C3.to_s)
18
18
  end
19
19
  end
@@ -2,7 +2,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
2
 
3
3
  describe Parsing::MeterParser do
4
4
  parser = Parsing::MeterParser.new
5
-
5
+
6
6
  {
7
7
  '4/4' => FOUR_FOUR,
8
8
  '2*3/8' => SIX_EIGHT,
@@ -11,13 +11,13 @@ describe Parsing::MeterParser do
11
11
  '3/4' => THREE_FOUR
12
12
  }.each do |str,met|
13
13
  res = parser.parse(str)
14
-
14
+
15
15
  it "should parse #{str}" do
16
- res.should_not be nil
16
+ expect(res).to_not be nil
17
17
  end
18
-
18
+
19
19
  it 'should produce node that properly converts to meter' do
20
- res.to_meter.should eq met
20
+ expect(res.to_meter).to eq met
21
21
  end
22
22
  end
23
23
  end
@@ -3,7 +3,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
3
3
  NOTE_PARSER = Parsing::NoteParser.new
4
4
 
5
5
  describe Parsing::NoteNode do
6
- context 'rest note' do
6
+ context 'rest note' do
7
7
  {
8
8
  '/2' => Note.new(Rational(1,2)),
9
9
  '4/2' => Note.new(Rational(4,2)),
@@ -13,17 +13,17 @@ describe Parsing::NoteNode do
13
13
  res = NOTE_PARSER.parse(str)
14
14
  context str do
15
15
  it 'should parse as NoteNode' do
16
- res.should be_a Parsing::NoteNode
16
+ expect(res).to be_a Parsing::NoteNode
17
17
  end
18
-
18
+
19
19
  describe '#to_note' do
20
20
  n = res.to_note
21
21
  it 'should produce a Note' do
22
- n.should be_a Note
22
+ expect(n).to be_a Note
23
23
  end
24
-
24
+
25
25
  it 'should produce value matching input str' do
26
- n.should eq tgt
26
+ expect(n).to eq tgt
27
27
  end
28
28
  end
29
29
  end
@@ -38,20 +38,20 @@ describe Parsing::NoteNode do
38
38
  "56/33B1!" => Note.new(Rational(56,33),[B1],articulation:STACCATISSIMO),
39
39
  }.each do |str,tgt|
40
40
  res = NOTE_PARSER.parse(str)
41
-
41
+
42
42
  context str do
43
43
  it 'should parse as `Node' do
44
- res.should be_a Parsing::NoteNode
44
+ expect(res).to be_a Parsing::NoteNode
45
45
  end
46
-
46
+
47
47
  describe '#to_note' do
48
48
  n = res.to_note
49
49
  it 'should produce a Note' do
50
- n.should be_a Note
50
+ expect(n).to be_a Note
51
51
  end
52
-
52
+
53
53
  it 'should produce value matching input str' do
54
- n.should eq tgt
54
+ expect(n).to eq tgt
55
55
  end
56
56
  end
57
57
  end
@@ -69,18 +69,18 @@ describe Parsing::NoteNode do
69
69
  res = NOTE_PARSER.parse(str)
70
70
  context str do
71
71
  it 'should parse as NoteNode' do
72
- res.should be_a Parsing::NoteNode
72
+ expect(res).to be_a Parsing::NoteNode
73
73
  end
74
-
74
+
75
75
  describe '#to_note' do
76
76
  n = res.to_note
77
77
 
78
78
  it 'should produce a Note' do
79
- n.should be_a Note
79
+ expect(n).to be_a Note
80
80
  end
81
-
81
+
82
82
  it 'should produce value matching input str' do
83
- n.should eq tgt
83
+ expect(n).to eq tgt
84
84
  end
85
85
  end
86
86
  end
@@ -96,7 +96,7 @@ describe Parsing::NoteNode do
96
96
  it 'should produce a Note with marks set correctly' do
97
97
  str = "#{begin_marks_str}/4Bb2#{end_marks_str}"
98
98
  n = NOTE_PARSER.parse(str).to_note
99
- n.marks.should eq(begin_marks+end_marks)
99
+ expect(n.marks).to eq(begin_marks+end_marks)
100
100
  end
101
101
  end
102
102
  end
@@ -107,7 +107,7 @@ describe Parsing::NoteNode do
107
107
  it 'should produce a Note with marks set to []' do
108
108
  str = "/4Bb2"
109
109
  n = NOTE_PARSER.parse(str).to_note
110
- n.marks.should eq([])
110
+ expect(n.marks).to eq([])
111
111
  end
112
112
  end
113
113
  end
@@ -4,7 +4,7 @@ describe Parsing::NoteParser do
4
4
  before :all do
5
5
  @parser = Parsing::NoteParser.new
6
6
  end
7
-
7
+
8
8
  valid_cases = {
9
9
  'duration only' => ['1/4','/2','1','55/33'],
10
10
  'single pitch' => ['/4C2','5/3Db3','/33E#8'],
@@ -26,11 +26,11 @@ describe Parsing::NoteParser do
26
26
  'begins marks at the end' => ['1Bb3('],
27
27
  'end marks at the beginning ' => [')3C3']
28
28
  }
29
-
29
+
30
30
  valid_cases.each do |descr, strs|
31
31
  context(descr + ' (valid)') do
32
32
  it 'should parse' do
33
- strs.each {|s| @parser.should parse(s) }
33
+ strs.each {|s| expect(@parser).to parse(s) }
34
34
  end
35
35
  end
36
36
  end
@@ -38,7 +38,7 @@ describe Parsing::NoteParser do
38
38
  invalid_cases.each do |descr, strs|
39
39
  context(descr + ' (invalid)') do
40
40
  it 'should not parse' do
41
- strs.each {|s| @parser.should_not parse(s) }
41
+ strs.each {|s| expect(@parser).to_not parse(s) }
42
42
  end
43
43
  end
44
44
  end
@@ -6,23 +6,23 @@ describe Parsing::NonnegativeFloatParser do
6
6
  ["0.0","0e1","2e2","1.0","0.50","05.003e-10","1.555e+2","3.443214","0.001","0000.0030000"].each do |str|
7
7
  res = parser.parse(str)
8
8
  f = str.to_f
9
-
9
+
10
10
  it "should parse '#{str}'" do
11
- res.should_not be nil
11
+ expect(res).to_not be nil
12
12
  end
13
13
 
14
14
  it 'should return node that is convertible to float using #to_f method' do
15
- res.to_f.should eq(f)
15
+ expect(res.to_f).to eq(f)
16
16
  end
17
-
17
+
18
18
  it 'should return node that is convertible to float using #to_num method' do
19
- res.to_num.should eq(f)
19
+ expect(res.to_num).to eq(f)
20
20
  end
21
21
  end
22
-
22
+
23
23
  ["-1.0","-0e1"].each do |str|
24
24
  it "should not parse '#{str}'" do
25
- parser.should_not parse(str)
26
- end
25
+ expect(parser).to_not parse(str)
26
+ end
27
27
  end
28
28
  end
@@ -5,11 +5,11 @@ describe Parsing::NonnegativeIntegerParser do
5
5
 
6
6
  ["1","50","05","502530","0"].each do |str|
7
7
  it "should parse '#{str}'" do
8
- parser.parse(str).should_not be nil
8
+ expect(parser.parse(str)).to_not be nil
9
9
  end
10
10
  end
11
11
 
12
12
  it 'should not parse an empty string' do
13
- parser.parse("").should be nil
13
+ expect(parser.parse("")).to be nil
14
14
  end
15
15
  end
@@ -5,7 +5,7 @@ describe Parsing::NonnegativeRationalParser do
5
5
 
6
6
  ["1/2","0/50","05/003","502530/1","0/1"].each do |str|
7
7
  it "should parse '#{str}'" do
8
- parser.parse(str).should_not be nil
8
+ expect(parser.parse(str)).to_not be nil
9
9
  end
10
10
  end
11
11
  end
@@ -6,23 +6,23 @@ describe Parsing::PositiveFloatParser do
6
6
  ["2e2","1.0","0.50","05.003e-10","1.555e+2","3.443214","0.001","0000.0030000"].each do |str|
7
7
  res = parser.parse(str)
8
8
  f = str.to_f
9
-
9
+
10
10
  it "should parse '#{str}'" do
11
- res.should_not be nil
11
+ expect(res).to_not be nil
12
12
  end
13
13
 
14
14
  it 'should return node that is convertible to float using #to_f method' do
15
- res.to_f.should eq(f)
15
+ expect(res.to_f).to eq(f)
16
16
  end
17
-
17
+
18
18
  it 'should return node that is convertible to float using #to_num method' do
19
- res.to_num.should eq(f)
19
+ expect(res.to_num).to eq(f)
20
20
  end
21
21
  end
22
-
22
+
23
23
  ["-2.0","-1.55e-2","0.0","0e1"].each do |str|
24
24
  it "should not parse '#{str}'" do
25
- parser.should_not parse(str)
26
- end
25
+ expect(parser).to_not parse(str)
26
+ end
27
27
  end
28
28
  end
@@ -6,23 +6,23 @@ describe Parsing::PositiveIntegerParser do
6
6
  ["1","50","05","502530"].each do |str|
7
7
  res = parser.parse(str)
8
8
  i = str.to_i
9
-
9
+
10
10
  it "should parse '#{str}'" do
11
- res.should_not be nil
11
+ expect(res).to_not be nil
12
12
  end
13
13
 
14
14
  it 'should return node that is convertible to integer using #to_i method' do
15
- res.to_i.should eq(i)
15
+ expect(res.to_i).to eq(i)
16
16
  end
17
-
17
+
18
18
  it 'should return node that is convertible to integer using #to_num method' do
19
- res.to_num.should eq(i)
19
+ expect(res.to_num).to eq(i)
20
20
  end
21
21
  end
22
22
 
23
23
  ["0"].each do |str|
24
24
  it "should not parse '#{str}'" do
25
- parser.should_not parse(str)
25
+ expect(parser).to_not parse(str)
26
26
  end
27
27
  end
28
28
  end
@@ -6,23 +6,23 @@ describe Parsing::PositiveRationalParser do
6
6
  ["1/2","50/50","050/003","502530/1","01/1"].each do |str|
7
7
  res = parser.parse(str)
8
8
  r = str.to_r
9
-
9
+
10
10
  it "should parse '#{str}'" do
11
- res.should_not be nil
11
+ expect(res).to_not be nil
12
12
  end
13
13
 
14
14
  it 'should return node that is convertible to rational using #to_r method' do
15
- res.to_r.should eq(r)
15
+ expect(res.to_r).to eq(r)
16
16
  end
17
-
17
+
18
18
  it 'should return node that is convertible to rational using #to_num method' do
19
- res.to_num.should eq(r)
19
+ expect(res.to_num).to eq(r)
20
20
  end
21
21
  end
22
22
 
23
23
  ["0/0","0/10","0000/1"].each do |str|
24
24
  it "should not parse '#{str}'" do
25
- parser.should_not parse(str)
25
+ expect(parser).to_not parse(str)
26
26
  end
27
27
  end
28
28
  end
@@ -2,7 +2,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
2
 
3
3
  describe Parsing::PitchNode do
4
4
  parser = Parsing::PitchParser.new
5
-
5
+
6
6
  {
7
7
  'C4' => C4,
8
8
  'Db2' => Db2,
@@ -19,19 +19,19 @@ describe Parsing::PitchNode do
19
19
  res = parser.parse(str)
20
20
  context str do
21
21
  it 'should parse as PitchNode' do
22
- res.should be_a Parsing::PitchNode
22
+ expect(res).to be_a Parsing::PitchNode
23
23
  end
24
-
24
+
25
25
  describe '#to_pitch' do
26
26
  p = res.to_pitch
27
27
  it 'should produce a Pitch object' do
28
- p.should be_a Pitch
28
+ expect(p).to be_a Pitch
29
29
  end
30
-
30
+
31
31
  it 'should produce pitch matching input str' do
32
- p.should eq tgt
32
+ expect(p).to eq tgt
33
33
  end
34
34
  end
35
35
  end
36
- end
36
+ end
37
37
  end