Class: Commands::Switch

Inherits:
Object
  • Object
show all
Defined in:
lib/app-runner/commands/switch.rb

Instance Method Summary collapse

Instance Method Details

#download(serviceUrl, artifactUrl, destination) ⇒ Object



19
20
21
22
23
24
25
26
27
# File 'lib/app-runner/commands/switch.rb', line 19

def download(serviceUrl, artifactUrl, destination)
  url="#{serviceUrl}/api/artifacts/url/#{artifactUrl}"
  exitCode=system("wget \"#{url}\" -O /tmp/artifact")
  if exitCode
    FileUtils.mv '/tmp/artifact', destination['dir']+"/"+destination['filename'], :force => true
  else
    raise "Can't download artifact"
  end
end

#execute(global_options, options, args) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/app-runner/commands/switch.rb', line 5

def execute(global_options, options, args)
  config=global_options['configHash'];
  serviceUrl=ENV['artifacts_url'] or config["url"];
  if (options["url"])
    download(serviceUrl, options["url"], config["destination"])
  elsif (options["v"] && options["t"]=='mvn')
    mvn=config["mvn"];
    download(serviceUrl, "#{options['t']}:#{mvn["group"]}:#{mvn["artifactId"]}:#{options['v']}:#{mvn["type"]}", config["destination"])
  else
    p "Not suported yet this combination"
  end

end