Class: Warbler::Application
- Inherits:
-
Rake::Application
- Object
- Rake::Application
- Warbler::Application
- Defined in:
- lib/warbler/application.rb
Overview
Extension of Rake::Application that allows the warble
command to report its name properly and inject its own tasks without a Rakefile.
Instance Method Summary collapse
-
#initialize ⇒ Application
constructor
A new instance of Application.
-
#load_project_rakefile ⇒ Object
Loads the project Rakefile in a separate application.
-
#load_rakefile ⇒ Object
Sets the application name and loads Warbler’s own tasks.
-
#run ⇒ Object
Run the application: The equivalent code for the
warble
command is simplyWarbler::Application.new.run
. -
#standard_rake_options ⇒ Object
Remap the version option to display Warbler version.
Constructor Details
#initialize ⇒ Application
Returns a new instance of Application.
14 15 16 17 18 |
# File 'lib/warbler/application.rb', line 14 def initialize super Warbler.application = self @project_loaded = false end |
Instance Method Details
#load_project_rakefile ⇒ Object
Loads the project Rakefile in a separate application
49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/warbler/application.rb', line 49 def load_project_rakefile return if @project_loaded # Load any application rakefiles to aid in autodetecting applications app = Warbler.project_application = Rake::Application.new Rake.application = app Rake::Application::DEFAULT_RAKEFILES.each do |rf| if File.exist?(rf) load rf break end end Rake.application = self @project_loaded = true end |
#load_rakefile ⇒ Object
Sets the application name and loads Warbler’s own tasks
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/warbler/application.rb', line 21 def load_rakefile @name = 'warble' # Load the main warbler tasks wt = Warbler::Task.new task :default => wt.name desc "Generate a configuration file to customize your archive" task :config => "#{wt.name}:config" desc "Install Warbler tasks in your Rails application" task :pluginize => "#{wt.name}:pluginize" desc "Feature: package gem repository inside a jar" task :gemjar => "#{wt.name}:gemjar" desc "Feature: make an executable archive" task :executable => "#{wt.name}:executable" desc "Feature: precompile all Ruby files" task :compiled => "#{wt.name}:compiled" desc "Display version of Warbler" task :version => "#{wt.name}:version" end |
#run ⇒ Object
Run the application: The equivalent code for the warble
command is simply Warbler::Application.new.run
.
66 67 68 69 |
# File 'lib/warbler/application.rb', line 66 def run Rake.application = self super end |
#standard_rake_options ⇒ Object
Remap the version option to display Warbler version.
72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/warbler/application.rb', line 72 def super.map do |opt| if opt.first == '--version' ['--version', '-V', "Display the program version.", lambda { |value| puts "Warbler version #{Warbler::VERSION}" exit } ] else opt end end end |