Class: Buildr::Application

Inherits:
Rake::Application
  • Object
show all
Defined in:
lib/buildr/core/application.rb

Overview

:nodoc:

Constant Summary collapse

DEFAULT_BUILDFILES =

Deprecated: rakefile/Rakefile, removed in 1.5

['buildfile', 'Buildfile'] + DEFAULT_RAKEFILES

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeApplication

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.expand_path('.buildr', ENV['HOME'])
  mkpath @home_dir unless File.exist?(@home_dir)
  @settings = Settings.new(self)
  @on_completion = []
  @on_failure = []
end

Instance Attribute Details

#gemsObject (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_dirObject (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

#settingsObject (readonly)

Returns the Settings associated with this build.



165
166
167
# File 'lib/buildr/core/application.rb', line 165

def settings
  @settings
end

Instance Method Details

#build_filesObject

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

#buildfileObject

: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.expand_path(rakefile))
end

#deprecated(message) ⇒ Object

:call-seq:

deprecated(message)

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.'


199
200
201
202
203
204
205
206
207
208
# File 'lib/buildr/core/application.rb', line 199

def deprecated(message) #:nodoc:
  return unless verbose
  "#{caller[1]}: Deprecated: #{message}".tap do |message|
    @deprecated ||= {}
    unless @deprecated[message]
      @deprecated[message] = true
      warn message
    end
  end
end

#environmentObject

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

#runObject



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