Class: Antwrap::AntProject
- Inherits:
-
Object
- Object
- Antwrap::AntProject
- Defined in:
- lib/ant_project.rb
Instance Attribute Summary collapse
-
#ant_version ⇒ Object
readonly
Returns the value of attribute ant_version.
-
#declarative ⇒ Object
Returns the value of attribute declarative.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#project ⇒ Object
readonly
Returns the value of attribute project.
Instance Method Summary collapse
-
#basedir ⇒ Object
The Ant Project’s basedir.
-
#initialize(options = Hash.new) ⇒ AntProject
constructor
Create an AntProject.
- #method_missing(sym, *args) ⇒ Object
-
#name ⇒ Object
The Ant Project’s name.
-
#to_s ⇒ Object
Displays the Class name followed by the AntProject name -e.g.
Constructor Details
#initialize(options = Hash.new) ⇒ AntProject
Create an AntProject. Parameters are specified via a hash: :ant_home=>Ant basedir
-A String indicating the location of the ANT_HOME directory. If provided, Antwrap will
load the classes from the ANT_HOME/lib dir. If ant_home is not provided, the Ant jar files
must be available in the CLASSPATH.
:name=>project_name
-A String indicating the name of this project.
:basedir=>project_basedir
-A String indicating the basedir of this project. Corresponds to the 'basedir' attribute
on an Ant project.
:declarative=>declarative_mode
-A boolean value indicating wether Ant tasks created by this project instance should
have their execute() method invoked during their creation. For example, with
the option :declarative=>true the following task would execute;
@antProject.echo(:message => "An Echo Task")
However, with the option :declarative=>false, the programmer is required to execute the
task explicitly;
echoTask = @antProject.echo(:message => "An Echo Task")
echoTask.execute()
Default value is <em>true</em>.
:logger=>Logger
-A Logger instance. Defaults to Logger.new(STDOUT)
:loglevel=>The level to set the logger to
-Defaults to Logger::ERROR
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/ant_project.rb', line 74 def initialize(=Hash.new) @logger = [:logger] || Logger.new(STDOUT) @logger.level = [:loglevel] || Logger::ERROR if(!@@classes_loaded && [:ant_home]) @logger.debug("loading ant jar files. Ant_Home: #{[:ant_home]}") AntwrapClassLoader.load_ant_libs([:ant_home]) @@classes_loaded = true end @logger.debug(Antwrap::ApacheAnt::Main.getAntVersion()) @ant_version = Antwrap::ApacheAnt::Main.getAntVersion()[/\d\.\d\.\d/].to_f init_project() @task_stack = Array.new end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args) ⇒ Object
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/ant_project.rb', line 93 def method_missing(sym, *args) begin task = AntTask.new(sym.to_s, self, args[0]) parent_task = @task_stack.last @task_stack << task yield self if block_given? parent_task.add(task) if parent_task if @task_stack.nitems == 1 if declarative == true @logger.debug("Executing #{task}") task.execute else @logger.debug("Returning #{task}") return task end end rescue @logger.error("Error instantiating '#{sym.to_s}' task: " + $!) raise ensure @task_stack.pop end end |
Instance Attribute Details
#ant_version ⇒ Object (readonly)
Returns the value of attribute ant_version.
47 48 49 |
# File 'lib/ant_project.rb', line 47 def ant_version @ant_version end |
#declarative ⇒ Object
Returns the value of attribute declarative.
48 49 50 |
# File 'lib/ant_project.rb', line 48 def declarative @declarative end |
#logger ⇒ Object
Returns the value of attribute logger.
48 49 50 |
# File 'lib/ant_project.rb', line 48 def logger @logger end |
#project ⇒ Object (readonly)
Returns the value of attribute project.
46 47 48 |
# File 'lib/ant_project.rb', line 46 def project @project end |
Instance Method Details
#basedir ⇒ Object
The Ant Project’s basedir. Default is ‘.’
130 131 132 |
# File 'lib/ant_project.rb', line 130 def basedir return @project.getBaseDir().getAbsolutePath(); end |
#name ⇒ Object
The Ant Project’s name. Default is ”
125 126 127 |
# File 'lib/ant_project.rb', line 125 def name return @project.getName end |
#to_s ⇒ Object
Displays the Class name followed by the AntProject name -e.g. AntProject
136 137 138 |
# File 'lib/ant_project.rb', line 136 def to_s return self.class.name + "[#{name}]" end |