storazzo 0.5.1 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +7 -5
- data/LICENSE +20 -1
- data/Makefile +9 -5
- data/Rakefile +22 -9
- data/VERSION +1 -1
- data/bin/hello-storazzo +1 -0
- data/bin/ricdisk-magic +33 -30
- data/bin/stats-with-md5 +146 -176
- data/bin/storazzo +158 -0
- data/bin/storazzo-symlink.rb +1 -0
- data/bin/storazzo-util +1 -0
- data/lib/storazzo/colors.rb +77 -36
- data/lib/storazzo/common.rb +72 -65
- data/lib/storazzo/debug.rb +2 -0
- data/lib/storazzo/hashify.rb +7 -5
- data/lib/storazzo/main.rb +59 -49
- data/lib/storazzo/media/abstract_ric_disk.rb +190 -161
- data/lib/storazzo/media/gcs_bucket.rb +78 -47
- data/lib/storazzo/media/local_folder.rb +56 -42
- data/lib/storazzo/media/mount_point.rb +22 -6
- data/lib/storazzo/ric_disk.rb +386 -383
- data/lib/storazzo/ric_disk_config.rb +229 -197
- data/lib/storazzo/ric_disk_sample_config.rb +26 -24
- data/lib/storazzo/ric_disk_statsfile.rb +19 -17
- data/lib/storazzo/ric_disk_ugly.rb +1 -0
- data/lib/storazzo/version.rb +3 -3
- data/lib/storazzo.rb +6 -7
- data/storazzo.gemspec +31 -19
- data/test/benchmark/for_future_use.rb +15 -0
- data/test/benchmark/test_hashing_functions-speed.rb +17 -0
- data/test/bin/new-idea.rb +17 -0
- data/test/bin/storazzo.rb +25 -0
- data/test/media/test_abstract_ric_disk.rb +6 -4
- data/test/media/test_gcs_bucket.rb +55 -21
- data/test/media/test_local_folder.rb +28 -29
- data/test/media/test_mount_point.rb +7 -5
- data/test/test_ric_disk.rb +8 -6
- data/test/test_ric_disk_config.rb +13 -12
- data/test/test_ric_disk_stats_file.rb +5 -3
- data/test/test_storazzo.rb +6 -4
- data/var/test/disks/disk02-full/Rakefile +7 -5
- data/var/test/disks/ricdisk_stats_v11.rds +11 -22
- metadata +22 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e82c96fbdff7b8d2f78556899257b431ec1e58ec255321bae2afb4ba3b1ac309
|
4
|
+
data.tar.gz: f343d195bce5121d18f456b3fd90f8032a41427ae41e4248f5b8628aca1b0a3e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d9aa08e7fcc62e0d8a3510db4d26f27e227aa778f8e9d8e6d7831676936c282e97f72f57f08febdc7383dec2f1e4c66beb42eb94dae3638f422fc6073292f204
|
7
|
+
data.tar.gz: e75cb487f55943dbae3d23242909ca61a83c39aaf5ef793225c074181f6914290d7f11aa3fa537f43010db4feab239efb14e88c5f30d91f737465081ad825309
|
data/Gemfile
CHANGED
@@ -1,10 +1,12 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source 'https://rubygems.org'
|
2
4
|
|
3
5
|
# to troubleshoot/debug things
|
4
|
-
gem 'rubocop'
|
5
|
-
gem "ruby-lsp", "~> 0.0.4", :group => :development
|
6
6
|
gem 'rake'
|
7
|
+
gem 'rubocop'
|
8
|
+
gem 'ruby-lsp', '~> 0.0.4', group: :development
|
9
|
+
|
7
10
|
# gem 'pry'
|
8
|
-
gem 'pry', :
|
9
|
-
# gem 'require_all' # yup I'm lazy: https://stackoverflow.com/questions/735073/best-way-to-require-all-files-from-a-directory-in-ruby
|
11
|
+
gem 'pry', group: :development
|
10
12
|
# gem 'after_do' # To allow AFTER calling instance to do LOAD() automagically. Naah I can do without :)
|
data/LICENSE
CHANGED
@@ -1 +1,20 @@
|
|
1
|
-
|
1
|
+
Copyright 2022 Riccardo Carlesso (MIT)
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Makefile
CHANGED
@@ -10,14 +10,14 @@ help:
|
|
10
10
|
build-local:
|
11
11
|
gem build storazzo.gemspec
|
12
12
|
|
13
|
-
build: build-local
|
13
|
+
build: build-local
|
14
14
|
|
15
15
|
install:
|
16
16
|
gem install ./storazzo-$(VER).gem
|
17
17
|
|
18
18
|
push-to-rubygems: build-local test
|
19
19
|
gem push ./storazzo-$(VER).gem
|
20
|
-
push-to-rubygems-without-tests: build-local
|
20
|
+
push-to-rubygems-without-tests: build-local
|
21
21
|
gem push ./storazzo-$(VER).gem
|
22
22
|
|
23
23
|
list:
|
@@ -31,7 +31,7 @@ test-all:
|
|
31
31
|
#bin/ricdisk-magic Ciao-da-Makefile
|
32
32
|
echo 3. run rake test.. ont configured yet just a memo for the future.
|
33
33
|
RUBYOPT="-W0" rake test
|
34
|
-
echo 4. Prove I can include local gem in irb and play around. Similarly to rails console without reload.
|
34
|
+
echo 4. Prove I can include local gem in irb and play around. Similarly to rails console without reload.
|
35
35
|
make irb-test
|
36
36
|
@echo 'OK: ALL TESTS PASSED. #STIKA'
|
37
37
|
|
@@ -62,7 +62,9 @@ test-local-folder:
|
|
62
62
|
test-media-subfolder:
|
63
63
|
rake test TEST="test/media/*.rb"
|
64
64
|
test-verbose:
|
65
|
-
rake test:verbose --verbose
|
65
|
+
rake test:verbose --verbose
|
66
|
+
test-silent:
|
67
|
+
RUBYOPT="-W0" rake test:silent --verbose
|
66
68
|
test-single-file-continuously:
|
67
69
|
\watch -n 5 --color rake test TEST="test/media/test_local_folder.rb"
|
68
70
|
|
@@ -70,4 +72,6 @@ test-binary-with-local-gem:
|
|
70
72
|
ruby -Ilib bin/hello-storazzo
|
71
73
|
test-binary-with-system-gem:
|
72
74
|
bin/hello-storazzo
|
73
|
-
|
75
|
+
|
76
|
+
lint:
|
77
|
+
rubocop --auto-correct
|
data/Rakefile
CHANGED
@@ -1,34 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# require 'rake'
|
2
4
|
|
3
5
|
# from hola: https://guides.rubygems.org/make-your-own-gem/#adding-an-executable
|
4
|
-
require
|
6
|
+
require 'rake/testtask'
|
5
7
|
|
6
|
-
desc
|
8
|
+
desc 'Run Unit tests'
|
7
9
|
Rake::TestTask.new(:test) do |t|
|
8
|
-
t.libs <<
|
9
|
-
t.libs <<
|
10
|
-
#
|
10
|
+
t.libs << 'test'
|
11
|
+
t.libs << 'test/media'
|
12
|
+
# NOTE: this is only useful for this: https://chriskottom.com/articles/command-line-flags-for-minitest-in-the-raw/
|
11
13
|
t.verbose = false
|
12
14
|
t.warning = false
|
13
15
|
# puts "[RiccardoOnly]: t.pattern: #{t.pattern}"
|
14
16
|
t.pattern = 'test/**/test_*.rb'
|
15
17
|
end
|
16
18
|
|
17
|
-
desc
|
19
|
+
desc 'By default, Run Unit tests'
|
18
20
|
task default: :test
|
19
21
|
|
20
22
|
# Adding test/media directory to rake test.
|
21
|
-
desc
|
23
|
+
desc 'Test tests/media/* code sobenem'
|
22
24
|
namespace :test do
|
23
25
|
desc "Test Verbosely by default since I'm too stupid to toggle via ENV var dammit"
|
24
26
|
Rake::TestTask.new(:verbose) do |t|
|
25
|
-
t.libs <<
|
26
|
-
t.libs <<
|
27
|
+
t.libs << 'test'
|
28
|
+
t.libs << 'test/media'
|
27
29
|
t.verbose = true
|
28
30
|
t.warning = true
|
29
31
|
t.pattern = 'test/**/test_*.rb'
|
30
32
|
$DEBUG = true
|
31
33
|
end
|
34
|
+
|
35
|
+
desc 'Test Silently and removes VERBOSITY'
|
36
|
+
Rake::TestTask.new(:silent) do |t|
|
37
|
+
t.libs << 'test'
|
38
|
+
t.libs << 'test/media'
|
39
|
+
t.verbose = false
|
40
|
+
t.warning = false
|
41
|
+
t.pattern = 'test/**/test_*.rb'
|
42
|
+
puts "Note: Best to call me with RUBYOPT='-W0'. Now RUBYOPT=#{ENV['RUBYOPT']}" if ENV['RUBYOPT'].nil?
|
43
|
+
$DEBUG = false
|
44
|
+
end
|
32
45
|
end
|
33
46
|
# namespace :verbose_test do
|
34
47
|
# desc "Test tests/media/* code"
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.6.1
|
data/bin/hello-storazzo
CHANGED
data/bin/ricdisk-magic
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
############# ############# ############# ############# ############# ############# ############# #############
|
4
5
|
# placeholder until i make it work..
|
@@ -32,7 +33,7 @@ include Storazzo::Common # instead
|
|
32
33
|
# extend Storazzo::Colors
|
33
34
|
|
34
35
|
if RUBY_VERSION.split('.')[0] == 1
|
35
|
-
puts
|
36
|
+
puts 'Refusing to launch a script form Ruby 1. Sorry Ric, its 2020 damn it!'
|
36
37
|
exit 2020
|
37
38
|
end
|
38
39
|
|
@@ -47,23 +48,21 @@ HISTORY = <<-BIG_LONG_MULTILINE
|
|
47
48
|
2022-07-DD v0.2 Some private stuff on GIC
|
48
49
|
BIG_LONG_MULTILINE
|
49
50
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
=end
|
51
|
+
#
|
52
|
+
# ############################################################
|
53
|
+
# @author: Riccardo Carlesso
|
54
|
+
# @email: riccardo.carlesso@gmail.com
|
55
|
+
# @maturity: development
|
56
|
+
# @language: Ruby
|
57
|
+
# @synopsis: Brief Description here
|
58
|
+
# @tags: development, rcarlesso, test
|
59
|
+
# @description: See description
|
60
|
+
# ############################################################
|
61
|
+
#
|
63
62
|
|
64
63
|
$myconf = {
|
65
|
-
:
|
66
|
-
:
|
64
|
+
app_name: "RicDisk Magic should be sth like #{$PROGRAM_NAME}",
|
65
|
+
description: "
|
67
66
|
This program is loosely inspired to ricdisk-magic.sh but its much better.
|
68
67
|
The idea is: iterate through all ARGV elements and build a DB of all files with length and MD5.
|
69
68
|
Then if folder is writeable, put this list INSIDE IT as its so conveniente.
|
@@ -74,13 +73,13 @@ $myconf = {
|
|
74
73
|
Note. This software is part of the Storazzo gem ('sai chi ti saluta un casino?'):
|
75
74
|
|
76
75
|
$ gem install storazzo
|
77
|
-
".strip.gsub(/^\s+/,
|
78
|
-
# TODO move to some class default
|
79
|
-
:
|
80
|
-
|
81
|
-
:
|
76
|
+
".strip.gsub(/^\s+/, '').gsub(/\s+$/, ''),
|
77
|
+
# TODO: move to some class default
|
78
|
+
media_dirs: %w[/media/riccardo/ /Volumes/ /mnt/ ~/git/storazzo/var/test/
|
79
|
+
/sobenme/giusto/per/imparare/ad/ammutolire/gli/errori/],
|
80
|
+
mount_types: %w[vfat ntfs]
|
82
81
|
}
|
83
|
-
$stats_file =
|
82
|
+
$stats_file = 'ricdisk_stats_v11.rds' # => RicDiskStatsFile
|
84
83
|
$gcs_bucket = 'TODO-CHANGE-CONFIG-palladius'
|
85
84
|
|
86
85
|
# This template from scripta.rb. from 2.1.0 removed aby ric gem dependency.
|
@@ -91,14 +90,15 @@ $TEMPLATE_VER = '2.1.1'
|
|
91
90
|
def usage(comment = nil)
|
92
91
|
puts white($optparse.banner)
|
93
92
|
puts($optparse.summarize)
|
94
|
-
puts("Description:
|
93
|
+
puts("Description: #{gray($myconf[:description])}")
|
95
94
|
puts red(comment) if comment
|
96
95
|
# puts "Description: #{ $myconf[:description] }"
|
97
96
|
exit 13
|
98
97
|
end
|
99
98
|
|
100
99
|
# include it in main if you want a custome one
|
101
|
-
|
100
|
+
# see lib_autoinit in lib/util.rb
|
101
|
+
def init
|
102
102
|
$opts = {}
|
103
103
|
# setting defaults
|
104
104
|
$opts[:verbose] = false
|
@@ -107,8 +107,11 @@ def init() # see lib_autoinit in lib/util.rb
|
|
107
107
|
$opts[:force] = false
|
108
108
|
|
109
109
|
$optparse = OptionParser.new do |opts|
|
110
|
-
opts.banner = "#{$
|
111
|
-
opts.on('-d', '--debug', 'enables debug (DFLT=false)')
|
110
|
+
opts.banner = "#{$PROGRAM_NAME} v.#{$PROG_VER}\n Usage: #{File.basename $PROGRAM_NAME} [options] file1 file2 ..."
|
111
|
+
opts.on('-d', '--debug', 'enables debug (DFLT=false)') do
|
112
|
+
$opts[:debug] = true
|
113
|
+
$DEBUG = true
|
114
|
+
end
|
112
115
|
opts.on('-f', '--force', 'force stuff (DFLT=false)') { $opts[:force] = true }
|
113
116
|
opts.on('-h', '--help', 'Display this screen') { usage }
|
114
117
|
# opts.on( '-j', '--jabba', 'Activates my Jabber powerful CLI' ) { $opts[:jabba] = true }
|
@@ -120,7 +123,7 @@ def init() # see lib_autoinit in lib/util.rb
|
|
120
123
|
end
|
121
124
|
|
122
125
|
def real_program
|
123
|
-
deb("Hello world from a templated '#{yellow $
|
126
|
+
deb("Hello world from a templated '#{yellow $PROGRAM_NAME}'")
|
124
127
|
deb "+ Options are: #{gray $opts}"
|
125
128
|
deb "+ Depured args: #{azure ARGV}"
|
126
129
|
deb "+ Script-specifig super-cool conf: #{green $prog_conf_d}"
|
@@ -130,7 +133,7 @@ def real_program
|
|
130
133
|
puts white("Hello world from #{$myconf[:app_name]}!")
|
131
134
|
puts "Description: '''#{white $myconf[:description]}'''"
|
132
135
|
|
133
|
-
config = Storazzo::RicDiskConfig.instance
|
136
|
+
config = Storazzo::RicDiskConfig.instance
|
134
137
|
config.load
|
135
138
|
puts "StorazzoConfig: #{config}"
|
136
139
|
# config.load # auto_sbrodola(ARGV)
|
@@ -167,8 +170,8 @@ def main(filename)
|
|
167
170
|
# warn "[warn] template v#{$TEMPLATE_VER }: proviamo il warn che magari depreca il DEB"
|
168
171
|
real_program
|
169
172
|
|
170
|
-
if
|
171
|
-
puts
|
173
|
+
if $DEBUG
|
174
|
+
puts 'First I need to figure out how to bring in all the libraries in here..'
|
172
175
|
Storazzo::Main.say_hi("ARGV is: #{ARGV.join ', '}")
|
173
176
|
puts Storazzo.version
|
174
177
|
end
|