Class: Ronan::Package

Inherits:
Base
  • Object
show all
Defined in:
lib/ronan/package.rb

Instance Attribute Summary

Attributes inherited from Base

#attributes

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

get, #initialize, #method_missing

Constructor Details

This class inherits a constructor from Ronan::Base

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Ronan::Base

Class Method Details

.where(recipe: nil) ⇒ Object



3
4
5
6
7
8
9
10
11
# File 'lib/ronan/package.rb', line 3

def self.where(recipe: nil)
  get("/v1/conans/#{recipe.name}/#{recipe.version}/#{recipe.user}/#{recipe.channel}/search") do |hash|
    hash.map do |revision, attributes|
      attributes[:revision] = revision.to_s
      attributes[:recipe] = recipe
      attributes
    end
  end
end

Instance Method Details

#<=>(other) ⇒ Object



30
31
32
33
34
35
36
37
38
# File 'lib/ronan/package.rb', line 30

def <=>(other)
  result = self.settings[:os] <=> other.settings[:os]
  result = self.settings[:arch] <=> other.settings[:arch] if result == 0
  result = self.settings[:compiler] <=> other.settings[:compiler] if result == 0
  result = self.settings[:"compiler.version"] <=> other.settings[:"compiler.version"] if result == 0
  result = self.settings[:"compiler.libcxx"] <=> other.settings[:"compiler.libcxx"] if result == 0
  result = self.settings[:build_type] <=> other.settings[:build_type] if result == 0
  result
end

#downloadsObject



13
14
15
# File 'lib/ronan/package.rb', line 13

def downloads
  @downloads ||= Downloads.where(package: self)
end

#filenameObject



21
22
23
24
25
26
27
28
# File 'lib/ronan/package.rb', line 21

def filename
  # settings has keys: :os, :"compiler.libcxx", :arch, :compiler, :build_type, :"compiler.version"
  name = "#{recipe.name}-#{settings[:os]}-#{settings[:arch]}-#{recipe.version}"
  if !["any", "release", "relwithdebinfo"].include?(settings[:build_type].downcase)
    (name << settings[:build_type])
  end
  "#{name.downcase}.tgz"
end

#to_hObject



40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/ronan/package.rb', line 40

def to_h
  {
    settings: settings,
    options: options,
    requires: requires,
    recipe_hash: recipe_hash,
    revision: revision,
    recipe: recipe.to_h,
    filename: filename,
    url: url
  }
end

#to_jsonObject



53
54
55
# File 'lib/ronan/package.rb', line 53

def to_json
  to_h.to_json
end

#urlObject



17
18
19
# File 'lib/ronan/package.rb', line 17

def url
  downloads.url("conan_package.tgz")
end