uniform_notifier 1.0.1 → 1.0.2

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/.gitignore CHANGED
@@ -2,3 +2,4 @@ pkg/*
2
2
  *.gem
3
3
  .bundle
4
4
  .rvmrc
5
+ bin/
data/Gemfile.lock CHANGED
@@ -1,28 +1,30 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- uniform_notifier (1.0.1)
4
+ uniform_notifier (1.0.2)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
8
8
  specs:
9
- diff-lcs (1.1.2)
10
- rspec (2.3.0)
11
- rspec-core (~> 2.3.0)
12
- rspec-expectations (~> 2.3.0)
13
- rspec-mocks (~> 2.3.0)
14
- rspec-core (2.3.0)
15
- rspec-expectations (2.3.0)
9
+ diff-lcs (1.1.3)
10
+ rspec (2.8.0)
11
+ rspec-core (~> 2.8.0)
12
+ rspec-expectations (~> 2.8.0)
13
+ rspec-mocks (~> 2.8.0)
14
+ rspec-core (2.8.0)
15
+ rspec-expectations (2.8.0)
16
16
  diff-lcs (~> 1.1.2)
17
- rspec-mocks (2.3.0)
17
+ rspec-mocks (2.8.0)
18
18
  ruby-growl (3.0)
19
+ ruby_gntp (0.3.4)
19
20
  xmpp4r (0.5)
20
21
 
21
22
  PLATFORMS
22
23
  ruby
23
24
 
24
25
  DEPENDENCIES
25
- rspec (= 2.3.0)
26
+ rspec
26
27
  ruby-growl (= 3.0)
28
+ ruby_gntp (= 0.3.4)
27
29
  uniform_notifier!
28
30
  xmpp4r (= 0.5)
data/README.md CHANGED
@@ -10,16 +10,23 @@ Install
10
10
 
11
11
  gem install uniform_notifier
12
12
 
13
- if you want to notify by growl or xmpp, you should install them first
13
+ if you want to notify by growl < v1.3, you should install ruby-growl first
14
14
 
15
15
  gem install ruby-growl
16
+
17
+ if you want to notify by growl v1.3+, you should install ruby_gntp first
18
+
19
+ gem install ruby_gntp
20
+
21
+ if you want to notify by xmpp, you should install xmpp4r first
22
+
16
23
  gem install xmpp4r
17
24
 
18
25
  ### add it into Gemfile (Bundler)
19
26
 
20
27
  gem "uniform_notifier"
21
28
 
22
- you should add ruby-growl and xmpp4r gem if you want.
29
+ you should add ruby-growl, ruby_gntp, or xmpp4r gem if you want.
23
30
 
24
31
  Usage
25
32
  -----
@@ -76,7 +83,8 @@ Growl Support
76
83
 
77
84
  To get Growl support up-and-running, follow the steps below:
78
85
 
79
- * Install the ruby-growl gem: <code>gem install ruby-growl</code>
86
+ * For Growl < v1.3, install the ruby-growl gem: <code>gem install ruby-growl</code>
87
+ * For Growl v1.3+, install the ruby_gntp gem: <code>gem install ruby_gntp</code>
80
88
  * Open the Growl preference pane in Systems Preferences
81
89
  * Click the "Network" tab
82
90
  * Make sure both "Listen for incoming notifications" and "Allow remote application registration" are checked. *Note*: If you set a password, you will need to set <code>UniformNotifier.growl_password = { :password => 'growl password' }</code> in the config file.
@@ -12,28 +12,53 @@ module UniformNotifier
12
12
  end
13
13
 
14
14
  def self.setup_connection( growl )
15
+ setup_connection_growl(growl)
16
+ rescue LoadError
17
+ begin
18
+ setup_connection_gntp(growl)
19
+ rescue LoadError
20
+ @growl = nil
21
+ raise NotificationError.new( 'You must install the ruby-growl or the ruby_gntp gem to use Growl notification: `gem install ruby-growl` or `gem install ruby_gntp`' )
22
+ end
23
+ end
24
+
25
+ def self.setup_connection_growl( growl )
15
26
  return unless growl
16
27
  require 'ruby-growl'
17
28
  @password = growl.instance_of?(Hash) ? growl[:password] : nil
18
- @growl = connect
29
+ @growl = ::Growl.new('localhost',
30
+ 'uniform_notifier',
31
+ [ 'uniform_notifier' ],
32
+ nil,
33
+ @password)
19
34
 
20
35
  notify 'Uniform Notifier Growl has been turned on'
21
- rescue LoadError
22
- @growl = nil
23
- raise NotificationError.new( 'You must install the ruby-growl gem to use Growl notification: `gem install ruby-growl`' )
24
36
  end
25
37
 
26
- private
27
- def self.connect
28
- ::Growl.new 'localhost',
29
- 'uniform_notifier',
30
- [ 'uniform_notifier' ],
31
- nil,
32
- @password
33
- end
38
+ def self.setup_connection_gntp( growl )
39
+ return unless growl
40
+ require 'ruby_gntp'
41
+ @password = growl.instance_of?(Hash) ? growl[:password] : nil
42
+ @growl = GNTP.new('uniform_notifier', 'localhost', @password, 23053)
43
+ @growl.register({:notifications => [{
44
+ :name => 'uniform_notifier',
45
+ :enabled => true,
46
+ }]})
47
+
48
+ notify 'Uniform Notifier Growl has been turned on (using GNTP)'
49
+ end
34
50
 
51
+ private
35
52
  def self.notify( message )
36
- @growl.notify( 'uniform_notifier', 'Uniform Notifier', message )
53
+ if defined?(::Growl) && @growl.is_a?(::Growl)
54
+ @growl.notify( 'uniform_notifier', 'Uniform Notifier', message )
55
+ elsif defined?(::GNTP) && @growl.is_a?(::GNTP)
56
+ @growl.notify({
57
+ :name => 'uniform_notifier',
58
+ :title => 'Uniform Notifier',
59
+ :text => message
60
+ })
61
+ end
37
62
  end
63
+ end
38
64
  end
39
- end
@@ -1,3 +1,3 @@
1
1
  module UniformNotifier
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
@@ -18,12 +18,14 @@ module UniformNotifier
18
18
 
19
19
  require 'xmpp4r'
20
20
 
21
+ @xmpp = xmpp_information
21
22
  @receiver = xmpp_information[:receiver]
22
23
  @password = xmpp_information[:password]
23
24
  @account = xmpp_information[:account]
24
25
  @show_online_status = xmpp_information[:show_online_status]
26
+ @stay_connected = xmpp_information[:stay_connected].nil? ? true : xmpp_information[:stay_connected]
25
27
 
26
- connect
28
+ connect if @stay_connected
27
29
  rescue LoadError
28
30
  @xmpp = nil
29
31
  raise NotificationError.new( 'You must install the xmpp4r gem to use XMPP notification: `gem install xmpp4r`' )
@@ -39,6 +41,7 @@ module UniformNotifier
39
41
  end
40
42
 
41
43
  def self.notify( message )
44
+ connect unless @stay_connected
42
45
  message = Jabber::Message.new( @receiver, message ).
43
46
  set_type( :normal ).
44
47
  set_subject( 'Uniform Notifier' )
@@ -7,7 +7,7 @@ describe UniformNotifier::Growl do
7
7
  end
8
8
 
9
9
  it "should notify growl without password" do
10
- growl = double('growl')
10
+ growl = double('growl', :is_a? => true)
11
11
  Growl.should_receive(:new).with('localhost', 'uniform_notifier', ['uniform_notifier'], nil, nil).and_return(growl)
12
12
  growl.should_receive(:notify).with('uniform_notifier', 'Uniform Notifier', 'Uniform Notifier Growl has been turned on').ordered
13
13
  growl.should_receive(:notify).with('uniform_notifier', 'Uniform Notifier', 'notify growl without password').ordered
@@ -17,7 +17,7 @@ describe UniformNotifier::Growl do
17
17
  end
18
18
 
19
19
  it "should notify growl with password" do
20
- growl = double('growl')
20
+ growl = double('growl', :is_a? => true)
21
21
  Growl.should_receive(:new).with('localhost', 'uniform_notifier', ['uniform_notifier'], nil, '123456').and_return(growl)
22
22
  growl.should_receive(:notify).with('uniform_notifier', 'Uniform Notifier', 'Uniform Notifier Growl has been turned on').ordered
23
23
  growl.should_receive(:notify).with('uniform_notifier', 'Uniform Notifier', 'notify growl with password').ordered
@@ -15,8 +15,9 @@ Gem::Specification.new do |s|
15
15
  s.rubyforge_project = "uniform_notifier"
16
16
 
17
17
  s.add_development_dependency "ruby-growl", "3.0"
18
+ s.add_development_dependency "ruby_gntp", "0.3.4"
18
19
  s.add_development_dependency "xmpp4r", "0.5"
19
- s.add_development_dependency "rspec", "2.3.0"
20
+ s.add_development_dependency "rspec"
20
21
 
21
22
  s.files = `git ls-files`.split("\n")
22
23
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
metadata CHANGED
@@ -1,79 +1,68 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: uniform_notifier
3
- version: !ruby/object:Gem::Version
4
- hash: 21
5
- prerelease: false
6
- segments:
7
- - 1
8
- - 0
9
- - 1
10
- version: 1.0.1
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.2
5
+ prerelease:
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Richard Huang
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2010-12-15 00:00:00 +08:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
12
+ date: 2012-03-06 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
22
15
  name: ruby-growl
16
+ requirement: &70109712498760 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - =
20
+ - !ruby/object:Gem::Version
21
+ version: '3.0'
22
+ type: :development
23
23
  prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
24
+ version_requirements: *70109712498760
25
+ - !ruby/object:Gem::Dependency
26
+ name: ruby_gntp
27
+ requirement: &70109712496600 !ruby/object:Gem::Requirement
25
28
  none: false
26
- requirements:
27
- - - "="
28
- - !ruby/object:Gem::Version
29
- hash: 7
30
- segments:
31
- - 3
32
- - 0
33
- version: "3.0"
29
+ requirements:
30
+ - - =
31
+ - !ruby/object:Gem::Version
32
+ version: 0.3.4
34
33
  type: :development
35
- version_requirements: *id001
36
- - !ruby/object:Gem::Dependency
37
- name: xmpp4r
38
34
  prerelease: false
39
- requirement: &id002 !ruby/object:Gem::Requirement
35
+ version_requirements: *70109712496600
36
+ - !ruby/object:Gem::Dependency
37
+ name: xmpp4r
38
+ requirement: &70109712495040 !ruby/object:Gem::Requirement
40
39
  none: false
41
- requirements:
42
- - - "="
43
- - !ruby/object:Gem::Version
44
- hash: 1
45
- segments:
46
- - 0
47
- - 5
48
- version: "0.5"
40
+ requirements:
41
+ - - =
42
+ - !ruby/object:Gem::Version
43
+ version: '0.5'
49
44
  type: :development
50
- version_requirements: *id002
51
- - !ruby/object:Gem::Dependency
52
- name: rspec
53
45
  prerelease: false
54
- requirement: &id003 !ruby/object:Gem::Requirement
46
+ version_requirements: *70109712495040
47
+ - !ruby/object:Gem::Dependency
48
+ name: rspec
49
+ requirement: &70109712493660 !ruby/object:Gem::Requirement
55
50
  none: false
56
- requirements:
57
- - - "="
58
- - !ruby/object:Gem::Version
59
- hash: 3
60
- segments:
61
- - 2
62
- - 3
63
- - 0
64
- version: 2.3.0
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
65
55
  type: :development
66
- version_requirements: *id003
67
- description: uniform notifier for rails logger, customized logger, javascript alert, javascript console, growl and xmpp
68
- email:
56
+ prerelease: false
57
+ version_requirements: *70109712493660
58
+ description: uniform notifier for rails logger, customized logger, javascript alert,
59
+ javascript console, growl and xmpp
60
+ email:
69
61
  - flyerhzm@gmail.com
70
62
  executables: []
71
-
72
63
  extensions: []
73
-
74
64
  extra_rdoc_files: []
75
-
76
- files:
65
+ files:
77
66
  - .gitignore
78
67
  - Gemfile
79
68
  - Gemfile.lock
@@ -97,41 +86,32 @@ files:
97
86
  - spec/uniform_notifier/rails_logger_spec.rb
98
87
  - spec/uniform_notifier/xmpp_spec.rb
99
88
  - uniform_notifier.gemspec
100
- has_rdoc: true
101
89
  homepage: http://rubygems.org/gems/uniform_notifier
102
90
  licenses: []
103
-
104
91
  post_install_message:
105
92
  rdoc_options: []
106
-
107
- require_paths:
93
+ require_paths:
108
94
  - lib
109
- required_ruby_version: !ruby/object:Gem::Requirement
95
+ required_ruby_version: !ruby/object:Gem::Requirement
110
96
  none: false
111
- requirements:
112
- - - ">="
113
- - !ruby/object:Gem::Version
114
- hash: 3
115
- segments:
116
- - 0
117
- version: "0"
118
- required_rubygems_version: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ! '>='
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ required_rubygems_version: !ruby/object:Gem::Requirement
119
102
  none: false
120
- requirements:
121
- - - ">="
122
- - !ruby/object:Gem::Version
123
- hash: 3
124
- segments:
125
- - 0
126
- version: "0"
103
+ requirements:
104
+ - - ! '>='
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
127
107
  requirements: []
128
-
129
108
  rubyforge_project: uniform_notifier
130
- rubygems_version: 1.3.7
109
+ rubygems_version: 1.8.15
131
110
  signing_key:
132
111
  specification_version: 3
133
- summary: uniform notifier for rails logger, customized logger, javascript alert, javascript console, growl and xmpp
134
- test_files:
112
+ summary: uniform notifier for rails logger, customized logger, javascript alert, javascript
113
+ console, growl and xmpp
114
+ test_files:
135
115
  - spec/spec_helper.rb
136
116
  - spec/uniform_notifier/customized_logger_spec.rb
137
117
  - spec/uniform_notifier/growl_spec.rb