spns 0.2.12 → 0.2.13
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/spns.rb +19 -25
- metadata +50 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.13
|
data/lib/spns.rb
CHANGED
@@ -15,20 +15,20 @@ require 'yaml'
|
|
15
15
|
############################################################
|
16
16
|
## Initilization Setup
|
17
17
|
############################################################
|
18
|
-
|
19
|
-
|
20
|
-
unless $LOAD_PATH.include?(
|
21
|
-
$LOAD_PATH <<
|
18
|
+
LIBDIR = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
|
19
|
+
ROOTDIR = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
20
|
+
unless $LOAD_PATH.include?(LIBDIR)
|
21
|
+
$LOAD_PATH << LIBDIR
|
22
22
|
end
|
23
23
|
|
24
24
|
unless File.exist?("#{Dir.pwd}/spns.yml") then
|
25
25
|
puts 'create config file: spns.yml'
|
26
|
-
system "cp #{
|
26
|
+
system "cp #{ROOTDIR}/spns.yml #{Dir.pwd}/spns.yml"
|
27
27
|
end
|
28
28
|
|
29
29
|
unless File.exist?("#{Dir.pwd}/cron") then
|
30
30
|
puts "create a demo 'cron' script"
|
31
|
-
system "cp #{
|
31
|
+
system "cp #{ROOTDIR}/cron #{Dir.pwd}/cron"
|
32
32
|
end
|
33
33
|
|
34
34
|
############################################################
|
@@ -40,8 +40,7 @@ $timer = "#{config['timer']}".to_i
|
|
40
40
|
$cron = config['cron'] || 'cron'
|
41
41
|
$port = config['port'] || 4567
|
42
42
|
$mode = config['mode'] || env
|
43
|
-
|
44
|
-
VERSION = File.open("#{ROOTDIR}/VERSION", "rb").read
|
43
|
+
$VERSION = File.open("#{ROOTDIR}/VERSION", "rb").read
|
45
44
|
$apps = config['apps'] || []
|
46
45
|
|
47
46
|
############################################################
|
@@ -77,10 +76,10 @@ unless check_cert then
|
|
77
76
|
exit
|
78
77
|
else
|
79
78
|
puts "*"*80
|
80
|
-
puts "Simple Push Notification Server
|
79
|
+
puts "Simple Push Notification Server(#{$VERSION}) is Running ..."
|
81
80
|
puts "Mode: #{$mode}"
|
82
81
|
puts "Port: #{$port}"
|
83
|
-
puts "Cron Job: '#{Dir.pwd}/#{$cron}' script is running every #{$timer} #{($timer == 1) ? 'minute' : 'minutes'} " unless "#{$timer}".
|
82
|
+
puts "Cron Job: '#{Dir.pwd}/#{$cron}' script is running every #{$timer} #{($timer == 1) ? 'minute' : 'minutes'} " unless "#{$timer}".to_i == 0
|
84
83
|
puts "*"*80
|
85
84
|
end
|
86
85
|
|
@@ -88,8 +87,6 @@ end
|
|
88
87
|
## Sequel Database Setup
|
89
88
|
############################################################
|
90
89
|
|
91
|
-
$DB;
|
92
|
-
|
93
90
|
unless File.exist?("#{Dir.pwd}/push.db") then
|
94
91
|
$DB = Sequel.connect("sqlite://#{Dir.pwd}/push.db")
|
95
92
|
|
@@ -123,27 +120,24 @@ unless $timer == 0 then
|
|
123
120
|
system "./#{$cron}"
|
124
121
|
end
|
125
122
|
else
|
123
|
+
puts "1: How to register notification? (Client Side)"
|
126
124
|
puts
|
127
|
-
puts "
|
128
|
-
puts "How to register notification?"
|
129
|
-
puts
|
130
|
-
puts "iOS Client: in AppDelegate file, didRegisterForRemoteNotificationsWithDeviceToken method should access url below:"
|
125
|
+
puts "In AppDelegate file, inside didRegisterForRemoteNotificationsWithDeviceToken method access url below to register device token:"
|
131
126
|
$apps.each { |app|
|
132
127
|
puts "'#{app}'s registration url: http://serverIP:#{$port}/v1/apps/#{app}/DeviceToken"
|
133
128
|
}
|
134
129
|
puts
|
135
|
-
puts "How to send push notification?"
|
130
|
+
puts "2: How to send push notification? (Server Side)"
|
136
131
|
puts
|
137
132
|
$apps.each { |app|
|
138
133
|
puts "curl http://localhost:#{$port}/v1/apps/#{app}/push/{message}/{pid}"
|
139
134
|
}
|
140
135
|
puts
|
141
136
|
puts "Note:"
|
142
|
-
puts "message: notification message you want to send, remember the message should be html escaped"
|
143
|
-
puts "pid: unique
|
137
|
+
puts "param1 (message): push notification message you want to send, remember the message should be html escaped"
|
138
|
+
puts "param2 (pid ): unique string to mark the message, for example current timestamp or md5/sha1 digest"
|
144
139
|
puts
|
145
140
|
puts "*"*80
|
146
|
-
puts
|
147
141
|
end
|
148
142
|
|
149
143
|
############################################################
|
@@ -154,7 +148,7 @@ class App < Sinatra::Base
|
|
154
148
|
|
155
149
|
set :port, "#{$port}".to_i
|
156
150
|
|
157
|
-
if $mode == 'development' then
|
151
|
+
if "#{$mode}".strip == 'development' then
|
158
152
|
set :show_exceptions, true
|
159
153
|
set :dump_errors, true
|
160
154
|
else
|
@@ -163,7 +157,8 @@ class App < Sinatra::Base
|
|
163
157
|
end
|
164
158
|
|
165
159
|
get '/' do
|
166
|
-
puts "Simple Push Notification Server"
|
160
|
+
puts "Simple Push Notification Server #{$VERSION}"
|
161
|
+
puts "written by Eiffel(Q) eiffelqiu@gmail.com"
|
167
162
|
end
|
168
163
|
|
169
164
|
$apps.each { |app|
|
@@ -186,10 +181,9 @@ class App < Sinatra::Base
|
|
186
181
|
|
187
182
|
@push = Token.where(:app => app)
|
188
183
|
@exist = Push.first(:pid => pid)
|
189
|
-
|
190
|
-
openSSLContext = $certkey["#{app}"]
|
191
|
-
|
184
|
+
|
192
185
|
unless @exist
|
186
|
+
openSSLContext = $certkey["#{app}"]
|
193
187
|
# Connect to port 2195 on the server.
|
194
188
|
sock = nil
|
195
189
|
if $mode == 'production' then
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spns
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.13
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -27,6 +27,22 @@ dependencies:
|
|
27
27
|
- - ! '>='
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: thin
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
30
46
|
- !ruby/object:Gem::Dependency
|
31
47
|
name: sinatra
|
32
48
|
requirement: !ruby/object:Gem::Requirement
|
@@ -171,6 +187,38 @@ dependencies:
|
|
171
187
|
- - ~>
|
172
188
|
- !ruby/object:Gem::Version
|
173
189
|
version: 1.8.4
|
190
|
+
- !ruby/object:Gem::Dependency
|
191
|
+
name: sqlite3
|
192
|
+
requirement: !ruby/object:Gem::Requirement
|
193
|
+
none: false
|
194
|
+
requirements:
|
195
|
+
- - ! '>='
|
196
|
+
- !ruby/object:Gem::Version
|
197
|
+
version: '0'
|
198
|
+
type: :runtime
|
199
|
+
prerelease: false
|
200
|
+
version_requirements: !ruby/object:Gem::Requirement
|
201
|
+
none: false
|
202
|
+
requirements:
|
203
|
+
- - ! '>='
|
204
|
+
- !ruby/object:Gem::Version
|
205
|
+
version: '0'
|
206
|
+
- !ruby/object:Gem::Dependency
|
207
|
+
name: thin
|
208
|
+
requirement: !ruby/object:Gem::Requirement
|
209
|
+
none: false
|
210
|
+
requirements:
|
211
|
+
- - ! '>='
|
212
|
+
- !ruby/object:Gem::Version
|
213
|
+
version: '0'
|
214
|
+
type: :runtime
|
215
|
+
prerelease: false
|
216
|
+
version_requirements: !ruby/object:Gem::Requirement
|
217
|
+
none: false
|
218
|
+
requirements:
|
219
|
+
- - ! '>='
|
220
|
+
- !ruby/object:Gem::Version
|
221
|
+
version: '0'
|
174
222
|
- !ruby/object:Gem::Dependency
|
175
223
|
name: sinatra
|
176
224
|
requirement: !ruby/object:Gem::Requirement
|
@@ -282,7 +330,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
282
330
|
version: '0'
|
283
331
|
segments:
|
284
332
|
- 0
|
285
|
-
hash:
|
333
|
+
hash: -42604517742237939
|
286
334
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
287
335
|
none: false
|
288
336
|
requirements:
|