rhoconnect 4.0.0.beta.12 → 4.0.0.beta.24

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. data/CHANGELOG.md +34 -0
  2. data/Gemfile +5 -8
  3. data/Gemfile.lock +34 -32
  4. data/Rakefile +2 -12
  5. data/bench/run_bench.sh +1 -1
  6. data/bench/spec/bench_spec_helper.rb +3 -5
  7. data/bin/rhoconnect +20 -13
  8. data/commands/dtach/dtach_install.rb +3 -3
  9. data/commands/generators/update.rb +1 -0
  10. data/commands/parser.rb +180 -0
  11. data/commands/rhoconnect/config.rb +8 -4
  12. data/commands/rhoconnect/get_token.rb +3 -1
  13. data/commands/rhoconnect/routes.rb +34 -0
  14. data/commands/rhoconnect/secret.rb +1 -1
  15. data/commands/rhoconnect/set_admin_password.rb +2 -1
  16. data/commands/rhoconnect/startbg.rb +4 -4
  17. data/commands/rhoconnect/stop.rb +2 -2
  18. data/commands/rhoconnect_console/console.rb +6 -6
  19. data/commands/rhoconnect_spec/spec.rb +2 -1
  20. data/commands/rhoconnect_war/war.rb +1 -0
  21. data/commands/utilities/redis_runner.rb +2 -2
  22. data/doc/data-partitioning.txt +20 -7
  23. data/doc/extending-rhoconnect-server.txt +36 -7
  24. data/doc/push-client-setup-rps.txt +3 -3
  25. data/doc/source-adapters-js.txt +41 -4
  26. data/doc/source-adapters.txt +3 -0
  27. data/generators/templates/application/rcgemfile +1 -5
  28. data/generators/templates/application/spec/spec_helper.rb +0 -9
  29. data/generators/templates/source/models/js/model.js +8 -0
  30. data/generators/templates/source/models/ruby/model.rb +5 -11
  31. data/install.sh +2 -2
  32. data/installer/unix-like/rho_connect_install_constants.rb +3 -3
  33. data/installer/utils/delete_from_s3.rb +3 -6
  34. data/installer/utils/download_from_s3.rb +5 -9
  35. data/installer/utils/verify_checksum.rb +16 -11
  36. data/js-adapters/ballroom.js +9 -0
  37. data/js-adapters/exceptions.js +60 -0
  38. data/js-adapters/node.rb +14 -5
  39. data/js-adapters/node_channel.rb +68 -48
  40. data/js-adapters/rhoconnect_helpers.js +8 -2
  41. data/js-adapters/router.js +16 -14
  42. data/lib/rhoconnect.rb +5 -5
  43. data/lib/rhoconnect/client.rb +2 -2
  44. data/lib/rhoconnect/condition/add_parameter.rb +21 -0
  45. data/lib/rhoconnect/controller/clients_controller.rb +1 -1
  46. data/lib/rhoconnect/controller/js_base.rb +1 -2
  47. data/lib/rhoconnect/controller/system_controller.rb +33 -10
  48. data/lib/rhoconnect/db_adapter.rb +1 -1
  49. data/lib/rhoconnect/document.rb +11 -3
  50. data/lib/rhoconnect/handler/changes.rb +20 -19
  51. data/lib/rhoconnect/handler/changes/engine.rb +48 -25
  52. data/lib/rhoconnect/handler/changes/hooks.rb +36 -0
  53. data/lib/rhoconnect/handler/changes/runner.rb +12 -2
  54. data/lib/rhoconnect/handler/helpers.rb +4 -4
  55. data/lib/rhoconnect/jobs/source_job.rb +1 -1
  56. data/lib/rhoconnect/model/base.rb +32 -8
  57. data/lib/rhoconnect/model/helpers.rb +15 -0
  58. data/lib/rhoconnect/model/helpers/find_duplicates_on_update.rb +85 -0
  59. data/lib/rhoconnect/model/js_base.rb +23 -28
  60. data/lib/rhoconnect/server.rb +23 -18
  61. data/lib/rhoconnect/source.rb +10 -17
  62. data/lib/rhoconnect/store.rb +36 -57
  63. data/lib/rhoconnect/test_methods.rb +5 -4
  64. data/lib/rhoconnect/utilities.rb +7 -5
  65. data/lib/rhoconnect/version.rb +2 -2
  66. data/lib/rhoconnect/web-console/server.rb +17 -16
  67. data/rhoconnect.gemspec +23 -24
  68. data/spec/apps/rhotestapp/controllers/js/js_sample_controller.js +4 -0
  69. data/spec/apps/rhotestapp/models/js/js_sample.js +36 -0
  70. data/spec/apps/rhotestapp/models/ruby/sample_adapter.rb +34 -19
  71. data/spec/async_spec.rb +1 -1
  72. data/spec/cli/cli_spec.rb +69 -31
  73. data/spec/client_sync_spec.rb +30 -13
  74. data/spec/controllers/js_base_spec.rb +10 -4
  75. data/spec/jobs/source_job_spec.rb +1 -1
  76. data/spec/models/{js_model_spec.rb → js_base_spec.rb} +63 -13
  77. data/spec/server/server_spec.rb +20 -0
  78. data/spec/server/stats_spec.rb +7 -17
  79. data/spec/source_adapter_spec.rb +6 -0
  80. data/spec/source_sync_spec.rb +219 -54
  81. data/spec/spec_helper.rb +8 -13
  82. data/spec/store_spec.rb +6 -4
  83. data/spec/test_methods_spec.rb +4 -4
  84. metadata +14 -27
  85. data/commands/execute.rb +0 -48
  86. data/commands/utilities/utilities.rb +0 -6
  87. data/generators/templates/application/controllers/application_controller.rb +0 -17
  88. data/lib/rhoconnect/js_adapter.rb +0 -79
