Class: Vagabund::Settler::Sources::Url
- Inherits:
-
Object
- Object
- Vagabund::Settler::Sources::Url
- Defined in:
- lib/vagabund/settler/sources/url.rb
Instance Attribute Summary collapse
-
#origin ⇒ Object
readonly
Returns the value of attribute origin.
Instance Method Summary collapse
- #download(machine, target_path) ⇒ Object (also: #pull)
Instance Attribute Details
#origin ⇒ Object (readonly)
Returns the value of attribute origin.
5 6 7 |
# File 'lib/vagabund/settler/sources/url.rb', line 5 def origin @origin end |
Instance Method Details
#download(machine, target_path) ⇒ Object Also known as: pull
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/vagabund/settler/sources/url.rb', line 7 def download(machine, target_path) machine.ui.detail "Downloading #{origin} to #{target_path}..." unless machine.communicate.test "[ -d #{File.dirname(target_path)} ]" machine.communicate.sudo "mkdir -p #{File.dirname(target_path)}" machine.communicate.sudo "chown -R #{machine.ssh_info[:username]} #{File.dirname(target_path)}" machine.communicate.sudo "chgrp -R #{machine.ssh_info[:username]} #{File.dirname(target_path)}" end machine.communicate.execute "curl -L -o #{target_path} #{origin}" do |type,data| color = type == :stderr ? :red : :green = { color: color, new_line: false, prefix: false } machine.ui.detail(data, ) end target_path end |