musk 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/LICENSE +2 -0
- data/README.md +8 -5
- data/lib/musk/formatter/csv.rb +16 -15
- data/lib/musk/formatter/pretty.rb +16 -18
- data/lib/musk/track.rb +1 -1
- data/lib/musk/track_loader.rb +25 -7
- data/lib/musk/track_printer.rb +13 -4
- data/lib/musk/version.rb +1 -1
- data/spec/lib/musk/formatter/csv_spec.rb +3 -4
- data/spec/lib/musk/formatter/pretty_spec.rb +3 -4
- data/spec/lib/musk/track_spec.rb +1 -1
- data/spec/support/examples/extract_command_with_csv_format_example.rb +1 -1
- data/spec/support/examples/extract_command_with_pretty_format_example.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fe54725858bda7ea5b54f600384b2825aa215beb
|
4
|
+
data.tar.gz: 714ce8c5c38647b30f12d94440c41ec2bd3bdd68
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e84f1c53a46a00e865f6b1c72a5dae29a7bf8040fa1fe73a160e4b82a19fd25ccdb58a44e378565e038b66d603e5974231510e7a903a079f466496ade18a6e2
|
7
|
+
data.tar.gz: 25b70dc5dee44dc91aa5e388e9653f9a5978594a2b6bff2fd6f1338bf7e0740fad451a26c29e71559fb390db81ea77ad5b19740ad3bfc0a5cfaf18dd530095a4
|
data/Gemfile.lock
CHANGED
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
## Musk
|
2
2
|
|
3
|
-
[![Gem Version](https://
|
4
|
-
[![Code Climate](https://
|
5
|
-
[![Coverage Status](https://
|
6
|
-
[![Build Status](https://
|
7
|
-
[![Dependency Status](https://
|
3
|
+
[![Gem Version](https://img.shields.io/gem/v/musk.svg)](https://badge.fury.io/rb/musk)
|
4
|
+
[![Code Climate](https://img.shields.io/codeclimate/github/pempel/musk.svg)](https://codeclimate.com/github/pempel/musk)
|
5
|
+
[![Coverage Status](https://img.shields.io/coveralls/pempel/musk/master.svg)](https://coveralls.io/r/pempel/musk?branch=master)
|
6
|
+
[![Build Status](https://img.shields.io/travis/pempel/musk/master.svg)](https://travis-ci.org/pempel/musk)
|
7
|
+
[![Dependency Status](https://img.shields.io/gemnasium/pempel/musk.svg)](https://gemnasium.com/pempel/musk)
|
8
|
+
[![MIT License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](https://tldrlegal.com/license/mit-license)
|
8
9
|
|
9
10
|
Use musk to impart the demonic scent of musk to your music.
|
10
11
|
Musk allows you to extract tags from MP3 files and perfume MP3 files
|
@@ -93,6 +94,8 @@ several commands together. For example,
|
|
93
94
|
|
94
95
|
## License
|
95
96
|
|
97
|
+
The MIT License (MIT)
|
98
|
+
|
96
99
|
Copyright (c) 2014 Eugene Pempel
|
97
100
|
|
98
101
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
data/lib/musk/formatter/csv.rb
CHANGED
@@ -1,22 +1,23 @@
|
|
1
1
|
module Musk
|
2
2
|
module Formatter
|
3
3
|
class CSV
|
4
|
-
ATTRIBUTES = [
|
5
|
-
:path,
|
6
|
-
:title,
|
7
|
-
:position,
|
8
|
-
:artist,
|
9
|
-
:release,
|
10
|
-
:genre,
|
11
|
-
:year,
|
12
|
-
:comment,
|
13
|
-
]
|
14
|
-
|
15
4
|
def self.print(tracks)
|
16
|
-
tracks.
|
17
|
-
|
18
|
-
|
19
|
-
|
5
|
+
new(tracks).print
|
6
|
+
end
|
7
|
+
|
8
|
+
def initialize(tracks)
|
9
|
+
@tracks = tracks.map { |t| Musk::Decorator::PrintableTrack.new(t) }
|
10
|
+
@fields = [:path, :title, :position, :artist, :release, :genre, :year, :comment]
|
11
|
+
end
|
12
|
+
|
13
|
+
def print
|
14
|
+
@tracks.each { |t| puts printed(t) }
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def printed(track)
|
20
|
+
@fields.map { |f| track.send(f) }.join(",")
|
20
21
|
end
|
21
22
|
end
|
22
23
|
end
|
@@ -1,25 +1,23 @@
|
|
1
1
|
module Musk
|
2
2
|
module Formatter
|
3
3
|
class Pretty
|
4
|
-
ATTRIBUTES = [
|
5
|
-
:path,
|
6
|
-
:title,
|
7
|
-
:position,
|
8
|
-
:artist,
|
9
|
-
:release,
|
10
|
-
:genre,
|
11
|
-
:year,
|
12
|
-
:comment,
|
13
|
-
]
|
14
|
-
|
15
4
|
def self.print(tracks)
|
16
|
-
tracks.
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
5
|
+
new(tracks).print
|
6
|
+
end
|
7
|
+
|
8
|
+
def initialize(tracks)
|
9
|
+
@tracks = tracks.map { |t| Musk::Decorator::PrintableTrack.new(t) }
|
10
|
+
@fields = [:path, :title, :position, :artist, :release, :genre, :year, :comment]
|
11
|
+
end
|
12
|
+
|
13
|
+
def print
|
14
|
+
puts @tracks.map { |t| printed(t) }.join("\n")
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def printed(track)
|
20
|
+
@fields.map { |f| sprintf("%-10s%s\n", "#{f.capitalize}:", track.send(f)) }.join
|
23
21
|
end
|
24
22
|
end
|
25
23
|
end
|
data/lib/musk/track.rb
CHANGED
data/lib/musk/track_loader.rb
CHANGED
@@ -3,18 +3,36 @@ require "taglib"
|
|
3
3
|
module Musk
|
4
4
|
class TrackLoader
|
5
5
|
def self.load!(path)
|
6
|
-
|
6
|
+
new(path).load!
|
7
|
+
end
|
8
|
+
|
9
|
+
def initialize(path)
|
10
|
+
@path = path
|
11
|
+
end
|
12
|
+
|
13
|
+
def load!
|
14
|
+
verify_tracks!
|
15
|
+
create_tracks!
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def verify_tracks!
|
21
|
+
unless @path and @path.length > 0
|
7
22
|
raise "Undefined path to a file or files"
|
8
23
|
end
|
9
|
-
unless File.file?(path) or File.directory?(path)
|
10
|
-
raise "Unknown path '#{path}' to a file or files"
|
24
|
+
unless File.file?(@path) or File.directory?(@path)
|
25
|
+
raise "Unknown path '#{@path}' to a file or files"
|
11
26
|
end
|
12
|
-
if File.file?(path)
|
13
|
-
unless File.extname(path) == ".mp3"
|
14
|
-
raise "Unknown extension '#{File.extname(path)}'"
|
27
|
+
if File.file?(@path)
|
28
|
+
unless File.extname(@path) == ".mp3"
|
29
|
+
raise "Unknown extension '#{File.extname(@path)}'"
|
15
30
|
end
|
16
31
|
end
|
17
|
-
|
32
|
+
end
|
33
|
+
|
34
|
+
def create_tracks!
|
35
|
+
path = File.expand_path(@path)
|
18
36
|
loadpath = "#{File.file?(path) ? File.dirname(path) : path}#{File::SEPARATOR}"
|
19
37
|
deeppath = File.file?(path) ? path : File.join(path, "**", "*.mp3")
|
20
38
|
Dir[deeppath].map do |fullpath|
|
data/lib/musk/track_printer.rb
CHANGED
@@ -1,11 +1,20 @@
|
|
1
1
|
module Musk
|
2
2
|
class TrackPrinter
|
3
3
|
def self.print!(format, tracks)
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
new(format, tracks).print!
|
5
|
+
end
|
6
|
+
|
7
|
+
def initialize(format, tracks)
|
8
|
+
@format = format
|
9
|
+
@tracks = tracks
|
10
|
+
end
|
11
|
+
|
12
|
+
def print!
|
13
|
+
case @format.to_s.to_sym
|
14
|
+
when :csv then Musk::Formatter::CSV.print(@tracks)
|
15
|
+
when :pretty then Musk::Formatter::Pretty.print(@tracks)
|
7
16
|
else
|
8
|
-
raise "Unknown format '#{format}'"
|
17
|
+
raise "Unknown format '#{@format}'"
|
9
18
|
end
|
10
19
|
end
|
11
20
|
end
|
data/lib/musk/version.rb
CHANGED
@@ -2,10 +2,9 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
describe Musk::Formatter::CSV do
|
4
4
|
describe ".print(tracks)" do
|
5
|
-
let(:tracks) {[build(:jets_track), build(:kamakura_track)]}
|
5
|
+
let(:tracks) { [build(:jets_track), build(:kamakura_track)] }
|
6
6
|
let(:stdout) do
|
7
|
-
|
8
|
-
printable_tracks.map do |track|
|
7
|
+
tracks.map { |t| Musk::Decorator::PrintableTrack.new(t) }.map do |track|
|
9
8
|
"#{track.path},"\
|
10
9
|
"#{track.title},"\
|
11
10
|
"#{track.position},"\
|
@@ -18,7 +17,7 @@ describe Musk::Formatter::CSV do
|
|
18
17
|
end
|
19
18
|
|
20
19
|
it "should print tracks to STDOUT in the csv format" do
|
21
|
-
capture_stdout {described_class.print(tracks)}.should eq(stdout)
|
20
|
+
capture_stdout { described_class.print(tracks) }.should eq(stdout)
|
22
21
|
end
|
23
22
|
end
|
24
23
|
end
|
@@ -2,10 +2,9 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
describe Musk::Formatter::Pretty do
|
4
4
|
describe ".print(tracks)" do
|
5
|
-
let(:tracks) {[build(:jets_track), build(:kamakura_track)]}
|
5
|
+
let(:tracks) { [build(:jets_track), build(:kamakura_track)] }
|
6
6
|
let(:stdout) do
|
7
|
-
|
8
|
-
printable_tracks.map do |track|
|
7
|
+
tracks.map { |t| Musk::Decorator::PrintableTrack.new(t) }.map do |track|
|
9
8
|
"Path: #{track.path}\n"\
|
10
9
|
"Title: #{track.title}\n"\
|
11
10
|
"Position: #{track.position}\n"\
|
@@ -18,7 +17,7 @@ describe Musk::Formatter::Pretty do
|
|
18
17
|
end
|
19
18
|
|
20
19
|
it "should print tracks to STDOUT in the pretty format" do
|
21
|
-
capture_stdout {described_class.print(tracks)}.should eq(stdout)
|
20
|
+
capture_stdout { described_class.print(tracks) }.should eq(stdout)
|
22
21
|
end
|
23
22
|
end
|
24
23
|
end
|
data/spec/lib/musk/track_spec.rb
CHANGED
@@ -26,7 +26,7 @@ describe Musk::Track do
|
|
26
26
|
it "should return a track attributes hash" do
|
27
27
|
track = build(:jets_track)
|
28
28
|
track.attributes.should eq(Hash[
|
29
|
-
Musk::Track::ATTRIBUTES.map {|a| [a, track.send("#{a}")]}
|
29
|
+
Musk::Track::ATTRIBUTES.map { |a| [a, track.send("#{a}")] }
|
30
30
|
])
|
31
31
|
end
|
32
32
|
end
|
@@ -5,7 +5,7 @@ shared_examples "the extract command with the csv format" do |options|
|
|
5
5
|
path = ENV["MUSK_TRACKS_PATH"]
|
6
6
|
tracks = Musk::TrackLoader.load!(path)
|
7
7
|
stdout, stderr, status = Open3.capture3("#{command} #{options} #{path}")
|
8
|
-
stdout.should eq(capture_stdout {Musk::Formatter::CSV.print(tracks)})
|
8
|
+
stdout.should eq(capture_stdout { Musk::Formatter::CSV.print(tracks) })
|
9
9
|
status.exitstatus.should eq(0)
|
10
10
|
end
|
11
11
|
end
|
@@ -5,7 +5,7 @@ shared_examples "the extract command with the pretty format" do |options|
|
|
5
5
|
path = ENV["MUSK_TRACKS_PATH"]
|
6
6
|
tracks = Musk::TrackLoader.load!(path)
|
7
7
|
stdout, stderr, status = Open3.capture3("#{command} #{options} #{path}")
|
8
|
-
stdout.should eq(capture_stdout {Musk::Formatter::Pretty.print(tracks)})
|
8
|
+
stdout.should eq(capture_stdout { Musk::Formatter::Pretty.print(tracks) })
|
9
9
|
status.exitstatus.should eq(0)
|
10
10
|
end
|
11
11
|
end
|
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.1.
|
4
|
+
version: 0.1.4
|
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-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gli
|