eventmachine-itunes 0.0.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/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gem 'eventmachine-distributed-notification', '>= 0.1.4'
4
+
5
+ group :development do
6
+ gem 'rspec', '~> 2.8.0'
7
+ gem 'bundler', '~> 1.1.0'
8
+ gem 'jeweler', '~> 1.8.3'
9
+ gem 'rb-appscript', :require => 'appscript'
10
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,36 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ diff-lcs (1.1.3)
5
+ eventmachine (0.12.10)
6
+ eventmachine-distributed-notification (0.1.4)
7
+ eventmachine
8
+ git (1.2.5)
9
+ jeweler (1.8.3)
10
+ bundler (~> 1.0)
11
+ git (>= 1.2.5)
12
+ rake
13
+ rdoc
14
+ json (1.6.5)
15
+ rake (0.9.2.2)
16
+ rb-appscript (0.6.1)
17
+ rdoc (3.12)
18
+ json (~> 1.4)
19
+ rspec (2.8.0)
20
+ rspec-core (~> 2.8.0)
21
+ rspec-expectations (~> 2.8.0)
22
+ rspec-mocks (~> 2.8.0)
23
+ rspec-core (2.8.0)
24
+ rspec-expectations (2.8.0)
25
+ diff-lcs (~> 1.1.2)
26
+ rspec-mocks (2.8.0)
27
+
28
+ PLATFORMS
29
+ ruby
30
+
31
+ DEPENDENCIES
32
+ bundler (~> 1.1.0)
33
+ eventmachine-distributed-notification (>= 0.1.4)
34
+ jeweler (~> 1.8.3)
35
+ rb-appscript
36
+ rspec (~> 2.8.0)
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 youpy
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,35 @@
1
+ = eventmachine-itunes
2
+
3
+ An {EventMachine}[http://wiki.github.com/eventmachine/eventmachine/] extension to watch iTunes play/pause/stop
4
+
5
+ == Synopsis
6
+
7
+ require 'eventmachine-itunes'
8
+
9
+ === Watch iTunes
10
+
11
+ module Watcher
12
+ def on_play(info)
13
+ puts 'now playing %s' % [info['Artist'], info['Name']].join(' - ')
14
+ end
15
+ end
16
+
17
+ EM.run {
18
+ EM.watch_itunes(Watcher)
19
+ }
20
+
21
+ == Contributing to eventmachine-itunes
22
+
23
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
24
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
25
+ * Fork the project.
26
+ * Start a feature/bugfix branch.
27
+ * Commit and push until you are happy with your contribution.
28
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
29
+ * 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.
30
+
31
+ == Copyright
32
+
33
+ Copyright (c) 2012 youpy. See LICENSE.txt for
34
+ further details.
35
+
data/Rakefile ADDED
@@ -0,0 +1,34 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "eventmachine-itunes"
18
+ gem.homepage = "http://github.com/youpy/eventmachine-itunes"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{An EventMachine Extension to Watch iTunes}
21
+ gem.description = %Q{An EventMachine Extension to Watch iTunes play/stop/pause}
22
+ gem.email = "youpy@buycheapviagraonlinenow.com"
23
+ gem.authors = ["youpy"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rspec/core'
29
+ require 'rspec/core/rake_task'
30
+ RSpec::Core::RakeTask.new(:spec) do |spec|
31
+ spec.pattern = FileList['spec/**/*_spec.rb']
32
+ end
33
+
34
+ task :default => :spec
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
@@ -0,0 +1,27 @@
1
+ require 'eventmachine-distributed-notification'
2
+
3
+ module EventMachine
4
+ class ITunesWatch < DistributedNotificationWatch
5
+ def notify(name, user_info)
6
+ states = {
7
+ 'Playing' => :on_play,
8
+ 'Paused' => :on_pause,
9
+ 'Stopped' => :on_stop
10
+ }
11
+
12
+ __send__(states[user_info['Player State']], user_info)
13
+ end
14
+
15
+ def on_play(user_info); end
16
+ def on_pause(user_info); end
17
+ def on_stop(user_info); end
18
+ end
19
+
20
+ def self.watch_itunes(handler = nil, *args, &block)
21
+ args = ['com.apple.iTunes.playerInfo', *args]
22
+ klass = klass_from_handler(EventMachine::ITunesWatch, handler, *args);
23
+ c = klass.new(*args, &block)
24
+ c.start
25
+ c
26
+ end
27
+ end
@@ -0,0 +1,41 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ require 'rubygems'
4
+ require 'spec_helper'
5
+ require 'appscript'
6
+
7
+ class Watcher < EM::ITunesWatch
8
+ attr_accessor :value, :user_info
9
+
10
+ def on_play(user_info)
11
+ @user_info = user_info
12
+ @value = user_info['Player State']
13
+ end
14
+ end
15
+
16
+ describe EventMachine::ITunesWatch do
17
+ before do
18
+ @itunes = Appscript.app('iTunes')
19
+ @itunes.run
20
+ @itunes.stop
21
+ end
22
+
23
+ it 'should watch playing' do
24
+ watcher = Watcher.new('com.apple.iTunes.playerInfo')
25
+
26
+ EM.run {
27
+ watcher = EM.watch_itunes(Watcher)
28
+
29
+ @itunes.playlists["Music"].tracks[1].play
30
+
31
+ EM::add_timer(1) {
32
+ @itunes.stop
33
+ EM.stop
34
+ watcher.stop
35
+ }
36
+ }
37
+
38
+ watcher.value.should_not be_nil
39
+ watcher.user_info['Total Time'].should be_kind_of(Fixnum)
40
+ end
41
+ end
@@ -0,0 +1,12 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ require 'rspec'
4
+ require 'eventmachine-itunes'
5
+
6
+ # Requires supporting files with custom matchers and macros, etc,
7
+ # in ./support/ and its subdirectories.
8
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
9
+
10
+ RSpec.configure do |config|
11
+
12
+ end
metadata ADDED
@@ -0,0 +1,116 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: eventmachine-itunes
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - youpy
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-03-24 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: eventmachine-distributed-notification
16
+ requirement: &70262213132300 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 0.1.4
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70262213132300
25
+ - !ruby/object:Gem::Dependency
26
+ name: rspec
27
+ requirement: &70262213170100 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: 2.8.0
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *70262213170100
36
+ - !ruby/object:Gem::Dependency
37
+ name: bundler
38
+ requirement: &70262213168980 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: 1.1.0
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *70262213168980
47
+ - !ruby/object:Gem::Dependency
48
+ name: jeweler
49
+ requirement: &70262213167420 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 1.8.3
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *70262213167420
58
+ - !ruby/object:Gem::Dependency
59
+ name: rb-appscript
60
+ requirement: &70262213166220 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *70262213166220
69
+ description: An EventMachine Extension to Watch iTunes play/stop/pause
70
+ email: youpy@buycheapviagraonlinenow.com
71
+ executables: []
72
+ extensions: []
73
+ extra_rdoc_files:
74
+ - LICENSE.txt
75
+ - README.rdoc
76
+ files:
77
+ - .document
78
+ - .rspec
79
+ - Gemfile
80
+ - Gemfile.lock
81
+ - LICENSE.txt
82
+ - README.rdoc
83
+ - Rakefile
84
+ - VERSION
85
+ - lib/eventmachine-itunes.rb
86
+ - spec/eventmachine-itunes_spec.rb
87
+ - spec/spec_helper.rb
88
+ homepage: http://github.com/youpy/eventmachine-itunes
89
+ licenses:
90
+ - MIT
91
+ post_install_message:
92
+ rdoc_options: []
93
+ require_paths:
94
+ - lib
95
+ required_ruby_version: !ruby/object:Gem::Requirement
96
+ none: false
97
+ requirements:
98
+ - - ! '>='
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ segments:
102
+ - 0
103
+ hash: 3037894038151161885
104
+ required_rubygems_version: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ requirements: []
111
+ rubyforge_project:
112
+ rubygems_version: 1.8.10
113
+ signing_key:
114
+ specification_version: 3
115
+ summary: An EventMachine Extension to Watch iTunes
116
+ test_files: []