Parent

Included Modules

Warbler::Traits::Rails

The Rails trait invokes the Rake environment task and sets up Rails for a war-based project.

Public Class Methods

detect?() click to toggle source
# File lib/warbler/traits/rails.rb, line 14
def self.detect?
  File.exist?("config/environment.rb")
end
requires?(trait) click to toggle source
# File lib/warbler/traits/rails.rb, line 18
def self.requires?(trait)
  trait == Traits::War
end

Public Instance Methods

after_configure() click to toggle source
# File lib/warbler/traits/rails.rb, line 45
def after_configure
  config.init_contents << "#{config.warbler_templates}/rails.erb"

  if threadsafe_enabled? or rails_4?
    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

  config.includes += FileList["public/assets/manifest-*.json"].existing
  config.includes += FileList["public/assets/manifest.yml"].existing
end
before_configure() click to toggle source
# 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
  config.script_files << "#{config.warbler_scripts}/rails.rb"
end
default_app_name() click to toggle source
# File lib/warbler/traits/rails.rb, line 57
def default_app_name
  File.basename(File.expand_path(defined?(::Rails.root) ? ::Rails.root : (defined?(RAILS_ROOT) ? RAILS_ROOT : Dir.getwd)))
end
rails_4?() click to toggle source
# File lib/warbler/traits/rails.rb, line 72
def rails_4?
  begin
    unless IO.readlines("Gemfile").grep(/^\s*gem\s('|")rails('|"),\s('|")4\.\d+\.\d+/).empty? &&
        IO.readlines("Gemfile.lock").grep(/^\s*rails\s\([=~><]*\s*4\.(\d+)\.(\d+).*\)$/).empty?
      return true
    end
  rescue
  end
end
threadsafe_enabled?() click to toggle source
# File lib/warbler/traits/rails.rb, line 61
def threadsafe_enabled?
  rails_env = config.webxml.rails.env
  begin
    unless IO.readlines("config/environments/#{rails_env}.rb").grep(/^\s*config\.threadsafe!/).empty? &&
        IO.readlines("config/environment.rb").grep(/^\s*config\.threadsafe!/).empty?
      return true
    end
  rescue
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.