Class: Volley::Descriptor
- Inherits:
-
Object
- Object
- Volley::Descriptor
- Defined in:
- lib/volley/descriptor.rb
Constant Summary collapse
- REGEX =
/[\@\:\/\\\-]/
Instance Attribute Summary collapse
-
#branch ⇒ Object
readonly
Returns the value of attribute branch.
-
#project ⇒ Object
readonly
Returns the value of attribute project.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
- #get ⇒ Object
-
#initialize(desc = "", options = {}) ⇒ Descriptor
constructor
A new instance of Descriptor.
- #to_s ⇒ Object
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 = { :partial => false, }.merge() 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
#branch ⇒ Object (readonly)
Returns the value of attribute branch.
5 6 7 |
# File 'lib/volley/descriptor.rb', line 5 def branch @branch end |
#project ⇒ Object (readonly)
Returns the value of attribute project.
5 6 7 |
# File 'lib/volley/descriptor.rb', line 5 def project @project end |
#version ⇒ Object (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
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 |
#get ⇒ Object
28 29 30 |
# File 'lib/volley/descriptor.rb', line 28 def get [@project, @branch, @version] end |
#to_s ⇒ Object
36 37 38 |
# File 'lib/volley/descriptor.rb', line 36 def to_s "#@project@#@branch:#@version" end |