storazzo 0.3.8 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/VERSION +1 -1
- data/bin/stats-with-md5 +428 -0
- data/lib/storazzo/media/gcs_bucket.rb +4 -2
- data/lib/storazzo/ric_disk.rb +54 -28
- data/lib/storazzo/ric_disk_config.rb +31 -20
- data/lib/storazzo/ric_disk_ugly.rb +245 -245
- data/storazzo.gemspec +4 -1
- data/test/test_gcs_bucket.rb +20 -12
- data/test/test_local_folder.rb +26 -4
- metadata +3 -1
@@ -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
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
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
|
-
|
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
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
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
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
=begin
|
212
|
-
|
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
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
=end
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
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
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
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
|
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"
|
data/test/test_gcs_bucket.rb
CHANGED
@@ -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!!
|
@@ -24,17 +26,18 @@ class GcsBucketTest < Minitest::Test
|
|
24
26
|
def setup # tear_up
|
25
27
|
deb "[GcsBucketTest] TEAR_UP with sample Config"
|
26
28
|
#removeme = Storazzo::RicDiskConfig.instance()
|
27
|
-
|
28
|
-
|
29
|
-
deb "[GcsBucketTest] TEAR_UP 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}'''"
|
30
32
|
end
|
31
33
|
|
32
34
|
def test_buckets_are_the_two_i_know
|
35
|
+
# copied from etc/sample.yaml :)
|
33
36
|
expected_list = %w{
|
34
37
|
gs://my-local-backup/storazzo/backups/
|
35
38
|
gs://my-other-bucket/
|
36
39
|
}
|
37
|
-
actual_list = Storazzo::RicDisk::GcsBucket.list_all
|
40
|
+
actual_list = Storazzo::RicDisk::GcsBucket.list_all($sample_config_obj)
|
38
41
|
assert_equal(
|
39
42
|
expected_list.sort,
|
40
43
|
actual_list.sort,
|
@@ -46,17 +49,22 @@ class GcsBucketTest < Minitest::Test
|
|
46
49
|
#require "storazzo/ric_disk_config"
|
47
50
|
|
48
51
|
#puts Storazzo.class
|
49
|
-
|
52
|
+
deb " Storazzo.constants: #{ Storazzo.constants}"
|
50
53
|
#puts Storazzo::RicDiskSampleConfig
|
51
|
-
config_obj = Storazzo::RicDiskSampleConfig.instance()
|
52
|
-
|
53
|
-
|
54
|
-
config_obj.load # _sample_version
|
55
|
-
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())
|
56
57
|
|
58
|
+
l = $sample_config_obj.load
|
59
|
+
Pry::ColorPrinter.pp(l)
|
57
60
|
|
58
|
-
|
59
|
-
|
61
|
+
puts "$sample_config_obj: #{$sample_config_obj}"
|
62
|
+
#config_obj.load # _sample_version
|
60
63
|
end
|
61
64
|
|
65
|
+
|
66
|
+
# def teardown
|
67
|
+
# puts :TEAR_DOWN_TODO
|
68
|
+
# end
|
69
|
+
|
62
70
|
end
|
data/test/test_local_folder.rb
CHANGED
@@ -21,8 +21,11 @@ class LocalFolderTest < Minitest::Test
|
|
21
21
|
def tear_up
|
22
22
|
include Storazzo::Colors
|
23
23
|
puts yellow("LocalFolderTest: tear up")
|
24
|
-
#$
|
25
|
-
|
24
|
+
#$config_useless = Storazzo::RicDiskConfig.instance()
|
25
|
+
$config = Storazzo::RicDiskSampleConfig.instance()
|
26
|
+
$config_load = $config.load()
|
27
|
+
puts $config.to_verbose_s
|
28
|
+
|
26
29
|
# my_class = Storazzo::RicDisk::LocalFolder
|
27
30
|
# my_obj = Storazzo::RicDisk::LocalFolder
|
28
31
|
end
|
@@ -43,7 +46,7 @@ class LocalFolderTest < Minitest::Test
|
|
43
46
|
|
44
47
|
# To only test this:
|
45
48
|
# $ ruby -I test test/test_local_folder.rb -n test_first_directory_parsing_actually_works
|
46
|
-
def
|
49
|
+
def TODO_test_1_first_directory_parsing_actually_works()
|
47
50
|
# include module
|
48
51
|
|
49
52
|
#p $vediamo_se_funge
|
@@ -70,7 +73,12 @@ class LocalFolderTest < Minitest::Test
|
|
70
73
|
# )
|
71
74
|
end
|
72
75
|
|
73
|
-
def
|
76
|
+
def test_vars_transporeted_across_teraup_and_tests
|
77
|
+
puts $config_load
|
78
|
+
puts $config
|
79
|
+
end
|
80
|
+
|
81
|
+
def TODO_test_2_iterate_through_file_list_for_disks
|
74
82
|
#p $vediamo_se_funge
|
75
83
|
puts("(#{__FILE__}) WEIRD THING: This test is flaky. SKipping for now until I complete the LocalFolder.parse() code")
|
76
84
|
folders = Storazzo::Media::LocalFolder.list_all
|
@@ -96,4 +104,18 @@ class LocalFolderTest < Minitest::Test
|
|
96
104
|
"parse on LocalFolder should create file '#{stats_file}'"
|
97
105
|
)
|
98
106
|
end
|
107
|
+
|
108
|
+
def test_readonly_folder
|
109
|
+
test_dir = "/etc/"
|
110
|
+
disk = Storazzo::Media::LocalFolder.new(test_dir)
|
111
|
+
stats_file = disk.stats_filename_default_fullpath
|
112
|
+
config = Storazzo::RicDiskSampleConfig.instance()
|
113
|
+
config.load
|
114
|
+
config.iterate_through_file_list_for_disks([test_dir])
|
115
|
+
assert(
|
116
|
+
not(File.exists?(stats_file)),
|
117
|
+
"parse on LocalFolder should NOT create file '#{stats_file}' but another in another TODO place"
|
118
|
+
)
|
119
|
+
# ...
|
120
|
+
end
|
99
121
|
end
|