Class: PackageCloud::Repository
- Inherits:
-
Object
- Object
- Object
- PackageCloud::Repository
show all
- Defined in:
- lib/package_cloud/repository.rb
Instance Method Summary
collapse
Methods inherited from Object
#method_missing, #respond_to?
Constructor Details
#initialize(attrs, config) ⇒ Repository
Returns a new instance of Repository.
3
4
5
6
|
# File 'lib/package_cloud/repository.rb', line 3
def initialize(attrs, config)
@attrs = attrs
@config = config
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class PackageCloud::Object
Instance Method Details
#create_package(file_path, dist_id) ⇒ Object
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/package_cloud/repository.rb', line 8
def create_package(file_path, dist_id)
file_data = File.new(file_path, 'rb')
base_url = @config.base_url
url = base_url + paths["create_package"]
begin
RestClient.post(url, package: {package_file: file_data,
distro_version_id: dist_id})
print "success!\n".green
rescue RestClient::UnprocessableEntity => e
print "error:\n".red
json = JSON.parse(e.response)
json.each do |k,v|
puts "\n\t#{k}: #{v.join(", ")}\n"
end
puts ""
exit(1)
end
end
|
#install_script(type) ⇒ Object
27
28
29
30
|
# File 'lib/package_cloud/repository.rb', line 27
def install_script(type)
url = paths["install_script"].gsub(/:package_type/, type)
RestClient.get(url)
end
|
#private_human ⇒ Object
32
33
34
|
# File 'lib/package_cloud/repository.rb', line 32
def private_human
send(:private) ? "private".red : "public".green
end
|