project layout

This commit is contained in:
Tomasz Gieniusz 2012-10-08 17:58:07 +02:00
parent c98224b9cb
commit f322835ba0
5 changed files with 65 additions and 5 deletions

9
bin/gitstats Executable file
View file

@ -0,0 +1,9 @@
#!/usr/bin/env ruby
# encoding: UTF-8
lib = File.expand_path(File.dirname(__FILE__) + '/../lib')
$LOAD_PATH.unshift(lib) if File.directory?(lib) && !$LOAD_PATH.include?(lib)
# start up the CLI
require "gitstats/cli"
GitStats::CLI.start(*ARGV)

View file

@ -10,10 +10,13 @@ Gem::Specification.new do |gem|
gem.email = ["tomasz.gieniusz@gmail.com"]
gem.description = %q{Git history statistics generator}
gem.summary = %q{HTML statistics generator from git repository}
gem.homepage = ""
gem.homepage = "https://github.com/tomgi/gitstats"
gem.executables = "gitstats"
gem.files = `git ls-files`.split($/)
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
gem.require_paths = ["lib"]
gem.add_development_dependency('pry')
end

View file

@ -1,5 +1,4 @@
require "gitstats/version"
module Gitstats
# Your code goes here...
module GitStats
end
Dir['lib/**/*.rb'].each { |r| require File.expand_path(r) }

40
lib/gitstats/cli.rb Normal file
View file

@ -0,0 +1,40 @@
require "gitstats"
class GitStats::CLI
def self.start(*args)
unless args.size == 2
puts "Wrong number of arguments"
help
else
repo_path, out_path = args
validate(repo_path, out_path)
GitStats::Generator.new(repo_path, out_path).generate
end
end
private
def self.help
puts "Usage: gitstats repo_path output_path"
exit 0
end
def self.validate(repo_path, out_path)
validate_repo(repo_path)
validate_out(out_path)
end
def self.validate_repo(repo_path)
unless Dir.exists?("#{repo_path}/.git")
puts "#{repo_path} is not a git repository"
help
end
end
def self.validate_out(out_path)
unless Dir.exists?("#{out_path}")
puts "#{out_path} doesn't exist"
help
end
end
end

View file

@ -0,0 +1,9 @@
class GitStats::Generator
def initialize(repo_path, out_path)
@repo_path, @out_path = repo_path, out_path
end
def generate
puts "generating..."
end
end