rhosync 2.1.17.beta7 → 2.1.17

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,4 +1,4 @@
1
- ## 2.1.17 (not yet released)
1
+ ## 2.1.17
2
2
  * Reset device attributes if Android ping returns "Not Registered" Error
3
3
  * #29214293 - do not execute ping if the platform is not configured
4
4
  * Refactor server middleware. Remove explicit rack dependency. Fix broken rspec examples.
@@ -11,6 +11,7 @@
11
11
  * Revert fix for Zendesk ticket #2336 by customer request
12
12
  * #28094895 - Zendesk ticket #2354: Bulk sync not updating sources table (fields 'last_inserted_size' and 'backend_refresh_time' now updated)
13
13
  * #29796429 - Zendesk ticket #2447: use list to preserve bulk data sources order
14
+ * Fixing redis dependencies to handle redis 3.0.0 release
14
15
 
15
16
  ## 2.1.16
16
17
  * revert rack support for v. 1.4.1 and lock to v. 1.3.6 due to problems with Heroku deployment (Rack 1.4.1 produces 502 error)
data/Rakefile CHANGED
@@ -71,7 +71,8 @@ begin
71
71
  gemspec.add_dependency "sqlite3-ruby", "~>1.2.5"
72
72
  gemspec.add_dependency "rubyzip", "~>0.9.4"
73
73
  gemspec.add_dependency "uuidtools", ">=2.1.1"
74
- gemspec.add_dependency "redis", "~>2.1.1"
74
+ gemspec.add_dependency "redis-namespace", "~>1.1.0"
75
+ gemspec.add_dependency "redis", "~>2.2.2"
75
76
  gemspec.add_dependency "resque", "~>1.14.0"
76
77
  gemspec.add_dependency "rest-client", "~>1.6.1"
77
78
  gemspec.add_dependency "templater", "~>1.0.0"
@@ -92,18 +92,18 @@ module Rhosync
92
92
  end
93
93
  sources = config[:sources] || []
94
94
  Source.delete_all
95
+ app.delete_sources
95
96
  sources.each do |source_name,fields|
96
- check_for_schema_field!(fields)
97
- fields[:name] = source_name
98
- Source.create(fields,{:app_id => app.name})
99
- unless app.sources.members.include?(source_name)
100
- app.sources << source_name
101
- end
97
+ source_config = source_config(source_name)
98
+ check_for_schema_field!(source_config)
99
+ source_config[:name] = source_name
100
+ Source.create(source_config,{:app_id => app.name})
101
+ app.sources << source_name
102
102
  # load ruby file for source adapter to re-load class
103
103
  load under_score(source_name+'.rb')
104
104
  end
105
105
  # Create associations for all sources
106
- Source.update_associations(app.sources.members)
106
+ Source.update_associations(app.sources)
107
107
  end
108
108
  end
109
109
 
@@ -127,8 +127,11 @@ module Rhosync
127
127
  YAML.load_file(settings_file) if settings_file and File.exist?(settings_file)
128
128
  end
129
129
 
130
- def source_config
131
- { "sources" => Rhosync.get_config(Rhosync.base_directory)[:sources] }
130
+ def source_config(source_name)
131
+ source_config = {}
132
+ sources = Rhosync.get_config(Rhosync.base_directory)[:sources]
133
+ source_config = sources[source_name] unless (sources.nil? or sources[source_name].nil?)
134
+ source_config
132
135
  end
133
136
  ### End Rhosync setup methods
134
137
 
@@ -2,7 +2,7 @@ Server.api :delete_user do |params,user|
2
2
  User.load(params[:user_id]).delete
3
3
  App.load(APP_NAME).users.delete(params[:user_id])
4
4
  params = {:app_id => APP_NAME,:user_id => params[:user_id]}
