Class: Churned::Commands::DB::Load
- Inherits:
-
Churned::Command
- Object
- Churned::Command
- Churned::Commands::DB::Load
- Defined in:
- lib/churned/commands/db/load.rb
Class Method Summary collapse
Instance Method Summary collapse
- #execute(filename, input: $stdin, output: $stdout) ⇒ Object
-
#initialize(options) ⇒ Load
constructor
A new instance of Load.
Methods inherited from Churned::Command
#command, #cursor, #db, #editor, #exec_exist?, #generator, #pager, #platform, #prompt, #screen, #which
Constructor Details
#initialize(options) ⇒ Load
Returns a new instance of Load.
9 10 11 |
# File 'lib/churned/commands/db/load.rb', line 9 def initialize() @options = end |
Class Method Details
.execute(filename) ⇒ Object
13 14 15 |
# File 'lib/churned/commands/db/load.rb', line 13 def self.execute(filename) new({}).execute(filename, input: $stdin, output: $stdout) end |
Instance Method Details
#execute(filename, input: $stdin, output: $stdout) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/churned/commands/db/load.rb', line 17 def execute(filename, input: $stdin, output: $stdout) IO.read(filename).split("\n\n").each do |description| sha, date, , *numstats = description.split("\n") commit = Commit.new(sha: sha, author_date: date, author: ) numstats.each do |numstat| additions, deletions, pathname = numstat.split("\t") commit.file_changes.build(additions: additions, deletions: deletions, pathname: pathname) end commit.save end end |