Skip to content

Commit

Permalink
set application helper + add Application.run for more intuitive binary
Browse files Browse the repository at this point in the history
  • Loading branch information
kares committed May 4, 2016
1 parent c45f0db commit cccf748
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
2 changes: 1 addition & 1 deletion bin/warble
Expand Up @@ -8,4 +8,4 @@
#++

require 'warbler'
Warbler::Application.new.run
Warbler::Application.run
23 changes: 16 additions & 7 deletions lib/warbler/application.rb
Expand Up @@ -42,7 +42,7 @@ def load_rakefile

desc "Feature: make a runnable archive (e.g. java -jar rails.war -S rake db:migrate)"
task :runnable => "#{wt.name}:runnable"

desc "Feature: precompile all Ruby files"
task :compiled => "#{wt.name}:compiled"

Expand All @@ -54,26 +54,28 @@ def load_rakefile
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
set_application Warbler.project_application = Rake::Application.new
Rake::Application::DEFAULT_RAKEFILES.each do |rf|
if File.exist?(rf)
begin
load rf
rescue LoadError => e
rescue LoadError
load File.join(Dir.getwd, rf)
end
break
end
end
Rake.application = self
set_application
@project_loaded = true
end

# Run the application: The equivalent code for the +warble+ command
# is simply <tt>Warbler::Application.new.run</tt>.
# is simply <tt>Warbler::Application.run</tt>.
def self.run; new.run end

# Run the application.
def run
Rake.application = self
set_application
super
end

Expand All @@ -92,4 +94,11 @@ def standard_rake_options
end
end
end

private

def set_application(app = self)
Rake.application = app
end

end

0 comments on commit cccf748

Please sign in to comment.