Object
The plugin acts a base class for ecapsulating batch routines. This helps to keep the main batch context free of the clutter of private supporting methods.
Plugins are tightly coupled to the batch context, which allows them to call on the context easily. However this means plugins cannot be used independent of a batch context, and changes in the batch context can cause effects in plugin behvior that can be harder to track down and fix if a bug arises.
The context must be a subclass of Syckle::Script.
Designate the procedure to run after the main cycle procedure.
# File lib/syckle/service.rb, line 86 def self.aftcycle(name, phase=nil, &block) unless phase name, phase = *name.split(':') name, phase = 'main', name unless phase end phase = ('aft_' + phase.to_s).to_sym cycle(name, phase, &block) end
DEPRECATE: temporarily, this is a no-op to prevent old plugins from breaking.
# File lib/syckle/service.rb, line 108 def self.autorun(&block) # @autorun = block if block # @autorun ||= nil end
# File lib/syckle/service.rb, line 96 def self.available(&block) @available = block if block @available ||= nil end
# File lib/syckle/service.rb, line 102 def self.available?(project) return true unless available @available.call(project) end
Define the procedure for a given cycle-phase.
cycle '<cycle>:<phase>' do ... end
# File lib/syckle/service.rb, line 59 def self.cycle(name, phase=nil, &block) unless phase name, phase = *name.split(':') name, phase = 'main', name unless phase end if block define_method("#{name}_#{phase}", &block) else define_method("#{name}_#{phase}") do send(phase) end end end
# File lib/syckle/service.rb, line 44 def self.factory(&block) Class.new(self, &block) end
TODO: Probably should make a named registry instead.
# File lib/syckle/service.rb, line 36 def self.inherited(base) return if base.name.to_s.empty? if base.name !~ /Service$/ registry[base.basename.downcase] = base end end
NOTE: How is this being used?
# File lib/syckle/service.rb, line 49 def self.init(&block) define_method(:init, &block) end
# File lib/syckle/service.rb, line 143 def initialize(context, key, options={}) @context = context @project = context.project @key = key @options = options || {} @priority = 0 @active = true raise TypeError, "context must be a subclass of Syckle::Script" unless context.is_a?(Syckle::Script) # Syckle::DSL initialize_defaults options ||= {} options.each do |k, v| send("#{k}=", v) unless v.nil? #if respond_to?("#{k}=") && !v.nil? end end
Designate the procedure to run prior to the main cycle procedure.
# File lib/syckle/service.rb, line 75 def self.precycle(name, phase=nil, &block) unless phase name, phase = *name.split(':') name, phase = 'main', name unless phase end phase = ('pre_' + phase.to_s).to_sym cycle(name, phase, &block) end
Generated with the Darkfish Rdoc Generator 2.