rubysl-digest 2.0.3 → 2.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +8 -10
- data/MRI_LICENSE +56 -0
- data/ext/rubysl/digest/bubblebabble/bubblebabble.c +27 -28
- data/ext/rubysl/digest/defs.h +1 -1
- data/ext/rubysl/digest/digest.c +142 -58
- data/ext/rubysl/digest/digest.h +25 -5
- data/ext/rubysl/digest/digest_conf.rb +28 -0
- data/ext/rubysl/digest/extconf.rb +1 -1
- data/ext/rubysl/digest/md5/extconf.rb +3 -13
- data/ext/rubysl/digest/md5/md5.c +9 -7
- data/ext/rubysl/digest/md5/md5.h +3 -3
- data/ext/rubysl/digest/md5/md5cc.h +12 -0
- data/ext/rubysl/digest/md5/md5init.c +12 -5
- data/ext/rubysl/digest/md5/md5ossl.h +4 -2
- data/ext/rubysl/digest/rmd160/extconf.rb +3 -12
- data/ext/rubysl/digest/rmd160/rmd160.c +12 -6
- data/ext/rubysl/digest/rmd160/rmd160.h +3 -3
- data/ext/rubysl/digest/rmd160/rmd160init.c +10 -5
- data/ext/rubysl/digest/rmd160/rmd160ossl.h +3 -2
- data/ext/rubysl/digest/sha1/extconf.rb +3 -12
- data/ext/rubysl/digest/sha1/sha1.c +5 -3
- data/ext/rubysl/digest/sha1/sha1.h +3 -3
- data/ext/rubysl/digest/sha1/sha1cc.h +14 -0
- data/ext/rubysl/digest/sha1/sha1init.c +12 -5
- data/ext/rubysl/digest/sha1/sha1ossl.h +4 -2
- data/ext/rubysl/digest/sha2/extconf.rb +7 -8
- data/ext/rubysl/digest/sha2/sha2.c +235 -73
- data/ext/rubysl/digest/sha2/sha2.h +142 -26
- data/ext/rubysl/digest/sha2/sha2cc.h +31 -0
- data/ext/rubysl/digest/sha2/sha2init.c +12 -4
- data/ext/rubysl/digest/sha2/sha2ossl.h +27 -0
- data/ext/rubysl/openssl/deprecation.rb +21 -0
- data/lib/digest/sha2.rb +42 -9
- data/lib/rubysl/digest/digest.rb +27 -7
- data/lib/rubysl/digest/version.rb +1 -1
- data/spec/fixtures/dir/common.rb +171 -0
- data/spec/md5/file_spec.rb +1 -1
- data/spec/sha1/file_spec.rb +1 -1
- data/spec/sha256/file_spec.rb +1 -1
- data/spec/sha384/file_spec.rb +1 -1
- data/spec/sha512/file_spec.rb +1 -1
- data/spec/shared/file/read.rb +21 -0
- metadata +15 -5
- data/ext/rubysl/digest/bubblebabble/depend +0 -3
- data/ext/rubysl/digest/bubblebabble/extconf.h +0 -4
data/lib/rubysl/digest/digest.rb
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
require 'digest/digest'
|
2
2
|
|
3
3
|
module Digest
|
4
|
+
# A mutex for Digest().
|
5
|
+
REQUIRE_MUTEX = Mutex.new
|
6
|
+
|
4
7
|
def self.const_missing(name) # :nodoc:
|
5
8
|
case name
|
6
9
|
when :SHA256, :SHA384, :SHA512
|
@@ -21,12 +24,14 @@ module Digest
|
|
21
24
|
end
|
22
25
|
|
23
26
|
class ::Digest::Class
|
24
|
-
#
|
27
|
+
# Creates a digest object and reads a given file, _name_.
|
28
|
+
# Optional arguments are passed to the constructor of the digest
|
29
|
+
# class.
|
25
30
|
#
|
26
31
|
# p Digest::SHA256.file("X11R6.8.2-src.tar.bz2").hexdigest
|
27
32
|
# # => "f02e3c85572dc9ad7cb77c2a638e3be24cc1b5bea9fdbb0b0299c9668475c534"
|
28
|
-
def self.file(name)
|
29
|
-
new.file(name)
|
33
|
+
def self.file(name, *args)
|
34
|
+
new(*args).file(name)
|
30
35
|
end
|
31
36
|
|
32
37
|
# Returns the base64 encoded hash value of a given _string_. The
|
@@ -38,7 +43,7 @@ module Digest
|
|
38
43
|
end
|
39
44
|
|
40
45
|
module Instance
|
41
|
-
#
|
46
|
+
# Updates the digest with the contents of a given file _name_ and
|
42
47
|
# returns self.
|
43
48
|
def file(name)
|
44
49
|
File.open(name, "rb") {|f|
|
@@ -74,15 +79,30 @@ end
|
|
74
79
|
# call-seq:
|
75
80
|
# Digest(name) -> digest_subclass
|
76
81
|
#
|
77
|
-
# Returns a Digest subclass by +name
|
82
|
+
# Returns a Digest subclass by +name+ in a thread-safe manner even
|
83
|
+
# when on-demand loading is involved.
|
78
84
|
#
|
79
85
|
# require 'digest'
|
80
86
|
#
|
81
87
|
# Digest("MD5")
|
82
88
|
# # => Digest::MD5
|
83
89
|
#
|
84
|
-
# Digest(
|
90
|
+
# Digest(:SHA256)
|
91
|
+
# # => Digest::SHA256
|
92
|
+
#
|
93
|
+
# Digest(:Foo)
|
85
94
|
# # => LoadError: library not found for class Digest::Foo -- digest/foo
|
86
95
|
def Digest(name)
|
87
|
-
|
96
|
+
const = name.to_sym
|
97
|
+
Digest::REQUIRE_MUTEX.synchronize {
|
98
|
+
# Ignore autoload's because it is void when we have #const_missing
|
99
|
+
Digest.const_missing(const)
|
100
|
+
}
|
101
|
+
rescue LoadError
|
102
|
+
# Constants do not necessarily rely on digest/*.
|
103
|
+
if Digest.const_defined?(const)
|
104
|
+
Digest.const_get(const)
|
105
|
+
else
|
106
|
+
raise
|
107
|
+
end
|
88
108
|
end
|
@@ -0,0 +1,171 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module DirSpecs
|
4
|
+
def self.mock_dir(dirs = ['dir_specs_mock'])
|
5
|
+
@mock_dir ||= tmp("")
|
6
|
+
File.join @mock_dir, dirs
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.nonexistent
|
10
|
+
name = File.join mock_dir, "nonexistent00"
|
11
|
+
name = name.next while File.exist? name
|
12
|
+
File.join mock_dir, name
|
13
|
+
end
|
14
|
+
|
15
|
+
# TODO: make these relative to the mock_dir
|
16
|
+
def self.clear_dirs
|
17
|
+
begin
|
18
|
+
kcode, $KCODE = $KCODE, 'u'
|
19
|
+
[ 'nonexisting',
|
20
|
+
'default_perms',
|
21
|
+
'reduced',
|
22
|
+
'always_returns_0',
|
23
|
+
'???',
|
24
|
+
[0xe9].pack('U')
|
25
|
+
].each do |dir|
|
26
|
+
begin
|
27
|
+
Dir.rmdir dir
|
28
|
+
rescue
|
29
|
+
end
|
30
|
+
end
|
31
|
+
ensure
|
32
|
+
$KCODE = kcode
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# The names of the fixture directories and files used by
|
37
|
+
# various Dir specs.
|
38
|
+
def self.mock_dir_files
|
39
|
+
unless @mock_dir_files
|
40
|
+
@mock_dir_files = %w[
|
41
|
+
.dotfile
|
42
|
+
.dotsubdir/.dotfile
|
43
|
+
.dotsubdir/nondotfile
|
44
|
+
|
45
|
+
deeply/.dotfile
|
46
|
+
deeply/nested/.dotfile.ext
|
47
|
+
deeply/nested/directory/structure/.ext
|
48
|
+
deeply/nested/directory/structure/bar
|
49
|
+
deeply/nested/directory/structure/baz
|
50
|
+
deeply/nested/directory/structure/file_one
|
51
|
+
deeply/nested/directory/structure/file_one.ext
|
52
|
+
deeply/nested/directory/structure/foo
|
53
|
+
deeply/nondotfile
|
54
|
+
|
55
|
+
file_one.ext
|
56
|
+
file_two.ext
|
57
|
+
|
58
|
+
dir_filename_ordering
|
59
|
+
dir/filename_ordering
|
60
|
+
|
61
|
+
nondotfile
|
62
|
+
|
63
|
+
subdir_one/.dotfile
|
64
|
+
subdir_one/nondotfile
|
65
|
+
subdir_two/nondotfile
|
66
|
+
subdir_two/nondotfile.ext
|
67
|
+
|
68
|
+
brace/a
|
69
|
+
brace/a.js
|
70
|
+
brace/a.erb
|
71
|
+
brace/a.js.rjs
|
72
|
+
brace/a.html.erb
|
73
|
+
|
74
|
+
special/+
|
75
|
+
|
76
|
+
special/^
|
77
|
+
special/$
|
78
|
+
|
79
|
+
special/(
|
80
|
+
special/)
|
81
|
+
special/[
|
82
|
+
special/]
|
83
|
+
special/{
|
84
|
+
special/}
|
85
|
+
|
86
|
+
special/test{1}/file[1]
|
87
|
+
|
88
|
+
special/こんにちは.txt
|
89
|
+
]
|
90
|
+
|
91
|
+
platform_is_not :windows do
|
92
|
+
@mock_dir_files += %w[
|
93
|
+
special/*
|
94
|
+
special/?
|
95
|
+
|
96
|
+
special/|
|
97
|
+
]
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
@mock_dir_files
|
102
|
+
end
|
103
|
+
|
104
|
+
def self.create_mock_dirs
|
105
|
+
umask = File.umask 0
|
106
|
+
mock_dir_files.each do |name|
|
107
|
+
file = File.join mock_dir, name
|
108
|
+
mkdir_p File.dirname(file)
|
109
|
+
touch file
|
110
|
+
end
|
111
|
+
File.umask umask
|
112
|
+
end
|
113
|
+
|
114
|
+
def self.delete_mock_dirs
|
115
|
+
rm_r mock_dir
|
116
|
+
end
|
117
|
+
|
118
|
+
def self.mock_rmdir(*dirs)
|
119
|
+
mock_dir ['rmdir_dirs'].concat(dirs)
|
120
|
+
end
|
121
|
+
|
122
|
+
def self.rmdir_dirs(create = true)
|
123
|
+
dirs = %w[
|
124
|
+
empty
|
125
|
+
nonempty
|
126
|
+
nonempty/child
|
127
|
+
noperm
|
128
|
+
noperm/child
|
129
|
+
]
|
130
|
+
|
131
|
+
base_dir = mock_dir ['rmdir_dirs']
|
132
|
+
|
133
|
+
dirs.reverse_each do |d|
|
134
|
+
dir = File.join base_dir, d
|
135
|
+
if File.exists? dir
|
136
|
+
File.chmod 0777, dir
|
137
|
+
rm_r dir
|
138
|
+
end
|
139
|
+
end
|
140
|
+
rm_r base_dir
|
141
|
+
|
142
|
+
if create
|
143
|
+
dirs.each do |d|
|
144
|
+
dir = File.join base_dir, d
|
145
|
+
unless File.exists? dir
|
146
|
+
mkdir_p dir
|
147
|
+
File.chmod 0777, dir
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
def self.expected_paths
|
154
|
+
%w[
|
155
|
+
.
|
156
|
+
..
|
157
|
+
.dotfile
|
158
|
+
.dotsubdir
|
159
|
+
brace
|
160
|
+
deeply
|
161
|
+
dir
|
162
|
+
dir_filename_ordering
|
163
|
+
file_one.ext
|
164
|
+
file_two.ext
|
165
|
+
nondotfile
|
166
|
+
special
|
167
|
+
subdir_one
|
168
|
+
subdir_two
|
169
|
+
]
|
170
|
+
end
|
171
|
+
end
|
data/spec/md5/file_spec.rb
CHANGED
data/spec/sha1/file_spec.rb
CHANGED
data/spec/sha256/file_spec.rb
CHANGED
data/spec/sha384/file_spec.rb
CHANGED
data/spec/sha512/file_spec.rb
CHANGED
@@ -0,0 +1,21 @@
|
|
1
|
+
require File.expand_path('../../../fixtures/dir/common', __FILE__)
|
2
|
+
|
3
|
+
describe :file_read_directory, :shared => true do
|
4
|
+
platform_is :darwin, :linux do
|
5
|
+
it "raises an Errno::EISDIR when passed a path that is a directory" do
|
6
|
+
lambda { @object.send(@method, ".") }.should raise_error(Errno::EISDIR)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
platform_is :bsd do
|
11
|
+
it "does not raises any exception when passed a path that is a directory" do
|
12
|
+
lambda { @object.send(@method, ".") }.should_not raise_error
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
platform_is :windows do
|
17
|
+
it "raises an Errno::EACCES when passed a path that is a directory" do
|
18
|
+
lambda { @object.send(@method, ".") }.should raise_error(Errno::EACCES)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubysl-digest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Shirai
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-05-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -83,22 +83,23 @@ files:
|
|
83
83
|
- ".travis.yml"
|
84
84
|
- Gemfile
|
85
85
|
- LICENSE
|
86
|
+
- MRI_LICENSE
|
86
87
|
- README.md
|
87
88
|
- Rakefile
|
88
89
|
- ext/rubysl/digest/bubblebabble/.gitignore
|
89
90
|
- ext/rubysl/digest/bubblebabble/bubblebabble.c
|
90
91
|
- ext/rubysl/digest/bubblebabble/bubblebabble.h
|
91
|
-
- ext/rubysl/digest/bubblebabble/depend
|
92
|
-
- ext/rubysl/digest/bubblebabble/extconf.h
|
93
92
|
- ext/rubysl/digest/bubblebabble/extconf.rb
|
94
93
|
- ext/rubysl/digest/defs.h
|
95
94
|
- ext/rubysl/digest/digest.c
|
96
95
|
- ext/rubysl/digest/digest.h
|
96
|
+
- ext/rubysl/digest/digest_conf.rb
|
97
97
|
- ext/rubysl/digest/extconf.rb
|
98
98
|
- ext/rubysl/digest/md5/.gitignore
|
99
99
|
- ext/rubysl/digest/md5/extconf.rb
|
100
100
|
- ext/rubysl/digest/md5/md5.c
|
101
101
|
- ext/rubysl/digest/md5/md5.h
|
102
|
+
- ext/rubysl/digest/md5/md5cc.h
|
102
103
|
- ext/rubysl/digest/md5/md5init.c
|
103
104
|
- ext/rubysl/digest/md5/md5ossl.c
|
104
105
|
- ext/rubysl/digest/md5/md5ossl.h
|
@@ -113,6 +114,7 @@ files:
|
|
113
114
|
- ext/rubysl/digest/sha1/extconf.rb
|
114
115
|
- ext/rubysl/digest/sha1/sha1.c
|
115
116
|
- ext/rubysl/digest/sha1/sha1.h
|
117
|
+
- ext/rubysl/digest/sha1/sha1cc.h
|
116
118
|
- ext/rubysl/digest/sha1/sha1init.c
|
117
119
|
- ext/rubysl/digest/sha1/sha1ossl.c
|
118
120
|
- ext/rubysl/digest/sha1/sha1ossl.h
|
@@ -120,7 +122,10 @@ files:
|
|
120
122
|
- ext/rubysl/digest/sha2/extconf.rb
|
121
123
|
- ext/rubysl/digest/sha2/sha2.c
|
122
124
|
- ext/rubysl/digest/sha2/sha2.h
|
125
|
+
- ext/rubysl/digest/sha2/sha2cc.h
|
123
126
|
- ext/rubysl/digest/sha2/sha2init.c
|
127
|
+
- ext/rubysl/digest/sha2/sha2ossl.h
|
128
|
+
- ext/rubysl/openssl/deprecation.rb
|
124
129
|
- lib/digest.rb
|
125
130
|
- lib/digest/bubblebabble.rb
|
126
131
|
- lib/digest/hmac.rb
|
@@ -132,6 +137,7 @@ files:
|
|
132
137
|
- lib/rubysl/digest/digest.rb
|
133
138
|
- lib/rubysl/digest/version.rb
|
134
139
|
- rubysl-digest.gemspec
|
140
|
+
- spec/fixtures/dir/common.rb
|
135
141
|
- spec/hexencode_spec.rb
|
136
142
|
- spec/md5/append_spec.rb
|
137
143
|
- spec/md5/block_length_spec.rb
|
@@ -209,6 +215,7 @@ files:
|
|
209
215
|
- spec/sha512/size_spec.rb
|
210
216
|
- spec/sha512/to_s_spec.rb
|
211
217
|
- spec/sha512/update_spec.rb
|
218
|
+
- spec/shared/file/read.rb
|
212
219
|
homepage: https://github.com/rubysl/rubysl-digest
|
213
220
|
licenses:
|
214
221
|
- BSD
|
@@ -229,11 +236,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
229
236
|
version: '0'
|
230
237
|
requirements: []
|
231
238
|
rubyforge_project:
|
232
|
-
rubygems_version: 2.
|
239
|
+
rubygems_version: 2.4.5
|
233
240
|
signing_key:
|
234
241
|
specification_version: 4
|
235
242
|
summary: Ruby standard library digest.
|
236
243
|
test_files:
|
244
|
+
- spec/fixtures/dir/common.rb
|
237
245
|
- spec/hexencode_spec.rb
|
238
246
|
- spec/md5/append_spec.rb
|
239
247
|
- spec/md5/block_length_spec.rb
|
@@ -311,3 +319,5 @@ test_files:
|
|
311
319
|
- spec/sha512/size_spec.rb
|
312
320
|
- spec/sha512/to_s_spec.rb
|
313
321
|
- spec/sha512/update_spec.rb
|
322
|
+
- spec/shared/file/read.rb
|
323
|
+
has_rdoc:
|