Class: Circus::Profiles::RubyBase

Inherits:
Base
  • Object
show all
Defined in:
lib/circus/profiles/ruby_base.rb

Direct Known Subclasses

PureRb, Rack

Constant Summary collapse

BUNDLER_TOOL =
File.expand_path('../../../bundler/gem_cacher.rb', __FILE__)

Instance Method Summary collapse

Methods inherited from Base

#mark_for_persistent_run?, #package_base_dir?, #package_for_deploy, #package_for_dev, #requirements, #supported_for_development?

Constructor Details

#initialize(name, dir, props) ⇒ RubyBase

Returns a new instance of RubyBase.



10
11
12
# File 'lib/circus/profiles/ruby_base.rb', line 10

def initialize(name, dir, props)
  super(name, dir, props)
end

Instance Method Details

#cleanup_after_deploy(logger, overlay_dir) ⇒ Object



37
38
39
# File 'lib/circus/profiles/ruby_base.rb', line 37

def cleanup_after_deploy(logger, overlay_dir)
  Bundler::CircusUtil.unfix_external_paths(@dir)
end

#extra_dirsObject



41
42
43
44
45
46
47
# File 'lib/circus/profiles/ruby_base.rb', line 41

def extra_dirs
  if has_gemfile?
    ["#{@dir}/.bundle"]
  else
    []
  end
end

#prepare_for_deploy(logger, overlay_dir) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/circus/profiles/ruby_base.rb', line 25

def prepare_for_deploy(logger, overlay_dir)
  # Run the gem bundler if necessary
  if has_gemfile?
    logger.info("Bundling gems")
    return false unless run_external(logger, 'gem installation', "cd #{@dir}; bundle install")
    return false unless run_external(logger, 'gem caching', 
        "cd #{@dir}; ruby #{BUNDLER_TOOL} && rm Gemfile.lock && bundle install vendor/bundle")
  end
  
  true
end

#prepare_for_dev(logger, run_dir) ⇒ Object

Do basic gemfile preparation for dev. Don’t override dev_run_script_content, since it is the same as the deployment variant.



16
17
18
19
20
21
22
23
# File 'lib/circus/profiles/ruby_base.rb', line 16

def prepare_for_dev(logger, run_dir)
  if has_gemfile?
      # TODO: Correct behaviour if working in the presence of an existing bundler environment
    run_external(logger, 'gem installation', "cd #{@dir}; bundle check || bundle install")
  end
  
  true
end