Sha256: 61551e1ff8599a5451b6438ac79620067abcba7ab7adba02f3e51b2e675b3f90

Contents?: true

Size: 881 Bytes

Versions: 12

Compression:

Stored size: 881 Bytes

Contents

#--
# Copyright (c) 2010-2012 Engine Yard, Inc.
# Copyright (c) 2007-2009 Sun Microsystems, Inc.
# This source code is available under the MIT license.
# See the file LICENSE.txt for details.
#++

module Warbler
  module Traits
    # The Rack trait adds config.ru to a Rack-based war project.
    class Rack
      include Trait

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

      def self.requires?(trait)
        trait == Traits::War
      end

      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

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

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
warbler-1.4.4 lib/warbler/traits/rack.rb
warbler-1.4.3 lib/warbler/traits/rack.rb
warbler-1.4.2 lib/warbler/traits/rack.rb
warbler-1.4.1 lib/warbler/traits/rack.rb
warbler-1.4.0 lib/warbler/traits/rack.rb
warbler-1.4.0.beta2 lib/warbler/traits/rack.rb
warbler-1.4.0.beta1 lib/warbler/traits/rack.rb
warbler-1.3.8 lib/warbler/traits/rack.rb
warbler-1.3.7 lib/warbler/traits/rack.rb
warbler-1.3.6 lib/warbler/traits/rack.rb
warbler-1.3.5 lib/warbler/traits/rack.rb
warbler-1.3.4 lib/warbler/traits/rack.rb