Sha256: 4614d68a67c22b2783ebc1088ce1a539655055d80a42511fb880c093f8031ca8

Contents?: true

Size: 1.43 KB

Versions: 6

Compression:

Stored size: 1.43 KB

Contents

module Cany
  module Recipes
    class Rails < Recipe
      register_as :rails
      hook :env

      class DSL < Recipe::DSL
        delegate :compile_assets
      end

      attr_accessor :compile_assets

      def initialize(*args)
        @compile_assets = true
        super
      end

      def clean
        rmtree 'tmp', 'public/assets'
        inner.clean
      end

      def prepare
        recipe(:bundler).configure :env_vars, RAILS_ENV: 'production'
      end

      def build
        run_hook :env, :before
        ENV['RAILS_ENV'] = 'production'
        ruby_bin 'bundle', 'exec', 'rake', 'assets:precompile' if compile_assets
        inner.build
      end

      def binary
        run_hook :env, :after
        %w(app config.ru db Gemfile Gemfile.lock lib public Rakefile vendor).each do |item|
          install item, "/usr/share/#{spec.name}" if File.exists? item
        end

        Dir.foreach('config') do |entry|
          next if %w(. ..).include? entry
          install File.join('config', entry), "/etc/#{spec.name}"
        end
        install_link "/etc/#{spec.name}", "/usr/share/#{spec.name}/config"

        install_dir "/etc/#{spec.name}"
        install_dir "/var/tmp/#{spec.name}"
        install_dir "/var/log/#{spec.name}"

        install_link "/var/log/#{spec.name}", "/usr/share/#{spec.name}/log"
        install_link "/var/tmp/#{spec.name}", "/usr/share/#{spec.name}/tmp"
        inner.binary
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
cany-0.2.1 lib/cany/recipes/rails.rb
cany-0.2.0 lib/cany/recipes/rails.rb
cany-0.1.3 lib/cany/recipes/rails.rb
cany-0.1.2 lib/cany/recipes/rails.rb
cany-0.1.1 lib/cany/recipes/rails.rb
cany-0.1.0 lib/cany/recipes/rails.rb