@@ -2,17 +2,16 @@ require 'rubygems'
2
2
  require 'rspec'
3
3
  require 'webmock/rspec'
4
4
  require 'rspec/autorun' # Required for Rcov to run with rspec '~> 2.8.0'
5
- if RUBY_VERSION =~ /1.9/ || defined?(JRUBY_VERSION)
6
- require 'simplecov'
7
- require 'simplecov-rcov'
8
- SimpleCov.formatter = SimpleCov::Formatter::RcovFormatter
9
- SimpleCov.start do
10
- add_filter '/spec/'
11
- end
5
+
6
+ require 'simplecov'
7
+ require 'simplecov-rcov'
8
+ SimpleCov.formatter = SimpleCov::Formatter::RcovFormatter
9
+ SimpleCov.start do
10
+ add_filter '/spec/'
12
11
  end
13
12
 
14
13
  # all specs are Async'd in new ruby
15
- if RUBY_VERSION =~ /1.9/ and not defined?(JRUBY_VERSION)
14
+ if not defined?(JRUBY_VERSION)
16
15
  require 'eventmachine'
17
16
  require 'fiber'
18
17
 
@@ -137,11 +136,7 @@ module TestHelpers
137
136
  end
138
137
 
139
138
  def setup_post_yield(response)
140
- if RUBY_VERSION =~ /1.9/ or defined?(JRUBY_VERSION)
141
- RestClient.stub!(:post).and_yield(response, nil, nil)
142
- else
143
- RestClient.stub!(:post).and_yield(response)
144
- end
139
+ RestClient.stub!(:post).and_yield(response, nil, nil)
145
140
  end
146
141
 
147
142
  def set_state(state,append=false)
@@ -200,7 +200,7 @@ describe "Store" do
200
200
  end
201
201
 
202
202
  it "should put_zdata and get_zdata" do
203
- create_doc = {'1' => {'foo' => 'bar'}}
203
+ create_doc = [[@s.name, [['1', {'foo' => 'bar'}]]]]
204
204
  assoc_key = 'my_assoc_key'
205
205
  Store.put_zdata('doc1',assoc_key,create_doc)
