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
@@ -1,3 +1,32 @@
1
+ ## 4.0.0.beta.24 (2013-06-07)
2
+ * Add /system/rps_login route to handle application credentials for push server
3
+ * Update doc for 'rhoconnect-push' config.json advanced options
4
+
5
+ ## 4.0.0.beta.18-23 (skipped for RMS version parity)
6
+
7
+ ## 4.0.0.beta.17 (2013-05-28)
8
+ * B-103375 - Added `rhoconnect routes` command
9
+ * D-05133 - Node.js process detection logic fails on windows
10
+ * Update production stack to ruby-1.9.3-p429
11
+ * D-05169 - Fixed issue where default options can't be overridden in JS controllers
12
+ * D-05223 - Support non-hash result value (needed for stashResult)
13
+ * Fixed recursive infinite loop in the CUD Source Job
14
+ * B-100517 - Added `find_duplicates_on_update` flag for update duplicate detection
15
+
16
+ ## 4.0.0.beta.16 (skipped for RMS version parity)
17
+
18
+ ## 4.0.0.beta.15 (skipped for RMS version parity)
19
+
20
+ ## 4.0.0.beta.14 (2013-05-14)
21
+ * B-101474 - Remove Ruby 1.8.7 support
22
+ * D-04477 - Rack::Session::Cookie security warning printing on every http request
23
+ * B-106356 - Update nginx package to 1.4.1 (CVE-2013-2028)
24
+ * B-105908 - Additional JS API methods: partitionName and exceptions
25
+ * B-105504 - Boilerplate handling of store blob function should return error
26
+ * TK-190698 - Support generic CUD queue (multi-source and interim states)
27
+
28
+ ## 4.0.0.beta.13 (skipped for RMS version parity)
29
+
1
30
  ## 4.0.0.beta.12 (2013-04-26)
2
31
  * B-104783 - Add Node package dependency for Ubuntu/CentOS packages
3
32
  * B-91486 - Redis custom partitions
@@ -68,6 +97,11 @@
68
97
  * Update rhoconnect prod stack to ruby-1.9.3-p374
69
98
  * Updated RhoConnect CLI: server is capable to start from any directory and accepts parameters (port, redis URL, and others)
70
99
 
100
+ ## 3.4.5 (2013-05-14)
101
+ * TK-182435 - Run platform validation in parallel (both nightly tests and release jobs)
102
+ * D-04477 - Rack::Session::Cookie security warning printing on every http request
103
+ * B-106356 - Update nginx package to 1.4.1 (CVE-2013-2028)
104
+
71
105
  ## 3.4.4 (2013-02-27)
72
106
  * Updated prod. stack to ruby-1.9.3-p392, redis-2.6.10, and nginx-1.3.13.
73
107
 
data/Gemfile CHANGED
@@ -6,15 +6,12 @@ gemspec
6
6
  gem 'win32-process', :platforms => [:mswin, :mingw]
7
7
 
8
8
  # use thin and eventmachine everywhere except JRuby
9
- platforms :ruby, :ruby_19, :mingw, :mingw_19 do
9
+ platforms :ruby, :mingw do
10
10
  gem "eventmachine", "~> 1.0.0"
11
11
  # using thin by default
12
12
  gem 'thin'
13
- end
14
-
15
13
  # for async framework
16
14
  # for Async, Eventful execution
17
- platforms :ruby_19, :mingw_19 do
18
15
  gem 'rack-fiber_pool'
19
16
  gem 'async-rack'
20
17
  end
@@ -32,10 +29,10 @@ group :development do
32
29
  # gem 'debugger'
33
30
  gem 'aws-s3', '>= 0.6.2', :require => 'aws/s3'
34
31
  gem 'sqlite3', ">= 1.3.3", :platforms => [:ruby, :mswin, :mingw]
35
- gem 'fog', '>= 1.1.0'
32
+ gem "excon", "~> 0.22.1"
33
+ gem "fog", "~> 1.11.1"
36
34
  gem 'ffaker', '~> 1.14.0'
37
35
  gem 'webmock', '~> 1.9.0'
38
- gem 'SystemTimer', '~> 1.2.3', :platforms => :ruby_18
39
36
  end
40
37
 
