-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add checksums generation & saving in yaml file.
This is for future work to optimize on only regeneration when needed.
- Loading branch information
1 parent
370ecc8
commit eeb4558
Showing
11 changed files
with
126 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,3 +18,4 @@ test/tmp | |
test/version_tmp | ||
tmp | ||
example/_site/* | ||
example/.meta.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
require 'yaml/store' | ||
|
||
module Flue | ||
class Metadata | ||
attr_reader :store, :basefiles | ||
|
||
def initialize | ||
@store = YAML::Store.new(".meta.yml") | ||
end | ||
|
||
def update_checksum(basefile) | ||
store.transaction do | ||
checksums = store["checksums"] || {} | ||
checksums[basefile.filename] = basefile.checksum | ||
store["checksums"] = checksums | ||
end | ||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
require "./spec/test_helper.rb" | ||
|
||
describe Metadata do | ||
let(:filename){ "filename" } | ||
let(:checksum){ "checksum" } | ||
let(:basefile) do | ||
m = Minitest::Mock.new | ||
m.expect(:filename, filename) | ||
m.expect(:checksum, checksum) | ||
m | ||
end | ||
let(:basefiles){ [basefile] } | ||
let(:metadata){ Metadata.new } | ||
let(:store){ Minitest::Mock.new } | ||
|
||
it "must update checksum of files" do | ||
store.expect(:transaction, nil) | ||
#store.expect(:[]=, nil, ["checksums", {filename => checksum}]) | ||
#TODO figure how to get block testing to work properly | ||
YAML::Store.stub :new, store do | ||
metadata.update_checksum(basefile) | ||
end | ||
store.verify | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters