Class: Buildr::Application
- Defined in:
- lib/buildr/core/application.rb
Overview
:nodoc:
Constant Summary collapse
- DEFAULT_BUILDFILES =
['buildfile', 'Buildfile', 'buildfile.rb', 'Buildfile.rb']
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.
114 115 116 117 118 119 120 121 122 123 |
# File 'lib/buildr/core/application.rb', line 114 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.
146 147 148 |
# File 'lib/buildr/core/application.rb', line 146 def gems @gems end |
#home_dir ⇒ Object (readonly)
Buildr home directory, .buildr under user’s home directory.
149 150 151 |
# File 'lib/buildr/core/application.rb', line 149 def home_dir @home_dir end |
Instance Method Details
#build_completed(title, message) ⇒ Object
Call on_completion hooks with the given title and message
183 184 185 186 187 |
# File 'lib/buildr/core/application.rb', line 183 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
190 191 192 193 194 |
# File 'lib/buildr/core/application.rb', line 190 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
167 168 169 170 |
# File 'lib/buildr/core/application.rb', line 167 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.
162 163 164 |
# File 'lib/buildr/core/application.rb', line 162 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.'
205 206 207 208 209 210 211 212 213 214 |
# File 'lib/buildr/core/application.rb', line 205 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.
152 153 154 |
# File 'lib/buildr/core/application.rb', line 152 def environment ENV['BUILDR_ENV'] end |
#on_completion(&block) ⇒ Object
Yields to block on successful completion. Primarily used for notifications.
173 174 175 |
# File 'lib/buildr/core/application.rb', line 173 def on_completion(&block) @on_completion << block end |
#on_failure(&block) ⇒ Object
Yields to block on failure with exception. Primarily used for notifications.
178 179 180 |
# File 'lib/buildr/core/application.rb', line 178 def on_failure(&block) @on_failure << block end |
#run ⇒ Object
125 126 127 128 129 130 131 132 |
# File 'lib/buildr/core/application.rb', line 125 def run @start = Time.now standard_exception_handling do init 'Buildr' load_buildfile top_level end end |
#switch_to_namespace(names) ⇒ Object
Not for external consumption.
135 136 137 138 139 140 141 142 |
# File 'lib/buildr/core/application.rb', line 135 def switch_to_namespace(names) #:nodoc: current, @scope = @scope, names begin yield ensure @scope = current end end |