Class: Modification

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/header-inserter/modification.rb

Constant Summary collapse

@@revision_format =
/r(\d{1,}) \| (\S+) \| (\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}) ([+|-]?\d{2})(\d{2}) .* \| \d{1,} line[s]?\n\n(.*)\n/m
@@svn_time_format =
"%Y-%m-%d %H:%M:%S %z"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(revision, author, date, log) ⇒ Modification

Returns a new instance of Modification.



21
22
23
24
25
26
# File 'lib/header-inserter/modification.rb', line 21

def initialize revision, author, date, log
  @revision = revision
  @author = author
  @date = date
  @log = log
end

Instance Attribute Details

#authorObject (readonly)

Returns the value of attribute author.



8
9
10
# File 'lib/header-inserter/modification.rb', line 8

def author
  @author
end

#dateObject (readonly)

Returns the value of attribute date.



8
9
10
# File 'lib/header-inserter/modification.rb', line 8

def date
  @date
end

#logObject (readonly)

Returns the value of attribute log.



8
9
10
# File 'lib/header-inserter/modification.rb', line 8

def log
  @log
end

#revisionObject (readonly)

Returns the value of attribute revision.



8
9
10
# File 'lib/header-inserter/modification.rb', line 8

def revision
  @revision
end

Class Method Details

.parse(text_log) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/header-inserter/modification.rb', line 10

def Modification.parse text_log
  if @@revision_format.match text_log
    revision = $1.to_i
    author = $2
    time_zone = ($4 + ":" + $5)
    date = DateTime.strptime($3 + " " + time_zone, @@svn_time_format)
    log = $6
    Modification.new revision, author, date, log
  end
end

Instance Method Details

#<=>(other) ⇒ Object



28
29
30
# File 'lib/header-inserter/modification.rb', line 28

def <=> other
  revision <=> other.revision
end