screwcap 0.6.pre → 0.6.pre2

Sign up to get free protection for your applications and to get access to all the features.
data/Manifest.txt CHANGED
@@ -14,7 +14,6 @@ lib/screwcap/task.rb
14
14
  lib/screwcap/task_manager.rb
15
15
  lib/trollop.rb
16
16
  recipes/setup_rails.rb
17
- runrdoc
18
17
  screwcap.gemspec
19
18
  spec/runner_spec.rb
20
19
  spec/sequence_spec.rb
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.pre'
14
+ self.version = '0.6.pre2'
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']]
data/bin/screwcap CHANGED
@@ -29,13 +29,14 @@ opts = Trollop::with_standard_exception_handling p do
29
29
  Debugger.start
30
30
  end
31
31
 
32
- if opts[:tasks] == true
32
+ if opts[:tasks] == true or ARGV.size == 1
33
33
  recipe_file = ARGV.shift
34
34
  deployer = TaskManager.new(opts.merge(:recipe_file => recipe_file))
35
- $stdout << "Tasks Available:\n" if deployer.__tasks.size > 0
35
+ $stdout << "\nTasks Available:\n" if deployer.__tasks.size > 0
36
36
  deployer.__tasks.map {|t| t.__name }.each {|name| $stdout << " #{name}\n" }
37
- $stdout << "Sequences Available:\n" if deployer.__sequences.size > 0
37
+ $stdout << "\nSequences Available:\n" if deployer.__sequences.size > 0
38
38
  deployer.__sequences.map {|t| t.__name }.each {|name| $stdout << " #{name}\n" }
39
+ $stdout << "\n"
39
40
  exit
40
41
  end
41
42
 
@@ -63,7 +64,6 @@ opts = Trollop::with_standard_exception_handling p do
63
64
  exit
64
65
  end
65
66
 
66
- raise Trollop::HelpNeeded if ARGV.size < 2
67
67
  recipe_file = ARGV.shift
68
68
  begin
69
69
  TaskManager.new(opts.merge(:recipe_file => recipe_file)).run! ARGV.map {|a| a.to_sym }
data/lib/screwcap/task.rb CHANGED
@@ -87,16 +87,45 @@ class Task < Screwcap::Base
87
87
  end
88
88
  end
89
89
 
90
+ # For a task, declare a set of things to run before or after a command set.
91
+ # command_set :release_the_hounds do
92
+ # run "release_the_hounds"
93
+ # end
94
+ #
95
+ # task :release do
96
+ # before :release_the_hounds do
97
+ # run "unlock_the_gate"
98
+ # end
99
+ # after :release_the_hounds do
100
+ # run "find_and_gather_released_hounds"
101
+ # end
102
+ # release_the_hounds
103
+ # end
104
+
90
105
  def before name, &block
91
106
  self.__local_before_command_sets << Task.new(:name => name, &block)
92
107
  end
93
108
 
109
+ # For a task, declare a set of things to run before or after a command set.
110
+ # command_set :release_the_hounds do
111
+ # run "release_the_hounds"
112
+ # end
113
+ #
114
+ # task :release do
115
+ # before :release_the_hounds do
116
+ # run "unlock_the_gate"
117
+ # end
118
+ # after :release_the_hounds do
119
+ # run "find_and_gather_released_hounds"
120
+ # end
121
+ # release_the_hounds
122
+ # end
123
+
94
124
  def after name, &block
95
125
  self.__local_after_command_sets << Task.new(:name => name, &block)
96
126
  end
97
127
 
98
-
99
- def __build_commands(command_sets = [])
128
+ def __build_commands(command_sets = [], _self = self)
100
129
  commands = []
101
130
 
102
131
  self.instance_eval(&self.__block)
@@ -119,21 +148,21 @@ class Task < Screwcap::Base
119
148
  self.__commands.each do |command|
120
149
  if command[:type] == :unknown
121
150
  if cs = command_sets.find {|cs| cs.__name == command[:command] }
122
- cs.clone_from(self)
151
+ cs.clone_from(_self)
123
152
 
124
- self.__local_before_command_sets.each do |lcs|
153
+ _self.__local_before_command_sets.each do |lcs|
125
154
  if command[:command] == lcs.__name
126
- lcs.clone_from(self)
127
- commands << lcs.__build_commands(command_sets)
155
+ lcs.clone_from(_self)
156
+ commands << lcs.__build_commands(command_sets, _self)
128
157
  end
