Class: Warbler::Traits::Rails
- Inherits:
-
Object
- Object
- Warbler::Traits::Rails
show all
- Includes:
- Warbler::Trait
- Defined in:
- lib/warbler/traits/rails.rb
Overview
The Rails trait invokes the Rake environment task and sets up Rails for a war-based project.
Instance Attribute Summary
#config
Class Method Summary
collapse
Instance Method Summary
collapse
#add_init_load_path, #add_main_rb, included, #initialize, #update_archive, #update_gem_path
Class Method Details
.detect? ⇒ Boolean
14
15
16
|
# File 'lib/warbler/traits/rails.rb', line 14
def self.detect?
File.exist?("config/environment.rb")
end
|
.requires?(trait) ⇒ Boolean
18
19
20
|
# File 'lib/warbler/traits/rails.rb', line 18
def self.requires?(trait)
trait == Traits::War
end
|
Instance Method Details
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/warbler/traits/rails.rb', line 44
def after_configure
config.init_contents << "#{config.warbler_templates}/rails.erb"
begin
rails_env = config.webxml.rails.env
unless IO.readlines("config/environments/#{rails_env}.rb").grep(/^\s*config\.threadsafe!/).empty? &&
IO.readlines("config/environment.rb").grep(/^\s*config\.threadsafe!/).empty?
config.webxml.jruby.min.runtimes = 1 unless Integer === config.webxml.jruby.min.runtimes
config.webxml.jruby.max.runtimes = 1 unless Integer === config.webxml.jruby.max.runtimes
end
rescue
end
end
|
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/warbler/traits/rails.rb', line 22
def before_configure
config.jar_name = default_app_name
config.webxml.rails.env = ENV['RAILS_ENV'] || 'production'
return unless Warbler.framework_detection
return false unless task = Warbler.project_application.lookup("environment")
task.invoke rescue nil
return false unless defined?(::Rails)
config.dirs << "tmp" if File.directory?("tmp")
config.webxml.booter = :rails
unless (defined?(::Rails.vendor_rails?) && ::Rails.vendor_rails?) || File.directory?("vendor/rails")
config.gems["rails"] = ::Rails::VERSION::STRING
end
if defined?(::Rails.configuration.gems)
::Rails.configuration.gems.each do |g|
config.gems << Gem::Dependency.new(g.name, g.requirement) if Dir["vendor/gems/#{g.name}*"].empty?
end
end
end
|
#default_app_name ⇒ Object
58
59
60
|
# File 'lib/warbler/traits/rails.rb', line 58
def default_app_name
File.basename(File.expand_path(defined?(::Rails.root) ? ::Rails.root : (defined?(RAILS_ROOT) ? RAILS_ROOT : Dir.getwd)))
end
|