Class: Octostat::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/octostat/command.rb

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Command

Returns a new instance of Command.



5
6
7
8
9
10
# File 'lib/octostat/command.rb', line 5

def initialize *args
  @db_path = "octostat.sqlite"
  args = parser.parse!(args)
  @path = args.first || Dir.pwd
  @batch_size = 1000
end

Instance Method Details

#callObject



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/octostat/command.rb', line 12

def call
  db = Database.new(db_path)
  @git = Git.new(path)
  git.each_slice(batch_size).with_index do |commits, batch|
    puts_progress batch * batch_size
    commits.each { |commit| db.insert_commit(**commit) }
  end
  puts_progress git.count
  puts "\nDone!"
rescue Octostat::Error => e
  warn e.message
  exit 1
end