Class: Buildr::Application
- Includes:
- CommandLineInterface
- Defined in:
- lib/buildr/core/application.rb
Overview
:nodoc:
Constant Summary collapse
- DEFAULT_BUILDFILES =
['buildfile', 'Buildfile'] + DEFAULT_RAKEFILES
Constants included from CommandLineInterface
Instance Attribute Summary collapse
-
#environment ⇒ Object
readonly
Copied from BUILD_ENV.
-
#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.
Instance Method Summary collapse
-
#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).
-
#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
-
#settings ⇒ Object
Returns the Settings associated with this build.
-
#switch_to_namespace(names) ⇒ Object
Not for external consumption.
Methods included from CommandLineInterface
#collect_tasks, #command_line_options, #do_option, #help, #parse_options, #usage, #version
Constructor Details
#initialize ⇒ Application
Returns a new instance of Application.
117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/buildr/core/application.rb', line 117 def initialize super @rakefiles = DEFAULT_BUILDFILES @name = 'Buildr' @requires = [] @top_level_tasks = [] collect_tasks @home_dir = File.('.buildr', ENV['HOME']) mkpath @home_dir, :verbose=>false unless File.exist?(@home_dir) @environment = ENV['BUILDR_ENV'] ||= 'development' @on_completion = [] @on_failure = [] end |
Instance Attribute Details
#environment ⇒ Object (readonly)
Copied from BUILD_ENV.
140 141 142 |
# File 'lib/buildr/core/application.rb', line 140 def environment @environment end |
#gems ⇒ Object (readonly)
Returns list of Gems associated with this buildfile, as listed in build.yaml. Each entry is of type Gem::Specification.
134 135 136 |
# File 'lib/buildr/core/application.rb', line 134 def gems @gems end |
#home_dir ⇒ Object (readonly)
Buildr home directory, .buildr under user’s home directory.
137 138 139 |
# File 'lib/buildr/core/application.rb', line 137 def home_dir @home_dir end |
Instance Method Details
#build_files ⇒ Object
Files that complement the buildfile itself
156 157 158 |
# File 'lib/buildr/core/application.rb', line 156 def build_files #:nodoc: buildfile.prerequisites end |
#buildfile ⇒ Object
:call-seq:
buildfile
Returns the buildfile as a task that you can use as a dependency.
151 152 153 |
# File 'lib/buildr/core/application.rb', line 151 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 |
#on_completion(&block) ⇒ Object
Yields to block on successful completion. Primarily used for notifications.
177 178 179 |
# File 'lib/buildr/core/application.rb', line 177 def on_completion(&block) @on_completion << block end |
#on_failure(&block) ⇒ Object
Yields to block on failure with exception. Primarily used for notifications.
182 183 184 |
# File 'lib/buildr/core/application.rb', line 182 def on_failure(&block) @on_failure << block end |
#run ⇒ Object
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
# File 'lib/buildr/core/application.rb', line 160 def run standard_exception_handling do find_buildfile load_gems load_artifacts load_tasks load_requires load_buildfile load_imports task('buildr:initialize').invoke top_level end title, = 'Your build has completed', "#{Dir.pwd}\nbuildr #{@top_level_tasks.join(' ')}" @on_completion.each { |block| block.call(title, ) rescue nil } end |
#settings ⇒ Object
Returns the Settings associated with this build.
143 144 145 146 |
# File 'lib/buildr/core/application.rb', line 143 def settings fail "Internal error: Called Buildr.settings before buildfile located" unless rakefile @settings ||= Settings.new(self) end |
#switch_to_namespace(names) ⇒ Object
Not for external consumption.
187 188 189 190 191 192 193 194 |
# File 'lib/buildr/core/application.rb', line 187 def switch_to_namespace(names) #:nodoc: current, @scope = @scope, names begin yield ensure @scope = current end end |