41
38
  group :test do
@@ -43,8 +40,8 @@ group :test do
43
40
  gem 'simplecov', '>= 0.7.1', :require => false
44
41
  gem 'simplecov-rcov', '~> 0.2.3'
45
42
  gem 'rack-test', '~> 0.6', :require => 'rack/test'
46
- gem 'jasmine', :platforms => [:ruby_19,:jruby]
47
- gem 'jasmine-headless-webkit', :platforms => [:ruby_19,:jruby]
43
+ gem 'jasmine', :platforms => [:ruby,:jruby]
44
+ gem 'jasmine-headless-webkit', :platforms => [:ruby,:jruby]
48
45
  end
49
46
 
50
47
  group :build do
@@ -1,11 +1,10 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rhoconnect (4.0.0.beta.12)
4
+ rhoconnect (4.0.0.beta.24)
5
5
  bundler (~> 1.0)
6
6
  connection_pool (~> 1.0.0)
7
7
  json (~> 1.7.7)
8
- ohm (~> 0.1.3)
9
8
  rack (~> 1.5.2)
10
9
  rake (~> 10.0.0)
11
10
  redis (>= 3.0.1)
@@ -14,13 +13,12 @@ PATH
14
13
  rubyzip (~> 0.9.4)
15
14
  sinatra (~> 1.3)
16
15
  templater (~> 1.0.0)
17
- thor (~> 0.15.0)
16
+ thor (~> 0.18.0)
18
17
  uuidtools (>= 2.1.1)
19
18
 
20
19
  GEM
21
20
  remote: https://rubygems.org/
22
21
  specs:
23
- SystemTimer (1.2.3)
24
22
  addressable (2.3.4)
25
23
  arr-pm (0.0.8)
26
24
  cabin (> 0)
@@ -30,47 +28,55 @@ GEM
30
28
  builder
31
29
  mime-types
32
30
  xml-simple
33
- backports (2.6.2)
34
- builder (3.2.0)
31
+ backports (3.3.1)
32
+ builder (3.2.2)
35
33
  cabin (0.6.0)
36
34
  childprocess (0.3.9)
37
35
  ffi (~> 1.0, >= 1.0.11)
38
- clamp (0.3.1)
36
+ clamp (0.6.1)
39
37
  coffee-script (2.2.0)
40
38
  coffee-script-source
41
39
  execjs
42
40
  coffee-script-source (1.6.2)
43
41
  connection_pool (1.0.0)
44
- crack (0.3.2)
42
+ crack (0.4.0)
43
+ safe_yaml (~> 0.9.0)
45
44
  daemons (1.1.9)
46
45
  diff-lcs (1.1.3)
47
46
  eventmachine (1.0.3)
48
- excon (0.20.1)
47
+ excon (0.22.1)
49
48
  execjs (1.4.0)
50
49
  multi_json (~> 1.0)
51
50
  extlib (0.9.16)
52
51
  ffaker (1.14.0)
53
52
  ffi (1.8.1)
54
- fog (1.10.1)
53
+ fog (1.11.1)
55
54
  builder
56
55
  excon (~> 0.20)
57
56
  formatador (~> 0.2.0)
57
+ json (~> 1.7)
58
58
  mime-types
59
- multi_json (~> 1.0)
60
59
  net-scp (~> 1.1)
61
60
  net-ssh (>= 2.1.3)
62
61
  nokogiri (~> 1.5.0)
63
62
  ruby-hmac
64
63
  formatador (0.2.4)
65
- fpm (0.4.33)
64
+ fpm (0.4.37)
66
65
  arr-pm (~> 0.0.8)
67
- backports (= 2.6.2)
66
+ backports (>= 2.6.2)
68
67
  cabin (>= 0.6.0)
69
- clamp (= 0.3.1)
68
+ childprocess
69
+ clamp (~> 0.6)
70
+ ftw (~> 0.0.30)
70
71
  json (~> 1.7.7)
71
- open4
72
- highline (1.6.18)
73
- hike (1.2.2)
72
+ ftw (0.0.34)
73
+ addressable
74
+ backports (>= 2.6.2)
75
+ cabin (> 0)
76
+ http_parser.rb (= 0.5.3)
77
+ highline (1.6.19)
78
+ hike (1.2.3)
79
+ http_parser.rb (0.5.3)
74
80
  jasmine (1.3.2)
