Class: Yapt::GitLogShiv

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message) ⇒ GitLogShiv

Returns a new instance of GitLogShiv.



52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/yapt.rb', line 52

def initialize(message)
  lines = message.split("\n")
  @sha = lines.first[/\w+$/].strip
  author_line = lines[1]
  @author = author_line[/:[^<]+/].sub(/\A:/,'').strip
  just_message = lines[3..-1].join("\n")
  tracker_directives = just_message.scan(/\[.*\d+\]/)
  @tracker_ids = []
  tracker_directives.each do |directive|
    @tracker_ids << directive[/\d+/]
    just_message.gsub!(directive,'')
  end
  @message = just_message.strip
end

Instance Attribute Details

#authorObject (readonly)

Returns the value of attribute author.



51
52
53
# File 'lib/yapt.rb', line 51

def author
  @author
end

#messageObject (readonly)

Returns the value of attribute message.



51
52
53
# File 'lib/yapt.rb', line 51

def message
  @message
end

#shaObject (readonly)

Returns the value of attribute sha.



51
52
53
# File 'lib/yapt.rb', line 51

def sha
  @sha
end

#tracker_idsObject (readonly)

Returns the value of attribute tracker_ids.



51
52
53
# File 'lib/yapt.rb', line 51

def tracker_ids
  @tracker_ids
end

Class Method Details

.find(since_until) ⇒ Object



44
45
46
47
48
49
# File 'lib/yapt.rb', line 44

def self.find(since_until)
  result = `git log #{since_until}`
  commits = result.split(/^commit/).reverse.collect {|c| "commit#{c}" }
  commits.pop if commits.last == 'commit'
  commits.collect {|c| new(c) }
end

Instance Method Details

#displayObject



71
72
73
74
75
76
77
78
79
# File 'lib/yapt.rb', line 71

def display
  output = ''
  tracker_ids.each do |id|
    story = Story.find(id)
    output << View.new([story]).display("for_git_display").strip + "\n"
  end
  output << "Git commit:\n  #{message} by #{author}\n  #{github_link}\n\n"
  output
end


67
68
69
# File 'lib/yapt.rb', line 67

def github_link
  "#{Yapt.github_url_base}/commit/#{sha}"
end