mirror of
https://github.com/tomgi/git_stats.git
synced 2024-09-28 19:51:29 +02:00
little refactor
This commit is contained in:
parent
9d3df90b24
commit
bc44bfa01d
@ -4,14 +4,14 @@ require "launchy"
|
||||
class GitStats::CLI
|
||||
|
||||
def self.start(*args)
|
||||
unless args.size == 2
|
||||
puts "Wrong number of arguments"
|
||||
help
|
||||
else
|
||||
if args.size == 2
|
||||
repo_path, out_path = args
|
||||
validate(repo_path, out_path)
|
||||
GitStats::Generator.new(repo_path, out_path).generate
|
||||
Launchy.open("#{out_path}/index.html")
|
||||
else
|
||||
puts "Wrong number of arguments"
|
||||
help
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -8,6 +8,6 @@ class GitStats::Generator
|
||||
data.gather_all_data
|
||||
GitStats::Assets.prepare(@out_path)
|
||||
output = GitStats::Template.new('index').render(data)
|
||||
File.open("#{@out_path}/index.html", 'w') { |f| f.write output }
|
||||
File.open("#@out_path/index.html", 'w') { |f| f.write output }
|
||||
end
|
||||
end
|
||||
|
@ -3,11 +3,11 @@ require 'tilt'
|
||||
class GitStats::Template
|
||||
def initialize(name)
|
||||
@name = name
|
||||
@@layout ||= Tilt.new("templates/layout.haml")
|
||||
@template = Tilt.new("templates/#{@name}.haml")
|
||||
@layout = Tilt.new("templates/layout.haml")
|
||||
@template = Tilt.new("templates/#@name.haml")
|
||||
end
|
||||
|
||||
def render(data)
|
||||
@@layout.render { @template.render(data) }
|
||||
@layout.render { @template.render(data) }
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user