epitools 0.4.33 → 0.4.34
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/epitools.gemspec +2 -2
- data/lib/epitools/path.rb +36 -4
- data/spec/path_spec.rb +18 -0
- metadata +4 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.34
|
data/epitools.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{epitools}
|
8
|
-
s.version = "0.4.
|
8
|
+
s.version = "0.4.34"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["epitron"]
|
12
|
-
s.date = %q{2011-05-
|
12
|
+
s.date = %q{2011-05-18}
|
13
13
|
s.description = %q{Miscellaneous utility libraries to make my life easier.}
|
14
14
|
s.email = %q{chris@ill-logic.com}
|
15
15
|
s.extra_rdoc_files = [
|
data/lib/epitools/path.rb
CHANGED
@@ -5,7 +5,7 @@ require 'uri'
|
|
5
5
|
class Path
|
6
6
|
|
7
7
|
## initializers
|
8
|
-
|
8
|
+
|
9
9
|
def initialize(newpath)
|
10
10
|
self.path = newpath
|
11
11
|
end
|
@@ -26,14 +26,18 @@ class Path
|
|
26
26
|
|
27
27
|
def self.tmpfile(prefix="tmp")
|
28
28
|
require 'tempfile' unless defined? Tempfile
|
29
|
-
|
30
|
-
path = Path[file]
|
29
|
+
path = Path[ Tempfile.new(prefix).path ]
|
31
30
|
yield path if block_given?
|
32
31
|
path
|
33
32
|
end
|
34
|
-
|
33
|
+
|
35
34
|
alias_class_method :tempfile, :tmpfile
|
36
35
|
|
36
|
+
|
37
|
+
def self.home
|
38
|
+
Path[ENV['HOME']]
|
39
|
+
end
|
40
|
+
|
37
41
|
|
38
42
|
## setters
|
39
43
|
|
@@ -145,6 +149,14 @@ class Path
|
|
145
149
|
File.mtime path
|
146
150
|
end
|
147
151
|
|
152
|
+
def ctime
|
153
|
+
File.ctime path
|
154
|
+
end
|
155
|
+
|
156
|
+
def atime
|
157
|
+
File.atime path
|
158
|
+
end
|
159
|
+
|
148
160
|
def dir?
|
149
161
|
File.directory? path
|
150
162
|
end
|
@@ -296,6 +308,26 @@ class Path
|
|
296
308
|
Path[File.join(path, other)]
|
297
309
|
end
|
298
310
|
end
|
311
|
+
|
312
|
+
|
313
|
+
## Checksums
|
314
|
+
|
315
|
+
def sha1
|
316
|
+
require 'digest/sha1' unless defined? Digest::SHA1
|
317
|
+
Digest::SHA1.file(self).hexdigest
|
318
|
+
end
|
319
|
+
|
320
|
+
def sha2
|
321
|
+
require 'digest/sha2' unless defined? Digest::SHA2
|
322
|
+
Digest::SHA2.file(self).hexdigest
|
323
|
+
end
|
324
|
+
|
325
|
+
def md5
|
326
|
+
require 'digest/md5' unless defined? Digest::MD5
|
327
|
+
Digest::MD5.file(self).hexdigest
|
328
|
+
end
|
329
|
+
|
330
|
+
alias_method :md5sum, :md5
|
299
331
|
|
300
332
|
end
|
301
333
|
|
data/spec/path_spec.rb
CHANGED
@@ -135,6 +135,12 @@ describe Path do
|
|
135
135
|
it "tempfiles" do
|
136
136
|
path = Path.tmpfile
|
137
137
|
path.exists?.should == true
|
138
|
+
|
139
|
+
path.write "blah"
|
140
|
+
path.read.should == "blah"
|
141
|
+
|
142
|
+
path.delete!
|
143
|
+
path.exists?.should == false
|
138
144
|
end
|
139
145
|
|
140
146
|
it "appends and writes" do
|
@@ -171,4 +177,16 @@ describe Path do
|
|
171
177
|
path.exists?.should == false
|
172
178
|
end
|
173
179
|
|
180
|
+
it "checksums" do
|
181
|
+
a, b = Path["*.rb"].take(2)
|
182
|
+
[:sha1, :sha2, :md5].each do |meth|
|
183
|
+
sum1 = a.send(meth)
|
184
|
+
sum2 = b.send(meth)
|
185
|
+
sum1.should_not == sum2
|
186
|
+
sum1.size.should > 5
|
187
|
+
sum1.should =~ /[a-z0-9]/
|
188
|
+
sum2.should =~ /[a-z0-9]/
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
174
192
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: epitools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 75
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 4
|
9
|
-
-
|
10
|
-
version: 0.4.
|
9
|
+
- 34
|
10
|
+
version: 0.4.34
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- epitron
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-05-
|
18
|
+
date: 2011-05-18 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: rspec
|