Class: Rake::ShipitTask
- Inherits:
-
TaskLib
- Object
- TaskLib
- Rake::ShipitTask
- Includes:
- Term::ANSIColor
- Defined in:
- lib/shipit.rb
Defined Under Namespace
Modules: Step
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#steps ⇒ Object
readonly
Returns the value of attribute steps.
Instance Method Summary collapse
- #define ⇒ Object
-
#initialize(name = :shipit, &block) ⇒ ShipitTask
constructor
A new instance of ShipitTask.
Constructor Details
#initialize(name = :shipit, &block) ⇒ ShipitTask
Returns a new instance of ShipitTask.
20 21 22 23 24 |
# File 'lib/shipit.rb', line 20 def initialize(name=:shipit, &block) @name = name @block = block define end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
13 14 15 |
# File 'lib/shipit.rb', line 13 def name @name end |
#steps ⇒ Object (readonly)
Returns the value of attribute steps.
14 15 16 |
# File 'lib/shipit.rb', line 14 def steps @steps end |
Instance Method Details
#define ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/shipit.rb', line 26 def define t = Proc.new do |t| puts green { "Preparing steps... " } steps = [] def steps.state @state ||= {} end eigenclass = class <<steps; self; end plugins = self.class.const_get(:Step) plugins.constants.each do |i| eigenclass.__send__(:define_method, i) do |*args| self << ret = plugins.const_get(i).new(self, *args) ret end end @block.call(steps) steps.each do |s| puts cyan { "Running Step (Prepare): #{s.class.name}" } s.prepare if s.respond_to? :prepare end puts green { "done." } unless t.name =~ /:prepare$/ puts puts green { "Steps: #{steps.map{|i| i.class.name.sub(/.+::/, "")}.join(", ")}" } puts "Really run? Cancel to press Ctrl+C." $stdin.gets steps.each do |s| puts red { "Running Step: #{s.class.name}" } s.run end puts green { "done." } end end desc "Shipit: Automated Release" task @name, &t namespace @name do desc "Shipit: Automated Release (Only run prepare phase)" task :prepare, &t # desc "Shipit: Automated Release (Dry run)" # task :dryrun, &t end end |