Class: Buildr::Application
- Defined in:
- lib/buildr/core/application.rb
Overview
:nodoc:
Constant Summary collapse
- DEFAULT_BUILDFILES =
Deprecated: rakefile/Rakefile, removed in 1.5
['buildfile', 'Buildfile', 'buildfile.rb', 'Buildfile.rb'] + DEFAULT_RAKEFILES
Instance Attribute Summary collapse
-
#gems ⇒ Object
readonly
Returns list of Gems associated with this buildfile, as listed in build.yaml.
-
#home_dir ⇒ Object
readonly
Buildr home directory, .buildr under user’s home directory.
-
#settings ⇒ Object
readonly
Returns the Settings associated with this build.
Instance Method Summary collapse
-
#build_completed(title, message) ⇒ Object
Call on_completion hooks with the given title and message.
-
#build_failed(title, message, ex = nil) ⇒ Object
Call on_failure hooks with the given title, message and exception.
-
#build_files ⇒ Object
Files that complement the buildfile itself.
-
#buildfile ⇒ Object
:call-seq: buildfile Returns the buildfile as a task that you can use as a dependency.
-
#deprecated(message) ⇒ Object
:call-seq: deprecated(message).
-
#environment ⇒ Object
Copied from BUILD_ENV.
-
#initialize ⇒ Application
constructor
A new instance of Application.
-
#on_completion(&block) ⇒ Object
Yields to block on successful completion.
-
#on_failure(&block) ⇒ Object
Yields to block on failure with exception.
- #run ⇒ Object
-
#switch_to_namespace(names) ⇒ Object
Not for external consumption.
Constructor Details
#initialize ⇒ Application
Returns a new instance of Application.
123 124 125 126 127 128 129 130 131 132 |
# File 'lib/buildr/core/application.rb', line 123 def initialize super @rakefiles = DEFAULT_BUILDFILES.dup @top_level_tasks = [] @home_dir = File.('.buildr', ENV['HOME']) mkpath @home_dir if !File.exist?(@home_dir) && File.writable?(ENV['HOME']) @settings = Settings.new(self) @on_completion = [] @on_failure = [] end |
Instance Attribute Details
#gems ⇒ Object (readonly)
Returns list of Gems associated with this buildfile, as listed in build.yaml. Each entry is of type Gem::Specification.
154 155 156 |
# File 'lib/buildr/core/application.rb', line 154 def gems @gems end |
#home_dir ⇒ Object (readonly)
Buildr home directory, .buildr under user’s home directory.
157 158 159 |
# File 'lib/buildr/core/application.rb', line 157 def home_dir @home_dir end |
Instance Method Details
#build_completed(title, message) ⇒ Object
Call on_completion hooks with the given title and message
191 192 193 194 195 |
# File 'lib/buildr/core/application.rb', line 191 def build_completed(title, ) @on_completion.each do |block| block.call(title, ) rescue nil end end |
#build_failed(title, message, ex = nil) ⇒ Object
Call on_failure hooks with the given title, message and exception
198 199 200 201 202 |
# File 'lib/buildr/core/application.rb', line 198 def build_failed(title, , ex = nil) @on_failure.each do |block| block.call(title, , ex) rescue nil end end |
#build_files ⇒ Object
Files that complement the buildfile itself
175 176 177 178 |
# File 'lib/buildr/core/application.rb', line 175 def build_files #:nodoc: deprecated 'Please call buildfile.prerequisites instead' buildfile.prerequisites end |
#buildfile ⇒ Object
:call-seq:
buildfile
Returns the buildfile as a task that you can use as a dependency.
170 171 172 |
# File 'lib/buildr/core/application.rb', line 170 def buildfile @buildfile_task ||= BuildfileTask.define_task(File.(rakefile)) end |
#deprecated(message) ⇒ Object
:call-seq:
deprecated()
Use with deprecated methods and classes. This method automatically adds the file name and line number, and the text ‘Deprecated’ before the message, and eliminated duplicate warnings. It only warns when running in verbose mode.
For example:
deprecated 'Please use new_foo instead of foo.'
213 214 215 216 217 218 219 220 221 222 |
# File 'lib/buildr/core/application.rb', line 213 def deprecated() #:nodoc: return unless verbose "#{caller[1]}: Deprecated: #{}".tap do || @deprecated ||= {} unless @deprecated[] @deprecated[] = true warn end end end |
#environment ⇒ Object
Copied from BUILD_ENV.
160 161 162 |
# File 'lib/buildr/core/application.rb', line 160 def environment ENV['BUILDR_ENV'] end |
#on_completion(&block) ⇒ Object
Yields to block on successful completion. Primarily used for notifications.
181 182 183 |
# File 'lib/buildr/core/application.rb', line 181 def on_completion(&block) @on_completion << block end |
#on_failure(&block) ⇒ Object
Yields to block on failure with exception. Primarily used for notifications.
186 187 188 |
# File 'lib/buildr/core/application.rb', line 186 def on_failure(&block) @on_failure << block end |
#run ⇒ Object
134 135 136 137 138 139 140 |
# File 'lib/buildr/core/application.rb', line 134 def run standard_exception_handling do init 'Buildr' load_buildfile top_level end end |
#switch_to_namespace(names) ⇒ Object
Not for external consumption.
143 144 145 146 147 148 149 150 |
# File 'lib/buildr/core/application.rb', line 143 def switch_to_namespace(names) #:nodoc: current, @scope = @scope, names begin yield ensure @scope = current end end |