Module: Ruploy

Defined in:
lib/ruploy.rb,
lib/ruploy/version.rb

Constant Summary collapse

DEFAULTS =
{
  :name         => File.basename(File.expand_path '.'),
  :address      => '127.0.0.1',
  :port         => 3000,
  :directory    => File.expand_path('.'),
  :environment  => 'production',
  :log_file     => '/var/log/rack-$PROCNAME-$PORT.log',
  :pid_file     => '/var/lock/rack-$PROCNAME-$PORT',
  :user         => 'www-data',
  :dependencies => 'apache2',
  :server_type  => 'thin'
}
VERSION =
"0.0.4"

Class Method Summary collapse

Class Method Details

.generate_init_file(config, independant = false) ⇒ Object



35
36
37
38
39
40
41
42
43
44
# File 'lib/ruploy.rb', line 35

def generate_init_file(config, independant=false)
  ruploy_init  = File.expand_path('../../data/ruploy-init.mustache', __FILE__)
  ruploy_base  = File.expand_path('../../data/ruploy-base.sh', __FILE__)
  template     = File.read(ruploy_init)
  config       = config.dup

  config[:ruploy_base] = independant ? File.read(ruploy_base) : %Q(. "#{ruploy_base}")

  Mustache.render(template, config)
end

.get_config(args, opts) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/ruploy.rb', line 18

def get_config(args, opts)
  config = DEFAULTS.merge(opts)

  unless opts[:use_defaults]
    config.merge! (config.keys - opts.keys).inject({}) { |h, key|
      h[key] = ask("#{key} ") { |q| q.default = DEFAULTS[key] }
      h
    }
  end

  config[:options]   = '--daemonize'
  config[:options]  << " #{args.join(' ')}" if args.any?
  config[:proc_name] = config[:name].gsub(/\W/, '_').squeeze('_').downcase

  return config
end