Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: youpy/eventmachine-itunes
base: e85dde79d0
...
head fork: youpy/eventmachine-itunes
compare: 6fd8b25640
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 5 files changed
  • 0 commit comments
  • 1 contributor
View
9 Gemfile
@@ -1,10 +1,3 @@
source 'http://rubygems.org'
-gem 'eventmachine-distributed-notification', '>= 0.1.4'
-
-group :development do
- gem 'rspec', '~> 2.8.0'
- gem 'bundler', '~> 1.1.0'
- gem 'jeweler', '~> 1.8.3'
- gem 'rb-appscript', :require => 'appscript'
-end
+gemspec
View
8 Gemfile.lock
@@ -1,3 +1,9 @@
+PATH
+ remote: .
+ specs:
+ eventmachine-itunes (0.0.1)
+ eventmachine-distributed-notification (>= 0.1.4)
+
GEM
remote: http://rubygems.org/
specs:
@@ -30,7 +36,7 @@ PLATFORMS
DEPENDENCIES
bundler (~> 1.1.0)
- eventmachine-distributed-notification (>= 0.1.4)
+ eventmachine-itunes!
jeweler (~> 1.8.3)
rb-appscript
rspec (~> 2.8.0)
View
62 eventmachine-itunes.gemspec
@@ -0,0 +1,62 @@
+# Generated by jeweler
+# DO NOT EDIT THIS FILE DIRECTLY
+# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
+# -*- encoding: utf-8 -*-
+
+Gem::Specification.new do |s|
+ s.name = "eventmachine-itunes"
+ s.version = "0.0.1"
+
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
+ s.authors = ["youpy"]
+ s.date = "2012-04-10"
+ s.description = "An EventMachine Extension to Watch iTunes play/stop/pause"
+ s.email = "youpy@buycheapviagraonlinenow.com"
+ s.extra_rdoc_files = [
+ "LICENSE.txt",
+ "README.rdoc"
+ ]
+ s.files = [
+ ".document",
+ ".rspec",
+ "Gemfile",
+ "Gemfile.lock",
+ "LICENSE.txt",
+ "README.rdoc",
+ "Rakefile",
+ "VERSION",
+ "lib/eventmachine-itunes.rb",
+ "spec/eventmachine-itunes_spec.rb",
+ "spec/spec_helper.rb"
+ ]
+ s.homepage = "http://github.com/youpy/eventmachine-itunes"
+ s.licenses = ["MIT"]
+ s.require_paths = ["lib"]
+ s.rubygems_version = "1.8.10"
+ s.summary = "An EventMachine Extension to Watch iTunes"
+
+ if s.respond_to? :specification_version then
+ s.specification_version = 3
+
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
+ s.add_runtime_dependency(%q<eventmachine-distributed-notification>, [">= 0.1.4"])
+ s.add_development_dependency(%q<rspec>, ["~> 2.8.0"])
+ s.add_development_dependency(%q<bundler>, ["~> 1.1.0"])
+ s.add_development_dependency(%q<jeweler>, ["~> 1.8.3"])
+ s.add_development_dependency(%q<rb-appscript>, [">= 0"])
+ else
+ s.add_dependency(%q<eventmachine-distributed-notification>, [">= 0.1.4"])
+ s.add_dependency(%q<rspec>, ["~> 2.8.0"])
+ s.add_dependency(%q<bundler>, ["~> 1.1.0"])
+ s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
+ s.add_dependency(%q<rb-appscript>, [">= 0"])
+ end
+ else
+ s.add_dependency(%q<eventmachine-distributed-notification>, [">= 0.1.4"])
+ s.add_dependency(%q<rspec>, ["~> 2.8.0"])
+ s.add_dependency(%q<bundler>, ["~> 1.1.0"])
+ s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
+ s.add_dependency(%q<rb-appscript>, [">= 0"])
+ end
+end
+
View
1  lib/eventmachine-itunes.rb
@@ -21,6 +21,7 @@ def self.watch_itunes(handler = nil, *args, &block)
args = ['com.apple.iTunes.playerInfo', *args]
klass = klass_from_handler(EventMachine::ITunesWatch, handler, *args);
c = klass.new(*args, &block)
+ block_given? and yield c
c.start
c
end
View
26 spec/eventmachine-itunes_spec.rb
@@ -20,7 +20,7 @@ def on_play(user_info)
@itunes.stop
end
- it 'should watch playing' do
+ it 'should watch playing with class' do
watcher = nil
EM.run {
@@ -38,4 +38,28 @@ def on_play(user_info)
watcher.value.should_not be_nil
watcher.user_info['Total Time'].should be_kind_of(Fixnum)
end
+
+ it 'should watch playing with block' do
+ result = nil
+ watcher = nil
+
+ EM.run {
+ watcher = EM.watch_itunes {|c|
+ (class << c; self; end).send(:define_method, :on_play) {|info|
+ result = info
+ }
+ }
+
+ @itunes.playlists["Music"].tracks[1].play
+
+ EM::add_timer(1) {
+ @itunes.stop
+ EM.stop
+ watcher.stop
+ }
+ }
+
+ result.should_not be_nil
+ result['Total Time'].should be_kind_of(Fixnum)
+ end
end

No commit comments for this range

Something went wrong with that request. Please try again.