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
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/svnx/revision/argfactory.rb', line 13 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
29 30 31 32 33 34 35 36 |
# File 'lib/svnx/revision/argfactory.rb', line 29 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
38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/svnx/revision/argfactory.rb', line 38 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 |