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
|
class GitStats::CLI
|
||||||
|
|
||||||
def self.start(*args)
|
def self.start(*args)
|
||||||
unless args.size == 2
|
if args.size == 2
|
||||||
puts "Wrong number of arguments"
|
|
||||||
help
|
|
||||||
else
|
|
||||||
repo_path, out_path = args
|
repo_path, out_path = args
|
||||||
validate(repo_path, out_path)
|
validate(repo_path, out_path)
|
||||||
GitStats::Generator.new(repo_path, out_path).generate
|
GitStats::Generator.new(repo_path, out_path).generate
|
||||||
Launchy.open("#{out_path}/index.html")
|
Launchy.open("#{out_path}/index.html")
|
||||||
|
else
|
||||||
|
puts "Wrong number of arguments"
|
||||||
|
help
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -8,6 +8,6 @@ class GitStats::Generator
|
|||||||
data.gather_all_data
|
data.gather_all_data
|
||||||
GitStats::Assets.prepare(@out_path)
|
GitStats::Assets.prepare(@out_path)
|
||||||
output = GitStats::Template.new('index').render(data)
|
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
|
||||||
end
|
end
|
||||||
|
@ -3,11 +3,11 @@ require 'tilt'
|
|||||||
class GitStats::Template
|
class GitStats::Template
|
||||||
def initialize(name)
|
def initialize(name)
|
||||||
@name = name
|
@name = name
|
||||||
@@layout ||= Tilt.new("templates/layout.haml")
|
@layout = Tilt.new("templates/layout.haml")
|
||||||
@template = Tilt.new("templates/#{@name}.haml")
|
@template = Tilt.new("templates/#@name.haml")
|
||||||
end
|
end
|
||||||
|
|
||||||
def render(data)
|
def render(data)
|
||||||
@@layout.render { @template.render(data) }
|
@layout.render { @template.render(data) }
|
||||||
end
|
end
|
||||||
end
|
end
|
Loading…
Reference in New Issue
Block a user