musk 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +31 -1
- data/Guardfile +9 -0
- data/lib/musk/decorator/printable_track.rb +29 -0
- data/lib/musk/{format → formatter}/pretty.rb +4 -1
- data/lib/musk/track.rb +12 -8
- data/lib/musk/track_loader.rb +19 -22
- data/lib/musk/track_printer.rb +2 -2
- data/lib/musk/version.rb +1 -1
- data/musk.gemspec +15 -11
- data/spec/lib/musk/decorator/printable_track_spec.rb +41 -0
- data/spec/lib/musk/{format → formatter}/pretty_spec.rb +8 -4
- data/spec/lib/musk/track_loader_spec.rb +12 -22
- data/spec/lib/musk/track_printer_spec.rb +5 -5
- data/spec/lib/musk/track_spec.rb +8 -4
- data/spec/support/examples/command_to_print_tracks_to_stdout_in_pretty_format_example.rb +2 -2
- data/spec/support/examples/decorator_with_nullable_attributes_example.rb +23 -0
- data/spec/support/examples/decorator_with_zeroable_attributes_example.rb +39 -0
- data/spec/support/factories/tracks.rb +8 -4
- metadata +53 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dbe21ecab6424d26fc0bad44e87410d0ce7bfe30
|
4
|
+
data.tar.gz: e1acde8199b48808e9756371812bcf8752f3dfd5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 970e98e097362cf63acc293754583ac067698a2ad053756cf118235ff040ee30c858978637b3d0e41043d328f34ac1ee37d21a63b824b55431c8f90a7ffbfa32
|
7
|
+
data.tar.gz: 949dfe1b4c97d634f9b9d74095f50e347df8b8fc560e71a8a5d656171dddaa15b6d89379eb0ab6bf08c2e9ced634f26be0331a32554304494ce682deb097cf01
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
musk (0.0.
|
4
|
+
musk (0.0.3)
|
5
5
|
gli (~> 2.9)
|
6
6
|
taglib-ruby (~> 0.6)
|
7
7
|
|
@@ -15,20 +15,46 @@ GEM
|
|
15
15
|
thread_safe (~> 0.1)
|
16
16
|
tzinfo (~> 0.3.37)
|
17
17
|
atomic (1.1.16)
|
18
|
+
celluloid (0.15.2)
|
19
|
+
timers (~> 1.1.0)
|
20
|
+
celluloid-io (0.15.0)
|
21
|
+
celluloid (>= 0.15.0)
|
22
|
+
nio4r (>= 0.5.0)
|
18
23
|
coderay (1.1.0)
|
19
24
|
diff-lcs (1.2.5)
|
20
25
|
docile (1.1.3)
|
21
26
|
factory_girl (4.4.0)
|
22
27
|
activesupport (>= 3.0.0)
|
28
|
+
ffi (1.9.3)
|
29
|
+
formatador (0.2.4)
|
23
30
|
gli (2.9.0)
|
31
|
+
guard (2.5.1)
|
32
|
+
formatador (>= 0.2.4)
|
33
|
+
listen (~> 2.6)
|
34
|
+
lumberjack (~> 1.0)
|
35
|
+
pry (>= 0.9.12)
|
36
|
+
thor (>= 0.18.1)
|
37
|
+
guard-rspec (4.2.8)
|
38
|
+
guard (~> 2.1)
|
39
|
+
rspec (>= 2.14, < 4.0)
|
24
40
|
i18n (0.6.9)
|
41
|
+
listen (2.7.1)
|
42
|
+
celluloid (>= 0.15.2)
|
43
|
+
celluloid-io (>= 0.15.0)
|
44
|
+
rb-fsevent (>= 0.9.3)
|
45
|
+
rb-inotify (>= 0.9)
|
46
|
+
lumberjack (1.0.5)
|
25
47
|
method_source (0.8.2)
|
26
48
|
minitest (4.7.5)
|
27
49
|
multi_json (1.9.2)
|
50
|
+
nio4r (1.0.0)
|
28
51
|
pry (0.9.12.6)
|
29
52
|
coderay (~> 1.0)
|
30
53
|
method_source (~> 0.8)
|
31
54
|
slop (~> 3.4)
|
55
|
+
rb-fsevent (0.9.4)
|
56
|
+
rb-inotify (0.9.3)
|
57
|
+
ffi (>= 0.5.0)
|
32
58
|
rspec (2.14.1)
|
33
59
|
rspec-core (~> 2.14.0)
|
34
60
|
rspec-expectations (~> 2.14.0)
|
@@ -44,8 +70,10 @@ GEM
|
|
44
70
|
simplecov-html (0.8.0)
|
45
71
|
slop (3.5.0)
|
46
72
|
taglib-ruby (0.6.0)
|
73
|
+
thor (0.19.0)
|
47
74
|
thread_safe (0.3.1)
|
48
75
|
atomic (>= 1.1.7, < 2)
|
76
|
+
timers (1.1.0)
|
49
77
|
tzinfo (0.3.39)
|
50
78
|
|
51
79
|
PLATFORMS
|
@@ -53,6 +81,8 @@ PLATFORMS
|
|
53
81
|
|
54
82
|
DEPENDENCIES
|
55
83
|
factory_girl (~> 4.4)
|
84
|
+
guard (~> 2.5)
|
85
|
+
guard-rspec (~> 4.2)
|
56
86
|
musk!
|
57
87
|
pry (~> 0.9)
|
58
88
|
rspec (~> 2.14)
|
data/Guardfile
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
module Musk
|
2
|
+
module Decorator
|
3
|
+
class PrintableTrack
|
4
|
+
def initialize(track)
|
5
|
+
@track = track
|
6
|
+
end
|
7
|
+
|
8
|
+
def path
|
9
|
+
@track.fullpath.gsub(@track.loadpath, "")
|
10
|
+
end
|
11
|
+
|
12
|
+
def position
|
13
|
+
"#{position_number}/#{positions_count}"
|
14
|
+
end
|
15
|
+
|
16
|
+
[:position_number, :positions_count, :year, :comment].each do |method|
|
17
|
+
define_method(method) do
|
18
|
+
[nil, 0, "0"].include?(@track.send(method)) ? "-" : @track.send(method)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
[:title, :artist, :album, :genre].each do |method|
|
23
|
+
define_method(method) do
|
24
|
+
@track.send(method) or "-"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -1,8 +1,11 @@
|
|
1
|
+
require "musk/decorator/printable_track"
|
2
|
+
|
1
3
|
module Musk
|
2
|
-
module
|
4
|
+
module Formatter
|
3
5
|
class Pretty
|
4
6
|
def self.print(tracks)
|
5
7
|
tracks.each_with_index do |track, index|
|
8
|
+
track = Musk::Decorator::PrintableTrack.new(track)
|
6
9
|
puts if index > 0
|
7
10
|
printf("%-10s%s\n", "Path:", track.path)
|
8
11
|
printf("%-10s%s\n", "Title:", track.title)
|
data/lib/musk/track.rb
CHANGED
@@ -1,13 +1,17 @@
|
|
1
1
|
module Musk
|
2
2
|
class Track
|
3
|
-
ATTRIBUTES = [
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
3
|
+
ATTRIBUTES = [
|
4
|
+
:loadpath,
|
5
|
+
:fullpath,
|
6
|
+
:title,
|
7
|
+
:position_number,
|
8
|
+
:positions_count,
|
9
|
+
:artist,
|
10
|
+
:album,
|
11
|
+
:genre,
|
12
|
+
:year,
|
13
|
+
:comment,
|
14
|
+
]
|
11
15
|
|
12
16
|
attr_accessor *ATTRIBUTES
|
13
17
|
|
data/lib/musk/track_loader.rb
CHANGED
@@ -3,14 +3,6 @@ require "musk/track"
|
|
3
3
|
|
4
4
|
module Musk
|
5
5
|
class TrackLoader
|
6
|
-
def self.supported_formats
|
7
|
-
["mp3"]
|
8
|
-
end
|
9
|
-
|
10
|
-
def self.supported_extensions
|
11
|
-
supported_formats.map {|f| ".#{f}"}
|
12
|
-
end
|
13
|
-
|
14
6
|
def self.load!(path)
|
15
7
|
unless path and path.length > 0
|
16
8
|
raise "Undefined path to a file or files"
|
@@ -19,25 +11,30 @@ module Musk
|
|
19
11
|
raise "Unknown path '#{path}' to a file or files"
|
20
12
|
end
|
21
13
|
if File.file?(path)
|
22
|
-
unless
|
14
|
+
unless File.extname(path) == ".mp3"
|
23
15
|
raise "Unknown extension '#{File.extname(path)}'"
|
24
16
|
end
|
25
17
|
end
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
Dir[
|
18
|
+
path = File.expand_path(path)
|
19
|
+
loadpath = File.file?(path) ? File.dirname(path) : path
|
20
|
+
deeppath = File.file?(path) ? path : File.join(path, "**", "*.mp3")
|
21
|
+
Dir[deeppath].map do |fullpath|
|
30
22
|
track = Musk::Track.new
|
31
|
-
track.
|
32
|
-
|
23
|
+
track.loadpath = loadpath
|
24
|
+
track.fullpath = fullpath
|
25
|
+
TagLib::MPEG::File.open(fullpath) do |file|
|
33
26
|
tag = file.id3v2_tag
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
track.
|
40
|
-
track.
|
27
|
+
if tag.frame_list("TRCK").first
|
28
|
+
number, count = tag.frame_list("TRCK").first.to_s.split("/")
|
29
|
+
track.position_number = number.to_i
|
30
|
+
track.positions_count = count.to_i
|
31
|
+
end
|
32
|
+
track.title = tag.title
|
33
|
+
track.artist = tag.artist
|
34
|
+
track.album = tag.album
|
35
|
+
track.genre = tag.genre
|
36
|
+
track.year = tag.year
|
37
|
+
track.comment = tag.comment
|
41
38
|
end
|
42
39
|
track
|
43
40
|
end
|
data/lib/musk/track_printer.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
require "musk/
|
1
|
+
require "musk/formatter/pretty"
|
2
2
|
|
3
3
|
module Musk
|
4
4
|
class TrackPrinter
|
5
5
|
def self.print!(format, tracks)
|
6
6
|
case format.to_s.to_sym
|
7
7
|
when :pretty
|
8
|
-
|
8
|
+
Musk::Formatter::Pretty.print(tracks)
|
9
9
|
else
|
10
10
|
raise "Unknown format '#{format}'"
|
11
11
|
end
|
data/lib/musk/version.rb
CHANGED
data/musk.gemspec
CHANGED
@@ -3,24 +3,28 @@ $LOAD_PATH << File.expand_path("../lib", __FILE__)
|
|
3
3
|
require "musk/version"
|
4
4
|
|
5
5
|
Gem::Specification.new do |s|
|
6
|
-
s.
|
7
|
-
s.
|
8
|
-
s.
|
9
|
-
s.
|
10
|
-
s.
|
6
|
+
s.name = "musk"
|
7
|
+
s.author = "Eugene Pempel"
|
8
|
+
s.email = "eugene.pempel@gmail.com"
|
9
|
+
s.summary = "Your music with the demonic scent of musk"
|
10
|
+
s.description = "Your music with the demonic scent of musk."
|
11
|
+
s.homepage = "https://github.com/pempel/musk"
|
12
|
+
s.license = "MIT"
|
13
|
+
s.version = Musk::VERSION
|
14
|
+
s.date = Time.now
|
11
15
|
|
12
|
-
s.
|
13
|
-
s.
|
14
|
-
s.
|
15
|
-
s.
|
16
|
-
s.license = "MIT"
|
17
|
-
s.version = Musk::VERSION
|
16
|
+
s.files = `git ls-files`.split($\)
|
17
|
+
s.test_files = `git ls-files -- spec/*`.split($\)
|
18
|
+
s.executables = `git ls-files -- bin/*`.split($\).map {|f| File.basename(f)}
|
19
|
+
s.require_paths = ["lib"]
|
18
20
|
|
19
21
|
s.add_runtime_dependency "gli", "~> 2.9"
|
20
22
|
s.add_runtime_dependency "taglib-ruby", "~> 0.6"
|
21
23
|
|
22
24
|
s.add_development_dependency "pry", "~> 0.9"
|
23
25
|
s.add_development_dependency "rspec", "~> 2.14"
|
26
|
+
s.add_development_dependency "guard", "~> 2.5"
|
27
|
+
s.add_development_dependency "guard-rspec", "~> 4.2"
|
24
28
|
s.add_development_dependency "factory_girl", "~> 4.4"
|
25
29
|
s.add_development_dependency "simplecov", "~> 0.8"
|
26
30
|
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Musk::Decorator::PrintableTrack do
|
4
|
+
describe "#path" do
|
5
|
+
it "should return track.fullpath.gsub(track.loadpath, '')" do
|
6
|
+
track = build(:track)
|
7
|
+
allow(track).to receive(:loadpath).and_return("/tmp")
|
8
|
+
allow(track).to receive(:fullpath).and_return("/tmp/tracks/track.mp3")
|
9
|
+
path = described_class.new(track).path
|
10
|
+
path.should eq("/tracks/track.mp3")
|
11
|
+
expect(track).to have_received(:loadpath)
|
12
|
+
expect(track).to have_received(:fullpath)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "#position" do
|
17
|
+
it "should return '{position_number}/{positions_count}'" do
|
18
|
+
track = described_class.new(build(:track))
|
19
|
+
allow(track).to receive(:position_number).and_return(1)
|
20
|
+
allow(track).to receive(:positions_count).and_return(2)
|
21
|
+
position = track.position
|
22
|
+
position.should eq("1/2")
|
23
|
+
expect(track).to have_received(:position_number)
|
24
|
+
expect(track).to have_received(:positions_count)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
it_should_behave_like "a decorator with zeroable attributes", [
|
29
|
+
:position_number,
|
30
|
+
:positions_count,
|
31
|
+
:comment,
|
32
|
+
:year,
|
33
|
+
]
|
34
|
+
|
35
|
+
it_should_behave_like "a decorator with nullable attributes", [
|
36
|
+
:title,
|
37
|
+
:artist,
|
38
|
+
:album,
|
39
|
+
:genre,
|
40
|
+
]
|
41
|
+
end
|
@@ -1,13 +1,17 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
describe Musk::
|
3
|
+
describe Musk::Formatter::Pretty do
|
4
4
|
describe ".print(tracks)" do
|
5
5
|
let(:tracks) do
|
6
6
|
[build(:jets_track), build(:kamakura_track)]
|
7
7
|
end
|
8
8
|
|
9
|
+
let(:printable_tracks) do
|
10
|
+
tracks.map {|t| Musk::Decorator::PrintableTrack.new(t)}
|
11
|
+
end
|
12
|
+
|
9
13
|
let(:stdout) do
|
10
|
-
|
14
|
+
printable_tracks.map do |track|
|
11
15
|
"Path: #{track.path}\n"\
|
12
16
|
"Title: #{track.title}\n"\
|
13
17
|
"Position: #{track.position}\n"\
|
@@ -15,12 +19,12 @@ describe Musk::Format::Pretty do
|
|
15
19
|
"Album: #{track.album}\n"\
|
16
20
|
"Genre: #{track.genre}\n"\
|
17
21
|
"Year: #{track.year}\n"\
|
18
|
-
"Comment:
|
22
|
+
"Comment: -\n"
|
19
23
|
end.join("\n")
|
20
24
|
end
|
21
25
|
|
22
26
|
it "should print tracks to STDOUT in the pretty format" do
|
23
|
-
capture_stdout {
|
27
|
+
capture_stdout { described_class.print(tracks) }.should eq(stdout)
|
24
28
|
end
|
25
29
|
end
|
26
30
|
end
|
@@ -1,30 +1,18 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe Musk::TrackLoader do
|
4
|
-
describe ".supported_formats" do
|
5
|
-
it "should return ['mp3']" do
|
6
|
-
subject.class.supported_formats.should eq(["mp3"])
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
describe ".supported_extensions" do
|
11
|
-
it "should return ['.mp3']" do
|
12
|
-
subject.class.supported_extensions.should eq([".mp3"])
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
4
|
describe ".load!(path)" do
|
17
5
|
context "when path.nil?" do
|
18
6
|
it "should raise \"Undefined path to a file or files\"" do
|
19
7
|
error = "Undefined path to a file or files"
|
20
|
-
expect {
|
8
|
+
expect { described_class.load!(nil) }.to raise_error(error)
|
21
9
|
end
|
22
10
|
end
|
23
11
|
|
24
12
|
context "when path.empty?" do
|
25
13
|
it "should raise \"Undefined path to a file or files\"" do
|
26
14
|
error = "Undefined path to a file or files"
|
27
|
-
expect {
|
15
|
+
expect { described_class.load!("") }.to raise_error(error)
|
28
16
|
end
|
29
17
|
end
|
30
18
|
|
@@ -32,15 +20,16 @@ describe Musk::TrackLoader do
|
|
32
20
|
it "should raise \"Unknown path '{path}' to a file or files\"" do
|
33
21
|
path = File.join(ENV["MUSK_TRACKS_PATH"], "/nonexistent")
|
34
22
|
error = "Unknown path '#{path}' to a file or files"
|
35
|
-
expect {
|
23
|
+
expect { described_class.load!(path) }.to raise_error(error)
|
36
24
|
end
|
37
25
|
end
|
38
26
|
|
39
27
|
context "when path is an exisiting directory" do
|
40
28
|
it "should create tracks from files in the directory and its subdirectories" do
|
41
|
-
|
42
|
-
|
43
|
-
build(:
|
29
|
+
loadpath = ENV["MUSK_TRACKS_PATH"]
|
30
|
+
described_class.load!(loadpath).should be_tracks([
|
31
|
+
build(:jets_track, :loaded, loadpath: loadpath),
|
32
|
+
build(:kamakura_track, :loaded, loadpath: loadpath),
|
44
33
|
])
|
45
34
|
end
|
46
35
|
end
|
@@ -49,7 +38,7 @@ describe Musk::TrackLoader do
|
|
49
38
|
it "should raise \"Unknown path '{path}' to a file or files\"" do
|
50
39
|
path = File.join(ENV["MUSK_TRACKS_PATH"], "/nonexistent.mp3")
|
51
40
|
error = "Unknown path '#{path}' to a file or files"
|
52
|
-
expect {
|
41
|
+
expect { described_class.load!(path) }.to raise_error(error)
|
53
42
|
end
|
54
43
|
end
|
55
44
|
|
@@ -58,14 +47,15 @@ describe Musk::TrackLoader do
|
|
58
47
|
path = File.join(ENV["MUSK_TRACKS_PATH"], "/track.bad")
|
59
48
|
error = "Unknown extension '.bad'"
|
60
49
|
allow(File).to receive(:file?).with(path).and_return(true)
|
61
|
-
expect {
|
50
|
+
expect { described_class.load!(path) }.to raise_error(error)
|
62
51
|
end
|
63
52
|
end
|
64
53
|
|
65
54
|
context "when path is an existing file that is supported" do
|
66
55
|
it "should create a track from the file" do
|
67
|
-
|
68
|
-
|
56
|
+
loadpath = File.join(ENV["MUSK_TRACKS_PATH"], "/bonobo")
|
57
|
+
track = build(:jets_track, :loaded, loadpath: loadpath)
|
58
|
+
described_class.load!(loadpath).should be_tracks([track])
|
69
59
|
end
|
70
60
|
end
|
71
61
|
end
|
@@ -5,17 +5,17 @@ describe Musk::TrackPrinter do
|
|
5
5
|
let(:tracks) { build_list(:track, 2) }
|
6
6
|
|
7
7
|
context "when format is the pretty format" do
|
8
|
-
it "should call Musk::
|
9
|
-
allow(Musk::
|
10
|
-
|
11
|
-
expect(Musk::
|
8
|
+
it "should call Musk::Formatter::Pretty.print(tracks)" do
|
9
|
+
allow(Musk::Formatter::Pretty).to receive(:print).with(tracks)
|
10
|
+
described_class.print!('pretty', tracks)
|
11
|
+
expect(Musk::Formatter::Pretty).to have_received(:print).with(tracks)
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
15
|
context "when format is an unsupported format" do
|
16
16
|
it "should raise \"Unknown format '{format}'\"" do
|
17
17
|
error = "Unknown format 'unsupported'"
|
18
|
-
expect {
|
18
|
+
expect { described_class.print!('unsupported', tracks) }.to raise_error(error)
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
data/spec/lib/musk/track_spec.rb
CHANGED
@@ -1,12 +1,16 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe Musk::Track do
|
4
|
-
it { should respond_to(:
|
5
|
-
it { should respond_to(:
|
4
|
+
it { should respond_to(:loadpath) }
|
5
|
+
it { should respond_to(:loadpath=) }
|
6
|
+
it { should respond_to(:fullpath) }
|
7
|
+
it { should respond_to(:fullpath=) }
|
6
8
|
it { should respond_to(:title) }
|
7
9
|
it { should respond_to(:title=) }
|
8
|
-
it { should respond_to(:
|
9
|
-
it { should respond_to(:
|
10
|
+
it { should respond_to(:position_number) }
|
11
|
+
it { should respond_to(:position_number=) }
|
12
|
+
it { should respond_to(:positions_count) }
|
13
|
+
it { should respond_to(:positions_count=) }
|
10
14
|
it { should respond_to(:artist) }
|
11
15
|
it { should respond_to(:artist=) }
|
12
16
|
it { should respond_to(:album) }
|
@@ -1,9 +1,9 @@
|
|
1
1
|
shared_examples "a command to print tracks to STDOUT in the pretty format" do
|
2
|
-
it "should print tracks to STDOUT via Musk::
|
2
|
+
it "should print tracks to STDOUT via Musk::Formatter::Pretty" do
|
3
3
|
path = ENV["MUSK_TRACKS_PATH"]
|
4
4
|
tracks = Musk::TrackLoader.load!(path)
|
5
5
|
stdout, stderr, status = Open3.capture3("#{expected_command} #{path}")
|
6
|
-
stdout.should eq(capture_stdout { Musk::
|
6
|
+
stdout.should eq(capture_stdout { Musk::Formatter::Pretty.print(tracks) })
|
7
7
|
status.exitstatus.should eq(0)
|
8
8
|
end
|
9
9
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
shared_examples "a decorator with nullable attributes" do |attributes|
|
2
|
+
subject { Musk::Decorator::PrintableTrack }
|
3
|
+
|
4
|
+
attributes.each do |attribute|
|
5
|
+
describe "##{attribute}" do
|
6
|
+
context "when track.#{attribute} == nil" do
|
7
|
+
it "should return '-'" do
|
8
|
+
track = build(:track)
|
9
|
+
allow(track).to receive(attribute).and_return(nil)
|
10
|
+
subject.new(track).send(attribute).should eq("-")
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
context "else" do
|
15
|
+
it "should return track.#{attribute}" do
|
16
|
+
track = build(:track)
|
17
|
+
allow(track).to receive(attribute).and_return("VaLuE")
|
18
|
+
subject.new(track).send(attribute).should eq("VaLuE")
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
shared_examples "a decorator with zeroable attributes" do |attributes|
|
2
|
+
subject { Musk::Decorator::PrintableTrack }
|
3
|
+
|
4
|
+
attributes.each do |attribute|
|
5
|
+
describe "##{attribute}" do
|
6
|
+
context "when track.#{attribute} == nil" do
|
7
|
+
it "should return '-'" do
|
8
|
+
track = build(:track)
|
9
|
+
allow(track).to receive(attribute).and_return(nil)
|
10
|
+
subject.new(track).send(attribute).should eq("-")
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
context "when track.#{attribute} == 0" do
|
15
|
+
it "should return '-'" do
|
16
|
+
track = build(:track)
|
17
|
+
allow(track).to receive(attribute).and_return(0)
|
18
|
+
subject.new(track).send(attribute).should eq("-")
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
context "when track.#{attribute} == \"0\"" do
|
23
|
+
it "should return '-'" do
|
24
|
+
track = build(:track)
|
25
|
+
allow(track).to receive(attribute).and_return("0")
|
26
|
+
subject.new(track).send(attribute).should eq("-")
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context "else" do
|
31
|
+
it "should return track.#{attribute}" do
|
32
|
+
track = build(:track)
|
33
|
+
allow(track).to receive(attribute).and_return("VaLuE")
|
34
|
+
subject.new(track).send(attribute).should eq("VaLuE")
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -3,9 +3,11 @@ FactoryGirl.define do
|
|
3
3
|
end
|
4
4
|
|
5
5
|
factory :jets_track, parent: :track do
|
6
|
-
|
6
|
+
loadpath ENV["MUSK_TRACKS_PATH"]
|
7
|
+
fullpath File.join(ENV["MUSK_TRACKS_PATH"], "bonobo/jets.mp3")
|
7
8
|
title "Jets"
|
8
|
-
|
9
|
+
position_number 6
|
10
|
+
positions_count 13
|
9
11
|
artist "Bonobo"
|
10
12
|
album "The North Borders"
|
11
13
|
genre "Electronic"
|
@@ -17,9 +19,11 @@ FactoryGirl.define do
|
|
17
19
|
end
|
18
20
|
|
19
21
|
factory :kamakura_track, parent: :track do
|
20
|
-
|
22
|
+
loadpath ENV["MUSK_TRACKS_PATH"]
|
23
|
+
fullpath File.join(ENV["MUSK_TRACKS_PATH"], "emancipator/kamakura.mp3")
|
21
24
|
title "Kamakura"
|
22
|
-
|
25
|
+
position_number 4
|
26
|
+
positions_count 14
|
23
27
|
artist "Emancipator"
|
24
28
|
album "Safe In The Steep Cliffs"
|
25
29
|
genre "Electronic"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: musk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eugene Pempel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gli
|
@@ -66,6 +66,34 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '2.14'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: guard
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '2.5'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '2.5'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: guard-rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '4.2'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '4.2'
|
69
97
|
- !ruby/object:Gem::Dependency
|
70
98
|
name: factory_girl
|
71
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -104,23 +132,28 @@ files:
|
|
104
132
|
- ".gitignore"
|
105
133
|
- Gemfile
|
106
134
|
- Gemfile.lock
|
135
|
+
- Guardfile
|
107
136
|
- LICENSE
|
108
137
|
- README.md
|
109
138
|
- bin/musk
|
110
139
|
- lib/musk.rb
|
111
|
-
- lib/musk/
|
140
|
+
- lib/musk/decorator/printable_track.rb
|
141
|
+
- lib/musk/formatter/pretty.rb
|
112
142
|
- lib/musk/track.rb
|
113
143
|
- lib/musk/track_loader.rb
|
114
144
|
- lib/musk/track_printer.rb
|
115
145
|
- lib/musk/version.rb
|
116
146
|
- musk.gemspec
|
117
147
|
- spec/bin/musk_spec.rb
|
118
|
-
- spec/lib/musk/
|
148
|
+
- spec/lib/musk/decorator/printable_track_spec.rb
|
149
|
+
- spec/lib/musk/formatter/pretty_spec.rb
|
119
150
|
- spec/lib/musk/track_loader_spec.rb
|
120
151
|
- spec/lib/musk/track_printer_spec.rb
|
121
152
|
- spec/lib/musk/track_spec.rb
|
122
153
|
- spec/spec_helper.rb
|
123
154
|
- spec/support/examples/command_to_print_tracks_to_stdout_in_pretty_format_example.rb
|
155
|
+
- spec/support/examples/decorator_with_nullable_attributes_example.rb
|
156
|
+
- spec/support/examples/decorator_with_zeroable_attributes_example.rb
|
124
157
|
- spec/support/factories/tracks.rb
|
125
158
|
- spec/support/helpers/capture_stdout_helper.rb
|
126
159
|
- spec/support/matchers/be_tracks_matcher.rb
|
@@ -150,4 +183,19 @@ rubygems_version: 2.2.2
|
|
150
183
|
signing_key:
|
151
184
|
specification_version: 4
|
152
185
|
summary: Your music with the demonic scent of musk
|
153
|
-
test_files:
|
186
|
+
test_files:
|
187
|
+
- spec/bin/musk_spec.rb
|
188
|
+
- spec/lib/musk/decorator/printable_track_spec.rb
|
189
|
+
- spec/lib/musk/formatter/pretty_spec.rb
|
190
|
+
- spec/lib/musk/track_loader_spec.rb
|
191
|
+
- spec/lib/musk/track_printer_spec.rb
|
192
|
+
- spec/lib/musk/track_spec.rb
|
193
|
+
- spec/spec_helper.rb
|
194
|
+
- spec/support/examples/command_to_print_tracks_to_stdout_in_pretty_format_example.rb
|
195
|
+
- spec/support/examples/decorator_with_nullable_attributes_example.rb
|
196
|
+
- spec/support/examples/decorator_with_zeroable_attributes_example.rb
|
197
|
+
- spec/support/factories/tracks.rb
|
198
|
+
- spec/support/helpers/capture_stdout_helper.rb
|
199
|
+
- spec/support/matchers/be_tracks_matcher.rb
|
200
|
+
- spec/support/tracks/bonobo/jets.mp3
|
201
|
+
- spec/support/tracks/emancipator/kamakura.mp3
|