206
206
  zdata,keys = Store.get_zdata('doc1')
@@ -215,7 +215,7 @@ describe "Store" do
215
215
  end
216
216
 
217
217
  it "should append duplicate data in put_zdata" do
218
- create_doc = {'1' => {'foo' => 'bar'}}
218
+ create_doc = [[@s.name, [['1', {'foo' => 'bar'}]]]]
219
219
  assoc_key = 'my_assoc_key'
220
220
  Store.put_zdata('doc1',assoc_key,create_doc)
221
221
  Store.put_zdata('doc1',assoc_key,create_doc, true)
@@ -225,14 +225,16 @@ describe "Store" do
225
225
  end
226
226
 
227
227
  it "should flush_zdata" do
228
- create_doc = {'1' => {'foo' => 'bar'}}
228
+ create_doc = [[@s.name, [['1', {'foo' => 'bar'}]]]]
229
229
  assoc_key = 'my_assoc_key'
230
230
  Store.put_zdata('doc1',assoc_key,create_doc)
231
+ zdocs = Store.get_data("doc1:1:my_assoc_key:#{@s.name}:0")
232
+ zdocs.should == {'0_1' => {'foo' => 'bar'}}
231
233
  Store.flush_zdata('doc1')
232
234
  zdata,keys = Store.get_zdata('doc1')
233
235
  zdata.should == []
234
236
  keys.should == []
235
- zdocs = Store.get_data('doc1:1:my_assoc_key:1')
237
+ zdocs = Store.get_data("doc1:1:my_assoc_key:#{@s.name}:0")
236
238
  zdocs.should == {}
237
239
  end
238
240
 
@@ -89,14 +89,14 @@ describe "TestMethods" do
89
89
  it "should include test_update helper" do
90
90
  record = {'4'=> { 'price' => '199.99' }}
91
91
  test_update(record)
92
- verify_source_queue_data(@s, :update => [])
92
+ verify_source_queue_data(@s, "update:post:/" => [])
93
93
  end
94
94
 
95
95
  it "should include test_update helper when pass through" do
96
96
  record = {'4'=> { 'price' => '199.99' }}
97
97
  @s.pass_through = 'true'
98
98
  test_update(record).should == {'processed' => ["4"]}.to_json
99
- verify_source_queue_data(@s, :update => [])
99
+ verify_source_queue_data(@s, "update:post:/" => [])
100
100
  end
101
101
 
102
102
  it "should include update_errors helper" do
@@ -108,14 +108,14 @@ describe "TestMethods" do
108
108
  it "should include test_delete helper" do
109
109
  record = {'4'=> { 'price' => '199.99' }}
110
110
  test_delete(record)
111
- verify_source_queue_data(@s, :delete => [])
111
+ verify_source_queue_data(@s, "delete:post:/" => [])
112
112
  end
113
113
 
114
114
  it "should include test_delete helper when pass through" do
115
115
  record = {'4'=> { 'price' => '199.99' }}
116
116
  @s.pass_through = 'true'
117
117
  test_delete(record).should == {'processed' => ["4"]}.to_json
118
- verify_source_queue_data(@s, :delete => [])
118
+ verify_source_queue_data(@s, "delete:post:/" => [])
119
119
  end
120
120
 
121
121
  it "should include delete_errors helper" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rhoconnect
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0.beta.12
4
+ version: 4.0.0.beta.24
5
5
  prerelease: 6
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: 2013-04-26 00:00:00.000000000 Z
12
+ date: 2013-06-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -210,7 +210,7 @@ dependencies:
210
210
  requirements:
211
211
  - - ~>
212
212
  - !ruby/object:Gem::Version
213
- version: 0.15.0
213
+ version: 0.18.0
214
214
  type: :runtime
215
215
  prerelease: false
216
216
  version_requirements: !ruby/object:Gem::Requirement
@@ -218,23 +218,7 @@ dependencies:
218
218
  requirements:
219
219
  - - ~>
220
220
  - !ruby/object:Gem::Version
