Class: Ronan::Recipe

Inherits:
Base
  • Object
show all
Defined in:
lib/ronan/recipe.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

.search(pattern) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/ronan/recipe.rb', line 3

def self.search(pattern)
  get("/v2/conans/search", q: pattern) do |hash|
    hash[:results].map do |r|
      r.match(/(\S+)\/(\S+)@(\S+)\/(\S+)/) do |m|
        {
          name: m[1],
          version: SemanticVersion.new(m[2]),
          user: m[3],
          channel: m[4]
        }
      end
    end
  end
end

Instance Method Details

#<=>(other) ⇒ Object



22
23
24
# File 'lib/ronan/recipe.rb', line 22

def <=>(other)
  self.version <=> other.version
end

#packagesObject



18
19
20
# File 'lib/ronan/recipe.rb', line 18

def packages
  Package.where(recipe: self)
end

#to_hObject



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

def to_h
  {
    name: name,
    version: version.to_s,
    user: user,
    channel: channel
  }
end

#to_jsonObject



39
40
41
# File 'lib/ronan/recipe.rb', line 39

def to_json
  to_h.to_json
end

#to_sObject



26
27
28
# File 'lib/ronan/recipe.rb', line 26

def to_s
  "#{name}/#{version}@#{user}/#{channel}"
end