posix-fileutils 0.1.9 → 0.1.10
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.
- checksums.yaml +8 -8
- data/lib/posix-fileutils/fileutils.rb +38 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
N2RjYTU3YWM2YjY4MTdiMGZjNjYxZWFmYWYzNzZiMDczYjQ5ZDQ2OQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
OThiNGQ5Njc1ZWE5MzFjMzQ3ODBhMGRiMTliODQ4NjJjNTcwODkwMQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YzJhNDEyZGI1ODQxYmJmOTVlMTUwYzI1NDBhMmU2Yzk2ZGRhM2VkMTMwYjQ0
|
10
|
+
NzE4ODllNjhlMWJlNjUyZDUyMzczZjBhNTU4NjJmNzY2NDkxYjFlY2I2NGQ5
|
11
|
+
M2YxZTEyMzhhM2ExZGQ3YjNmZjEwOGI2Y2VmM2Y4YWQwNTczZmE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NDYyYjU0YmIxMGVjMzljOThkY2E4MDZkMzM4MjgxMDI3NjM4MGIwNjE4NjA1
|
14
|
+
ZWIyNmI0NmFlNWY1MGZjZWUzODAzM2IyZDVkNDhjZTU3NzRjMjQ0MTAxYWI2
|
15
|
+
YmIwMmUyY2Y2M2Y0YWIxYmUxYzhlZGE4OGMzMDc5MDIwZTVmNTM=
|
@@ -221,6 +221,44 @@ module Fs
|
|
221
221
|
Pathname.new(`pwd`.chomp)
|
222
222
|
end
|
223
223
|
|
224
|
+
def self.diff file1, file2, *opts
|
225
|
+
file1 = Pathname.new file1 unless file1.kind_of? Pathname
|
226
|
+
file2 = Pathname.new file2 unless file2.kind_of? Pathname
|
227
|
+
|
228
|
+
raise ArgumentError unless file1.directory? == file2.directory?
|
229
|
+
|
230
|
+
if file1.directory?
|
231
|
+
list1 = Dir["#{file1.to_s}/**/{*,.*}"]
|
232
|
+
list2 = Dir["#{file2.to_s}/**/{*,.*}"]
|
233
|
+
|
234
|
+
rellist1 = list1.map do |e| Pathname.new(e).relative_path_from file1 end
|
235
|
+
rellist2 = list2.map do |e| Pathname.new(e).relative_path_from file2 end
|
236
|
+
|
237
|
+
return false unless rellist1.to_set == rellist2.to_set
|
238
|
+
|
239
|
+
list1.each do |file|
|
240
|
+
file = Pathname.new file
|
241
|
+
ofile = file2 + file.relative_path_from(file1)
|
242
|
+
|
243
|
+
if file.directory?
|
244
|
+
return false if Dir["#{file.to_s}/{*,.*}"] == Dir["#{ofile.to_s}/{*,.*}"]
|
245
|
+
|
246
|
+
next
|
247
|
+
end
|
248
|
+
|
249
|
+
return false unless ofile.exist?
|
250
|
+
return false if ofile.directory?
|
251
|
+
return false unless Digest::SHA256.file(file) == Digest::SHA256.file(ofile)
|
252
|
+
end
|
253
|
+
|
254
|
+
return true
|
255
|
+
end
|
256
|
+
|
257
|
+
return false unless Digest::SHA256.file(file1) == Digest::SHA256.file(file2)
|
258
|
+
|
259
|
+
true
|
260
|
+
end
|
261
|
+
|
224
262
|
end # module Fs
|
225
263
|
|
226
264
|
# vim: sw=2 sts=2 ts=8:
|