Class: Application
- Inherits:
-
Object
- Object
- Application
- Defined in:
- lib/conan/manifest_builder.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#artifact_id ⇒ Object
Returns the value of attribute artifact_id.
-
#artifact_meta_data ⇒ Object
Returns the value of attribute artifact_meta_data.
-
#extension ⇒ Object
Returns the value of attribute extension.
-
#group_id ⇒ Object
Returns the value of attribute group_id.
-
#id ⇒ Object
Returns the value of attribute id.
-
#platform_type ⇒ Object
Returns the value of attribute platform_type.
-
#sha1 ⇒ Object
Returns the value of attribute sha1.
-
#url_segment ⇒ Object
Returns the value of attribute url_segment.
-
#version ⇒ Object
Returns the value of attribute version.
Instance Method Summary collapse
- #compareVersion(target_version, deployed_version) ⇒ Object
- #download(location) ⇒ Object
- #findRequestedVersion(requested_version = 'LATEST') ⇒ Object
-
#initialize(id, project_name, platform_type, url_segment = nil) ⇒ Application
constructor
A new instance of Application.
- #isDeployedAt(url) ⇒ Object
- #readArtifactMetadata(xml) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(id, project_name, platform_type, url_segment = nil) ⇒ Application
Returns a new instance of Application.
276 277 278 279 280 281 282 283 |
# File 'lib/conan/manifest_builder.rb', line 276 def initialize(id, project_name, platform_type, url_segment=nil) @id = id @platform_type = platform_type @url_segment = url_segment || id mvn_id = project_name.split(':') @group_id = mvn_id[0] @artifact_id = mvn_id[1] end |
Instance Attribute Details
#artifact_id ⇒ Object
Returns the value of attribute artifact_id.
274 275 276 |
# File 'lib/conan/manifest_builder.rb', line 274 def artifact_id @artifact_id end |
#artifact_meta_data ⇒ Object
Returns the value of attribute artifact_meta_data.
274 275 276 |
# File 'lib/conan/manifest_builder.rb', line 274 def end |
#extension ⇒ Object
Returns the value of attribute extension.
274 275 276 |
# File 'lib/conan/manifest_builder.rb', line 274 def extension @extension end |
#group_id ⇒ Object
Returns the value of attribute group_id.
274 275 276 |
# File 'lib/conan/manifest_builder.rb', line 274 def group_id @group_id end |
#id ⇒ Object
Returns the value of attribute id.
274 275 276 |
# File 'lib/conan/manifest_builder.rb', line 274 def id @id end |
#platform_type ⇒ Object
Returns the value of attribute platform_type.
274 275 276 |
# File 'lib/conan/manifest_builder.rb', line 274 def platform_type @platform_type end |
#sha1 ⇒ Object
Returns the value of attribute sha1.
274 275 276 |
# File 'lib/conan/manifest_builder.rb', line 274 def sha1 @sha1 end |
#url_segment ⇒ Object
Returns the value of attribute url_segment.
274 275 276 |
# File 'lib/conan/manifest_builder.rb', line 274 def url_segment @url_segment end |
#version ⇒ Object
Returns the value of attribute version.
274 275 276 |
# File 'lib/conan/manifest_builder.rb', line 274 def version @version end |
Instance Method Details
#compareVersion(target_version, deployed_version) ⇒ Object
365 366 367 368 369 370 371 372 373 374 |
# File 'lib/conan/manifest_builder.rb', line 365 def compareVersion(target_version, deployed_version) target = Gem::Version.new(target_version) begin found = Gem::Version.new(deployed_version) target > found rescue => e puts "Error parsing version number: #{e}" false end end |
#download(location) ⇒ Object
319 320 321 322 |
# File 'lib/conan/manifest_builder.rb', line 319 def download(location) puts "- Provision #{group_id}:#{artifact_id}:#{extension}:#{version}" @artifact_repo.downloadArtifact(location, group_id, artifact_id, extension, version, sha1) end |
#findRequestedVersion(requested_version = 'LATEST') ⇒ Object
285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 |
# File 'lib/conan/manifest_builder.rb', line 285 def findRequestedVersion(requested_version='LATEST') puts("Finding requested version: #{requested_version}") extension = case platform_type when :jvm "jar" when :rails_zip "tar.gz" else raise "Unsupported platform type: #{platform_type}" end readArtifactMetadata(@artifact_repo.resolveArtifact(group_id, artifact_id, extension, requested_version)) puts "- Found version #{version} #{@id} artifact\n"+ " Artifact: #{self}\n" + " Checksum: #{@sha1}" end |
#isDeployedAt(url) ⇒ Object
324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 |
# File 'lib/conan/manifest_builder.rb', line 324 def isDeployedAt(url) # only deploy if an older version is found, or no app found res = false begin response = RestClient::Request.new( :method => :get, :url => url, :headers => { 'accept' => :json, 'content_type' => :json }, :timeout => 5, :open_timeout => 5 ).execute if (response.code == 200) = JSON.parse(response.to_str) puts '' puts "+- Currently at #{url}:" printM = ->(s) { puts " | #{s}: #{build_metadata[s]}" } printM.call 'Implementation-Title' printM.call 'Build-Version' printM.call 'Build-Url' printM.call 'Git-Commit' current_ver = ["Build-Version"] end #TODO make sure the artifact id matches too, currently finding "Implementation-Title": "apollo" in build metadata if (compareVersion(@version, current_ver)) puts "#{@artifact_id} #{@version} is newer than version found at #{url}: #{current_ver}" else puts "#{@artifact_id} #{@version} found at #{url}. (skipping deployment)" res = true end rescue => e puts "#{@artifact_id} not found at #{url}: #{e}" end res end |
#readArtifactMetadata(xml) ⇒ Object
301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 |
# File 'lib/conan/manifest_builder.rb', line 301 def readArtifactMetadata(xml) = xml begin doc = REXML::Document.new(xml) rescue Exception => e puts "Failed to parse meta-data: #{e}" puts "--------------------------------" puts xml puts "--------------------------------" raise "Unreadable artifact meta-data for #{self}" end = doc.elements['/artifact-resolution/data'] @version = .elements['version'].text @sha1 = .elements['sha1'].text @extension = .elements['extension'].text end |
#to_s ⇒ Object
376 377 378 |
# File 'lib/conan/manifest_builder.rb', line 376 def to_s "#{artifact_id}-#{version}.#{extension}" end |