Class: Octostat::Command
- Inherits:
-
Object
- Object
- Octostat::Command
- Defined in:
- lib/octostat/command.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(*args) ⇒ Command
constructor
A new instance of Command.
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
#call ⇒ Object
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. exit 1 end |