5
- App.load(APP_NAME).sources.members.each{ |source|
5
+ App.load(APP_NAME).sources.each{ |source|
6
6
  Source.load(source, params).flash_store_data
7
7
  }
8
8
  "User deleted"
@@ -1,5 +1,5 @@
1
1
  Server.api :list_sources do |params,user|
2
- sources = App.load(APP_NAME).sources.members
2
+ sources = App.load(APP_NAME).sources
3
3
  if params[:partition_type].nil? or params[:partition_type] == 'all'
4
4
  sources.to_json
5
5
  else
@@ -2,10 +2,11 @@ module Rhosync
2
2
  class App < Model
3
3
  field :name, :string
4
4
  set :users, :string
5
- set :sources, :string
6
5
  attr_reader :delegate
7
6
  validates_presence_of :name
8
-
7
+
8
+ @@sources = []
9
+
9
10
  class << self
10
11
  def create(fields={})
11
12
  fields[:id] = fields[:name]
@@ -31,10 +32,19 @@ module Rhosync
31
32
  def delegate
32
33
  @delegate.nil? ? Object.const_get(camelize(self.name)) : @delegate
33
34
  end
35
+
36
+ def delete
37
+ @@sources = []
38
+ super
39
+ end
40
+
41
+ def delete_sources
42
+ @@sources = []
43
+ end
34
44
 
35
45
  def partition_sources(partition,user_id)
36
46
  names = []
37
- sources.members.each do |source|
47
+ @@sources.each do |source|
38
48
  s = Source.load(source,{:app_id => self.name,
39
49
  :user_id => user_id})
40
50
  if s.partition == partition
@@ -47,5 +57,11 @@ module Rhosync
47
57
  def store_blob(obj,field_name,blob)
48
58
  self.delegate.send :store_blob, obj,field_name,blob
49
59
  end
60
+
61
+ def sources
62
+ @@sources.uniq!
63
+ # Sort sources array by priority
64
+ @@sources = @@sources.sort_by { |s| Source.load(s, {:app_id => self.name, :user_id => '*'}).priority }
65
+ end
50
66
  end
51
67
  end
@@ -218,21 +218,21 @@ module Rhosync
218
218
  content_type :json
219
219
  client = Client.create(:user_id => current_user.id,:app_id => current_app.id)
220
220
  client.update_fields(params)
221
- { "client" => { "client_id" => client.id.to_s } }.merge!(source_config).to_json
221
+ { "client" => { "client_id" => client.id.to_s } }.to_json
222
222
  end
223
223
  end
224
224
 
225
225
  post '/application/clientregister' do
226
226
  catch_all do
227
227
  current_client.update_fields(params)
228
- source_config.to_json
228
+ status 200
229
229
  end
230
230
  end
231
231
 
232
232
  get '/application/clientreset' do
233
233
  catch_all do
234
234
  ClientSync.reset(current_client, params)
235
- source_config.to_json
235
+ status 200
236
236
  end
237
237
  end
238
238
 
@@ -1,3 +1,3 @@
1
1
  module Rhosync
2
- VERSION = '2.1.17.beta7'
2
+ VERSION = '2.1.17'
3
3
  end
@@ -13,7 +13,7 @@ describe "RhosyncApiGetSourceParams" do
13
13
  {"name"=>"url", "value"=>"http://example.com", "type"=>"string"},
14
14
  {"name"=>"login", "value"=>"testuser", "type"=>"string"},
15
15
  {"name"=>"password", "value"=>"testpass", "type"=>"string"},
16
- {"name"=>"priority", "value"=>3, "type"=>"integer"},
16
+ {"name"=>"priority", "value"=>1, "type"=>"integer"},
17
17
  {"name"=>"callback_url", "value"=>nil, "type"=>"string"},
18
18
  {"name"=>"poll_interval", "value"=>300, "type"=>"integer"},
19
19
  {"name"=>"retry_limit", "value"=>0, "type"=>"integer"},
@@ -162,7 +162,7 @@ describe "RhosyncApi" do
162
162
  {"name"=>"url", "value"=>"http://example.com", "type"=>"string"},
163
163
  {"name"=>"login", "value"=>"testuser", "type"=>"string"},
164
164
  {"name"=>"password", "value"=>"testpass", "type"=>"string"},
165
- {"name"=>"priority", "value"=>3, "type"=>"integer"},
165
+ {"name"=>"priority", "value"=>1, "type"=>"integer"},
166
166
  {"name"=>"callback_url", "value"=>nil, "type"=>"string"},
167
167
  {"name"=>"poll_interval", "value"=>300, "type"=>"integer"},
168
168
  {"name"=>"retry_limit", "type"=>"integer", "value"=>0},
@@ -13,6 +13,6 @@ describe "App" do
13
13
 
14
14
  it "should add source adapters" do
15
15
  @a1 = App.load(@a_fields[:name])
16
- @a1.sources.members.sort.should == ["FixedSchemaAdapter", "SampleAdapter"]
16
+ @a1.sources.sort.should == ["FixedSchemaAdapter", "SampleAdapter", "SimpleAdapter"]
17
17
  end
18
18
  end
@@ -1,11 +1,13 @@
1
1
  :sources:
2
2
  SampleAdapter:
3
3
  poll_interval: 300
4
+ priority: 1
4
5
  SimpleAdapter:
5
6
  poll_interval: 600
6
7
  partition_type: 'app'
7
8
  FixedSchemaAdapter:
8
9
  poll_interval: 300
10
+ priority: 5
9
11
  sync_type: 'incremental'
10
12
  belongs_to:
11
13
  - brand: 'SampleAdapter'
@@ -61,17 +61,16 @@ describe "BulkData" do
61
61
  File.join(@a_fields[:name],@a_fields[:name])
62
62
  end
63
63
 
64
- it "should have ordered sources list" do
64
+ it "should have ordered sources list by priority" do
65
65
  data = BulkData.create(:name => bulk_data_docname(@a.id,@u.id),
66
66
  :state => :inprogress,
67
67
  :app_id => @a.id,
68
68
  :user_id => @u.id,
69
69
  :sources => @a.partition_sources(:user, @u.id))
70
70
  data.sources[0, -1].should == ["SampleAdapter", "FixedSchemaAdapter"]
71
- end
72
-
73
- it "should have ordered sources list by priority" do
74
- pending
71
+ p1 = Source.load("SampleAdapter", {:app_id => data.app_id, :user_id => data.user_id}).priority
72
+ p2 = Source.load("FixedSchemaAdapter", {:app_id => data.app_id, :user_id => data.user_id}).priority
73
+ p1.should < p2
75
74
  end
76
75
 
77
76
  it "should process_sources for bulk data" do
@@ -583,6 +583,7 @@ describe "ClientSync" do
583
583
  end
584
584
 
585
585
  it "should create bulk data job app partition if none exists and no partition sources" do
586
+ @a.sources.delete("SimpleAdapter")
586
587
  ClientSync.bulk_data(:app,@c).should == {:result => :nop}
587
588
  Resque.peek(:bulk_data).should == nil
588
589
  end
@@ -48,7 +48,7 @@ describe "Rhosync" do
48
48
  )
