musk 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -1
- data/Gemfile +1 -2
- data/Gemfile.lock +28 -7
- data/bin/musk +15 -41
- data/lib/musk/format/pretty.rb +19 -0
- data/lib/musk/track.rb +18 -0
- data/lib/musk/track_loader.rb +46 -0
- data/lib/musk/track_printer.rb +14 -0
- data/lib/musk/version.rb +3 -0
- data/lib/musk.rb +3 -5
- data/musk.gemspec +21 -15
- data/spec/bin/musk_spec.rb +41 -0
- data/spec/lib/musk/format/pretty_spec.rb +26 -0
- data/spec/lib/musk/track_loader_spec.rb +72 -0
- data/spec/lib/musk/track_printer_spec.rb +22 -0
- data/spec/lib/musk/track_spec.rb +29 -0
- data/spec/spec_helper.rb +21 -3
- data/spec/support/examples/command_to_print_tracks_to_stdout_in_pretty_format_example.rb +9 -0
- data/spec/support/factories/tracks.rb +32 -0
- data/spec/support/helpers/capture_stdout_helper.rb +14 -0
- data/spec/support/matchers/be_tracks_matcher.rb +17 -0
- data/spec/support/tracks/bonobo/jets.mp3 +0 -0
- data/spec/support/tracks/emancipator/kamakura.mp3 +0 -0
- metadata +41 -12
- data/spec/musk_spec.rb +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 813d2fc5466547c772986b8bdeb64971e74c247a
|
4
|
+
data.tar.gz: 2fbe6fe8aeeb901933615f154f2da15111321b31
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6621d503cc6ef86046c449c6555c7fc098893507bff5b35b6454cf37d1f723244ae30579906e0c879ef6dfd34f83d1a5c2167cac6142a8b4f4b1579b17956b0f
|
7
|
+
data.tar.gz: 1057bf6d031e4cb183cbdd3c1116a3421e7ffc7bf3d6d531074beec261e94f0640d91d81af8038a732fc077d6073f2d3281696630e6004bed34e486fafd01d17
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,19 +1,30 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
musk (0.0.
|
5
|
-
|
6
|
-
|
7
|
-
taglib-ruby (~> 0.6.0)
|
4
|
+
musk (0.0.2)
|
5
|
+
gli (~> 2.9)
|
6
|
+
taglib-ruby (~> 0.6)
|
8
7
|
|
9
8
|
GEM
|
10
9
|
remote: https://rubygems.org/
|
11
10
|
specs:
|
11
|
+
activesupport (4.0.4)
|
12
|
+
i18n (~> 0.6, >= 0.6.9)
|
13
|
+
minitest (~> 4.2)
|
14
|
+
multi_json (~> 1.3)
|
15
|
+
thread_safe (~> 0.1)
|
16
|
+
tzinfo (~> 0.3.37)
|
17
|
+
atomic (1.1.16)
|
12
18
|
coderay (1.1.0)
|
13
19
|
diff-lcs (1.2.5)
|
14
|
-
|
20
|
+
docile (1.1.3)
|
21
|
+
factory_girl (4.4.0)
|
22
|
+
activesupport (>= 3.0.0)
|
15
23
|
gli (2.9.0)
|
24
|
+
i18n (0.6.9)
|
16
25
|
method_source (0.8.2)
|
26
|
+
minitest (4.7.5)
|
27
|
+
multi_json (1.9.2)
|
17
28
|
pry (0.9.12.6)
|
18
29
|
coderay (~> 1.0)
|
19
30
|
method_source (~> 0.8)
|
@@ -26,13 +37,23 @@ GEM
|
|
26
37
|
rspec-expectations (2.14.5)
|
27
38
|
diff-lcs (>= 1.1.3, < 2.0)
|
28
39
|
rspec-mocks (2.14.6)
|
40
|
+
simplecov (0.8.2)
|
41
|
+
docile (~> 1.1.0)
|
42
|
+
multi_json
|
43
|
+
simplecov-html (~> 0.8.0)
|
44
|
+
simplecov-html (0.8.0)
|
29
45
|
slop (3.5.0)
|
30
46
|
taglib-ruby (0.6.0)
|
47
|
+
thread_safe (0.3.1)
|
48
|
+
atomic (>= 1.1.7, < 2)
|
49
|
+
tzinfo (0.3.39)
|
31
50
|
|
32
51
|
PLATFORMS
|
33
52
|
ruby
|
34
53
|
|
35
54
|
DEPENDENCIES
|
55
|
+
factory_girl (~> 4.4)
|
36
56
|
musk!
|
37
|
-
pry (~> 0.9
|
38
|
-
rspec (~> 2.14
|
57
|
+
pry (~> 0.9)
|
58
|
+
rspec (~> 2.14)
|
59
|
+
simplecov (~> 0.8)
|
data/bin/musk
CHANGED
@@ -1,51 +1,25 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require "gli"
|
4
|
+
require "musk/track_loader"
|
5
|
+
require "musk/track_printer"
|
5
6
|
|
6
|
-
|
7
|
+
extend GLI::App
|
7
8
|
|
8
|
-
desc
|
9
|
-
arg_name
|
9
|
+
desc "Extract meta-data (tags) from MP3 files"
|
10
|
+
arg_name "path_to_file or path_to_files"
|
10
11
|
command :extract do |command|
|
11
|
-
command.
|
12
|
-
|
13
|
-
|
12
|
+
command.arg_name "format"
|
13
|
+
command.default_value "pretty"
|
14
|
+
command.flag [:f, :format]
|
15
|
+
command.action do |global_options, options, arguments|
|
16
|
+
begin
|
17
|
+
tracks = Musk::TrackLoader.load!(arguments.first)
|
18
|
+
Musk::TrackPrinter.print!(options[:f], tracks)
|
19
|
+
rescue RuntimeError => error
|
20
|
+
STDERR.puts error
|
14
21
|
exit 1
|
15
22
|
end
|
16
|
-
unless File.directory?(args.first)
|
17
|
-
unless File.file?(args.first)
|
18
|
-
STDERR.puts "Unknown path '#{args.first}' to an MP3 file or files"
|
19
|
-
exit 2
|
20
|
-
end
|
21
|
-
unless File.extname(args.first) == '.mp3'
|
22
|
-
STDERR.puts "Unknown extension '#{File.extname(args.first)}'"
|
23
|
-
exit 2
|
24
|
-
end
|
25
|
-
end
|
26
|
-
tracks = []
|
27
|
-
if File.file?(args.first)
|
28
|
-
tracks << args.first
|
29
|
-
else
|
30
|
-
Dir.glob(File.join(args.first, '**', '*.mp3')) do |track|
|
31
|
-
tracks << track
|
32
|
-
end
|
33
|
-
end
|
34
|
-
tracks.each_with_index do |track, index|
|
35
|
-
TagLib::MPEG::File.open(track) do |file|
|
36
|
-
tag = file.id3v2_tag
|
37
|
-
puts if index > 0
|
38
|
-
printf("%-9s%s\n", 'File:', track)
|
39
|
-
printf("%-9s%s\n", 'Cover:', !tag.frame_list('APIC').first.nil?)
|
40
|
-
printf("%-9s%s\n", 'Track:', tag.frame_list('TRCK').first)
|
41
|
-
printf("%-9s%s\n", 'Title:', tag.title)
|
42
|
-
printf("%-9s%s\n", 'Artist:', tag.artist)
|
43
|
-
printf("%-9s%s\n", 'Album:', tag.album)
|
44
|
-
printf("%-9s%s\n", 'Genre:', tag.genre)
|
45
|
-
printf("%-9s%s\n", 'Year:', tag.year)
|
46
|
-
printf("%-9s%s\n", 'Comment:', tag.comment)
|
47
|
-
end
|
48
|
-
end
|
49
23
|
end
|
50
24
|
end
|
51
25
|
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Musk
|
2
|
+
module Format
|
3
|
+
class Pretty
|
4
|
+
def self.print(tracks)
|
5
|
+
tracks.each_with_index do |track, index|
|
6
|
+
puts if index > 0
|
7
|
+
printf("%-10s%s\n", "Path:", track.path)
|
8
|
+
printf("%-10s%s\n", "Title:", track.title)
|
9
|
+
printf("%-10s%s\n", "Position:", track.position)
|
10
|
+
printf("%-10s%s\n", "Artist:", track.artist)
|
11
|
+
printf("%-10s%s\n", "Album:", track.album)
|
12
|
+
printf("%-10s%s\n", "Genre:", track.genre)
|
13
|
+
printf("%-10s%s\n", "Year:", track.year)
|
14
|
+
printf("%-10s%s\n", "Comment:", track.comment)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/musk/track.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
module Musk
|
2
|
+
class Track
|
3
|
+
ATTRIBUTES = [:path,
|
4
|
+
:title,
|
5
|
+
:position,
|
6
|
+
:artist,
|
7
|
+
:album,
|
8
|
+
:genre,
|
9
|
+
:year,
|
10
|
+
:comment]
|
11
|
+
|
12
|
+
attr_accessor *ATTRIBUTES
|
13
|
+
|
14
|
+
def attributes
|
15
|
+
Hash[ATTRIBUTES.map {|a| [a, send("#{a}")]}]
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require "taglib"
|
2
|
+
require "musk/track"
|
3
|
+
|
4
|
+
module Musk
|
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
|
+
def self.load!(path)
|
15
|
+
unless path and path.length > 0
|
16
|
+
raise "Undefined path to a file or files"
|
17
|
+
end
|
18
|
+
unless File.file?(path) or File.directory?(path)
|
19
|
+
raise "Unknown path '#{path}' to a file or files"
|
20
|
+
end
|
21
|
+
if File.file?(path)
|
22
|
+
unless supported_extensions.include?(File.extname(path))
|
23
|
+
raise "Unknown extension '#{File.extname(path)}'"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
if File.directory?(path)
|
27
|
+
path = File.join(path, "**", "*.{#{supported_formats.join(',')}}")
|
28
|
+
end
|
29
|
+
Dir[path].map do |path|
|
30
|
+
track = Musk::Track.new
|
31
|
+
track.path = path
|
32
|
+
TagLib::MPEG::File.open(path) do |file|
|
33
|
+
tag = file.id3v2_tag
|
34
|
+
track.title = tag.title
|
35
|
+
track.position = tag.track
|
36
|
+
track.artist = tag.artist
|
37
|
+
track.album = tag.album
|
38
|
+
track.genre = tag.genre
|
39
|
+
track.year = tag.year
|
40
|
+
track.comment = tag.comment
|
41
|
+
end
|
42
|
+
track
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
data/lib/musk/version.rb
ADDED
data/lib/musk.rb
CHANGED
data/musk.gemspec
CHANGED
@@ -1,20 +1,26 @@
|
|
1
|
+
$LOAD_PATH << File.expand_path("../lib", __FILE__)
|
2
|
+
|
3
|
+
require "musk/version"
|
4
|
+
|
1
5
|
Gem::Specification.new do |s|
|
2
|
-
s.
|
3
|
-
s.
|
4
|
-
s.summary =
|
5
|
-
s.description =
|
6
|
-
s.homepage =
|
7
|
-
|
8
|
-
s.
|
9
|
-
s.
|
10
|
-
s.license = 'MIT'
|
6
|
+
s.author = "Eugene Pempel"
|
7
|
+
s.email = "eugene.pempel@gmail.com"
|
8
|
+
s.summary = "Your music with the demonic scent of musk"
|
9
|
+
s.description = "Your music with the demonic scent of musk."
|
10
|
+
s.homepage = "https://github.com/pempel/musk"
|
11
|
+
|
12
|
+
s.name = "musk"
|
13
|
+
s.date = "2014-03-19"
|
11
14
|
s.files = `git ls-files`.split($\)
|
12
|
-
s.executables = `git ls-files -- bin/*`.split($\).map {
|
15
|
+
s.executables = `git ls-files -- bin/*`.split($\).map {|f| File.basename(f)}
|
16
|
+
s.license = "MIT"
|
17
|
+
s.version = Musk::VERSION
|
13
18
|
|
14
|
-
s.add_runtime_dependency
|
15
|
-
s.add_runtime_dependency
|
16
|
-
s.add_runtime_dependency 'discogs-wrapper', '~> 1.1'
|
19
|
+
s.add_runtime_dependency "gli", "~> 2.9"
|
20
|
+
s.add_runtime_dependency "taglib-ruby", "~> 0.6"
|
17
21
|
|
18
|
-
s.add_development_dependency
|
19
|
-
s.add_development_dependency
|
22
|
+
s.add_development_dependency "pry", "~> 0.9"
|
23
|
+
s.add_development_dependency "rspec", "~> 2.14"
|
24
|
+
s.add_development_dependency "factory_girl", "~> 4.4"
|
25
|
+
s.add_development_dependency "simplecov", "~> 0.8"
|
20
26
|
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "musk extract" do
|
4
|
+
let(:command) { "bundle exec bin/musk extract" }
|
5
|
+
|
6
|
+
context "called without arguments" do
|
7
|
+
it "should fail with the exit code 1" do
|
8
|
+
stdout, stderr, status = Open3.capture3(command)
|
9
|
+
status.exitstatus.should eq(1)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should write an error message to STDERR" do
|
13
|
+
stdout, stderr, status = Open3.capture3(command)
|
14
|
+
stderr.should_not be_empty
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
context "called with 'path_to_tracks'" do
|
19
|
+
it_should_behave_like "a command to print tracks to STDOUT in the pretty format" do
|
20
|
+
let(:expected_command) { command }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
context "called with '-f pretty path_to_tracks'" do
|
25
|
+
it_should_behave_like "a command to print tracks to STDOUT in the pretty format" do
|
26
|
+
let(:expected_command) { "#{command} -f pretty" }
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context "called with '--format pretty path_to_tracks'" do
|
31
|
+
it_should_behave_like "a command to print tracks to STDOUT in the pretty format" do
|
32
|
+
let(:expected_command) { "#{command} --format pretty" }
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context "called with '--format=pretty path_to_tracks'" do
|
37
|
+
it_should_behave_like "a command to print tracks to STDOUT in the pretty format" do
|
38
|
+
let(:expected_command) { "#{command} --format=pretty" }
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Musk::Format::Pretty do
|
4
|
+
describe ".print(tracks)" do
|
5
|
+
let(:tracks) do
|
6
|
+
[build(:jets_track), build(:kamakura_track)]
|
7
|
+
end
|
8
|
+
|
9
|
+
let(:stdout) do
|
10
|
+
tracks.map do |track|
|
11
|
+
"Path: #{track.path}\n"\
|
12
|
+
"Title: #{track.title}\n"\
|
13
|
+
"Position: #{track.position}\n"\
|
14
|
+
"Artist: #{track.artist}\n"\
|
15
|
+
"Album: #{track.album}\n"\
|
16
|
+
"Genre: #{track.genre}\n"\
|
17
|
+
"Year: #{track.year}\n"\
|
18
|
+
"Comment: #{track.comment}\n"\
|
19
|
+
end.join("\n")
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should print tracks to STDOUT in the pretty format" do
|
23
|
+
capture_stdout { subject.class.print(tracks) }.should eq(stdout)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
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
|
+
describe ".load!(path)" do
|
17
|
+
context "when path.nil?" do
|
18
|
+
it "should raise \"Undefined path to a file or files\"" do
|
19
|
+
error = "Undefined path to a file or files"
|
20
|
+
expect { subject.class.load!(nil) }.to raise_error(error)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
context "when path.empty?" do
|
25
|
+
it "should raise \"Undefined path to a file or files\"" do
|
26
|
+
error = "Undefined path to a file or files"
|
27
|
+
expect { subject.class.load!("") }.to raise_error(error)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
context "when path is a nonexistent directory" do
|
32
|
+
it "should raise \"Unknown path '{path}' to a file or files\"" do
|
33
|
+
path = File.join(ENV["MUSK_TRACKS_PATH"], "/nonexistent")
|
34
|
+
error = "Unknown path '#{path}' to a file or files"
|
35
|
+
expect { subject.class.load!(path) }.to raise_error(error)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context "when path is an exisiting directory" do
|
40
|
+
it "should create tracks from files in the directory and its subdirectories" do
|
41
|
+
subject.class.load!(ENV["MUSK_TRACKS_PATH"]).should be_tracks([
|
42
|
+
build(:jets_track, :loaded),
|
43
|
+
build(:kamakura_track, :loaded),
|
44
|
+
])
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
context "when path is a nonexistent file" do
|
49
|
+
it "should raise \"Unknown path '{path}' to a file or files\"" do
|
50
|
+
path = File.join(ENV["MUSK_TRACKS_PATH"], "/nonexistent.mp3")
|
51
|
+
error = "Unknown path '#{path}' to a file or files"
|
52
|
+
expect { subject.class.load!(path) }.to raise_error(error)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
context "when path is an existing file that is unsupported" do
|
57
|
+
it "should raise \"Unknown extension '{extension}'\"" do
|
58
|
+
path = File.join(ENV["MUSK_TRACKS_PATH"], "/track.bad")
|
59
|
+
error = "Unknown extension '.bad'"
|
60
|
+
allow(File).to receive(:file?).with(path).and_return(true)
|
61
|
+
expect { subject.class.load!(path) }.to raise_error(error)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
context "when path is an existing file that is supported" do
|
66
|
+
it "should create a track from the file" do
|
67
|
+
path = File.join(ENV["MUSK_TRACKS_PATH"], "/bonobo/jets.mp3")
|
68
|
+
subject.class.load!(path).should be_tracks([build(:jets_track, :loaded)])
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Musk::TrackPrinter do
|
4
|
+
describe ".print!(format, tracks)" do
|
5
|
+
let(:tracks) { build_list(:track, 2) }
|
6
|
+
|
7
|
+
context "when format is the pretty format" do
|
8
|
+
it "should call Musk::Format::Pretty.print(tracks)" do
|
9
|
+
allow(Musk::Format::Pretty).to receive(:print).with(tracks)
|
10
|
+
subject.class.print!('pretty', tracks)
|
11
|
+
expect(Musk::Format::Pretty).to have_received(:print).with(tracks)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
context "when format is an unsupported format" do
|
16
|
+
it "should raise \"Unknown format '{format}'\"" do
|
17
|
+
error = "Unknown format 'unsupported'"
|
18
|
+
expect { subject.class.print!('unsupported', tracks) }.to raise_error(error)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Musk::Track do
|
4
|
+
it { should respond_to(:path) }
|
5
|
+
it { should respond_to(:path=) }
|
6
|
+
it { should respond_to(:title) }
|
7
|
+
it { should respond_to(:title=) }
|
8
|
+
it { should respond_to(:position) }
|
9
|
+
it { should respond_to(:position=) }
|
10
|
+
it { should respond_to(:artist) }
|
11
|
+
it { should respond_to(:artist=) }
|
12
|
+
it { should respond_to(:album) }
|
13
|
+
it { should respond_to(:album=) }
|
14
|
+
it { should respond_to(:genre) }
|
15
|
+
it { should respond_to(:genre=) }
|
16
|
+
it { should respond_to(:year) }
|
17
|
+
it { should respond_to(:year=) }
|
18
|
+
it { should respond_to(:comment) }
|
19
|
+
it { should respond_to(:comment=) }
|
20
|
+
|
21
|
+
describe "#attributes" do
|
22
|
+
it "should return a track attributes hash" do
|
23
|
+
track = build(:jets_track)
|
24
|
+
track.attributes.should eq(Hash[
|
25
|
+
Musk::Track::ATTRIBUTES.map {|a| [a, track.send("#{a}")]}
|
26
|
+
])
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,4 +1,22 @@
|
|
1
|
-
require
|
2
|
-
Bundler.setup
|
1
|
+
require "simplecov"
|
3
2
|
|
4
|
-
|
3
|
+
SimpleCov.start do
|
4
|
+
add_filter ".bundle/"
|
5
|
+
add_filter "spec/"
|
6
|
+
end
|
7
|
+
|
8
|
+
ENV["MUSK_TRACKS_PATH"] = File.expand_path("../support/tracks", __FILE__)
|
9
|
+
|
10
|
+
require "factory_girl"
|
11
|
+
require "open3"
|
12
|
+
require "musk"
|
13
|
+
|
14
|
+
Dir[File.expand_path("../support/**/*.rb", __FILE__)].each do |file|
|
15
|
+
require file
|
16
|
+
end
|
17
|
+
|
18
|
+
RSpec.configure do |config|
|
19
|
+
config.include FactoryGirl::Syntax::Methods
|
20
|
+
config.include Helpers
|
21
|
+
config.include Matchers
|
22
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
shared_examples "a command to print tracks to STDOUT in the pretty format" do
|
2
|
+
it "should print tracks to STDOUT via Musk::Format::Pretty" do
|
3
|
+
path = ENV["MUSK_TRACKS_PATH"]
|
4
|
+
tracks = Musk::TrackLoader.load!(path)
|
5
|
+
stdout, stderr, status = Open3.capture3("#{expected_command} #{path}")
|
6
|
+
stdout.should eq(capture_stdout { Musk::Format::Pretty.print(tracks) })
|
7
|
+
status.exitstatus.should eq(0)
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
FactoryGirl.define do
|
2
|
+
factory :track, class: Musk::Track do
|
3
|
+
end
|
4
|
+
|
5
|
+
factory :jets_track, parent: :track do
|
6
|
+
path File.join(ENV["MUSK_TRACKS_PATH"], "bonobo/jets.mp3")
|
7
|
+
title "Jets"
|
8
|
+
position 6
|
9
|
+
artist "Bonobo"
|
10
|
+
album "The North Borders"
|
11
|
+
genre "Electronic"
|
12
|
+
year 2013
|
13
|
+
|
14
|
+
trait :loaded do
|
15
|
+
comment "0"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
factory :kamakura_track, parent: :track do
|
20
|
+
path File.join(ENV["MUSK_TRACKS_PATH"], "emancipator/kamakura.mp3")
|
21
|
+
title "Kamakura"
|
22
|
+
position 4
|
23
|
+
artist "Emancipator"
|
24
|
+
album "Safe In The Steep Cliffs"
|
25
|
+
genre "Electronic"
|
26
|
+
year 2010
|
27
|
+
|
28
|
+
trait :loaded do
|
29
|
+
comment "0"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class BeTracksMatcher
|
2
|
+
include RSpec::Matchers
|
3
|
+
|
4
|
+
def initialize(tracks)
|
5
|
+
@tracks = tracks
|
6
|
+
end
|
7
|
+
|
8
|
+
def matches?(tracks)
|
9
|
+
@tracks.map(&:attributes).should =~ tracks.map(&:attributes)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
module Matchers
|
14
|
+
def be_tracks(tracks = [])
|
15
|
+
BeTracksMatcher.new(tracks)
|
16
|
+
end
|
17
|
+
end
|
Binary file
|
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eugene Pempel
|
@@ -39,47 +39,61 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0.6'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: pry
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
48
|
-
type: :
|
47
|
+
version: '0.9'
|
48
|
+
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '0.9'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '2.14'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '2.14'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: factory_girl
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
75
|
+
version: '4.4'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
82
|
+
version: '4.4'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: simplecov
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.8'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0.8'
|
83
97
|
description: Your music with the demonic scent of musk.
|
84
98
|
email: eugene.pempel@gmail.com
|
85
99
|
executables:
|
@@ -94,9 +108,24 @@ files:
|
|
94
108
|
- README.md
|
95
109
|
- bin/musk
|
96
110
|
- lib/musk.rb
|
111
|
+
- lib/musk/format/pretty.rb
|
112
|
+
- lib/musk/track.rb
|
113
|
+
- lib/musk/track_loader.rb
|
114
|
+
- lib/musk/track_printer.rb
|
115
|
+
- lib/musk/version.rb
|
97
116
|
- musk.gemspec
|
98
|
-
- spec/musk_spec.rb
|
117
|
+
- spec/bin/musk_spec.rb
|
118
|
+
- spec/lib/musk/format/pretty_spec.rb
|
119
|
+
- spec/lib/musk/track_loader_spec.rb
|
120
|
+
- spec/lib/musk/track_printer_spec.rb
|
121
|
+
- spec/lib/musk/track_spec.rb
|
99
122
|
- spec/spec_helper.rb
|
123
|
+
- spec/support/examples/command_to_print_tracks_to_stdout_in_pretty_format_example.rb
|
124
|
+
- spec/support/factories/tracks.rb
|
125
|
+
- spec/support/helpers/capture_stdout_helper.rb
|
126
|
+
- spec/support/matchers/be_tracks_matcher.rb
|
127
|
+
- spec/support/tracks/bonobo/jets.mp3
|
128
|
+
- spec/support/tracks/emancipator/kamakura.mp3
|
100
129
|
homepage: https://github.com/pempel/musk
|
101
130
|
licenses:
|
102
131
|
- MIT
|