Class: RAW::RawRunner
- Inherits:
-
AntProject
- Object
- AntProject
- RAW::RawRunner
- Defined in:
- lib/raw_runner.rb
Instance Attribute Summary collapse
-
#root ⇒ Object
readonly
Returns the value of attribute root.
-
#targets ⇒ Object
readonly
Returns the value of attribute targets.
Attributes inherited from AntProject
#ant_version, #declarative, #default_target, #logger, #project
Instance Method Summary collapse
- #build(task) ⇒ Object
- #condition(options) ⇒ Object
-
#initialize(template, root = '', options = {}) ⇒ RawRunner
constructor
A new instance of RawRunner.
- #load_script(template) ⇒ Object
-
#property(options) ⇒ Object
defines a property in ant and also an instance variable.
- #target(name, depends = [], &block) ⇒ Object
Methods inherited from AntProject
#basedir, #build_instance_variable, #build_properties, #init_project, #instvar, #method_missing, #name, #property_value, #to_s
Constructor Details
#initialize(template, root = '', options = {}) ⇒ RawRunner
Returns a new instance of RawRunner.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/raw_runner.rb', line 24 def initialize(template, root = '', = {}) super() @targets = Hash.new @root = File.(File.directory?(root) ? root : File.join(Dir.pwd, root)) if template logger.info("Applying script #{template}") load_script(template) # Execute the given target if [:target] build [:target] # or find the default and call that elsif @default_target build @default_target.to_sym end logger.info"Applied script #{template}" else logger.info"No script #{template} applied." end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class RAW::AntProject
Instance Attribute Details
#root ⇒ Object (readonly)
Returns the value of attribute root.
22 23 24 |
# File 'lib/raw_runner.rb', line 22 def root @root end |
#targets ⇒ Object (readonly)
Returns the value of attribute targets.
22 23 24 |
# File 'lib/raw_runner.rb', line 22 def targets @targets end |
Instance Method Details
#build(task) ⇒ Object
97 98 99 100 101 |
# File 'lib/raw_runner.rb', line 97 def build(task) block = targets[task] raise "No target named #{task} found." unless block block.call end |
#condition(options) ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/raw_runner.rb', line 66 def condition() property = [:property] environment = [:value] if name build_instance_variable([name, [:location] || [:value]]) elsif file || environment build_properties else logger.debug .inspect raise "No name or file attribute given for property!" end method_missing(:property, ) end |
#load_script(template) ⇒ Object
83 84 85 86 87 88 89 90 91 |
# File 'lib/raw_runner.rb', line 83 def load_script(template) begin code = open(template).read self.instance_eval(code) rescue LoadError, Errno::ENOENT => e raise "The script #{template} could not be loaded. Error: #{e}" end end |
#property(options) ⇒ Object
defines a property in ant and also an instance variable
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/raw_runner.rb', line 49 def property() name = [:name] file = [:file] environment = [:environment] method_missing(:property, ) if name build_instance_variable([name, [:location] || [:value]]) elsif file || environment build_properties else logger.debug .inspect raise "No name or file attribute given for property!" end end |
#target(name, depends = [], &block) ⇒ Object
93 94 95 |
# File 'lib/raw_runner.rb', line 93 def target(name, depends = [], &block) targets[name] = block end |