climax 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -210,3 +210,27 @@ The three files you will want to modify are `README.md` (with info about your ap
210
210
  `<project-name>.gemspec` and `lib/<project-name>.rb`.
211
211
 
212
212
  You can bundle your application with `gem bundle *.gemspec`.
213
+
214
+ Control DRb
215
+ ===========
216
+
217
+ The Control DRb provides a way to interact with your running application. In future releases expect
218
+ new functionality to be added to the Control DRb and expect new ways of interacting with your long
219
+ running jobs.
220
+
221
+ You control your application with `climax control`. Simply pass `climax control` the name of the
222
+ command you wish to send to your application and any optional arguments. If your application is
223
+ using a different port than the default (7249) you can tell climax which port to connect on with the
224
+ `-p <port>` option:
225
+
226
+ climax control -p 1234 start_debugger
227
+
228
+ Starting the Debugger
229
+ ---------------------
230
+
231
+ To attach to your running application with a debugger, simply make sure your application is running
232
+ and then execute:
233
+
234
+ climax control start_debugger
235
+
236
+ When you are finished type `quit` to exit the debugger and resume your application.
@@ -170,7 +170,7 @@ module Climax
170
170
  case event.type
171
171
  when :set_log_level then log_level = event.payload
172
172
  when :stop_control_drb then @control_drb && @control_drb.stop_service
173
- when :start_remote_debugger then binding.remote_pry
173
+ when :start_remote_debugger then binding.remote_pry rescue nil
174
174
  when :quit, :exit then return 0
175
175
  end
176
176
  end
@@ -1 +1,41 @@
1
+ require 'drb'
2
+ require 'pry-remote'
1
3
 
4
+ module Climax
5
+ module CLI
6
+ module Command
7
+ class Control
8
+
9
+ def initialize (options, args)
10
+ @opts = options.dup
11
+ @args = args.dup
12
+ end
13
+
14
+ def run
15
+ args = @args.dup
16
+ DRb.start_service
17
+ server = DRbObject.new_with_uri("druby://localhost:#{port}")
18
+ command = args.shift
19
+ server.send(command, *args)
20
+
21
+ if command == "start_debugger"
22
+ success = nil
23
+ begin
24
+ PryRemote::CLI.new.run
25
+ success = true
26
+ rescue
27
+ end while success.nil?
28
+ end
29
+ end
30
+
31
+ def opts
32
+ @opts
33
+ end
34
+
35
+ def port
36
+ @port ||= @opts[:port]
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -37,7 +37,7 @@ module Climax
37
37
  # Create standard bundler gem layout
38
38
  %x[bundle gem #{name}]
39
39
  # Add a couple extra directories
40
- FileUtils.mkpath(["#{name}/bin", "#{name}/features", "#{name}/pkg"])
40
+ FileUtils.mkpath(["#{name}/bin", "#{name}/features/support", "#{name}/features/step_definitions", "#{name}/pkg"])
41
41
 
42
42
  # Get bundler generated module path
43
43
  gemspec = File.read("#{name}/#{name}.gemspec")
@@ -47,20 +47,31 @@ module Climax
47
47
  template_dir = File.join(File.dirname(__FILE__), "..", "..", "..", "templates")
48
48
 
49
49
  File.open("#{name}/bin/#{name}", "w") do |file|
50
- file.write(ERB.new(File.read(File.join(template_dir, "application_wrapper.erb")), 0, '<>').result(binding))
50
+ file.write(ERB.new(File.read(File.join(template_dir, "bin", "application.rb.erb")), 0, '<>').result(binding))
51
51
  end
52
52
 
53
53
  FileUtils.chmod "+x", "#{name}/bin/#{name}"
54
54
 
55
55
  File.open("#{name}/lib/#{name}.rb", "w") do |file|
56
- file.write(ERB.new(File.read(File.join(template_dir, "application.rb.erb")), 0, '<>').result(binding))
56
+ file.write(ERB.new(File.read(File.join(template_dir, "lib", "application.rb.erb")), 0, '<>').result(binding))
57
57
  end
58
58
 
59
- gemspec.gsub!(/^end$/, " gem.add_development_dependency \"cucumber\"\n gem.add_runtime_dependency \"climax\"\nend")
59
+ gemspec.gsub!(/^end$/, " gem.add_development_dependency \"cucumber\"\n gem.add_development_dependency \"rspec\"\n gem.add_runtime_dependency \"climax\"\nend")
60
60
  File.open("#{name}/#{name}.gemspec", "w") do |file|
61
61
  file.write(gemspec)
62
62
  end
63
63
 
64
+ File.open("#{name}/features/support/env.rb", "w") do |file|
65
+ file.write(ERB.new(File.read(File.join(template_dir, "features", "support", "env.rb.erb")), 0, '<>').result(binding))
66
+ end
67
+
68
+ FileUtils.cp(File.join(template_dir, "features", "support", "io.rb"), "#{name}/features/support/io.rb")
69
+
70
+ in_directory(name) do
71
+ %x[git add .]
72
+ %x[git commit -m 'Initial project']
73
+ end
74
+
64
75
  end
65
76
  end
66
77
 
@@ -1,3 +1,3 @@
1
1
  module Climax
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -0,0 +1,5 @@
1
+ $:.unshift File.join(File.dirname(__FILE__), "..", "..", "lib")
2
+ require "rubygems" rescue nil
3
+ require "<%= name %>"
4
+ require "rspec/expectations"
5
+ require "cucumber/rspec/doubles" # For mocking, stubs, and test doubles
@@ -0,0 +1,26 @@
1
+ require 'stringio'
2
+
3
+ ## Example:
4
+ ## out, err = with_captured_io do
5
+ ## puts "wee!"
6
+ ## end
7
+ ##
8
+ ## puts out # => "wee!\n"
9
+
10
+ def with_captured_io
11
+ sio_stdout = StringIO.new
12
+ sio_stderr = StringIO.new
13
+ _stdout, $stdout = $stdout, sio_stdout
14
+ _stderr, $stderr = $stderr, sio_stderr
15
+ begin
16
+ # Call block with new stdout and stderr
17
+ yield
18
+ ensure
19
+ $stdout = _stdout
20
+ $stderr = _stderr
21
+ end
22
+ sio_stdout.seek(0)
23
+ sio_stderr.seek(0)
24
+ stdout, stderr = sio_stdout.read(), sio_stderr.read()
25
+ return [stdout, stderr]
26
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: climax
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -114,8 +114,10 @@ files:
114
114
  - lib/climax/commands/create.rb
115
115
  - lib/climax/control_drb.rb
116
116
  - lib/climax/version.rb
117
- - templates/application.rb.erb
118
- - templates/application_wrapper.erb
117
+ - templates/bin/application.rb.erb
118
+ - templates/features/support/env.rb.erb
119
+ - templates/features/support/io.rb
120
+ - templates/lib/application.rb.erb
119
121
  - test/bin/hello_world
120
122
  - test/lib/hello_world.rb
121
123
  homepage: https://github.com/appriss/climax