gitara 1.0.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +1 -0
  3. data/CHANGELOG.markdown +11 -0
  4. data/README.markdown +1 -1
  5. data/examples/aimee-man-wise-up.ly +1 -1
  6. data/gitara.gemspec +4 -5
  7. data/lib/gitara/app.rb +3 -3
  8. data/lib/gitara/node/base.rb +1 -4
  9. data/lib/gitara/template/tab.erb +1 -1
  10. data/lib/gitara/utilities.rb +7 -4
  11. data/lib/gitara/version.rb +1 -1
  12. data/lib/gitara.rb +2 -2
  13. data/spec/factories.rb +7 -7
  14. data/spec/lib/gitara/app_spec.rb +4 -4
  15. data/spec/lib/gitara/dsl_spec.rb +112 -112
  16. data/spec/lib/gitara/node/alternative_spec.rb +4 -4
  17. data/spec/lib/gitara/node/bar/chorded_version_spec.rb +6 -6
  18. data/spec/lib/gitara/node/bar/stanza_version_spec.rb +5 -5
  19. data/spec/lib/gitara/node/bar/voiced_version_spec.rb +5 -5
  20. data/spec/lib/gitara/node/bar_spec.rb +20 -20
  21. data/spec/lib/gitara/node/base/node_version_spec.rb +19 -19
  22. data/spec/lib/gitara/node/base/voiced_version_spec.rb +9 -9
  23. data/spec/lib/gitara/node/base_spec.rb +113 -106
  24. data/spec/lib/gitara/node/chord_set/chorded_version_spec.rb +2 -2
  25. data/spec/lib/gitara/node/line_spec.rb +2 -2
  26. data/spec/lib/gitara/node/repeat_spec.rb +3 -3
  27. data/spec/lib/gitara/node/stanza_spec.rb +14 -14
  28. data/spec/lib/gitara/node/tab_spec.rb +25 -25
  29. data/spec/lib/gitara/time_signature_spec.rb +6 -6
  30. data/spec/lib/gitara/voice_spec.rb +33 -33
  31. data/spec/lib/gitara_spec.rb +4 -4
  32. data/spec/spec_helper.rb +6 -4
  33. data/spec/support/app_tester.rb +5 -5
  34. metadata +68 -140
  35. data/examples/aimee-man-wise-up.midi +0 -0
  36. data/examples/aimee-man-wise-up.pdf +0 -0
  37. data/examples/eraserheads-huling-el-bimbo.midi +0 -0
  38. data/examples/eraserheads-huling-el-bimbo.pdf +0 -0
  39. data/examples/foo-fighters-walking-after-you.midi +0 -0
  40. data/examples/foo-fighters-walking-after-you.pdf +0 -0
  41. data/examples/tab-with-alternate-tuning.midi +0 -0
  42. data/examples/tab-with-alternate-tuning.pdf +0 -0
  43. data/examples/tab-with-chords.midi +0 -0
  44. data/examples/tab-with-chords.pdf +0 -0
  45. data/examples/tab-with-key-signature.midi +0 -0
  46. data/examples/tab-with-key-signature.pdf +0 -0
  47. data/examples/tab-with-line-with-no-break.midi +0 -0
  48. data/examples/tab-with-line-with-no-break.pdf +0 -0
  49. data/examples/tab-with-partial.midi +0 -0
  50. data/examples/tab-with-partial.pdf +0 -0
  51. data/examples/tab-with-repeats.midi +0 -0
  52. data/examples/tab-with-repeats.pdf +0 -0
  53. data/examples/tab-with-reused-bar-in-stanza.midi +0 -0
  54. data/examples/tab-with-reused-bar-in-stanza.pdf +0 -0
  55. data/examples/tab-with-time-signature.midi +0 -0
  56. data/examples/tab-with-time-signature.pdf +0 -0
@@ -3,63 +3,63 @@ require 'spec_helper'
3
3
  describe Gitara::Node::Tab do
4
4
  describe "#voices" do
5
5
  it "should create a max_number_of_voices voices" do
