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
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
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 = { :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
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 |
#get ⇒ Object
29 30 31 |
# File 'lib/volley/descriptor.rb', line 29 def get [@project, @branch, @version] end |
#to_s ⇒ Object
37 38 39 |
# File 'lib/volley/descriptor.rb', line 37 def to_s "#@project@#@branch:#@version" end |