eventmachine-distributed-notification 0.1.5 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,57 @@
1
+ # rcov generated
2
+ coverage
3
+ coverage.data
4
+
5
+ # rdoc generated
6
+ rdoc
7
+
8
+ # yard generated
9
+ doc
10
+ .yardoc
11
+
12
+ # bundler
13
+ .bundle
14
+
15
+ # jeweler generated
16
+ pkg
17
+
18
+ # Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
19
+ #
20
+ # * Create a file at ~/.gitignore
21
+ # * Include files you want ignored
22
+ # * Run: git config --global core.excludesfile ~/.gitignore
23
+ #
24
+ # After doing this, these files will be ignored in all your git projects,
25
+ # saving you from having to 'pollute' every project you touch with them
26
+ #
27
+ # Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
28
+ #
29
+ # For MacOS:
30
+ #
31
+ #.DS_Store
32
+
33
+ # For TextMate
34
+ #*.tmproj
35
+ #tmtags
36
+
37
+ # For emacs:
38
+ #*~
39
+ #\#*
40
+ #.\#*
41
+
42
+ # For vim:
43
+ #*.swp
44
+
45
+ # For redcar:
46
+ #.redcar
47
+
48
+ # For rubinius:
49
+ #*.rbc
50
+
51
+ # ext
52
+ *.bundle
53
+ *.log
54
+ *.o
55
+ Makefile
56
+
57
+ Gemfile.lock
data/Gemfile CHANGED
@@ -1,11 +1,3 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
- gem 'eventmachine'
4
-
5
- group :development do
6
- gem 'rspec', '~> 2.8.0'
7
- gem 'rdoc', '~> 3.12'
8
- gem 'bundler', '~> 1.1.0'
9
- gem 'jeweler', '~> 1.8.3'
10
- gem 'rb-appscript', :require => 'appscript'
11
- end
3
+ gemspec
data/Rakefile CHANGED
@@ -1,28 +1,7 @@
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
1
+ #!/usr/bin/env rake
12
2
  require 'rake'