75
81
  jasmine-core (~> 1.3.1)
76
82
  rack (~> 1.0)
@@ -85,17 +91,12 @@ GEM
85
91
  sprockets (~> 2)
86
92
  json (1.7.7)
87
93
  mime-types (1.23)
88
- mono_logger (1.0.1)
89
- multi_json (1.7.2)
90
- nest (1.1.2)
91
- redis
92
- net-scp (1.1.0)
94
+ mono_logger (1.1.0)
95
+ multi_json (1.7.6)
96
+ net-scp (1.1.1)
93
97
  net-ssh (>= 2.6.5)
94
98
  net-ssh (2.6.7)
95
99
  nokogiri (1.5.9)
96
- ohm (0.1.5)
97
- nest (~> 1.0)
98
- open4 (1.3.0)
99
100
  rack (1.5.2)
100
101
  rack-fiber_pool (0.9.3)
101
102
  rack-protection (1.5.0)
@@ -105,7 +106,7 @@ GEM
105
106
  rainbow (1.1.4)
106
107
  rake (10.0.4)
107
108
  redis (3.0.4)
108
- redis-namespace (1.2.1)
109
+ redis-namespace (1.3.0)
109
110
  redis (~> 3.0.0)
110
111
  resque (1.24.1)
111
112
  mono_logger (~> 1.0)
@@ -125,7 +126,8 @@ GEM
125
126
  rspec-mocks (2.10.1)
126
127
  ruby-hmac (0.4.0)
127
128
  rubyzip (0.9.9)
128
- selenium-webdriver (2.32.1)
129
+ safe_yaml (0.9.3)
130
+ selenium-webdriver (2.33.0)
129
131
  childprocess (>= 0.2.5)
130
132
  multi_json (~> 1.0)
131
133
  rubyzip
@@ -140,7 +142,7 @@ GEM
140
142
  rack (~> 1.5, >= 1.5.2)
141
143
  rack-protection (~> 1.4)
142
144
  tilt (~> 1.3, >= 1.3.4)
143
- sprockets (2.9.3)
145
+ sprockets (2.10.0)
144
146
  hike (~> 1.2)
145
147
  multi_json (~> 1.0)
146
148
  rack (~> 1.0)
@@ -154,8 +156,8 @@ GEM
154
156
  daemons (>= 1.0.9)
155
157
  eventmachine (>= 0.12.6)
156
158
  rack (>= 1.0.0)
157
- thor (0.15.4)
158
- tilt (1.3.7)
159
+ thor (0.18.1)
160
+ tilt (1.4.1)
159
161
  uuidtools (2.1.4)
160
162
  vegas (0.1.11)
161
163
  rack (>= 1.0.0)
@@ -169,14 +171,14 @@ PLATFORMS
169
171
  ruby
170
172
 
171
173
  DEPENDENCIES
172
- SystemTimer (~> 1.2.3)
173
174
  async-rack
174
175
  aws-s3 (>= 0.6.2)
175
176
  dbd-jdbc (>= 0.1.4)
176
177
  dbi (>= 0.4.5)
177
178
  eventmachine (~> 1.0.0)
179
+ excon (~> 0.22.1)
178
180
  ffaker (~> 1.14.0)
179
- fog (>= 1.1.0)
181
+ fog (~> 1.11.1)
180
182
  fpm (>= 0.4.26)
181
183
  jasmine
182
184
  jasmine-headless-webkit
data/Rakefile CHANGED
@@ -48,11 +48,6 @@ begin
48
48
  RSpec::Core::RakeTask.new('spec:all') do |t|
49
49
  t.rspec_opts = ["-b", "-c", "-fd"]
50
50
  t.pattern = FileList[TYPES.values]
51
- unless RUBY_VERSION =~ /1.9/ || defined?(JRUBY_VERSION)
52
- require 'rcov/rcovtask'
53
- t.rcov = true
54
- t.rcov_opts = ['--exclude', 'spec/*,gems/*,apps/*,bench/spec/*,json/*']
55
- end
56
51
  end
57
52
 
58
53
  desc "Run doc generator - dumps out doc/protocol.html"
