mirror of
https://github.com/tomgi/git_stats.git
synced 2024-12-22 13:32:17 +01:00
project layout
This commit is contained in:
parent
c98224b9cb
commit
f322835ba0
5 changed files with 65 additions and 5 deletions
9
bin/gitstats
Executable file
9
bin/gitstats
Executable 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)
|
|
@ -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
|
||||
|
|
|
@ -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
40
lib/gitstats/cli.rb
Normal 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
|
9
lib/gitstats/generator.rb
Normal file
9
lib/gitstats/generator.rb
Normal 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
|
Loading…
Reference in a new issue