gdshowsdb 0.9.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 (90) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +6 -0
  3. data/.rvmrc +4 -0
  4. data/.travis.yml +4 -0
  5. data/Gemfile +12 -0
  6. data/Gemfile.lock +106 -0
  7. data/LICENSE.txt +22 -0
  8. data/README.md +49 -0
  9. data/Rakefile +4 -0
  10. data/data/gdshowsdb/1965.yaml +78 -0
  11. data/data/gdshowsdb/1966.yaml +780 -0
  12. data/data/gdshowsdb/1967.yaml +857 -0
  13. data/data/gdshowsdb/1968.yaml +1252 -0
  14. data/data/gdshowsdb/1969.yaml +1799 -0
  15. data/data/gdshowsdb/1970.yaml +3547 -0
  16. data/data/gdshowsdb/1971.yaml +1396 -0
  17. data/data/gdshowsdb/1972.yaml +6849 -0
  18. data/data/gdshowsdb/1973.yaml +6229 -0
  19. data/data/gdshowsdb/1974.yaml +3516 -0
  20. data/data/gdshowsdb/1975.yaml +207 -0
  21. data/data/gdshowsdb/1976.yaml +3226 -0
  22. data/data/gdshowsdb/1977.yaml +4469 -0
  23. data/data/gdshowsdb/1978.yaml +5681 -0
  24. data/data/gdshowsdb/1979.yaml +5487 -0
  25. data/data/gdshowsdb/1980.yaml +7133 -0
  26. data/data/gdshowsdb/1981.yaml +6347 -0
  27. data/data/gdshowsdb/1982.yaml +4475 -0
  28. data/data/gdshowsdb/1983.yaml +4561 -0
  29. data/data/gdshowsdb/1984.yaml +4431 -0
  30. data/data/gdshowsdb/1985.yaml +4810 -0
  31. data/data/gdshowsdb/1986.yaml +3029 -0
  32. data/data/gdshowsdb/1987.yaml +5958 -0
  33. data/data/gdshowsdb/1988.yaml +5398 -0
  34. data/data/gdshowsdb/1989.yaml +4979 -0
  35. data/data/gdshowsdb/1990.yaml +4941 -0
  36. data/data/gdshowsdb/1991.yaml +5269 -0
  37. data/data/gdshowsdb/1992.yaml +3576 -0
  38. data/data/gdshowsdb/1993.yaml +5178 -0
  39. data/data/gdshowsdb/1994.yaml +5206 -0
  40. data/data/gdshowsdb/1995.yaml +2931 -0
  41. data/data/gdshowsdb/shows-debug.yaml +138 -0
  42. data/data/gdshowsdb/song_refs.yaml +411 -0
  43. data/gdshowsdb.gemspec +23 -0
  44. data/lib/gdshowsdb/db/migrations/001_create_song_ref_table.rb +15 -0
  45. data/lib/gdshowsdb/db/migrations/002_import_song_refs.rb +14 -0
  46. data/lib/gdshowsdb/db/migrations/003_create_show_table.rb +22 -0
  47. data/lib/gdshowsdb/db/migrations/004_create_show_set_table.rb +15 -0
  48. data/lib/gdshowsdb/db/migrations/005_create_song_table.rb +18 -0
  49. data/lib/gdshowsdb/db/migrations/006_create_song_occurences_table.rb +17 -0
  50. data/lib/gdshowsdb/db/migrations/008_add_count_to_song_ref_table.rb +11 -0
  51. data/lib/gdshowsdb/db/migrations/009_import_shows.rb +45 -0
  52. data/lib/gdshowsdb/diff.rb +36 -0
  53. data/lib/gdshowsdb/generators/gdshowsdatabase_generator.rb +17 -0
  54. data/lib/gdshowsdb/generators/gdshowsdatabase_upgrade_generator.rb +49 -0
  55. data/lib/gdshowsdb/models/extensions/uuid.rb +9 -0
  56. data/lib/gdshowsdb/models/show.rb +58 -0
  57. data/lib/gdshowsdb/models/show_set.rb +40 -0
  58. data/lib/gdshowsdb/models/song.rb +72 -0
  59. data/lib/gdshowsdb/models/song_occurence.rb +9 -0
  60. data/lib/gdshowsdb/models/song_ref.rb +32 -0
  61. data/lib/gdshowsdb/set_db_extractor.rb +19 -0
  62. data/lib/gdshowsdb/set_diff.rb +10 -0
  63. data/lib/gdshowsdb/set_yaml_parser.rb +29 -0
  64. data/lib/gdshowsdb/show_db_extractor.rb +19 -0
  65. data/lib/gdshowsdb/show_diff.rb +12 -0
  66. data/lib/gdshowsdb/show_yaml_parser.rb +20 -0
  67. data/lib/gdshowsdb/song_db_extractor.rb +21 -0
  68. data/lib/gdshowsdb/song_diff.rb +10 -0
  69. data/lib/gdshowsdb/song_ref_db_extractror.rb +18 -0
  70. data/lib/gdshowsdb/song_ref_diff.rb +12 -0
  71. data/lib/gdshowsdb/song_ref_yaml_parser.rb +19 -0
  72. data/lib/gdshowsdb/song_yaml_parser.rb +25 -0
  73. data/lib/gdshowsdb/templates/update_migration.rb.erb +53 -0
  74. data/lib/gdshowsdb/version.rb +3 -0
  75. data/lib/gdshowsdb.rb +45 -0
  76. data/sample.rb +29 -0
  77. data/spec/gdshowsdb/diff_spec.rb +69 -0
  78. data/spec/gdshowsdb/models/show_set_spec.rb +29 -0
  79. data/spec/gdshowsdb/models/show_spec.rb +13 -0
  80. data/spec/gdshowsdb/models/song_spec.rb +72 -0
  81. data/spec/gdshowsdb/set_db_extractor_spec.rb +37 -0
  82. data/spec/gdshowsdb/set_yaml_parser_spec.rb +74 -0
  83. data/spec/gdshowsdb/show_db_extractor_spec.rb +25 -0
  84. data/spec/gdshowsdb/show_yaml_parser_spec.rb +42 -0
  85. data/spec/gdshowsdb/song_db_extractor_spec.rb +47 -0
  86. data/spec/gdshowsdb/song_ref_db_extractor_spec.rb +20 -0
  87. data/spec/gdshowsdb/song_ref_yaml_parser_spec.rb +19 -0
  88. data/spec/gdshowsdb/song_yaml_parser_spec.rb +93 -0
  89. data/spec/spec_helper.rb +15 -0
  90. metadata +186 -0
