storazzo 0.3.7 → 0.4.2

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.
@@ -1,251 +1,251 @@
1
- # TODO remove this! Ugly code to just borrow and cleanup a bit,
1
+ # # TODO remove this! Ugly code to just borrow and cleanup a bit,
2
2
 
3
- module Storazzo
4
- class Storazzo::RicDiskUgly
5
- RICDISK_VERSION = "1.0ugly"
6
- DEFAULT_MEDIA_DIRS = %w{
7
- /media/riccardo/
8
- /Volumes/
9
- /mnt/
10
- ~/storazzo/var/test/disks/
11
- }.append(Storazzo.root + "/var/test/disks/")
3
+ # module Storazzo
4
+ # class Storazzo::RicDiskUgly
5
+ # RICDISK_VERSION = "1.0ugly"
6
+ # DEFAULT_MEDIA_DIRS = %w{
7
+ # /media/riccardo/
8
+ # /Volumes/
9
+ # /mnt/
10
+ # ~/storazzo/var/test/disks/
11
+ # }.append(Storazzo.root + "/var/test/disks/")
12
12
 
13
- include Hashify
14
- extend Storazzo::Colors
15
-
16
- # todo substitute with protobuf..
17
- attr_accessor :name, :description, :ricdisk_file, :local_mountpoint, :wr
18
-
19
- def self.interesting_mount_points(opts={})
20
- #https://unix.stackexchange.com/questions/177014/showing-only-interesting-mount-points-filtering-non-interesting-types
21
- `mount | grep -Ev 'type (proc|sysfs|tmpfs|devpts|debugfs|rpc_pipefs|nfsd|securityfs|fusectl|devtmpfs) '`.split(/\n+/)
22
- end
23
-
24
- def initialize(path, ricdisk_file)
25
- puts "[DEB] RicDiskUgly initialize.. path=#{path}"
26
- @local_mountpoint = path
27
- @description = "This is an automated RicDiskUgly description from v.#{VERSION}. Riccardo feel free to edit away with characteristicshs of this device.. Created on #{Time.now}'"
28
- @ricdisk_version = VERSION
29
- @ricdisk_file = ricdisk_file
30
- #@questo_non_esiste = :sobenme
31
- @label = path.split("/").last
32
- @name = path.split("/").last
33
- @wr = File.writable?("#{path}/#{ricdisk_file}" ) # .writeable?
34
- @tags = 'ricdisk'
35
- puts :beleza
36
- @config = RicDiskConfig.instance.get_config
37
- #puts @config if @config
38
- find_info_from_mount(path)
39
- find_info_from_df()
40
- end
41
-
42
- def ricdisk_absolute_path
43
- @local_mountpoint + "/" + @ricdisk_file
44
- end
45
-
46
- def add_tag(tag)
47
- @tags += ", #{tag}"
48
- end
49
-
50
- # might have other things in the future...
51
- def find_info_from_mount(path)
52
- mount_table_lines = interesting_mount_points()
53
- mount_line = nil
54
- mount_table_lines.each do |line|
55
- next if line =~ /^map /
56
- dev, on, mount_path, mode = line.split(/ /)
57
- if mount_path==path
58
- mount_line = line
59
- else
60
- @info_from_mount = false
61
- end
62
- end
63
- @info_from_mount = ! (mount_line.nil?)
64
- if @info_from_mount
65
- #@mount_line = mount_line
66
- @description += "\nMount line:\n" + mount_line
67
- @remote_mountpoint = mount_line.split(/ /)[0]
68
- @fstype = mount_line.split(/ /)[3].gsub(/[\(,]/, '')
69
- add_tag(:synology) if @remote_mountpoint.match('1.0.1.10')
70
- end
71
- end
72
-
73
- def find_info_from_df()
74
- path = @local_mountpoint
75
- df_info = `df -h "#{path}"`
76
- @df_info = df_info
77
- lines = df_info.split(/\n+/)
78
- raise "I need exactly TWO lines! Or no info is served here..." unless lines.size == 2
79
- mount, @size_readable, used_size, avail_size, @disk_utilization, other = lines[1].split(/\s+/) # second line..
80
- end
81
-
82
-
83
-
84
- def self.sbrodola_ricdisk(subdir)
85
- # given a path, if .ricdisk exists i do stuff with it..
86
- disk_info = nil
87
- unless self.ok_dir?(subdir)
88
- puts("Nothing for me here. Existing")
89
- return
90
- end
91
- if File.exists?( "#{subdir}/.ricdisk") and File.empty?( "#{subdir}/.ricdisk")
92
- deb("Interesting1. Empty file! Now I write YAML with it.")
93
- disk_info = RicDiskUgly.new(subdir, '.ricdisk')
94
- #puts(x)
95
- #puts(yellow x.to_yaml)
96
- end
97
- if File.exists?( "#{subdir}/.ricdisk.yaml") and File.empty?( "#{subdir}/.ricdisk.yaml")
98
- deb("Interesting2. Empty file! TODO write YAML with it.")
99
- disk_info = RicDiskUgly.new(subdir, '.ricdisk.yaml')
100
- # todo write
101
- #puts(x)
102
- puts(yellow disk_info.to_yaml)
103
- end
104
- if disk_info
105
- if File.empty?(disk_info.ricdisk_absolute_path) and (disk_info.wr)
106
- puts(green("yay, we can now write the file '#{disk_info.ricdisk_absolute_path}' (which is R/W, I just checked!) with proper YAML content.."))
107
- ret = File.write(disk_info.ricdisk_absolute_path, disk_info.to_yaml)
108
- puts("Written file! ret=#{ret}")
109
- else
110
- puts(red("Nope, qualcosa non va.. #{File.empty?(disk_info.ricdisk_absolute_path)}"))
111
- puts("File size: #{File.size(disk_info.ricdisk_absolute_path)}")
112
- end
113
- end
114
- if File.exists?( "#{subdir}/.ricdisk") and ! File.empty?( "#{subdir}/.ricdisk")
115
- puts("Config File found with old-style name: '#{subdir}/.ricdisk' !")
116
- #puts(white `cat "#{subdir}/.ricdisk"`)
117
- end
118
- end
119
-
120
- # separiamo cosi usiamo meglio...
121
- def self.ok_dir?(subdir)
122
- File.exists?( "#{subdir}/.ricdisk") or File.exists?( "#{subdir}/.ricdisk.yaml")
123
- end
124
-
125
- def self.obsolescence_seconds file_path
126
- creation_time = File.stat(file_path).ctime
127
- deb("[obsolescence_seconds] File #{file_path}: #{creation_time} - #{(Time.now - creation_time)} seconds ago")
128
- (Time.now - creation_time).to_i
129
- end
130
- def self.obsolescence_days(file_path)
131
- return obsolescence_seconds(file_path) / 86400
132
- end
133
-
134
- def self.backquote_execute(cmd)
135
- # executed a command wrapped by dryrun though
136
- return "DRYRUN backquote_execute(#{cmd})" if $opts[:dryrun]
137
- `#{cmd}`
138
- end
13
+ # include Hashify
14
+ # extend Storazzo::Colors
15
+
16
+ # # todo substitute with protobuf..
17
+ # attr_accessor :name, :description, :ricdisk_file, :local_mountpoint, :wr
18
+
19
+ # def self.interesting_mount_points(opts={})
20
+ # #https://unix.stackexchange.com/questions/177014/showing-only-interesting-mount-points-filtering-non-interesting-types
21
+ # `mount | grep -Ev 'type (proc|sysfs|tmpfs|devpts|debugfs|rpc_pipefs|nfsd|securityfs|fusectl|devtmpfs) '`.split(/\n+/)
22
+ # end
23
+
24
+ # def initialize(path, ricdisk_file)
25
+ # puts "[DEB] RicDiskUgly initialize.. path=#{path}"
26
+ # @local_mountpoint = path
27
+ # @description = "This is an automated RicDiskUgly description from v.#{VERSION}. Riccardo feel free to edit away with characteristicshs of this device.. Created on #{Time.now}'"
28
+ # @ricdisk_version = VERSION
29
+ # @ricdisk_file = ricdisk_file
30
+ # #@questo_non_esiste = :sobenme
31
+ # @label = path.split("/").last
32
+ # @name = path.split("/").last
33
+ # @wr = File.writable?("#{path}/#{ricdisk_file}" ) # .writeable?
34
+ # @tags = 'ricdisk'
35
+ # puts :beleza
36
+ # @config = RicDiskConfig.instance.get_config
37
+ # #puts @config if @config
38
+ # find_info_from_mount(path)
39
+ # find_info_from_df()
40
+ # end
41
+
42
+ # def ricdisk_absolute_path
43
+ # @local_mountpoint + "/" + @ricdisk_file
44
+ # end
45
+
46
+ # def add_tag(tag)
47
+ # @tags += ", #{tag}"
48
+ # end
49
+
50
+ # # might have other things in the future...
51
+ # def find_info_from_mount(path)
52
+ # mount_table_lines = interesting_mount_points()
53
+ # mount_line = nil
54
+ # mount_table_lines.each do |line|
55
+ # next if line =~ /^map /
56
+ # dev, on, mount_path, mode = line.split(/ /)
57
+ # if mount_path==path
58
+ # mount_line = line
59
+ # else
60
+ # @info_from_mount = false
61
+ # end
62
+ # end
63
+ # @info_from_mount = ! (mount_line.nil?)
64
+ # if @info_from_mount
65
+ # #@mount_line = mount_line
66
+ # @description += "\nMount line:\n" + mount_line
67
+ # @remote_mountpoint = mount_line.split(/ /)[0]
68
+ # @fstype = mount_line.split(/ /)[3].gsub(/[\(,]/, '')
69
+ # add_tag(:synology) if @remote_mountpoint.match('1.0.1.10')
70
+ # end
71
+ # end
72
+
73
+ # def find_info_from_df()
74
+ # path = @local_mountpoint
75
+ # df_info = `df -h "#{path}"`
76
+ # @df_info = df_info
77
+ # lines = df_info.split(/\n+/)
78
+ # raise "I need exactly TWO lines! Or no info is served here..." unless lines.size == 2
79
+ # mount, @size_readable, used_size, avail_size, @disk_utilization, other = lines[1].split(/\s+/) # second line..
80
+ # end
81
+
82
+
83
+
84
+ # def self.sbrodola_ricdisk(subdir)
85
+ # # given a path, if .ricdisk exists i do stuff with it..
86
+ # disk_info = nil
87
+ # unless self.ok_dir?(subdir)
88
+ # puts("Nothing for me here. Existing")
89
+ # return
90
+ # end
91
+ # if File.exists?( "#{subdir}/.ricdisk") and File.empty?( "#{subdir}/.ricdisk")
92
+ # deb("Interesting1. Empty file! Now I write YAML with it.")
93
+ # disk_info = RicDiskUgly.new(subdir, '.ricdisk')
94
+ # #puts(x)
95
+ # #puts(yellow x.to_yaml)
96
+ # end
97
+ # if File.exists?( "#{subdir}/.ricdisk.yaml") and File.empty?( "#{subdir}/.ricdisk.yaml")
98
+ # deb("Interesting2. Empty file! TODO write YAML with it.")
99
+ # disk_info = RicDiskUgly.new(subdir, '.ricdisk.yaml')
100
+ # # todo write
101
+ # #puts(x)
102
+ # puts(yellow disk_info.to_yaml)
103
+ # end
104
+ # if disk_info
105
+ # if File.empty?(disk_info.ricdisk_absolute_path) and (disk_info.wr)
106
+ # puts(green("yay, we can now write the file '#{disk_info.ricdisk_absolute_path}' (which is R/W, I just checked!) with proper YAML content.."))
107
+ # ret = File.write(disk_info.ricdisk_absolute_path, disk_info.to_yaml)
108
+ # puts("Written file! ret=#{ret}")
109
+ # else
110
+ # puts(red("Nope, qualcosa non va.. #{File.empty?(disk_info.ricdisk_absolute_path)}"))
111
+ # puts("File size: #{File.size(disk_info.ricdisk_absolute_path)}")
112
+ # end
113
+ # end
114
+ # if File.exists?( "#{subdir}/.ricdisk") and ! File.empty?( "#{subdir}/.ricdisk")
115
+ # puts("Config File found with old-style name: '#{subdir}/.ricdisk' !")
116
+ # #puts(white `cat "#{subdir}/.ricdisk"`)
117
+ # end
118
+ # end
119
+
120
+ # # separiamo cosi usiamo meglio...
121
+ # def self.ok_dir?(subdir)
122
+ # File.exists?( "#{subdir}/.ricdisk") or File.exists?( "#{subdir}/.ricdisk.yaml")
123
+ # end
124
+
125
+ # def self.obsolescence_seconds file_path
126
+ # creation_time = File.stat(file_path).ctime
127
+ # deb("[obsolescence_seconds] File #{file_path}: #{creation_time} - #{(Time.now - creation_time)} seconds ago")
128
+ # (Time.now - creation_time).to_i
129
+ # end
130
+ # def self.obsolescence_days(file_path)
131
+ # return obsolescence_seconds(file_path) / 86400
132
+ # end
133
+
134
+ # def self.backquote_execute(cmd)
135
+ # # executed a command wrapped by dryrun though
136
+ # return "DRYRUN backquote_execute(#{cmd})" if $opts[:dryrun]
137
+ # `#{cmd}`
138
+ # end
139
139
 
140
- def self.upload_to_gcs(file, opts={})
141
- deb("upload_to_gcs(#{file}). TODO(ricc) after breafast upload to GCS : #{file}")
142
- mount_name = file.split('/')[-2]
143
- filename = "#{mount_name}-#{File.basename file}"
144
- hostname = Socket.gethostname[/^[^.]+/]
145
- command = "gsutil cp '#{file}' gs://#{$gcs_bucket}/backup/ricdisk-magic/#{ hostname }-#{filename}"
146
- deb("Command: #{command}")
147
- ret = backquote_execute(command)
148
- # if $opts[:debug] do
149
- # puts "+ Current list of files:"
150
- # ret = backquote_execute("gsutil ls -al gs://#{$gcs_bucket}/backup/ricdisk-magic/")
151
- # puts ret
152
- # end
153
- ret
154
- end
155
-
156
- # Create RDS file.
157
- def self.calculate_stats_files(dir, opts={})
158
- opts_upload_to_gcs = opts.fetch :upload_to_gcs, true
159
- full_file_path = "#{dir}/#{$stats_file}"
160
-
161
- puts("calculate_stats_files(#{white dir}): #{white full_file_path}")
162
- puts "TEST1 DIR EXISTS: #{dir} -> #{File.directory? dir}"
163
- Dir.chdir(dir)
164
- if File.exists?(full_file_path) and ($opts[:force] == false)
165
- puts "File '#{$stats_file}' exists already." # - now should see if its too old, like more than 1 week old"
166
- # TODO check for file time...
167
- print "Lines found: #{yellow `wc -l "#{full_file_path}" `.chomp }. File obsolescence (days): #{yellow obsolescence_days(full_file_path)}."
168
- if obsolescence_days(full_file_path) > 7
169
- puts("*** ACHTUNG *** FIle is pretty old. You might consider rotating: #{yellow "mv #{full_file_path} #{full_file_path}_old"}. Or invoke with --force")
170
- end
171
- upload_to_gcs(full_file_path) if opts_upload_to_gcs
172
- else
173
- puts "Crunching data stats from '#{dir}' into '#{$stats_file}' ... please bear with me.. [maybe file didnt exist, maybe $opts[:force] is true]"
174
- command = "find . -print0 | xargs -0 stats-with-md5.rb --no-color | tee '#{full_file_path}'"
175
- puts("[#{`pwd`.chomp}] Executing: #{azure command}")
176
- ret = backquote_execute command
177
- puts "Done. #{ret.split("\n").count} files processed."
178
- end
179
- end
180
-
181
- def self.find_active_dirs(base_dirs=nil, also_mountpoints=true)
182
- base_dirs = DEFAULT_MEDIA_DIRS if base_dirs.nil?
183
- active_dirs = []
184
- base_dirs.each do |ugly_dir|
185
- # https://stackoverflow.com/questions/1899072/getting-a-list-of-folders-in-a-directory#:~:text=Dir.chdir(%27/destination_directory%27)%0ADir.glob(%27*%27).select%20%7B%7Cf%7C%20File.directory%3F%20f%7D
186
- dir = File.expand_path(ugly_dir)
187
- begin
188
- x=[]
189
- # puts "TEST2 DIR EXISTS: #{dir} -> #{Dir.exists?(dir)}"
190
- unless Dir.exists?(dir)
191
- deb "Dir doesnt exist, skipping: #{dir}"
192
- next
193
- end
194
- Dir.chdir(dir)
195
- x = Dir.glob('*').select {|f| File.directory? f}
196
- subdirs = x.map{|subdir| "#{dir}#{subdir}"}
197
- subdirs.each{|subdir|
198
- #puts `ls -al "#{subdir}"`
199
- active_dirs << subdir if self.ok_dir?(subdir)
200
- }
201
- #puts(white x)
202
- rescue Exception => e # optionally: `rescue Exception => ex`
203
- puts "Exception: '#{e}'"
204
- ensure # will always get executed
205
- #deb 'Always gets executed.'
206
- #x = []
207
- end
208
- end
209
-
210
- if also_mountpoints
211
- =begin
212
- Example output from mount:
140
+ # def self.upload_to_gcs(file, opts={})
141
+ # deb("upload_to_gcs(#{file}). TODO(ricc) after breafast upload to GCS : #{file}")
142
+ # mount_name = file.split('/')[-2]
143
+ # filename = "#{mount_name}-#{File.basename file}"
144
+ # hostname = Socket.gethostname[/^[^.]+/]
145
+ # command = "gsutil cp '#{file}' gs://#{$gcs_bucket}/backup/ricdisk-magic/#{ hostname }-#{filename}"
146
+ # deb("Command: #{command}")
147
+ # ret = backquote_execute(command)
148
+ # # if $opts[:debug] do
149
+ # # puts "+ Current list of files:"
150
+ # # ret = backquote_execute("gsutil ls -al gs://#{$gcs_bucket}/backup/ricdisk-magic/")
151
+ # # puts ret
152
+ # # end
153
+ # ret
154
+ # end
155
+
156
+ # # Create RDS file.
157
+ # def self.calculate_stats_files(dir, opts={})
158
+ # opts_upload_to_gcs = opts.fetch :upload_to_gcs, true
159
+ # full_file_path = "#{dir}/#{$stats_file}"
160
+
161
+ # puts("calculate_stats_files(#{white dir}): #{white full_file_path}")
162
+ # puts "TEST1 DIR EXISTS: #{dir} -> #{File.directory? dir}"
163
+ # Dir.chdir(dir)
164
+ # if File.exists?(full_file_path) and ($opts[:force] == false)
165
+ # puts "File '#{$stats_file}' exists already." # - now should see if its too old, like more than 1 week old"
166
+ # # TODO check for file time...
167
+ # print "Lines found: #{yellow `wc -l "#{full_file_path}" `.chomp }. File obsolescence (days): #{yellow obsolescence_days(full_file_path)}."
168
+ # if obsolescence_days(full_file_path) > 7
169
+ # puts("*** ACHTUNG *** FIle is pretty old. You might consider rotating: #{yellow "mv #{full_file_path} #{full_file_path}_old"}. Or invoke with --force")
170
+ # end
171
+ # upload_to_gcs(full_file_path) if opts_upload_to_gcs
172
+ # else
173
+ # puts "Crunching data stats from '#{dir}' into '#{$stats_file}' ... please bear with me.. [maybe file didnt exist, maybe $opts[:force] is true]"
174
+ # command = "find . -print0 | xargs -0 stats-with-md5.rb --no-color | tee '#{full_file_path}'"
175
+ # puts("[#{`pwd`.chomp}] Executing: #{azure command}")
176
+ # ret = backquote_execute command
177
+ # puts "Done. #{ret.split("\n").count} files processed."
178
+ # end
179
+ # end
180
+
181
+ # def self.find_active_dirs(base_dirs=nil, also_mountpoints=true)
182
+ # base_dirs = DEFAULT_MEDIA_DIRS if base_dirs.nil?
183
+ # active_dirs = []
184
+ # base_dirs.each do |ugly_dir|
185
+ # # https://stackoverflow.com/questions/1899072/getting-a-list-of-folders-in-a-directory#:~:text=Dir.chdir(%27/destination_directory%27)%0ADir.glob(%27*%27).select%20%7B%7Cf%7C%20File.directory%3F%20f%7D
186
+ # dir = File.expand_path(ugly_dir)
187
+ # begin
188
+ # x=[]
189
+ # # puts "TEST2 DIR EXISTS: #{dir} -> #{Dir.exists?(dir)}"
190
+ # unless Dir.exists?(dir)
191
+ # deb "Dir doesnt exist, skipping: #{dir}"
192
+ # next
193
+ # end
194
+ # Dir.chdir(dir)
195
+ # x = Dir.glob('*').select {|f| File.directory? f}
196
+ # subdirs = x.map{|subdir| "#{dir}#{subdir}"}
197
+ # subdirs.each{|subdir|
198
+ # #puts `ls -al "#{subdir}"`
199
+ # active_dirs << subdir if self.ok_dir?(subdir)
200
+ # }
201
+ # #puts(white x)
202
+ # rescue Exception => e # optionally: `rescue Exception => ex`
203
+ # puts "Exception: '#{e}'"
204
+ # ensure # will always get executed
205
+ # #deb 'Always gets executed.'
206
+ # #x = []
207
+ # end
208
+ # end
209
+
210
+ # if also_mountpoints
211
+ # =begin
212
+ # Example output from mount:
213
213
 
214
- devfs on /dev (devfs, local, nobrowse)
215
- /dev/disk3s6 on /System/Volumes/VM (apfs, local, noexec, journaled, noatime, nobrowse)
216
- /dev/disk3s2 on /System/Volumes/Preboot (apfs, local, journaled, nobrowse)
217
- /dev/disk3s4 on /System/Volumes/Update (apfs, local, journaled, nobrowse)
218
- /dev/disk1s2 on /System/Volumes/xarts (apfs, local, noexec, journaled, noatime, nobrowse)
219
- /dev/disk1s1 on /System/Volumes/iSCPreboot (apfs, local, journaled, nobrowse)
220
- /dev/disk1s3 on /System/Volumes/Hardware (apfs, local, journaled, nobrowse)
221
- /dev/disk3s5 on /System/Volumes/Data (apfs, local, journaled, nobrowse, protect)
222
- map auto_home on /System/Volumes/Data/home (autofs, automounted, nobrowse)
223
- //riccardo@1.0.1.10/video on /Volumes/video (afpfs, nodev, nosuid, mounted by ricc)
224
- //riccardo@1.0.1.10/photo on /Volumes/photo (afpfs, nodev, nosuid, mounted by ricc)
225
- =end
226
- # add directories from current mountpoints...
227
- mount_table_lines = interesting_mount_points()
228
- mount_table_lines.each{|line|
229
- next if line =~ /^map /
230
- dev, on, path, mode = line.split(/ /)
231
- #puts line
232
- #deb yellow(path)
233
- active_dirs << path if self.ok_dir?(path)
234
- }
235
- end
236
- active_dirs.uniq!
237
- puts("find_active_dirs(): found dirs " + green(active_dirs))
238
- return active_dirs
239
- end
214
+ # devfs on /dev (devfs, local, nobrowse)
215
+ # /dev/disk3s6 on /System/Volumes/VM (apfs, local, noexec, journaled, noatime, nobrowse)
216
+ # /dev/disk3s2 on /System/Volumes/Preboot (apfs, local, journaled, nobrowse)
217
+ # /dev/disk3s4 on /System/Volumes/Update (apfs, local, journaled, nobrowse)
218
+ # /dev/disk1s2 on /System/Volumes/xarts (apfs, local, noexec, journaled, noatime, nobrowse)
219
+ # /dev/disk1s1 on /System/Volumes/iSCPreboot (apfs, local, journaled, nobrowse)
220
+ # /dev/disk1s3 on /System/Volumes/Hardware (apfs, local, journaled, nobrowse)
221
+ # /dev/disk3s5 on /System/Volumes/Data (apfs, local, journaled, nobrowse, protect)
222
+ # map auto_home on /System/Volumes/Data/home (autofs, automounted, nobrowse)
223
+ # //riccardo@1.0.1.10/video on /Volumes/video (afpfs, nodev, nosuid, mounted by ricc)
224
+ # //riccardo@1.0.1.10/photo on /Volumes/photo (afpfs, nodev, nosuid, mounted by ricc)
225
+ # =end
226
+ # # add directories from current mountpoints...
227
+ # mount_table_lines = interesting_mount_points()
228
+ # mount_table_lines.each{|line|
229
+ # next if line =~ /^map /
230
+ # dev, on, path, mode = line.split(/ /)
231
+ # #puts line
232
+ # #deb yellow(path)
233
+ # active_dirs << path if self.ok_dir?(path)
234
+ # }
235
+ # end
236
+ # active_dirs.uniq!
237
+ # puts("find_active_dirs(): found dirs " + green(active_dirs))
238
+ # return active_dirs
239
+ # end
240
240
 
241
241
 
242
- def analyze_local_system()
243
- puts :TODO
244
- puts "1. Interesting Mounts: #{green interesting_mount_points}"
245
- puts "2. Sbrodoling everything: :TODO"
246
- # find_info_from_mount(path)
247
- # find_info_from_df()
248
- end
249
-
250
- end
251
- end
242
+ # def analyze_local_system()
243
+ # puts :TODO
244
+ # puts "1. Interesting Mounts: #{green interesting_mount_points}"
245
+ # puts "2. Sbrodoling everything: :TODO"
246
+ # # find_info_from_mount(path)
247
+ # # find_info_from_df()
248
+ # end
249
+
250
+ # end
251
+ # end
data/storazzo.gemspec CHANGED
@@ -9,7 +9,10 @@ Gem::Specification.new do |s|
9
9
  # Autoglob as per https://stackoverflow.com/questions/11873294/determining-the-gems-list-of-files-for-the-specification
10
10
  s.files = %w(Gemfile LICENSE README.md Makefile Rakefile storazzo.gemspec VERSION) + Dir["{bin,lib,test,var}/**/*"]
11
11
  s.test_files = Dir["test/**/*"] + Dir["var/test/**/*"]
12
- s.executables << "ricdisk-magic"
12
+ s.executables = [
13
+ "ricdisk-magic",
14
+ "stats-with-md5",
15
+ ]
13
16
 
14
17
  s.homepage = "https://rubygems.org/gems/storazzo" # maybe https://github.com/palladius/storazzo
15
18
  s.license = "MIT"
@@ -6,6 +6,8 @@ require 'storazzo/colors'
6
6
  require "storazzo/media/local_folder"
7
7
  require "storazzo/ric_disk_config_example"
8
8
 
9
+ require 'pry' # must install the gem... but you ALWAYS want pry installed anyways
10
+
9
11
  #require "storazzo/ric_disk_config"
10
12
  #require "storazzo/ric_disk_sample_config"
11
13
  #require 'storazzo/ric_disk_sample_config' # => NOTHING!!
@@ -21,39 +23,48 @@ class GcsBucketTest < Minitest::Test
21
23
 
22
24
  include Storazzo::Common
23
25
 
24
- def TODO_setup # tear_up
26
+ def setup # tear_up
25
27
  deb "[GcsBucketTest] TEAR_UP with sample Config"
26
28
  #removeme = Storazzo::RicDiskConfig.instance()
27
- config_obj = Storazzo::RicDiskSampleConfig.instance()
28
- deb "[GcsBucketTest] TEAR_UP config_obj: '''#{config_obj}'''"
29
+ $sample_config_obj = Storazzo::RicDiskSampleConfig.instance()
30
+ $sample_config_hash = $sample_config_obj.load()
31
+ deb "[GcsBucketTest] TEAR_UP config_obj: '''#{$sample_config_obj}'''"
29
32
  end
30
33
 
31
- def TODO_test_buckets_are_the_two_i_know
34
+ def test_buckets_are_the_two_i_know
35
+ # copied from etc/sample.yaml :)
32
36
  expected_list = %w{
33
37
  gs://my-local-backup/storazzo/backups/
34
38
  gs://my-other-bucket/
35
39
  }
36
- actual_list = Storazzo::RicDisk::GcsBucket.list_all
37
- assert_equal(expected_list, actual_list,
40
+ actual_list = Storazzo::RicDisk::GcsBucket.list_all($sample_config_obj)
41
+ assert_equal(
42
+ expected_list.sort,
43
+ actual_list.sort,
38
44
  "These are the two lists from Sample Storazzo Config")
39
45
  end
40
46
 
41
- def TODO_test_import
47
+ def test_import_sample_class_correctly
42
48
  #require "storazzo/ric_disk_sample_config" rescue nil
43
49
  #require "storazzo/ric_disk_config"
44
50
 
45
51
  #puts Storazzo.class
46
- puts " Storazzo.constants: #{ Storazzo.constants}"
52
+ deb " Storazzo.constants: #{ Storazzo.constants}"
47
53
  #puts Storazzo::RicDiskSampleConfig
48
- config_obj = Storazzo::RicDiskSampleConfig.instance()
49
- l = config_obj.load
50
- puts "config_obj: #{config_obj}"
51
- config_obj.load # _sample_version
52
- end
54
+ #config_obj = Storazzo::RicDiskSampleConfig.instance()
55
+ Pry::ColorPrinter.pp($sample_config_obj.to_verbose_s())
56
+ #pp green(config_obj.to_verbose_s())
53
57
 
58
+ l = $sample_config_obj.load
59
+ Pry::ColorPrinter.pp(l)
54
60
 
55
- def teardown
56
- puts :TEAR_DOWN_TODO
61
+ puts "$sample_config_obj: #{$sample_config_obj}"
62
+ #config_obj.load # _sample_version
57
63
  end
58
64
 
65
+
66
+ # def teardown
67
+ # puts :TEAR_DOWN_TODO
68
+ # end
69
+
59
70
  end