notify-push 0.1.0 → 0.1.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: efa3fc9abcef7e26a0e215820da56a98894b9597
4
- data.tar.gz: 3fca230957a77717878171fc62963495da2061b3
3
+ metadata.gz: e5e52e6142a2573fe33415d6b71362d4988763f4
4
+ data.tar.gz: 95903bb0ece552d3cd9305d55c5db64a1efbfd8e
5
5
  SHA512:
6
- metadata.gz: a267ee4692cc2819e84eb8635df12b5b4b562b588bbf291f678ce3124bf5335d426f6502f270f0d0b3273ca570a8c9965963f0ce027848fe402d0d57d9579481
7
- data.tar.gz: 71d7f548b8d076ebcf775b736740010486d9d3000b28dd5b7ecb7f40664476a31822c1a11dc05514945601882514c852791d182d9783f5d4566ed4347f1b3bc3
6
+ metadata.gz: b932e42771827493e8877ce6b7959ca0fcbbe888e426f8247ee795a42d0bfd611e70dddd4fcab9aa9382af2de4d581fb76da062f5f4230b3eeac96bdf3852ac5
7
+ data.tar.gz: f5b1ea146162bc5bd06d7a6dad2a466caa2ebe504c25f00cadbd929e960e40b1ee11ad66689cd82c57bb1e4ceae81d357501b0bac79ce97ffa25b6dd8449c5a5
data/Gemfile CHANGED
@@ -1,15 +1,15 @@
1
+ # ================================================
2
+ # GEMFILE ========================================
3
+ # ================================================
1
4
  source "http://rubygems.org"
2
- # Add dependencies required to use your gem here.
3
- # Example:
4
- # gem "activesupport", ">= 2.3.5"
5
+
5
6
  gem "pusher"
6
7
  gem "pusher-client"
7
8
  gem "activesupport"
8
9
  gem "recursive-open-struct"
9
10
  gem "pidfile"
11
+ gem "os"
10
12
 
11
- # Add dependencies to develop your gem here.
12
- # Include everything needed to run rake, tests, features, etc.
13
13
  group :development do
14
14
  gem "shoulda", ">= 0"
15
15
  gem "rdoc", "~> 3.12"
data/Gemfile.lock CHANGED
@@ -51,6 +51,7 @@ GEM
51
51
  multi_json (~> 1.3)
52
52
  multi_xml (~> 0.5)
53
53
  rack (~> 1.2)
54
+ os (0.9.6)
54
55
  pidfile (0.3.0)
55
56
  pusher (0.14.5)
56
57
  httpclient (~> 2.5)
@@ -89,6 +90,7 @@ DEPENDENCIES
89
90
  activesupport
90
91
  bundler (~> 1.0)
91
92
  jeweler (~> 2.0.1)
93
+ os
92
94
  pidfile
93
95
  pusher
94
96
  pusher-client
data/README.md CHANGED
@@ -1,3 +1,59 @@
1
1
  # notify-push
2
2
  A general purpose popup notifier sender/receiver for using WebSockets (via Pusher).
3
3
 
