Class: Svnx::Revision::ArgumentFactory
- Inherits:
-
Object
- Object
- Svnx::Revision::ArgumentFactory
- Includes:
- Logue::Loggable
- Defined in:
- lib/svnx/revision/argfactory.rb
Constant Summary collapse
- DATE_REGEXP =
Regexp.new '^\{(.*?)\}'
- SVN_ARGUMENT_WORDS =
%w{ HEAD BASE COMMITTED PREV }
Instance Method Summary collapse
- #create(value, args = Hash.new) ⇒ Object
- #create_for_fixnum(value, args) ⇒ Object
- #create_for_string(value, args) ⇒ Object
Instance Method Details
#create(value, args = Hash.new) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/svnx/revision/argfactory.rb', line 17 def create value, args = Hash.new case value when Fixnum create_for_fixnum value, args when String create_for_string value, args when Symbol raise RevisionError.new "symbol not yet handled" when Date # $$$ this (and Time) will probably have to be converted to svn's format raise RevisionError.new "date not yet handled" when Time raise RevisionError.new "time not yet handled" end end |
#create_for_fixnum(value, args) ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/svnx/revision/argfactory.rb', line 33 def create_for_fixnum value, args if value < 0 # these are log entries: RelativeArgument.new value, entries: args[:entries] else IndexArgument.new value end end |
#create_for_string(value, args) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/svnx/revision/argfactory.rb', line 42 def create_for_string value, args case when SVN_ARGUMENT_WORDS.include?(value) StringArgument.new value when md = RELATIVE_REVISION_RE.match(value) RelativeArgument.new md[0].to_i, entries: args[:entries] when DATE_REGEXP.match(value) StringArgument.new value else IndexArgument.new value.to_i end end |