49
49
  App.should_receive(:load).twice.with(@test_app_name).and_return(app)
50
50
  Rhosync.bootstrap(get_testapp_path)
51
- App.load(@test_app_name).sources.members.should == []
51
+ App.load(@test_app_name).sources.should == []
52
52
  end
53
53
 
54
54
  it "should exit if schema config exists" do
@@ -129,15 +129,6 @@ describe "Server" do
129
129
  describe "client management routes" do
130
130
  before(:each) do
131
131
  do_post "/application/clientlogin", "login" => @u.login, "password" => 'testpass'
132
- @source_config = {
133
- "sources"=>
134
- {"FixedSchemaAdapter"=>
135
- {"poll_interval"=>300,
136
- "sync_type"=>"incremental",
137
- "belongs_to"=>[{"brand"=>"SampleAdapter"}]},
138
- "SampleAdapter"=>{"poll_interval"=>300},
139
- "SimpleAdapter"=>{"partition_type"=>"app", "poll_interval"=>600}}
140
- }
141
132
  end
142
133
 
143
134
  it "should respond to clientcreate" do
@@ -147,17 +138,16 @@ describe "Server" do
147
138
  id = JSON.parse(last_response.body)['client']['client_id']
148
139
  id.length.should == 32
149
140
  JSON.parse(last_response.body).should ==
150
- {"client"=>{"client_id"=>id}}.merge!(@source_config)
141
+ {"client"=>{"client_id"=>id}}
151
142
  c = Client.load(id,{:source_name => '*'})
152
143
  c.user_id.should == 'testuser'
153
144
  c.device_type.should == 'blackberry'
154
145
  end
155
-
146
+
156
147
  it "should respond to clientregister" do
157
148
  do_post "/application/clientregister",
158
149
  "device_type" => "iPhone", "device_pin" => 'abcd', "client_id" => @c.id
159
150
  last_response.should be_ok
160
- JSON.parse(last_response.body).should == @source_config
161
151
  @c.device_type.should == 'Apple'
162
152
  @c.device_pin.should == 'abcd'
163
153
  @c.id.length.should == 32
@@ -166,7 +156,6 @@ describe "Server" do
166
156
  it "should respond to clientreset" do
167
157
  set_state(@c.docname(:cd) => @data)
168
158
  get "/application/clientreset", :client_id => @c.id,:version => ClientSync::VERSION
169
- JSON.parse(last_response.body).should == @source_config
170
159
  verify_result(@c.docname(:cd) => {})
171
160
  end
172
161
 
@@ -177,7 +166,7 @@ describe "Server" do
177
166
  set_state(@c.docname(:cd) => @data)
178
167
  sources = [{'name' => 'SimpleAdapter'}]
179
168
  get "/application/clientreset", :client_id => @c.id,:version => ClientSync::VERSION, :sources => sources
180
- JSON.parse(last_response.body).should == @source_config
169
+ last_response.should be_ok
181
170
  @c.source_name = 'SampleAdapter'
182
171
  verify_result(@c.docname(:cd) => @data)
183
172
  @c.source_name = 'SimpleAdapter'
@@ -13,7 +13,7 @@ describe "Source" do
13
13
  @s.url.should == @s_fields[:url]
14
14
  @s.login.should == @s_fields[:login]
15
15
  @s.app.name.should == @a_fields[:name]
16
- @s.priority.should == 3
16
+ @s.priority.should == 1
17
17
  @s.callback_url.should be_nil
18
18
  @s.queue.should be_nil
19
19
  @s.query_queue.should be_nil
@@ -29,7 +29,7 @@ describe "Source" do
29
29
  @s1.url.should == @s_fields[:url]
30
30
  @s1.login.should == @s_fields[:login]
31
31
  @s1.app.name.should == @a_fields[:name]
32
- @s1.priority.should == 3
32
+ @s1.priority.should == 1
33
33
  @s1.callback_url.should be_nil
34
34
  @s1.poll_interval.should == 300
35
35
  @s1.app_id.should == @s_params[:app_id]
@@ -303,12 +303,14 @@ describe "DBObjectsHelper", :shared => true do
303
303
  :url => 'http://example.com',
304
304
  :login => 'testuser',
305
305
  :password => 'testpass',
306
+ :priority => '1'
306
307
  }
307
308
  @s1_fields = {
308
309
  :name => 'FixedSchemaAdapter',
309
310
  :url => 'http://example.com',
310
311
  :login => 'testuser',
311
312
  :password => 'testpass',
313
+ :priority => '5'
312
314
  }
