Class: Cany::Recipes::Rails
- Inherits:
-
Cany::Recipe
- Object
- Cany::Recipe
- Cany::Recipes::Rails
- Defined in:
- lib/cany/recipes/rails.rb
Defined Under Namespace
Classes: DSL
Instance Attribute Summary collapse
-
#assets_env ⇒ Object
Returns the value of attribute assets_env.
-
#compile_assets ⇒ Object
Returns the value of attribute compile_assets.
Attributes inherited from Cany::Recipe
Instance Method Summary collapse
- #binary ⇒ Object
- #build ⇒ Object
- #clean ⇒ Object
-
#initialize(*args) ⇒ Rails
constructor
A new instance of Rails.
- #prepare ⇒ Object
Methods inherited from Cany::Recipe
#configure, #create, #depend, #exec, from_name, hook, #hook, #install, #install_content, #install_dir, #install_link, #install_service, option, #option, #recipe, register_as, #rmtree, #ruby_bin, #run_hook
Methods included from Mixins::DependMixin
Constructor Details
#initialize(*args) ⇒ Rails
Returns a new instance of Rails.
13 14 15 16 17 |
# File 'lib/cany/recipes/rails.rb', line 13 def initialize(*args) @compile_assets = true @assets_env = 'production' super end |
Instance Attribute Details
#assets_env ⇒ Object
Returns the value of attribute assets_env.
11 12 13 |
# File 'lib/cany/recipes/rails.rb', line 11 def assets_env @assets_env end |
#compile_assets ⇒ Object
Returns the value of attribute compile_assets.
11 12 13 |
# File 'lib/cany/recipes/rails.rb', line 11 def compile_assets @compile_assets end |
Instance Method Details
#binary ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/cany/recipes/rails.rb', line 38 def binary run_hook :env, :after %w(app bin 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 |
#build ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/cany/recipes/rails.rb', line 28 def build run_hook :env, :before if compile_assets ENV['RAILS_ENV'] = assets_env ruby_bin 'bundle', 'exec', 'rake', 'assets:precompile' end ENV['RAILS_ENV'] = 'production' inner.build end |
#clean ⇒ Object
19 20 21 22 |
# File 'lib/cany/recipes/rails.rb', line 19 def clean rmtree 'tmp', 'public/assets' inner.clean end |
#prepare ⇒ Object
24 25 26 |
# File 'lib/cany/recipes/rails.rb', line 24 def prepare recipe(:bundler).configure :env_vars, RAILS_ENV: 'production' end |