Module: Rsm::Actions

Included in:
Base
Defined in:
lib/rsm/actions.rb

Constant Summary

TAR_OPTS =
{:gz => '-z', :bz2 => '-j'}.freeze

Instance Method Summary collapse

Instance Method Details

#application_rootObject



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/rsm/actions.rb', line 5

def application_root
  unless @application_root
    @application_root = if options[:capistrano]
      "#{options[:apps_root]}/#{name}/#{options[:capistrano]}/current"
    else
      "#{options[:apps_root]}/#{name}"
    end
    @application_root = Pathname.new(@application_root)
    say "Application root: #{@application_root}" if options[:verbose]
  end
  @application_root
end

#downloaded_file(name, compressor) ⇒ Object

relative downloaded filename

name

application name

compressor

:gz or :bz2



31
32
33
# File 'lib/rsm/actions.rb', line 31

def downloaded_file(name, compressor)
  "#{name}.tar.#{compressor}"
end

#fetch_temporary_archive(name, uri, compressor) ⇒ Object

download archive form uri and temporary save it

name

application name

uri

source URI - supported by open-uri.

compressor

:gz or :bz2



39
40
41
# File 'lib/rsm/actions.rb', line 39

def fetch_temporary_archive(name, uri, compressor)
  get uri, downloaded_file(name, compressor)
end

#run_ruby_binary(command, config = {}) ⇒ Object



18
19
20
21
22
23
24
25
26
# File 'lib/rsm/actions.rb', line 18

def run_ruby_binary(command, config = {})
  rvmrc = application_root.join(".rvmrc")
  with = if rvmrc.exist?
    File.new(rvmrc).readline.strip + " exec"
  else
    "#{Thor::Util.ruby_command} -S"
  end
  run(command, config.merge(:with => with))
end

#unpack_compressed_archive(name, compressor) ⇒ Object

unpack temporary archive file

name

application name

compressor

:gz or :bz2



46
47
48
49
# File 'lib/rsm/actions.rb', line 46

def unpack_compressed_archive(name, compressor)
  opt = TAR_OPTS[compressor]
  run "tar --remove-files #{opt} -xf #{downloaded_file(name, compressor)}"
end