313
315
  @s_params = {
314
316
  :user_id => @u.id,
@@ -318,12 +320,12 @@ describe "DBObjectsHelper", :shared => true do
318
320
  @s = Source.create(@s_fields,@s_params)
319
321
  @s1 = Source.create(@s1_fields,@s_params)
320
322
  @s1.belongs_to = [{'brand' => 'SampleAdapter'}].to_json
321
- config = Rhosync.source_config["sources"]['FixedSchemaAdapter']
323
+ config = Rhosync.source_config('FixedSchemaAdapter')
322
324
  @s1.update(config)
323
325
  @r = @s.read_state
324
326
  @a.sources << @s.id
325
327
  @a.sources << @s1.id
326
- Source.update_associations(@a.sources.members)
328
+ Source.update_associations(@a.sources)
327
329
  @a.users << @u.id
328
330
  end
329
331
  end
metadata CHANGED
@@ -1,15 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rhosync
3
3
  version: !ruby/object:Gem::Version
4
- hash: 62196341
5
- prerelease: 7
4
+ hash: 41
5
+ prerelease:
6
6
  segments:
7
7
  - 2
8
8
  - 1
9
9
  - 17
10
- - beta
11
- - 7
12
- version: 2.1.17.beta7
10
+ version: 2.1.17
13
11
  platform: ruby
14
12
  authors:
15
13
  - Rhomobile
@@ -17,7 +15,7 @@ autorequire:
17
15
  bindir: bin
18
16
  cert_chain: []
19
17
 
20
- date: 2012-05-17 00:00:00 Z
18
+ date: 2012-05-28 00:00:00 Z
21
19
  dependencies:
22
20
  - !ruby/object:Gem::Dependency
23
21
  name: sinatra
@@ -100,25 +98,41 @@ dependencies:
100
98
  type: :runtime
101
99
  version_requirements: *id005
102
100
  - !ruby/object:Gem::Dependency
103
- name: redis
101
+ name: redis-namespace
104
102
  prerelease: false
105
103
  requirement: &id006 !ruby/object:Gem::Requirement
106
104
  none: false
107
105
  requirements:
108
106
  - - ~>
109
107
  - !ruby/object:Gem::Version
110
- hash: 9
108
+ hash: 19
111
109
  segments:
112
- - 2
113
110
  - 1
114
111
  - 1
115
- version: 2.1.1
112
+ - 0
113
+ version: 1.1.0
116
114
  type: :runtime
117
115
  version_requirements: *id006
118
116
  - !ruby/object:Gem::Dependency
119
- name: resque
117
+ name: redis
120
118
  prerelease: false
121
119
  requirement: &id007 !ruby/object:Gem::Requirement
120
+ none: false
121
+ requirements:
122
+ - - ~>
123
+ - !ruby/object:Gem::Version
124
+ hash: 3
125
+ segments:
126
+ - 2
127
+ - 2
128
+ - 2
129
+ version: 2.2.2
130
+ type: :runtime
131
+ version_requirements: *id007
132
+ - !ruby/object:Gem::Dependency
133
+ name: resque
134
+ prerelease: false
135
+ requirement: &id008 !ruby/object:Gem::Requirement
122
136
  none: false
123
137
  requirements:
124
138
  - - ~>
@@ -130,11 +144,11 @@ dependencies:
130
144
  - 0
131
145
  version: 1.14.0
132
146
  type: :runtime
133
- version_requirements: *id007
147
+ version_requirements: *id008
134
148
  - !ruby/object:Gem::Dependency
135
149
  name: rest-client
136
150
  prerelease: false
137
- requirement: &id008 !ruby/object:Gem::Requirement
151
+ requirement: &id009 !ruby/object:Gem::Requirement
138
152
  none: false
139
153
  requirements:
140
154
  - - ~>
@@ -146,11 +160,11 @@ dependencies:
146
160
  - 1
147
161
  version: 1.6.1
148
162
  type: :runtime
149
- version_requirements: *id008
163
+ version_requirements: *id009
150
164
  - !ruby/object:Gem::Dependency
151
165
  name: templater
152
166
  prerelease: false
153
- requirement: &id009 !ruby/object:Gem::Requirement
167
+ requirement: &id010 !ruby/object:Gem::Requirement
154
168
  none: false
155
169
  requirements:
156
170
  - - ~>
@@ -162,11 +176,11 @@ dependencies:
162
176
  - 0
163
177
  version: 1.0.0
164
178
  type: :runtime
165
- version_requirements: *id009
179
+ version_requirements: *id010
166
180
  - !ruby/object:Gem::Dependency
167
181
  name: rake
168
182
  prerelease: false
169
- requirement: &id010 !ruby/object:Gem::Requirement
183
+ requirement: &id011 !ruby/object:Gem::Requirement
170
184
  none: false
171
185
  requirements:
172
186
  - - ~>
@@ -179,11 +193,11 @@ dependencies:
179
193
  - 2
180
194
  version: 0.9.2.2
181
195
  type: :runtime
182
- version_requirements: *id010
196
+ version_requirements: *id011
183
197
  - !ruby/object:Gem::Dependency
184
198
  name: log4r
185
199
  prerelease: false
186
- requirement: &id011 !ruby/object:Gem::Requirement
200
+ requirement: &id012 !ruby/object:Gem::Requirement
187
201
  none: false
188
202
  requirements:
189
203
  - - ~>
@@ -195,11 +209,11 @@ dependencies:
195
209
  - 7
196
210
  version: 1.1.7
197
211
  type: :development
198
- version_requirements: *id011
212
+ version_requirements: *id012
199
213
  - !ruby/object:Gem::Dependency
200
214
  name: jeweler
201
215
  prerelease: false
202
- requirement: &id012 !ruby/object:Gem::Requirement
216
+ requirement: &id013 !ruby/object:Gem::Requirement
203
217
  none: false
204
218
  requirements:
205
219
  - - ">="
@@ -211,11 +225,11 @@ dependencies:
211
225
  - 0
212
226
  version: 1.4.0
213
227
  type: :development
214
- version_requirements: *id012
228
+ version_requirements: *id013
215
229
  - !ruby/object:Gem::Dependency
216
230
  name: rspec
217
231
  prerelease: false
218
- requirement: &id013 !ruby/object:Gem::Requirement
232
+ requirement: &id014 !ruby/object:Gem::Requirement
219
233
  none: false
220
234
  requirements:
221
235
  - - ">="
@@ -227,11 +241,11 @@ dependencies:
227
241
  - 0
228
242
  version: 1.3.0
229
243
  type: :development
230
- version_requirements: *id013
244
+ version_requirements: *id014
231
245
  - !ruby/object:Gem::Dependency
232
246
  name: rcov
233
247
  prerelease: false
234
- requirement: &id014 !ruby/object:Gem::Requirement
248
+ requirement: &id015 !ruby/object:Gem::Requirement
235
249
  none: false
236
250
  requirements:
237
251
  - - ">="
@@ -243,11 +257,11 @@ dependencies:
243
257
  - 8
244
258
  version: 0.9.8
245
259
  type: :development
246
- version_requirements: *id014
260
+ version_requirements: *id015
247
261
  - !ruby/object:Gem::Dependency
248
262
  name: faker
249
263
  prerelease: false
250
- requirement: &id015 !ruby/object:Gem::Requirement
264
+ requirement: &id016 !ruby/object:Gem::Requirement
251
265
  none: false
252
266
  requirements:
253
267
  - - ">="
@@ -259,11 +273,11 @@ dependencies:
259
273
  - 1
260
274
  version: 0.3.1
261
275
  type: :development
262
- version_requirements: *id015
276
+ version_requirements: *id016
263
277
  - !ruby/object:Gem::Dependency
264
278
  name: rack-test
265
279
  prerelease: false
266
- requirement: &id016 !ruby/object:Gem::Requirement
280
+ requirement: &id017 !ruby/object:Gem::Requirement
267
281
  none: false
268
282
  requirements:
269
283
  - - ">="
@@ -275,11 +289,11 @@ dependencies:
275
289
  - 3
276
290
  version: 0.5.3
277
291
  type: :development
278
- version_requirements: *id016
292
+ version_requirements: *id017
279
293
  - !ruby/object:Gem::Dependency
280
294
  name: thor
281
295
  prerelease: false
282
- requirement: &id017 !ruby/object:Gem::Requirement
296
+ requirement: &id018 !ruby/object:Gem::Requirement
283
297
  none: false
284
298
  requirements:
285
299
  - - ">="
@@ -291,7 +305,7 @@ dependencies:
291
305
  - 6
292
306
  version: 0.13.6
293
307
  type: :development
294
- version_requirements: *id017
308
+ version_requirements: *id018
295
309
  description: RhoSync Synchronization Framework and related command-line utilities
296
310
  email: dev@rhomobile.com
297
311
  executables:
@@ -571,18 +585,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
571
585
  required_rubygems_version: !ruby/object:Gem::Requirement
572
586
  none: false
573
587
  requirements:
574
- - - ">"
588
+ - - ">="
575
589
  - !ruby/object:Gem::Version
576
- hash: 25
590
+ hash: 3
577
591
  segments:
578
- - 1
579
- - 3
580
- - 1
581
- version: 1.3.1
592
+ - 0
593
+ version: "0"
582
594
  requirements: []
583
595
 
584
596
  rubyforge_project:
585
- rubygems_version: 1.8.10
597
+ rubygems_version: 1.8.24
586
598
  signing_key:
587
599
  specification_version: 3
588
600
  summary: RhoSync Synchronization Framework