storazzo 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/bin/stats-with-md5 +75 -12
- data/lib/storazzo.rb +4 -4
- data/var/test/disks/ricdisk_stats_v11.rds +22 -11
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8def316c4a0c581b9d357bcd2558c9575fc1cf8de8e6cba07d1207134d963aed
|
4
|
+
data.tar.gz: 6f5715317c526538d8a5635bfbd73cdeee342807c7b8f9934d1b8f1f3de66cc5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: efaf738c70312c22c0461c2332ba3865f33417b9ec88069734d2082c2c18ad6063c591fd46cccc200eff8bd81dff1d75bf0fe059ecc8d846b937b2aa31b8c1d2
|
7
|
+
data.tar.gz: 052c40b07650f14d53ec15479d4aa589449e57fad5e8da91d49badca594c280ebf5dde2c7e2319186b7aa4666e78b42ee31270de10485a87d0b0c91e9ad5e0b6
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.1
|
data/bin/stats-with-md5
CHANGED
@@ -109,6 +109,7 @@ def compute_stats_and_md5(file)
|
|
109
109
|
ret = {}
|
110
110
|
ret[:name] = file
|
111
111
|
|
112
|
+
<<<<<<< HEAD
|
112
113
|
begin
|
113
114
|
stats = File.stat(file)
|
114
115
|
ret[:stats_object] = stats # TODO deprecate
|
@@ -142,9 +143,44 @@ def compute_stats_and_md5(file)
|
|
142
143
|
ret[:error] = e
|
143
144
|
end
|
144
145
|
ret
|
146
|
+
=======
|
147
|
+
begin
|
148
|
+
stats = File.stat(file)
|
149
|
+
ret[:stats_object] = stats # TODO deprecate
|
150
|
+
#deb("Stats methods: #{stats.methods.sort.join(', ')}")
|
151
|
+
#deb(stats.ctime)
|
152
|
+
#puts(stats.birthtime rescue (stats.ctime))
|
153
|
+
# On Mac/Linux: see test/dumps/***.yaml
|
154
|
+
ret[:size] = stats.size
|
155
|
+
ret[:mode] = stats.mode
|
156
|
+
# datetimes
|
157
|
+
ret[:stat_safebirthtime] = getSafeCreationTime(file) # in Mac uses birthtime,but on Linux wont work
|
158
|
+
# defined?(stats.birthtime) ? # rescue stats.mtime # eg, 2022-03-05 21:47:51 +0100 on Mac (not implemented on my Linuix)#
|
159
|
+
# stats.birthtime : # works on Mac
|
160
|
+
# stats.ctime
|
161
|
+
ret[:stat_mtime] = stats.mtime # eg, 2022-03-05 21:47:51 +0100 Returns the modification time of stat.
|
162
|
+
ret[:stat_ctime] = stats.ctime # eg, 2022-03-05 21:47:51 +0100 Returns the change time for stat (that is, the time directory information about the file was changed, not the file itself). Note that on Windows (NTFS), returns creation time (birth time).
|
163
|
+
ret[:stat_atime] = stats.atime # eg, 2022-03-05 21:47:51 +0100 Last Access
|
164
|
+
ret[:stat_gid] = stats.gid # Group Id
|
165
|
+
ret[:stat_uid] = stats.uid # UUID
|
166
|
+
ret[:stat_ftype] = stats.ftype #
|
167
|
+
|
168
|
+
ret[:md5] = '______________NONE______________'
|
169
|
+
if stats.ftype != "directory"
|
170
|
+
file_content = File.read(file)
|
171
|
+
ret[:md5] = Digest::MD5.hexdigest(file_content) # rescue 'none ' #=> string with hexadecimal digits
|
172
|
+
end
|
173
|
+
rescue Errno::EISDIR => e
|
174
|
+
#puts "It's a dir, nothing I can do here except skipping the stuff"
|
175
|
+
ret[:md5] = "_________I'm a dir sorry________"
|
176
|
+
rescue Exception => e
|
177
|
+
ret[:error] = e
|
178
|
+
end
|
179
|
+
ret
|
180
|
+
>>>>>>> 97a64f1 (perfected CLI)
|
145
181
|
end
|
146
182
|
|
147
|
-
$print_stats_and_md5_version = "1.
|
183
|
+
$print_stats_and_md5_version = "1.1b_220805_F" # files
|
148
184
|
$print_stats_and_md5_counter = 0
|
149
185
|
$print_stats_and_md5_for_gcs_version = "1.1alpha_220628_G" # GCS bucket
|
150
186
|
|
@@ -334,18 +370,24 @@ def autowrite_to_dir_or_gcs(fs_type, path, opts = {})
|
|
334
370
|
return :ok
|
335
371
|
end
|
336
372
|
|
337
|
-
def print_stats_and_md5_for_directory(directory_to_explore_recursively, opts = {})
|
338
|
-
puts "# [print_stats_and_md5_for_directory] DIR to explore (make sure you glob also): #{directory_to_explore_recursively}"
|
339
|
-
puts "# DEB Options: #{opts}"
|
340
373
|
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
374
|
+
def print_stats_and_md5_for_directory_from_cli(directory_to_explore_recursively, opts={})
|
375
|
+
puts "# [print_stats_and_md5_for_directory_from_cli] v#{$print_stats_and_md5_version}] DIR to explore (make sure you glob also): #{directory_to_explore_recursively }"
|
376
|
+
opts_autowrite = opts.fetch :autowrite, false
|
377
|
+
opts_verbose = opts.fetch( :verbose, $opts[:verbose])
|
378
|
+
opts_debug = opts.fetch :debug, $opts[:debug]
|
379
|
+
opts_color = opts.fetch :color, $opts[:color]
|
380
|
+
if opts_debug
|
381
|
+
puts "# DEB Options1 opts (FUNC) BAD: s #{opts}" # probably useless since this is invoked by CLI and has ful fledged options.
|
382
|
+
puts "# DEB Options2 $opts (ARGV) GOOD: #{$opts}" # This is what we ewant in this CLI. TODO(ricc): if you move this function to be used as function invert the priority...
|
383
|
+
puts("# DEB version=#{$print_stats_and_md5_version} host=#{Socket.gethostname}(#{`uname`.chomp}) created_on=#{Time.now}") # if ARGV.size > 0
|
384
|
+
end
|
385
|
+
|
386
|
+
Dir.glob("#{(directory_to_explore_recursively)}/**/*") do |globbed_filename|
|
387
|
+
# Do work on files & directories ending in .rb
|
388
|
+
#puts "[deb] #{globbed_filename}"
|
389
|
+
print_stats_and_md5(globbed_filename, :color => opts_color, :verbose => opts_verbose, :autowrite => opts_autowrite)
|
390
|
+
end
|
349
391
|
|
350
392
|
autowrite_to_dir_or_gcs(:dir, directory_to_explore_recursively) if opts_autowrite
|
351
393
|
end
|
@@ -368,25 +410,46 @@ def real_program
|
|
368
410
|
if ARGV.size == 1
|
369
411
|
directory_to_explore_recursively = ARGV[0]
|
370
412
|
if smells_like_gcs?(directory_to_explore_recursively)
|
413
|
+
<<<<<<< HEAD
|
371
414
|
print_stats_and_md5_for_gcs(directory_to_explore_recursively, common_opts)
|
372
415
|
else # normal file..
|
373
416
|
print_stats_and_md5_for_directory(directory_to_explore_recursively, common_opts)
|
374
417
|
end
|
418
|
+
=======
|
419
|
+
print_stats_and_md5_for_gcs(directory_to_explore_recursively, common_opts)
|
420
|
+
else # normal file..
|
421
|
+
print_stats_and_md5_for_directory_from_cli(directory_to_explore_recursively, common_opts)
|
422
|
+
end
|
423
|
+
>>>>>>> 97a64f1 (perfected CLI)
|
375
424
|
elsif ARGV.size > 1
|
376
425
|
deb "2. I expect a lot of single files or directories:"
|
377
426
|
for arg in ARGV
|
427
|
+
<<<<<<< HEAD
|
378
428
|
if File.directory?(arg)
|
379
429
|
print_stats_and_md5_for_directory(arg, common_opts)
|
380
430
|
else
|
381
431
|
print_stats_and_md5(arg, common_opts)
|
382
432
|
end
|
433
|
+
=======
|
434
|
+
if File.directory?(arg)
|
435
|
+
print_stats_and_md5_for_directory_from_cli(arg, common_opts )
|
436
|
+
else
|
437
|
+
print_stats_and_md5(arg, common_opts)
|
438
|
+
end
|
439
|
+
>>>>>>> 97a64f1 (perfected CLI)
|
383
440
|
end
|
384
441
|
else
|
385
442
|
puts "No args given. Exiting"
|
386
443
|
exit 41
|
387
444
|
end
|
388
445
|
tf = Time.now
|
446
|
+
<<<<<<< HEAD
|
389
447
|
puts "# [#{File.basename $0}] Time taken for processing #{stats_and_md5_number_of_files_processed} files: #{tf - t0}"
|
448
|
+
=======
|
449
|
+
#rounding to 3 decimals
|
450
|
+
approx_delta = (tf-t0).round(3)
|
451
|
+
puts "# [#{File.basename $0}] Time taken for processing #{stats_and_md5_number_of_files_processed} files: #{approx_delta} seconds"
|
452
|
+
>>>>>>> 97a64f1 (perfected CLI)
|
390
453
|
end
|
391
454
|
|
392
455
|
def main(filename)
|
data/lib/storazzo.rb
CHANGED
@@ -5,17 +5,17 @@ module Storazzo
|
|
5
5
|
# require 'storazzo/translator'
|
6
6
|
|
7
7
|
def latest_parser_version
|
8
|
-
|
8
|
+
"1.2"
|
9
9
|
end
|
10
10
|
|
11
11
|
# Finds RAILS_ROOT for Storazzo Gem. Copied from:
|
12
12
|
# https://stackoverflow.com/questions/10132949/finding-the-gem-root
|
13
13
|
def self.root
|
14
|
-
File.expand_path '
|
14
|
+
File.expand_path '../..', __FILE__
|
15
15
|
end
|
16
16
|
|
17
17
|
def self.version
|
18
|
-
File.read(root + '/VERSION').chomp # "10.0.0"
|
18
|
+
File.read(self.root + '/VERSION').chomp # "10.0.0"
|
19
19
|
end
|
20
20
|
|
21
21
|
# alias_method :VERSION, :version
|
@@ -30,7 +30,7 @@ end
|
|
30
30
|
|
31
31
|
# nice to paste nice output
|
32
32
|
require 'pp'
|
33
|
-
|
33
|
+
require 'require_all'
|
34
34
|
|
35
35
|
# require_all './' , 'media/'
|
36
36
|
# require_all 'lib/**/*.rb'
|
@@ -1,11 +1,22 @@
|
|
1
|
-
[
|
2
|
-
|
3
|
-
[
|
4
|
-
[
|
5
|
-
[
|
6
|
-
[
|
7
|
-
[
|
8
|
-
[
|
9
|
-
[
|
10
|
-
|
11
|
-
|
1
|
+
# [print_stats_and_md5_for_directory] DIR to explore (make sure you glob also): .
|
2
|
+
# DEB Options: {:max_files=>nil, :color=>false, :verbose=>false, :autowrite=>false}
|
3
|
+
[file_v1.2] d41d8cd98f00b204e9800998ecf8427e 100644 f 2022-07-30T11:54:42+02:00 0 [text/plain] ./ricdisk_stats_v11.rds
|
4
|
+
[file_v1.2] ______________NONE______________ 040755 d 2022-07-28T12:11:48+02:00 200 [inode/directory] ./disk01-empty
|
5
|
+
[file_v1.2] ______________NONE______________ 040755 d 2022-07-29T19:00:54+02:00 300 [inode/directory] ./disk02-full
|
6
|
+
[file_v1.2] d41d8cd98f00b204e9800998ecf8427e 100644 f 2022-07-24T06:38:25+02:00 0 [inode/x-empty] ./disk02-full/fake file.touch
|
7
|
+
[file_v1.2] f344106fac7926960912486256a56af9 100644 f 2022-07-24T06:38:25+02:00 454 [text/plain] ./disk02-full/ls.txt
|
8
|
+
[file_v1.2] 437b184a6b045975f0fb6c8c978f28ad 100644 f 2022-07-29T19:01:26+02:00 507 [text/plain] ./disk02-full/Rakefile
|
9
|
+
# [print_stats_and_md5_for_directory] DIR to explore (make sure you glob also): ./disk01-empty
|
10
|
+
# DEB Options: {:max_files=>nil, :color=>false, :verbose=>false, :autowrite=>false}
|
11
|
+
[file_v1.2] f8382af52d00023dc4ee9e9029b367b9 100644 f 2022-07-28T14:30:46+02:00 1022 [text/plain] ./disk01-empty/.ricdisk
|
12
|
+
[file_v1.2] d41d8cd98f00b204e9800998ecf8427e 100644 f 2022-07-24T06:38:25+02:00 0 [inode/x-empty] ./disk01-empty/.keep
|
13
|
+
# [print_stats_and_md5_for_directory] DIR to explore (make sure you glob also): ./disk02-full
|
14
|
+
# DEB Options: {:max_files=>nil, :color=>false, :verbose=>false, :autowrite=>false}
|
15
|
+
[file_v1.2] d41d8cd98f00b204e9800998ecf8427e 100644 f 2022-07-24T06:38:25+02:00 0 [inode/x-empty] ./disk02-full/fake file.touch
|
16
|
+
[file_v1.2] f344106fac7926960912486256a56af9 100644 f 2022-07-24T06:38:25+02:00 454 [text/plain] ./disk02-full/ls.txt
|
17
|
+
[file_v1.2] 437b184a6b045975f0fb6c8c978f28ad 100644 f 2022-07-29T19:01:26+02:00 507 [text/plain] ./disk02-full/Rakefile
|
18
|
+
[file_v1.2] d41d8cd98f00b204e9800998ecf8427e 100644 f 2022-07-24T06:38:25+02:00 0 [inode/x-empty] ./disk02-full/.ricdisk
|
19
|
+
[file_v1.2] d41d8cd98f00b204e9800998ecf8427e 100644 f 2022-07-24T06:38:25+02:00 0 [inode/x-empty] ./disk02-full/fake file.touch
|
20
|
+
[file_v1.2] f344106fac7926960912486256a56af9 100644 f 2022-07-24T06:38:25+02:00 454 [text/plain] ./disk02-full/ls.txt
|
21
|
+
[file_v1.2] 437b184a6b045975f0fb6c8c978f28ad 100644 f 2022-07-29T19:01:26+02:00 507 [text/plain] ./disk02-full/Rakefile
|
22
|
+
# [stats-with-md5] Time taken for processing 15 files: 0.35655
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: storazzo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Riccardo Carlesso
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-08-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|
@@ -81,7 +81,7 @@ homepage: https://rubygems.org/gems/storazzo
|
|
81
81
|
licenses:
|
82
82
|
- MIT
|
83
83
|
metadata: {}
|
84
|
-
post_install_message:
|
84
|
+
post_install_message:
|
85
85
|
rdoc_options: []
|
86
86
|
require_paths:
|
87
87
|
- lib
|
@@ -97,7 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
97
97
|
version: '0'
|
98
98
|
requirements: []
|
99
99
|
rubygems_version: 3.1.6
|
100
|
-
signing_key:
|
100
|
+
signing_key:
|
101
101
|
specification_version: 4
|
102
102
|
summary: storazzo is an amazing gem. Code is in https://github.com/palladius/storazzo
|
103
103
|
test_files:
|