spns 0.2.6 → 0.2.7
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/VERSION +1 -1
- data/bin/spns +0 -18
- data/lib/spns.rb +47 -13
- metadata +3 -3
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.2.
|
|
1
|
+
0.2.7
|
data/bin/spns
CHANGED
|
@@ -9,24 +9,6 @@ class Object
|
|
|
9
9
|
alias sh system
|
|
10
10
|
end
|
|
11
11
|
|
|
12
|
-
lib_dir = File.expand_path(File.join(File.dirname(__FILE__),'..','lib'))
|
|
13
|
-
root_dir = File.expand_path(File.join(File.dirname(__FILE__),'..'))
|
|
14
|
-
unless $LOAD_PATH.include?(lib_dir)
|
|
15
|
-
$LOAD_PATH << lib_dir
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
if File.exist?('push.db') then system "rm push.db" end
|
|
19
|
-
|
|
20
|
-
unless File.exist?("#{Dir.pwd}/spns.yml") then
|
|
21
|
-
puts 'create config file: spns.yml'
|
|
22
|
-
system "cp #{root_dir}/spns.yml #{Dir.pwd}/spns.yml"
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
unless File.exist?("#{Dir.pwd}/cron") then
|
|
26
|
-
puts "create a demo 'cron' script"
|
|
27
|
-
system "cp #{root_dir}/cron #{Dir.pwd}/cron"
|
|
28
|
-
end
|
|
29
|
-
|
|
30
12
|
require 'spns'
|
|
31
13
|
|
|
32
14
|
App.run!
|
data/lib/spns.rb
CHANGED
|
@@ -12,6 +12,25 @@ require 'eventmachine'
|
|
|
12
12
|
require 'sinatra/base'
|
|
13
13
|
require 'yaml'
|
|
14
14
|
|
|
15
|
+
############################################################
|
|
16
|
+
## Initilization Setup
|
|
17
|
+
############################################################
|
|
18
|
+
lib_dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
|
|
19
|
+
root_dir = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
|
20
|
+
unless $LOAD_PATH.include?(lib_dir)
|
|
21
|
+
$LOAD_PATH << lib_dir
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
unless File.exist?("#{Dir.pwd}/spns.yml") then
|
|
25
|
+
puts 'create config file: spns.yml'
|
|
26
|
+
system "cp #{root_dir}/spns.yml #{Dir.pwd}/spns.yml"
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
unless File.exist?("#{Dir.pwd}/cron") then
|
|
30
|
+
puts "create a demo 'cron' script"
|
|
31
|
+
system "cp #{root_dir}/cron #{Dir.pwd}/cron"
|
|
32
|
+
end
|
|
33
|
+
|
|
15
34
|
############################################################
|
|
16
35
|
## Configuration Setup
|
|
17
36
|
############################################################
|
|
@@ -34,7 +53,10 @@ unless File.exist?("#{Dir.pwd}/#{$certificate}") then
|
|
|
34
53
|
puts "1: please provide certificate key pem file under current directory"
|
|
35
54
|
puts "2: edit your spns.yml under current directory"
|
|
36
55
|
puts "3: run spns"
|
|
37
|
-
puts "4: Client: in AppDelegate file, didRegisterForRemoteNotificationsWithDeviceToken method should access
|
|
56
|
+
puts "4: iOS Client: in AppDelegate file, didRegisterForRemoteNotificationsWithDeviceToken method should access url below:"
|
|
57
|
+
$apps.each { |app|
|
|
58
|
+
puts "'#{app}'s registration url: http://serverIP:#{$port}/v1/apps/#{app}/DeviceToken"
|
|
59
|
+
}
|
|
38
60
|
puts "5: Server: cron should access 'curl http://localhost:#{$port}/v1/app/push/#{messages}/#{pid}' to send push message"
|
|
39
61
|
exit
|
|
40
62
|
else
|
|
@@ -56,19 +78,25 @@ $openSSLContext.key = OpenSSL::PKey::RSA.new($cert)
|
|
|
56
78
|
## Sequel Database Setup
|
|
57
79
|
############################################################
|
|
58
80
|
|
|
59
|
-
DB =
|
|
81
|
+
DB = nil;
|
|
60
82
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
String :app, :unique => true, :null => false
|
|
64
|
-
String :token, :unique => true, :null => false, :size => 100
|
|
65
|
-
index [:app, :token]
|
|
66
|
-
end
|
|
83
|
+
unless File.exist?("#{Dir.pwd}/push.db") then
|
|
84
|
+
DB = Sequel.connect("sqlite://#{Dir.pwd}/push.db")
|
|
67
85
|
|
|
68
|
-
DB.create_table :
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
86
|
+
DB.create_table :tokens do
|
|
87
|
+
primary_key :id
|
|
88
|
+
String :app, :unique => true, :null => false
|
|
89
|
+
String :token, :unique => true, :null => false, :size => 100
|
|
90
|
+
index [:app, :token]
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
DB.create_table :pushes do
|
|
94
|
+
primary_key :id
|
|
95
|
+
String :pid, :unique => true, :null => false, :size => 100
|
|
96
|
+
index :pid
|
|
97
|
+
end
|
|
98
|
+
else
|
|
99
|
+
DB = Sequel.connect("sqlite://#{Dir.pwd}/push.db")
|
|
72
100
|
end
|
|
73
101
|
|
|
74
102
|
Token = DB[:tokens]
|
|
@@ -87,6 +115,12 @@ unless "#{$timer}".squeeze.strip == "0"
|
|
|
87
115
|
else
|
|
88
116
|
puts
|
|
89
117
|
puts "*"*80
|
|
118
|
+
puts "How to register notification?"
|
|
119
|
+
puts
|
|
120
|
+
puts "iOS Client: in AppDelegate file, didRegisterForRemoteNotificationsWithDeviceToken method should access url below:"
|
|
121
|
+
$apps.each { |app|
|
|
122
|
+
puts "'#{app}'s registration url: http://serverIP:#{$port}/v1/apps/#{app}/DeviceToken"
|
|
123
|
+
}
|
|
90
124
|
puts
|
|
91
125
|
puts "How to send push notification?"
|
|
92
126
|
puts
|
|
@@ -116,7 +150,7 @@ class App < Sinatra::Base
|
|
|
116
150
|
|
|
117
151
|
$apps.each { |app|
|
|
118
152
|
get "/v1/apps/#{app}/:token" do
|
|
119
|
-
puts "#{:token} was added to #{app}"
|
|
153
|
+
puts "[#{params[:token]}] was added to '#{app}'"
|
|
120
154
|
o = Token.first(:token => params[:token])
|
|
121
155
|
unless o
|
|
122
156
|
Token.insert(
|
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.7
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2012-09-
|
|
12
|
+
date: 2012-09-12 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: sqlite3
|
|
@@ -315,7 +315,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
315
315
|
version: '0'
|
|
316
316
|
segments:
|
|
317
317
|
- 0
|
|
318
|
-
hash:
|
|
318
|
+
hash: 761777499486161200
|
|
319
319
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
320
320
|
none: false
|
|
321
321
|
requirements:
|