4
+ ## Disclaimer
5
+
6
+ ![alt text](http://serve.eriknomitch.com/images/works-on-my-machine.jpg "Works on My Machine")
7
+
8
+ ## Installation
9
+
10
+ ### Create Pusher App
11
+ Create an App on [Pusher](https://pusher.com) named **notify-push**. The free account should be plenty.
12
+
13
+ ### Install notify-push
14
+ For the Receiver machine and the Sender machine(s):
15
+
16
+ ```Shell
17
+ $ gem install notify-push
18
+ ```
19
+
20
+ ### Create & Distribute Configuration File
21
+ Next, create a configuration file with your Pusher App's credentials (found on your Pusher App's page under *App Credentials*) and distribute it to each machine (Receiver and Sender(s)).
22
+
23
+ **Location**: `~/.notify-pushrc`
24
+
25
+ #### Example
26
+
27
+ ```YML
28
+ pusher:
29
+ key: a1a2a3b1b2b3c1c2c3d1
30
+ secret: a1a2a3b1b2b3c1c3c1d1
31
+ app_id: 12345
32
+ ```
33
+
34
+ ## Receiver
35
+
36
+ ### Usage
37
+ Invoke the Receiver with:
38
+
39
+ ```Shell
40
+ $ notify-push --receiver # or -r
41
+ ```
42
+
43
+ TODO: There's a .plist launchd file in there but it's not ready.
44
+
45
+ ## Sender
46
+
47
+ ### Usage
48
+
49
+ ```Shell
50
+ $ notify-push <message> [title] [subtitle]
51
+ ```
52
+
53
+ Alternatively, you can `curl` or use any Pusher tool to send on messages to your `notify-push` app on channel `"notifications"` with data:
54
+
55
+ ```
56
+ message: The message to notify you with in the notifier popup (REQUIRED)
57
+ title: The title of the notifier popup (Optional)
58
+ subtitle: The subtitle of the notifier popup (Optional)
59
+ ```
data/Rakefile CHANGED
@@ -22,6 +22,14 @@ Jeweler::Tasks.new do |gem|
22
22
  gem.email = "erik@nomitch.com"
23
23
  gem.authors = ["Erik Nomitch"]
24
24
  gem.licenses = ["GPL-2"]
25
+ gem.post_install_message = <<-EOS
26
+ ---------------------------------------------------------------
27
+ You may need to create a configuration file at ~/.notify-pushrc
28
+
29
+ See the example at https://github.com/eriknomitch/notify-push
30
+ ---------------------------------------------------------------
31
+ EOS
32
+
25
33
  #s.files = `git ls-files`.split("\n")
26
34
  # dependencies defined in Gemfile
27
35
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.0
1
+ 0.1.1
data/lib/notify-push.rb CHANGED
@@ -2,9 +2,11 @@ require "json"
2
2
  require "shellwords"
3
3
  require "yaml"
4
4
  require "recursive-open-struct"
5
- require "active_support/dependencies" # For mattr_accessor
6
- require 'active_support/core_ext/hash/reverse_merge'
7
- require 'active_support/core_ext/module'
5
+ require "os"
6
+
7
+ require "active_support/core_ext/hash/reverse_merge"
8
+ require "active_support/core_ext/module"
9
+ require "active_support/core_ext/object/blank"
8
10
 
9
11
  # ------------------------------------------------
10
12
  # MODULE->NOTIFY-PUSH ----------------------------
@@ -19,7 +21,7 @@ module NotifyPush
19
21
  # ----------------------------------------------
20
22
  # CONSTANTS ------------------------------------
21
23
  # ----------------------------------------------
22
- CHANNEL_NAME = "notify-push"
24
+ CHANNEL_NAME = "notify-push"
23
25
  CONFIGURATION_FILE_PATH = "#{ENV["HOME"]}/.notify-pushrc"
24
26
 
25
27
  # ----------------------------------------------
@@ -63,18 +65,28 @@ module NotifyPush
63
65
  def self.start()
64
66
  require "pusher"
65
67
 
66
- raise "No message supplied." if ARGV.length == 0
68
+ # The only thing we require is a message.
69
+ # The others will be nil if not supplied.
70
+ raise "No message supplied." if ARGV[0].blank?
67
71
 
68
- Pusher.url = "http://#{configuration.pusher.key}:#{configuration.pusher.secret}@api.pusherapp.com/apps/#{configuration.pusher.app_id}"
72
+ notification = {
73
+ message: ARGV[0],
74
+ title: ARGV[1],
75
+ subtitle: ARGV[2]
76
+ }
69
77
 
70
- notification = {message: ARGV[0]}
78
+ # Strip the nil key/value pairs out so we don't have to
79
+ # worry about them on the Receiver end.
80
+ notification.delete_if {|key, value| value.blank?}
81
+
82
+ # Connect to Pusher and trigger the notification
83
+ Pusher.url = "http://#{configuration.pusher.key}:#{configuration.pusher.secret}@api.pusherapp.com/apps/#{configuration.pusher.app_id}"
71
84
 
72
- notification[:title] = ARGV[1] if ARGV[1]
73
-
74
85
  Pusher[CHANNEL_NAME].trigger("notification", notification)
75
86
 
76
87
  0
77
88
  end
89
+
78
90
  end
79
91
 
80
92
  # ----------------------------------------------
@@ -103,17 +115,20 @@ module NotifyPush
103
115
  end
104
116
 
105
117
  def self.ensure_compatibility
106
- `uname`.chomp("\n") == "Darwin" or "The notify-push receiver only supports OS X."
118
+ OS.mac? or "The notify-push receiver only supports OS X."
107
119
  end
108
120
 
109
121
  # --------------------------------------------
110
122
  # NOTIFY -------------------------------------
111
123
  # --------------------------------------------
112
- def self.notify(title: "notify-push", subtitle: nil, message: " ")
124
+ def self.notify(title: "notify-push", subtitle: nil, message:)
113
125
 
114
- args = ["-title", title, "-message", message]
126
+ args = [
127
+ "-message", message,
128
+ "-title", title
129
+ ]
115
130
 
116
- args.concat ["-subtitle", subtitle] if subtitle
131
+ args.concat ["-subtitle", subtitle] unless subtitle.blank?
117
132
 
118
133
  system "terminal-notifier", *args
119
134
  end
@@ -137,7 +152,7 @@ module NotifyPush
137
152
  socket.subscribe(CHANNEL_NAME)
138
153
 
139
154
  # Bind to the main channel event
140
- socket[CHANNEL_NAME].bind('notification') do |data|
155
+ socket[CHANNEL_NAME].bind("notification") do |data|
141
156
 
142
157
  begin
143
158
  data = JSON.parse(data, symbolize_names: true)
@@ -166,7 +181,6 @@ module NotifyPush
166
181
  0
167
182
  end
168
183
 
169
-
170
184
  end
171
185
  end
172
186
 
@@ -174,6 +188,6 @@ end
174
188
  # TRAP->SIGINT -----------------------------------
175
189
  # ------------------------------------------------
176
190
  trap "SIGINT" do
177
- puts "Exiting"
191
+ puts "Exiting."
178
192
  exit 130
179
193
  end
data/notify-push.gemspec CHANGED
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: notify-push 0.1.0 ruby lib
5
+ # stub: notify-push 0.1.1 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "notify-push"
9
- s.version = "0.1.0"
9
+ s.version = "0.1.1"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
13
13
  s.authors = ["Erik Nomitch"]
14
- s.date = "2015-06-03"
14
+ s.date = "2015-06-04"
15
15
  s.description = "A general purpose popup notifier sender/receiver using WebSockets (via Pusher)"
16
16
  s.email = "erik@nomitch.com"
17
17
  s.executables = ["notify-push"]
@@ -37,6 +37,7 @@ Gem::Specification.new do |s|
37
37
  ]