@@ -65,13 +60,8 @@ rescue LoadError => e
65
60
  # Array of groups whose gems are not installed
66
61
  # if bundle install called with the --without option
67
62
  unless Bundler.settings.without.include? :test
68
- if RUBY_VERSION =~ /1.9/
69
- puts "rspec / simplecov not available. Install with: "
70
- puts "gem install rspec simplecov\n\n"
71
- else
72
- puts "rspec / rcov not available. Install with: "
73
- puts "gem install rspec rcov\n\n"
74
- end
63
+ puts "rspec / simplecov not available. Install with: "
64
+ puts "gem install rspec simplecov\n\n"
75
65
  end
76
66
  end
77
67
 
@@ -33,7 +33,7 @@ redis-cli flushdb > /dev/null
33
33
 
34
34
  # Run benchmarks for ruby 1.8.7, ree, 1.9.2, and 1.9.3
35
35
  # TODO: 'jruby'
36
- for ruby in '1.9.3' '1.9.2' '1.8.7' 'ree'
36
+ for ruby in '1.9.3'
37
37
  do
38
38
  rvm use $ruby > /dev/null
39
39
  ruby_version=$(rvm current)
@@ -4,11 +4,9 @@ require 'excon'
4
4
  $:.unshift File.join(File.dirname(__FILE__),'..')
5
5
  $:.unshift File.join(File.dirname(__FILE__),'..','lib')
6
6
 
7
- if RUBY_VERSION =~ /1.9/ || defined?(JRUBY_VERSION)
8
- require 'simplecov'
9
- SimpleCov.start do
10
- add_filter '/spec/'
11
- end
7
+ require 'simplecov'
8
+ SimpleCov.start do
9
+ add_filter '/spec/'
12
10
  end
13
11
 
14
12
  require 'bench/logging'
@@ -1,18 +1,25 @@
1
1
  #!/usr/bin/env ruby -W0
2
- require 'rubygems'
2
+ require 'thor'
3
+ require_relative "../lib/rhoconnect/utilities"
4
+ include Utilities
3
5
 
4
- begin
5
- if File.exists?(File.join(Dir.pwd,'Gemfile'))
6
- require 'bundler'
7
- Bundler.require
8
- end
9
- $:.unshift File.join(File.dirname(__FILE__),'..')
10
- $:.unshift File.join(File.dirname(__FILE__),'..','lib')
11
- require 'templater'
12
- require 'generators/rhoconnect'
13
- require 'rhoconnect'
14
- require 'commands/execute'
6
+ # Default settings (template/settings/settings.yml)
7
+ RHOCONNECT_PORT = 9292
8
+ REDIS_SERVER_URL = "localhost:6379"
9
+ PUSH_SERVER_URL = "http://someappname@localhost:8675/"
10
+ API_TOKEN = "my-rhoconnect-token"
15
11
 
12
+ class Execute < Thor
13
+ no_tasks {
14
+ def self.define_task(&block)
15
+ Execute.class_eval(&block)
16
+ end
17
+ }
18
+
19
+ require_relative "../commands/parser"
20
+ end
21
+
22
+ begin
16
23
  Execute.start
17
24
  rescue SystemExit => se
18
25
  # This is normal
@@ -25,4 +32,4 @@ rescue Exception => e
25
32
  puts "Run rhoconnect command error: #{e.inspect}"
26
33
  puts e.backtrace.join("\n")
27
34
  end
28
- end
35
+ end
@@ -5,7 +5,7 @@ def fetch(uri_str, limit = 10)
5
5
 
6
6
  url = URI(uri_str)
7
7
  response = Net::HTTP.get_response(url)
8
-
8
+
9
9
  case response
10
10
  when Net::HTTPOK then
11
11
  Net::HTTP.start(url.host, url.port) do |http|
@@ -31,7 +31,7 @@ Execute.define_task do
31
31
  desc 'dtach-install', 'Install dtach program from sources'
32
32
  def dtach_install
33
33
  dtach_about
34
-
34
+
35
35
  unless windows?
36
36
  Dir.chdir('/tmp/')
37
37
  system "rm /tmp/dtach-0.8.tar.gz" if File.exists?('/tmp/dtach-0.8.tar.gz')
