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.



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

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.



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

def author
  @author
end

#messageObject (readonly)

Returns the value of attribute message.



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

def message
  @message
end

#shaObject (readonly)

Returns the value of attribute sha.



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

def sha
  @sha
end

#tracker_idsObject (readonly)

Returns the value of attribute tracker_ids.



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

def tracker_ids
  @tracker_ids
end

Class Method Details

.find(since_until) ⇒ Object



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

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



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

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

#storiesObject



72
73
74
# File 'lib/yapt.rb', line 72

def stories
  @stories ||= tracker_ids.collect {|t| Story.find(t) }
end