cucumba 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. data/History.md +33 -0
  2. data/Manifest.txt +79 -0
  3. data/PostInstall.txt +7 -0
  4. data/README.rdoc +59 -0
  5. data/Rakefile +33 -0
  6. data/config/website.yml.sample +2 -0
  7. data/cucumba.gemspec +52 -0
  8. data/generators/cucumba/USAGE +9 -0
  9. data/generators/cucumba/cucumba_generator.rb +23 -0
  10. data/generators/cucumba/templates/config.yml +15 -0
  11. data/generators/cucumba/templates/cucumba +18 -0
  12. data/lib/cucumba.rb +49 -0
  13. data/lib/cucumba/drb.rb +52 -0
  14. data/lib/cucumba/rails.rb +60 -0
  15. data/lib/cucumba/rails/model.rb +26 -0
  16. data/lib/cucumba/rails/runner.rb +73 -0
  17. data/lib/cucumba/server.rb +14 -0
  18. data/script/console +10 -0
  19. data/script/destroy +14 -0
  20. data/script/generate +14 -0
  21. data/script/txt2html +71 -0
  22. data/spec/cucumba_configuration_spec.rb +97 -0
  23. data/spec/cucumba_spec_rails.rb +59 -0
  24. data/spec/spec.opts +1 -0
  25. data/spec/spec_helper.rb +23 -0
  26. data/spec/support/sample_app/README +1 -0
  27. data/spec/support/sample_app/Rakefile +10 -0
  28. data/spec/support/sample_app/app/controllers/application_controller.rb +4 -0
  29. data/spec/support/sample_app/app/controllers/users_controller.rb +83 -0
  30. data/spec/support/sample_app/app/helpers/application_helper.rb +2 -0
  31. data/spec/support/sample_app/app/helpers/users_helper.rb +2 -0
  32. data/spec/support/sample_app/app/models/user.rb +9 -0
  33. data/spec/support/sample_app/app/views/layouts/users.html.erb +17 -0
  34. data/spec/support/sample_app/app/views/users/edit.html.erb +20 -0
  35. data/spec/support/sample_app/app/views/users/index.html.erb +22 -0
  36. data/spec/support/sample_app/app/views/users/new.html.erb +19 -0
  37. data/spec/support/sample_app/app/views/users/show.html.erb +13 -0
  38. data/spec/support/sample_app/config/boot.rb +110 -0
  39. data/spec/support/sample_app/config/database.yml +22 -0
  40. data/spec/support/sample_app/config/environment.rb +12 -0
  41. data/spec/support/sample_app/config/environments/development.rb +17 -0
  42. data/spec/support/sample_app/config/environments/production.rb +28 -0
  43. data/spec/support/sample_app/config/environments/test.rb +29 -0
  44. data/spec/support/sample_app/config/initializers/cookie_verification_secret.rb +7 -0
  45. data/spec/support/sample_app/config/initializers/new_rails_defaults.rb +21 -0
  46. data/spec/support/sample_app/config/initializers/session_store.rb +15 -0
  47. data/spec/support/sample_app/config/routes.rb +6 -0
  48. data/spec/support/sample_app/db/schema.rb +21 -0
  49. data/spec/support/sample_app/public/404.html +30 -0
  50. data/spec/support/sample_app/public/422.html +30 -0
  51. data/spec/support/sample_app/public/500.html +30 -0
  52. data/spec/support/sample_app/public/favicon.ico +0 -0
  53. data/spec/support/sample_app/public/images/rails.png +0 -0
  54. data/spec/support/sample_app/public/index.html +275 -0
  55. data/spec/support/sample_app/public/javascripts/application.js +2 -0
  56. data/spec/support/sample_app/public/javascripts/controls.js +963 -0
  57. data/spec/support/sample_app/public/javascripts/dragdrop.js +973 -0
  58. data/spec/support/sample_app/public/javascripts/effects.js +1128 -0
  59. data/spec/support/sample_app/public/javascripts/prototype.js +4320 -0
  60. data/spec/support/sample_app/public/robots.txt +5 -0
  61. data/spec/support/sample_app/public/stylesheets/scaffold.css +54 -0
  62. data/spec/support/sample_app/script/about +4 -0
  63. data/spec/support/sample_app/script/console +3 -0
  64. data/spec/support/sample_app/script/dbconsole +3 -0
  65. data/spec/support/sample_app/script/destroy +3 -0
  66. data/spec/support/sample_app/script/generate +3 -0
  67. data/spec/support/sample_app/script/performance/benchmarker +3 -0
  68. data/spec/support/sample_app/script/performance/profiler +3 -0
  69. data/spec/support/sample_app/script/plugin +3 -0
  70. data/spec/support/sample_app/script/runner +3 -0
  71. data/spec/support/sample_app/script/server +3 -0
  72. data/spec/support/sample_app_run.sh +11 -0
  73. data/tasks/rspec.rake +26 -0
  74. data/tasks/yard.rake +14 -0
  75. data/website/index.html +11 -0
  76. data/website/index.txt +81 -0
  77. data/website/javascripts/rounded_corners_lite.inc.js +285 -0
  78. data/website/stylesheets/screen.css +159 -0
  79. data/website/template.html.erb +50 -0
  80. metadata +248 -0
