absolute paths building so it can be used as a gem

This commit is contained in:
Tomasz Gieniusz 2012-10-22 22:19:12 +02:00
parent 54301365f8
commit 015202d1e1
6 changed files with 42 additions and 8 deletions

View file

@ -11,4 +11,4 @@ require 'lazy_high_charts'
require 'launchy'
require 'i18n'
Dir['lib/**/*.rb'].each { |r| require File.expand_path(r) }
require 'git_stats/base'

29
lib/git_stats/base.rb Normal file
View file

@ -0,0 +1,29 @@
require 'git_stats/core_extensions/hash'
require 'git_stats/core_extensions/string'
require 'git_stats/core_extensions/symbol'
require 'git_stats/version'
require 'git_stats/i18n'
require 'git_stats/by_field_finder'
require 'git_stats/cli'
require 'git_stats/generator'
require 'git_stats/git_data/activity'
require 'git_stats/git_data/author'
require 'git_stats/git_data/blob'
require 'git_stats/git_data/command_parser'
require 'git_stats/git_data/command_runner'
require 'git_stats/git_data/commit'
require 'git_stats/git_data/repo'
require 'git_stats/git_data/short_stat'
require 'git_stats/stats_view/template'
require 'git_stats/stats_view/view'
require 'git_stats/stats_view/view_data'
require 'git_stats/stats_view/charts/activity_charts'
require 'git_stats/stats_view/charts/authors_charts'
require 'git_stats/stats_view/charts/chart'
require 'git_stats/stats_view/charts/charts'
require 'git_stats/stats_view/charts/repo_charts'

View file

@ -0,0 +1,5 @@
class String
def absolute_path
Pathname.new(__FILE__).expand_path.join(self).cleanpath.to_s
end
end

View file

@ -1 +1 @@
I18n.load_path += Dir['config/locales/*.yml']
I18n.load_path += Dir['../../../../config/locales/*.yml'.absolute_path]

View file

@ -4,7 +4,7 @@ module GitStats
def initialize(name, layout=nil)
@name = name
@layout = layout
@template = Tilt.new("templates/#@name.haml")
@template = Tilt.new("../../../../templates/#@name.haml".absolute_path)
end
def render(data, params={})

View file

@ -3,7 +3,7 @@ module GitStats
class View
def initialize(view_data, out_path)
@view_data, @out_path = view_data, out_path
@layout = Tilt.new("templates/layout.haml")
@layout = Tilt.new("../../../../templates/layout.haml".absolute_path)
end
def render_all
@ -34,10 +34,10 @@ module GitStats
end
def all_templates(root = '')
Dir["templates/#{root}**/[^_]*.haml"].map {
Dir["../../../../templates/#{root}**/[^_]*.haml".absolute_path].map {
|f| Pathname.new(f)
}.map { |f|
f.relative_path_from(Pathname.new('templates')).sub_ext('')
f.relative_path_from(Pathname.new('../../../../templates'.absolute_path)).sub_ext('')
}.map(&:to_s) - %w(layout)
end
@ -59,11 +59,11 @@ module GitStats
end
def prepare_static_content
FileUtils.cp_r(Dir['templates/static/*'], @out_path)
FileUtils.cp_r(Dir["../../../../templates/static/*".absolute_path], @out_path)
end
def prepare_assets
FileUtils.cp_r('templates/assets', @out_path)
FileUtils.cp_r('../../../../templates/assets'.absolute_path, @out_path)
end
end