13
-
14
- require 'jeweler'
15
- tasks = 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-distributed-notification"
18
- gem.homepage = "http://github.com/youpy/eventmachine-distributed-notification"
19
- gem.license = "MIT"
20
- gem.summary = %Q{An EventMachine extension to watch OSX's Distributed Notification}
21
- gem.description = %Q{An EventMachine extension to watch OSX's Distributed Notification, posted by iTunes etc.}
22
- gem.email = "youpy@buycheapviagraonlinenow.com"
23
- gem.authors = ["youpy"]
24
- gem.extensions = FileList["ext/**/extconf.rb"]
25
- end
3
+ require 'rake/clean'
4
+ require "bundler/gem_tasks"
26
5
 
27
6
  # rule to build the extension: this says
28
7
  # that the extension should be rebuilt
@@ -48,8 +27,6 @@ ext_names.each do |ext_name|
48
27
  task :spec => "lib/#{ext_name}.bundle"
49
28
  end
50
29
 
51
- Jeweler::RubygemsDotOrgTasks.new
52
-
53
30
  require 'rspec/core'
54
31
  require 'rspec/core/rake_task'
55
32
  RSpec::Core::RakeTask.new(:spec) do |spec|
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/eventmachine-distributed-notification/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["youpy"]
6
+ gem.email = ["youpy@buycheapviagraonlinenow.com"]
7
+ gem.description = "An EventMachine extension to watch OSX's Distributed Notification, posted by iTunes etc."
8
+ gem.summary = "An EventMachine extension to watch OSX's Distributed Notification"
9
+ gem.homepage = "http://github.com/youpy/eventmachine-distributed-notification"
10
+
11
+ gem.extensions = ["ext/observer_native/extconf.rb", "ext/poster_native/extconf.rb"]
12
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
13
+ gem.files = `git ls-files`.split("\n")
14
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
15
+ gem.name = "eventmachine-distributed-notification"
16
+ gem.require_paths = ["lib"]
17
+ gem.version = EventMachine::DistributedNotification::VERSION
18
+ gem.licenses = ["MIT"]
19
+
20
+ gem.add_dependency('eventmachine')
21
+ gem.add_development_dependency('rspec', ['~> 2.8.0'])
22
+ gem.add_development_dependency('rake')
23
+ gem.add_development_dependency('itunes-client')
24
+ end
@@ -0,0 +1,5 @@
1
+ module EventMachine
2
+ module DistributedNotification
3
+ VERSION = "0.2.0"
4
+ end
5
+ end
@@ -2,6 +2,8 @@ require 'eventmachine'
2
2
  require 'observer_native'
3
3
  require 'poster_native'
4
4
 
5
+ require 'eventmachine-distributed-notification/version'
6
+
5
7
  module EventMachine
6
8
  module DistributedNotification
7
9
  class Poster
@@ -16,22 +18,25 @@ module EventMachine
16
18
  end
17
19
 
18
20
  class DistributedNotificationWatch
19
- def initialize(name)
20
- @observer = DistributedNotification::ObserverNative.new(name, self)
21
+ def initialize(names)
22
+ names = names.kind_of?(Array) ? names : [names]
23
+ @observers = names.map do |name|
24
+ DistributedNotification::ObserverNative.new(name, self)
25
+ end
21
26
  end
22
27
 
23
28
  def notify(name, user_info)
24
29
  end
25
30
 
26
31
  def start
27
- @observer.observe
32
+ @observers.map(&:observe)
28
33
  @timer = EventMachine::add_periodic_timer(1) do
29
- @observer.run
34
+ @observers.map(&:run)
30
35
  end
31
36
  end
32
37
 
33
38
  def stop
34
- @observer.unobserve
39
+ @observers.map(&:unobserve)
35
40
  @timer.cancel if @timer
36
41
  end
37
42
  end
@@ -3,7 +3,7 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
3
3
  require 'rubygems'
4
4
  require 'spec_helper'
5
5
  require 'eventmachine'
6
- require 'appscript'
6
+ require 'itunes-client'
7
7
 
8
8
  class Watcher < EM::DistributedNotificationWatch
9
9
  attr_accessor :value, :user_info
@@ -33,28 +33,41 @@ describe EventMachine::DistributedNotification::Poster do
33
33
  end
34
34
 
35
35
  describe EventMachine::DistributedNotificationWatch do
36
- itunes = Appscript.app('iTunes')
37
- itunes.run
38
- itunes.stop
36
+ Itunes::Player.play
37
+ Itunes::Player.stop
39
38
 
40
39
  context 'instantiate' do
41
- it 'should watch distributed notifications' do
42
- watcher = Watcher.new('com.apple.iTunes.playerInfo')
40
+ shared_examples_for 'watch distributed notifications' do
41
+ it 'should watch distributed notifications' do
42
+ watcher = Watcher.new(name)
43
43
 
44
- EM.run {
45
- watcher.start
44
+ EM.run {
45
+ watcher.start
46
46
 
47
- itunes.playlists["Music"].tracks[1].play
47
+ Itunes::Player.play
48
48
 
49
- EM::add_timer(1) {
50
- itunes.stop
51
- EM.stop
52
- watcher.stop
49
+ EM::add_timer(1) {
50
+ Itunes::Player.stop
51
+ EM.stop
52
+ watcher.stop
53
+ }
53
54
  }
54
- }
55
55
 
56
- watcher.value.should_not be_nil
57
- watcher.user_info['Total Time'].should be_kind_of(Fixnum)
56
+ watcher.value.should_not be_nil
57
+ watcher.user_info['Total Time'].should be_kind_of(Fixnum)
58
+ end
59
+ end
60
+
61
+ context 'name is passed as a string' do
62
+ let(:name) { 'com.apple.iTunes.playerInfo' }
63
+
64
+ it_should_behave_like 'watch distributed notifications'
65
+ end
66
+
67
+ context 'name is passed as an array of strings' do
68
+ let(:name) { ['xxx', 'com.apple.iTunes.playerInfo'] }
69
+
70
+ it_should_behave_like 'watch distributed notifications'
58
71
  end
59
72
  end
60
73
 
@@ -66,10 +79,10 @@ describe EventMachine::DistributedNotificationWatch do
66
79
  EM.run {
67
80
  watcher = EM.watch_distributed_notification(nil, Watcher)
68
81
 
69
- itunes.playlists["Music"].tracks[1].play
82
+ Itunes::Player.play
70
83
 
71
84
  EM::add_timer(1) {
72
- itunes.stop
85
+ Itunes::Player.stop
73
86
  EM.stop
74
87
  watcher.stop
75
88
  }
@@ -90,10 +103,10 @@ describe EventMachine::DistributedNotificationWatch do
90
103
  end
91
104
  end
92
105
 
93
- itunes.playlists["Music"].tracks[1].play
106
+ Itunes::Player.play
94
107
 
95
108
  EM::add_timer(1) {
96
- itunes.stop
109
+ Itunes::Player.stop
97
110
  EM.stop
98
111
  watcher.stop
99
112
  }
metadata CHANGED
@@ -1,133 +1,97 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: eventmachine-distributed-notification
3
- version: !ruby/object:Gem::Version
4
- hash: 17
5
- prerelease: false
6
- segments:
7
- - 0
8
- - 1
9
- - 5
10
- version: 0.1.5
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ prerelease:
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - youpy
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2012-03-29 00:00:00 +09:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
22
- version_requirements: &id001 !ruby/object:Gem::Requirement
12
+ date: 2013-10-15 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: eventmachine
16
+ requirement: !ruby/object:Gem::Requirement
23
17
  none: false
24
- requirements:
25
- - - ">="
26
- - !ruby/object:Gem::Version
27
- hash: 3
28
- segments:
29
- - 0
30
- version: "0"
31
- requirement: *id001
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
32
22
  type: :runtime
33
- name: eventmachine
34
23
  prerelease: false
35
- - !ruby/object:Gem::Dependency
36
- version_requirements: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: !ruby/object:Gem::Requirement
37
25
  none: false
38
- requirements:
39
- - - ~>
40
- - !ruby/object:Gem::Version
41
- hash: 47
42
- segments:
43
- - 2
44
- - 8
45
- - 0
46
- version: 2.8.0
47
- requirement: *id002
48
- type: :development
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
49
31
  name: rspec
50
- prerelease: false
51
- - !ruby/object:Gem::Dependency
52
- version_requirements: &id003 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
53
33
  none: false
54
- requirements:
34
+ requirements:
55
35
  - - ~>
56
- - !ruby/object:Gem::Version
57
- hash: 31
58
- segments:
59
- - 3
60
- - 12
61
- version: "3.12"
62
- requirement: *id003
36
+ - !ruby/object:Gem::Version
37
+ version: 2.8.0
63
38
  type: :development
64
- name: rdoc
65
39
  prerelease: false
66
- - !ruby/object:Gem::Dependency
67
- version_requirements: &id004 !ruby/object:Gem::Requirement
40
+ version_requirements: !ruby/object:Gem::Requirement
68
41
  none: false
69
- requirements:
42
+ requirements:
70
43
  - - ~>
71
- - !ruby/object:Gem::Version
72
- hash: 19
73
- segments:
74
- - 1
75
- - 1
76
- - 0
77
- version: 1.1.0
78
- requirement: *id004
79
- type: :development
80
- name: bundler
81
- prerelease: false
82
- - !ruby/object:Gem::Dependency
83
- version_requirements: &id005 !ruby/object:Gem::Requirement
44
+ - !ruby/object:Gem::Version
45
+ version: 2.8.0
46
+ - !ruby/object:Gem::Dependency
47
+ name: rake
48
+ requirement: !ruby/object:Gem::Requirement
84
49
  none: false
85
- requirements:
86
- - - ~>
87
- - !ruby/object:Gem::Version
88
- hash: 49
89
- segments:
90
- - 1
91
- - 8
92
- - 3
93
- version: 1.8.3
94
- requirement: *id005
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
95
54
  type: :development
96
- name: jeweler
97
55
  prerelease: false
98
- - !ruby/object:Gem::Dependency
99
- version_requirements: &id006 !ruby/object:Gem::Requirement
56
+ version_requirements: !ruby/object:Gem::Requirement
100
57
  none: false
101
- requirements:
102
- - - ">="
103
- - !ruby/object:Gem::Version
104
- hash: 3
105
- segments:
106
- - 0
107
- version: "0"
108
- requirement: *id006
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: itunes-client
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
109
70
  type: :development
110
- name: rb-appscript
111
71
  prerelease: false
112
- description: An EventMachine extension to watch OSX's Distributed Notification, posted by iTunes etc.
113
- email: youpy@buycheapviagraonlinenow.com
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ description: An EventMachine extension to watch OSX's Distributed Notification, posted
79
+ by iTunes etc.
80
+ email:
81
+ - youpy@buycheapviagraonlinenow.com
114
82
  executables: []
115
-
116
- extensions:
83
+ extensions:
117
84
  - ext/observer_native/extconf.rb
118
85
  - ext/poster_native/extconf.rb
119
- extra_rdoc_files:
120
- - LICENSE.txt
121
- - README.rdoc
122
- files:
123
- - .document
86
+ extra_rdoc_files: []
87
+ files:
88
+ - .gitignore
124
89
  - .rspec
125
90
  - Gemfile
126
- - Gemfile.lock
127
91
  - LICENSE.txt
128
92
  - README.rdoc
129
93
  - Rakefile
130
- - VERSION
94
+ - eventmachine-distributed-notification.gemspec
131
95
  - examples/client.rb
132
96
  - examples/server.rb
133
97
  - ext/lib/mkmf.rb
@@ -139,41 +103,40 @@ files:
139
103
  - ext/poster_native/poster_native.h
140
104
  - ext/poster_native/poster_native.m
141
105
  - lib/eventmachine-distributed-notification.rb
106
+ - lib/eventmachine-distributed-notification/version.rb
142
107
  - spec/eventmachine-distributed-notification_spec.rb
143
108
  - spec/spec_helper.rb
144
- has_rdoc: true
145
109
  homepage: http://github.com/youpy/eventmachine-distributed-notification
146
- licenses:
110
+ licenses:
147
111
  - MIT
148
112
  post_install_message:
149
113
  rdoc_options: []
150
-
151
- require_paths:
114
+ require_paths:
152
115
  - lib
153
- required_ruby_version: !ruby/object:Gem::Requirement
116
+ required_ruby_version: !ruby/object:Gem::Requirement
154
117
  none: false
155
- requirements:
156
- - - ">="
157
- - !ruby/object:Gem::Version
158
- hash: 3
159
- segments:
118
+ requirements:
119
+ - - ! '>='
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
122
+ segments:
160
123
  - 0
161
- version: "0"
162
- required_rubygems_version: !ruby/object:Gem::Requirement
124
+ hash: -3242985691495466250
125
+ required_rubygems_version: !ruby/object:Gem::Requirement
163
126
  none: false
164
- requirements:
165
- - - ">="
166
- - !ruby/object:Gem::Version
167
- hash: 3
168
- segments:
127
+ requirements:
128
+ - - ! '>='
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ segments:
169
132
  - 0
170
- version: "0"
133
+ hash: -3242985691495466250
171
134
  requirements: []
172
-
173
135
  rubyforge_project:
174
- rubygems_version: 1.3.7
136
+ rubygems_version: 1.8.24
175
137
  signing_key:
176
138
  specification_version: 3
177
139
  summary: An EventMachine extension to watch OSX's Distributed Notification
178
- test_files: []
179
-
140
+ test_files:
141
+ - spec/eventmachine-distributed-notification_spec.rb
142
+ - spec/spec_helper.rb
data/.document DELETED
@@ -1,5 +0,0 @@
1
- lib/**/*.rb
2
- bin/*
3
- -
4
- features/**/*.feature
5
- LICENSE.txt
data/Gemfile.lock DELETED
@@ -1,35 +0,0 @@
1
- GEM
2
- remote: http://rubygems.org/
3
- specs:
4
- diff-lcs (1.1.3)
5
- eventmachine (0.12.10)
6
- git (1.2.5)
7
- jeweler (1.8.3)
8
- bundler (~> 1.0)
9
- git (>= 1.2.5)
10
- rake
11
- rdoc
12
- json (1.6.5)
13
- rake (0.9.2.2)
14
- rb-appscript (0.6.1)
15
- rdoc (3.12)
16
- json (~> 1.4)
17
- rspec (2.8.0)
18
- rspec-core (~> 2.8.0)
19
- rspec-expectations (~> 2.8.0)
20
- rspec-mocks (~> 2.8.0)
21
- rspec-core (2.8.0)
22
- rspec-expectations (2.8.0)
23
- diff-lcs (~> 1.1.2)
24
- rspec-mocks (2.8.0)
25
-
26
- PLATFORMS
27
- ruby
28
-
29
- DEPENDENCIES
30
- bundler (~> 1.1.0)
31
- eventmachine
32
- jeweler (~> 1.8.3)
33
- rb-appscript
34
- rdoc (~> 3.12)
35
- rspec (~> 2.8.0)
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.1.5