storazzo 0.5.1 → 0.6.1
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 +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
data/bin/storazzo
ADDED
@@ -0,0 +1,158 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'storazzo'
|
5
|
+
# gem 'storazzo', :path => File.expand_path("../lib", __FILE__)
|
6
|
+
|
7
|
+
require 'optparse'
|
8
|
+
|
9
|
+
extend Storazzo::Colors
|
10
|
+
include Storazzo::Common # instead
|
11
|
+
|
12
|
+
if RUBY_VERSION.split('.')[0] == 1
|
13
|
+
puts 'Refusing to launch a script form Ruby 1. Sorry Ric, its 2020 damn it!'
|
14
|
+
exit 2020
|
15
|
+
end
|
16
|
+
|
17
|
+
$PROG_VER = '0.1'
|
18
|
+
$DEBUG = ENV['DEBUG'] == 'true' # (true/false)
|
19
|
+
|
20
|
+
$actions = %w[
|
21
|
+
show auto help
|
22
|
+
].sort
|
23
|
+
|
24
|
+
# you can't but love Ruby monkey-patching ability..
|
25
|
+
class Array
|
26
|
+
# puts "array drop"
|
27
|
+
def tail
|
28
|
+
drop(1) # https://stackoverflow.com/questions/3615700/ruby-what-is-the-easiest-way-to-remove-the-first-element-from-an-array
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
HISTORY = <<-BIG_LONG_MULTILINE
|
33
|
+
2022-0806 v0.1 First stesure
|
34
|
+
BIG_LONG_MULTILINE
|
35
|
+
|
36
|
+
$description = <<DESCRIPTION_HEREFILE.gsub(/\s+/, ' ').strip
|
37
|
+
This util shall expose all Storazzo aPIs via CLI: show-local-dirs, ...
|
38
|
+
show GCS buckets, ...
|
39
|
+
|
40
|
+
It's also my dream to add some nice icons which are joy to the eye, like
|
41
|
+
some [ ] [x] before the list to show if its agood or bad directory and type also#{' '}
|
42
|
+
DESCRIPTION_HEREFILE
|
43
|
+
# >> "SELECT * FROM users ORDER BY users.id DESC"
|
44
|
+
|
45
|
+
$myconf = {
|
46
|
+
app_name: "Storazzo CLI: #{$PROGRAM_NAME}",
|
47
|
+
description: $description
|
48
|
+
# TODO: move to some class default
|
49
|
+
# :media_dirs => %w{/media/riccardo/ /Volumes/ /mnt/ ~/git/storazzo/var/test/
|
50
|
+
# /sobenme/giusto/per/imparare/ad/ammutolire/gli/errori/},
|
51
|
+
# :mount_types => %w{vfat ntfs},
|
52
|
+
}
|
53
|
+
|
54
|
+
def usage(comment = nil)
|
55
|
+
puts white($optparse.banner)
|
56
|
+
puts($optparse.summarize)
|
57
|
+
# puts("Description: " + gray($myconf[:description]))
|
58
|
+
puts red("ERROR: #{comment}") if comment
|
59
|
+
# puts "Description: #{ $myconf[:description] }"
|
60
|
+
exit 13
|
61
|
+
end
|
62
|
+
|
63
|
+
# include it in main if you want a custome one
|
64
|
+
# see lib_autoinit in lib/util.rb
|
65
|
+
def init
|
66
|
+
$opts = {}
|
67
|
+
# setting defaults
|
68
|
+
$opts[:verbose] = false
|
69
|
+
$opts[:dryrun] = false
|
70
|
+
$opts[:debug] = false
|
71
|
+
$opts[:force] = false
|
72
|
+
|
73
|
+
$optparse = OptionParser.new do |opts|
|
74
|
+
opts.banner = "#{$PROGRAM_NAME} v.#{$PROG_VER}\n Usage: #{File.basename $PROGRAM_NAME} [options] ACTION [file1] [file2] ..."
|
75
|
+
opts.separator "Actions: #{$actions.join ', '}"
|
76
|
+
opts.separator ' $0 show # show options and local folders '
|
77
|
+
opts.separator ' $0 auto # takes automated actions based on config and local disk. For lazy users'
|
78
|
+
opts.separator 'Options: '
|
79
|
+
opts.on('-d', '--debug', 'enables debug (DFLT=false)') do
|
80
|
+
$opts[:debug] = true
|
81
|
+
$DEBUG = true
|
82
|
+
end
|
83
|
+
opts.on('-f', '--force', 'force stuff (DFLT=false)') { $opts[:force] = true }
|
84
|
+
opts.on('-h', '--help', 'Display this screen') { usage }
|
85
|
+
# opts.on( '-j', '--jabba', 'Activates my Jabber powerful CLI' ) { $opts[:jabba] = true }
|
86
|
+
opts.on('-n', '--dryrun', "Don't really execute code") { $opts[:dryrun] = true }
|
87
|
+
opts.on('-l', '--logfile FILE', 'Write log to FILE') { |file| $opts[:logfile] = file }
|
88
|
+
opts.on('-v', '--verbose', 'Output more information') { $opts[:verbose] = true }
|
89
|
+
opts.separator("Description: #{gray($myconf[:description])}")
|
90
|
+
# opts.separator " -- "
|
91
|
+
end
|
92
|
+
$optparse.parse!
|
93
|
+
end
|
94
|
+
|
95
|
+
def show_action(argv)
|
96
|
+
deb "ARGV remaning is: #{argv}"
|
97
|
+
deb('TODO show_action')
|
98
|
+
# puts(white("1. Config"))
|
99
|
+
# Pry::ColorPrinter.pp $config.to_verbose_s
|
100
|
+
puts(white('2. Mounts/Dirs'))
|
101
|
+
Pry::ColorPrinter.pp Storazzo::Media::GcsBucket.list_all_with_type
|
102
|
+
pp Storazzo::Media::AbstractRicDisk.super_duper_list_all_with_type
|
103
|
+
end
|
104
|
+
|
105
|
+
def real_program
|
106
|
+
deb("Hello world from a templated '#{yellow $PROGRAM_NAME}'")
|
107
|
+
deb "+ Options are: #{gray $opts}"
|
108
|
+
deb "+ Depured args: #{azure ARGV}"
|
109
|
+
deb "+ Script-specifig super-cool conf: #{green $prog_conf_d}"
|
110
|
+
deb "+ Your configuration: #{purple $myconf.inspect}"
|
111
|
+
|
112
|
+
# Your code goes here...
|
113
|
+
puts white("Hello world from #{$myconf[:app_name]}!")
|
114
|
+
puts "Description: '''#{white $myconf[:description]}'''"
|
115
|
+
Storazzo::Main.say_hi("Note: if the version of this storazzo is behind local version youre probably using a old library.
|
116
|
+
I still need to learn how to call the binary with local/current lib/: bundle exec stiKazzi?")
|
117
|
+
|
118
|
+
$config = Storazzo::RicDiskConfig.instance
|
119
|
+
$config.load
|
120
|
+
deb "StorazzoConfig: #{$config}"
|
121
|
+
# config.load # auto_sbrodola(ARGV)
|
122
|
+
puts yellow("ARGV: #{ARGV}")
|
123
|
+
# config.iterate_through_file_list_for_disks(ARGV)
|
124
|
+
|
125
|
+
if_deb? { Storazzo::Main.say_hi("ARGV: #{ARGV}") }
|
126
|
+
|
127
|
+
usage('I need at least one argument (storazzo ACTION)') if ARGV == []
|
128
|
+
argv_action = ARGV[0]
|
129
|
+
case argv_action # first argment - action
|
130
|
+
when 'show', 'list'
|
131
|
+
show_action(ARGV.tail)
|
132
|
+
when 'auto'
|
133
|
+
auto_action(ARGV.tail)
|
134
|
+
when 'help'
|
135
|
+
usage("There you go, here's your HELP :)")
|
136
|
+
when String
|
137
|
+
usage("Unknown action1: #{argv_action}. Available actions: #{$actions}")
|
138
|
+
else
|
139
|
+
usage("Unknown action2, really strange!: '#{argv_action}'. Actions: #{$actions}")
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
def main(filename)
|
144
|
+
deb "I'm called by #{white filename}"
|
145
|
+
deb "HISTORY: #{gray HISTORY}"
|
146
|
+
init # Enable this to have command line parsing capabilities!
|
147
|
+
puts white("$DEBUG is #{$DEBUG}. Tu turn on, call me with -d") unless $DEBUG
|
148
|
+
# warn "[warn] template v#{$TEMPLATE_VER }: proviamo il warn che magari depreca il DEB"
|
149
|
+
real_program
|
150
|
+
|
151
|
+
if_deb? do
|
152
|
+
puts 'First I need to figure out how to bring in all the libraries in here..'
|
153
|
+
Storazzo::Main.say_hi("ARGV is: #{ARGV.join ', '}")
|
154
|
+
puts Storazzo.version
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
main(__FILE__)
|
@@ -0,0 +1 @@
|
|
1
|
+
bin/storazzo
|
data/bin/storazzo-util
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
bin/storazzo
|
data/lib/storazzo/colors.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Use EXTEND vs INCLUDE and magically the Class will inherit instead of instance. Magical! :)
|
2
4
|
# http://www.railstips.org/blog/archives/2009/05/15/include-vs-extend-in-ruby/
|
3
5
|
#
|
@@ -9,41 +11,80 @@ module Storazzo
|
|
9
11
|
# needs to be defined before
|
10
12
|
end
|
11
13
|
|
12
|
-
module Storazzo
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
14
|
+
module Storazzo
|
15
|
+
module Colors
|
16
|
+
PREPEND_ME = '[Storazzo::Colors] '
|
17
|
+
|
18
|
+
def deb2(s)
|
19
|
+
puts "#DEB_OBSOLETE #{gray(s)} [include Storazzo::Common instead]" if $DEBUG
|
20
|
+
end
|
21
|
+
|
22
|
+
# colors 16
|
23
|
+
def yellow(s)
|
24
|
+
"\033[1;33m#{s}\033[0m"
|
25
|
+
end
|
26
|
+
|
27
|
+
def gray(s)
|
28
|
+
"\033[1;30m#{s}\033[0m"
|
29
|
+
end
|
30
|
+
|
31
|
+
def green(s)
|
32
|
+
"\033[1;32m#{s}\033[0m"
|
33
|
+
end
|
34
|
+
|
35
|
+
def red(s)
|
36
|
+
"\033[1;31m#{s}\033[0m"
|
37
|
+
end
|
38
|
+
|
39
|
+
def blue(s)
|
40
|
+
"\033[1;34m#{s}\033[0m"
|
41
|
+
end
|
42
|
+
|
43
|
+
def purple(s)
|
44
|
+
"\033[1;35m#{s}\033[0m"
|
45
|
+
end
|
46
|
+
|
47
|
+
def azure(s)
|
48
|
+
"\033[1;36m#{s}\033[0m"
|
49
|
+
end
|
50
|
+
|
51
|
+
def white(s)
|
52
|
+
"\033[1;37m#{s}\033[0m"
|
53
|
+
end
|
54
|
+
|
55
|
+
# colors 64k
|
56
|
+
def orange(s)
|
57
|
+
"\033[38;5;208m#{s}\033[0m"
|
58
|
+
end
|
59
|
+
|
60
|
+
# i dont undertstand why i need self :/
|
61
|
+
# SELF version because I'm just stupid or lazy or both.
|
62
|
+
# def self.yellow(s) "#{PREPEND_ME}\033[1;33m#{s}\033[0m" ; end
|
63
|
+
# def self.green(s) "#{PREPEND_ME}\033[1;32m#{s}\033[0m" ; end
|
64
|
+
# def self.gray(s) "#{PREPEND_ME}\033[1;30m#{s}\033[0m" ; end
|
65
|
+
# def self.green(s) "#{PREPEND_ME}\033[1;32m#{s}\033[0m" ; end
|
66
|
+
# def self.red(s) "#{PREPEND_ME}\033[1;31m#{s}\033[0m" ; end
|
67
|
+
# def self.blue(s) "#{PREPEND_ME}\033[1;34m#{s}\033[0m" ; end
|
68
|
+
# def self.purple(s) "#{PREPEND_ME}\033[1;35m#{s}\033[0m" ; end
|
69
|
+
# def self.azure(s) "#{PREPEND_ME}\033[1;36m#{s}\033[0m" ; end
|
70
|
+
# def self.white(s) "#{PREPEND_ME}\033[1;37m#{s}\033[0m" ; end
|
71
|
+
|
72
|
+
# p<COLOR> Carlessian functions..
|
73
|
+
def pwhite(s)
|
74
|
+
puts(white(s))
|
75
|
+
end
|
76
|
+
|
77
|
+
def pgreen(s)
|
78
|
+
puts(green(s))
|
79
|
+
end
|
80
|
+
|
81
|
+
def pred(s)
|
82
|
+
puts(red(s))
|
83
|
+
end
|
84
|
+
|
85
|
+
def pyellow(s)
|
86
|
+
puts(yellow(s))
|
87
|
+
end
|
88
|
+
end
|
48
89
|
end
|
49
90
|
# end
|
data/lib/storazzo/common.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Ric common stuff! :)
|
2
4
|
#
|
3
5
|
# Usage:
|
@@ -5,86 +7,91 @@
|
|
5
7
|
# or
|
6
8
|
# extend Storazzo::Common (def to def self.XX)
|
7
9
|
#
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
🧏 🦻 🦮 🦯 🦺 🦼 🦽 🦾 🦿 🤵 👮 👷 💁 💂 🕴 🕵 🦸 🦹 🧙 🧚 🧜 🧝 🧞 🧛 🧟 👼 👿 👻 👹 👺 👽 👾 🛸 💀 ☠ 🕱 🧠 🦴 👁 👀 👂 👃 👄 🗢 👅 🦷 🦵 🦶 💭 🗬 🗭 💬 🗨 🗩 🗪 🗫 🗰 🗱 🗮 🗯 🗣 🗤 🗥 🗦 🗧 💦 💧 💢 💫 💤 💨 💥 💪 🗲 🔥 💡 💩 💯 🔟 🔰 🕲
|
29
|
-
=end
|
10
|
+
# Emoji to copy:
|
11
|
+
# 👍 👎 👌 ✌ 👋 🤝 👏 🤘 🤟 🤙 🤏 🙌 🙏 🖖 🤞 ✋ 🤚 🖐 🖑 🤲 👐 👊 🤛 🤜 🖕
|
12
|
+
# 👈 👉 👆 👇
|
13
|
+
# ☺ ☻ 😃 😄 😅 😆 😊 😎 😇 😈 😏 🤣 🤩 🤪 🥳 😁 😀 😂 🤠 🤡 🤑 🤓 🤖 kiss
|
14
|
+
# 😗 😚 😘 😙 flirting
|
15
|
+
# 😉 🤗 😍 🥰 🤤 😋 😛 😜 😝 neutral
|
16
|
+
# 😶 🙃 😐 😑 🤔 🤨 🧐 hush
|
17
|
+
# 🤭 🤫 😯 🤐 😌 😖 😕 😳 😔 🤥 🥴 shocked
|
18
|
+
# 😮 😲 🤯 tired
|
19
|
+
# 😩 😫 🥱 😪 😴 😵 sad
|
20
|
+
# ☹ 😦 😞 😥 😟 cry
|
21
|
+
# 😢 😭 sick
|
22
|
+
# 🤢 🤮 😷 🤒 🤕 🥵 🥶 fear
|
23
|
+
# 🥺 😬 😓 😰 😨 😱 angry
|
24
|
+
# 😒 😠 😡 😤 😣 😧 🤬 😸 😹 😺 😻 😼 😽 😾 😿 🙀 🙈 🙉 🙊
|
25
|
+
# [see Animal Emoji 🐰] gesture
|
26
|
+
# 🤦 🤷 🙅 🙆 🙋 🙌 🙍 🙎 🙇 🙏 activity
|
27
|
+
# 👯 💃 🕺 🤳 💇 💈 💆 🧖 🧘 🧍 🧎 👰 🤰 🤱 faces
|
28
|
+
# 👶 🧒 👦 👧 👩 👨 🧑 🧔 🧓 👴 👵 👤 👥 👪 👫 👬 👭 👱 👳 👲 🧕 👸 🤴 🎅 🤶 disabled
|
29
|
+
# 🧏 🦻 🦮 🦯 🦺 🦼 🦽 🦾 🦿 🤵 👮 👷 💁 💂 🕴 🕵 🦸 🦹 🧙 🧚 🧜 🧝 🧞 🧛 🧟 👼 👿 👻 👹 👺 👽 👾 🛸 💀 ☠ 🕱 🧠 🦴 👁 👀 👂 👃 👄 🗢 👅 🦷 🦵 🦶 💭 🗬 🗭 💬 🗨 🗩 🗪 🗫 🗰 🗱 🗮 🗯 🗣 🗤 🗥 🗦 🗧 💦 💧 💢 💫 💤 💨 💥 💪 🗲 🔥 💡 💩 💯 🔟 🔰 🕲
|
30
30
|
require_relative 'colors'
|
31
31
|
require 'pry'
|
32
32
|
|
33
|
-
module Storazzo
|
34
|
-
|
33
|
+
module Storazzo
|
34
|
+
module Common
|
35
|
+
include Storazzo::Colors
|
35
36
|
|
36
|
-
|
37
|
-
|
38
|
-
|
37
|
+
def deb(s)
|
38
|
+
# useless: put logic in _debug_true() # return if ENV['RUBYOPT'] == "-W0"
|
39
|
+
puts "[DEB👀] #{yellow(s)}" if _debug_true # $DEBUG
|
40
|
+
end
|
39
41
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
42
|
+
# this has a yield
|
43
|
+
def if_deb?
|
44
|
+
if _debug_true # $DEBUG
|
45
|
+
deb '== yield START =='
|
46
|
+
yield
|
47
|
+
deb '== yield END =='
|
48
|
+
end
|
46
49
|
end
|
47
|
-
end
|
48
50
|
|
49
|
-
|
50
|
-
|
51
|
-
|
51
|
+
def warn(s)
|
52
|
+
puts "[W⚠️RN] #{azure(s)}"
|
53
|
+
end
|
52
54
|
|
53
|
-
|
54
|
-
|
55
|
-
|
55
|
+
def err(_str)
|
56
|
+
puts "[ERR👎] #{red(s)}" # ⛔
|
57
|
+
end
|
56
58
|
|
57
|
-
|
58
|
-
|
59
|
-
|
59
|
+
def bug(s)
|
60
|
+
puts "[🐛] #{gray s}"
|
61
|
+
end
|
60
62
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
end
|
63
|
+
def pverbose(_is_verbose, str)
|
64
|
+
# puts "[V📚RB💀S📚] #{gray str}"
|
65
|
+
return if ENV['RUBYOPT'] == '-W0'
|
65
66
|
|
66
|
-
|
67
|
-
|
68
|
-
Pry::ColorPrinter.pp(complex_object_to_colorize)
|
69
|
-
end
|
67
|
+
puts "[🦋🐛🐝🐞🐜🕷🕸🦂🦗🦟] #{gray str}" # insects: http://xahlee.info/comp/unicode_insects.html
|
68
|
+
end
|
70
69
|
|
71
|
-
|
72
|
-
|
73
|
-
|
70
|
+
def ppp(complex_object_to_colorize)
|
71
|
+
# TODO: i need to learn to return without printing..
|
72
|
+
Pry::ColorPrinter.pp(complex_object_to_colorize)
|
73
|
+
end
|
74
74
|
|
75
|
-
|
76
|
-
|
77
|
-
|
75
|
+
def fatal(s)
|
76
|
+
raise "[F💀TAL] #{red s}"
|
77
|
+
end
|
78
78
|
|
79
|
-
|
80
|
-
|
81
|
-
|
79
|
+
def mac?
|
80
|
+
`uname`.chomp == 'Darwin'
|
81
|
+
end
|
82
82
|
|
83
|
-
|
83
|
+
def linux?
|
84
|
+
`uname`.chomp == 'Linux'
|
85
|
+
end
|
84
86
|
|
85
|
-
|
86
|
-
|
87
|
-
|
87
|
+
private
|
88
|
+
|
89
|
+
def _debug_true
|
90
|
+
return false if ENV['RUBYOPT'] == '-W0'
|
88
91
|
|
89
|
-
|
92
|
+
$DEBUG or ENV['DEBUG'] == 'true' # but FALSE isor _debug_true
|
93
|
+
end
|
94
|
+
|
95
|
+
# puts "[DEBUG ENABLED!]" if _debug_true
|
96
|
+
end
|
90
97
|
end
|
data/lib/storazzo/debug.rb
CHANGED
data/lib/storazzo/hashify.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# copied from https://dev.to/ayushn21/how-to-generate-yaml-from-ruby-objects-without-type-annotations-4fli
|
2
4
|
module Storazzo
|
3
5
|
module Hashify
|
@@ -20,19 +22,19 @@ module Storazzo
|
|
20
22
|
value = instance_variable_get(var)
|
21
23
|
value = value.map(&:to_hash) if value.is_a? Array
|
22
24
|
|
23
|
-
hash[var.to_s.delete(
|
25
|
+
hash[var.to_s.delete('@')] = value
|
24
26
|
end
|
25
27
|
|
26
|
-
|
28
|
+
hash
|
27
29
|
end
|
28
30
|
|
29
31
|
def obj_to_hash
|
30
32
|
h = {}
|
31
33
|
puts self
|
32
|
-
|
34
|
+
instance_variables.each do |var|
|
33
35
|
# puts var
|
34
|
-
h[var.to_s.delete('@')] =
|
35
|
-
|
36
|
+
h[var.to_s.delete('@')] = instance_variable_get(var) # send(var.to_s.delete('@'))
|
37
|
+
end
|
36
38
|
h
|
37
39
|
end
|
38
40
|
|
data/lib/storazzo/main.rb
CHANGED
@@ -1,7 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# main entrypoint for tests and silly stuff from Makefile..
|
2
4
|
# This Class externalizes all relevant things from other libs while I learn how to do it from there
|
3
5
|
# eg from RicDisk.
|
4
6
|
|
7
|
+
require 'English'
|
5
8
|
module Storazzo
|
6
9
|
# This is the Main Class - an entrypoint to call the meravilles hidden therein.
|
7
10
|
#
|
@@ -12,62 +15,69 @@ module Storazzo
|
|
12
15
|
# Arguments:
|
13
16
|
# message: (String) - optional
|
14
17
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
+
# Can be same name as Module: https://stackoverflow.com/questions/13261474/ruby-modules-and-classes-same-name-in-structure
|
19
|
+
module Storazzo
|
20
|
+
class Main
|
21
|
+
require 'storazzo/colors'
|
22
|
+
extend Storazzo::Colors
|
18
23
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
24
|
+
# version 1.2
|
25
|
+
def self.say_hi(message = nil)
|
26
|
+
str = get_hi(message)
|
27
|
+
puts str
|
28
|
+
str
|
29
|
+
end
|
25
30
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
31
|
+
# salutation
|
32
|
+
def self.get_hi(message = nil)
|
33
|
+
str = "Hello from Storazzo v#{begin
|
34
|
+
white Storazzo.version
|
35
|
+
rescue StandardError
|
36
|
+
"Error: #{$ERROR_INFO}"
|
37
|
+
end}!"
|
38
|
+
str += " Message: '#{yellow message.to_s}'" if message
|
39
|
+
str
|
40
|
+
end
|
32
41
|
|
33
|
-
|
34
|
-
|
42
|
+
def self.all_mounts(opts = {})
|
43
|
+
opts_verbose = opts.fetch :verbose, true
|
35
44
|
|
36
|
-
|
45
|
+
say_hi "Storazzo::Main.all_mounts(): BEGIN - RicDiskVersion is: #{Storazzo::RicDiskUgly::RICDISK_VERSION}"
|
37
46
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
47
|
+
pwhite('1. First I load the config in verbose mode..')
|
48
|
+
config = Storazzo::RicDiskConfig.instance
|
49
|
+
config.load
|
50
|
+
# puts config.object_id
|
51
|
+
# puts Storazzo::RicDiskConfig.instance.object_id
|
52
|
+
pwhite 'TODO(ricc): show a list of all RicDisk relevant mounts' if opts_verbose
|
53
|
+
# d = Storazzo::RicDisk.new
|
54
|
+
config.iterate_through_file_list_for_disks # analyze_local_system
|
55
|
+
# sbrodola_ricdisk("/Volumes/")
|
56
|
+
Storazzo::RicDisk.test
|
57
|
+
Storazzo::RicDisk.find_active_dirs
|
58
|
+
# Storazzo::RicDisk.sbrodola_ricdisk StorazzoMod::root + "./var/disks/"
|
59
|
+
# sbrodola_ricdisk(StorazzoMod::root + "./var/disks/") rescue "[Storazzo::AllMount] SomeError: #{$!}"
|
60
|
+
hi 'Storazzo::Main.all_mounts(): END'
|
61
|
+
end
|
53
62
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
63
|
+
def self.all_tests
|
64
|
+
# include vs extend: https://stackoverflow.com/questions/15097929/ruby-module-require-and-include
|
65
|
+
# => http://www.railstips.org/blog/archives/2009/05/15/include-vs-extend-in-ruby/
|
66
|
+
# include Storazzo::Colors
|
67
|
+
extend Storazzo::Colors
|
59
68
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
69
|
+
pwhite 'All tests BEGIN - todo obsolete this now that I have proper Rake testing suite...'
|
70
|
+
deb 'Maybe debug is enabled?'
|
71
|
+
say_hi
|
72
|
+
# This works with EXTEND..
|
73
|
+
puts(yellow('Just YELLOW 0'))
|
74
|
+
# This reqwuires a INCLUDE.
|
75
|
+
# puts(Storazzo::Colors.yellow "Test YELLOW 1 self")
|
76
|
+
# puts(Colors.yellow "Test YELLOW 1 self")
|
77
|
+
# puts(Colors.green "Test YELLOW 2 ohne self")
|
78
|
+
pwhite 'All tests END'
|
79
|
+
# puts "All tests END"
|
80
|
+
end
|
71
81
|
end
|
72
82
|
end
|
73
83
|
end
|