screwcap 0.6.2 → 0.6.3

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -11,7 +11,7 @@ Hoe.plugin :newgem
11
11
  # Generate all the Rake tasks
12
12
  # Run 'rake -T' to see list of generated tasks (from gem root directory)
13
13
  $hoe = Hoe.spec 'screwcap' do
14
- self.version = '0.6.2'
14
+ self.version = '0.6.3'
15
15
  self.developer 'Grant Ammons', 'grant@pipelinedeals.com'
16
16
  self.rubyforge_name = self.name # TODO this is default value
17
17
  self.extra_deps = [['net-ssh','>= 2.0.23'],['net-ssh-gateway','>=1.0.1'], ['net-scp','>=1.0.4']]
@@ -42,7 +42,8 @@ class Runner
42
42
  private
43
43
 
44
44
  def self.run_command(command, ssh, options)
45
- if command[:type] == :remote
45
+ case command[:type]
46
+ when :remote
46
47
  stdout, stderr, exit_code, exit_signal = ssh_exec! ssh, command[:command]
47
48
  command[:stdout] = stdout
48
49
  command[:stderr] = stderr
@@ -53,7 +54,7 @@ class Runner
53
54
  _errorlog("\n E: (#{options[:address]}): #{command[:command]} return exit code: #{exit_code}\n", :color => :red) if exit_code != 0
54
55
  end
55
56
  return exit_code
56
- elsif command[:type] == :local
57
+ when :local
57
58
  ret = `#{command[:command]}`
58
59
  command[:stdout] = ret
59
60
  if $?.to_i == 0
@@ -62,12 +63,14 @@ class Runner
62
63
  _errorlog("\n E: (local): #{command[:command]} return exit code: #{$?}\n", :color => :red) if $? != 0
63
64
  end
64
65
  return $?
65
- elsif command[:type] == :scp
66
+ when :scp
66
67
  putc "."
67
68
  options[:server].__upload_to!(options[:address], command[:local], command[:remote])
68
69
 
69
70
  # this will need to be improved to allow for :onfailure
70
71
  return 0
72
+ when :block
73
+ command[:block].call
71
74
  end
72
75
  end
73
76
 
data/lib/screwcap/task.rb CHANGED
@@ -54,6 +54,22 @@ class Task < Screwcap::Base
54
54
  end
55
55
  end
56
56
 
57
+ # execute a ruby command.
58
+ # command_set :test do
59
+ # run "do this"
60
+ # ex { @myvar = true }
61
+ # run "do that"
62
+ # end
63
+ #
64
+ # this is good for calling an external service during your deployment.
65
+ #
66
+ # command_set :after_deploy do
67
+ # ex { $hipchat_client.send "Deployment has finished" }
68
+ # end
69
+ def ex(&block)
70
+ self.__commands << {:type => :block, :from => self.__name, :block => block}
71
+ end
72
+
57
73
  # SCP a file from your local drive to a remote machine.
58
74
  # task_for :item, :servers => :server do
59
75
  # scp :local => "/tmp/pirate_booty", :remote => "/mnt/app/config/booty.yml"
@@ -214,7 +230,7 @@ class Task < Screwcap::Base
214
230
  private
215
231
 
216
232
  def method_missing(m, *args) # :nodoc
217
- if m.to_s[0..1] == "__" or [:run].include?(m) or m.to_s.reverse[0..0] == "="
233
+ if m.to_s[0..1] == "__" or [:run, :ex].include?(m) or m.to_s.reverse[0..0] == "="
218
234
  super(m, args.first)
219
235
  elsif m == :to_ary
220
236
  # In Ruby 1.9, Array#flatten calls #to_ary on each of the
data/lib/screwcap.rb CHANGED
@@ -16,7 +16,7 @@ require 'screwcap/sequence'
16
16
  require 'screwcap/task_manager'
17
17
 
18
18
  module Screwcap
19
- VERSION='0.6.2'
19
+ VERSION='0.6.3'
20
20
 
21
21
  class TaskNotFound < RuntimeError; end
22
22
  class NoServersDefined < Exception; end
data/screwcap.gemspec CHANGED
@@ -6,7 +6,7 @@ require 'bundler/version'
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "screwcap"
9
- s.version = "0.6.2"
9
+ s.version = "0.6.3"
10
10
  s.platform = Gem::Platform::RUBY
11
11
  s.author = "Grant Ammons"
12
12
  s.email = ["grant@pipelinedealsco.com"]
data/spec/runner_spec.rb CHANGED
@@ -48,4 +48,18 @@ describe "The Runner" do
48
48
  commands = Runner.execute_locally! :name => :localtest, :commands => task.__build_commands, :silent => true
49
49
  commands[0][:stdout].should == "bongle\n"
50
50
  end
51
+
52
+ it "should be able to execute ex commands" do
53
+ @@testvar = :bingo
54
+ task = Task.new :name => :extest do
55
+ ex { @@testvar = :bango }
56
+ end
57
+ @@testvar.should == :bingo
58
+ commands = Runner.execute! :name => "test",
59
+ :server => @server,
60
+ :address => "fake.com",
61
+ :commands => task.__build_commands,
62
+ :silent => true
63
+ @@testvar.should == :bango
64
+ end
51
65
  end
data/spec/task_spec.rb CHANGED
@@ -279,4 +279,14 @@ describe "Tasks" do
279
279
  commands = task.__build_commands [n1, n2, n3]
280
280
  commands.map {|c| c[:command] }.should == %w(unlock_the_gate release_the_hounds lock_the_gate)
281
281
  end
282
+
283
+ it "has an ex command" do
284
+
285
+ task = Task.new :name => :task do
286
+ @test = "asdf"
287
+ ex { @test = "fdsa" }
288
+ end
289
+
290
+ commands = task.__build_commands([task])
291
+ end
282
292
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: screwcap
3
3
  version: !ruby/object:Gem::Version
4
- hash: 3
4
+ hash: 1
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 6
9
- - 2
10
- version: 0.6.2
9
+ - 3
10
+ version: 0.6.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Grant Ammons
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-02-26 00:00:00 -05:00
18
+ date: 2011-03-18 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency