little refactor

This commit is contained in:
Tomasz Gieniusz 2012-10-08 18:49:41 +02:00
parent 9d3df90b24
commit bc44bfa01d
3 changed files with 8 additions and 8 deletions

View File

@ -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

View File

@ -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

View File

@ -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