rob-gordon 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem 'id3lib-ruby'
4
+
5
+ group :development do
6
+ gem "shoulda", ">= 0"
7
+ gem "bundler", "~> 1.0.0"
8
+ gem "jeweler", "~> 1.5.2"
9
+ gem "rcov", ">= 0"
10
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,22 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ git (1.2.5)
5
+ id3lib-ruby (0.6.0)
6
+ jeweler (1.5.2)
7
+ bundler (~> 1.0.0)
8
+ git (>= 1.2.5)
9
+ rake
10
+ rake (0.8.7)
11
+ rcov (0.9.9)
12
+ shoulda (2.11.3)
13
+
14
+ PLATFORMS
15
+ ruby
16
+
17
+ DEPENDENCIES
18
+ bundler (~> 1.0.0)
19
+ id3lib-ruby
20
+ jeweler (~> 1.5.2)
21
+ rcov
22
+ shoulda
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 andyleclair
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,27 @@
1
+ = Rob Gordon
2
+
3
+ A music organizer for the self-confessed obsessive.
4
+
5
+ == Credits
6
+
7
+ * Camden for the Vale EP included in the test directory. Download it at http://camden.bandcamp.com
8
+ * Robin Stocker fro id3lib-ruby -- http://id3lib-ruby.rubyforge.org/
9
+
10
+ No, seriously, turbo props to Camden for letting me distribute their EP as a part of this source.
11
+ Check them out at http://camdensoundz.com
12
+
13
+ == Contributing to rob-gordon
14
+
15
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
16
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
17
+ * Fork the project
18
+ * Start a feature/bugfix branch
19
+ * Commit and push until you are happy with your contribution
20
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
21
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
22
+
23
+ == Copyright
24
+
25
+ Copyright (c) 2011 andyleclair. See LICENSE.txt for
26
+ further details.
27
+
data/Rakefile ADDED
@@ -0,0 +1,52 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'rake'
11
+
12
+ require 'jeweler'
13
+ Jeweler::Tasks.new do |gem|
14
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
15
+ gem.name = "rob-gordon"
16
+ gem.homepage = "http://github.com/andyleclair/rob-gordon"
17
+ gem.license = "MIT"
18
+ gem.summary = %Q{A music organizer, for the self confessed obsessive}
19
+ gem.description = %Q{A music organizer, for the self confessed obsessive}
20
+ gem.email = "andyleclair@gmail.com"
21
+ gem.authors = ["andyleclair"]
22
+ # Include your dependencies below. Runtime dependencies are required when using your gem,
23
+ # and development dependencies are only needed for development (ie running rake tasks, tests, etc)
24
+ gem.add_runtime_dependency 'id3lib-ruby', '> 0.1'
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rake/testtask'
29
+ Rake::TestTask.new(:test) do |test|
30
+ test.libs << 'lib' << 'test'
31
+ test.pattern = 'test/**/test_*.rb'
32
+ test.verbose = true
33
+ end
34
+
35
+ require 'rcov/rcovtask'
36
+ Rcov::RcovTask.new do |test|
37
+ test.libs << 'test'
38
+ test.pattern = 'test/**/test_*.rb'
39
+ test.verbose = true
40
+ end
41
+
42
+ task :default => :test
43
+
44
+ require 'rake/rdoctask'
45
+ Rake::RDocTask.new do |rdoc|
46
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
47
+
48
+ rdoc.rdoc_dir = 'rdoc'
49
+ rdoc.title = "rob-gordon #{version}"
50
+ rdoc.rdoc_files.include('README*')
51
+ rdoc.rdoc_files.include('lib/**/*.rb')
52
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.1
data/bin/rob ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
4
+
5
+ require 'rob'
6
+
7
+ exit Rob::Gordon::run!(*ARGV)
data/lib/rob.rb ADDED
@@ -0,0 +1,91 @@
1
+ require 'id3lib'
2
+ require 'fileutils'
3
+ require 'iconv'
4
+
5
+ module Rob
6
+ module Gordon
7
+
8
+ INTRO = %{
9
+ "What came first, the music or the misery? People worry about kids playing with guns, or watching violent videos, that some sort of culture of violence will take them over.
10
+ Nobody worries about kids listening to thousands, literally thousands of songs about heartbreak, rejection, pain, misery and loss.
11
+ Did I listen to pop music because I was miserable? Or was I miserable because I listened to pop music?"
12
+
13
+ usage:
14
+ rob %folder %library
15
+
16
+ That command will import the folder to your library
17
+ }
18
+
19
+
20
+ def self.run!(*args)
21
+
22
+ case args.length
23
+ when 0
24
+ puts INTRO
25
+ when 1
26
+ indir = args[0]
27
+ import!(indir)
28
+ when 2
29
+ indir, lib = args
30
+ import!(indir, lib)
31
+ else
32
+ puts INTRO
33
+ end
34
+ return 0
35
+ end
36
+
37
+ def self.import!(indir, libdir="#{ ENV['HOME']}/Music")
38
+ puts "Imporing all mp3s in: #{ indir }"
39
+ puts "Now importing to #{ libdir }"
40
+ Dir[File.join(indir, '**.mp3')].sort.each do |file|
41
+ if File.extname(file) == '.mp3'
42
+ song = ID3Lib::Tag.new file
43
+ begin
44
+ artist = song.artist
45
+ album = song.album
46
+ track = song.track[0]
47
+ title = song.title
48
+ rescue
49
+ # Suck a dick, UTF-16
50
+ artist = Iconv.conv('UTF-8', 'UTF-16BE', song.artist)
51
+ album = Iconv.conv('UTF-8', 'UTF-16BE', song.album)
52
+ track = Iconv.conv('UTF-8', 'UTF-16BE', song.track)[0]
53
+ title = Iconv.conv('UTF-8', 'UTF-16BE', song.title)
54
+ end
55
+
56
+ out_file = filename(track, title)
57
+ dest = File.join(libdir, artist, album, out_file)
58
+ artistdir = File.join(libdir, artist)
59
+ albumdir = File.join(artistdir, album)
60
+
61
+ if !File.exists? dest
62
+ if !Dir.exists? artistdir
63
+ puts "Creating artist directory #{ artistdir }"
64
+ Dir.mkdir artistdir
65
+ end
66
+
67
+ if !Dir.exists? albumdir
68
+ puts "Creating album directory #{ albumdir }"
69
+ Dir.mkdir albumdir
70
+ end
71
+
72
+ puts "Now importing #{ title } to #{ dest }"
73
+ FileUtils.cp file, dest
74
+ else
75
+ puts "Destination file #{ dest } exists, skipping..."
76
+ end
77
+ else
78
+
79
+ end
80
+ end
81
+ end
82
+
83
+ def self.filename(track, title)
84
+ if track.to_i < 10
85
+ "0#{ track }. #{ title }.mp3"
86
+ else
87
+ "#{ track }. #{ title }.mp3"
88
+ end
89
+ end
90
+ end
91
+ end
@@ -0,0 +1,78 @@
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 = %q{rob-gordon}
8
+ s.version = "0.1.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["andyleclair"]
12
+ s.date = %q{2011-03-09}
13
+ s.default_executable = %q{rob}
14
+ s.description = %q{A music organizer, for the self confessed obsessive}
15
+ s.email = %q{andyleclair@gmail.com}
16
+ s.executables = ["rob"]
17
+ s.extra_rdoc_files = [
18
+ "LICENSE.txt",
19
+ "README.rdoc"
20
+ ]
21
+ s.files = [
22
+ ".document",
23
+ "Gemfile",
24
+ "Gemfile.lock",
25
+ "LICENSE.txt",
26
+ "README.rdoc",
27
+ "Rakefile",
28
+ "VERSION",
29
+ "bin/rob",
30
+ "lib/rob.rb",
31
+ "rob-gordon.gemspec",
32
+ "test/helper.rb",
33
+ "test/music/Camden - Vale EP - 01 Penelope.mp3",
34
+ "test/music/Camden - Vale EP - 02 Walkin' on the Beast.mp3",
35
+ "test/music/Camden - Vale EP - 03 Whenever You're Awake.mp3",
36
+ "test/music/Camden - Vale EP - 04 Too Young To Come.mp3",
37
+ "test/music/Camden - Vale EP - 05 It's Hot in the Morning.mp3",
38
+ "test/test_rob.rb"
39
+ ]
40
+ s.homepage = %q{http://github.com/andyleclair/rob-gordon}
41
+ s.licenses = ["MIT"]
42
+ s.require_paths = ["lib"]
43
+ s.rubygems_version = %q{1.3.7}
44
+ s.summary = %q{A music organizer, for the self confessed obsessive}
45
+ s.test_files = [
46
+ "test/helper.rb",
47
+ "test/test_rob.rb"
48
+ ]
49
+
50
+ if s.respond_to? :specification_version then
51
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
52
+ s.specification_version = 3
53
+
54
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
55
+ s.add_runtime_dependency(%q<id3lib-ruby>, [">= 0"])
56
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
57
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
58
+ s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
59
+ s.add_development_dependency(%q<rcov>, [">= 0"])
60
+ s.add_runtime_dependency(%q<id3lib-ruby>, ["> 0.1"])
61
+ else
62
+ s.add_dependency(%q<id3lib-ruby>, [">= 0"])
63
+ s.add_dependency(%q<shoulda>, [">= 0"])
64
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
65
+ s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
66
+ s.add_dependency(%q<rcov>, [">= 0"])
67
+ s.add_dependency(%q<id3lib-ruby>, ["> 0.1"])
68
+ end
69
+ else
70
+ s.add_dependency(%q<id3lib-ruby>, [">= 0"])
71
+ s.add_dependency(%q<shoulda>, [">= 0"])
72
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
73
+ s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
74
+ s.add_dependency(%q<rcov>, [">= 0"])
75
+ s.add_dependency(%q<id3lib-ruby>, ["> 0.1"])
76
+ end
77
+ end
78
+
data/test/helper.rb ADDED
@@ -0,0 +1,19 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'test/unit'
11
+ require 'shoulda'
12
+
13
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
14
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
15
+ require 'rob'
16
+ require 'fileutils'
17
+
18
+ class Test::Unit::TestCase
19
+ end
data/test/test_rob.rb ADDED
@@ -0,0 +1,24 @@
1
+ require 'helper'
2
+
3
+ class TestRob < Test::Unit::TestCase
4
+
5
+ def setup
6
+ @music_dir = File.expand_path(File.join('test', 'music'))
7
+ @music_lib = File.expand_path(File.join('test', 'library'))
8
+ end
9
+
10
+ def test_import
11
+ Rob::Gordon::import!(@music_dir, @music_lib)
12
+ assert Dir.exists?(File.join(@music_lib, 'Camden')), "Didin't create artist dir"
13
+ assert Dir.exists?(File.join(@music_lib, 'Camden', 'Vale EP')), "Didin't create album dir"
14
+ end
15
+
16
+ def teardown
17
+ Dir[File.join(@music_lib, '**/**/*.mp3')].each do |file|
18
+ FileUtils.remove_file file
19
+ end
20
+ Dir.delete(File.join(@music_lib, 'Camden', 'Vale EP'))
21
+ Dir.delete(File.join(@music_lib, 'Camden'))
22
+ end
23
+
24
+ end
metadata ADDED
@@ -0,0 +1,165 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rob-gordon
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ - 1
9
+ version: 0.1.1
10
+ platform: ruby
11
+ authors:
12
+ - andyleclair
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2011-03-09 00:00:00 -05:00
18
+ default_executable: rob
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: id3lib-ruby
22
+ requirement: &id001 !ruby/object:Gem::Requirement
23
+ none: false
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
29
+ version: "0"
30
+ type: :runtime
31
+ prerelease: false
32
+ version_requirements: *id001
33
+ - !ruby/object:Gem::Dependency
34
+ name: shoulda
35
+ requirement: &id002 !ruby/object:Gem::Requirement
36
+ none: false
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ segments:
41
+ - 0
42
+ version: "0"
43
+ type: :development
44
+ prerelease: false
45
+ version_requirements: *id002
46
+ - !ruby/object:Gem::Dependency
47
+ name: bundler
48
+ requirement: &id003 !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ segments:
54
+ - 1
55
+ - 0
56
+ - 0
57
+ version: 1.0.0
58
+ type: :development
59
+ prerelease: false
60
+ version_requirements: *id003
61
+ - !ruby/object:Gem::Dependency
62
+ name: jeweler
63
+ requirement: &id004 !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ segments:
69
+ - 1
70
+ - 5
71
+ - 2
72
+ version: 1.5.2
73
+ type: :development
74
+ prerelease: false
75
+ version_requirements: *id004
76
+ - !ruby/object:Gem::Dependency
77
+ name: rcov
78
+ requirement: &id005 !ruby/object:Gem::Requirement
79
+ none: false
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ segments:
84
+ - 0
85
+ version: "0"
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: *id005
89
+ - !ruby/object:Gem::Dependency
90
+ name: id3lib-ruby
91
+ requirement: &id006 !ruby/object:Gem::Requirement
92
+ none: false
93
+ requirements:
94
+ - - ">"
95
+ - !ruby/object:Gem::Version
96
+ segments:
97
+ - 0
98
+ - 1
99
+ version: "0.1"
100
+ type: :runtime
101
+ prerelease: false
102
+ version_requirements: *id006
103
+ description: A music organizer, for the self confessed obsessive
104
+ email: andyleclair@gmail.com
105
+ executables:
106
+ - rob
107
+ extensions: []
108
+
109
+ extra_rdoc_files:
110
+ - LICENSE.txt
111
+ - README.rdoc
112
+ files:
113
+ - .document
114
+ - Gemfile
115
+ - Gemfile.lock
116
+ - LICENSE.txt
117
+ - README.rdoc
118
+ - Rakefile
119
+ - VERSION
120
+ - bin/rob
121
+ - lib/rob.rb
122
+ - rob-gordon.gemspec
123
+ - test/helper.rb
124
+ - test/music/Camden - Vale EP - 01 Penelope.mp3
125
+ - test/music/Camden - Vale EP - 02 Walkin' on the Beast.mp3
126
+ - test/music/Camden - Vale EP - 03 Whenever You're Awake.mp3
127
+ - test/music/Camden - Vale EP - 04 Too Young To Come.mp3
128
+ - test/music/Camden - Vale EP - 05 It's Hot in the Morning.mp3
129
+ - test/test_rob.rb
130
+ has_rdoc: true
131
+ homepage: http://github.com/andyleclair/rob-gordon
132
+ licenses:
133
+ - MIT
134
+ post_install_message:
135
+ rdoc_options: []
136
+
137
+ require_paths:
138
+ - lib
139
+ required_ruby_version: !ruby/object:Gem::Requirement
140
+ none: false
141
+ requirements:
142
+ - - ">="
143
+ - !ruby/object:Gem::Version
144
+ hash: 3852869770370115375
145
+ segments:
146
+ - 0
147
+ version: "0"
148
+ required_rubygems_version: !ruby/object:Gem::Requirement
149
+ none: false
150
+ requirements:
151
+ - - ">="
152
+ - !ruby/object:Gem::Version
153
+ segments:
154
+ - 0
155
+ version: "0"
156
+ requirements: []
157
+
158
+ rubyforge_project:
159
+ rubygems_version: 1.3.7
160
+ signing_key:
161
+ specification_version: 3
162
+ summary: A music organizer, for the self confessed obsessive
163
+ test_files:
164
+ - test/helper.rb
165
+ - test/test_rob.rb