data/lib/gdshowsdb.rb ADDED
@@ -0,0 +1,45 @@
1
+ require "gdshowsdb/version"
2
+
3
+ require 'rubygems'
4
+ require 'active_record'
5
+ require 'rails/generators'
6
+
7
+ require File.dirname(__FILE__) + '/gdshowsdb/diff.rb'
8
+ Dir[File.dirname(__FILE__) + '/gdshowsdb/*.rb'].each {|file| require file }
9
+ Dir[File.dirname(__FILE__) + '/gdshowsdb/db/migrations/*.rb'].each {|file| require file }
10
+ Dir[File.dirname(__FILE__) + '/gdshowsdb/models/extensions/*.rb'].each {|file| require file }
11
+ Dir[File.dirname(__FILE__) + '/gdshowsdb/models/*.rb'].each {|file| require file }
12
+ Dir[File.dirname(__FILE__) + '/gdshowsdb/generators/*.rb'].each {|file| require file }
13
+
14
+ module Gdshowsdb
15
+
16
+ def generate_uuid
17
+ SecureRandom.uuid
18
+ end
19
+
20
+ def self.init(params = { adapter: 'sqlite3', database: 'gdshowsdb.db' })
21
+ @@connection = ActiveRecord::Base.establish_connection(params)
22
+ end
23
+
24
+ def self.load(level = nil)
25
+ ActiveRecord::Migrator.up File.dirname(__FILE__) + '/gdshowsdb/db/migrations', level
26
+ end
27
+
28
+ def self.load_yaml(file_name)
29
+ YAML.load_file(Gem.datadir('gdshowsdb') + "/#{file_name}")
30
+ end
31
+
32
+ def self.load_yaml_for_year(year)
33
+ load_yaml("#{year}.yaml")
34
+ end
35
+ end
36
+
37
+ class Hash
38
+ def convert_to_sym
39
+ inject({}) do |symboled, (k,v)|
40
+ symboled[k.to_sym] = v
41
+ symboled
42
+ end
43
+ end
44
+ end
45
+
data/sample.rb ADDED
@@ -0,0 +1,29 @@
1
+ require 'gdshowsdb'
2
+
3
+ Gdshowsdb.init()
4
+ Gdshowsdb.load()
5
+
6
+ puts "Sample Application"
7
+
8
+ show = Show.find_by_year_and_month_and_day(1995,7,8)
9
+
10
+ puts "#{show.year}/#{show.month}/#{show.day} @ #{show.venue}"
11
+
12
+ show.show_sets.each do |set|
13
+ puts set.encore? ? 'Encore' : "Set #{set.position + 1}"
14
+ set.songs.each do |song|
15
+ song_string = "#{song.position} #{song.song_ref.name}"
16
+ song_string << " >" if song.segued
17
+ puts song_string
18
+ end
19
+ end
20
+
21
+ jack_straw = SongRef.find_by_name('Jack Straw')
22
+ puts "#{jack_straw.name} was played #{jack_straw.song_occurences.size} times"
23
+ jack_straw_shows = jack_straw.shows
24
+
25
+ jack_straw_shows.each do |show|
26
+ puts show.title
27
+ end
28
+
29
+ puts SongRef.friendly.find('althea').inspect
@@ -0,0 +1,69 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Diff' do
4
+
5
+ let(:from_yaml) { nil }
6
+ let(:from_db) { nil }
7
+ let(:common_set) { {uuid: generate_uuid, show_uuid: generate_uuid, position: 1, encore: false} }
8
+
9
+ before(:each) do
10
+ @diff = Gdshowsdb::Diff.new(from_yaml, from_db)
11
+ end
12
+
13
+ context 'set added to the yaml' do
14
+ let(:added_set) { {uuid: generate_uuid, show_uuid: generate_uuid, position: 2, encore: false} }
15
+ let(:from_yaml) {[common_set, added_set]}
16
+ let(:from_db) { [common_set] }
17
+ subject { @diff.added }
18
+
19
+ it { should == [added_set] }
20
+ end
21
+
22
+ context 'set removed from the yaml' do
23
+ let(:removed_set) { {uuid: generate_uuid, show_uuid: generate_uuid, position: 2, encore: false} }
24
+ let(:from_yaml) { [common_set] }
25
+ let(:from_db) {[common_set, removed_set]}
26
+ subject { @diff.removed }
27
+
28
+ it { should == [removed_set] }
29
+ end
30
+
31
+ context 'set updated in the yaml' do
32
+ let(:set_uuid) { generate_uuid }
33
+ let(:added_set) { {uuid: generate_uuid, show_uuid: generate_uuid, position: 2, encore: false} }
34
+ let(:original_set) { {uuid: set_uuid, show_uuid: generate_uuid, position: 2, encore: false} }
35
+ let(:updated_set) { {uuid: set_uuid, show_uuid: generate_uuid, position: 1, encore: true } }
36
+ let(:from_yaml) { [common_set, updated_set, added_set] }
37
+ let(:from_db) { [common_set, original_set] }
38
+ subject { @diff.updated }
39
+
40
+ it { should == [updated_set] }
41
+
42
+ it 'should not include updated set in added' do
43
+ (@diff.added.select { |item| item[:uuid] == set_uuid }).size.should == 0
44
+ end
45
+
46
+ it 'should not include updated set in removed' do
47
+ (@diff.removed.select { |item| item[:uuid] == set_uuid }).size.should == 0
48
+ end
49
+ end
50
+
51
+ context 'order of inputs should be irrelevant' do
52
+ let(:additional_set) { {uuid: generate_uuid, show_uuid: generate_uuid, position: 2, encore: false} }
53
+ let(:from_yaml) { [common_set, additional_set] }
54
+ let(:from_db) { [additional_set, common_set] }
55
+
56
+ it 'should not find any added' do
57
+ @diff.updated.empty?.should == true
58
+ end
59
+
60
+ it 'should not find any removed' do
61
+ @diff.removed.empty?.should == true
62
+ end
63
+
64
+ it 'should not find any updated' do
65
+ @diff.updated.empty?.should == true
66
+ end
67
+ end
68
+
69
+ end
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'ShowSet' do
4
+ let(:show_uuid) { generate_uuid }
5
+ let(:show) { Show.create(uuid: show_uuid) }
6
+
7
+ let(:show_set_uuid) { generate_uuid }
8
+ let(:set_spec) { {uuid: show_set_uuid, show_uuid: show.uuid, position: 0, encore: false} }
9
+ let(:show_set) { ShowSet.create_from(set_spec) }
10
+
11
+ context '#create_from' do
12
+ subject { show_set }
13
+ it { should_not == nil }
14
+ its(:show) { should == show }
15
+ end
16
+
17
+ context '#remove_from' do
18
+ before(:each) do
19
+ ShowSet.create_from(set_spec)
20
+ ShowSet.remove_from(set_spec)
21
+ show.show_sets.each {}
22
+ end
23
+
24
+ subject { show }
25
+
26
+ its(:show_sets) { should_not include show_set }
27
+ end
28
+
29
+ end
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Show" do
4
+ let(:show_spec) { {uuid: generate_uuid, venue: 'The Venue', city: 'Boulder', state: 'CO', country: 'US', year: 1981, month: 2, day: 25, position: 0} }
5
+
6
+ context '#update_from' do
7
+ before(:each) { Show.create_from(show_spec) }
8
+ subject { show_spec[:position] = 1; Show.update_from(show_spec) }
9
+
10
+ its(:position) { should == 1 }
11
+ end
12
+
13
+ end
@@ -0,0 +1,72 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Song' do
4
+ let(:song_ref_one_name) { generate_uuid }
5
+ let(:song_ref_one) { SongRef.create(uuid: generate_uuid, name: song_ref_one_name) }
6
+
7
+ let(:show) { Show.create(uuid: generate_uuid) }
8
+ let(:set_one_uuid) { generate_uuid }
9
+ let(:set_one) do
10
+ ShowSet.create(uuid: set_one_uuid) do |s|
11
+ s.show = show
12
+ s.position = 0
13
+ s.encore = false
14
+ end
15
+ end
16
+ let(:song_one_uuid) { generate_uuid }
17
+ let(:song_spec) { {uuid: song_one_uuid, position: 0, segued: true, show_set_uuid: set_one.uuid, name: song_ref_one.name} }
18
+ let(:song) { Song.create_from(song_spec) }
19
+
20
+ context '#create_from' do
21
+ context 'song_ref' do
22
+ subject { song_ref_one }
23
+ its(:songs) { should include song }
24
+ end
25
+
26
+ context 'occurences' do
27
+ before(:each) { song }
28
+ subject { song_ref_one.song_occurences.find_by_show_uuid(show.uuid) }
29
+ its(:song_ref) { should == song_ref_one }
30
+ end
31
+ end
32
+
33
+ context '#remove_from' do
34
+ before(:each) do
35
+ song
36
+ Song.remove_from(song_spec)
37
+ end
38
+
39
+ context 'song_ref' do
40
+ subject { song_ref_one }
41
+ its(:songs) { should == []}
42
+ end
43
+
44
+ context 'occurences' do
45
+ subject { song_ref_one.song_occurences.find_by_show_uuid(show.uuid) }
46
+ it { should == nil }
47
+ end
48
+ end
49
+
50
+ context '#update_from' do
51
+ let(:new_set_uuid) { generate_uuid }
52
+ let(:new_show_set) do
53
+ ShowSet.create(uuid: new_set_uuid) do |s|
54
+ s.show = show
55
+ s.position = 1
56
+ s.encore = true
57
+ end
58
+ end
59
+
60
+ subject do
61
+ Song.create_from(song_spec)
62
+ song_spec[:show_set_uuid] = new_show_set[:uuid]
63
+ song_spec[:segued] = false
64
+ Song.update_from(song_spec)
65
+ end
66
+
67
+ it { should_not == nil }
68
+ its(:show_set) { should == new_show_set }
69
+ its(:segued) { should == false }
70
+ end
71
+
72
+ end
@@ -0,0 +1,37 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'SetDBExtractor' do
4
+ let(:show_uuid) { generate_uuid }
5
+ let(:show) { Show.create(uuid: show_uuid) }
6
+
7
+ let(:first_show_set_uuid) { generate_uuid }
8
+ let(:sets) do
9
+ [
10
+ ShowSet.create(uuid: first_show_set_uuid) do |s|
11
+ s.show = show
12
+ s.position = 0
13
+ s.encore = false
14
+ end,
15
+ ShowSet.create(uuid: generate_uuid) do |s|
16
+ s.show = show
17
+ s.position = 1
18
+ s.encore = false
19
+ end,
20
+ ShowSet.create(uuid: generate_uuid) do |s|
21
+ s.show = show
22
+ s.position = 2
23
+ s.encore = true
24
+ end
25
+ ]
26
+ end
27
+
28
+ subject(:extracted) { Gdshowsdb::SetDBExtractor.new(sets).extract }
29
+
30
+ its(:size) { should equal 3 }
31
+
32
+ context 'individual item' do
33
+ subject { extracted[0] }
34
+
35
+ it { should == ({ uuid: first_show_set_uuid, show_uuid: show_uuid, position: 0, encore: false }) }
36
+ end
37
+ end
@@ -0,0 +1,74 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'SetYAMLParser' do
4
+
5
+ let(:first_show_uuid) { generate_uuid }
6
+ let(:second_show_uuid) { generate_uuid }
7
+ let(:hash) do
8
+ {
9
+ '1999/01/01' => {
10
+ uuid: first_show_uuid,
11
+ venue: 'Boulder Theater',
12
+ city: 'Boulder',
13
+ state: 'CO',
14
+ country: 'US',
15
+ sets: first_show_sets
16
+ },
17
+ '1999/01/02' => {
18
+ uuid: second_show_uuid,
19
+ venue: 'Ogden Theater',
20
+ city: 'Denver',
21
+ state: 'CO',
22
+ country: 'US',
23
+ sets: second_show_sets
24
+ }
25
+ }
26
+ end
27
+
28
+ before(:each) do
29
+ @parser = Gdshowsdb::SetYAMLParser.new(hash)
30
+ end
31
+
32
+ context 'no shows have sets' do
33
+ let(:first_show_sets) { nil }
34
+ let(:second_show_sets) { [] }
35
+
36
+ it 'should not find any sets' do
37
+ @parser.parse.empty?.should == true
38
+ end
39
+ end
40
+
41
+ context 'some shows have sets' do
42
+ let(:first_show_set_one_uuid) { generate_uuid }
43
+ let(:first_show_set_two_uuid) { generate_uuid }
44
+ let(:first_show_sets) do
45
+ [
46
+ {
47
+ uuid: first_show_set_one_uuid,
48
+ songs: [
49
+ {uuid: generate_uuid},
50
+ {uuid: generate_uuid},
51
+ {uuid: generate_uuid},
52
+ {uuid: generate_uuid},
53
+ {uuid: generate_uuid}
54
+ ]
55
+ },
56
+ {
57
+ uuid: first_show_set_two_uuid,
58
+ songs: [
59
+ {uuid: generate_uuid},
60
+ {uuid: generate_uuid}
61
+ ]
62
+ }
63
+ ]
64
+ end
65
+
66
+ let(:second_show_sets) { nil }
67
+ subject { @parser.parse }
68
+
69
+ it { should eql [
70
+ {uuid: first_show_set_one_uuid, show_uuid: first_show_uuid, position: 0, encore: false},
71
+ {uuid: first_show_set_two_uuid, show_uuid: first_show_uuid, position: 1, encore: true} ] }
72
+ end
73
+
74
+ end
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'ShowDBExtractor' do
4
+
5
+ let(:first) { {uuid: generate_uuid, venue: 'The Venue', city: 'Boulder', state: 'CO', country: 'US', year: 1981, month: 2, day: 25, position: 0} }
6
+ let(:second) { {uuid: generate_uuid, venue: 'The Venue', city: 'Boulder', state: 'CO', country: 'US', year: 1981, month: 2, day: 25, position: 1} }
7
+ let(:third) { {uuid: generate_uuid, venue: 'The Other Venue', city: 'Denver', state: 'CO', country: 'US', year: 1981, month: 2, day: 26} }
8
+ let(:shows) do
9
+ [
10
+ Show.create(first),
11
+ Show.create(second),
12
+ Show.create(third) do |show|
13
+ show.show_sets.push(ShowSet.create(uuid: generate_uuid, show: show))
14
+ end
15
+ ]
16
+ end
17
+
18
+ subject { Gdshowsdb::ShowDBExtractor.new(shows).extract }
19
+
20
+ its(:size) { should == 3 }
21
+ it { should include first }
22
+ it { should include second }
23
+ it { should include third }
24
+
25
+ end
@@ -0,0 +1,42 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'ShowYAMLParser' do
4
+
5
+ let(:first_uuid) { generate_uuid }
6
+ let(:second_uuid) { generate_uuid }
7
+ let(:third_uuid) { generate_uuid }
8
+ let(:shows) do
9
+ {
10
+ '1981/02/25/0' => {
11
+ uuid: first_uuid,
12
+ venue: 'The Venue',
13
+ city: 'Boulder',
14
+ state: 'CO',
15
+ country: 'US'
16
+ },
17
+ '1981/02/25/1' => {
18
+ uuid: second_uuid,
19
+ venue: 'The Venue',
20
+ city: 'Boulder',
21
+ state: 'CO',
22
+ country: 'US'
23
+ },
24
+ '1981/02/26' => {
25
+ uuid: third_uuid,
26
+ venue: 'The Other Venue',
27
+ city: 'Denver',
28
+ state: 'CO',
29
+ country: 'US',
30
+ sets: []
31
+ }
32
+ }
33
+ end
34
+
35
+ subject { Gdshowsdb::ShowYAMLParser.new(shows).parse }
36
+
37
+ its(:size) { should == 3 }
38
+ it { should include ( {uuid: first_uuid, venue: 'The Venue', city: 'Boulder', state: 'CO', country: 'US', year: 1981, month: 2, day: 25, position: 0 } ) }
39
+ it { should include ( {uuid: second_uuid, venue: 'The Venue', city: 'Boulder', state: 'CO', country: 'US', year: 1981, month: 2, day: 25, position: 1 } ) }
40
+ it { should include ( {uuid: third_uuid, venue: 'The Other Venue', city: 'Denver', state: 'CO', country: 'US', year: 1981, month: 2, day: 26} ) }
41
+
42
+ end
@@ -0,0 +1,47 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'SongDBExtractor' do
4
+ let(:song_one) { SongRef.create(uuid: generate_uuid, name: "Song 1") }
5
+ let(:song_two) { SongRef.create(uuid: generate_uuid, name: "Song 2") }
6
+
7
+ let(:show) { Show.create(uuid: generate_uuid) }
8
+ let(:set_one_uuid) { generate_uuid }
9
+ let(:set_two_uuid) { generate_uuid }
10
+ let(:set_one) do
11
+ ShowSet.create(uuid: set_one_uuid) do |s|
12
+ s.show = show
13
+ s.position = 0
14
+ s.encore = false
15
+ end
16
+ end
17
+ let(:set_two) do
18
+ ShowSet.create(uuid: set_two_uuid) do |s|
19
+ s.show = show
20
+ s.position = 1
21
+ s.encore = false
22
+ end
23
+ end
24
+
25
+ let(:song_one_uuid) { generate_uuid }
26
+ let(:song_two_uuid) { generate_uuid }
27
+ let(:songs) do
28
+ [
29
+ Song.create(uuid: song_one_uuid, position: 0, segued: true) do |s|
30
+ s.show_set = set_one
31
+ s.song_ref = song_one
32
+ end,
33
+ Song.create(uuid: song_two_uuid, position: 1, segued: false) do |s|
34
+ s.show_set = set_two
35
+ s.song_ref = song_two
36
+ end
37
+ ]
38
+ end
39
+
40
+ subject { Gdshowsdb::SongDBExtractor.new(songs).extract }
41
+
42
+ its(:size) { should == 2 }
43
+
44
+ it { should include ( {uuid: song_one_uuid, name: 'Song 1', show_set_uuid: set_one_uuid, position: 0, segued: true} ) }
45
+ it { should include ( {uuid: song_two_uuid, name: 'Song 2', show_set_uuid: set_two_uuid, position: 1, segued: false} ) }
46
+
47
+ end
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'SongRefDBExtractor' do
4
+
5
+ let(:first_song_uuid) { generate_uuid }
6
+ let(:second_song_uuid) { generate_uuid }
7
+ let(:song_ref_list) do
8
+ [
9
+ SongRef.create(uuid: first_song_uuid, name: "Song 1"),
10
+ SongRef.create(uuid: second_song_uuid, name: "Song 2")
11
+ ]
12
+ end
13
+
14
+ subject { Gdshowsdb::SongRefDBExtractor.new(song_ref_list).extract }
15
+
16
+ it { should include ( {uuid: first_song_uuid, name: 'Song 1'} ) }
17
+
18
+ it { should include ( {uuid: second_song_uuid, name: 'Song 2'} ) }
19
+
20
+ end
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'SongRefYamlParser' do
4
+
5
+ let(:first_song_uuid) { generate_uuid }
6
+ let(:second_song_uuid) { generate_uuid }
7
+ let(:song_ref_list) do
8
+ [
9
+ {"Song A" => first_song_uuid},
10
+ {"Song B" => second_song_uuid}
11
+ ]
12
+ end
13
+
14
+ subject { Gdshowsdb::SongRefYAMLParser.new(song_ref_list).parse }
15
+
16
+ its(:size) { should == 2 }
17
+ it { should include ( {uuid: first_song_uuid, name: 'Song A'}) }
18
+ it { should include ( {uuid: second_song_uuid, name: 'Song B'}) }
19
+ end
@@ -0,0 +1,93 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'SongYAMLParser' do
4
+
5
+ let(:show_one_set_one_uuid) { generate_uuid }
6
+ let(:show_one_set_two_uuid) { generate_uuid }
7
+ let(:show_two_set_one_uuid) { generate_uuid }
8
+ let(:song_one_uuid) { generate_uuid }
9
+ let(:song_two_uuid) { generate_uuid }
10
+ let(:song_three_uuid) { generate_uuid }
11
+ let(:song_a_uuid) { generate_uuid }
12
+ let(:song_b_uuid) { generate_uuid }
13
+ let(:song_c_uuid) { generate_uuid }
14
+ let(:shows) do
15
+ {
16
+ '1999/01/01' => {
17
+ uuid: generate_uuid,
18
+ venue: 'Boulder Theater',
19
+ city: 'Boulder',
20
+ state: 'CO',
21
+ country: 'US',
22
+ sets: [
23
+ {
24
+ uuid: show_one_set_one_uuid
25
+ },
26
+ {
27
+ uuid: show_one_set_two_uuid,
28
+ songs: [
29
+ {
30
+ uuid: song_one_uuid,
31
+ name: 'Song Name 1',
32
+ segued: true
33
+ },
34
+ {
35
+ uuid: song_two_uuid,
36
+ name: 'Song Name 2',
37
+ segued: true
38
+ },
39
+ {
40
+ uuid: song_three_uuid,
41
+ name: 'Song Name 3',
42
+ segued: false
43
+ }
44
+ ]
45
+ }
46
+
47
+ ]
48
+ },
49
+ '1999/01/02' => {
50
+ uuid: generate_uuid,
51
+ venue: 'Ogden Theater',
52
+ city: 'Denver',
53
+ state: 'CO',
54
+ country: 'US',
55
+ sets: [
56
+ {
57
+ uuid: show_two_set_one_uuid,
58
+ songs: [
59
+ {
60
+ uuid: song_a_uuid,
61
+ name: 'Song Name A',
62
+ segued: true
63
+ },
64
+ {
65
+ uuid: song_b_uuid,
66
+ name: 'Song Name B',
67
+ segued: true
68
+ },
69
+ {
70
+ uuid: song_c_uuid,
71
+ name: 'Song Name C',
72
+ segued: false
73
+ }
74
+ ]
75
+ }
76
+ ]
77
+ }
78
+ }
79
+ end
80
+
81
+ subject { Gdshowsdb::SongYAMLParser.new(shows).parse }
82
+
83
+ its(:size) { should == 6 }
84
+
85
+ it { should include ( {uuid: song_one_uuid, name: 'Song Name 1', show_set_uuid: show_one_set_two_uuid, position: 0, segued: true} ) }
86
+ it { should include ( {uuid: song_two_uuid, name: 'Song Name 2', show_set_uuid: show_one_set_two_uuid, position: 1, segued: true} ) }
87
+ it { should include ( {uuid: song_three_uuid, name: 'Song Name 3', show_set_uuid: show_one_set_two_uuid, position: 2, segued: false} ) }
88
+ it { should include ( {uuid: song_a_uuid, name: 'Song Name A', show_set_uuid: show_two_set_one_uuid, position: 0, segued: true} ) }
89
+ it { should include ( {uuid: song_b_uuid, name: 'Song Name B', show_set_uuid: show_two_set_one_uuid, position: 1, segued: true} ) }
90
+ it { should include ( {uuid: song_c_uuid, name: 'Song Name C', show_set_uuid: show_two_set_one_uuid, position: 2, segued: false} ) }
91
+
92
+
93
+ end
@@ -0,0 +1,15 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+
4
+ require 'rubygems'
5
+ require 'bundler/setup'
6
+
7
+ require 'gdshowsdb'
8
+
9
+ include Gdshowsdb
10
+ Gdshowsdb.init({ adapter: 'sqlite3', database: ':memory:' })
11
+ Gdshowsdb.load(8) #Magic Number warning. This will migrate the DB all the way until loading the shows
12
+
13
+ RSpec.configure do |config|
14
+ # some (optional) config here
15
+ end