Sha256: b594520a9151376becd0d621d348c60e98e182cbfab0ded02f809e7a5ae9f17a
Contents?: true
Size: 1.65 KB
Versions: 1
Compression:
Stored size: 1.65 KB
Contents
module GithubStats # Main entrance point to the command line tool. # Sets defaults and parses options etc. class CLI def self.run(search_string, options) new(search_string, options).run end attr_accessor :search_string, :options def initialize(remaining_args, options) @search_string = remaining_args.join(' ') options[:database_url] ||= "sqlite://#{home_dir}/db.sqlite" options[:report_type] ||= 'issues_closed_by_week' options[:ingest] = true unless options.key?(:ingest) @options = options end def run setup_db ingest results end private def setup_db Database.new(options).setup end private def home_dir return if @home_dir @home_dir = File.join(Dir.home, '.github-stats') Dir.mkdir(@home_dir) unless Dir.exist?(@home_dir) @home_dir end private def ingest IssueIngester.new(search_string, options).ingest end private def report Reports.for(options[:report_type]).new(search_string, options) end private def results CommaSeperatedLinePerResultResultsView.new(report.results) end # Transforms a result set into a space-seperated table the results hash # keys becoming the table headers and line breaks between rows. class CommaSeperatedLinePerResultResultsView attr_accessor :results def initialize(results) self.results = results end def fields results.keys end def to_s fields.join(',') + "\n" + results.map do |result| fields.map(&result.method(:fetch)).join(',') end.join("\n") end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
github-stats-0.2.0 | lib/github_stats/cli.rb |