class UrlBuilder
Attributes
build[R]
repo[R]
token[R]
Public Class Methods
new(repo, build, token = nil)
click to toggle source
# File lib/circle/art.rb, line 8 def initialize(repo, build, token = nil) @repo = repo @build = build @token = token raise "Missing repo" unless @repo raise "Missing build" unless @build system("mkdir -p downloads/#{build}/artifacts") system("mkdir -p downloads/builds") end
Public Instance Methods
download!(parser)
click to toggle source
# File lib/circle/art.rb, line 48 def download!(parser) if Dir[File.join(folder_path, "*")].length > 0 puts "Already downloaded." return end parser.urls.each_with_index do |url, index| cmd = "curl #{url}?circle-token=#{token} --output downloads/#{build}/artifacts/#{parser.filenames[index]}" puts "🌐 #{cmd}" system(cmd) end end
download_cmd()
click to toggle source
# File lib/circle/art.rb, line 29 def download_cmd "curl #{download_url}" end
download_json!()
click to toggle source
# File lib/circle/art.rb, line 33 def download_json! # save json unless File.exist?(json_path) system(download_cmd + " --output #{json_path}") end end
download_url()
click to toggle source
# File lib/circle/art.rb, line 44 def download_url "https://circleci.com/api/v1.1/project/github/#{repo}/#{build}/artifacts?circle-token=#{token}" end
folder_path()
click to toggle source
# File lib/circle/art.rb, line 21 def folder_path "downloads/#{build}/artifacts" end
json_path()
click to toggle source
# File lib/circle/art.rb, line 25 def json_path "downloads/#{build}.json" end
url()
click to toggle source
# File lib/circle/art.rb, line 40 def url "https://circleci.com/gh/#{repo}/#{build}#artifacts" end