Class: EasyManageClient::Downloader
- Inherits:
-
Core
- Object
- Core
- EasyManageClient::Downloader
show all
- Defined in:
- lib/easy_manage_client/downloader.rb
Overview
Instance Attribute Summary
Attributes inherited from Core
#connection, #profile, #response, #success
Instance Method Summary
collapse
Methods inherited from Core
#generate_bearer_token, #handle_response, #headers, #initialize, #params
Instance Method Details
#compiled_version_uri ⇒ Object
37
38
39
40
|
# File 'lib/easy_manage_client/downloader.rb', line 37
def compiled_version_uri
'/api/projects/by_reference/' +
::EasyManageClient.configuration(profile).compile_id.to_s
end
|
#latest_version_uri ⇒ Object
42
43
44
|
# File 'lib/easy_manage_client/downloader.rb', line 42
def latest_version_uri
'/api/projects/latest_compiled_version'
end
|
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/easy_manage_client/downloader.rb', line 16
def perform
super
return false unless success
write_to_folder
true
end
|
28
29
30
31
32
33
34
35
|
# File 'lib/easy_manage_client/downloader.rb', line 28
def perform!
perform
unless success
raise ::EasyManageClient::DownloadProcessFailed, response[:message]
end
true
end
|
#prepare_file_path_to_download ⇒ Object
52
53
54
55
56
|
# File 'lib/easy_manage_client/downloader.rb', line 52
def prepare_file_path_to_download
folder = ::EasyManageClient.configuration(profile).download_folder
extension = ::EasyManageClient.configuration(profile).extension
File.join(folder, "#{response[:reference]}.#{extension}")
end
|
#request_uri ⇒ Object
6
7
8
9
10
11
12
13
14
|
# File 'lib/easy_manage_client/downloader.rb', line 6
def request_uri
if ::EasyManageClient.configuration(profile).compile_id.nil?
return latest_version_uri
end
compiled_version_uri
end
|
#write_to_folder ⇒ Object
46
47
48
49
50
|
# File 'lib/easy_manage_client/downloader.rb', line 46
def write_to_folder
File.open(prepare_file_path_to_download, 'w') do |file|
file.write(response[:content])
end
end
|