Class: Travis::Artifacts::Cli

Inherits:
Object
  • Object
show all
Defined in:
lib/travis/artifacts/cli.rb

Constant Summary collapse

VALID_COMMANDS =
['upload']

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv = nil) ⇒ Cli

Returns a new instance of Cli.


10
11
12
13
14
15
# File 'lib/travis/artifacts/cli.rb', line 10

def initialize(argv = nil)
  @argv    = argv || ARGV
  @options = { :paths => [], :private => false }
  @paths   = []
  @client  = Travis::Client.new
end

Instance Attribute Details

#argvObject (readonly)

Returns the value of attribute argv


5
6
7
# File 'lib/travis/artifacts/cli.rb', line 5

def argv
  @argv
end

#clientObject

Returns the value of attribute client


6
7
8
# File 'lib/travis/artifacts/cli.rb', line 6

def client
  @client
end

#commandObject

Returns the value of attribute command


6
7
8
# File 'lib/travis/artifacts/cli.rb', line 6

def command
  @command
end

#optionsObject (readonly)

Returns the value of attribute options


5
6
7
# File 'lib/travis/artifacts/cli.rb', line 5

def options
  @options
end

#pathsObject (readonly)

Returns the value of attribute paths


5
6
7
# File 'lib/travis/artifacts/cli.rb', line 5

def paths
  @paths
end

Instance Method Details

#rootObject


27
28
29
# File 'lib/travis/artifacts/cli.rb', line 27

def root
  options[:root] || Dir.pwd
end

#startObject

I would like to use option parser for now, to keep the code super simple and without too much external dependencies, if it grows too much, I may change it


20
21
22
23
24
25
# File 'lib/travis/artifacts/cli.rb', line 20

def start
  parse!
  create_paths

  execute_command
end

#uploadObject


31
32
33
# File 'lib/travis/artifacts/cli.rb', line 31

def upload
  Uploader.new(paths, options).upload
end