class Dpl::Ctx::Test
Attributes
Public Class Methods
Source
# File lib/dpl/ctx/test.rb, line 14 def initialize @cmds = [] @stderr = StringIO.new @stdout = {} super('dpl') end
Calls superclass method
Public Instance Methods
Source
# File lib/dpl/ctx/test.rb, line 36 def apt_get(name, cmd = name) cmds << "[apt:get] #{name} (#{cmd})" end
Source
# File lib/dpl/ctx/test.rb, line 32 def apts_get(apts) apts.each { |apt| apt_get(*apt) } end
Source
# File lib/dpl/ctx/test.rb, line 227 def chmod(perm, path) cmds << [:chmod, perm, path].join(' ') end
Source
# File lib/dpl/ctx/test.rb, line 97 def deprecate_opt(key, msg) msg = "please use #{msg}" if msg.is_a?(Symbol) warn "Deprecated option #{key} used (#{msg})." end
Source
# File lib/dpl/ctx/test.rb, line 93 def error(message) raise Error, message end
Source
# File lib/dpl/ctx/test.rb, line 250 def except(hash, *keys) hash.reject { |key, _| keys.include?(key) } end
Source
# File lib/dpl/ctx/test.rb, line 203 def file_size(path) File.size(path.sub(File.expand_path('~').to_s, './home')) end
Source
# File lib/dpl/ctx/test.rb, line 21 def fold(name) cmds << "[fold] #{name}" yield.tap { cmds << "[unfold] #{name}" } end
Source
# File lib/dpl/ctx/test.rb, line 44 def gem_require(name, version = nil, opts = {}) # not sure why this is needed. bundler should take care of this, but # it does not for octokit for whatever reason begin require opts[:require] || name rescue StandardError nil end cmds << "[gem:require] #{name} (#{version}, #{opts})" end
Source
# File lib/dpl/ctx/test.rb, line 40 def gems_require(gems) gems.each { |gem| gem_require(*gem) } end
Source
# File lib/dpl/ctx/test.rb, line 146 def git_ls_remote?(_url, _ref) true end
Source
# File lib/dpl/ctx/test.rb, line 150 def git_remote_urls ['git://origin.git'] end
Source
# File lib/dpl/ctx/test.rb, line 154 def git_rev_parse(ref) "ref: #{ref}" end
Source
# File lib/dpl/ctx/test.rb, line 193 def logger(level = :info) logger = Logger.new(stderr) logger.level = Logger.const_get(level.to_s.upcase) logger end
Source
# File lib/dpl/ctx/test.rb, line 207 def move_files(paths) paths.each do |path| mv(path, "/tmp/#{File.basename(path)}") end end
Source
# File lib/dpl/ctx/test.rb, line 219 def mv(src, dest) cmds << [:mv, src, dest].join(' ') end
Source
# File lib/dpl/ctx/test.rb, line 55 def npm_install(name, cmd = name) cmds << "[npm:install] #{name} (#{cmd})" end
Source
# File lib/dpl/ctx/test.rb, line 59 def pip_install(name, cmd = name, version = nil) cmds << "[pip:install] #{name} (#{cmd}, #{version})" end
Source
# File lib/dpl/ctx/test.rb, line 85 def print(chars) cmds << "[print] #{chars}" end
Source
# File lib/dpl/ctx/test.rb, line 223 def rm_rf(path) cmds << [:rm_rf, path].join(' ') end
Source
# File lib/dpl/ctx/test.rb, line 68 def shell(cmd, _opts = {}) info cmd.msg if cmd.msg? info cmd.echo if cmd.echo? cmds << cmd.cmd return stdout[cmd.key] if stdout.key?(cmd.key) cmd.capture? ? 'captured_stdout' : true end
Source
# File lib/dpl/ctx/test.rb, line 63 def ssh_keygen(_name, file) File.open(file, 'w+') { |f| f.write('private-key') } File.open("#{file}.pub", 'w+') { |f| f.write('ssh-rsa public-key') } end
Source
# File lib/dpl/ctx/test.rb, line 182 def tmp_dir FileUtils.mkdir_p('tmp') 'tmp' end
Source
# File lib/dpl/ctx/test.rb, line 213 def unmove_files(paths) paths.each do |path| mv("/tmp/#{File.basename(path)}", path) end end
Source
# File lib/dpl/ctx/test.rb, line 26 def validate_runtimes(runtimes) runtimes.each do |name, requirements| cmds << "[validate:runtime] #{name} (#{requirements.join(', ')})" end end
Source
# File lib/dpl/ctx/test.rb, line 231 def write_file(path, content, _chmod = nil) path = File.expand_path(path) path = path.sub(File.expand_path('~').to_s, './home') FileUtils.mkdir_p(File.dirname(path)) File.open(path, 'w+') { |f| f.write(content) } end
Source
# File lib/dpl/ctx/test.rb, line 238 def write_netrc(machine, login, password) write_file('~/.netrc', sq(<<-RC)) machine #{machine} login #{login} password #{password} RC end