rubysl-digest 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/digest/md5.rb +3 -6
- data/lib/digest/sha1.rb +3 -6
- data/lib/md5.rb +0 -17
- data/lib/rubysl/digest/version.rb +1 -1
- data/lib/sha1.rb +0 -17
- 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/fixtures/common.rb +167 -0
- data/spec/shared/read.rb +21 -0
- metadata +22 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d1c288600a8f27bd51232a67835072bd3490bce
|
4
|
+
data.tar.gz: f6348c808953e9ebd3ec97c1b1074b21e95f903d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5356a5f4c3744e2ce9186e1cc871ed0e07ee3ddf4557bbb753fdb0e92988f3887adfb86d1ffe82c027d8ce4f4c9c2d71ad1c0c2f30f6a9d56ab3280b05359764
|
7
|
+
data.tar.gz: e116e8da798069b4025aba518d02146f4ee6929bca60ce6d606bf518bc99ebc1f7f959603f23fb603b970683990529c50349aee75e0c712e58129ec458e74c9e
|
data/lib/digest/md5.rb
CHANGED
@@ -7,13 +7,10 @@ require 'digest/md5/md5'
|
|
7
7
|
|
8
8
|
class MD5 < Digest::MD5
|
9
9
|
class << self
|
10
|
-
alias orig_new new
|
11
10
|
def new(str = nil)
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
orig_new
|
16
|
-
end
|
11
|
+
md5 = super()
|
12
|
+
md5.update(str) if str
|
13
|
+
md5
|
17
14
|
end
|
18
15
|
|
19
16
|
def md5(*args)
|
data/lib/digest/sha1.rb
CHANGED
@@ -7,13 +7,10 @@ require 'digest/sha1/sha1'
|
|
7
7
|
|
8
8
|
class SHA1 < Digest::SHA1
|
9
9
|
class << self
|
10
|
-
alias orig_new new
|
11
10
|
def new(str = nil)
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
orig_new
|
16
|
-
end
|
11
|
+
sha1 = super()
|
12
|
+
sha1.update(str) if str
|
13
|
+
sha1
|
17
14
|
end
|
18
15
|
|
19
16
|
def sha1(*args)
|
data/lib/md5.rb
CHANGED
@@ -4,20 +4,3 @@
|
|
4
4
|
# $Id: md5.rb 12007 2007-03-06 10:09:51Z knu $
|
5
5
|
|
6
6
|
require 'digest/md5'
|
7
|
-
|
8
|
-
class MD5 < Digest::MD5
|
9
|
-
class << self
|
10
|
-
alias orig_new new
|
11
|
-
def new(str = nil)
|
12
|
-
if str
|
13
|
-
orig_new.update(str)
|
14
|
-
else
|
15
|
-
orig_new
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
def md5(*args)
|
20
|
-
new(*args)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
data/lib/sha1.rb
CHANGED
@@ -4,20 +4,3 @@
|
|
4
4
|
# $Id: sha1.rb 12007 2007-03-06 10:09:51Z knu $
|
5
5
|
|
6
6
|
require 'digest/sha1'
|
7
|
-
|
8
|
-
class SHA1 < Digest::SHA1
|
9
|
-
class << self
|
10
|
-
alias orig_new new
|
11
|
-
def new(str = nil)
|
12
|
-
if str
|
13
|
-
orig_new.update(str)
|
14
|
-
else
|
15
|
-
orig_new
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
def sha1(*args)
|
20
|
-
new(*args)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
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,167 @@
|
|
1
|
+
module DirSpecs
|
2
|
+
def self.mock_dir(dirs = ['dir_specs_mock'])
|
3
|
+
@mock_dir ||= tmp("")
|
4
|
+
File.join @mock_dir, dirs
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.nonexistent
|
8
|
+
name = File.join mock_dir, "nonexistent00"
|
9
|
+
name = name.next while File.exist? name
|
10
|
+
File.join mock_dir, name
|
11
|
+
end
|
12
|
+
|
13
|
+
# TODO: make these relative to the mock_dir
|
14
|
+
def self.clear_dirs
|
15
|
+
begin
|
16
|
+
kcode, $KCODE = $KCODE, 'u'
|
17
|
+
[ 'nonexisting',
|
18
|
+
'default_perms',
|
19
|
+
'reduced',
|
20
|
+
'always_returns_0',
|
21
|
+
'???',
|
22
|
+
[0xe9].pack('U')
|
23
|
+
].each do |dir|
|
24
|
+
begin
|
25
|
+
Dir.rmdir dir
|
26
|
+
rescue
|
27
|
+
end
|
28
|
+
end
|
29
|
+
ensure
|
30
|
+
$KCODE = kcode
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# The names of the fixture directories and files used by
|
35
|
+
# various Dir specs.
|
36
|
+
def self.mock_dir_files
|
37
|
+
unless @mock_dir_files
|
38
|
+
@mock_dir_files = %w[
|
39
|
+
.dotfile
|
40
|
+
.dotsubdir/.dotfile
|
41
|
+
.dotsubdir/nondotfile
|
42
|
+
|
43
|
+
deeply/.dotfile
|
44
|
+
deeply/nested/.dotfile.ext
|
45
|
+
deeply/nested/directory/structure/.ext
|
46
|
+
deeply/nested/directory/structure/bar
|
47
|
+
deeply/nested/directory/structure/baz
|
48
|
+
deeply/nested/directory/structure/file_one
|
49
|
+
deeply/nested/directory/structure/file_one.ext
|
50
|
+
deeply/nested/directory/structure/foo
|
51
|
+
deeply/nondotfile
|
52
|
+
|
53
|
+
file_one.ext
|
54
|
+
file_two.ext
|
55
|
+
|
56
|
+
dir_filename_ordering
|
57
|
+
dir/filename_ordering
|
58
|
+
|
59
|
+
nondotfile
|
60
|
+
|
61
|
+
subdir_one/.dotfile
|
62
|
+
subdir_one/nondotfile
|
63
|
+
subdir_two/nondotfile
|
64
|
+
subdir_two/nondotfile.ext
|
65
|
+
|
66
|
+
brace/a
|
67
|
+
brace/a.js
|
68
|
+
brace/a.erb
|
69
|
+
brace/a.js.rjs
|
70
|
+
brace/a.html.erb
|
71
|
+
|
72
|
+
special/+
|
73
|
+
|
74
|
+
special/^
|
75
|
+
special/$
|
76
|
+
|
77
|
+
special/(
|
78
|
+
special/)
|
79
|
+
special/[
|
80
|
+
special/]
|
81
|
+
special/{
|
82
|
+
special/}
|
83
|
+
|
84
|
+
special/test{1}/file[1]
|
85
|
+
]
|
86
|
+
|
87
|
+
platform_is_not :windows do
|
88
|
+
@mock_dir_files += %w[
|
89
|
+
special/*
|
90
|
+
special/?
|
91
|
+
|
92
|
+
special/|
|
93
|
+
]
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
@mock_dir_files
|
98
|
+
end
|
99
|
+
|
100
|
+
def self.create_mock_dirs
|
101
|
+
umask = File.umask 0
|
102
|
+
mock_dir_files.each do |name|
|
103
|
+
file = File.join mock_dir, name
|
104
|
+
mkdir_p File.dirname(file)
|
105
|
+
touch file
|
106
|
+
end
|
107
|
+
File.umask umask
|
108
|
+
end
|
109
|
+
|
110
|
+
def self.delete_mock_dirs
|
111
|
+
rm_r mock_dir
|
112
|
+
end
|
113
|
+
|
114
|
+
def self.mock_rmdir(*dirs)
|
115
|
+
mock_dir ['rmdir_dirs'].concat(dirs)
|
116
|
+
end
|
117
|
+
|
118
|
+
def self.rmdir_dirs(create = true)
|
119
|
+
dirs = %w[
|
120
|
+
empty
|
121
|
+
nonempty
|
122
|
+
nonempty/child
|
123
|
+
noperm
|
124
|
+
noperm/child
|
125
|
+
]
|
126
|
+
|
127
|
+
base_dir = mock_dir ['rmdir_dirs']
|
128
|
+
|
129
|
+
dirs.reverse_each do |d|
|
130
|
+
dir = File.join base_dir, d
|
131
|
+
if File.exists? dir
|
132
|
+
File.chmod 0777, dir
|
133
|
+
rm_r dir
|
134
|
+
end
|
135
|
+
end
|
136
|
+
rm_r base_dir
|
137
|
+
|
138
|
+
if create
|
139
|
+
dirs.each do |d|
|
140
|
+
dir = File.join base_dir, d
|
141
|
+
unless File.exists? dir
|
142
|
+
mkdir_p dir
|
143
|
+
File.chmod 0777, dir
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
def self.expected_paths
|
150
|
+
%w[
|
151
|
+
.
|
152
|
+
..
|
153
|
+
.dotfile
|
154
|
+
.dotsubdir
|
155
|
+
brace
|
156
|
+
deeply
|
157
|
+
dir
|
158
|
+
dir_filename_ordering
|
159
|
+
file_one.ext
|
160
|
+
file_two.ext
|
161
|
+
nondotfile
|
162
|
+
special
|
163
|
+
subdir_one
|
164
|
+
subdir_two
|
165
|
+
]
|
166
|
+
end
|
167
|
+
end
|
data/spec/shared/read.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require File.expand_path('../fixtures/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,71 +1,71 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubysl-digest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
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-06-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
+
version_requirements: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - "~>"
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: '1.3'
|
14
19
|
name: bundler
|
20
|
+
prerelease: false
|
15
21
|
requirement: !ruby/object:Gem::Requirement
|
16
22
|
requirements:
|
17
23
|
- - "~>"
|
18
24
|
- !ruby/object:Gem::Version
|
19
25
|
version: '1.3'
|
20
26
|
type: :development
|
21
|
-
|
27
|
+
- !ruby/object:Gem::Dependency
|
22
28
|
version_requirements: !ruby/object:Gem::Requirement
|
23
29
|
requirements:
|
24
30
|
- - "~>"
|
25
31
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
27
|
-
- !ruby/object:Gem::Dependency
|
32
|
+
version: '10.0'
|
28
33
|
name: rake
|
34
|
+
prerelease: false
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
30
36
|
requirements:
|
31
37
|
- - "~>"
|
32
38
|
- !ruby/object:Gem::Version
|
33
39
|
version: '10.0'
|
34
40
|
type: :development
|
35
|
-
|
41
|
+
- !ruby/object:Gem::Dependency
|
36
42
|
version_requirements: !ruby/object:Gem::Requirement
|
37
43
|
requirements:
|
38
44
|
- - "~>"
|
39
45
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
41
|
-
- !ruby/object:Gem::Dependency
|
46
|
+
version: '1.5'
|
42
47
|
name: mspec
|
48
|
+
prerelease: false
|
43
49
|
requirement: !ruby/object:Gem::Requirement
|
44
50
|
requirements:
|
45
51
|
- - "~>"
|
46
52
|
- !ruby/object:Gem::Version
|
47
53
|
version: '1.5'
|
48
54
|
type: :development
|
49
|
-
|
55
|
+
- !ruby/object:Gem::Dependency
|
50
56
|
version_requirements: !ruby/object:Gem::Requirement
|
51
57
|
requirements:
|
52
58
|
- - "~>"
|
53
59
|
- !ruby/object:Gem::Version
|
54
|
-
version: '1.
|
55
|
-
- !ruby/object:Gem::Dependency
|
60
|
+
version: '1.0'
|
56
61
|
name: rubysl-prettyprint
|
62
|
+
prerelease: false
|
57
63
|
requirement: !ruby/object:Gem::Requirement
|
58
64
|
requirements:
|
59
65
|
- - "~>"
|
60
66
|
- !ruby/object:Gem::Version
|
61
67
|
version: '1.0'
|
62
68
|
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '1.0'
|
69
69
|
description: Ruby standard library digest.
|
70
70
|
email:
|
71
71
|
- brixen@gmail.com
|
@@ -211,6 +211,8 @@ files:
|
|
211
211
|
- spec/sha512/size_spec.rb
|
212
212
|
- spec/sha512/to_s_spec.rb
|
213
213
|
- spec/sha512/update_spec.rb
|
214
|
+
- spec/shared/fixtures/common.rb
|
215
|
+
- spec/shared/read.rb
|
214
216
|
homepage: https://github.com/rubysl/rubysl-digest
|
215
217
|
licenses:
|
216
218
|
- BSD
|
@@ -231,7 +233,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
231
233
|
version: '0'
|
232
234
|
requirements: []
|
233
235
|
rubyforge_project:
|
234
|
-
rubygems_version: 2.
|
236
|
+
rubygems_version: 2.4.6
|
235
237
|
signing_key:
|
236
238
|
specification_version: 4
|
237
239
|
summary: Ruby standard library digest.
|
@@ -313,3 +315,5 @@ test_files:
|
|
313
315
|
- spec/sha512/size_spec.rb
|
314
316
|
- spec/sha512/to_s_spec.rb
|
315
317
|
- spec/sha512/update_spec.rb
|
318
|
+
- spec/shared/fixtures/common.rb
|
319
|
+
- spec/shared/read.rb
|