Class: Travis::CLI::Gh::Upload

Inherits:
Write
  • Object
show all
Defined in:
lib/travis/cli/gh/upload.rb

Constant Summary

Constants inherited from Write

Write::USER_FORMAT

Instance Method Summary collapse

Methods inherited from Write

#create, #create?, #get, #parse_user, #put, #update, #update?, #write

Methods included from GitHub::Authenticated

#auth, #gh, #plugin_config

Methods included from GitHub::Error

#gh_error

Instance Method Details

#run(*paths) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/travis/cli/gh/upload.rb', line 9

def run(*paths)
  paths.each do |source|
    error "cannot read #{source}" unless File.readable? source
    target  = File.basename(source)
    target  = File.join(prefix, target) if prefix
    message = "Uploading " << color(source, :important)
    message << " as " << color(target, :important) if target != source
    say message
    write(target, File.read(source))
  end
rescue GH::Error => e
  gh_error(e)
end