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

Returns a new instance of Descriptor.



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

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 (readonly)

Returns the value of attribute version.



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

def version
  @version
end

Class Method Details

.valid?(desc) ⇒ Boolean

Returns:

  • (Boolean)


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

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



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

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

#getObject



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

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

#to_sObject



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

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