26: def define
27: t = Proc.new do |t|
28: puts green { "Preparing steps... " }
29: steps = []
30:
31: def steps.state
32: @state ||= {}
33: end
34:
35: eigenclass = class <<steps; self; end
36: plugins = self.class.const_get(:Step)
37: plugins.constants.each do |i|
38: eigenclass.__send__(:define_method, i) do |*args|
39: self << ret = plugins.const_get(i).new(self, *args)
40: ret
41: end
42: end
43: @block.call(steps)
44: steps.each do |s|
45: puts cyan { "Running Step (Prepare): #{s.class.name}" }
46: s.prepare if s.respond_to? :prepare
47: end
48: puts green { "done." }
49: unless t.name =~ /:prepare$/
50: puts
51: puts green { "Steps: #{steps.map{|i| i.class.name.sub(/.+::/, "")}.join(", ")}" }
52: puts "Really run? Cancel to press Ctrl+C."
53: $stdin.gets
54: steps.each do |s|
55: puts red { "Running Step: #{s.class.name}" }
56: s.run
57: end
58: puts green { "done." }
59: end
60: end
61: desc "Shipit: Automated Release"
62: task @name, &t
63: namespace @name do
64: desc "Shipit: Automated Release (Only run prepare phase)"
65: task :prepare, &t
66:
67:
68: end
69: end