221
- version: 0.15.0
222
- - !ruby/object:Gem::Dependency
223
- name: ohm
224
- requirement: !ruby/object:Gem::Requirement
225
- none: false
226
- requirements:
227
- - - ~>
228
- - !ruby/object:Gem::Version
229
- version: 0.1.3
230
- type: :runtime
231
- prerelease: false
232
- version_requirements: !ruby/object:Gem::Requirement
233
- none: false
234
- requirements:
235
- - - ~>
236
- - !ruby/object:Gem::Version
237
- version: 0.1.3
221
+ version: 0.18.0
238
222
  description: RhoConnect App Integration Server and related command-line utilities
239
223
  email: dev@rhomobile.com
240
224
  executables:
@@ -336,6 +320,7 @@ files:
336
320
  - commands/rhoconnect/config.rb
337
321
  - commands/rhoconnect/web.rb
338
322
  - commands/rhoconnect/set_admin_password.rb
323
+ - commands/rhoconnect/routes.rb
339
324
  - commands/rhoconnect/startbg.rb
340
325
  - commands/rhoconnect/flushdb.rb
341
326
  - commands/rhoconnect/startdebug.rb
@@ -346,17 +331,16 @@ files:
346
331
  - commands/rhoconnect_attach/attach.rb
347
332
  - commands/rhoconnect_spec/spec.rb
348
333
  - commands/utilities/redis_runner.rb
349
- - commands/utilities/utilities.rb
350
334
  - commands/utilities/blank_app.ru
351
335
  - commands/generators/app.rb
352
336
  - commands/generators/controller.rb
353
337
  - commands/generators/model.rb
354
338
  - commands/generators/source.rb
355
339
  - commands/generators/update.rb
356
- - commands/execute.rb
357
340
  - commands/rhoconnect_war/war.rb
358
341
  - commands/rhoconnect_console/console.rb
359
342
  - commands/rhoconnect_console/console_helper.rb
343
+ - commands/parser.rb
360
344
  - commands/redis/redis_download.rb
361
345
  - commands/redis/redis_make.rb
362
346
  - commands/redis/redis_restart.rb
@@ -444,7 +428,6 @@ files:
444
428
  - generators/templates/application/spec/spec_helper.rb
445
429
  - generators/templates/application/spec/application_controller_spec.rb
446
430
  - generators/templates/application/config.ru
447
- - generators/templates/application/controllers/application_controller.rb
448
431
  - generators/templates/application/controllers/js/application_controller.js
449
432
  - generators/templates/application/controllers/ruby/application_controller.rb
450
433
  - generators/templates/application/Rakefile
@@ -517,6 +500,7 @@ files:
517
500
  - lib/rhoconnect/handler/changes/pass_through_runner.rb
518
501
  - lib/rhoconnect/handler/changes/execute_methods.rb
519
502
  - lib/rhoconnect/handler/changes/runner.rb
503
+ - lib/rhoconnect/handler/changes/hooks.rb
520
504
  - lib/rhoconnect/handler/changes/engine.rb
521
505
  - lib/rhoconnect/lock_ops.rb
522
506
  - lib/rhoconnect/utilities.rb
@@ -525,9 +509,11 @@ files:
525
509
  - lib/rhoconnect/document.rb
526
510
  - lib/rhoconnect/license.rb
527
511
  - lib/rhoconnect/test_methods.rb
512
+ - lib/rhoconnect/model/helpers/find_duplicates_on_update.rb
528
513
  - lib/rhoconnect/model/dynamic_adapter_model.rb
529
514
  - lib/rhoconnect/model/base.rb
530
515
  - lib/rhoconnect/model/js_base.rb
516
+ - lib/rhoconnect/model/helpers.rb
531
517
  - lib/rhoconnect/server.rb
532
518
  - lib/rhoconnect/middleware/body_content_type_parser.rb
533
519
  - lib/rhoconnect/middleware/cors.rb
@@ -536,7 +522,6 @@ files:
536
522
  - lib/rhoconnect/middleware/stats.rb
