Class: SVNx::Revision::Argument

Inherits:
Object
  • Object
show all
Includes:
Comparable, Logue::Loggable
Defined in:
lib/svnx/revision/argument.rb

Overview

-n means to count from the end of the list. +n means to count from the beginning of the list.

n means the literal revision number.

Constant Summary collapse

DATE_REGEXP =
Regexp.new '^\{(.*?)\}'
SVN_ARGUMENT_WORDS =
%w{ HEAD BASE COMMITTED PREV }

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ Argument

Returns a new instance of Argument.



71
72
73
# File 'lib/svnx/revision/argument.rb', line 71

def initialize value
  @value = value
end

Instance Attribute Details

#valueObject (readonly)

these are also valid revisions :working_copy :head



30
31
32
# File 'lib/svnx/revision/argument.rb', line 30

def value
  @value
end

Class Method Details

.matches_relative?(str) ⇒ Boolean

Returns:

  • (Boolean)


66
67
68
# File 'lib/svnx/revision/argument.rb', line 66

def matches_relative? str
  RELATIVE_REVISION_RE.match str
end

.new(value, args = Hash.new) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/svnx/revision/argument.rb', line 35

def new value, args = Hash.new
  # these are log entries:
  entries = args[:entries]
  
  case value
  when Fixnum
    if value < 0
      RelativeArgument.orig_new value, entries: entries
    else
      FixnumArgument.orig_new value
    end
  when String
    if SVN_ARGUMENT_WORDS.include? value
      StringArgument.orig_new value
    elsif md = RELATIVE_REVISION_RE.match(value)
      RelativeArgument.orig_new md[0].to_i, entries: entries
    elsif DATE_REGEXP.match value
      StringArgument.orig_new value
    else
      FixnumArgument.orig_new value.to_i
    end
  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

.orig_newObject



33
# File 'lib/svnx/revision/argument.rb', line 33

alias_method :orig_new, :new

Instance Method Details

#<=>(other) ⇒ Object



79
80
81
# File 'lib/svnx/revision/argument.rb', line 79

def <=> other
  @value <=> other.value
end

#to_sObject



75
76
77
# File 'lib/svnx/revision/argument.rb', line 75

def to_s
  @value.to_s
end