rhosync 2.1.2 → 2.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +4 -0
- data/bench/benchapp/config.ru +0 -1
- data/generators/templates/application/config.ru +0 -1
- data/lib/rhosync/jobs/ping_job.rb +12 -4
- data/lib/rhosync/tasks.rb +1 -1
- data/lib/rhosync/version.rb +1 -1
- data/lib/rhosync.rb +1 -1
- data/spec/api/api_helper.rb +3 -5
- data/spec/apps/rhotestapp/settings/settings.yml +4 -4
- data/spec/doc/doc_spec.rb +3 -5
- data/spec/jobs/ping_job_spec.rb +15 -0
- data/spec/rhosync_spec.rb +9 -1
- data/spec/server/server_spec.rb +3 -5
- data/spec/spec_helper.rb +1 -0
- metadata +5 -5
data/CHANGELOG
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
## 2.1.3
|
2
|
+
* #4398193 - ping should only send push messages to unique device pin list
|
3
|
+
* #13022667 - settings.yml doesn't work for setting external Redis instances
|
4
|
+
|
1
5
|
## 2.1.2
|
2
6
|
* Use server-dir/redis.conf if not found at RedisRunner.prefix (via artemk)
|
3
7
|
* #8471337 - switch client user if it is not equal to current_user
|
data/bench/benchapp/config.ru
CHANGED
@@ -21,7 +21,6 @@ ROOT_PATH = File.expand_path(File.dirname(__FILE__))
|
|
21
21
|
Rhosync::Server.disable :run
|
22
22
|
Rhosync::Server.disable :clean_trace
|
23
23
|
Rhosync::Server.enable :raise_errors
|
24
|
-
Rhosync::Server.set :environment, :development
|
25
24
|
Rhosync::Server.set :secret, '<changeme>'
|
26
25
|
Rhosync::Server.set :root, ROOT_PATH
|
27
26
|
Rhosync::Server.use Rack::Static, :urls => ["/data"], :root => Rhosync::Server.root
|
@@ -18,7 +18,6 @@ ROOT_PATH = File.expand_path(File.dirname(__FILE__))
|
|
18
18
|
Rhosync::Server.disable :run
|
19
19
|
Rhosync::Server.disable :clean_trace
|
20
20
|
Rhosync::Server.enable :raise_errors
|
21
|
-
Rhosync::Server.set :environment, :development
|
22
21
|
Rhosync::Server.set :secret, '<%= @secret %>'
|
23
22
|
Rhosync::Server.set :root, ROOT_PATH
|
24
23
|
Rhosync::Server.use Rack::Static, :urls => ["/data"], :root => Rhosync::Server.root
|
@@ -7,13 +7,21 @@ module Rhosync
|
|
7
7
|
# Perform a ping for all clients registered to a user
|
8
8
|
def self.perform(params)
|
9
9
|
user = User.load(params["user_id"])
|
10
|
+
device_pins = []
|
10
11
|
user.clients.members.each do |client_id|
|
11
12
|
client = Client.load(client_id,{:source_name => '*'})
|
12
|
-
params.merge!('device_port' => client.device_port,
|
13
|
-
'device_pin' => client.device_pin)
|
13
|
+
params.merge!('device_port' => client.device_port, 'device_pin' => client.device_pin)
|
14
14
|
if client.device_type and client.device_type.size > 0 and client.device_pin and client.device_pin.size > 0
|
15
|
-
|
16
|
-
|
15
|
+
unless device_pins.include? client.device_pin
|
16
|
+
device_pins << client.device_pin
|
17
|
+
klass = Object.const_get(camelize(client.device_type.downcase))
|
18
|
+
if klass
|
19
|
+
params['vibrate'] = params['vibrate'].to_s
|
20
|
+
klass.ping(params)
|
21
|
+
end
|
22
|
+
else
|
23
|
+
log "Dropping ping request for client_id '#{client_id}' because it's already in user's device pin list."
|
24
|
+
end
|
17
25
|
else
|
18
26
|
log "Skipping ping for non-registered client_id '#{client_id}'..."
|
19
27
|
end
|
data/lib/rhosync/tasks.rb
CHANGED
@@ -88,7 +88,7 @@ namespace :rhosync do
|
|
88
88
|
|
89
89
|
task :config do
|
90
90
|
$settings = load_settings(File.join('settings','settings.yml'))
|
91
|
-
$env = (ENV['RHO_ENV'] || :development).to_sym
|
91
|
+
$env = (ENV['RHO_ENV'] || ENV['RACK_ENV'] || :development).to_sym
|
92
92
|
uri = URI.parse($settings[$env][:syncserver])
|
93
93
|
$url = "#{uri.scheme}://#{uri.host}"
|
94
94
|
$url = "#{$url}:#{uri.port}" if uri.port && uri.port != 80
|
data/lib/rhosync/version.rb
CHANGED
data/lib/rhosync.rb
CHANGED
@@ -51,7 +51,7 @@ module Rhosync
|
|
51
51
|
def bootstrap(basedir)
|
52
52
|
config = get_config(basedir)
|
53
53
|
#Load environment
|
54
|
-
environment = (ENV['RHO_ENV'] || :development).to_sym
|
54
|
+
environment = (ENV['RHO_ENV'] || ENV['RACK_ENV'] || :development).to_sym
|
55
55
|
# Initialize Rhosync and Resque
|
56
56
|
Rhosync.base_directory = basedir
|
57
57
|
Rhosync.app_directory = get_setting(config,environment,:app_directory)
|
data/spec/api/api_helper.rb
CHANGED
@@ -17,11 +17,9 @@ describe "ApiHelper", :shared => true do
|
|
17
17
|
Rhosync.bootstrap(get_testapp_path) do |rhosync|
|
18
18
|
rhosync.vendor_directory = File.join(rhosync.base_directory,'..','..','..','vendor')
|
19
19
|
end
|
20
|
-
Rhosync::Server.set
|
21
|
-
|
22
|
-
|
23
|
-
:secret => "secure!"
|
24
|
-
)
|
20
|
+
Rhosync::Server.set :environment, :test
|
21
|
+
Rhosync::Server.set :run, false
|
22
|
+
Rhosync::Server.set :secret, "secure!"
|
25
23
|
@api_token = User.load('rhoadmin').token_id
|
26
24
|
end
|
27
25
|
|
@@ -12,15 +12,15 @@
|
|
12
12
|
|
13
13
|
:development:
|
14
14
|
:licensefile: settings/license.key
|
15
|
-
:iphonecertfile: settings/apple_fake_cert.pem
|
16
|
-
:iphonepassphrase: certpassword
|
17
|
-
:iphoneserver: gateway.sandbox.push.apple.com
|
18
|
-
:iphoneport: 2195
|
19
15
|
:bulk_sync_poll_interval: 3600
|
20
16
|
:redis: localhost:6379
|
21
17
|
:syncserver: http://localhost:9292/application/
|
22
18
|
:test:
|
23
19
|
:licensefile: settings/license.key
|
20
|
+
:iphonecertfile: settings/apple_fake_cert.pem
|
21
|
+
:iphonepassphrase: certpassword
|
22
|
+
:iphoneserver: gateway.sandbox.push.apple.com
|
23
|
+
:iphoneport: 2195
|
24
24
|
:bulk_sync_poll_interval: 3600
|
25
25
|
:redis: localhost:6379
|
26
26
|
:syncserver: http://localhost:9292/application/
|
data/spec/doc/doc_spec.rb
CHANGED
@@ -23,11 +23,9 @@ describe "Protocol" do
|
|
23
23
|
Rhosync.bootstrap(get_testapp_path) do |rhosync|
|
24
24
|
rhosync.vendor_directory = File.join(rhosync.base_directory,'..','..','..','vendor')
|
25
25
|
end
|
26
|
-
Rhosync::Server.set
|
27
|
-
|
28
|
-
|
29
|
-
:secret => "secure!"
|
30
|
-
)
|
26
|
+
Rhosync::Server.set :environment, :test
|
27
|
+
Rhosync::Server.set :run, false
|
28
|
+
Rhosync::Server.set :secret, "secure!"
|
31
29
|
end
|
32
30
|
|
33
31
|
before(:each) do
|
data/spec/jobs/ping_job_spec.rb
CHANGED
@@ -41,5 +41,20 @@ describe "PingJob" do
|
|
41
41
|
PingJob.should_receive(:log).once.with("Skipping ping for non-registered client_id '#{@c.id}'...")
|
42
42
|
lambda { PingJob.perform(params) }.should_not raise_error
|
43
43
|
end
|
44
|
+
|
45
|
+
it "should drop ping if it's already in user's device pin list" do
|
46
|
+
params = {"user_id" => @u.id, "api_token" => @api_token,
|
47
|
+
"sources" => [@s.name], "message" => 'hello world',
|
48
|
+
"vibrate" => '5', "badge" => '5', "sound" => 'hello.mp3'}
|
49
|
+
|
50
|
+
# another client with the same device pin ...
|
51
|
+
@c1 = Client.create(@c_fields,{:source_name => @s_fields[:name]})
|
52
|
+
# and yet another one ...
|
53
|
+
@c2 = Client.create(@c_fields,{:source_name => @s_fields[:name]})
|
54
|
+
|
55
|
+
Apple.should_receive(:ping).with({'device_pin' => @c.device_pin, 'device_port' => @c.device_port}.merge!(params))
|
56
|
+
PingJob.should_receive(:log).twice.with(/Dropping ping request for client/)
|
57
|
+
lambda { PingJob.perform(params) }.should_not raise_error
|
58
|
+
end
|
44
59
|
|
45
60
|
end
|
data/spec/rhosync_spec.rb
CHANGED
@@ -15,7 +15,7 @@ describe "Rhosync" do
|
|
15
15
|
Rhosync.vendor_directory.should == 'foo'
|
16
16
|
Rhosync.blackberry_bulk_sync.should == false
|
17
17
|
Rhosync.bulk_sync_poll_interval.should == 3600
|
18
|
-
Rhosync.environment.should == :
|
18
|
+
Rhosync.environment.should == :test
|
19
19
|
Rhosync.stats.should == false
|
20
20
|
App.is_exist?(@test_app_name).should be_true
|
21
21
|
end
|
@@ -27,6 +27,14 @@ describe "Rhosync" do
|
|
27
27
|
ENV.delete('RHO_ENV')
|
28
28
|
end
|
29
29
|
|
30
|
+
it "should bootstrap Rhosync with RACK_ENV provided" do
|
31
|
+
env = ENV['RACK_ENV'].dup
|
32
|
+
ENV['RACK_ENV'] = 'production'
|
33
|
+
Rhosync.bootstrap(get_testapp_path)
|
34
|
+
Rhosync.environment.should == :production
|
35
|
+
ENV['RACK_ENV'] = env
|
36
|
+
end
|
37
|
+
|
30
38
|
it "should bootstrap with existing app" do
|
31
39
|
app = App.create(:name => @test_app_name)
|
32
40
|
App.should_receive(:load).once.with(@test_app_name).and_return(app)
|
data/spec/server/server_spec.rb
CHANGED
@@ -18,11 +18,9 @@ describe "Server" do
|
|
18
18
|
Rhosync.bootstrap(get_testapp_path) do |rhosync|
|
19
19
|
rhosync.vendor_directory = File.join(rhosync.base_directory,'..','..','..','vendor')
|
20
20
|
end
|
21
|
-
Rhosync::Server.set
|
22
|
-
|
23
|
-
|
24
|
-
:secret => "secure!"
|
25
|
-
)
|
21
|
+
Rhosync::Server.set :environment, :test
|
22
|
+
Rhosync::Server.set :run, false
|
23
|
+
Rhosync::Server.set :secret, "secure!"
|
26
24
|
Rhosync::Server.use Rack::Static, :urls => ["/data"],
|
27
25
|
:root => File.expand_path(File.join(File.dirname(__FILE__),'..','apps','rhotestapp'))
|
28
26
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rhosync
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 13
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 2
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 2.1.
|
9
|
+
- 3
|
10
|
+
version: 2.1.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Rhomobile
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-05-05 00:00:00 -07:00
|
19
19
|
default_executable: rhosync
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -574,7 +574,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
574
574
|
requirements: []
|
575
575
|
|
576
576
|
rubyforge_project:
|
577
|
-
rubygems_version: 1.
|
577
|
+
rubygems_version: 1.6.2
|
578
578
|
signing_key:
|
579
579
|
specification_version: 3
|
580
580
|
summary: RhoSync Synchronization Framework
|