Class: Warbler::Traits::Rack

Inherits:
Object
  • Object
show all
Includes:
Warbler::Trait
Defined in:
lib/warbler/traits/rack.rb

Overview

The Rack trait adds config.ru to a Rack-based war project.

Instance Attribute Summary

Attributes included from Warbler::Trait

#config

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Warbler::Trait

#add_init_load_path, #add_main_rb, included, #initialize, #jruby_jars, #update_archive, #update_gem_path

Class Method Details

.detect?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/warbler/traits/rack.rb', line 14

def self.detect?
  !Rails.detect? && (File.exist?("config.ru") || !Dir['*/config.ru'].empty?)
end

.requirementsObject



18
19
20
# File 'lib/warbler/traits/rack.rb', line 18

def self.requirements
  [ Traits::War ]
end

Instance Method Details

#after_configureObject



28
29
30
# File 'lib/warbler/traits/rack.rb', line 28

def after_configure
  config.init_contents << "#{config.warbler_templates}/rack.erb"
end

#before_configureObject



22
23
24
25
26
# File 'lib/warbler/traits/rack.rb', line 22

def before_configure
  config.webxml.booter = :rack
  config.webinf_files += [FileList['config.ru', '*/config.ru'].detect {|f| File.exist?(f)}]
  config.webxml.rack.env = ENV['RACK_ENV'] || 'production'
end