storazzo 0.3.1 → 0.3.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Makefile +6 -1
- data/VERSION +1 -1
- data/bin/ricdisk-magic +28 -9
- data/lib/storazzo/colors.rb +2 -1
- data/lib/storazzo/common.rb +19 -4
- data/lib/storazzo/hashify.rb +29 -16
- data/lib/storazzo/media/local_folder.rb +6 -6
- data/lib/storazzo/ric_disk.rb +151 -54
- data/lib/storazzo/ric_disk_config.rb +68 -34
- data/lib/storazzo/ric_disk_sample_config.rb +35 -0
- data/lib/storazzo/ric_disk_statsfile.rb +2 -1
- data/lib/storazzo/ric_disk_ugly.rb +1 -1
- data/lib/storazzo/version.rb +5 -0
- data/lib/storazzo.rb +9 -4
- data/test/test_gcs_bucket.rb +37 -5
- data/test/test_local_folder.rb +55 -14
- data/test/test_ric_disk_config.rb +38 -0
- data/test/test_storazzo.rb +9 -9
- metadata +5 -3
- data/lib/storazzo/translator.rb +0 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7af080e9d4d71c7ceb558b4b4cbd1f13345fa3c4dbea5d6060da8fb9d5b21cc0
|
4
|
+
data.tar.gz: fe4fd90e12756dbe535e96f0c7c42834ce44c452839890d381a0e43a78ce926e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f753c4e14018803a731de9cf992dcfcf4f4cac601fb0b978de6d16c83c8ab0f06430e0cdd2a203b025a714f168c08f0e6107606b9b354fcf792e0041be8d727
|
7
|
+
data.tar.gz: 072da4e8a2b24fedd83e1cd04b41f695a38a49e623cef5bd1643a11dfc8813604d32c7950976b6b5500839d2a2580293623ab7b32070d9e162db6a753f2d8d02
|
data/Makefile
CHANGED
@@ -17,6 +17,8 @@ install:
|
|
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
|
21
|
+
gem push ./storazzo-$(VER).gem
|
20
22
|
|
21
23
|
list:
|
22
24
|
gem list -r storazzo
|
@@ -46,4 +48,7 @@ irb-test:
|
|
46
48
|
./irb-test.sh
|
47
49
|
|
48
50
|
watch-test:
|
49
|
-
watch -c make test
|
51
|
+
watch -c make test
|
52
|
+
|
53
|
+
test-gcs-bucket:
|
54
|
+
ruby -I test test/test_gcs_bucket.rb
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.8
|
data/bin/ricdisk-magic
CHANGED
@@ -14,17 +14,18 @@ require 'optparse' # http://ruby.about.com/od/advancedruby/a/optionparser.
|
|
14
14
|
|
15
15
|
# Including local gem.
|
16
16
|
#puts File.expand_path(FileUtils.pwd, "/../")
|
17
|
-
local_gem_path = File.expand_path(FileUtils.pwd, "/../")
|
18
|
-
gem 'storazzo', path: local_gem_path
|
17
|
+
#local_gem_path = File.expand_path(FileUtils.pwd, "/../")
|
18
|
+
#gem 'storazzo', path: local_gem_path
|
19
19
|
require 'storazzo'
|
20
20
|
#include Storazzo
|
21
21
|
#include Storazzo::Colors
|
22
|
+
extend Storazzo::Colors
|
23
|
+
include Storazzo::Common #instead
|
22
24
|
|
23
25
|
|
24
|
-
puts "First I need to figure out how to bring in all the libraries in here.."
|
25
|
-
|
26
|
-
puts Storazzo
|
27
|
-
#exit(0)
|
26
|
+
#puts "First I need to figure out how to bring in all the libraries in here.."
|
27
|
+
#Storazzo::Main.say_hi("ARGV is: #{ ARGV.join ', '}")
|
28
|
+
#puts Storazzo.version
|
28
29
|
############# ############# ############# ############# ############# ############# ############# #############
|
29
30
|
|
30
31
|
|
@@ -40,7 +41,9 @@ if RUBY_VERSION.split('.')[0] == 1
|
|
40
41
|
end
|
41
42
|
|
42
43
|
$PROG_VER = '0.4'
|
43
|
-
$DEBUG = true
|
44
|
+
$DEBUG = ENV['DEBUG'] == 'true' # (true/false)
|
45
|
+
# p ENV['DEBUG']
|
46
|
+
# p $DEBUG
|
44
47
|
|
45
48
|
HISTORY = <<-BIG_LONG_MULTILINE
|
46
49
|
2022-07-13 v0.4 Now that library has stabilized this kind of works! I can just push gem, update amd include here and work quite well :)
|
@@ -67,8 +70,15 @@ $myconf = {
|
|
67
70
|
:app_name => "RicDisk Magic should be sth like #{$0}",
|
68
71
|
:description => "
|
69
72
|
This program is loosely inspired to ricdisk-magic.sh but its much better.
|
70
|
-
|
71
|
-
|
73
|
+
The idea is: iterate through all ARGV elements and build a DB of all files with length and MD5.
|
74
|
+
Then if folder is writeable, put this list INSIDE IT as its so conveniente.
|
75
|
+
If not, put in a ENV-var-defined folder which defaults to ./.storazzo/ :)
|
76
|
+
|
77
|
+
And maybe someday - add a nice protobuf and an entity in lib/.
|
78
|
+
|
79
|
+
Note. This software is part of the Storazzo gem ('sai chi ti saluta un casino?'):
|
80
|
+
|
81
|
+
$ gem install storazzo
|
72
82
|
".strip.gsub(/^\s+/, "").gsub(/\s+$/, ""),
|
73
83
|
# TODO move to some class default
|
74
84
|
:media_dirs => %w{ /media/riccardo/ /Volumes/ /mnt/ ~/git/storazzo/var/test/ /sobenme/giusto/per/imparare/ad/ammutolire/gli/errori/ },
|
@@ -126,6 +136,8 @@ def real_program
|
|
126
136
|
puts "Description: '''#{white $myconf[:description] }'''"
|
127
137
|
|
128
138
|
config = Storazzo::RicDiskConfig.instance()
|
139
|
+
config.load
|
140
|
+
puts "StorazzoConfig: #{config}"
|
129
141
|
#config.load # auto_sbrodola(ARGV)
|
130
142
|
puts yellow("ARGV: #{ARGV}")
|
131
143
|
config.iterate_through_file_list_for_disks(ARGV)
|
@@ -158,8 +170,15 @@ def main(filename)
|
|
158
170
|
deb "HISTORY: #{gray HISTORY}"
|
159
171
|
#deb "To remove this shit, just set $DEBUG=false :)"
|
160
172
|
init # Enable this to have command line parsing capabilities!
|
173
|
+
puts white("$DEBUG is #{$DEBUG }. Tu turn on, call me with -d") unless $DEBUG
|
161
174
|
#warn "[warn] template v#{$TEMPLATE_VER }: proviamo il warn che magari depreca il DEB"
|
162
175
|
real_program
|
176
|
+
|
177
|
+
if ($DEBUG)
|
178
|
+
puts "First I need to figure out how to bring in all the libraries in here.."
|
179
|
+
Storazzo::Main.say_hi("ARGV is: #{ ARGV.join ', '}")
|
180
|
+
puts Storazzo.version
|
181
|
+
end
|
163
182
|
end
|
164
183
|
|
165
184
|
main(__FILE__)
|
data/lib/storazzo/colors.rb
CHANGED
@@ -13,7 +13,8 @@ module Storazzo::Colors
|
|
13
13
|
|
14
14
|
PREPEND_ME = "[Storazzo::Colors] "
|
15
15
|
|
16
|
-
|
16
|
+
|
17
|
+
def deb2(s); puts "#DEB_OBSOLETE #{gray(s)} [include Storazzo::Common instead]" if $DEBUG; end # Use the Common instead
|
17
18
|
|
18
19
|
# colors 16
|
19
20
|
def yellow(s) "\033[1;33m#{s}\033[0m" ; end
|
data/lib/storazzo/common.rb
CHANGED
@@ -1,12 +1,27 @@
|
|
1
1
|
# Ric common stuff! :)
|
2
|
-
|
2
|
+
#
|
3
|
+
#
|
4
|
+
# Usage:
|
5
|
+
# include Storazzo::Common
|
6
|
+
#
|
7
|
+
require_relative 'colors'
|
3
8
|
|
4
9
|
module Storazzo::Common
|
5
10
|
|
11
|
+
include Storazzo::Colors
|
6
12
|
|
7
|
-
def deb(str)
|
8
|
-
puts "[DEB] #{str}"
|
9
|
-
end
|
10
13
|
|
14
|
+
def deb(s)
|
15
|
+
puts "[DEB] #{yellow(s)}" if $DEBUG
|
16
|
+
end
|
17
|
+
def warn(s)
|
18
|
+
puts "[WRN] #{azure(s)}"
|
19
|
+
end
|
20
|
+
def err(str)
|
21
|
+
puts "[ERR] #{red(s)}"
|
22
|
+
end
|
23
|
+
def bug(s)
|
24
|
+
puts "[🐛] #{gray s}"
|
25
|
+
end
|
11
26
|
|
12
27
|
end
|
data/lib/storazzo/hashify.rb
CHANGED
@@ -5,29 +5,42 @@ module Storazzo
|
|
5
5
|
# instance variable from its hash representation by overriding
|
6
6
|
# this method
|
7
7
|
def ivars_excluded_from_hash
|
8
|
-
|
8
|
+
[ 'this_doesnt_exist' ]
|
9
9
|
end
|
10
10
|
|
11
11
|
def to_hash
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
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
|
24
27
|
end
|
25
|
-
|
26
|
-
|
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
|
27
37
|
end
|
28
38
|
|
29
39
|
def to_yaml
|
30
|
-
|
40
|
+
to_hash.to_yaml
|
41
|
+
end
|
42
|
+
def obj_to_yaml
|
43
|
+
obj_to_hash.to_yaml
|
31
44
|
end
|
32
45
|
end
|
33
46
|
end
|
@@ -13,7 +13,8 @@ module Storazzo::Media
|
|
13
13
|
raise "Sorry local mount doesnt exist!" unless File.exist?(@local_mountpoint)
|
14
14
|
@wr = File.writable?(stats_filename_default_fullpath) # .writeable? stats_file_smart_fullpath
|
15
15
|
|
16
|
-
super.initialize(local_mount) rescue "SUPER_ERROR: #{$!}"
|
16
|
+
#super.initialize(local_mount) rescue "SUPER_ERROR: #{$!}"
|
17
|
+
super(local_mount) rescue "SUPER_ERROR: #{$!}"
|
17
18
|
end
|
18
19
|
|
19
20
|
def self.list_all
|
@@ -40,11 +41,10 @@ module Storazzo::Media
|
|
40
41
|
File.writable?(@local_mountpoint)
|
41
42
|
end
|
42
43
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
# end
|
44
|
+
def default_stats_filename
|
45
|
+
#'42'
|
46
|
+
Storazzo::RicDiskStatsFile.default_name
|
47
|
+
end
|
48
48
|
|
49
49
|
end
|
50
50
|
|
data/lib/storazzo/ric_disk.rb
CHANGED
@@ -1,27 +1,39 @@
|
|
1
1
|
# A RicDisk wraps a local mount/disk/folder
|
2
2
|
# it's considered interesting if there's a ".ricdisk/.ricdisk"
|
3
3
|
|
4
|
+
require 'digest'
|
5
|
+
|
4
6
|
module Storazzo
|
5
7
|
class Storazzo::RicDisk
|
6
8
|
|
7
9
|
include Hashify
|
10
|
+
include Storazzo::Common
|
8
11
|
extend Storazzo::Colors
|
12
|
+
require 'socket'
|
9
13
|
|
10
14
|
|
11
15
|
## Instance variables
|
12
16
|
|
13
17
|
# in order of finding, so the first will be the one we actually READ and use. I could looknat the date but cmon...
|
14
|
-
|
15
|
-
|
16
|
-
|
18
|
+
# These are the files I do accept.
|
19
|
+
ConfigFiles = %W{ ricdisk.yaml .ricdisk storazzo.yaml }
|
20
|
+
DefaultConfigFile = "storazzo.yaml" # .ricdisk }
|
21
|
+
RicdiskVersion = '2.1'
|
22
|
+
RicdiskHistory = [
|
23
|
+
'2022-07-29 2.1 Added timestamp',
|
24
|
+
'2022-07-28 2.0 Added tags, siz, unique_hash, cmputation_hostname, wr, ...',
|
25
|
+
]
|
26
|
+
DefaultGemfileTestDiskFolder = Storazzo.root + "/var/test/disks/" # was: @@default_gemfile_test_disks_folder
|
17
27
|
# Immutable
|
18
|
-
|
28
|
+
DefaultMediaFolders = %w{
|
19
29
|
/Volumes/
|
20
30
|
/mnt/
|
21
|
-
}.append(
|
31
|
+
}.append(DefaultGemfileTestDiskFolder ).append("/media/#{ENV["USER"]}/" )
|
22
32
|
|
23
33
|
# # todo substitute with protobuf..
|
24
|
-
attr_accessor :name, :description, :ricdisk_file, :local_mountpoint, :wr, :path,
|
34
|
+
attr_accessor :name, :description, :ricdisk_file, :ricdisk_file_full, :local_mountpoint, :wr, :path,
|
35
|
+
:ricdisk_file_empty, :size, :active_dirs, :ricdisk_version,
|
36
|
+
:unique_hash # new 202207
|
25
37
|
|
26
38
|
|
27
39
|
################################
|
@@ -30,36 +42,44 @@ module Storazzo
|
|
30
42
|
|
31
43
|
|
32
44
|
def initialize(path, opts={})
|
33
|
-
|
34
|
-
@local_mountpoint = path
|
35
|
-
@description = "This is an automated RicDisk description from v.#{
|
36
|
-
@ricdisk_version =
|
37
|
-
|
38
|
-
@
|
39
|
-
@ricdisk_file_empty = ricdisk_file_empty?
|
45
|
+
deb "RicDisk initialize.. path=#{path}"
|
46
|
+
@local_mountpoint = File.expand_path(path)
|
47
|
+
@description = "This is an automated RicDisk description from v.#{RicdiskVersion}. Created on #{Time.now}'"
|
48
|
+
@ricdisk_version = RicdiskVersion
|
49
|
+
@ricdisk_file = compute_ricdisk_file() # Storazzo::RicDisk.get_ricdisk_file(path)
|
50
|
+
@ricdisk_file_full = "#{@local_mountpoint}/#{@ricdisk_file}"
|
40
51
|
@label = path.split("/").last
|
41
52
|
@name = path.split("/").last
|
42
53
|
#@wr = File.writable?("#{path}/#{ricdisk_file}" ) # .writeable?
|
54
|
+
#@wr = writeable?
|
43
55
|
@tags = ['ricdisk', 'storazzo']
|
44
56
|
@size = `du -s '#{path}'`.split(/\s/)[0] # self.size
|
45
|
-
|
57
|
+
@unique_hash = "MD5::" + Digest::MD5.hexdigest(File.expand_path(path)) # hash = Digest::MD5.hexdigest(File.expand_path(get_local_mountpoint))
|
58
|
+
@computation_hostname = Socket.gethostname
|
59
|
+
@created_at = Time.now
|
60
|
+
|
61
|
+
@ricdisk_file_empty = ricdisk_file_empty?
|
62
|
+
|
46
63
|
# @config = RicDiskConfig.instance.get_config
|
47
64
|
# #puts @config if @config
|
48
65
|
# find_info_from_mount(path)
|
66
|
+
deb "RicDisk initialize. to_s: #{self}"
|
49
67
|
# find_info_from_df()
|
50
68
|
end
|
51
69
|
|
52
70
|
def ricdisk_file_empty?()
|
53
|
-
File.empty?(
|
71
|
+
# File.empty?("#{local_mountpoint}/.ricdisk.yaml")
|
72
|
+
puts "compute_ricdisk_file: #{compute_ricdisk_file}"
|
73
|
+
File.empty?(compute_ricdisk_file.to_s) # was (get_ricdisk_file)
|
54
74
|
end
|
55
75
|
|
56
76
|
def ok_dir?
|
57
|
-
not
|
77
|
+
not ricdisk_file.nil?
|
58
78
|
end
|
59
79
|
|
60
80
|
|
61
81
|
def analyze_local_system()
|
62
|
-
puts
|
82
|
+
puts "TODO This should analyzze the WHOLE system. TODO(ricc): move to another object which has to do with the system/computer."
|
63
83
|
puts "1. Interesting Mounts: #{green interesting_mount_points}"
|
64
84
|
puts "2. Sbrodoling everything: :TODO"
|
65
85
|
# find_info_from_mount(path)
|
@@ -71,7 +91,7 @@ module Storazzo
|
|
71
91
|
end
|
72
92
|
|
73
93
|
def to_s
|
74
|
-
"RicDisk(paz=#{path},
|
94
|
+
"RicDisk(paz=#{path}, r/w=#{writeable?}, size=#{size}B, f=#{ricdisk_file}, v#{ricdisk_version})"
|
75
95
|
end
|
76
96
|
|
77
97
|
# could take long..
|
@@ -80,7 +100,15 @@ module Storazzo
|
|
80
100
|
# end
|
81
101
|
|
82
102
|
def writeable?()
|
83
|
-
|
103
|
+
return @wr unless @wr.nil?
|
104
|
+
# Otherwise I can do an EXPENSIVE calculation
|
105
|
+
puts yellow("TODO(ricc): Do expensive calculation if this FS is writeable: #{path}")
|
106
|
+
#@wr = File.writable?(File.expand_path(@ricdisk_file)) # rescue false
|
107
|
+
raise "for some reason an important info (ricdisk_file='#{absolute_path}') is missing!" if ricdisk_file.nil?
|
108
|
+
@wr = File.writable?(absolute_path) # rescue false
|
109
|
+
return @wr
|
110
|
+
#:boh_todo_fix_me_and_compute
|
111
|
+
#false
|
84
112
|
end
|
85
113
|
|
86
114
|
################################
|
@@ -90,20 +118,21 @@ module Storazzo
|
|
90
118
|
|
91
119
|
# All places where to find for something :)
|
92
120
|
def self.default_media_folders
|
93
|
-
DEFAULT_MEDIA_FOLDERS
|
121
|
+
DefaultMediaFolders # was DEFAULT_MEDIA_FOLDERS
|
94
122
|
end
|
95
123
|
|
96
124
|
|
97
125
|
def self.test # _localgem_disks
|
98
|
-
d = RicDisk.new(
|
126
|
+
d = RicDisk.new( DefaultGemfileTestDiskFolder)
|
99
127
|
puts (d)
|
100
128
|
puts "do something with it: #{d}"
|
101
129
|
#d.find_active_dirs()
|
102
130
|
end
|
103
131
|
|
104
|
-
|
105
|
-
|
106
|
-
|
132
|
+
def absolute_path
|
133
|
+
#@local_mountpoint + "/" + @ricdisk_file
|
134
|
+
"#{local_mountpoint}/#{ricdisk_file}"
|
135
|
+
end
|
107
136
|
|
108
137
|
def self.find_active_dirs(base_dirs=nil, also_mountpoints=true)
|
109
138
|
if base_dirs.nil?
|
@@ -139,15 +168,53 @@ module Storazzo
|
|
139
168
|
end
|
140
169
|
end
|
141
170
|
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
171
|
+
def compute_ricdisk_file()
|
172
|
+
unless @ricdisk_file.nil?
|
173
|
+
deb "[CACHE HIT] ricdisk_file (didnt have to recompute it - yay!)"
|
174
|
+
return @ricdisk_file
|
175
|
+
end
|
176
|
+
warn "RICC_WARNING This requires cmputation I wanna do it almost once"
|
177
|
+
ConfigFiles.each do |papable_config_filename|
|
178
|
+
#return ".ricdisk.yaml" if File.exist?("#{path}/.ricdisk.yaml") #and File.empty?( "#{path}/.ricdisk.yaml")
|
179
|
+
#return ".ricdisk" if File.exist?("#{path}/.ricdisk") # and File.empty?( "#{path}/.ricdisk")
|
180
|
+
return papable_config_filename if File.exist?("#{path}/#{papable_config_filename}") # and File.empty?( "#{path}/.ricdisk")
|
181
|
+
end
|
182
|
+
deb "File not found! Neither #{ConfigFiles} exist.."
|
183
|
+
# return nil
|
184
|
+
return DefaultConfigFile
|
149
185
|
end
|
150
186
|
|
187
|
+
|
188
|
+
# def self.compute_ricdisk_file_by_path_once(path)
|
189
|
+
# # unless @ricdisk_file.nil?
|
190
|
+
# # deb "[CACHE HIT] ricdisk_file (didnt have to recompute it - yay!)"
|
191
|
+
# # return @ricdisk_file
|
192
|
+
# # end
|
193
|
+
# warn "RICC_WARNING This requires cmputation I wanna do it almost once"
|
194
|
+
# ConfigFiles.each do |papable_config_filename|
|
195
|
+
# #return ".ricdisk.yaml" if File.exist?("#{path}/.ricdisk.yaml") #and File.empty?( "#{path}/.ricdisk.yaml")
|
196
|
+
# #return ".ricdisk" if File.exist?("#{path}/.ricdisk") # and File.empty?( "#{path}/.ricdisk")
|
197
|
+
# return papable_config_filename if File.exist?("#{path}/#{papable_config_filename}") # and File.empty?( "#{path}/.ricdisk")
|
198
|
+
# end
|
199
|
+
# return nil
|
200
|
+
# end
|
201
|
+
|
202
|
+
|
203
|
+
# # new
|
204
|
+
# def self.get_ricdisk_file_obsolete(path)
|
205
|
+
# if @ricdisk_file
|
206
|
+
# puts "[CACHE HIT] ricdisk_file"
|
207
|
+
# return @ricdisk_file
|
208
|
+
# end
|
209
|
+
# puts "RICC_WARNING This requires cmputation I wanna do it almost once"
|
210
|
+
# ConfigFiles.each do |papable_config_filename|
|
211
|
+
# #return ".ricdisk.yaml" if File.exist?("#{path}/.ricdisk.yaml") #and File.empty?( "#{path}/.ricdisk.yaml")
|
212
|
+
# #return ".ricdisk" if File.exist?("#{path}/.ricdisk") # and File.empty?( "#{path}/.ricdisk")
|
213
|
+
# return papable_config_filename if File.exist?("#{path}/#{papable_config_filename}") # and File.empty?( "#{path}/.ricdisk")
|
214
|
+
# end
|
215
|
+
# return nil
|
216
|
+
# end
|
217
|
+
|
151
218
|
|
152
219
|
def self.interesting_mount_points(opts={})
|
153
220
|
#https://unix.stackexchange.com/questions/177014/showing-only-interesting-mount-points-filtering-non-interesting-types
|
@@ -167,48 +234,78 @@ module Storazzo
|
|
167
234
|
|
168
235
|
|
169
236
|
# FORMER SBRODOLA, now write_config_yaml_to_disk
|
170
|
-
def self.write_config_yaml_to_disk(subdir) # sbrodola_ricdisk(subdir)
|
237
|
+
#def self.write_config_yaml_to_disk(subdir, opts={}) # sbrodola_ricdisk(subdir)
|
238
|
+
def write_config_yaml_to_disk(subdir, opts={}) # sbrodola_ricdisk(subdir)
|
171
239
|
# given a path, if .ricdisk exists i do stuff with it..
|
172
240
|
disk_info = nil
|
173
|
-
unless self.ok_dir?(subdir)
|
174
|
-
puts("Nothing for me here: '#{subdir}'. Existing")
|
241
|
+
unless ok_dir? # self.ok_dir?(subdir)
|
242
|
+
puts("[write_config_yaml_to_disk] Nothing for me here: '#{subdir}'. Existing")
|
175
243
|
return
|
176
244
|
end
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
deb("Interesting2. Empty file! TODO write YAML with it.")
|
183
|
-
disk_info = RicDisk.new(subdir, '.ricdisk.yaml')
|
184
|
-
puts(yellow disk_info.to_yaml)
|
245
|
+
ConfigFiles.each do |papable_configfile_name|
|
246
|
+
if File.exists?( "#{subdir}/#{papable_configfile_name}") and File.empty?( "#{subdir}/#{papable_configfile_name}")
|
247
|
+
deb("Interesting. Empty file '#{papable_configfile_name}'! Now I write YAML with it.")
|
248
|
+
disk_info = RicDisk.new(subdir, papable_configfile_name)
|
249
|
+
end
|
185
250
|
end
|
186
|
-
if
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
251
|
+
# if File.exists?( "#{subdir}/.ricdisk") and File.empty?( "#{subdir}/.ricdisk")
|
252
|
+
# deb("Interesting1. Empty file! Now I write YAML with it.")
|
253
|
+
# disk_info = RicDisk.new(subdir, '.ricdisk')
|
254
|
+
# end
|
255
|
+
# if File.exists?( "#{subdir}/.ricdisk.yaml") and File.empty?( "#{subdir}/.ricdisk.yaml")
|
256
|
+
# deb("Interesting2. Empty file! TODO write YAML with it.")
|
257
|
+
# disk_info = RicDisk.new(subdir, '.ricdisk.yaml')
|
258
|
+
# puts(yellow disk_info.to_yaml)
|
259
|
+
# end
|
260
|
+
if disk_info.is_a?(RicDisk)
|
261
|
+
puts yellow("DEB disk_info.class: #{disk_info.class}")
|
262
|
+
if File.empty?(disk_info.absolute_path) # and (disk_info.wr)
|
263
|
+
puts(green("yay, we can now write the file '#{disk_info.absolute_path}' (which is R/W, I just checked!) with proper YAML content.."))
|
264
|
+
if disk_info.wr
|
265
|
+
ret = File.write(disk_info.absolute_path, disk_info.obj_to_yaml)
|
266
|
+
puts green("Written file! ret=#{ret}")
|
267
|
+
else
|
268
|
+
raise "TODO_IMPLEMENT: write in proper place in config dir"
|
269
|
+
puts red("TODO implement me")
|
270
|
+
end
|
191
271
|
else
|
192
|
-
puts(red("
|
193
|
-
puts("File size: #{File.size(disk_info.
|
272
|
+
puts(red("Something not right here: either file is NOT empty or disk is NOT writeable.. #{File.empty?(disk_info.absolute_path)}"))
|
273
|
+
puts("File size: #{File.size(disk_info.absolute_path)}")
|
274
|
+
puts(disk_info.to_s)
|
275
|
+
puts(disk_info.obj_to_hash)
|
276
|
+
puts(disk_info.obj_to_yaml)
|
194
277
|
end
|
278
|
+
else # not a RicDisk..
|
279
|
+
puts "[write_config_yaml_to_disk] No DiskInfo found across #{ConfigFiles}. I leave this function empty-handed."
|
195
280
|
end
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
281
|
+
|
282
|
+
#disk_info.absolute_path
|
283
|
+
#if File.exists?( "#{subdir}/.ricdisk") and ! File.empty?( "#{subdir}/.ricdisk")
|
284
|
+
# if File.exists?(disk_info.absolute_path) and ! File.empty?(disk_info.absolute_path)
|
285
|
+
# puts("Config File found with old-style name: '#{subdir}/.ricdisk' ! Please move it to .ricdisk.yaml!")
|
286
|
+
# puts(white `cat "#{disk_info.absolute_path}"`)
|
287
|
+
# else
|
288
|
+
# puts "WRITING NOW. [I BELIEVE THIS IS DUPE CODE - see a few lines above!] disk_info.obj_to_yaml .. to #{compute_ricdisk_file}"
|
289
|
+
# File.open(ricdisk_file_full, 'w').write(disk_info.obj_to_yaml)
|
290
|
+
# end
|
200
291
|
end
|
201
292
|
|
202
293
|
# TODO obsolete this as i should NOT be calling it from clas, but from method.
|
203
294
|
def self.ok_dir?(subdir)
|
204
295
|
File.exists?( "#{subdir}/.ricdisk") or File.exists?( "#{subdir}/.ricdisk.yaml")
|
205
296
|
end
|
297
|
+
|
298
|
+
def compute_stats_files(opts={})
|
299
|
+
puts azure("TODO implement natively. Now I'm being lazy")
|
300
|
+
Storazzo::RicDisk.calculate_stats_files(path, opts)
|
301
|
+
end
|
206
302
|
|
207
303
|
|
208
304
|
|
209
305
|
# Create RDS file.
|
210
306
|
def self.calculate_stats_files(dir, opts={})
|
211
|
-
opts_upload_to_gcs = opts.fetch :upload_to_gcs, true
|
307
|
+
opts_upload_to_gcs = opts.fetch :upload_to_gcs, true
|
308
|
+
|
212
309
|
full_file_path = "#{dir}/#{$stats_file}"
|
213
310
|
return "This refacgtor is for another day"
|
214
311
|
|
@@ -12,33 +12,43 @@ require 'yaml'
|
|
12
12
|
=end
|
13
13
|
|
14
14
|
module Storazzo
|
15
|
-
class Storazzo::
|
15
|
+
# class Storazzo::Blah
|
16
|
+
# end
|
17
|
+
|
18
|
+
class Storazzo::RicDiskConfig
|
16
19
|
include Singleton
|
17
20
|
include Storazzo::Common
|
18
21
|
include Storazzo::Colors
|
19
22
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
"
|
23
|
+
#@@default_config_location = "~/.storazzo.yaml"
|
24
|
+
DefaultConfigLocation = File.expand_path "~/.storazzo.yaml"
|
25
|
+
# @@default_config_locations = [
|
26
|
+
# "~/.storazzo.yaml" , # HOME
|
27
|
+
# "./.storazzo.yaml" , # LOCAL DIR
|
28
|
+
# ]
|
29
|
+
DefaultConfigLocations = [
|
30
|
+
File.expand_path("~/.storazzo.yaml") , # HOME
|
31
|
+
File.expand_path("./.storazzo.yaml") , # LOCAL DIR
|
28
32
|
]
|
29
|
-
|
33
|
+
#@@default_gem_location_for_tests
|
34
|
+
DefaultGemLocationForTests = File.expand_path('../../../', __FILE__) + "/etc/storazzo_config.sample.yaml"
|
30
35
|
|
31
|
-
attr_accessor :config, :config_file
|
36
|
+
attr_accessor :config, :config_file, :load_called
|
32
37
|
|
33
38
|
public
|
34
39
|
# Load from the first valid config.
|
35
40
|
def load(config_path=nil, opts={})
|
36
41
|
verbose = opts.fetch :verbose, false
|
37
42
|
|
43
|
+
if already_loaded? # and not self.config.nil?
|
44
|
+
puts "[#{self.class}] VERBOSE load: already loaded" if verbose
|
45
|
+
return self.config
|
46
|
+
end
|
47
|
+
|
38
48
|
puts "[VERBOSE] Storazzo::RicDiskConfig.load(): BEGIN " if verbose
|
39
49
|
# trying default location
|
40
|
-
raise "
|
41
|
-
possible_locations =
|
50
|
+
raise "DefaultConfigLocation is not a string" unless DefaultConfigLocation.is_a?(String)
|
51
|
+
possible_locations = DefaultConfigLocations # [ @@default_config_location , "./.storazzo.yaml"]
|
42
52
|
puts "DEB possible_locations: #{possible_locations}"
|
43
53
|
if config_path.is_a?(String)
|
44
54
|
#possible_locations = [config_path] + possible_locations # .append()
|
@@ -47,12 +57,12 @@ public
|
|
47
57
|
puts "[LOAD] possible_locations: #{possible_locations}" if verbose
|
48
58
|
end
|
49
59
|
puts "[VERBOSE] Searching these paths in order: #{possible_locations}" if verbose
|
50
|
-
|
60
|
+
bug "This is not always an array of sTRINGS."
|
51
61
|
raise "possible_locations is not an array" unless possible_locations.is_a?(Array)
|
52
62
|
possible_locations.each do |possible_path|
|
53
63
|
# ASSERT is a string
|
54
64
|
raise "possible_path is not a string" unless possible_path.is_a?(String)
|
55
|
-
|
65
|
+
deb "before buggy expand_path paz: '#{possible_path}''"
|
56
66
|
paz = File.expand_path(possible_path) rescue possible_path
|
57
67
|
raise "Not a string: #{paz}" unless paz.is_a?(String)
|
58
68
|
if File.exists?(paz)
|
@@ -67,35 +77,43 @@ public
|
|
67
77
|
#pp @config if verbose
|
68
78
|
config_ver = @config["apiVersion"]
|
69
79
|
#puts @config[:ConfigVersion]
|
70
|
-
|
71
|
-
puts "RicDiskConfig.to_s: #{self}" if verbose
|
80
|
+
deb("OK. Storazzo::RicDiskConfig v'#{config_ver}' parsed correctly")
|
81
|
+
#puts "[VERBOSE] RicDiskConfig.to_s: #{self}" if verbose
|
82
|
+
@load_called = true
|
72
83
|
return self.config
|
73
84
|
end
|
74
85
|
end
|
86
|
+
@load_called = true
|
75
87
|
# only get here if nothing is found
|
76
88
|
raise "No config found across these locations: #{possible_locations}. Consider copying and editing: #{RicDiskConfig.gem_default_config_path}"
|
77
|
-
# @config = 42
|
78
|
-
# puts "[VERBOSE] Storazzo::RicDiskConfig.load(): END " if verbose
|
79
89
|
end
|
80
90
|
|
91
|
+
# Obsolete, call another class instead.
|
81
92
|
def load_sample_version
|
82
|
-
|
83
|
-
|
93
|
+
# puts("Warning! We're destroying the world here. We're taking a Singletong and changing the way it behaves by moving the config file by under her feet. Don't be mad at me if this misbehaves. You saw it coming, my friends. This is why I would NEVER hire you as a Software Developer in my Company.")
|
94
|
+
raise "DEPRECATED! USE SampleRicDiskConfig.load() instead!"
|
95
|
+
# load(DefaultGemLocationForTests, :verbose => true )
|
84
96
|
end
|
85
97
|
|
86
98
|
def config_ver
|
87
|
-
@config
|
99
|
+
raise "I cant compute Version since I cant compute @config. Are you sure you didnt instance this Singleton without calling load?" if @config.nil?
|
100
|
+
@config['apiVersion'] # rescue :StillUnknown
|
88
101
|
#config['ConfigVersion']
|
89
102
|
end
|
90
103
|
def config_default_folder
|
91
104
|
#self.
|
92
105
|
@config['Config']['DefaultFolder'] #rescue "Unknown config_default_folder: #{$!}"
|
93
106
|
end
|
107
|
+
def already_loaded?
|
108
|
+
#return
|
109
|
+
load_called == true
|
110
|
+
end
|
94
111
|
|
95
112
|
def to_s
|
96
|
-
size =
|
113
|
+
size = File.size(@config_file) rescue -1
|
97
114
|
#puts yellow "DEB: #{@config["apiVersion"]}"
|
98
|
-
"RicDiskConfig(ver=#{config_ver}, file=#{config_file}), #{white(size)} bytes" # - config_default_folder=#{self.config_default_folder}"
|
115
|
+
#"RicDiskConfig(ver=#{config_ver}, file=#{config_file}), #{white(size)} bytes" # - config_default_folder=#{self.config_default_folder}"
|
116
|
+
"POLY_#{self.class}_(ver=#{config_ver}, file=#{config_file}), #{white(size)} bytes" # - config_default_folder=#{self.config_default_folder}"
|
99
117
|
end
|
100
118
|
|
101
119
|
def get_config(opts={})
|
@@ -131,7 +149,8 @@ public
|
|
131
149
|
end
|
132
150
|
|
133
151
|
# UGLY CODE, copipasted from binary for ARGV, ex autosbrodola
|
134
|
-
def iterate_through_file_list_for_disks(files_list=[])
|
152
|
+
def iterate_through_file_list_for_disks(files_list=[], opts={})
|
153
|
+
verbose = opts.fetch :verbose, true
|
135
154
|
# I decided i wont accept an emopty list, this is not how you use the gem, you lazy XXX!
|
136
155
|
# if files_list == [] # or files_list.nil? # empty -> ALL
|
137
156
|
# deb "iterate_through_file_list_for_disks(): no args provided"
|
@@ -142,24 +161,39 @@ public
|
|
142
161
|
# RicDisk.calculate_stats_files(dir) # dir is inutile
|
143
162
|
# } # TODO refactor in option sbrodola_afterwards=true. :)
|
144
163
|
# else
|
145
|
-
|
146
|
-
|
164
|
+
raise "Wrong input: #{files_list} " unless files_list.is_a?(Array)
|
165
|
+
|
166
|
+
puts "iterate_through_file_list_for_disks(): I consider files_list as a list of directories to parse :)" if verbose
|
167
|
+
|
168
|
+
#dirs = RicDisk.find_active_dirs()
|
147
169
|
files_list.each do |dir|
|
148
170
|
dir = File.expand_path(dir)
|
149
|
-
if
|
150
|
-
|
151
|
-
|
152
|
-
RicDisk.
|
171
|
+
if File.directory?(dir)
|
172
|
+
#if dirs.include?(dir)
|
173
|
+
puts "iterate_through_file_list_for_disks() Legit dir: #{green dir}" if verbose
|
174
|
+
rd = RicDisk.new(dir)
|
175
|
+
rd.write_config_yaml_to_disk(dir)
|
176
|
+
#RicDisk.write_config_yaml_to_disk(dir)
|
177
|
+
#RicDisk.calculate_stats_files (CLASS) => will become OBJECT compute_stats_files
|
178
|
+
rd.compute_stats_files() # dir is inutile # TODO
|
153
179
|
else
|
154
|
-
deb "
|
180
|
+
deb red("Doesnt seem a legit dir to me: #{dir}")
|
181
|
+
# deb "Figghiu ri buttana: doesnt exist #{red dir}"
|
155
182
|
end
|
156
183
|
end
|
157
184
|
#end
|
158
185
|
end #/iterate_through_file_list_for_disks
|
186
|
+
|
187
|
+
def config_hash
|
188
|
+
config['Config']
|
189
|
+
end
|
159
190
|
|
160
191
|
|
161
192
|
def self.get_config
|
193
|
+
self.instance.load unless self.instance.load_called
|
162
194
|
self.instance.get_config
|
163
195
|
end
|
164
|
-
end
|
165
|
-
|
196
|
+
end # class Storazzo::RicDiskConfig
|
197
|
+
|
198
|
+
end # module Storazzo
|
199
|
+
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'singleton'
|
2
|
+
require 'yaml'
|
3
|
+
|
4
|
+
require_relative "./common"
|
5
|
+
require_relative "./ric_disk_config"
|
6
|
+
|
7
|
+
=begin
|
8
|
+
This is a singleton class. You call me this way..
|
9
|
+
You call me with:
|
10
|
+
|
11
|
+
Storazzo::RicDiskSampleConfig.instance()
|
12
|
+
|
13
|
+
=end
|
14
|
+
|
15
|
+
module Storazzo
|
16
|
+
|
17
|
+
class Storazzo::RicDiskSampleConfig < Storazzo::RicDiskConfig
|
18
|
+
#include Storazzo::Common
|
19
|
+
|
20
|
+
#include Singleton
|
21
|
+
|
22
|
+
public
|
23
|
+
def load # _sample_version
|
24
|
+
deb("[RicDiskSampleConfig] Wheew 1! We're NOT destroying the world here. We're actually instancing a second Singleton which is a child of the mother, and this time doing things nicely and Rubily.")
|
25
|
+
# super.load DefaultGemLocationForTests #super.load(DefaultGemLocationForTests, :verbose => true )
|
26
|
+
super(DefaultGemLocationForTests, :verbose => false )
|
27
|
+
end
|
28
|
+
def load_sample_version
|
29
|
+
puts white("[RicDiskSampleConfig] Wheew 2! We're NOT destroying the world here. We're actually instancing a second Singleton which is a child of the mother, and this time doing things nicely and Rubily.")
|
30
|
+
super(DefaultGemLocationForTests, :verbose => false )
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
end # module Storazzo
|
35
|
+
|
data/lib/storazzo/version.rb
CHANGED
data/lib/storazzo.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
# Inspired from https://guides.rubygems.org/make-your-own-gem/#introduction
|
2
2
|
|
3
|
-
|
4
3
|
module Storazzo
|
5
4
|
#VERSION = File.read('./VERSION').chomp # "10.0.0"
|
6
5
|
#require 'storazzo/translator'
|
@@ -23,11 +22,16 @@ module Storazzo
|
|
23
22
|
def self.VERSION
|
24
23
|
version
|
25
24
|
end
|
25
|
+
|
26
|
+
def self.storazzo_classes
|
27
|
+
[42, 43]
|
28
|
+
end
|
26
29
|
end
|
27
30
|
|
28
31
|
# nice to paste nice output
|
29
32
|
require 'pp'
|
30
33
|
|
34
|
+
require 'storazzo'
|
31
35
|
require 'storazzo/common'
|
32
36
|
require 'storazzo/colors'
|
33
37
|
require 'storazzo/hashify'
|
@@ -37,10 +41,11 @@ require 'storazzo/media/abstract_ric_disk'
|
|
37
41
|
require 'storazzo/media/gcs_bucket'
|
38
42
|
require 'storazzo/media/local_folder'
|
39
43
|
require 'storazzo/ric_disk_ugly' # OLD and 90% working
|
40
|
-
require 'storazzo/ric_disk_config'
|
44
|
+
require 'storazzo/ric_disk_config' # => RicDiskConfif
|
45
|
+
require 'storazzo/ric_disk_sample_config' # => NOTHING!!
|
46
|
+
#require 'storazzo/ric_disk_config_example' # => NEW!!!
|
41
47
|
require 'storazzo/ric_disk_statsfile'
|
42
48
|
require 'storazzo/main'
|
43
|
-
require 'storazzo/translator'
|
49
|
+
#require 'storazzo/translator'
|
44
50
|
|
45
51
|
#puts Storazzo::Main.say_hi
|
46
|
-
|
data/test/test_gcs_bucket.rb
CHANGED
@@ -1,16 +1,32 @@
|
|
1
1
|
require "minitest/autorun"
|
2
2
|
require "storazzo"
|
3
3
|
require "storazzo/ric_disk"
|
4
|
+
require "storazzo/ric_disk_config"
|
5
|
+
require 'storazzo/colors'
|
4
6
|
require "storazzo/media/local_folder"
|
7
|
+
require "storazzo/ric_disk_config_example"
|
8
|
+
|
9
|
+
#require "storazzo/ric_disk_config"
|
10
|
+
#require "storazzo/ric_disk_sample_config"
|
11
|
+
#require 'storazzo/ric_disk_sample_config' # => NOTHING!!
|
12
|
+
#require 'storazzo/ric_disk_config_sample' # => NOTHING!!
|
13
|
+
|
14
|
+
#require "storazzo/ric_disk"
|
15
|
+
#require "lib/storazzo/ric_disk_sample_config"
|
16
|
+
#require "storazzo/media/local_folder"
|
5
17
|
#require "storazzo/ric_disk/gcs_bucket"
|
6
18
|
#require "storazzo/media/local_folder"
|
7
19
|
|
8
20
|
class GcsBucketTest < Minitest::Test
|
9
21
|
|
22
|
+
include Storazzo::Common
|
23
|
+
|
10
24
|
def setup # tear_up
|
11
|
-
|
12
|
-
|
13
|
-
config_obj.
|
25
|
+
deb "[GcsBucketTest] TEAR_UP with sample Config"
|
26
|
+
#removeme = Storazzo::RicDiskConfig.instance()
|
27
|
+
config_obj = Storazzo::RicDiskSampleConfig.instance()
|
28
|
+
config_obj.load()
|
29
|
+
deb "[GcsBucketTest] TEAR_UP config_obj: '''#{config_obj}'''"
|
14
30
|
end
|
15
31
|
|
16
32
|
def test_buckets_are_the_two_i_know
|
@@ -19,12 +35,28 @@ class GcsBucketTest < Minitest::Test
|
|
19
35
|
gs://my-other-bucket/
|
20
36
|
}
|
21
37
|
actual_list = Storazzo::RicDisk::GcsBucket.list_all
|
22
|
-
assert_equal(
|
38
|
+
assert_equal(
|
39
|
+
expected_list.sort,
|
40
|
+
actual_list.sort,
|
23
41
|
"These are the two lists from Sample Storazzo Config")
|
24
42
|
end
|
25
43
|
|
44
|
+
def test_import_sample_class_correctly
|
45
|
+
#require "storazzo/ric_disk_sample_config" rescue nil
|
46
|
+
#require "storazzo/ric_disk_config"
|
47
|
+
|
48
|
+
#puts Storazzo.class
|
49
|
+
puts " Storazzo.constants: #{ Storazzo.constants}"
|
50
|
+
#puts Storazzo::RicDiskSampleConfig
|
51
|
+
config_obj = Storazzo::RicDiskSampleConfig.instance()
|
52
|
+
l = config_obj.load
|
53
|
+
puts "config_obj: #{config_obj}"
|
54
|
+
config_obj.load # _sample_version
|
55
|
+
end
|
56
|
+
|
57
|
+
|
26
58
|
def teardown
|
27
|
-
|
59
|
+
puts :TEAR_DOWN_TODO
|
28
60
|
end
|
29
61
|
|
30
62
|
end
|
data/test/test_local_folder.rb
CHANGED
@@ -1,22 +1,28 @@
|
|
1
1
|
require "minitest/autorun"
|
2
2
|
require "storazzo"
|
3
3
|
require "storazzo/ric_disk"
|
4
|
+
require "storazzo/ric_disk_config"
|
5
|
+
require 'storazzo/colors'
|
4
6
|
require "storazzo/media/local_folder"
|
5
7
|
|
6
8
|
#require "storazzo/ric_disk/gcs_bucket"
|
7
9
|
#require "storazzo/media/local_folder"
|
8
10
|
|
9
|
-
extend Storazzo::Colors
|
10
11
|
|
11
12
|
#puts yellow("DISABLING FOR NOW TODO restore")
|
12
13
|
|
13
14
|
class LocalFolderTest < Minitest::Test
|
15
|
+
include Storazzo::Colors
|
14
16
|
# def test_fail_on_purpOSE # test_storazzo_hi_with_argument
|
15
17
|
# assert_match 42, 42 , "change me when it failes from makefile"
|
16
18
|
# #"Hello from Storazzo", Storazzo::Main.hi("ruby this should fail")
|
17
19
|
# #assert_match "ruby this should fail", Storazzo::Main.hi("ruby this should fail")
|
18
20
|
# end
|
19
21
|
def tear_up
|
22
|
+
include Storazzo::Colors
|
23
|
+
puts yellow("LocalFolderTest: tear up")
|
24
|
+
#$config = Storazzo::RicDiskConfig.instance()
|
25
|
+
#$vediamo_se_funge = 42
|
20
26
|
# my_class = Storazzo::RicDisk::LocalFolder
|
21
27
|
# my_obj = Storazzo::RicDisk::LocalFolder
|
22
28
|
end
|
@@ -35,24 +41,59 @@ class LocalFolderTest < Minitest::Test
|
|
35
41
|
end
|
36
42
|
end
|
37
43
|
|
38
|
-
|
44
|
+
# To only test this:
|
45
|
+
# $ ruby -I test test/test_local_folder.rb -n test_first_directory_parsing_actually_works
|
46
|
+
def test_1_first_directory_parsing_actually_works()
|
39
47
|
# include module
|
40
|
-
extend Storazzo::Colors
|
41
48
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
#
|
49
|
+
#p $vediamo_se_funge
|
50
|
+
puts("(#{__FILE__}) WEIRD THING: This test is flaky. SKipping for now until I complete the LocalFolder.parse() code")
|
51
|
+
folders = Storazzo::Media::LocalFolder.list_all
|
52
|
+
puts "Folders: #{folders}"
|
53
|
+
config = Storazzo::RicDiskSampleConfig.instance()
|
54
|
+
puts "config1: #{config}"
|
55
|
+
config.load
|
56
|
+
puts "config2: #{config.load}"
|
57
|
+
test_dir = folders.first
|
58
|
+
puts "test_first_directory_parsing_actually_works() TestDir: #{test_dir}"
|
59
|
+
puts yellow "TEST S:M:LF methods: #{folders}" # methods
|
60
|
+
|
61
|
+
disk = Storazzo::Media::LocalFolder.new(test_dir)
|
62
|
+
stats_file = disk.stats_filename_default_fullpath
|
63
|
+
puts "stats_file: #{stats_file}"
|
64
|
+
disk.parse()
|
65
|
+
puts "[DEB] config: ''#{config}''"
|
66
|
+
# config.iterate_through_file_list_for_disks([test_dir])
|
53
67
|
# assert(
|
54
68
|
# File.exists?(stats_file),
|
55
69
|
# "parse on LocalFolder should create file '#{stats_file}'"
|
56
70
|
# )
|
57
71
|
end
|
72
|
+
|
73
|
+
def test_2_iterate_through_file_list_for_disks
|
74
|
+
#p $vediamo_se_funge
|
75
|
+
puts("(#{__FILE__}) WEIRD THING: This test is flaky. SKipping for now until I complete the LocalFolder.parse() code")
|
76
|
+
folders = Storazzo::Media::LocalFolder.list_all
|
77
|
+
puts "Folders: #{folders}"
|
78
|
+
config = Storazzo::RicDiskSampleConfig.instance()
|
79
|
+
puts "config1: #{config}"
|
80
|
+
config.load
|
81
|
+
puts "config2: #{config.load}"
|
82
|
+
test_dir = folders.first
|
83
|
+
puts "test_first_directory_parsing_actually_works() TestDir: #{test_dir}"
|
84
|
+
puts "TEST S:M:LF methods: #{folders}" # methods
|
85
|
+
|
86
|
+
disk = Storazzo::Media::LocalFolder.new(test_dir)
|
87
|
+
stats_file = disk.stats_filename_default_fullpath
|
88
|
+
#puts "stats_file: #{stats_file}"
|
89
|
+
#disk.parse()
|
90
|
+
#puts "[DEB] config: ''#{config}''"
|
91
|
+
|
92
|
+
#TEST2: config + iterate
|
93
|
+
config.iterate_through_file_list_for_disks([test_dir])
|
94
|
+
assert(
|
95
|
+
File.exists?(stats_file),
|
96
|
+
"parse on LocalFolder should create file '#{stats_file}'"
|
97
|
+
)
|
98
|
+
end
|
58
99
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
=begin
|
2
|
+
to just test this file, try:
|
3
|
+
|
4
|
+
`ruby -I test test/test_ric_disk_config.rb`
|
5
|
+
|
6
|
+
=end
|
7
|
+
|
8
|
+
require "minitest/autorun"
|
9
|
+
require "storazzo"
|
10
|
+
#require "storazzo/ric_disk_config"
|
11
|
+
#require "storazzo/ric_disk_sample_config"
|
12
|
+
#require "storazzo/ric_disk_config_example"
|
13
|
+
|
14
|
+
# require "storazzo/media/local_folder"
|
15
|
+
#require "storazzo/ric_disk/gcs_bucket"
|
16
|
+
#require "storazzo/media/local_folder"
|
17
|
+
|
18
|
+
|
19
|
+
class RicDiskConfigTest < Minitest::Test
|
20
|
+
|
21
|
+
def test_load_sample_version # test_sample_config_is_within_gems_boundaries
|
22
|
+
#config_obj = Storazzo::RicDiskConfig.instance()
|
23
|
+
#puts :sofar_so_good
|
24
|
+
config_obj = Storazzo::RicDiskSampleConfig.instance()
|
25
|
+
puts "config_obj.class: #{config_obj.class}"
|
26
|
+
config = config_obj.load # _sample_version
|
27
|
+
puts "Config: #{config}"
|
28
|
+
#puts '[RicDiskConfigTest] TODO lets make sure the gem being imported is actually in /etc/storazz-config.smaple blah blah'
|
29
|
+
#puts "[RicDiskConfigTest] config_file: ", config_obj.config_file
|
30
|
+
assert_equal(
|
31
|
+
config_obj.config_file,
|
32
|
+
Storazzo.root + "/etc/storazzo_config.sample.yaml",
|
33
|
+
"Config file expected to be here.."
|
34
|
+
)
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
end
|
data/test/test_storazzo.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
require "minitest/autorun"
|
2
|
+
require "storazzo"
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
class StorazzoTest < Minitest::Test
|
5
|
+
def test_storazzo_hi_with_argument
|
6
|
+
assert_match "Hello from Storazzo", Storazzo::Main.say_hi("ruby this should fail")
|
7
|
+
assert_match "ruby this should fail", Storazzo::Main.say_hi("ruby this should fail")
|
8
|
+
end
|
9
9
|
# def test_storazzo_hi_without_argument
|
10
10
|
# assert_match "Hello from Storazzo", Storazzo::Main.say_hi()
|
11
11
|
# end
|
@@ -30,5 +30,5 @@
|
|
30
30
|
# # def test_spanish_hello
|
31
31
|
# # assert_equal "hola mundo",
|
32
32
|
# # Hola.hi("spanish")
|
33
|
-
#
|
34
|
-
|
33
|
+
# end
|
34
|
+
end
|
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.3.
|
4
|
+
version: 0.3.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Riccardo Carlesso
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-07-
|
11
|
+
date: 2022-07-29 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A simple gem to manage your external hard drives and extract MD5 and
|
14
14
|
common stuff from them.
|
@@ -39,13 +39,14 @@ files:
|
|
39
39
|
- lib/storazzo/parser/parser.rb
|
40
40
|
- lib/storazzo/ric_disk.rb
|
41
41
|
- lib/storazzo/ric_disk_config.rb
|
42
|
+
- lib/storazzo/ric_disk_sample_config.rb
|
42
43
|
- lib/storazzo/ric_disk_statsfile.rb
|
43
44
|
- lib/storazzo/ric_disk_ugly.rb
|
44
|
-
- lib/storazzo/translator.rb
|
45
45
|
- lib/storazzo/version.rb
|
46
46
|
- storazzo.gemspec
|
47
47
|
- test/test_gcs_bucket.rb
|
48
48
|
- test/test_local_folder.rb
|
49
|
+
- test/test_ric_disk_config.rb
|
49
50
|
- test/test_ric_disk_stats_file.rb
|
50
51
|
- test/test_storazzo.rb
|
51
52
|
- var/test/README.md
|
@@ -77,6 +78,7 @@ summary: storazzo is an amazing gem. Code is in https://github.com/palladius/sto
|
|
77
78
|
test_files:
|
78
79
|
- test/test_storazzo.rb
|
79
80
|
- test/test_ric_disk_stats_file.rb
|
81
|
+
- test/test_ric_disk_config.rb
|
80
82
|
- test/test_gcs_bucket.rb
|
81
83
|
- test/test_local_folder.rb
|
82
84
|
- var/test/README.md
|
data/lib/storazzo/translator.rb
DELETED