class BundleDepot::SCPStore
Attributes
host[R]
password[R]
path[R]
user[R]
Public Class Methods
new(host, user, password, path = ".")
click to toggle source
# File lib/bundle_depot/cache.rb, line 35 def initialize(host, user, password, path = ".") @host = host @user = user @password = password @path = path end
Public Instance Methods
cached?(file)
click to toggle source
# File lib/bundle_depot/cache.rb, line 42 def cached?(file) target = File.join(path, File.basename(file)) output = "false" Net::SSH.start(host, user, { password: password}) do |session| output = session.exec! "test -e #{target} && echo 'true'" end output && output.strip == "true" end
fetch(file, dest_dir)
click to toggle source
# File lib/bundle_depot/cache.rb, line 60 def fetch(file, dest_dir) source = File.join(path, file) target = File.join(dest_dir, file) Net::SCP.download!(host, user, source, target, ssh: { password: password }) rescue Net::SCP::Error raise BundleNotFound end
store(file)
click to toggle source
# File lib/bundle_depot/cache.rb, line 53 def store(file) Net::SSH.start(host, user, { password: password}) do |session| session.exec! "mkdir -p #{path}" session.scp.upload! file, File.join(path, File.basename(file)) end end