itunes-cli 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gem 'optitron'
4
+
5
+ group :test do
6
+ gem 'thoughtbot-shoulda'
7
+ gem 'redgreen'
8
+ end
@@ -0,0 +1,25 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ callsite (0.0.4)
5
+ optitron (0.2.2)
6
+ callsite (~> 0.0.4)
7
+ ruby2ruby (~> 1.2.4)
8
+ ruby_parser (~> 2.0)
9
+ sexp_processor (~> 3.0.4)
10
+ redgreen (1.2.2)
11
+ ruby2ruby (1.2.5)
12
+ ruby_parser (~> 2.0)
13
+ sexp_processor (~> 3.0)
14
+ ruby_parser (2.0.5)
15
+ sexp_processor (~> 3.0)
16
+ sexp_processor (3.0.5)
17
+ thoughtbot-shoulda (2.11.1)
18
+
19
+ PLATFORMS
20
+ ruby
21
+
22
+ DEPENDENCIES
23
+ optitron
24
+ redgreen
25
+ thoughtbot-shoulda
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Marcus Ortiz
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.
@@ -0,0 +1,31 @@
1
+ = itunes-cli
2
+
3
+ a command line interface for itunes (only supports windows/cygwin currently)
4
+
5
+ == Usage
6
+
7
+ Commands
8
+
9
+ show # Shows information about the current track
10
+ play # Plays the current track
11
+ pause # Pauses the current track
12
+ prev # Plays the previous track
13
+ next # Plays the next track
14
+
15
+ Global options
16
+
17
+ -?/--help # Print help message
18
+
19
+ == Note on Patches/Pull Requests
20
+
21
+ * Fork the project.
22
+ * Make your feature addition or bug fix.
23
+ * Add tests for it. This is important so I don't break it in a
24
+ future version unintentionally.
25
+ * Commit, do not mess with rakefile, version, or history.
26
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
27
+ * Send me a pull request. Bonus points for topic branches.
28
+
29
+ == Copyright
30
+
31
+ Copyright (c) 2010 Marcus Ortiz. See LICENSE for details.
@@ -0,0 +1,55 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ require './lib/itunes-cli'
7
+ Jeweler::Tasks.new do |gem|
8
+ gem.name = "itunes-cli"
9
+ gem.summary = %Q{a command line interface for itunes}
10
+ gem.description = %Q{a command line interface for itunes (only supports windows/cygwin currently)}
11
+ gem.email = "mportiz08@gmail.com"
12
+ gem.homepage = "http://github.com/mportiz08/itunes-cli"
13
+ gem.authors = ["Marcus Ortiz"]
14
+ gem.add_dependency "optitron"
15
+ gem.executables = ["itunes"]
16
+ gem.version = ItunesCLI::VERSION
17
+ end
18
+ Jeweler::GemcutterTasks.new
19
+ rescue LoadError
20
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
21
+ end
22
+
23
+ require 'rake/testtask'
24
+ Rake::TestTask.new(:test) do |test|
25
+ test.libs << 'lib' << 'test'
26
+ test.pattern = 'test/**/test_*.rb'
27
+ test.verbose = true
28
+ end
29
+
30
+ begin
31
+ require 'rcov/rcovtask'
32
+ Rcov::RcovTask.new do |test|
33
+ test.libs << 'test'
34
+ test.pattern = 'test/**/test_*.rb'
35
+ test.verbose = true
36
+ end
37
+ rescue LoadError
38
+ task :rcov do
39
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
40
+ end
41
+ end
42
+
43
+ task :test# => :check_dependencies
44
+
45
+ task :default => :test
46
+
47
+ require 'rake/rdoctask'
48
+ Rake::RDocTask.new do |rdoc|
49
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
50
+
51
+ rdoc.rdoc_dir = 'rdoc'
52
+ rdoc.title = "itunes-cli #{version}"
53
+ rdoc.rdoc_files.include('README*')
54
+ rdoc.rdoc_files.include('lib/**/*.rb')
55
+ end
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
4
+
5
+ require 'itunes-cli'
6
+
7
+ ItunesCLI::App.dispatch
@@ -0,0 +1,65 @@
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{itunes-cli}
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Marcus Ortiz"]
12
+ s.date = %q{2010-12-21}
13
+ s.default_executable = %q{itunes}
14
+ s.description = %q{a command line interface for itunes (only supports windows/cygwin currently)}
15
+ s.email = %q{mportiz08@gmail.com}
16
+ s.executables = ["itunes"]
17
+ s.extra_rdoc_files = [
18
+ "LICENSE",
19
+ "README.rdoc"
20
+ ]
21
+ s.files = [
22
+ "Gemfile",
23
+ "Gemfile.lock",
24
+ "LICENSE",
25
+ "README.rdoc",
26
+ "Rakefile",
27
+ "bin/itunes",
28
+ "itunes-cli.gemspec",
29
+ "lib/itunes-cli.rb",
30
+ "lib/itunes-cli/app.rb",
31
+ "lib/itunes-cli/player.rb",
32
+ "lib/itunes-cli/track.rb",
33
+ "test/helper.rb",
34
+ "test/itunes-cli/test_player.rb",
35
+ "test/itunes-cli/test_track.rb",
36
+ "test/test_itunes-cli.rb"
37
+ ]
38
+ s.homepage = %q{http://github.com/mportiz08/itunes-cli}
39
+ s.require_paths = ["lib"]
40
+ s.rubygems_version = %q{1.3.7}
41
+ s.summary = %q{a command line interface for itunes}
42
+ s.test_files = [
43
+ "test/helper.rb",
44
+ "test/itunes-cli/test_player.rb",
45
+ "test/itunes-cli/test_track.rb",
46
+ "test/test_itunes-cli.rb"
47
+ ]
48
+
49
+ if s.respond_to? :specification_version then
50
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
51
+ s.specification_version = 3
52
+
53
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
54
+ s.add_runtime_dependency(%q<optitron>, [">= 0"])
55
+ s.add_runtime_dependency(%q<optitron>, [">= 0"])
56
+ else
57
+ s.add_dependency(%q<optitron>, [">= 0"])
58
+ s.add_dependency(%q<optitron>, [">= 0"])
59
+ end
60
+ else
61
+ s.add_dependency(%q<optitron>, [">= 0"])
62
+ s.add_dependency(%q<optitron>, [">= 0"])
63
+ end
64
+ end
65
+
@@ -0,0 +1,10 @@
1
+ module ItunesCLI
2
+ VERSION = "0.1.0"
3
+ AUTHOR = "Marcus Ortiz"
4
+ NAME = "itunes-cli"
5
+ end
6
+
7
+ dir = File.expand_path(File.dirname(__FILE__))
8
+ require File.join(dir, 'itunes-cli', 'track')
9
+ require File.join(dir, 'itunes-cli', 'player')
10
+ require File.join(dir, 'itunes-cli', 'app')
@@ -0,0 +1,48 @@
1
+ require 'optitron'
2
+
3
+ module ItunesCLI
4
+ class App < Optitron::CLI
5
+ include ItunesCLI
6
+
7
+ desc "displays the current version of itunes-cli"
8
+ def version
9
+ puts "#{NAME} v#{VERSION}\nby #{AUTHOR}"
10
+ end
11
+
12
+ desc "Shows information about the current track"
13
+ def show
14
+ player = Player.new
15
+ puts player.current
16
+ end
17
+
18
+ desc "Plays the current track"
19
+ def play
20
+ player = Player.new
21
+ player.play
22
+ end
23
+
24
+ desc "Pauses the current track"
25
+ def pause
26
+ player = Player.new
27
+ player.pause
28
+ end
29
+
30
+ desc "Stop the current track"
31
+ def stop
32
+ player = Player.new
33
+ player.stop
34
+ end
35
+
36
+ desc "Plays the previous track"
37
+ def prev
38
+ player = Player.new
39
+ player.prev
40
+ end
41
+
42
+ desc "Plays the next track"
43
+ def next
44
+ player = Player.new
45
+ player.next
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,49 @@
1
+ require 'win32ole'
2
+
3
+ module ItunesCLI
4
+ class Player
5
+ attr_reader :itunes
6
+
7
+ def initialize
8
+ @itunes = WIN32OLE.new("iTunes.Application")
9
+ end
10
+
11
+ def play
12
+ @itunes.Play()
13
+ end
14
+
15
+ def pause
16
+ @itunes.Pause()
17
+ end
18
+
19
+ def stop
20
+ @itunes.Stop()
21
+ end
22
+
23
+ def prev
24
+ @itunes.PreviousTrack()
25
+ end
26
+
27
+ def next
28
+ @itunes.NextTrack()
29
+ end
30
+
31
+ def current
32
+ Track.new({:title => track, :artist => artist, :album => album})
33
+ end
34
+
35
+ private
36
+
37
+ def track
38
+ @itunes.CurrentTrack.name
39
+ end
40
+
41
+ def artist
42
+ @itunes.CurrentTrack.Artist
43
+ end
44
+
45
+ def album
46
+ @itunes.CurrentTrack.Album
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,15 @@
1
+ module ItunesCLI
2
+ class Track
3
+ attr_reader :title, :artist, :album
4
+
5
+ def initialize(info)
6
+ @title = info[:title]
7
+ @artist = info[:artist]
8
+ @album = info[:album]
9
+ end
10
+
11
+ def to_s
12
+ "song:\t#{@title}\nartist:\t#{@artist}\nalbum:\t#{@album}"
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,11 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'shoulda'
4
+ require 'redgreen'
5
+
6
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
7
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
8
+ require 'itunes-cli'
9
+
10
+ class Test::Unit::TestCase
11
+ end
@@ -0,0 +1,37 @@
1
+ require 'helper'
2
+
3
+ class TestPlayer < Test::Unit::TestCase
4
+ include ItunesCLI
5
+
6
+ def setup
7
+ @player = Player.new
8
+ @track = @player.current
9
+ end
10
+
11
+ should "respond to the play method" do
12
+ assert_respond_to @player, :play
13
+ end
14
+
15
+ should "respond to the pause method" do
16
+ assert_respond_to @player, :pause
17
+ end
18
+
19
+ should "respond to the stop method" do
20
+ assert_respond_to @player, :stop
21
+ end
22
+
23
+ should "respond to the prev method" do
24
+ assert_respond_to @player, :prev
25
+ end
26
+
27
+ should "respond to the next method" do
28
+ assert_respond_to @player, :next
29
+ end
30
+
31
+ should "return the current track" do
32
+ assert_equal @track.title, @player.current.title
33
+ assert_equal @track.artist, @player.current.artist
34
+ assert_equal @track.album, @player.current.album
35
+ assert_equal @track.to_s, @player.current.to_s
36
+ end
37
+ end
@@ -0,0 +1,29 @@
1
+ require 'helper'
2
+
3
+ class TestTrack < Test::Unit::TestCase
4
+ include ItunesCLI
5
+
6
+ def setup
7
+ @track = Track.new({
8
+ :title => "Act Appalled",
9
+ :artist => "Circa Survive",
10
+ :album => "Juturna"
11
+ })
12
+ end
13
+
14
+ should "have the correct song title" do
15
+ assert_equal "Act Appalled", @track.title
16
+ end
17
+
18
+ should "have the correct artist of song" do
19
+ assert_equal "Circa Survive", @track.artist
20
+ end
21
+
22
+ should "have the correct album of song" do
23
+ assert_equal "Juturna", @track.album
24
+ end
25
+
26
+ should "display information about the current track correctly" do
27
+ assert_equal "song:\tAct Appalled\nartist:\tCirca Survive\nalbum:\tJuturna", @track.to_s
28
+ end
29
+ end
@@ -0,0 +1,7 @@
1
+ require 'helper'
2
+
3
+ class TestItunesCli < Test::Unit::TestCase
4
+ should "have the correct version listed" do
5
+ assert_equal "0.1.0", ItunesCLI::VERSION
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,112 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: itunes-cli
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
11
+ platform: ruby
12
+ authors:
13
+ - Marcus Ortiz
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-12-21 00:00:00 -08:00
19
+ default_executable: itunes
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ requirement: &id001 !ruby/object:Gem::Requirement
23
+ none: false
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ hash: 3
28
+ segments:
29
+ - 0
30
+ version: "0"
31
+ type: :runtime
32
+ prerelease: false
33
+ version_requirements: *id001
34
+ name: optitron
35
+ - !ruby/object:Gem::Dependency
36
+ requirement: &id002 !ruby/object:Gem::Requirement
37
+ none: false
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ hash: 3
42
+ segments:
43
+ - 0
44
+ version: "0"
45
+ type: :runtime
46
+ prerelease: false
47
+ version_requirements: *id002
48
+ name: optitron
49
+ description: a command line interface for itunes (only supports windows/cygwin currently)
50
+ email: mportiz08@gmail.com
51
+ executables:
52
+ - itunes
53
+ extensions: []
54
+
55
+ extra_rdoc_files:
56
+ - LICENSE
57
+ - README.rdoc
58
+ files:
59
+ - Gemfile
60
+ - Gemfile.lock
61
+ - LICENSE
62
+ - README.rdoc
63
+ - Rakefile
64
+ - bin/itunes
65
+ - itunes-cli.gemspec
66
+ - lib/itunes-cli.rb
67
+ - lib/itunes-cli/app.rb
68
+ - lib/itunes-cli/player.rb
69
+ - lib/itunes-cli/track.rb
70
+ - test/helper.rb
71
+ - test/itunes-cli/test_player.rb
72
+ - test/itunes-cli/test_track.rb
73
+ - test/test_itunes-cli.rb
74
+ has_rdoc: true
75
+ homepage: http://github.com/mportiz08/itunes-cli
76
+ licenses: []
77
+
78
+ post_install_message:
79
+ rdoc_options: []
80
+
81
+ require_paths:
82
+ - lib
83
+ required_ruby_version: !ruby/object:Gem::Requirement
84
+ none: false
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ hash: 3
89
+ segments:
90
+ - 0
91
+ version: "0"
92
+ required_rubygems_version: !ruby/object:Gem::Requirement
93
+ none: false
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ hash: 3
98
+ segments:
99
+ - 0
100
+ version: "0"
101
+ requirements: []
102
+
103
+ rubyforge_project:
104
+ rubygems_version: 1.3.7
105
+ signing_key:
106
+ specification_version: 3
107
+ summary: a command line interface for itunes
108
+ test_files:
109
+ - test/helper.rb
110
+ - test/itunes-cli/test_player.rb
111
+ - test/itunes-cli/test_track.rb
112
+ - test/test_itunes-cli.rb