treehash 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.travis.yml +1 -0
- data/README.md +1 -1
- data/lib/treehash.rb +3 -1
- data/lib/treehash/version.rb +1 -1
- data/spec/{tree_hash_spec.rb → treehash_spec.rb} +8 -0
- data/treehash.gemspec +1 -1
- metadata +6 -12
data/.travis.yml
CHANGED
data/README.md
CHANGED
data/lib/treehash.rb
CHANGED
@@ -19,8 +19,10 @@ module Treehash
|
|
19
19
|
shas << Digest::SHA256.new.digest(mega_byte)
|
20
20
|
end
|
21
21
|
|
22
|
+
return nil if shas.empty?
|
23
|
+
|
22
24
|
while shas.size > 1
|
23
|
-
shas = shas.each_slice(2).
|
25
|
+
shas = shas.each_slice(2).map do |pair|
|
24
26
|
pair[1] ? Digest::SHA256.new.update(pair[0]).update(pair[1]).digest : pair[0]
|
25
27
|
end
|
26
28
|
end
|
data/lib/treehash/version.rb
CHANGED
@@ -23,4 +23,12 @@ describe Treehash do
|
|
23
23
|
hash.should == '2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae'
|
24
24
|
end
|
25
25
|
end
|
26
|
+
|
27
|
+
it "should raise if improper data type" do
|
28
|
+
expect { Treehash::calculate_tree_hash [] }.to raise_error
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should handle empty strings" do
|
32
|
+
Treehash::calculate_tree_hash('').should be_nil
|
33
|
+
end
|
26
34
|
end
|
data/treehash.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |gem|
|
|
10
10
|
gem.email = ["erich.menge@me.com"]
|
11
11
|
gem.description = %q{Calculates the SHA256 tree hash of a file or string. It also includes a command line tool.}
|
12
12
|
gem.summary = %q{Calculates the SHA256 tree hash of a file or string. It also includes a command line tool.}
|
13
|
-
gem.homepage = ""
|
13
|
+
gem.homepage = "https://github.com/erichmenge/treehash"
|
14
14
|
|
15
15
|
gem.files = `git ls-files`.split($/)
|
16
16
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: treehash
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-01-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -64,9 +64,9 @@ files:
|
|
64
64
|
- lib/treehash/version.rb
|
65
65
|
- spec/fixtures/small_file
|
66
66
|
- spec/spec_helper.rb
|
67
|
-
- spec/
|
67
|
+
- spec/treehash_spec.rb
|
68
68
|
- treehash.gemspec
|
69
|
-
homepage:
|
69
|
+
homepage: https://github.com/erichmenge/treehash
|
70
70
|
licenses: []
|
71
71
|
post_install_message:
|
72
72
|
rdoc_options: []
|
@@ -78,21 +78,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
78
78
|
- - ! '>='
|
79
79
|
- !ruby/object:Gem::Version
|
80
80
|
version: '0'
|
81
|
-
segments:
|
82
|
-
- 0
|
83
|
-
hash: 614530273586430424
|
84
81
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
82
|
none: false
|
86
83
|
requirements:
|
87
84
|
- - ! '>='
|
88
85
|
- !ruby/object:Gem::Version
|
89
86
|
version: '0'
|
90
|
-
segments:
|
91
|
-
- 0
|
92
|
-
hash: 614530273586430424
|
93
87
|
requirements: []
|
94
88
|
rubyforge_project:
|
95
|
-
rubygems_version: 1.8.
|
89
|
+
rubygems_version: 1.8.23
|
96
90
|
signing_key:
|
97
91
|
specification_version: 3
|
98
92
|
summary: Calculates the SHA256 tree hash of a file or string. It also includes a
|
@@ -100,4 +94,4 @@ summary: Calculates the SHA256 tree hash of a file or string. It also includes
|
|
100
94
|
test_files:
|
101
95
|
- spec/fixtures/small_file
|
102
96
|
- spec/spec_helper.rb
|
103
|
-
- spec/
|
97
|
+
- spec/treehash_spec.rb
|