Class: Volley::Descriptor

Inherits:
Object
  • Object
show all
Defined in:
lib/volley/descriptor.rb

Constant Summary collapse

REGEX =
/[\@\:\/\\\-]/

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(desc = "", options = {}) ⇒ Descriptor



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/volley/descriptor.rb', line 8

def initialize(desc="", options={})
  @options = {
      :partial => false,
  }.merge(options)

  if desc
    @project = nil
    @branch = nil
    @version = nil

    list = desc.split(REGEX)
    raise "error parsing descriptor: #{desc}" if (list.count < 2 || list.count > 4) && !@options[:partial]

    (@project, @branch, @version, @after) = list
    @version ||= "latest"
    @version = "#@version-#@after" if @version != "latest" && @after

    raise "error parsing descriptor: #{desc}" unless (@project && @branch && @version) || @options[:partial]
  end
end

Instance Attribute Details

#branchObject (readonly)

Returns the value of attribute branch.



5
6
7
# File 'lib/volley/descriptor.rb', line 5

def branch
  @branch
end

#projectObject (readonly)

Returns the value of attribute project.



5
6
7
# File 'lib/volley/descriptor.rb', line 5

def project
  @project
end

#versionObject

Returns the value of attribute version.



6
7
8
# File 'lib/volley/descriptor.rb', line 6

def version
  @version
end

Class Method Details

.valid?(desc) ⇒ Boolean



42
43
44
45
46
47
# File 'lib/volley/descriptor.rb', line 42

def valid?(desc)
  return false if desc.nil? || desc.blank?
  list = desc.split(REGEX)
  return false if (list.count < 2 || list.count > 4)
  true
end

Instance Method Details

#==(other) ⇒ Object



33
34
35
# File 'lib/volley/descriptor.rb', line 33

def ==(other)
  @project == other.project && @branch == other.branch && @version == other.version
end

#getObject



29
30
31
# File 'lib/volley/descriptor.rb', line 29

def get
  [@project, @branch, @version]
end

#to_sObject



37
38
39
# File 'lib/volley/descriptor.rb', line 37

def to_s
  "#@project@#@branch:#@version"
end