Class: ChangesetSelector
- Inherits:
-
Object
- Object
- ChangesetSelector
- Defined in:
- lib/vcseif/connection.rb
Instance Attribute Summary collapse
-
#attribute ⇒ Object
Returns the value of attribute attribute.
-
#relation ⇒ Object
Returns the value of attribute relation.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(condition) ⇒ ChangesetSelector
constructor
A new instance of ChangesetSelector.
Constructor Details
#initialize(condition) ⇒ ChangesetSelector
Returns a new instance of ChangesetSelector.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/vcseif/connection.rb', line 12 def initialize(condition) """ A ChangesetSelector instance is of the form: attribute relational_operator value_or_expression Prime our 3 instance attributes of interest in case the regex match fails """ @attribute = "" @relation = "" @value = "" # define our extractor regex to handle a string with "attribute relation value_or_expression_that_may have spaces" # examples: 'Revision = 4' or 'Author = NilsLofgren' or "CommitTimestamp >= '2012-09-12T17:32:49.000Z'" # We only support these relational operators (=, !=, <, <=, >, >=) attr_identifier_pattern = '[a-zA-Z@$%&*].*[a-zA-Z0-9_@$%&*]+' relational_operators = ['=', '!=', '<', '<=', '>', '>='] relations = "%s" % [relational_operators.join('|')] selector_pattern_spec = "^(?<attribute>%s)\s+(?<relation>%s)\s+(?<value>.+)$" % [attr_identifier_pattern, relations] selector_patt = Regexp.compile(selector_pattern_spec) md = selector_patt.match(condition) if not md.nil? @attribute = md[:attribute].strip() @relation = md[:relation] @value = md[:value].strip() end if (@attribute.empty? or @relation.empty? or @value.empty?) problem = "Invalid Changeset Selector specification: %s" % condition confex = VCSEIF_Exceptions::ConfigurationError.new(problem) raise confex, problem end end |
Instance Attribute Details
#attribute ⇒ Object
Returns the value of attribute attribute.
10 11 12 |
# File 'lib/vcseif/connection.rb', line 10 def attribute @attribute end |
#relation ⇒ Object
Returns the value of attribute relation.
10 11 12 |
# File 'lib/vcseif/connection.rb', line 10 def relation @relation end |
#value ⇒ Object
Returns the value of attribute value.
10 11 12 |
# File 'lib/vcseif/connection.rb', line 10 def value @value end |