Class: Artifactory::Resource::BuildComponent
- Defined in:
- lib/artifactory/resources/build_component.rb
Class Method Summary collapse
-
.all(options = {}) ⇒ Array<Resource::BuildComponent>
Search for all compoenents for which build data exists.
-
.find(name, options = {}) ⇒ Resource::BuildComponent?
Find (fetch) data for a particular build component.
- .from_hash(hash, options = {}) ⇒ Object
Instance Method Summary collapse
-
#builds ⇒ Collection::Build
The list of build data for this component.
-
#delete(options = {}) ⇒ Boolean
Remove this component’s build data stored in Artifactory.
-
#last_started ⇒ Object
Return this object’s
last_started
. -
#last_started=(value) ⇒ Object
Set this object’s
last_started
. -
#last_started? ⇒ Boolean
Determines if the
last_started
value exists and is truthy. -
#name ⇒ Object
Return this object’s
name
. -
#name=(value) ⇒ Object
Set this object’s
name
. -
#name? ⇒ Boolean
Determines if the
name
value exists and is truthy. -
#rename(new_name, options = {}) ⇒ Boolean
Rename a build component.
-
#uri ⇒ Object
Return this object’s
uri
. -
#uri=(value) ⇒ Object
Set this object’s
uri
. -
#uri? ⇒ Boolean
Determines if the
uri
value exists and is truthy.
Methods inherited from Base
attribute, attributes, #attributes, #client, #client=, #client?, #extract_client!, extract_client!, find_from_config, format_repos!, #format_repos!, from_url, has_attribute?, #initialize, #inspect, list_from_config, #set, #to_hash, #to_json, #to_matrix_properties, #to_query_string_parameters, #to_s, url_safe, #url_safe
Constructor Details
This class inherits a constructor from Artifactory::Resource::Base
Class Method Details
.all(options = {}) ⇒ Array<Resource::BuildComponent>
Search for all compoenents for which build data exists.
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/artifactory/resources/build_component.rb', line 34 def all( = {}) client = extract_client!() client.get('/api/build')['builds'].map do |component| from_hash(component, client: client) end.compact.flatten rescue Error::HTTPError => e # Artifactory returns a 404 instead of an empty list when there are no # builds. Whoever decided that was a good idea clearly doesn't # understand the point of REST interfaces... raise unless e.code == 404 [] end |
.find(name, options = {}) ⇒ Resource::BuildComponent?
Find (fetch) data for a particular build component
65 66 67 68 69 70 |
# File 'lib/artifactory/resources/build_component.rb', line 65 def find(name, = {}) client = extract_client!() all.find do |component| component.name == name end end |
.from_hash(hash, options = {}) ⇒ Object
75 76 77 78 79 80 81 |
# File 'lib/artifactory/resources/build_component.rb', line 75 def from_hash(hash, = {}) super.tap do |instance| # Remove the leading / from the `uri` value. Converts `/foo` to `foo`. instance.name = instance.uri.slice(1..-1) instance.last_started = Time.parse(instance.last_started) rescue nil end end |
Instance Method Details
#builds ⇒ Collection::Build
The list of build data for this component.
98 99 100 101 102 |
# File 'lib/artifactory/resources/build_component.rb', line 98 def builds @builds ||= Collection::Build.new(self, name: name) do Resource::Build.all(name) end end |
#delete(options = {}) ⇒ Boolean
Remove this component’s build data stored in Artifactory
118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/artifactory/resources/build_component.rb', line 118 def delete( = {}) params = {}.tap do |param| param[:buildNumbers] = [:build_numbers].join(',') if [:build_numbers] param[:artifacts] = 1 if [:artifacts] param[:deleteAll] = 1 if [:delete_all] end endpoint = api_path + "?#{to_query_string_parameters(params)}" client.delete(endpoint, {}) true rescue Error::HTTPError => e false end |
#last_started ⇒ Object
Return this object’s last_started
86 |
# File 'lib/artifactory/resources/build_component.rb', line 86 attribute :last_started |
#last_started=(value) ⇒ Object
Set this object’s last_started
86 |
# File 'lib/artifactory/resources/build_component.rb', line 86 attribute :last_started |
#last_started? ⇒ Boolean
Determines if the last_started
value exists and is truthy
86 |
# File 'lib/artifactory/resources/build_component.rb', line 86 attribute :last_started |
#name ⇒ Object
Return this object’s name
85 |
# File 'lib/artifactory/resources/build_component.rb', line 85 attribute :name, ->{ raise 'Name missing!' } |
#name=(value) ⇒ Object
Set this object’s name
85 |
# File 'lib/artifactory/resources/build_component.rb', line 85 attribute :name, ->{ raise 'Name missing!' } |
#name? ⇒ Boolean
Determines if the name
value exists and is truthy
85 |
# File 'lib/artifactory/resources/build_component.rb', line 85 attribute :name, ->{ raise 'Name missing!' } |
#rename(new_name, options = {}) ⇒ Boolean
Rename a build component.
141 142 143 144 145 146 147 |
# File 'lib/artifactory/resources/build_component.rb', line 141 def rename(new_name, = {}) endpoint = "/api/build/rename/#{url_safe(name)}" + "?to=#{new_name}" client.post(endpoint, {}) true rescue Error::HTTPError => e false end |
#uri ⇒ Object
Return this object’s uri
84 |
# File 'lib/artifactory/resources/build_component.rb', line 84 attribute :uri |
#uri=(value) ⇒ Object
Set this object’s uri
84 |
# File 'lib/artifactory/resources/build_component.rb', line 84 attribute :uri |
#uri? ⇒ Boolean
Determines if the uri
value exists and is truthy
84 |
# File 'lib/artifactory/resources/build_component.rb', line 84 attribute :uri |