storazzo 0.4.9 → 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/Gemfile +5 -4
- data/Rakefile +8 -11
- data/VERSION +1 -1
- data/bin/hello-storazzo +0 -1
- data/bin/ricdisk-magic +50 -56
- data/bin/stats-with-md5 +288 -220
- data/lib/storazzo/colors.rb +43 -45
- data/lib/storazzo/common.rb +52 -46
- data/lib/storazzo/debug.rb +5 -8
- data/lib/storazzo/hashify.rb +44 -43
- data/lib/storazzo/main.rb +40 -41
- data/lib/storazzo/media/abstract_ric_disk.rb +162 -151
- data/lib/storazzo/media/gcs_bucket.rb +52 -51
- data/lib/storazzo/media/local_folder.rb +43 -44
- data/lib/storazzo/media/mount_point.rb +8 -9
- data/lib/storazzo/ric_disk.rb +153 -170
- data/lib/storazzo/ric_disk_config.rb +224 -219
- data/lib/storazzo/ric_disk_sample_config.rb +12 -12
- data/lib/storazzo/ric_disk_statsfile.rb +17 -15
- data/lib/storazzo/ric_disk_ugly.rb +35 -38
- data/lib/storazzo/version.rb +7 -7
- data/lib/storazzo.rb +36 -36
- data/storazzo.gemspec +22 -21
- data/test/media/test_abstract_ric_disk.rb +12 -16
- data/test/media/test_gcs_bucket.rb +44 -47
- data/test/media/test_local_folder.rb +134 -136
- data/test/media/test_mount_point.rb +18 -19
- data/test/test_ric_disk.rb +12 -13
- data/test/test_ric_disk_config.rb +20 -24
- data/test/test_ric_disk_stats_file.rb +13 -14
- data/test/test_storazzo.rb +26 -26
- data/var/test/disks/disk02-full/Rakefile +4 -4
- metadata +2 -2
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
@@ -8,7 +8,7 @@
|
|
8
8
|
=begin
|
9
9
|
Emoji to copy:
|
10
10
|
👍 👎 👌 ✌ 👋 🤝 👏 🤘 🤟 🤙 🤏 🙌 🙏 🖖 🤞 ✋ 🤚 🖐 🖑 🤲 👐 👊 🤛 🤜 🖕
|
11
|
-
👈 👉 👆 👇
|
11
|
+
👈 👉 👆 👇
|
12
12
|
☺ ☻ 😃 😄 😅 😆 😊 😎 😇 😈 😏 🤣 🤩 🤪 🥳 😁 😀 😂 🤠 🤡 🤑 🤓 🤖 kiss
|
13
13
|
😗 😚 😘 😙 flirting
|
14
14
|
😉 🤗 😍 🥰 🤤 😋 😛 😜 😝 neutral
|
@@ -30,55 +30,61 @@
|
|
30
30
|
require_relative 'colors'
|
31
31
|
require 'pry'
|
32
32
|
|
33
|
-
module Storazzo::Common
|
33
|
+
module Storazzo::Common
|
34
|
+
include Storazzo::Colors
|
34
35
|
|
35
|
-
|
36
|
+
def deb(s)
|
37
|
+
puts "[DEB👀] #{yellow(s)}" if _debug_true # $DEBUG
|
38
|
+
end
|
36
39
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
if _debug_true # $DEBUG
|
44
|
-
deb "== yield START =="
|
45
|
-
yield
|
46
|
-
deb "== yield END =="
|
47
|
-
end
|
48
|
-
end
|
49
|
-
def warn(s)
|
50
|
-
puts "[W⚠️RN] #{azure(s)}"
|
51
|
-
end
|
52
|
-
def err(str)
|
53
|
-
puts "[ERR👎] #{red(s)}" # ⛔
|
54
|
-
end
|
55
|
-
def bug(s)
|
56
|
-
puts "[🐛] #{gray s}"
|
57
|
-
end
|
58
|
-
def pverbose(is_verbose, str)
|
59
|
-
#puts "[V📚RB💀S📚] #{gray str}"
|
60
|
-
puts "[🦋🐛🐝🐞🐜🕷🕸🦂🦗🦟] #{gray str}" # insects: http://xahlee.info/comp/unicode_insects.html
|
61
|
-
end
|
62
|
-
def ppp(complex_object_to_colorize)
|
63
|
-
# TODO i need to learn to return without printing..
|
64
|
-
Pry::ColorPrinter.pp(complex_object_to_colorize)
|
40
|
+
# this has a yield
|
41
|
+
def if_deb?()
|
42
|
+
if _debug_true # $DEBUG
|
43
|
+
deb "== yield START =="
|
44
|
+
yield
|
45
|
+
deb "== yield END =="
|
65
46
|
end
|
47
|
+
end
|
66
48
|
|
67
|
-
|
68
|
-
|
69
|
-
|
49
|
+
def warn(s)
|
50
|
+
puts "[W⚠️RN] #{azure(s)}"
|
51
|
+
end
|
70
52
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
def linux?
|
75
|
-
`uname`.chomp == 'Linux'
|
76
|
-
end
|
53
|
+
def err(str)
|
54
|
+
puts "[ERR👎] #{red(s)}" # ⛔
|
55
|
+
end
|
77
56
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
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
|
82
88
|
|
83
|
-
# puts "[DEBUG ENABLED!]" if _debug_true
|
84
|
-
end
|
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,62 +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)
|
23
21
|
str = get_hi(message)
|
24
|
-
puts str
|
25
|
-
str
|
22
|
+
puts str
|
23
|
+
str
|
26
24
|
end
|
25
|
+
|
27
26
|
# salutation
|
28
|
-
def self.get_hi(message=nil)
|
27
|
+
def self.get_hi(message = nil)
|
29
28
|
str = "Hello from Storazzo v#{white Storazzo::version rescue "Error: #{$!}"}!"
|
30
29
|
str += " Message: '#{yellow message.to_s}'" if message
|
31
30
|
str
|
32
31
|
end
|
33
32
|
|
34
|
-
def self.all_mounts(opts={})
|
35
|
-
|
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}"
|
36
37
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
config
|
41
|
-
|
42
|
-
|
43
|
-
#
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
#sbrodola_ricdisk(StorazzoMod::root + "./var/disks/") rescue "[Storazzo::AllMount] SomeError: #{$!}"
|
52
|
-
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'
|
53
52
|
end
|
54
53
|
|
55
|
-
def self.all_tests
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
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
|
60
59
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
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"
|
72
71
|
end
|
73
72
|
end
|
74
|
-
end
|
73
|
+
end
|