129
158
  end
130
159
 
131
- commands << cs.__build_commands(command_sets)
160
+ commands << cs.__build_commands(command_sets, _self)
132
161
 
133
- self.__local_after_command_sets.each do |lcs|
162
+ _self.__local_after_command_sets.each do |lcs|
134
163
  if command[:command] == lcs.__name
135
- lcs.clone_from(self)
136
- commands << lcs.__build_commands(command_sets)
164
+ lcs.clone_from(_self)
165
+ commands << lcs.__build_commands(command_sets, _self)
137
166
  end
138
167
  end
139
168
 
@@ -157,7 +186,7 @@ class Task < Screwcap::Base
157
186
  command_sets.select {|cs| cs.__name.to_s == "after_#{self.__name}"}.each do |after|
158
187
  next if after == self
159
188
  after.clone_from(self)
160
- commands << after.__build_commands(command_sets)
189
+ commands << after.__build_commands(command_sets, self)
161
190
  end
162
191
 
163
192
  commands.flatten
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.pre'
19
+ VERSION='0.6.pre2'
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.pre"
9
+ s.version = "0.6.pre2"
10
10
  s.platform = Gem::Platform::RUBY
11
11
  s.author = "Grant Ammons"
12
12
  s.email = ["grant@pipelinedealsco.com"]
data/spec/task_spec.rb CHANGED
@@ -228,4 +228,55 @@ describe "Tasks" do
228
228
  commands = task.__build_commands([before1, before2])
229
229
  commands.map {|c| c[:command] }.should == %w(do1 do2 task)
230
230
  end
231
+
232
+ it "should be able to run before on deeply nested command sets" do
233
+ n1 = Task.new :name => :nested do
234
+ inner_nested
235
+ end
236
+
237
+ n2 = Task.new :name => :inner_nested do
238
+ run "inner_nested"
239
+ inner_inner_nested
240
+ end
241
+
242
+ n3 = Task.new :name => :inner_inner_nested do
243
+ run "inner_inner_nested"
244
+ end
245
+
246
+ task = Task.new :name => :deploy do
247
+ before :inner_inner_nested do
248
+ run "before_inner_inner_nested"
249
+ end
250
+ after :inner_nested do
251
+ run "after_inner_nested"
252
+ end
253
+ nested
254
+ end
255
+
256
+ commands = task.__build_commands [n1, n2, n3]
257
+ commands.map {|c| c[:command] }.should == %w(inner_nested before_inner_inner_nested inner_inner_nested after_inner_nested)
258
+ end
259
+
260
+ it "before and after should be able to run command sets on their own" do
261
+ n1 = Task.new :name => :release_the_hounds do
262
+ run "release_the_hounds"
263
+ end
264
+
265
+ n2 = Task.new :name => :lock_the_gate do
266
+ run "lock_the_gate"
267
+ end
268
+
269
+ n3 = Task.new :name => :unlock_the_gate do
270
+ run "unlock_the_gate"
271
+ end
272
+
273
+ task = Task.new :name => :deploy_the_animals do
274
+ before(:release_the_hounds) { unlock_the_gate }
275
+ after(:release_the_hounds) { lock_the_gate }
276
+ release_the_hounds
277
+ end
278
+
279
+ commands = task.__build_commands [n1, n2, n3]
280
+ commands.map {|c| c[:command] }.should == %w(unlock_the_gate release_the_hounds lock_the_gate)
281
+ end
231
282
  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: 961915916
4
+ hash: -1876988247
5
5
  prerelease: true
6
6
  segments:
7
7
  - 0
8
8
  - 6
9
- - pre
10
- version: 0.6.pre
9
+ - pre2
10
+ version: 0.6.pre2
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: 2010-11-19 00:00:00 -05:00
18
+ date: 2010-11-20 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -125,7 +125,6 @@ files:
125
125
  - lib/screwcap/task_manager.rb
126
126
  - lib/trollop.rb
127
127
  - recipes/setup_rails.rb
128
- - runrdoc
129
128
  - screwcap.gemspec
130
129
  - spec/runner_spec.rb
131
130
  - spec/sequence_spec.rb
data/runrdoc DELETED
@@ -1 +0,0 @@
1
- rdoc -x trollop -x spec -x runner -x object -x message -x tasknotfound -x runrdoc