537
523
  - lib/rhoconnect/middleware/current_app.rb
538
524
  - lib/rhoconnect/middleware/x_domain_session_wrapper.rb
539
- - lib/rhoconnect/js_adapter.rb
540
525
  - lib/rhoconnect/client.rb
541
526
  - lib/rhoconnect/rho_indifferent_access.rb
542
527
  - lib/rhoconnect/controller/sources_controller.rb
@@ -556,6 +541,7 @@ files:
556
541
  - lib/rhoconnect/bulk_data/bulk_data.rb
557
542
  - lib/rhoconnect/condition/verbs.rb
558
543
  - lib/rhoconnect/condition/verify_success.rb
544
+ - lib/rhoconnect/condition/add_parameter.rb
559
545
  - lib/rhoconnect/condition/admin_required.rb
560
546
  - lib/rhoconnect/condition/client_required.rb
561
547
  - lib/rhoconnect/condition/source_required.rb
@@ -636,6 +622,7 @@ files:
636
622
  - js-adapters/rhoconnect_helpers.js
637
623
  - js-adapters/request.js
638
624
  - js-adapters/response.js
625
+ - js-adapters/exceptions.js
639
626
  - tasks/jasmine.rake
640
627
  - tasks/redis.rake
641
628
  - spec/jobs/source_job_spec.rb
@@ -675,7 +662,7 @@ files:
675
662
  - spec/perf/store_perf_spec.rb
676
663
  - spec/rhoconnect_spec.rb
677
664
  - spec/user_spec.rb
678
- - spec/models/js_model_spec.rb
665
+ - spec/models/js_base_spec.rb
679
666
  - spec/server/cors_spec.rb
680
667
  - spec/server/x_domain_session_wrapper_spec.rb
681
668
  - spec/server/stats_spec.rb
@@ -788,7 +775,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
788
775
  version: '0'
789
776
  segments:
790
777
  - 0
791
- hash: -420963856285787510
778
+ hash: 3543928944342720211
792
779
  required_rubygems_version: !ruby/object:Gem::Requirement
793
780
  none: false
794
781
  requirements:
@@ -839,7 +826,7 @@ test_files:
839
826
  - spec/perf/store_perf_spec.rb
840
827
  - spec/rhoconnect_spec.rb
841
828
  - spec/user_spec.rb
842
- - spec/models/js_model_spec.rb
829
+ - spec/models/js_base_spec.rb
843
830
  - spec/server/cors_spec.rb
844
831
  - spec/server/x_domain_session_wrapper_spec.rb
845
832
  - spec/server/stats_spec.rb
@@ -1,48 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'rubygems'
4
- require 'thor'
5
- require 'json'
6
- require 'uri'
7
- $:.unshift File.join(File.dirname(__FILE__), '.')
8
- $:.unshift File.join(File.dirname(__FILE__), '..')
9
- require 'lib/rhoconnect/utilities'
10
- require 'lib/rhoconnect'
11
- require 'utilities/utilities'
12
- require 'utilities/redis_runner'
13
-
14
- include Utilities
15
-
16
- settings_file = File.join(File.dirname(__FILE__), '..', 'generators', 'templates', 'application', 'settings', "settings.yml")
17
- options = load_settings(settings_file)[Rhoconnect.environment]
18
- RHOCONNECT_PORT = URI.parse(options[:syncserver]).port
19
- REDIS_SERVER_URL = options[:redis]
20
- PUSH_SERVER_URL = options[:push_server]
21
- API_TOKEN = options[:api_token]
22
-
23
- class Execute < Thor
24
- no_tasks {
25
- def self.define_task(&block)
26
- Execute.class_eval(&block)
27
- end
28
- }
29
-
30
- tasks = [ 'generators', 'rhoconnect', 'redis' ]
31
- unless windows?
32
- tasks << 'dtach'
33
- tasks << 'rhoconnect_attach' unless jruby?
34
- end
35
- tasks << if jruby? then "rhoconnect_war" else "rhoconnect_console" end
36
- # 'rhoconnect spec' command is available only if it called from root of
37
- # rhoconnect app and its bundle includes 'rspec' gem
38
- if File.exists?(File.join(Dir.pwd,'Gemfile'))
39
- require 'bundler'
40
- tasks << 'rhoconnect_spec' if Bundler.load.specs.find{ |s| s.name == 'rspec' }
41
- end
42
-
43
- tasks.each do |dir|
44
- Dir.glob(File.join(File.dirname(__FILE__), "#{dir}", "*.rb")) do |file|
45
- require file
46
- end
47
- end
48
- end
@@ -1,6 +0,0 @@
1
- module Utilities
2
- def dtach_installed?
3
- return false if windows? # dtach n/a on Windows
4
- `which dtach` != ''
5
- end
6
- end
@@ -1,17 +0,0 @@
1
- class ApplicationController < Rhoconnect::Controller::AppBase
2
- register Rhoconnect::EndPoint
3
-
4
- post "/login", :rc_handler => :authenticate,
5
- :deprecated_route => {:verb => :post, :url => ['/application/clientlogin', '/api/application/clientlogin']} do
6
- login = params[:login]
7
- password = params[:password]
8
- true # do some interesting authentication here...
9
- end
10
-
11
- get "/rps_login", :rc_handler => :rps_authenticate,
12
- :login_required => true do
13
- login = params[:login]
14
- password = params[:password]
15
- true # optionally handle rhoconnect push authentication...
16
- end
17
- end
@@ -1,79 +0,0 @@
1
- # module Rhoconnect
2
- # class JsAdapter < SourceAdapter
3
- # attr_accessor :name
4
- #
5
- # def initialize(source)
6
- # @source = source
7
- # @name = source.name
8
- # end
9
- #
10
- # def self.method_missing method_name, *args
11
- # #grab function and args and publish to channel
12
- # begin
13
- # json = create_json_hash(method_name,args)
14
- # NodeChannel.publish_channel_and_wait(json)
15
- # rescue Exception => e
16
- # puts "#{method_name error} - #{e.message}"
17
- # end
18
- # end
19
- #
20
- # def login(params=nil)
21
- # begin
22
- # json = create_json_hash('get',params)
23
- # NodeChannel.publish_channel_and_wait(json)
24
- # rescue Exception=>e
25
- # puts "error login #{e.message}\n #{e.backtrace}"
26
- # end
27
- # end
28
- #
29
- # def query(params=nil)
30
- # begin
31
- # json = create_json_hash('get',params)
32
- # @result = NodeChannel.publish_channel_and_wait(json)
33
- # puts "res is ******* #{@result}"
34
- # @result
35
- # rescue Exception=>e
36
- # puts "error query #{e.message}\n#{e.backtrace}"
37
- # end
38
- # end
39
- #
40
- # # def search(params=nil)
41
- # # json = create_json_hash('search',params)
42
- # # NodeChannel.publish_channel_and_wait(json)
43
- # # end
44
- #
45
- # # def sync
46
- # # @result
47
- # # super
48
- # # end
49
- #
50
- # def create(create_hash)
51
- # json = create_json_hash('post',create_hash)
52
- # NodeChannel.publish_channel_and_wait(json)
53
- # end
54
- #
55
- # def update(update_hash)
56
- # puts "update hash is #{update_hash}"
57
- # json = create_json_hash('put',update_hash)
58
- # NodeChannel.publish_channel_and_wait(json)
59
- # end
60
- #
61
- # def delete(delete_hash)
62
- # puts "create hash is #{delete_hash}"
63
- # json = create_json_hash('delete',delete_hash)
64
- # NodeChannel.publish_channel_and_wait(json)
65
- # end
66
- #
67
- #
68
- # private
69
- #
70
- # def create_json_hash(operation,params)
71
- # json = {
72
- # :url => "#{operation}-/#{@name}",
73
- # :args => params,
74
- # :route => 'request'
75
- # }
76
- # end
77
- # end
78
- #
79
- # end