@@ -0,0 +1,33 @@
1
+ 0.0.6 (ureleased)
2
+
3
+ * TODO
4
+ * invoking rake tasks
5
+ * optimize testing
6
+
7
+ 0.0.5 (04.10.2010)
8
+ ------------------
9
+
10
+ * added:
11
+ * [FIX] handling hard attributes(:user, :email => 'bla')
12
+ * method execute ( Cucumba[:main].e("1+1") )
13
+
14
+ 0.0.4 (01.10.2010)
15
+ -----------------------
16
+
17
+ * 1 major enhancement:
18
+ * API was coined
19
+ * added exceptions and method invoking
20
+ * minor changes:
21
+ * organized files and extensions for easily writing docs(History.txt => History.md)
22
+ * write documentation(for me to not forget what exactly to do)
23
+ * YARD documentation generation task
24
+ * Writed gem description
25
+ * development gem deps
26
+ * write tests
27
+ * organize tests
28
+ * write tests due to new API
29
+
30
+ older releases
31
+ --------------
32
+
33
+ * was yanked because was not enough functional or buggy
@@ -0,0 +1,79 @@
1
+ History.md
2
+ Manifest.txt
3
+ PostInstall.txt
4
+ README.rdoc
5
+ Rakefile
6
+ config/website.yml.sample
7
+ cucumba.gemspec
8
+ generators/cucumba/USAGE
9
+ generators/cucumba/cucumba_generator.rb
10
+ generators/cucumba/templates/config.yml
11
+ generators/cucumba/templates/cucumba
12
+ lib/cucumba.rb
13
+ lib/cucumba/drb.rb
14
+ lib/cucumba/rails.rb
15
+ lib/cucumba/rails/model.rb
16
+ lib/cucumba/rails/runner.rb
17
+ lib/cucumba/server.rb
18
+ script/console
19
+ script/destroy
20
+ script/generate
21
+ script/txt2html
22
+ spec/cucumba_configuration_spec.rb
23
+ spec/cucumba_spec_rails.rb
24
+ spec/spec.opts
25
+ spec/spec_helper.rb
26
+ spec/support/sample_app/README
27
+ spec/support/sample_app/Rakefile
28
+ spec/support/sample_app/app/controllers/application_controller.rb
29
+ spec/support/sample_app/app/controllers/users_controller.rb
30
+ spec/support/sample_app/app/helpers/application_helper.rb
31
+ spec/support/sample_app/app/helpers/users_helper.rb
32
+ spec/support/sample_app/app/models/user.rb
33
+ spec/support/sample_app/app/views/layouts/users.html.erb
34
+ spec/support/sample_app/app/views/users/edit.html.erb
35
+ spec/support/sample_app/app/views/users/index.html.erb
36
+ spec/support/sample_app/app/views/users/new.html.erb
37
+ spec/support/sample_app/app/views/users/show.html.erb
38
+ spec/support/sample_app/config/boot.rb
39
+ spec/support/sample_app/config/database.yml
40
+ spec/support/sample_app/config/environment.rb
41
+ spec/support/sample_app/config/environments/development.rb
42
+ spec/support/sample_app/config/environments/production.rb
43
+ spec/support/sample_app/config/environments/test.rb
44
+ spec/support/sample_app/config/initializers/cookie_verification_secret.rb
45
+ spec/support/sample_app/config/initializers/new_rails_defaults.rb
46
+ spec/support/sample_app/config/initializers/session_store.rb
47
+ spec/support/sample_app/config/routes.rb
48
+ spec/support/sample_app/db/schema.rb
49
+ spec/support/sample_app/public/404.html
50
+ spec/support/sample_app/public/422.html
51
+ spec/support/sample_app/public/500.html
52
+ spec/support/sample_app/public/favicon.ico
53
+ spec/support/sample_app/public/images/rails.png
54
+ spec/support/sample_app/public/index.html
55
+ spec/support/sample_app/public/javascripts/application.js
56
+ spec/support/sample_app/public/javascripts/controls.js
57
+ spec/support/sample_app/public/javascripts/dragdrop.js
58
+ spec/support/sample_app/public/javascripts/effects.js
59
+ spec/support/sample_app/public/javascripts/prototype.js
60
+ spec/support/sample_app/public/robots.txt
61
+ spec/support/sample_app/public/stylesheets/scaffold.css
62
+ spec/support/sample_app/script/about
63
+ spec/support/sample_app/script/console
64
+ spec/support/sample_app/script/dbconsole
65
+ spec/support/sample_app/script/destroy
66
+ spec/support/sample_app/script/generate
67
+ spec/support/sample_app/script/performance/benchmarker
68
+ spec/support/sample_app/script/performance/profiler
69
+ spec/support/sample_app/script/plugin
70
+ spec/support/sample_app/script/runner
71
+ spec/support/sample_app/script/server
72
+ spec/support/sample_app_run.sh
73
+ tasks/rspec.rake
74
+ tasks/yard.rake
75
+ website/index.html
76
+ website/index.txt
77
+ website/javascripts/rounded_corners_lite.inc.js
78
+ website/stylesheets/screen.css
79
+ website/template.html.erb
@@ -0,0 +1,7 @@
1
+ Thanks for installing,don't forget following:
2
+
3
+ * run cucumba generator
4
+ * add to you config/environments/test.rb:
5
+ require 'cucumba/drb'
6
+
7
+ For more information on cucumba, see http://cucumba.rubyforge.org
@@ -0,0 +1,59 @@
1
+ = cucumba
2
+
3
+ * http://github.com/hxcoding/cucumba
4
+
5
+ == DESCRIPTION:
6
+
7
+ If you develop more than one rails applications
8
+ that communicate with each other and you need to test them
9
+ with something like capybara and also whant to communicate with database -
10
+ this gem will help you
11
+
12
+ == FEATURES/PROBLEMS:
13
+
14
+ * FIX (list of features or problems)
15
+
16
+ == SYNOPSIS:
17
+
18
+ * comunication with models:
19
+
20
+ Cucumba[:main].model("User").create!
21
+ Cucumba[:main].m(:Article).destroy
22
+
23
+ * cookies and session(TODO):
24
+
25
+ Cucumba[:main].cookies
26
+ Cucumba[:main].session
27
+
28
+ == REQUIREMENTS:
29
+
30
+ * FIX (list of requirements)
31
+
32
+ == INSTALL:
33
+
34
+ * FIX (sudo gem install, anything else)
35
+
36
+ == LICENSE:
37
+
38
+ (The MIT License)
39
+
40
+ Copyright (c) 2010 hxcoding
41
+
42
+ Permission is hereby granted, free of charge, to any person obtaining
43
+ a copy of this software and associated documentation files (the
44
+ 'Software'), to deal in the Software without restriction, including
45
+ without limitation the rights to use, copy, modify, merge, publish,
46
+ distribute, sublicense, and/or sell copies of the Software, and to
47
+ permit persons to whom the Software is furnished to do so, subject to
48
+ the following conditions:
49
+
50
+ The above copyright notice and this permission notice shall be
51
+ included in all copies or substantial portions of the Software.
52
+
53
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
54
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
55
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
56
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
57
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
58
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
59
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,33 @@
1
+ require 'rubygems'
2
+ gem 'hoe', '>= 2.1.0'
3
+ require 'hoe'
4
+ require 'fileutils'
5
+ require './lib/cucumba'
6
+
7
+ Hoe.plugin :newgem
8
+ Hoe.plugin :website
9
+
10
+ # Generate all the Rake tasks
11
+ # Run 'rake -T' to see list of generated tasks (from gem root directory)
12
+ $hoe = Hoe.spec 'cucumba' do
13
+ self.developer 'kucaahbe', 'kucaahbe@ukr.net'
14
+ self.post_install_message = 'PostInstall.txt'
15
+ self.rubyforge_name = self.name
16
+ # self.extra_deps = [['activesupport','>= 2.0.2']]
17
+ self.extra_dev_deps = [
18
+ ['yard', '>= 0.6.1'],
19
+ ['bluecloth', '2.0.9'],
20
+ ['rails', '2.3.8'],
21
+ ['sqlite3-ruby','1.3.1'],
22
+ ['rspec', '1.3.0']
23
+ ]
24
+ self.history_file = 'History.md'
25
+ self.readme_file = 'README.rdoc'
26
+ end
27
+
28
+ require 'newgem/tasks'
29
+ Dir['tasks/**/*.rake'].each { |t| load t }
30
+
31
+ remove_task :default
32
+ remove_task :spec
33
+ task :default => ['spec:config', 'spec:rails']
@@ -0,0 +1,2 @@
1
+ host: unknown@rubyforge.org
2
+ remote_dir: /var/www/gforge-projects/cucumba
@@ -0,0 +1,52 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{cucumba}
5
+ s.version = "0.0.5"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["kucaahbe"]
9
+ s.date = %q{2010-10-04}
10
+ s.description = %q{If you develop more than one rails applications
11
+ that communicate with each other and you need to test them
12
+ with something like capybara and also whant to communicate with database -
13
+ this gem will help you}
14
+ s.email = ["kucaahbe@ukr.net"]
15
+ s.extra_rdoc_files = ["Manifest.txt", "PostInstall.txt", "website/index.txt"]
16
+ s.files = ["History.md", "Manifest.txt", "PostInstall.txt", "README.rdoc", "Rakefile", "config/website.yml.sample", "cucumba.gemspec", "generators/cucumba/USAGE", "generators/cucumba/cucumba_generator.rb", "generators/cucumba/templates/config.yml", "generators/cucumba/templates/cucumba", "lib/cucumba.rb", "lib/cucumba/drb.rb", "lib/cucumba/rails.rb", "lib/cucumba/rails/model.rb", "lib/cucumba/rails/runner.rb", "lib/cucumba/server.rb", "script/console", "script/destroy", "script/generate", "script/txt2html", "spec/cucumba_configuration_spec.rb", "spec/cucumba_spec_rails.rb", "spec/spec.opts", "spec/spec_helper.rb", "spec/support/sample_app/README", "spec/support/sample_app/Rakefile", "spec/support/sample_app/app/controllers/application_controller.rb", "spec/support/sample_app/app/controllers/users_controller.rb", "spec/support/sample_app/app/helpers/application_helper.rb", "spec/support/sample_app/app/helpers/users_helper.rb", "spec/support/sample_app/app/models/user.rb", "spec/support/sample_app/app/views/layouts/users.html.erb", "spec/support/sample_app/app/views/users/edit.html.erb", "spec/support/sample_app/app/views/users/index.html.erb", "spec/support/sample_app/app/views/users/new.html.erb", "spec/support/sample_app/app/views/users/show.html.erb", "spec/support/sample_app/config/boot.rb", "spec/support/sample_app/config/database.yml", "spec/support/sample_app/config/environment.rb", "spec/support/sample_app/config/environments/development.rb", "spec/support/sample_app/config/environments/production.rb", "spec/support/sample_app/config/environments/test.rb", "spec/support/sample_app/config/initializers/cookie_verification_secret.rb", "spec/support/sample_app/config/initializers/new_rails_defaults.rb", "spec/support/sample_app/config/initializers/session_store.rb", "spec/support/sample_app/config/routes.rb", "spec/support/sample_app/db/schema.rb", "spec/support/sample_app/public/404.html", "spec/support/sample_app/public/422.html", "spec/support/sample_app/public/500.html", "spec/support/sample_app/public/favicon.ico", "spec/support/sample_app/public/images/rails.png", "spec/support/sample_app/public/index.html", "spec/support/sample_app/public/javascripts/application.js", "spec/support/sample_app/public/javascripts/controls.js", "spec/support/sample_app/public/javascripts/dragdrop.js", "spec/support/sample_app/public/javascripts/effects.js", "spec/support/sample_app/public/javascripts/prototype.js", "spec/support/sample_app/public/robots.txt", "spec/support/sample_app/public/stylesheets/scaffold.css", "spec/support/sample_app/script/about", "spec/support/sample_app/script/console", "spec/support/sample_app/script/dbconsole", "spec/support/sample_app/script/destroy", "spec/support/sample_app/script/generate", "spec/support/sample_app/script/performance/benchmarker", "spec/support/sample_app/script/performance/profiler", "spec/support/sample_app/script/plugin", "spec/support/sample_app/script/runner", "spec/support/sample_app/script/server", "spec/support/sample_app_run.sh", "tasks/rspec.rake", "tasks/yard.rake", "website/index.html", "website/index.txt", "website/javascripts/rounded_corners_lite.inc.js", "website/stylesheets/screen.css", "website/template.html.erb"]
17
+ s.homepage = %q{http://github.com/hxcoding/cucumba}
18
+ s.post_install_message = %q{PostInstall.txt}
19
+ s.rdoc_options = ["--main", "README.rdoc"]
20
+ s.require_paths = ["lib"]
21
+ s.rubyforge_project = %q{cucumba}
22
+ s.rubygems_version = %q{1.3.7}
23
+ s.summary = %q{If you develop more than one rails applications that communicate with each other and you need to test them with something like capybara and also whant to communicate with database - this gem will help you}
24
+
25
+ if s.respond_to? :specification_version then
26
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
27
+ s.specification_version = 3
28
+
29
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
30
+ s.add_development_dependency(%q<yard>, [">= 0.6.1"])
31
+ s.add_development_dependency(%q<bluecloth>, ["= 2.0.9"])
32
+ s.add_development_dependency(%q<rails>, ["= 2.3.8"])
33
+ s.add_development_dependency(%q<sqlite3-ruby>, ["= 1.3.1"])
34
+ s.add_development_dependency(%q<rspec>, ["= 1.3.0"])
35
+ s.add_development_dependency(%q<hoe>, [">= 2.6.2"])
36
+ else
37
+ s.add_dependency(%q<yard>, [">= 0.6.1"])
38
+ s.add_dependency(%q<bluecloth>, ["= 2.0.9"])
39
+ s.add_dependency(%q<rails>, ["= 2.3.8"])
40
+ s.add_dependency(%q<sqlite3-ruby>, ["= 1.3.1"])
41
+ s.add_dependency(%q<rspec>, ["= 1.3.0"])
42
+ s.add_dependency(%q<hoe>, [">= 2.6.2"])
43
+ end
44
+ else
45
+ s.add_dependency(%q<yard>, [">= 0.6.1"])
46
+ s.add_dependency(%q<bluecloth>, ["= 2.0.9"])
47
+ s.add_dependency(%q<rails>, ["= 2.3.8"])
48
+ s.add_dependency(%q<sqlite3-ruby>, ["= 1.3.1"])
49
+ s.add_dependency(%q<rspec>, ["= 1.3.0"])
50
+ s.add_dependency(%q<hoe>, [">= 2.6.2"])
51
+ end
52
+ end
@@ -0,0 +1,9 @@
1
+ Description:
2
+ Generate cucumba setup
3
+
4
+ Example:
5
+ ./script/generate cucumba server1 server2 server3
6
+
7
+ This will create:
8
+ config/cucumba.yml
9
+ lib/tasks/cucumba.rake
@@ -0,0 +1,23 @@
1
+ class CucumbaGenerator < Rails::Generator::NamedBase
2
+ attr_reader :server_names
3
+
4
+ def initialize(runtime_args, runtime_options={})
5
+ super
6
+ @server_names = runtime_args.uniq
7
+ end
8
+
9
+ def manifest
10
+ record do |m|
11
+ m.directory "config"
12
+ m.template 'config.yml', "config/cucumba.yml"
13
+ m.directory "script"
14
+ m.file 'cucumba', 'script/cucumba', { :chmod => 0755 }
15
+ end
16
+ end
17
+
18
+ private
19
+
20
+ def banner
21
+ 'Usage: ./script/generate cucumba server1 server2 server3'
22
+ end
23
+ end
@@ -0,0 +1,15 @@
1
+ ---
2
+ <%- server_names.each_index do |i| -%>
3
+ - :name: <%= server_names[i] %>
4
+ :host: localhost
5
+ :port: 500<%= i+1 %>
6
+ :desc: FIXME <%= server_names[i] %> description
7
+ :env: test
8
+ <%- if i==0 -%>
9
+ :run: true
10
+ <%- else -%>
11
+ :run: false
12
+ :path: '../<%= server_names[i] %>'
13
+ <%- end -%>
14
+
15
+ <%- end -%>
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+ require File.expand_path('../../config/boot', __FILE__)
3
+ begin
4
+ cucumba_vendored_dir = Dir[File.join(Rails.root.to_s,'vendor/gems/cucumba-*')].last
5
+ cucumba_server_file = File.join(cucumba_vendored_dir.to_s,'lib/cucumba/server.rb')
6
+ if File.exists?(cucumba_server_file)
7
+ puts 'loading vendored cucumba'
8
+ require cucumba_server_file
9
+ else
10
+ require 'rubygems'
11
+ require 'cucumba/server'
12
+ end
13
+ rescue LoadError
14
+ puts <<EOF
15
+ 'cucumba' gem seems not installed,install it
16
+ EOF
17
+ exit 1
18
+ end
@@ -0,0 +1,49 @@
1
+ lib = File.expand_path(File.join(File.dirname(__FILE__),'../lib'))
2
+ $:.unshift(lib) unless $:.include?(lib)
3
+
4
+ require 'yaml'
5
+ require 'cucumba/rails'
6
+
7
+ module Cucumba
8
+ VERSION = '0.0.5'
9
+
10
+ class ConfigNotFound < StandardError
11
+ end
12
+
13
+ # Usage:
14
+ #
15
+ # Cucumba[:main]
16
+ # or
17
+ #
18
+ # Cucumba['main']
19
+ #
20
+ # where :main('main') is the
21
+ # server name in config file.
22
+ # Return Cucumba client instance
23
+ def self.[] server_name
24
+ server_name = server_name.to_s
25
+ if server_name == "_self_"
26
+ Cucumba::Rails.new(config.first)
27
+ else
28
+ Cucumba::Rails.new(config_for(server_name))
29
+ end
30
+ end
31
+
32
+ private
33
+
34
+ def self.config_for(server_name)
35
+ config.each do |server_config|
36
+ if server_config[:name]==server_name
37
+ return server_config
38
+ break
39
+ end
40
+ end
41
+ raise Cucumba::Rails::ServerNotFound, "server with '#{server_name}' not described in config file"
42
+ rescue Errno::ENOENT # yml file not found
43
+ raise ConfigNotFound, "config not found, run 'cucumba' generator"
44
+ end
45
+
46
+ def self.config
47
+ @@config ||= YAML.load_file(File.join((defined?(::Rails) ? ::Rails.root.to_s : Dir.pwd),'config','cucumba.yml'))
48
+ end
49
+ end
@@ -0,0 +1,52 @@
1
+ require 'cucumba'
2
+ require 'drb'
3
+
4
+ module Cucumba
5
+ class Drb
6
+ class Server
7
+ def has_model?(model)
8
+ Object.const_defined?(model.to_s.classify)
9
+ end
10
+
11
+ def model_has_method?(model,method)
12
+ Object.const_get(model).respond_to?(method)
13
+ end
14
+
15
+ def invoke_method_on_model(model,method,*args)
16
+ logger.info "Processing #{model}.#{method.to_s} (for TODO_IP at #{Time.now.strftime('%Y-%m-%d %H:%M:%S')}) [DRb]"
17
+ Object.const_get(model).method(method).call(*args.first)
18
+ rescue Exception => e
19
+ handle_exception(e)
20
+ raise RuntimeError, "#{e.class.to_s} #{e.message}"
21
+ end
22
+
23
+ def execute(code)
24
+ logger.info "Evaluating code (for TODO_IP at #{Time.now.strftime('%Y-%m-%d %H:%M:%S')}) [DRb]"
25
+ logger.info '---'
26
+ logger.info code
27
+ logger.info '---'
28
+ Object.send :eval, code
29
+ rescue Exception => e
30
+ handle_exception(e)
31
+ raise RuntimeError, e.message
32
+ end
33
+
34
+ private
35
+
36
+ def logger
37
+ RAILS_DEFAULT_LOGGER
38
+ end
39
+
40
+ def handle_exception(exception)
41
+ logger.info "#{exception.class.to_s}: #{exception.message}"
42
+ exception.backtrace.each { |t| logger.info t }
43
+ end
44
+
45
+ end
46
+ end
47
+ end
48
+
49
+ begin
50
+ DRb.start_service(Cucumba[:_self_].drb_url, Cucumba::Drb::Server.new) if Cucumba[:_self_].run?
51
+ rescue Errno::EADDRINUSE
52
+ end