Class: Baltix::Rake
Defined Under Namespace
Classes: InvalidRakefileError
Constant Summary collapse
- TYPE =
'Rake::Application'
- PRELOAD_MATCHER =
{ /\/rakefile(.rb)?$/i => :preload }
Constants included from Log
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#rakefile ⇒ Object
readonly
Returns the value of attribute rakefile.
Class Method Summary collapse
- .load(rakefile) ⇒ Object
-
.preload ⇒ Object
preload callback.
Instance Method Summary collapse
- #blank? ⇒ Boolean
-
#initialize(rakefile, options = {}) ⇒ Rake
constructor
A new instance of Rake.
- #present? ⇒ Boolean
- #run_task(task_name) ⇒ Object
- #tasks ⇒ Object
Methods included from Loader
app_file, extended, extended_list, load_file, mods, pre_loaders, type_hash
Methods included from Log
default_prefix, io_name_parse, ios, level, #level_match, #log, prefix, prefix_for, setup, setup_kind
Constructor Details
#initialize(rakefile, options = {}) ⇒ Rake
Returns a new instance of Rake.
39 40 41 42 43 44 45 |
# File 'lib/baltix/rake.rb', line 39 def initialize rakefile, = {} raise InvalidRakefileError unless File.file?(rakefile) @rakefile = rakefile @options = @app = self.class.load(rakefile).objects.first end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
13 14 15 |
# File 'lib/baltix/rake.rb', line 13 def app @app end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
13 14 15 |
# File 'lib/baltix/rake.rb', line 13 def @options end |
#rakefile ⇒ Object (readonly)
Returns the value of attribute rakefile.
13 14 15 |
# File 'lib/baltix/rake.rb', line 13 def rakefile @rakefile end |
Class Method Details
.load(rakefile) ⇒ Object
53 54 55 |
# File 'lib/baltix/rake.rb', line 53 def load rakefile app_file(rakefile) end |
.preload ⇒ Object
preload callback
49 50 51 |
# File 'lib/baltix/rake.rb', line 49 def preload Rake.instance_variable_set(:@application, nil) end |
Instance Method Details
#blank? ⇒ Boolean
15 16 17 |
# File 'lib/baltix/rake.rb', line 15 def blank? !@app end |
#present? ⇒ Boolean
19 20 21 |
# File 'lib/baltix/rake.rb', line 19 def present? !!@app end |
#run_task(task_name) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/baltix/rake.rb', line 27 def run_task task_name if @app Rake.instance_variable_set(:@application, @app) Dir.chdir(@app.original_dir) do @app.invoke_task(task_name) end end rescue Exception => e warn "#{e.class}: #{e.}\n\t#{e.backtrace.join("\n\t")}" end |
#tasks ⇒ Object
23 24 25 |
# File 'lib/baltix/rake.rb', line 23 def tasks @tasks ||= @app&.tasks || [] end |