6
- tab = FactoryGirl.build(:tab, :children => [
7
- FactoryGirl.build(:bar, :children => [
8
- FactoryGirl.build(:note_set),
9
- FactoryGirl.build(:note_set)
6
+ tab = FactoryBot.build(:tab, :children => [
7
+ FactoryBot.build(:bar, :children => [
8
+ FactoryBot.build(:note_set),
9
+ FactoryBot.build(:note_set)
10
10
  ])
11
11
  ])
12
12
  voices = tab.voices
13
- voices.should have(2).values
14
- voices[0].id.should == 1
15
- voices[1].id.should == 2
16
- voices.map(&:parent).uniq.should == [tab]
13
+ expect(voices.size).to eq(2)
14
+ expect(voices[0].id).to eq(1)
15
+ expect(voices[1].id).to eq(2)
16
+ expect(voices.map(&:parent).uniq).to eq([tab])
17
17
  end
18
18
  end
19
19
 
20
20
  describe "#max_number_of_voices" do
21
21
  it "should be the max number of note_sets in a bar" do
22
- tab = FactoryGirl.build(:tab, :children => [
23
- FactoryGirl.build(:bar, :children => [
24
- FactoryGirl.build(:note_set),
25
- FactoryGirl.build(:note_set)
22
+ tab = FactoryBot.build(:tab, :children => [
23
+ FactoryBot.build(:bar, :children => [
24
+ FactoryBot.build(:note_set),
25
+ FactoryBot.build(:note_set)
26
26
  ])
27
27
  ])
28
28
 
29
- tab.max_number_of_voices.should == 2
29
+ expect(tab.max_number_of_voices).to eq(2)
30
30
  end
31
31
  end
32
32
 
33
33
  describe "#playable_child" do
34
34
  it "should be the last child of the tab" do
35
- tab = FactoryGirl.build(:tab, :children => [
36
- FactoryGirl.build(:bar, :name => 'Intro', :children => [
37
- FactoryGirl.build(:note_set),
38
- FactoryGirl.build(:note_set)
35
+ tab = FactoryBot.build(:tab, :children => [
36
+ FactoryBot.build(:bar, :name => 'Intro', :children => [
37
+ FactoryBot.build(:note_set),
38
+ FactoryBot.build(:note_set)
39
39
  ]),
40
- FactoryGirl.build(:bar, :name => 'Intro')
40
+ FactoryBot.build(:bar, :name => 'Intro')
41
41
  ])
42
42
 
43
- tab.playable_child.id.should == 2
43
+ expect(tab.playable_child.id).to eq(2)
44
44
  end
45
45
  end
46
46
 
47
47
  describe "#midi_instrument" do
48
48
  it "should have acoustic guitar (nylon) as default" do
49
- tab = FactoryGirl.build(:tab)
50
- tab.midi_instrument.should == 'acoustic guitar (nylon)'
49
+ tab = FactoryBot.build(:tab)
50
+ expect(tab.midi_instrument).to eq('acoustic guitar (nylon)')
51
51
  end
52
52
  end
53
53
 
54
54
  describe "#time_signature" do
55
55
  it "should be based on time if it exists" do
56
- tab = FactoryGirl.build(:tab, :time => '3/4')
57
- tab.time_signature.value.should == '3/4'
56
+ tab = FactoryBot.build(:tab, :time => '3/4')
57
+ expect(tab.time_signature.value).to eq('3/4')
58
58
  end
59
59
 
60
60
  it "should be 4/4 if time is not set" do
61
- tab = FactoryGirl.build(:tab, :time => nil)
62
- tab.time_signature.value.should == '4/4'
61
+ tab = FactoryBot.build(:tab, :time => nil)
62
+ expect(tab.time_signature.value).to eq('4/4')
63
63
  end
64
64
  end
65
65
  end
@@ -3,33 +3,33 @@ require 'spec_helper'
3
3
  describe Gitara::TimeSignature do
4
4
  describe "#rest_bar_value" do
5
5
  it "should be r1 if the time signature generates whole note bars" do
6
- FactoryGirl.build(:time_signature, :value => '4/4').rest_bar_value.should == "r1"
6
+ expect(FactoryBot.build(:time_signature, :value => '4/4').rest_bar_value).to eq("r1")
7
7
  end
8
8
 
9
9
  it "should be based on beat unit and beats per bar if the time signature does not generate whole note bars" do
10
- FactoryGirl.build(:time_signature, :value => '3/4').rest_bar_value.should == "r4 r4 r4"
10
+ expect(FactoryBot.build(:time_signature, :value => '3/4').rest_bar_value).to eq("r4 r4 r4")
11
11
  end
12
12
  end
13
13
 
14
14
  describe "#generates_whole_note_bars?" do
15
15
  it "should be true if the beat unit is the same as the beats per bar" do
16
- FactoryGirl.build(:time_signature, :value => '4/4').generates_whole_note_bars?.should be_true
16
+ expect(FactoryBot.build(:time_signature, :value => '4/4').generates_whole_note_bars?).to be_truthy
17
17
  end
18
18
 
19
19
  it "should be false if the beat unit is not the same as the beats per bar" do
20
- FactoryGirl.build(:time_signature, :value => '3/4').generates_whole_note_bars?.should be_false
20
+ expect(FactoryBot.build(:time_signature, :value => '3/4').generates_whole_note_bars?).to be_falsy
21
21
  end
22
22
  end
23
23
 
24
24
  describe "beat_unit" do
25
25
  it "is the second part of the value" do
26
- FactoryGirl.build(:time_signature, :value => '3/4').beat_unit.should == 4
26
+ expect(FactoryBot.build(:time_signature, :value => '3/4').beat_unit).to eq(4)
27
27
  end
28
28
  end
29
29
 
30
30
  describe "beats_per_bar" do
31
31
  it "is the first part of the value" do
32
- FactoryGirl.build(:time_signature, :value => '3/4').beats_per_bar.should == 3
32
+ expect(FactoryBot.build(:time_signature, :value => '3/4').beats_per_bar).to eq(3)
33
33
  end
34
34
  end
35
35
  end
@@ -3,83 +3,83 @@ require 'spec_helper'
3
3
  describe Gitara::Voice do
4
4
  describe "#call_name" do
5
5
  it "should be the variable name of the node when called inside lilypond" do
6
- voice = FactoryGirl.build(:voice, :id => 1)
7
- voice.call_name.should == '\vOne'
6
+ voice = FactoryBot.build(:voice, :id => 1)
7
+ expect(voice.call_name).to eq('\vOne')
8
8
  end
9
9
  end
10
10
 
11
11
  describe "#definition_name" do
12
12
  it "should be the name of the voice in a lilypond variable definition statement" do
13
- voice = FactoryGirl.build(:voice, :id => 1)
14
- voice.definition_name.should == "vOne"
13
+ voice = FactoryBot.build(:voice, :id => 1)
14
+ expect(voice.definition_name).to eq("vOne")
15
15
  end
16
16
  end
17
17
 
18
18
  describe "#id_as_word" do
19
19
  it "should convert the id to word" do
20
- node = FactoryGirl.build(:voice, :id => 1)
21
- node.id_as_word.should == "One"
20
+ node = FactoryBot.build(:voice, :id => 1)
21
+ expect(node.id_as_word).to eq("One")
22
22
  end
23
23
  end
24
24
 
25
25
  describe "#stem_type" do
26
26
  it "should be the lilypond stem type for the voice" do
27
- voice = FactoryGirl.build(:voice, :id => 1)
28
- voice.stem_type.should == '\voiceOne'
27
+ voice = FactoryBot.build(:voice, :id => 1)
28
+ expect(voice.stem_type).to eq('\voiceOne')
29
29
  end
30
30
  end
31
31
 
32
32
  describe "#transposition" do
33
33
  it "should be based on the tab's transposition and the voice's octave" do
34
- tab = FactoryGirl.build(:tab,
34
+ tab = FactoryBot.build(:tab,
35
35
  :transposition => 'd',
36
36
  :children => [
37
- FactoryGirl.build(:bar, :children => [
38
- FactoryGirl.build(:note_set),
39
- FactoryGirl.build(:note_set)
37
+ FactoryBot.build(:bar, :children => [
38
+ FactoryBot.build(:note_set),
39
+ FactoryBot.build(:note_set)
40
40
  ])
41
41
  ]
42
42
  )
43
- tab.max_number_of_voices.should == 2
43
+ expect(tab.max_number_of_voices).to eq(2)
44
44
 
45
- voice = FactoryGirl.build(:voice, :parent => tab, :id => 1)
46
- voice.transposition.should == "d''"
45
+ voice = FactoryBot.build(:voice, :parent => tab, :id => 1)
46
+ expect(voice.transposition).to eq("d''")
47
47
 
48
- voice = FactoryGirl.build(:voice, :parent => tab, :id => 2)
49
- voice.transposition.should == "d'"
48
+ voice = FactoryBot.build(:voice, :parent => tab, :id => 2)
49
+ expect(voice.transposition).to eq("d'")
50
50
  end
51
51
 
52
52
  it "should be blank if the tab has no transposition" do
53
- tab = FactoryGirl.build(:tab,
53
+ tab = FactoryBot.build(:tab,
54
54
  :children => [
55
- FactoryGirl.build(:bar, :children => [
56
- FactoryGirl.build(:note_set),
57
- FactoryGirl.build(:note_set)
55
+ FactoryBot.build(:bar, :children => [
56
+ FactoryBot.build(:note_set),
57
+ FactoryBot.build(:note_set)
58
58
  ])
59
59
  ]
60
60
  )
61
- tab.max_number_of_voices.should == 2
61
+ expect(tab.max_number_of_voices).to eq(2)
62
62
 
63
- voice = FactoryGirl.build(:voice, :parent => tab, :id => 1)
64
- voice.transposition.should be_nil
63
+ voice = FactoryBot.build(:voice, :parent => tab, :id => 1)
64
+ expect(voice.transposition).to be_nil
65
65
  end
66
66
  end
67
67
 
68
68
  describe "#octave" do
69
69
  it "should be based on the voice's position in the tab" do
70
- tab = FactoryGirl.build(:tab, :children => [
71
- FactoryGirl.build(:bar, :children => [
72
- FactoryGirl.build(:note_set),
73
- FactoryGirl.build(:note_set)
70
+ tab = FactoryBot.build(:tab, :children => [
71
+ FactoryBot.build(:bar, :children => [
72
+ FactoryBot.build(:note_set),
73
+ FactoryBot.build(:note_set)
74
74
  ])
75
75
  ])
76
- tab.max_number_of_voices.should == 2
76
+ expect(tab.max_number_of_voices).to eq(2)
77
77
 
78
- voice = FactoryGirl.build(:voice, :parent => tab, :id => 1)
79
- voice.octave.should == 2
78
+ voice = FactoryBot.build(:voice, :parent => tab, :id => 1)
79
+ expect(voice.octave).to eq(2)
80
80
 
81
- voice = FactoryGirl.build(:voice, :parent => tab, :id => 2)
82
- voice.octave.should == 1
81
+ voice = FactoryBot.build(:voice, :parent => tab, :id => 2)
82
+ expect(voice.octave).to eq(1)
83
83
  end
84
84
  end
85
85
  end
@@ -3,9 +3,9 @@ require 'spec_helper'
3
3
  describe Gitara do
4
4
  describe ".tab" do
5
5
  it "should create a tab instance if it does not exist" do
6
- Gitara.tab.should be_nil
6
+ expect(Gitara.tab).to be_nil
7
7
  Gitara.define
8
- Gitara.tab.should be_a(Node::Tab)
8
+ expect(Gitara.tab).to be_a(Node::Tab)
9
9
  end
10
10
  end
11
11
 
@@ -18,8 +18,8 @@ describe Gitara do
18
18
  end
19
19
 
20
20
  bars = tab.definitions(Node::Bar)
21
- bars.size.should == 1
22
- bars[0].name.should == 'Intro'
21
+ expect(bars.size).to eq(1)
22
+ expect(bars[0].name).to eq('Intro')
23
23
  end
24
24
  end
25
25
  end
data/spec/spec_helper.rb CHANGED
@@ -1,19 +1,21 @@
1
- require 'factory_girl'
1
+ require 'factory_bot'
2
2
  require 'gitara'
3
- require 'pry'
3
+ require 'byebug'
4
4
 
5
5
  RSpec.configure do |config|
6
6
  include Gitara
7
7
  require 'factories'
8
8
  require 'support/app_tester'
9
9
 
10
+ config.example_status_persistence_file_path = 'spec/support/examples.txt'
11
+
10
12
  config.before :each do
11
- test_tmp_dir.delete! if test_tmp_dir.exists? && ! run_lilypond?
13
+ test_tmp_dir.delete! if test_tmp_dir.exist? && ! run_lilypond?
12
14
  Gitara.instance_variable_set :@tab, nil
13
15
  end
14
16
 
15
17
  def test_tmp_dir
16
- Pow('tmp/test')
18
+ Pathname.new('tmp/test')
17
19
  end
18
20
 
19
21
  def run_lilypond?
@@ -4,18 +4,18 @@ class AppTester < Valuable
4
4
  has_value :run_lilypond, :klass => :boolean, :default => false
5
5
 
6
6
  def run
7
- app = FactoryGirl.build(:app)
7
+ app = FactoryBot.build(:app)
8
8
  app.invoke :export, ["examples/#{name}.rb"],
9
9
  "target-directory" => test_tmp_dir.path,
10
10
  "run-lilypond" => self.run_lilypond?
11
- (Pow("tmp") / "#{name}.ly").write actual if self.expected != self.actual
11
+ (Pathname.new("tmp") / "#{name}.ly").write actual if self.expected != self.actual
12
12
  end
13
13
 
14
14
  def expected
15
- @expected ||= Utilities.read!(Pow("examples/#{name}.ly")).gsub(/\n\s+\n/, "\n")
16
- rescue PowError => e
15
+ @expected ||= Utilities.read!(Pathname.new("examples/#{name}.ly")).gsub(/\n\s+\n/, "\n")
16
+ rescue Utilities::PathnameDoesNotExist => e
17
17
  puts "#{e.message}. Copying actual result..."
18
- Pow("examples/#{name}.ly").write actual
18
+ Pathname.new("examples/#{name}.ly").write actual
19
19
  retry
20
20
  end
21
21