Class: GitStats::StatsView::View
- Inherits:
-
Object
- Object
- GitStats::StatsView::View
- Defined in:
- lib/git_stats/stats_view/view.rb
Instance Method Summary collapse
- #all_templates(root = '') ⇒ Object
-
#initialize(view_data, out_path) ⇒ View
constructor
A new instance of View.
- #render_all ⇒ Object
- #render_authors ⇒ Object
Constructor Details
#initialize(view_data, out_path) ⇒ View
Returns a new instance of View.
5 6 7 8 |
# File 'lib/git_stats/stats_view/view.rb', line 5 def initialize(view_data, out_path) @view_data, @out_path = view_data, out_path @layout = Tilt.new("../../../../templates/layout.haml".absolute_path) end |
Instance Method Details
#all_templates(root = '') ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/git_stats/stats_view/view.rb', line 37 def all_templates(root = '') (Dir["../../../../templates/#{root}**/[^_]*.haml".absolute_path].map { |f| Pathname.new(f) }.map { |f| f.relative_path_from(Pathname.new('../../../../templates'.absolute_path)).sub_ext('') }.map(&:to_s) - %w(layout)) end |
#render_all ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/git_stats/stats_view/view.rb', line 10 def render_all prepare_static_content prepare_assets all_templates.reject {|t| t =~ /author_details/}.each do |template| output = Template.new(template, @layout).render(@view_data, author: @view_data.repo, links: links) write(output, "#@out_path/#{template}.html") end end |
#render_authors ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/git_stats/stats_view/view.rb', line 22 def done = [] @view_data.repo..sort_by { |a| -a.commits.size }.each do || next if done.include? .dirname done << .dirname (all_templates('activity/') + all_templates('author_details')).each do |template| output = Template.new(template, @layout).render(@view_data, author: , links: links, active_page: "/authors/#{.dirname}/#{template}") write(output, "#@out_path/authors/#{.dirname}/#{template}.html") end end end |