Class: Markout::Revision

Inherits:
Object
  • Object
show all
Defined in:
lib/markout/revision.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(repo, commit) ⇒ Revision

Returns a new instance of Revision.



9
10
11
12
13
14
15
16
# File 'lib/markout/revision.rb', line 9

def initialize(repo, commit)
  @repo   = repo
  @sha    = commit.sha
  @date   = commit.date
  @author = commit.author.to_s
  @subject, @message = parse_commit_message(commit)
  @diff   = commit.show.first.diff || ''
end

Instance Attribute Details

#authorObject (readonly)

Returns the value of attribute author.



7
8
9
# File 'lib/markout/revision.rb', line 7

def author
  @author
end

#dateObject (readonly)

Returns the value of attribute date.



7
8
9
# File 'lib/markout/revision.rb', line 7

def date
  @date
end

#shaObject (readonly)

Returns the value of attribute sha.



7
8
9
# File 'lib/markout/revision.rb', line 7

def sha
  @sha
end

#subjectObject (readonly)

Returns the value of attribute subject.



7
8
9
# File 'lib/markout/revision.rb', line 7

def subject
  @subject
end

Instance Method Details

#diff(options = {}) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/markout/revision.rb', line 18

def diff(options={})
  case options[:format]
    when 'raw'    then @diff
    when 'short'  then short_diff
    when 'inline' then inline_diff
    else @diff
  end
end

#message(options = {}) ⇒ Object



27
28
29
30
31
32
33
34
# File 'lib/markout/revision.rb', line 27

def message(options={})
  case options[:format]
  when :html
    return RDiscount.new(@message).to_html
  else
    return @message
  end
end