@@ -47,7 +47,7 @@ Execute.define_task do
47
47
  system 'cd /tmp/dtach-0.8/ && ./configure && make'
48
48
 
49
49
  ENV['PREFIX'] and bin_dir = "#{ENV['PREFIX']}/bin" or bin_dir = "#{RedisRunner.prefix}bin"
50
- mk_bin_dir(bin_dir)
50
+ mkdir_p(bin_dir) unless File.exists?(bin_dir)
51
51
  system "sudo cp /tmp/dtach-0.8/dtach #{bin_dir}"
52
52
 
53
53
  system "rm /tmp/dtach-0.8.tar.gz"
@@ -1,6 +1,7 @@
1
1
  Execute.define_task do
2
2
  desc "update", "Update an existing application to the latest rhoconnect release"
3
3
  def update
4
+ require 'bundler'
4
5
  Bundler.with_clean_env do
5
6
  `bundle install`
6
7
  end
@@ -0,0 +1,180 @@
1
+ # Matches all inputs
2
+ module InvalidCommand
3
+ def self.match?(input); true; end
4
+ def self.execute(input); end
5
+ end
6
+
7
+ # rhoconnect [help [cmd]]
8
+ module HelpCommand
9
+ def self.match?(input); (input == 'help'); end
10
+
11
+ def self.execute(input)
12
+ tasks = [ 'generators', 'rhoconnect', 'redis' ]
13
+ unless windows?
14
+ tasks << 'dtach'
15
+ tasks << 'rhoconnect_attach' unless jruby?
16
+ end
17
+ tasks << if jruby? then "rhoconnect_war" else "rhoconnect_console" end
18
+ tasks << 'rhoconnect_spec' if File.exists?(File.join(Dir.pwd,'Gemfile'))
19
+ tasks.each do |dir|
20
+ Dir.glob(File.join(File.dirname(__FILE__), "..", "commands", "#{dir}", "*.rb")) do |file|
21
+ next if windows? &&
22
+ ["redis_download.rb", "redis_install.rb", "redis_make.rb"].include?(File.basename(file))
23
+ require file
24
+ end
25
+ end
26
+ end
27
+ end
28
+
29
+ # rhoconnect start|stop|restart|...
30
+ module RunTimeCommands
31
+ def self.match?(input)
32
+ %w[start stop restart startbg startdebug].include?(input)
33
+ end
34
+ def self.execute(input)
35
+ if File.exists?(File.join(Dir.pwd,'Gemfile')) && input =~ /start/
36
+ require 'bundler'
37
+ Bundler.require
38
+ end
39
+ require_relative '../commands/rhoconnect/config'
40
+ require_relative '../commands/utilities/redis_runner'
41
+ %w[start stop restart startbg startdebug].each { |f| require_relative "../commands/rhoconnect/#{f}" }
42
+ end
43
+ end
44
+
45
+ # Group of rhconnect redis-*
46
+ module RedisCommands
47
+ def self.match?(input); input =~ /^redis/; end
48
+ def self.execute(input)
49
+ require_relative '../commands/utilities/redis_runner'
50
+ require_relative '../commands/rhoconnect/config'
51
+ %w[about start startbg restart stop status].each { |f| require_relative "../commands/redis/redis_#{f}" }
52
+ unless windows?
53
+ %w[download install make].each { |f| require_relative "../commands/redis/redis_#{f}" }
54
+ require_relative '../commands/dtach/redis_attach'
55
+ end
56
+ end
57
+ end
58
+
59
+ # rhoconnect app|source|...
60
+ module GeneratorCommands
61
+ def self.match?(input); %w[app controller model source update].include?(input); end
62
+ def self.execute(input)
63
+ require_relative "../generators/rhoconnect"
64
+ require_relative '../lib/rhoconnect'
65
+ include Rhoconnect
66
+ %w[app controller model source update].each { |f| require_relative "../commands/generators/#{f}" }
67
+ end
68
+ end
69
+
70
+ # rhoconnect version
71
+ module VersionCommand
72
+ def self.match?(input); input == 'version'; end
73
+ def self.execute(input)
74
+ require_relative '../lib/rhoconnect/version'
75
+ include Rhoconnect
76
+ require_relative '../commands/rhoconnect/version'
77
+ end
78
+ end
79
+
80
+ # rhoconnect secret
81
+ module SecretCommand
82
+ def self.match?(input); input == 'secret'; end
83
+ def self.execute(input); require_relative '../commands/rhoconnect/secret'; end
84
+ end
85
+
86
+ # rhoconnect console
87
+ module ConsoleCommand
88
+ def self.match?(input); input == 'console'; end
89
+ def self.execute(input)
90
+ unless jruby?
91
+ require_relative '../commands/utilities/redis_runner'
92
+ require_relative '../commands/rhoconnect_console/console'
93
+ end
94
+ end
95
+ end
96
+
97
+ # rhoconnect web
98
+ module WebCommand
99
+ def self.match?(input); input == 'web'; end
100
+ def self.execute(input)
101
+ require_relative '../commands/rhoconnect/config'
102
+ require_relative '../commands/rhoconnect/web'
103
+ end
104
+ end
105
+
106
+ # rhoconnect war
107
+ module WarCommand
108
+ def self.match?(input); input == 'war'; end
109
+ def self.execute(input); require_relative '../commands/rhoconnect_war/war' if jruby?; end
110
+ end
111
+
112
+ # rhoconnect dtach-*
113
+ module DtachCommands
114
+ def self.match?(input); input =~ /^dtach/ || input == 'attach'; end
115
+ def self.execute(input)
116
+ unless windows?
117
+ require_relative '../commands/utilities/redis_runner'
118
+ require_relative '../commands/dtach/dtach_about'
119
+ require_relative '../commands/dtach/dtach_install'
120
+ require_relative '../commands/rhoconnect_attach/attach' unless jruby?
121
+ end
122
+ end
123
+ end
124
+
125
+ # rhoconnect flushdb
126
+ module FlushdbCommand
127
+ def self.match?(input); input == 'flushdb'; end
128
+ def self.execute(input)
129
+ require_relative '../commands/rhoconnect/config'
130
+ require_relative '../commands/utilities/redis_runner'
131
+ require_relative '../commands/rhoconnect/flushdb'
132
+ end
133
+ end
134
+
135
+ # rhoconnect get-token|set-admin-password
136
+ module AdminCommands
137
+ def self.match?(input); input == 'get-token' || input == 'set_admin_password'; end
138
+ def self.execute(input)
139
+ require_relative '../commands/rhoconnect/config'
140
+ require_relative '../commands/rhoconnect/get_token'
141
+ require_relative '../commands/rhoconnect/set_admin_password'
142
+ end
143
+ end
144
+
145
+ # rhoconnect routes
146
+ module RoutesCommand
147
+ def self.match?(input); input == 'routes'; end
148
+ def self.execute(input)
149
+ if File.exists?(File.join(Dir.pwd,'Gemfile'))
150
+ require 'bundler'
151
+ Bundler.require
152
+ end
153
+ require_relative '../commands/rhoconnect/config'
154
+ require_relative '../commands/utilities/redis_runner'
155
+ require_relative '../commands/rhoconnect/routes'
156
+ end
157
+ end
158
+
159
+ # rhoconnect spec
160
+ module SpecCommand
161
+ def self.match?(input); input == 'spec'; end
162
+ def self.execute(input)
163
+ if File.exists?(File.join(Dir.pwd,'Gemfile'))
164
+ require 'bundler'
165
+ Bundler.require
166
+ require_relative '../commands/rhoconnect_spec/spec' if Bundler.load.specs.find{ |s| s.name == 'rspec' }
167
+ end
168
+ end
169
+ end
170
+
171
+ commands = [
172
+ HelpCommand, RunTimeCommands, RedisCommands, GeneratorCommands, VersionCommand,
173
+ SecretCommand, ConsoleCommand, WebCommand, WarCommand, DtachCommands,
174
+ FlushdbCommand, AdminCommands, RoutesCommand, SpecCommand, InvalidCommand ]
175
+
176
+ input = ARGV[0] ? ARGV[0] : 'help'
177
+ # Process user input
178
+ command = commands.find { |cmd| cmd.match?(input) }
179
+ # Load code that matches selected command
180
+ command.execute(input)