Class: PVN::Revision::Argument

Inherits:
Object
  • Object
show all
Includes:
Comparable, Loggable
Defined in:
lib/pvn/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.



73
74
75
# File 'lib/pvn/revision/argument.rb', line 73

def initialize value
  @value = value
end

Instance Attribute Details

#log_entryObject (readonly)

Returns the value of attribute log_entry.



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

def log_entry
  @log_entry
end

#valueObject (readonly)

these are also valid revisions :working_copy :head



29
30
31
# File 'lib/pvn/revision/argument.rb', line 29

def value
  @value
end

Class Method Details

.matches_relative?(str) ⇒ Boolean

Returns:

  • (Boolean)


68
69
70
# File 'lib/pvn/revision/argument.rb', line 68

def matches_relative? str
  RELATIVE_REVISION_RE.match str
end

.new(value, xmllines = nil) ⇒ 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
65
66
# File 'lib/pvn/revision/argument.rb', line 35

def new value, xmllines = nil
  # these are lines from "svn log -v <file>"
  if xmllines.kind_of? Array
    xmllines = xmllines.join ''
  end
  
  case value
  when Fixnum
    if value < 0
      RelativeArgument.orig_new value, xmllines
    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, xmllines
    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/pvn/revision/argument.rb', line 33

alias_method :orig_new, :new

Instance Method Details

#<=>(other) ⇒ Object



81
82
83
# File 'lib/pvn/revision/argument.rb', line 81

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

#to_sObject



77
78
79
# File 'lib/pvn/revision/argument.rb', line 77

def to_s
  @value.to_s
end