rubycue 0.0.1 → 0.1.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.
- data/Rakefile +3 -3
- data/VERSION +1 -1
- data/lib/rubycue/cuesheet.rb +27 -8
- data/rubycue.gemspec +49 -0
- data/spec/fixtures/multi_file.cue +79 -0
- data/spec/unit/cuesheet_spec.rb +40 -0
- metadata +29 -50
- data/.gitignore +0 -1
data/Rakefile
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
require 'rake'
|
2
|
-
require '
|
2
|
+
require 'rspec/core/rake_task'
|
3
3
|
|
4
|
-
|
5
|
-
t.
|
4
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
5
|
+
t.pattern = './spec/unit/*_spec.rb'
|
6
6
|
end
|
7
7
|
|
8
8
|
task :default => :spec
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0
|
1
|
+
0.1.0
|
data/lib/rubycue/cuesheet.rb
CHANGED
@@ -1,14 +1,16 @@
|
|
1
1
|
module RubyCue
|
2
2
|
class Cuesheet
|
3
|
-
attr_reader :cuesheet, :songs, :track_duration
|
3
|
+
attr_reader :cuesheet, :songs, :track_duration, :performer, :title, :file, :genre
|
4
4
|
|
5
5
|
def initialize(cuesheet, track_duration=nil)
|
6
6
|
@cuesheet = cuesheet
|
7
7
|
@reg = {
|
8
|
-
:track => %r(TRACK (\d{1,3}) AUDIO),
|
9
|
-
:performer => %r(PERFORMER "(.*)"),
|
10
|
-
:title => %r(TITLE "(.*)"),
|
11
|
-
:index => %r(INDEX \d{1,3} (\d{1,3}):(\d{1,2}):(\d{1,2}))
|
8
|
+
:track => %r(TRACK (\d{1,3}) AUDIO),
|
9
|
+
:performer => %r(PERFORMER "(.*)"),
|
10
|
+
:title => %r(TITLE "(.*)"),
|
11
|
+
:index => %r(INDEX \d{1,3} (\d{1,3}):(\d{1,2}):(\d{1,2})),
|
12
|
+
:file => %r(FILE "(.*)"),
|
13
|
+
:genre => %r(REM GENRE (.*)\b)
|
12
14
|
}
|
13
15
|
@track_duration = RubyCue::Index.new(track_duration) if track_duration
|
14
16
|
end
|
@@ -19,7 +21,9 @@ module RubyCue
|
|
19
21
|
song[:performer] = parse_performers[i]
|
20
22
|
song[:track] = parse_tracks[i]
|
21
23
|
song[:index] = parse_indices[i]
|
24
|
+
song[:file] = parse_files[i]
|
22
25
|
end
|
26
|
+
parse_genre
|
23
27
|
raise RubyCue::InvalidCuesheet.new("Field amounts are not all present. Cuesheet is malformed!") unless valid?
|
24
28
|
calculate_song_durations!
|
25
29
|
true
|
@@ -42,7 +46,7 @@ module RubyCue
|
|
42
46
|
end
|
43
47
|
end
|
44
48
|
|
45
|
-
|
49
|
+
private
|
46
50
|
|
47
51
|
def calculate_song_durations!
|
48
52
|
@songs.each_with_index do |song, i|
|
@@ -61,7 +65,7 @@ module RubyCue
|
|
61
65
|
def parse_titles
|
62
66
|
unless @titles
|
63
67
|
@titles = cuesheet_scan(:title).map{|title| title.first}
|
64
|
-
@titles.delete_at(0)
|
68
|
+
@title = @titles.delete_at(0)
|
65
69
|
end
|
66
70
|
@titles
|
67
71
|
end
|
@@ -69,7 +73,7 @@ module RubyCue
|
|
69
73
|
def parse_performers
|
70
74
|
unless @performers
|
71
75
|
@performers = cuesheet_scan(:performer).map{|performer| performer.first}
|
72
|
-
@performers.delete_at(0)
|
76
|
+
@performer = @performers.delete_at(0)
|
73
77
|
end
|
74
78
|
@performers
|
75
79
|
end
|
@@ -82,6 +86,21 @@ module RubyCue
|
|
82
86
|
@indices ||= cuesheet_scan(:index).map{|index| RubyCue::Index.new([index[0].to_i, index[1].to_i, index[2].to_i])}
|
83
87
|
end
|
84
88
|
|
89
|
+
def parse_files
|
90
|
+
unless @files
|
91
|
+
@files = cuesheet_scan(:file).map{|file| file.first}
|
92
|
+
@file = @files.delete_at(0) if @files.size == 1
|
93
|
+
end
|
94
|
+
@files
|
95
|
+
end
|
96
|
+
|
97
|
+
def parse_genre
|
98
|
+
@cuesheet.scan(@reg[:genre]) do |genre|
|
99
|
+
@genre = genre.first
|
100
|
+
break
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
85
104
|
def cuesheet_scan(field)
|
86
105
|
scan = @cuesheet.scan(@reg[field])
|
87
106
|
raise InvalidCuesheet.new("No fields were found for #{field.to_s}") if scan.empty?
|
data/rubycue.gemspec
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "rubycue"
|
8
|
+
s.version = "0.1.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Blake Smith"]
|
12
|
+
s.date = "2012-07-23"
|
13
|
+
s.description = "Basic ruby parser for song cuesheets"
|
14
|
+
s.email = "blakesmith0@gmail.com"
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"README.rdoc"
|
17
|
+
]
|
18
|
+
s.files = [
|
19
|
+
"MIT-LICENSE",
|
20
|
+
"README.rdoc",
|
21
|
+
"Rakefile",
|
22
|
+
"VERSION",
|
23
|
+
"lib/rubycue.rb",
|
24
|
+
"lib/rubycue/cuesheet.rb",
|
25
|
+
"lib/rubycue/exceptions.rb",
|
26
|
+
"lib/rubycue/index.rb",
|
27
|
+
"rubycue.gemspec",
|
28
|
+
"spec/fixtures/malformed.cue",
|
29
|
+
"spec/fixtures/multi_file.cue",
|
30
|
+
"spec/fixtures/test.cue",
|
31
|
+
"spec/spec_helper.rb",
|
32
|
+
"spec/unit/cuesheet_spec.rb",
|
33
|
+
"spec/unit/index_spec.rb"
|
34
|
+
]
|
35
|
+
s.homepage = "http://github.com/blakesmith/rubycue"
|
36
|
+
s.require_paths = ["lib"]
|
37
|
+
s.rubygems_version = "1.8.15"
|
38
|
+
s.summary = "Ruby cuesheet track parser"
|
39
|
+
|
40
|
+
if s.respond_to? :specification_version then
|
41
|
+
s.specification_version = 3
|
42
|
+
|
43
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
44
|
+
else
|
45
|
+
end
|
46
|
+
else
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
@@ -0,0 +1,79 @@
|
|
1
|
+
REM GENRE Rock
|
2
|
+
REM DATE 2012
|
3
|
+
REM DISCID A60DC10C
|
4
|
+
REM COMMENT "ExactAudioCopy v1.0b3"
|
5
|
+
PERFORMER "Patti Smith"
|
6
|
+
TITLE "Banga"
|
7
|
+
FILE "01 - Amerigo.wav" WAVE
|
8
|
+
TRACK 01 AUDIO
|
9
|
+
TITLE "Amerigo"
|
10
|
+
PERFORMER "Patti Smith"
|
11
|
+
ISRC H2KM11202363
|
12
|
+
INDEX 01 00:00:00
|
13
|
+
FILE "02 - April Fool.wav" WAVE
|
14
|
+
TRACK 02 AUDIO
|
15
|
+
TITLE "April Fool"
|
16
|
+
PERFORMER "Patti Smith"
|
17
|
+
ISRC H2KM11202009
|
18
|
+
INDEX 01 00:00:00
|
19
|
+
FILE "03 - Fuji-san.wav" WAVE
|
20
|
+
TRACK 03 AUDIO
|
21
|
+
TITLE "Fuji-san"
|
22
|
+
PERFORMER "Patti Smith"
|
23
|
+
ISRC H2KM11202364
|
24
|
+
INDEX 01 00:00:00
|
25
|
+
FILE "04 - This Is The Girl.wav" WAVE
|
26
|
+
TRACK 04 AUDIO
|
27
|
+
TITLE "This Is The Girl"
|
28
|
+
PERFORMER "Patti Smith"
|
29
|
+
ISRC H2KM11202365
|
30
|
+
INDEX 01 00:00:00
|
31
|
+
FILE "05 - Banga.wav" WAVE
|
32
|
+
TRACK 05 AUDIO
|
33
|
+
TITLE "Banga"
|
34
|
+
PERFORMER "Patti Smith"
|
35
|
+
ISRC H2KM11202366
|
36
|
+
INDEX 01 00:00:00
|
37
|
+
TRACK 06 AUDIO
|
38
|
+
TITLE "Maria"
|
39
|
+
PERFORMER "Patti Smith"
|
40
|
+
ISRC H2KM11202367
|
41
|
+
INDEX 00 02:50:13
|
42
|
+
FILE "06 - Maria.wav" WAVE
|
43
|
+
INDEX 01 00:00:00
|
44
|
+
FILE "07 - Mosaic.wav" WAVE
|
45
|
+
TRACK 07 AUDIO
|
46
|
+
TITLE "Mosaic"
|
47
|
+
PERFORMER "Patti Smith"
|
48
|
+
ISRC H2KM11202368
|
49
|
+
INDEX 01 00:00:00
|
50
|
+
FILE "08 - Tarkovsky (The Second Stop Is Jupiter).wav" WAVE
|
51
|
+
TRACK 08 AUDIO
|
52
|
+
TITLE "Tarkovsky (The Second Stop Is Jupiter)"
|
53
|
+
PERFORMER "Patti Smith"
|
54
|
+
ISRC H2KM11202369
|
55
|
+
INDEX 01 00:00:00
|
56
|
+
FILE "09 - Nine.wav" WAVE
|
57
|
+
TRACK 09 AUDIO
|
58
|
+
TITLE "Nine"
|
59
|
+
PERFORMER "Patti Smith"
|
60
|
+
ISRC H2KM11202370
|
61
|
+
INDEX 01 00:00:00
|
62
|
+
FILE "10 - Seneca.wav" WAVE
|
63
|
+
TRACK 10 AUDIO
|
64
|
+
TITLE "Seneca"
|
65
|
+
PERFORMER "Patti Smith"
|
66
|
+
ISRC H2KM11202371
|
67
|
+
INDEX 01 00:00:00
|
68
|
+
FILE "11 - Constantine's Dream.wav" WAVE
|
69
|
+
TRACK 11 AUDIO
|
70
|
+
TITLE "Constantine's Dream"
|
71
|
+
PERFORMER "Patti Smith"
|
72
|
+
ISRC H2KM11202372
|
73
|
+
INDEX 01 00:00:00
|
74
|
+
FILE "12 - After The Gold Rush.wav" WAVE
|
75
|
+
TRACK 12 AUDIO
|
76
|
+
TITLE "After The Gold Rush"
|
77
|
+
PERFORMER "Patti Smith"
|
78
|
+
ISRC H2KM11202373
|
79
|
+
INDEX 01 00:00:00
|
data/spec/unit/cuesheet_spec.rb
CHANGED
@@ -17,6 +17,14 @@ describe RubyCue::Cuesheet do
|
|
17
17
|
it "returns true if successfully parsed" do
|
18
18
|
@cuesheet.parse!.should be_true
|
19
19
|
end
|
20
|
+
|
21
|
+
it "has the main performer" do
|
22
|
+
@cuesheet.performer.should == 'Netsky'
|
23
|
+
end
|
24
|
+
|
25
|
+
it "has the main title" do
|
26
|
+
@cuesheet.title.should == 'Essential Mix (2010-10-09)'
|
27
|
+
end
|
20
28
|
|
21
29
|
it "has the right first track" do
|
22
30
|
@cuesheet.songs.first[:title].should == "Intro"
|
@@ -54,6 +62,14 @@ describe RubyCue::Cuesheet do
|
|
54
62
|
@cuesheet.songs.size.should == 53
|
55
63
|
end
|
56
64
|
|
65
|
+
it "has the main file" do
|
66
|
+
@cuesheet.file.should == '2010-10-09 - Essential Mix - Netsky.mp3'
|
67
|
+
end
|
68
|
+
|
69
|
+
it "has no tracks files" do
|
70
|
+
@cuesheet.songs.each { |song| song[:file].should == nil }
|
71
|
+
end
|
72
|
+
|
57
73
|
describe "#calculate_song_duration!" do
|
58
74
|
it "properly calculates song duration at the beginning of the track" do
|
59
75
|
@cuesheet.songs.first[:duration].to_a.should == [1, 50, 07]
|
@@ -83,6 +99,30 @@ describe RubyCue::Cuesheet do
|
|
83
99
|
lambda { cuesheet.parse! }.should raise_error(RubyCue::InvalidCuesheet)
|
84
100
|
end
|
85
101
|
end
|
102
|
+
|
103
|
+
context "multiple files cuesheet" do
|
104
|
+
before do
|
105
|
+
@cuesheet_file = load_cuesheet("multi_file")
|
106
|
+
@cuesheet = RubyCue::Cuesheet.new(@cuesheet_file)
|
107
|
+
@cuesheet.parse!
|
108
|
+
end
|
109
|
+
|
110
|
+
it "has the main file" do
|
111
|
+
@cuesheet.file.should == nil
|
112
|
+
end
|
113
|
+
|
114
|
+
it "has the right first track file" do
|
115
|
+
@cuesheet.songs.first[:file].should == "01 - Amerigo.wav"
|
116
|
+
end
|
117
|
+
|
118
|
+
it "has the right last track file" do
|
119
|
+
@cuesheet.songs.last[:file].should == "12 - After The Gold Rush.wav"
|
120
|
+
end
|
121
|
+
|
122
|
+
it "has genre" do
|
123
|
+
@cuesheet.genre.should == 'Rock'
|
124
|
+
end
|
125
|
+
end
|
86
126
|
end
|
87
127
|
|
88
128
|
describe "#position" do
|
metadata
CHANGED
@@ -1,34 +1,23 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubycue
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 0
|
9
|
-
- 1
|
10
|
-
version: 0.0.1
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.1.0
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Blake Smith
|
14
|
-
autorequire:
|
9
|
+
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
date: 2010-10-26 00:00:00 -05:00
|
19
|
-
default_executable:
|
12
|
+
date: 2012-07-23 00:00:00.000000000Z
|
20
13
|
dependencies: []
|
21
|
-
|
22
14
|
description: Basic ruby parser for song cuesheets
|
23
15
|
email: blakesmith0@gmail.com
|
24
16
|
executables: []
|
25
|
-
|
26
17
|
extensions: []
|
27
|
-
|
28
|
-
extra_rdoc_files:
|
18
|
+
extra_rdoc_files:
|
29
19
|
- README.rdoc
|
30
|
-
files:
|
31
|
-
- .gitignore
|
20
|
+
files:
|
32
21
|
- MIT-LICENSE
|
33
22
|
- README.rdoc
|
34
23
|
- Rakefile
|
@@ -37,46 +26,36 @@ files:
|
|
37
26
|
- lib/rubycue/cuesheet.rb
|
38
27
|
- lib/rubycue/exceptions.rb
|
39
28
|
- lib/rubycue/index.rb
|
29
|
+
- rubycue.gemspec
|
40
30
|
- spec/fixtures/malformed.cue
|
31
|
+
- spec/fixtures/multi_file.cue
|
41
32
|
- spec/fixtures/test.cue
|
42
33
|
- spec/spec_helper.rb
|
43
34
|
- spec/unit/cuesheet_spec.rb
|
44
35
|
- spec/unit/index_spec.rb
|
45
|
-
has_rdoc: true
|
46
36
|
homepage: http://github.com/blakesmith/rubycue
|
47
37
|
licenses: []
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
- --charset=UTF-8
|
52
|
-
require_paths:
|
38
|
+
post_install_message:
|
39
|
+
rdoc_options: []
|
40
|
+
require_paths:
|
53
41
|
- lib
|
54
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
42
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ! '>='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
55
47
|
none: false
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
- 0
|
62
|
-
version: "0"
|
63
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
48
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - ! '>='
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0'
|
64
53
|
none: false
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
hash: 3
|
69
|
-
segments:
|
70
|
-
- 0
|
71
|
-
version: "0"
|
72
54
|
requirements: []
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
signing_key:
|
55
|
+
rubyforge_project:
|
56
|
+
rubygems_version: 1.8.15
|
57
|
+
signing_key:
|
77
58
|
specification_version: 3
|
78
59
|
summary: Ruby cuesheet track parser
|
79
|
-
test_files:
|
80
|
-
|
81
|
-
- spec/unit/cuesheet_spec.rb
|
82
|
-
- spec/unit/index_spec.rb
|
60
|
+
test_files: []
|
61
|
+
...
|
data/.gitignore
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
*.swp
|