Module: Rsm::Actions
- Included in:
- Base
- Defined in:
- lib/rsm/actions.rb
Constant Summary collapse
- TAR_OPTS =
{:gz => '-z', :bz2 => '-j'}.freeze
Instance Method Summary collapse
- #application_root ⇒ Object
-
#downloaded_file(name, compressor) ⇒ Object
- relative downloaded filename name
- application name compressor
-
:gz
or:bz2
.
-
#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
.
- download archive form
- #run_ruby_binary(command, config = {}) ⇒ Object
-
#unpack_compressed_archive(name, compressor) ⇒ Object
- unpack temporary archive file name
- application name compressor
-
:gz
or:bz2
.
Instance Method Details
#application_root ⇒ Object
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 [:capistrano] "#{[:apps_root]}/#{name}/#{[:capistrano]}/current" else "#{[:apps_root]}/#{name}" end @application_root = Pathname.new(@application_root) say "Application root: #{@application_root}" if [: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 |