Class: Occson::Commands::Run

Inherits:
Object
  • Object
show all
Defined in:
lib/occson/commands/run.rb

Instance Method Summary collapse

Constructor Details

#initialize(source, command, arguments, access_token, passphrase) ⇒ Run

Returns a new instance of Run.



6
7
8
9
10
11
12
# File 'lib/occson/commands/run.rb', line 6

def initialize(source, command, arguments, access_token, passphrase)
  @source = source
  @command = command
  @arguments = arguments
  @access_token = access_token
  @passphrase = passphrase
end

Instance Method Details

#callObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/occson/commands/run.rb', line 14

def call
  content = Document.new(@source, @access_token, @passphrase).download
  return unless content

  parsed_content = content.split("\n").map do |line|
    next if line.start_with?('#')

    line.split('=', 2) # @TODO handle wrapped values
  end.compact

  envs = parsed_content.to_h

  system(envs, @command, *@arguments)
end