storazzo 0.4.2 → 0.5.0
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 -4
- data/Makefile +20 -1
- data/README.md +23 -0
- data/Rakefile +35 -8
- data/VERSION +1 -1
- data/bin/hello-storazzo +5 -0
- data/bin/ricdisk-magic +50 -57
- data/bin/stats-with-md5 +268 -297
- data/lib/storazzo/colors.rb +43 -45
- data/lib/storazzo/common.rb +80 -17
- data/lib/storazzo/debug.rb +5 -8
- data/lib/storazzo/hashify.rb +44 -43
- data/lib/storazzo/main.rb +44 -40
- data/lib/storazzo/media/abstract_ric_disk.rb +163 -104
- data/lib/storazzo/media/gcs_bucket.rb +51 -15
- data/lib/storazzo/media/local_folder.rb +43 -46
- data/lib/storazzo/media/mount_point.rb +12 -2
- data/lib/storazzo/ric_disk.rb +223 -251
- data/lib/storazzo/ric_disk_config.rb +230 -193
- data/lib/storazzo/ric_disk_sample_config.rb +12 -16
- data/lib/storazzo/ric_disk_statsfile.rb +17 -16
- data/lib/storazzo/ric_disk_ugly.rb +35 -38
- data/lib/storazzo/version.rb +7 -7
- data/lib/storazzo.rb +34 -29
- data/storazzo.gemspec +22 -20
- data/test/media/test_abstract_ric_disk.rb +19 -0
- data/test/media/test_gcs_bucket.rb +58 -0
- data/test/media/test_local_folder.rb +145 -0
- data/test/media/test_mount_point.rb +25 -0
- data/test/test_ric_disk.rb +16 -0
- data/test/test_ric_disk_config.rb +20 -29
- data/test/test_ric_disk_stats_file.rb +13 -14
- data/test/test_storazzo.rb +26 -26
- data/var/dumps/file_stat.linux.yaml +15 -0
- data/var/dumps/file_stat.macosx.yaml +15 -0
- data/var/test/disks/disk02-full/Rakefile +13 -0
- data/var/test/disks/ricdisk_stats_v11.rds +11 -0
- metadata +38 -10
- data/test/test_gcs_bucket.rb +0 -70
- data/test/test_local_folder.rb +0 -121
data/lib/storazzo/colors.rb
CHANGED
@@ -1,51 +1,49 @@
|
|
1
1
|
# Use EXTEND vs INCLUDE and magically the Class will inherit instead of instance. Magical! :)
|
2
2
|
# http://www.railstips.org/blog/archives/2009/05/15/include-vs-extend-in-ruby/
|
3
|
-
#
|
4
|
-
# include Storazzo::Colors
|
5
|
-
# extend Storazzo::Colors
|
6
|
-
#
|
3
|
+
#
|
4
|
+
# include Storazzo::Colors
|
5
|
+
# extend Storazzo::Colors
|
6
|
+
#
|
7
7
|
|
8
|
-
module Storazzo
|
9
|
-
|
10
|
-
end
|
8
|
+
module Storazzo
|
9
|
+
# needs to be defined before
|
10
|
+
end
|
11
11
|
|
12
12
|
module Storazzo::Colors
|
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
|
-
|
48
|
-
def pyellow(s) puts(yellow(s)); end
|
49
|
-
|
13
|
+
PREPEND_ME = "[Storazzo::Colors] "
|
14
|
+
|
15
|
+
def deb2(s);
|
16
|
+
puts "#DEB_OBSOLETE #{gray(s)} [include Storazzo::Common instead]" if $DEBUG; end # Use the Common instead
|
17
|
+
|
18
|
+
# colors 16
|
19
|
+
def yellow(s) "\033[1;33m#{s}\033[0m"; end
|
20
|
+
def gray(s) "\033[1;30m#{s}\033[0m"; end
|
21
|
+
def green(s) "\033[1;32m#{s}\033[0m"; end
|
22
|
+
def red(s) "\033[1;31m#{s}\033[0m"; end
|
23
|
+
def blue(s) "\033[1;34m#{s}\033[0m"; end
|
24
|
+
def purple(s) "\033[1;35m#{s}\033[0m"; end
|
25
|
+
def azure(s) "\033[1;36m#{s}\033[0m"; end
|
26
|
+
def white(s) "\033[1;37m#{s}\033[0m"; end
|
27
|
+
|
28
|
+
# colors 64k
|
29
|
+
def orange(s) "\033[38;5;208m#{s}\033[0m"; end
|
30
|
+
|
31
|
+
# i dont undertstand why i need self :/
|
32
|
+
# SELF version because I'm just stupid or lazy or both.
|
33
|
+
# def self.yellow(s) "#{PREPEND_ME}\033[1;33m#{s}\033[0m" ; end
|
34
|
+
# def self.green(s) "#{PREPEND_ME}\033[1;32m#{s}\033[0m" ; end
|
35
|
+
# def self.gray(s) "#{PREPEND_ME}\033[1;30m#{s}\033[0m" ; end
|
36
|
+
# def self.green(s) "#{PREPEND_ME}\033[1;32m#{s}\033[0m" ; end
|
37
|
+
# def self.red(s) "#{PREPEND_ME}\033[1;31m#{s}\033[0m" ; end
|
38
|
+
# def self.blue(s) "#{PREPEND_ME}\033[1;34m#{s}\033[0m" ; end
|
39
|
+
# def self.purple(s) "#{PREPEND_ME}\033[1;35m#{s}\033[0m" ; end
|
40
|
+
# def self.azure(s) "#{PREPEND_ME}\033[1;36m#{s}\033[0m" ; end
|
41
|
+
# def self.white(s) "#{PREPEND_ME}\033[1;37m#{s}\033[0m" ; end
|
42
|
+
|
43
|
+
# p<COLOR> Carlessian functions..
|
44
|
+
def pwhite(s) puts(white(s)); end
|
45
|
+
def pgreen(s) puts(green(s)); end
|
46
|
+
def pred(s) puts(red(s)); end
|
47
|
+
def pyellow(s) puts(yellow(s)); end
|
50
48
|
end
|
51
|
-
#end
|
49
|
+
# end
|
data/lib/storazzo/common.rb
CHANGED
@@ -1,27 +1,90 @@
|
|
1
1
|
# Ric common stuff! :)
|
2
2
|
#
|
3
|
-
#
|
4
3
|
# Usage:
|
5
|
-
# include Storazzo::Common
|
4
|
+
# include Storazzo::Common (def to def)
|
5
|
+
# or
|
6
|
+
# extend Storazzo::Common (def to def self.XX)
|
6
7
|
#
|
8
|
+
=begin
|
9
|
+
Emoji to copy:
|
10
|
+
👍 👎 👌 ✌ 👋 🤝 👏 🤘 🤟 🤙 🤏 🙌 🙏 🖖 🤞 ✋ 🤚 🖐 🖑 🤲 👐 👊 🤛 🤜 🖕
|
11
|
+
👈 👉 👆 👇
|
12
|
+
☺ ☻ 😃 😄 😅 😆 😊 😎 😇 😈 😏 🤣 🤩 🤪 🥳 😁 😀 😂 🤠 🤡 🤑 🤓 🤖 kiss
|
13
|
+
😗 😚 😘 😙 flirting
|
14
|
+
😉 🤗 😍 🥰 🤤 😋 😛 😜 😝 neutral
|
15
|
+
😶 🙃 😐 😑 🤔 🤨 🧐 hush
|
16
|
+
🤭 🤫 😯 🤐 😌 😖 😕 😳 😔 🤥 🥴 shocked
|
17
|
+
😮 😲 🤯 tired
|
18
|
+
😩 😫 🥱 😪 😴 😵 sad
|
19
|
+
☹ 😦 😞 😥 😟 cry
|
20
|
+
😢 😭 sick
|
21
|
+
🤢 🤮 😷 🤒 🤕 🥵 🥶 fear
|
22
|
+
🥺 😬 😓 😰 😨 😱 angry
|
23
|
+
😒 😠 😡 😤 😣 😧 🤬 😸 😹 😺 😻 😼 😽 😾 😿 🙀 🙈 🙉 🙊
|
24
|
+
[see Animal Emoji 🐰] gesture
|
25
|
+
🤦 🤷 🙅 🙆 🙋 🙌 🙍 🙎 🙇 🙏 activity
|
26
|
+
👯 💃 🕺 🤳 💇 💈 💆 🧖 🧘 🧍 🧎 👰 🤰 🤱 faces
|
27
|
+
👶 🧒 👦 👧 👩 👨 🧑 🧔 🧓 👴 👵 👤 👥 👪 👫 👬 👭 👱 👳 👲 🧕 👸 🤴 🎅 🤶 disabled
|
28
|
+
🧏 🦻 🦮 🦯 🦺 🦼 🦽 🦾 🦿 🤵 👮 👷 💁 💂 🕴 🕵 🦸 🦹 🧙 🧚 🧜 🧝 🧞 🧛 🧟 👼 👿 👻 👹 👺 👽 👾 🛸 💀 ☠ 🕱 🧠 🦴 👁 👀 👂 👃 👄 🗢 👅 🦷 🦵 🦶 💭 🗬 🗭 💬 🗨 🗩 🗪 🗫 🗰 🗱 🗮 🗯 🗣 🗤 🗥 🗦 🗧 💦 💧 💢 💫 💤 💨 💥 💪 🗲 🔥 💡 💩 💯 🔟 🔰 🕲
|
29
|
+
=end
|
7
30
|
require_relative 'colors'
|
31
|
+
require 'pry'
|
8
32
|
|
9
|
-
module Storazzo::Common
|
10
|
-
|
11
|
-
include Storazzo::Colors
|
33
|
+
module Storazzo::Common
|
34
|
+
include Storazzo::Colors
|
12
35
|
|
36
|
+
def deb(s)
|
37
|
+
puts "[DEB👀] #{yellow(s)}" if _debug_true # $DEBUG
|
38
|
+
end
|
13
39
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
def err(str)
|
21
|
-
puts "[ERR] #{red(s)}"
|
22
|
-
end
|
23
|
-
def bug(s)
|
24
|
-
puts "[🐛] #{gray s}"
|
40
|
+
# this has a yield
|
41
|
+
def if_deb?()
|
42
|
+
if _debug_true # $DEBUG
|
43
|
+
deb "== yield START =="
|
44
|
+
yield
|
45
|
+
deb "== yield END =="
|
25
46
|
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def warn(s)
|
50
|
+
puts "[W⚠️RN] #{azure(s)}"
|
51
|
+
end
|
52
|
+
|
53
|
+
def err(str)
|
54
|
+
puts "[ERR👎] #{red(s)}" # ⛔
|
55
|
+
end
|
56
|
+
|
57
|
+
def bug(s)
|
58
|
+
puts "[🐛] #{gray s}"
|
59
|
+
end
|
60
|
+
|
61
|
+
def pverbose(is_verbose, str)
|
62
|
+
# puts "[V📚RB💀S📚] #{gray str}"
|
63
|
+
puts "[🦋🐛🐝🐞🐜🕷🕸🦂🦗🦟] #{gray str}" # insects: http://xahlee.info/comp/unicode_insects.html
|
64
|
+
end
|
65
|
+
|
66
|
+
def ppp(complex_object_to_colorize)
|
67
|
+
# TODO i need to learn to return without printing..
|
68
|
+
Pry::ColorPrinter.pp(complex_object_to_colorize)
|
69
|
+
end
|
70
|
+
|
71
|
+
def fatal(s)
|
72
|
+
raise "[F💀TAL] #{red s}"
|
73
|
+
end
|
74
|
+
|
75
|
+
def mac?
|
76
|
+
`uname`.chomp == 'Darwin'
|
77
|
+
end
|
78
|
+
|
79
|
+
def linux?
|
80
|
+
`uname`.chomp == 'Linux'
|
81
|
+
end
|
82
|
+
|
83
|
+
private
|
84
|
+
|
85
|
+
def _debug_true
|
86
|
+
$DEBUG or ENV["DEBUG"] == 'true'
|
87
|
+
end
|
26
88
|
|
27
|
-
|
89
|
+
# puts "[DEBUG ENABLED!]" if _debug_true
|
90
|
+
end
|
data/lib/storazzo/debug.rb
CHANGED
@@ -1,10 +1,7 @@
|
|
1
|
-
|
2
1
|
# idea from https://medium.com/@leo_hetsch/ruby-modules-include-vs-prepend-vs-extend-f09837a5b073
|
3
2
|
module Debug
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
end
|
3
|
+
def log(message)
|
4
|
+
# debug output
|
5
|
+
puts "TODO(ricc): LOG '#{message}' on GCP :)"
|
6
|
+
end
|
7
|
+
end
|
data/lib/storazzo/hashify.rb
CHANGED
@@ -1,46 +1,47 @@
|
|
1
1
|
# copied from https://dev.to/ayushn21/how-to-generate-yaml-from-ruby-objects-without-type-annotations-4fli
|
2
2
|
module Storazzo
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
end
|
10
|
-
|
11
|
-
def to_hash
|
12
|
-
hash = {}
|
13
|
-
excluded_ivars = ivars_excluded_from_hash
|
14
|
-
|
15
|
-
# Iterate over all the instance variables and store their
|
16
|
-
# names and values in a hash
|
17
|
-
instance_variables.each do |var|
|
18
|
-
next if excluded_ivars.include? var.to_s
|
19
|
-
|
20
|
-
value = instance_variable_get(var)
|
21
|
-
value = value.map(&:to_hash) if value.is_a? Array
|
22
|
-
|
23
|
-
hash[var.to_s.delete("@")] = value
|
24
|
-
end
|
25
|
-
|
26
|
-
return hash
|
27
|
-
end
|
28
|
-
|
29
|
-
def obj_to_hash
|
30
|
-
h = {}
|
31
|
-
puts self
|
32
|
-
self.instance_variables.each{|var|
|
33
|
-
#puts var
|
34
|
-
h[var.to_s.delete('@')] = self.instance_variable_get(var) # send(var.to_s.delete('@'))
|
35
|
-
}
|
36
|
-
h
|
37
|
-
end
|
38
|
-
|
39
|
-
def to_yaml
|
40
|
-
to_hash.to_yaml
|
41
|
-
end
|
42
|
-
def obj_to_yaml
|
43
|
-
obj_to_hash.to_yaml
|
44
|
-
end
|
3
|
+
module Hashify
|
4
|
+
# Classes that include this module can exclude certain
|
5
|
+
# instance variable from its hash representation by overriding
|
6
|
+
# this method
|
7
|
+
def ivars_excluded_from_hash
|
8
|
+
['this_doesnt_exist']
|
45
9
|
end
|
46
|
-
|
10
|
+
|
11
|
+
def to_hash
|
12
|
+
hash = {}
|
13
|
+
excluded_ivars = ivars_excluded_from_hash
|
14
|
+
|
15
|
+
# Iterate over all the instance variables and store their
|
16
|
+
# names and values in a hash
|
17
|
+
instance_variables.each do |var|
|
18
|
+
next if excluded_ivars.include? var.to_s
|
19
|
+
|
20
|
+
value = instance_variable_get(var)
|
21
|
+
value = value.map(&:to_hash) if value.is_a? Array
|
22
|
+
|
23
|
+
hash[var.to_s.delete("@")] = value
|
24
|
+
end
|
25
|
+
|
26
|
+
return hash
|
27
|
+
end
|
28
|
+
|
29
|
+
def obj_to_hash
|
30
|
+
h = {}
|
31
|
+
puts self
|
32
|
+
self.instance_variables.each { |var|
|
33
|
+
# puts var
|
34
|
+
h[var.to_s.delete('@')] = self.instance_variable_get(var) # send(var.to_s.delete('@'))
|
35
|
+
}
|
36
|
+
h
|
37
|
+
end
|
38
|
+
|
39
|
+
def to_yaml
|
40
|
+
to_hash.to_yaml
|
41
|
+
end
|
42
|
+
|
43
|
+
def obj_to_yaml
|
44
|
+
obj_to_hash.to_yaml
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
data/lib/storazzo/main.rb
CHANGED
@@ -3,7 +3,6 @@
|
|
3
3
|
# eg from RicDisk.
|
4
4
|
|
5
5
|
module Storazzo
|
6
|
-
|
7
6
|
# This is the Main Class - an entrypoint to call the meravilles hidden therein.
|
8
7
|
#
|
9
8
|
# Example:
|
@@ -13,57 +12,62 @@ module Storazzo
|
|
13
12
|
# Arguments:
|
14
13
|
# message: (String) - optional
|
15
14
|
|
16
|
-
|
17
15
|
class Storazzo::Main # Can be same name as Module: https://stackoverflow.com/questions/13261474/ruby-modules-and-classes-same-name-in-structure
|
18
16
|
require 'storazzo/colors'
|
19
17
|
extend Storazzo::Colors
|
20
18
|
|
21
19
|
# version 1.2
|
22
|
-
def self.say_hi(message=nil)
|
20
|
+
def self.say_hi(message = nil)
|
21
|
+
str = get_hi(message)
|
22
|
+
puts str
|
23
|
+
str
|
24
|
+
end
|
25
|
+
|
26
|
+
# salutation
|
27
|
+
def self.get_hi(message = nil)
|
23
28
|
str = "Hello from Storazzo v#{white Storazzo::version rescue "Error: #{$!}"}!"
|
24
29
|
str += " Message: '#{yellow message.to_s}'" if message
|
25
|
-
|
26
|
-
str
|
30
|
+
str
|
27
31
|
end
|
28
32
|
|
29
|
-
def self.all_mounts(opts={})
|
30
|
-
|
33
|
+
def self.all_mounts(opts = {})
|
34
|
+
opts_verbose = opts.fetch :verbose, true
|
35
|
+
|
36
|
+
self.say_hi "Storazzo::Main.all_mounts(): BEGIN - RicDiskVersion is: #{Storazzo::RicDiskUgly::RICDISK_VERSION}"
|
31
37
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
config
|
36
|
-
|
37
|
-
|
38
|
-
#
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
#sbrodola_ricdisk(StorazzoMod::root + "./var/disks/") rescue "[Storazzo::AllMount] SomeError: #{$!}"
|
47
|
-
self.hi 'Storazzo::Main.all_mounts(): END'
|
38
|
+
pwhite("1. First I load the config in verbose mode..")
|
39
|
+
config = Storazzo::RicDiskConfig.instance
|
40
|
+
config.load
|
41
|
+
# puts config.object_id
|
42
|
+
# puts Storazzo::RicDiskConfig.instance.object_id
|
43
|
+
pwhite "TODO(ricc): show a list of all RicDisk relevant mounts" if opts_verbose
|
44
|
+
# d = Storazzo::RicDisk.new
|
45
|
+
config.iterate_through_file_list_for_disks() # analyze_local_system
|
46
|
+
# sbrodola_ricdisk("/Volumes/")
|
47
|
+
Storazzo::RicDisk.test
|
48
|
+
Storazzo::RicDisk.find_active_dirs
|
49
|
+
# Storazzo::RicDisk.sbrodola_ricdisk StorazzoMod::root + "./var/disks/"
|
50
|
+
# sbrodola_ricdisk(StorazzoMod::root + "./var/disks/") rescue "[Storazzo::AllMount] SomeError: #{$!}"
|
51
|
+
self.hi 'Storazzo::Main.all_mounts(): END'
|
48
52
|
end
|
49
53
|
|
50
|
-
def self.all_tests
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
54
|
+
def self.all_tests
|
55
|
+
# include vs extend: https://stackoverflow.com/questions/15097929/ruby-module-require-and-include
|
56
|
+
# => http://www.railstips.org/blog/archives/2009/05/15/include-vs-extend-in-ruby/
|
57
|
+
# include Storazzo::Colors
|
58
|
+
extend Storazzo::Colors
|
55
59
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
60
|
+
pwhite "All tests BEGIN - todo obsolete this now that I have proper Rake testing suite..."
|
61
|
+
deb "Maybe debug is enabled?"
|
62
|
+
say_hi
|
63
|
+
# This works with EXTEND..
|
64
|
+
puts(yellow "Just YELLOW 0")
|
65
|
+
# This reqwuires a INCLUDE.
|
66
|
+
# puts(Storazzo::Colors.yellow "Test YELLOW 1 self")
|
67
|
+
# puts(Colors.yellow "Test YELLOW 1 self")
|
68
|
+
# puts(Colors.green "Test YELLOW 2 ohne self")
|
69
|
+
pwhite "All tests END"
|
70
|
+
# puts "All tests END"
|
67
71
|
end
|
68
72
|
end
|
69
|
-
end
|
73
|
+
end
|