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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 133564e8ff231c5a22373dff976442425055270d
4
- data.tar.gz: f2244b11611fcb50294454a92ebd4b5bdf201861
3
+ metadata.gz: fe54725858bda7ea5b54f600384b2825aa215beb
4
+ data.tar.gz: 714ce8c5c38647b30f12d94440c41ec2bd3bdd68
5
5
  SHA512:
6
- metadata.gz: 105306e6386f4018e53ef9b5b5ce7ba6e19f80779618dd224d3110e00ac5658c04a81ffba6a3064c72ca60b7e5d32141f6f702c46833579ff7834a5ff938744b
7
- data.tar.gz: ad172e5d32c437b6d3693e8efbf6a4ed628b4fe8938327fe9af681692565273cf322271024be9a4d9787cea49e2e547e0005c316265dd5bc6d366ca6103a9df0
6
+ metadata.gz: 4e84f1c53a46a00e865f6b1c72a5dae29a7bf8040fa1fe73a160e4b82a19fd25ccdb58a44e378565e038b66d603e5974231510e7a903a079f466496ade18a6e2
7
+ data.tar.gz: 25b70dc5dee44dc91aa5e388e9653f9a5978594a2b6bff2fd6f1338bf7e0740fad451a26c29e71559fb390db81ea77ad5b19740ad3bfc0a5cfaf18dd530095a4
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- musk (0.1.3)
4
+ musk (0.1.4)
5
5
  gli (~> 2.9)
6
6
  taglib-ruby (~> 0.6)
7
7
 
data/LICENSE CHANGED
@@ -1,3 +1,5 @@
1
+ The MIT License (MIT)
2
+
1
3
  Copyright (c) 2014 Eugene Pempel
2
4
 
3
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
data/README.md CHANGED
@@ -1,10 +1,11 @@
1
1
  ## Musk
2
2
 
3
- [![Gem Version](https://badge.fury.io/rb/musk.png)](http://badge.fury.io/rb/musk)
4
- [![Code Climate](https://codeclimate.com/github/pempel/musk.png)](https://codeclimate.com/github/pempel/musk)
5
- [![Coverage Status](https://coveralls.io/repos/pempel/musk/badge.png?branch=master)](https://coveralls.io/r/pempel/musk?branch=master)
6
- [![Build Status](https://travis-ci.org/pempel/musk.png?branch=master)](https://travis-ci.org/pempel/musk)
7
- [![Dependency Status](https://gemnasium.com/pempel/musk.png)](https://gemnasium.com/pempel/musk)
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
@@ -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.each do |track|
17
- track = Musk::Decorator::PrintableTrack.new(track)
18
- puts ATTRIBUTES.map {|a| track.send(a)}.join(",")
19
- end
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.each_with_index do |track, index|
17
- track = Musk::Decorator::PrintableTrack.new(track)
18
- puts if index > 0
19
- ATTRIBUTES.map do |attribute|
20
- printf("%-10s%s\n", "#{attribute.capitalize}:", track.send(attribute))
21
- end
22
- end
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
@@ -16,7 +16,7 @@ module Musk
16
16
  attr_accessor *ATTRIBUTES
17
17
 
18
18
  def attributes
19
- Hash[ATTRIBUTES.map {|a| [a, send("#{a}")]}]
19
+ Hash[ATTRIBUTES.map { |a| [a, send("#{a}")] }]
20
20
  end
21
21
  end
22
22
  end
@@ -3,18 +3,36 @@ require "taglib"
3
3
  module Musk
4
4
  class TrackLoader
5
5
  def self.load!(path)
6
- unless path and path.length > 0
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
- path = File.expand_path(path)
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|
@@ -1,11 +1,20 @@
1
1
  module Musk
2
2
  class TrackPrinter
3
3
  def self.print!(format, tracks)
4
- case format.to_s.to_sym
5
- when :csv then Musk::Formatter::CSV.print(tracks)
6
- when :pretty then Musk::Formatter::Pretty.print(tracks)
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
@@ -1,3 +1,3 @@
1
1
  module Musk
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
@@ -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
- printable_tracks = tracks.map {|t| Musk::Decorator::PrintableTrack.new(t)}
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
- printable_tracks = tracks.map {|t| Musk::Decorator::PrintableTrack.new(t)}
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
@@ -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.3
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-27 00:00:00.000000000 Z
11
+ date: 2014-03-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gli