Class: Precious::Views::Commit

Inherits:
Compare show all
Defined in:
lib/gollum/views/commit.rb

Constant Summary

Constants included from RouteHelpers

RouteHelpers::ROUTES

Constants included from LocaleHelpers

LocaleHelpers::NO_METHOD_MESSAGE, LocaleHelpers::YAML_VARIABLE_REGEXP

Instance Attribute Summary collapse

Attributes inherited from Compare

#allow_editing, #diff, #page, #versions

Attributes inherited from Layout

#name, #path

Instance Method Summary collapse

Methods inherited from Compare

#after, #before, #git_line?, #left_diff_line_number, #line_class, #lines, #right_diff_line_number, #show_revert

Methods included from HasPage

#escaped_url_path, #format, #id, #path

Methods inherited from Layout

#base_url, #critic_markup, #css, #custom_css, #custom_js, #custom_path, #escaped_name, #has_path, #history, #js, #latest_changes, #mathjax_config_path, #mathjax_js, #overview, #partial, #per_page_uploads, #search, #show_local_time

Methods included from TemplateCascade

#first_path_available, #template_file, #template_priority_path, #template_priority_path=

Methods included from OcticonHelpers

included, #octicon, #rocticon, #rocticon_css

Methods included from RouteHelpers

#clean_url, included, #page_route, parse_routes

Methods included from SprocketsHelpers

included, #sprockets_asset_path, #sprockets_image_path, #sprockets_javascript_tag, #sprockets_stylesheet_tag

Methods included from LocaleHelpers

#t

Methods included from AppHelpers

#extract_page_dir

Instance Attribute Details

#versionObject (readonly)

Returns the value of attribute version.



7
8
9
# File 'lib/gollum/views/commit.rb', line 7

def version
  @version
end

Instance Method Details

#authorObject



13
14
15
# File 'lib/gollum/views/commit.rb', line 13

def author
  @commit.author.name
end

#authored_dateObject



17
18
19
# File 'lib/gollum/views/commit.rb', line 17

def authored_date
  @commit.authored_date
end

#datetimeObject



21
22
23
# File 'lib/gollum/views/commit.rb', line 21

def datetime
  authored_date.utc.iso8601
end

#filesObject



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/gollum/views/commit.rb', line 29

def files
  files = @diff.force_encoding(Encoding::UTF_8).scan(%r{
    ^diff\ --git\         # diff start
    .+?                   # diff body
    (?=^diff\ --git|\Z)   # scan until next diff or string
  }sxmu)

  files.map do |diff|
    match = diff.match(%r{^diff --git (")?[ab]/(.+)(?(1)") (")?[ab]/(.+)(?(3)")})
    path = match[2]
    path = match[4] if path.nil?

    {
      path: path,
      lines: lines(diff)
    }
  end
end

#messageObject



25
26
27
# File 'lib/gollum/views/commit.rb', line 25

def message
  @commit.message
end

#titleObject



9
10
11
# File 'lib/gollum/views/commit.rb', line 9

def title
  "Changes in #{@version[0..6]}: #{message}"
end