38
38
  s.homepage = "http://github.com/eriknomitch/notify-push"
39
39
  s.licenses = ["GPL-2"]
40
+ s.post_install_message = "---------------------------------------------------------------\nYou may need to create a configuration file at ~/.notify-pushrc\n\nSee the example at https://github.com/eriknomitch/notify-push\n---------------------------------------------------------------\n"
40
41
  s.rubygems_version = "2.4.6"
41
42
  s.summary = "A general purpose popup notifier sender/receiver using WebSockets (via Pusher)"
42
43
 
@@ -49,6 +50,7 @@ Gem::Specification.new do |s|
49
50
  s.add_runtime_dependency(%q<activesupport>, [">= 0"])
50
51
  s.add_runtime_dependency(%q<recursive-open-struct>, [">= 0"])
51
52
  s.add_runtime_dependency(%q<pidfile>, [">= 0"])
53
+ s.add_runtime_dependency(%q<os>, [">= 0"])
52
54
  s.add_development_dependency(%q<shoulda>, [">= 0"])
53
55
  s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
54
56
  s.add_development_dependency(%q<yard>, ["~> 0.7"])
@@ -61,6 +63,7 @@ Gem::Specification.new do |s|
61
63
  s.add_dependency(%q<activesupport>, [">= 0"])
62
64
  s.add_dependency(%q<recursive-open-struct>, [">= 0"])
63
65
  s.add_dependency(%q<pidfile>, [">= 0"])
66
+ s.add_dependency(%q<os>, [">= 0"])
64
67
  s.add_dependency(%q<shoulda>, [">= 0"])
65
68
  s.add_dependency(%q<rdoc>, ["~> 3.12"])
66
69
  s.add_dependency(%q<yard>, ["~> 0.7"])
@@ -74,6 +77,7 @@ Gem::Specification.new do |s|
74
77
  s.add_dependency(%q<activesupport>, [">= 0"])
75
78
  s.add_dependency(%q<recursive-open-struct>, [">= 0"])
76
79
  s.add_dependency(%q<pidfile>, [">= 0"])
80
+ s.add_dependency(%q<os>, [">= 0"])
77
81
  s.add_dependency(%q<shoulda>, [">= 0"])
78
82
  s.add_dependency(%q<rdoc>, ["~> 3.12"])
79
83
  s.add_dependency(%q<yard>, ["~> 0.7"])
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: notify-push
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Erik Nomitch
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-03 00:00:00.000000000 Z
11
+ date: 2015-06-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pusher
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: os
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: shoulda
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -192,7 +206,12 @@ homepage: http://github.com/eriknomitch/notify-push
192
206
  licenses:
193
207
  - GPL-2
194
208
  metadata: {}
195
- post_install_message:
209
+ post_install_message: |
210
+ ---------------------------------------------------------------
211
+ You may need to create a configuration file at ~/.notify-pushrc
212
+
213
+ See the example at https://github.com/eriknomitch/notify-push
214
+ ---------------------------------------------------------------
196
215
  rdoc_options: []
197
216
  require_paths:
198
217
  - lib