storazzo 0.4.2 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +7 -4
  3. data/Makefile +20 -1
  4. data/README.md +23 -0
  5. data/Rakefile +35 -8
  6. data/VERSION +1 -1
  7. data/bin/hello-storazzo +5 -0
  8. data/bin/ricdisk-magic +50 -57
  9. data/bin/stats-with-md5 +268 -297
  10. data/lib/storazzo/colors.rb +43 -45
  11. data/lib/storazzo/common.rb +80 -17
  12. data/lib/storazzo/debug.rb +5 -8
  13. data/lib/storazzo/hashify.rb +44 -43
  14. data/lib/storazzo/main.rb +44 -40
  15. data/lib/storazzo/media/abstract_ric_disk.rb +163 -104
  16. data/lib/storazzo/media/gcs_bucket.rb +51 -15
  17. data/lib/storazzo/media/local_folder.rb +43 -46
  18. data/lib/storazzo/media/mount_point.rb +12 -2
  19. data/lib/storazzo/ric_disk.rb +223 -251
  20. data/lib/storazzo/ric_disk_config.rb +230 -193
  21. data/lib/storazzo/ric_disk_sample_config.rb +12 -16
  22. data/lib/storazzo/ric_disk_statsfile.rb +17 -16
  23. data/lib/storazzo/ric_disk_ugly.rb +35 -38
  24. data/lib/storazzo/version.rb +7 -7
  25. data/lib/storazzo.rb +34 -29
  26. data/storazzo.gemspec +22 -20
  27. data/test/media/test_abstract_ric_disk.rb +19 -0
  28. data/test/media/test_gcs_bucket.rb +58 -0
  29. data/test/media/test_local_folder.rb +145 -0
  30. data/test/media/test_mount_point.rb +25 -0
  31. data/test/test_ric_disk.rb +16 -0
  32. data/test/test_ric_disk_config.rb +20 -29
  33. data/test/test_ric_disk_stats_file.rb +13 -14
  34. data/test/test_storazzo.rb +26 -26
  35. data/var/dumps/file_stat.linux.yaml +15 -0
  36. data/var/dumps/file_stat.macosx.yaml +15 -0
  37. data/var/test/disks/disk02-full/Rakefile +13 -0
  38. data/var/test/disks/ricdisk_stats_v11.rds +11 -0
  39. metadata +38 -10
  40. data/test/test_gcs_bucket.rb +0 -70
  41. data/test/test_local_folder.rb +0 -121
@@ -3,24 +3,24 @@
3
3
  # module Storazzo
4
4
  # class Storazzo::RicDiskUgly
5
5
  # RICDISK_VERSION = "1.0ugly"
6
- # DEFAULT_MEDIA_DIRS = %w{
7
- # /media/riccardo/
8
- # /Volumes/
9
- # /mnt/
6
+ # DEFAULT_MEDIA_DIRS = %w{
7
+ # /media/riccardo/
8
+ # /Volumes/
9
+ # /mnt/
10
10
  # ~/storazzo/var/test/disks/
11
11
  # }.append(Storazzo.root + "/var/test/disks/")
12
12
 
13
13
  # include Hashify
14
14
  # extend Storazzo::Colors
15
-
15
+
16
16
  # # todo substitute with protobuf..
17
17
  # attr_accessor :name, :description, :ricdisk_file, :local_mountpoint, :wr
18
-
18
+
19
19
  # def self.interesting_mount_points(opts={})
20
20
  # #https://unix.stackexchange.com/questions/177014/showing-only-interesting-mount-points-filtering-non-interesting-types
21
21
  # `mount | grep -Ev 'type (proc|sysfs|tmpfs|devpts|debugfs|rpc_pipefs|nfsd|securityfs|fusectl|devtmpfs) '`.split(/\n+/)
22
22
  # end
23
-
23
+
24
24
  # def initialize(path, ricdisk_file)
25
25
  # puts "[DEB] RicDiskUgly initialize.. path=#{path}"
26
26
  # @local_mountpoint = path
@@ -38,15 +38,15 @@
38
38
  # find_info_from_mount(path)
39
39
  # find_info_from_df()
40
40
  # end
41
-
41
+
42
42
  # def ricdisk_absolute_path
43
43
  # @local_mountpoint + "/" + @ricdisk_file
44
44
  # end
45
-
45
+
46
46
  # def add_tag(tag)
47
47
  # @tags += ", #{tag}"
48
48
  # end
49
-
49
+
50
50
  # # might have other things in the future...
51
51
  # def find_info_from_mount(path)
52
52
  # mount_table_lines = interesting_mount_points()
@@ -55,9 +55,9 @@
55
55
  # next if line =~ /^map /
56
56
  # dev, on, mount_path, mode = line.split(/ /)
57
57
  # if mount_path==path
58
- # mount_line = line
58
+ # mount_line = line
59
59
  # else
60
- # @info_from_mount = false
60
+ # @info_from_mount = false
61
61
  # end
62
62
  # end
63
63
  # @info_from_mount = ! (mount_line.nil?)
@@ -69,7 +69,7 @@
69
69
  # add_tag(:synology) if @remote_mountpoint.match('1.0.1.10')
70
70
  # end
71
71
  # end
72
-
72
+
73
73
  # def find_info_from_df()
74
74
  # path = @local_mountpoint
75
75
  # df_info = `df -h "#{path}"`
@@ -78,15 +78,13 @@
78
78
  # raise "I need exactly TWO lines! Or no info is served here..." unless lines.size == 2
79
79
  # mount, @size_readable, used_size, avail_size, @disk_utilization, other = lines[1].split(/\s+/) # second line..
80
80
  # end
81
-
82
-
83
-
81
+
84
82
  # def self.sbrodola_ricdisk(subdir)
85
83
  # # given a path, if .ricdisk exists i do stuff with it..
86
84
  # disk_info = nil
87
85
  # unless self.ok_dir?(subdir)
88
86
  # puts("Nothing for me here. Existing")
89
- # return
87
+ # return
90
88
  # end
91
89
  # if File.exists?( "#{subdir}/.ricdisk") and File.empty?( "#{subdir}/.ricdisk")
92
90
  # deb("Interesting1. Empty file! Now I write YAML with it.")
@@ -116,12 +114,12 @@
116
114
  # #puts(white `cat "#{subdir}/.ricdisk"`)
117
115
  # end
118
116
  # end
119
-
117
+
120
118
  # # separiamo cosi usiamo meglio...
121
119
  # def self.ok_dir?(subdir)
122
120
  # File.exists?( "#{subdir}/.ricdisk") or File.exists?( "#{subdir}/.ricdisk.yaml")
123
121
  # end
124
-
122
+
125
123
  # def self.obsolescence_seconds file_path
126
124
  # creation_time = File.stat(file_path).ctime
127
125
  # deb("[obsolescence_seconds] File #{file_path}: #{creation_time} - #{(Time.now - creation_time)} seconds ago")
@@ -130,13 +128,13 @@
130
128
  # def self.obsolescence_days(file_path)
131
129
  # return obsolescence_seconds(file_path) / 86400
132
130
  # end
133
-
131
+
134
132
  # def self.backquote_execute(cmd)
135
133
  # # executed a command wrapped by dryrun though
136
134
  # return "DRYRUN backquote_execute(#{cmd})" if $opts[:dryrun]
137
135
  # `#{cmd}`
138
136
  # end
139
-
137
+
140
138
  # def self.upload_to_gcs(file, opts={})
141
139
  # deb("upload_to_gcs(#{file}). TODO(ricc) after breafast upload to GCS : #{file}")
142
140
  # mount_name = file.split('/')[-2]
@@ -152,12 +150,12 @@
152
150
  # # end
153
151
  # ret
154
152
  # end
155
-
153
+
156
154
  # # Create RDS file.
157
155
  # def self.calculate_stats_files(dir, opts={})
158
- # opts_upload_to_gcs = opts.fetch :upload_to_gcs, true
156
+ # opts_upload_to_gcs = opts.fetch :upload_to_gcs, true
159
157
  # full_file_path = "#{dir}/#{$stats_file}"
160
-
158
+
161
159
  # puts("calculate_stats_files(#{white dir}): #{white full_file_path}")
162
160
  # puts "TEST1 DIR EXISTS: #{dir} -> #{File.directory? dir}"
163
161
  # Dir.chdir(dir)
@@ -165,23 +163,23 @@
165
163
  # puts "File '#{$stats_file}' exists already." # - now should see if its too old, like more than 1 week old"
166
164
  # # TODO check for file time...
167
165
  # 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
166
+ # if obsolescence_days(full_file_path) > 7
169
167
  # puts("*** ACHTUNG *** FIle is pretty old. You might consider rotating: #{yellow "mv #{full_file_path} #{full_file_path}_old"}. Or invoke with --force")
170
168
  # end
171
169
  # upload_to_gcs(full_file_path) if opts_upload_to_gcs
172
170
  # else
173
- # puts "Crunching data stats from '#{dir}' into '#{$stats_file}' ... please bear with me.. [maybe file didnt exist, maybe $opts[:force] is true]"
171
+ # puts "Crunching data stats from '#{dir}' into '#{$stats_file}' ... please bear with me.. [maybe file didnt exist, maybe $opts[:force] is true]"
174
172
  # command = "find . -print0 | xargs -0 stats-with-md5.rb --no-color | tee '#{full_file_path}'"
175
173
  # puts("[#{`pwd`.chomp}] Executing: #{azure command}")
176
174
  # ret = backquote_execute command
177
175
  # puts "Done. #{ret.split("\n").count} files processed."
178
176
  # end
179
177
  # end
180
-
178
+
181
179
  # def self.find_active_dirs(base_dirs=nil, also_mountpoints=true)
182
- # base_dirs = DEFAULT_MEDIA_DIRS if base_dirs.nil?
180
+ # base_dirs = DEFAULT_MEDIA_DIRS if base_dirs.nil?
183
181
  # active_dirs = []
184
- # base_dirs.each do |ugly_dir|
182
+ # base_dirs.each do |ugly_dir|
185
183
  # # 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
184
  # dir = File.expand_path(ugly_dir)
187
185
  # begin
@@ -189,12 +187,12 @@
189
187
  # # puts "TEST2 DIR EXISTS: #{dir} -> #{Dir.exists?(dir)}"
190
188
  # unless Dir.exists?(dir)
191
189
  # deb "Dir doesnt exist, skipping: #{dir}"
192
- # next
190
+ # next
193
191
  # end
194
- # Dir.chdir(dir)
192
+ # Dir.chdir(dir)
195
193
  # x = Dir.glob('*').select {|f| File.directory? f}
196
194
  # subdirs = x.map{|subdir| "#{dir}#{subdir}"}
197
- # subdirs.each{|subdir|
195
+ # subdirs.each{|subdir|
198
196
  # #puts `ls -al "#{subdir}"`
199
197
  # active_dirs << subdir if self.ok_dir?(subdir)
200
198
  # }
@@ -204,9 +202,9 @@
204
202
  # ensure # will always get executed
205
203
  # #deb 'Always gets executed.'
206
204
  # #x = []
207
- # end
205
+ # end
208
206
  # end
209
-
207
+
210
208
  # if also_mountpoints
211
209
  # =begin
212
210
  # Example output from mount:
@@ -237,15 +235,14 @@
237
235
  # puts("find_active_dirs(): found dirs " + green(active_dirs))
238
236
  # return active_dirs
239
237
  # end
240
-
241
238
 
242
239
  # def analyze_local_system()
243
- # puts :TODO
240
+ # puts :TODO
244
241
  # puts "1. Interesting Mounts: #{green interesting_mount_points}"
245
242
  # puts "2. Sbrodoling everything: :TODO"
246
243
  # # find_info_from_mount(path)
247
244
  # # find_info_from_df()
248
245
  # end
249
-
246
+
250
247
  # end
251
- # end
248
+ # end
@@ -1,12 +1,12 @@
1
1
  # copied from https://github.com/rails/strong_parameters/edit/master/lib/strong_parameters/version.rb
2
2
  # I;'m copying the DHH philosophy here.
3
3
  module Storazzo
4
- DHH_VERSION = "0.2.3_TODOFileRead" # TODO file.read ../../VERSION . chomp
5
- RICC_VERSION = File.read("../VERSION").chomp
4
+ # DHH_VERSION = "0.2.3._TODOFileRead.1" # TODO file.read ../../VERSION . chomp
5
+ RICC_VERSION = File.read("../VERSION").chomp
6
6
 
7
- public
8
- def self.version
9
- RICC_VERSION
10
- end
7
+ public
8
+
9
+ def self.version
10
+ RICC_VERSION
11
+ end
11
12
  end
12
-
data/lib/storazzo.rb CHANGED
@@ -1,51 +1,56 @@
1
1
  # Inspired from https://guides.rubygems.org/make-your-own-gem/#introduction
2
2
 
3
3
  module Storazzo
4
- #VERSION = File.read('./VERSION').chomp # "10.0.0"
5
- #require 'storazzo/translator'
4
+ # VERSION = File.read('./VERSION').chomp # "10.0.0"
5
+ # require 'storazzo/translator'
6
6
 
7
- def latest_parser_version
8
- "1.2"
9
- end
7
+ def latest_parser_version
8
+ '1.2'
9
+ end
10
10
 
11
- # Finds RAILS_ROOT for Storazzo Gem. Copied from:
12
- # https://stackoverflow.com/questions/10132949/finding-the-gem-root
13
- def self.root
14
- File.expand_path '../..', __FILE__
15
- end
11
+ # Finds RAILS_ROOT for Storazzo Gem. Copied from:
12
+ # https://stackoverflow.com/questions/10132949/finding-the-gem-root
13
+ def self.root
14
+ File.expand_path '..', __dir__
15
+ end
16
16
 
17
- def self.version
18
- File.read(self.root + '/VERSION').chomp # "10.0.0"
19
- end
17
+ def self.version
18
+ File.read(root + '/VERSION').chomp # "10.0.0"
19
+ end
20
20
 
21
- # alias_method :VERSION, :version
22
- def self.VERSION
23
- version
24
- end
21
+ # alias_method :VERSION, :version
22
+ def self.VERSION
23
+ version
24
+ end
25
25
 
26
- def self.storazzo_classes
27
- [42, 43]
28
- end
29
- end
26
+ def self.storazzo_classes
27
+ [42, 43]
28
+ end
29
+ end
30
30
 
31
31
  # nice to paste nice output
32
32
  require 'pp'
33
+ # require 'require_all'
34
+
35
+ # require_all './' , 'media/'
36
+ # require_all 'lib/**/*.rb'
37
+ # require_rel '.', 'media'
38
+ Dir[File.dirname(__FILE__) + '/../lib/*.rb'].each do |file|
39
+ puts "+ Requiring... #{file}"
40
+ require File.basename(file, File.extname(file))
41
+ end
33
42
 
34
43
  require 'storazzo'
35
44
  require 'storazzo/common'
36
45
  require 'storazzo/colors'
37
46
  require 'storazzo/hashify'
38
47
  require 'storazzo/ric_disk' # NEW and will build from ground up using multiple files..
39
- #require 'storazzo/ric_disk/asbtract_ric_disk'
40
48
  require 'storazzo/media/abstract_ric_disk'
41
- require 'storazzo/media/gcs_bucket'
42
- require 'storazzo/media/local_folder'
49
+ require 'storazzo/media/gcs_bucket'
50
+ require 'storazzo/media/local_folder'
51
+ require 'storazzo/media/mount_point'
43
52
  require 'storazzo/ric_disk_ugly' # OLD and 90% working
44
- require 'storazzo/ric_disk_config' # => RicDiskConfif
53
+ require 'storazzo/ric_disk_config' # => RicDiskConfif
45
54
  require 'storazzo/ric_disk_sample_config' # => NOTHING!!
46
- #require 'storazzo/ric_disk_config_example' # => NEW!!!
47
55
  require 'storazzo/ric_disk_statsfile'
48
56
  require 'storazzo/main'
49
- #require 'storazzo/translator'
50
-
51
- #puts Storazzo::Main.say_hi
data/storazzo.gemspec CHANGED
@@ -1,21 +1,23 @@
1
1
  Gem::Specification.new do |s|
2
- s.name = "storazzo"
3
- # TOSDO: copy approach from here to dry version calculating: https://github.com/rails/strong_parameters/blob/master/strong_parameters.gemspec#L15
4
- s.version = File.read("VERSION").chomp # TODO cat version File.read(@,.VERSION).chomp
5
- s.summary = "storazzo is an amazing gem. Code is in https://github.com/palladius/storazzo"
6
- s.description = "A simple gem to manage your external hard drives and extract MD5 and common stuff from them."
7
- s.authors = ["Riccardo Carlesso"]
8
- s.email = "name dot surname at popular Google-owned Mail"
9
- # Autoglob as per https://stackoverflow.com/questions/11873294/determining-the-gems-list-of-files-for-the-specification
10
- s.files = %w(Gemfile LICENSE README.md Makefile Rakefile storazzo.gemspec VERSION) + Dir["{bin,lib,test,var}/**/*"]
11
- s.test_files = Dir["test/**/*"] + Dir["var/test/**/*"]
12
- s.executables = [
13
- "ricdisk-magic",
14
- "stats-with-md5",
15
- ]
16
-
17
- s.homepage = "https://rubygems.org/gems/storazzo" # maybe https://github.com/palladius/storazzo
18
- s.license = "MIT"
19
-
20
- #s.add_dependency "activesupport", "~> 3.0"
21
- end
2
+ s.name = "storazzo"
3
+ # TOSDO: copy approach from here to dry version calculating: https://github.com/rails/strong_parameters/blob/master/strong_parameters.gemspec#L15
4
+ s.version = File.read("VERSION").chomp # TODO cat version File.read(@,.VERSION).chomp
5
+ s.summary = "storazzo is an amazing gem. Code is in https://github.com/palladius/storazzo"
6
+ s.description = "A simple gem to manage your external hard drives and extract MD5 and common stuff from them."
7
+ s.authors = ["Riccardo Carlesso"]
8
+ s.email = "name dot surname at popular Google-owned Mail"
9
+ # Autoglob as per https://stackoverflow.com/questions/11873294/determining-the-gems-list-of-files-for-the-specification
10
+ s.files = %w(Gemfile LICENSE README.md Makefile Rakefile storazzo.gemspec
11
+ VERSION) + Dir["{bin,lib,test,var}/**/*"]
12
+ s.test_files = Dir["test/**/*"] + Dir["var/test/**/*"]
13
+ s.executables = [
14
+ # todo: everything in bin/
15
+ "ricdisk-magic",
16
+ "stats-with-md5",
17
+ "hello-storazzo",
18
+ ]
19
+ s.homepage = "https://rubygems.org/gems/storazzo" # maybe https://github.com/palladius/storazzo
20
+ s.license = "MIT"
21
+ # s.add_dependency "activesupport", "~> 3.0"
22
+ s.add_dependency "pry" # , "~> 3.0"
23
+ end
@@ -0,0 +1,19 @@
1
+ # TODO
2
+ require "minitest/autorun"
3
+ require "storazzo"
4
+
5
+ # require 'pry' # must install the gem... but you ALWAYS want pry installed anyways
6
+
7
+ class AbstractRicDiskTest < Minitest::Test
8
+ include Storazzo::Common
9
+
10
+ def TODO_test_super_duper_list_all_with_type_returns_something
11
+ deb "This would be already... something :) it means they're all implemented"
12
+ ret = Storazzo::Media::AbstractRicDisk.super_duper_list_all_with_type
13
+ assert(
14
+ ret.class,
15
+ Array,
16
+ "test_super_duper_list_all_with_type_returns_something should return an array.."
17
+ )
18
+ end
19
+ end
@@ -0,0 +1,58 @@
1
+ require "minitest/autorun"
2
+ require "storazzo"
3
+ require "storazzo/ric_disk"
4
+ require "storazzo/ric_disk_config"
5
+ require 'storazzo/colors'
6
+ require "storazzo/media/local_folder"
7
+
8
+ require 'pry' # must install the gem... but you ALWAYS want pry installed anyways
9
+
10
+ class GcsBucketTest < Minitest::Test
11
+ include Storazzo::Common
12
+
13
+ def setup # tear_up
14
+ deb "[GcsBucketTest] TEAR_UP with sample Config"
15
+ # removeme = Storazzo::RicDiskConfig.instance()
16
+ $sample_config_obj = Storazzo::RicDiskSampleConfig.instance()
17
+ $sample_config_hash = $sample_config_obj.load()
18
+ deb "[GcsBucketTest] TEAR_UP config_obj: '''#{$sample_config_obj}'''"
19
+ end
20
+
21
+ def test_buckets_are_the_two_i_know
22
+ # copied from etc/sample.yaml :)
23
+ expected_list = %w{
24
+ gs://my-local-backup/storazzo/backups/
25
+ gs://my-other-bucket/
26
+ }
27
+ actual_list = Storazzo::RicDisk::GcsBucket.list_all($sample_config_obj)
28
+ assert_equal(
29
+ expected_list.sort,
30
+ actual_list.sort,
31
+ "These are the two lists from Sample Storazzo Config"
32
+ )
33
+ end
34
+
35
+ def test_import_sample_class_correctly
36
+ # require "storazzo/ric_disk_sample_config" rescue nil
37
+ # require "storazzo/ric_disk_config"
38
+
39
+ # puts Storazzo.class
40
+ deb " Storazzo.constants: #{Storazzo.constants}"
41
+ # puts Storazzo::RicDiskSampleConfig
42
+ # config_obj = Storazzo::RicDiskSampleConfig.instance()
43
+ if_deb? do
44
+ Pry::ColorPrinter.pp($sample_config_obj.to_verbose_s())
45
+ end
46
+ # pp green(config_obj.to_verbose_s())
47
+
48
+ l = $sample_config_obj.load
49
+ Pry::ColorPrinter.pp(l) if $DEBUG
50
+
51
+ puts "$sample_config_obj: #{$sample_config_obj}"
52
+ # config_obj.load # _sample_version
53
+ end
54
+
55
+ # def teardown
56
+ # puts :TEAR_DOWN_TODO
57
+ # end
58
+ end
@@ -0,0 +1,145 @@
1
+ require "minitest/autorun"
2
+ require "storazzo"
3
+ require 'storazzo/common'
4
+ require "storazzo/ric_disk"
5
+ require "storazzo/ric_disk_config"
6
+ require 'storazzo/colors'
7
+ require "storazzo/media/local_folder"
8
+
9
+ class LocalFolderTest < Minitest::Test
10
+ # include Storazzo::Colors
11
+ # include Storazzo::Common
12
+ include Storazzo::Common
13
+
14
+ # def test_fail_on_purpOSE # test_storazzo_hi_with_argument
15
+ # assert_match 42, 42 , "change me when it failes from makefile"
16
+ # #"Hello from Storazzo", Storazzo::Main.hi("ruby this should fail")
17
+ # #assert_match "ruby this should fail", Storazzo::Main.hi("ruby this should fail")
18
+ # end
19
+ def tear_up
20
+ include Storazzo::Colors
21
+ puts yellow("LocalFolderTest: tear up")
22
+ # $config_useless = Storazzo::RicDiskConfig.instance()
23
+ $config = Storazzo::RicDiskSampleConfig.safe_instance()
24
+ $config_load = $config.load()
25
+ puts $config.to_verbose_s
26
+
27
+ # my_class = Storazzo::RicDisk::LocalFolder
28
+ # my_obj = Storazzo::RicDisk::LocalFolder
29
+ end
30
+
31
+ def test_show_all_shouldnt_fail_and_should_return_a_non_empty_array
32
+ assert_equal(Array, Storazzo::Media::LocalFolder.list_all.class,
33
+ "Storazzo::RicDisk::LocalFolder.list_all should return an Array")
34
+ assert(Storazzo::Media::LocalFolder.list_all.size > 0, "Array size should be >0")
35
+ # puts Storazzo::Media::LocalFolder.list_all
36
+ end
37
+
38
+ def test_list_all_returns_an_array_of_real_directories
39
+ dirs = Storazzo::Media::LocalFolder.list_all
40
+ dirs.each do |mydir|
41
+ assert_equal(String, mydir.class, "Dir should be a String representing an existing directory")
42
+ assert(File.directory?(mydir), "Dir should be a file of type 'directory'")
43
+ end
44
+ end
45
+
46
+ # To only test this:
47
+ # $ ruby -I test test/test_local_folder.rb -n test_first_directory_parsing_actually_works
48
+ def test_1_first_directory_parsing_actually_works()
49
+ # include module
50
+
51
+ # p $vediamo_se_funge
52
+ puts("(#{__FILE__}) WEIRD THING: This test is flaky. SKipping for now until I complete the LocalFolder.parse() code")
53
+ folders = Storazzo::Media::LocalFolder.list_all
54
+ puts "Folders: #{folders}"
55
+ config = Storazzo::RicDiskSampleConfig.safe_instance()
56
+ puts "config1: #{config}"
57
+ puts "config2: #{config.load}"
58
+ test_dir = folders.first
59
+ puts "test_first_directory_parsing_actually_works() TestDir: #{test_dir}"
60
+ puts yellow "TEST S:M:LF methods: #{folders}" # methods
61
+
62
+ disk = Storazzo::Media::LocalFolder.new(test_dir)
63
+ stats_file = disk.stats_filename_default_fullpath
64
+ puts "stats_file: #{stats_file}"
65
+ disk.parse()
66
+ deb "config: ''#{config}''"
67
+ # config.iterate_through_file_list_for_disks([test_dir])
68
+ # assert(
69
+ # File.exists?(stats_file),
70
+ # "parse on LocalFolder should create file '#{stats_file}'"
71
+ # )
72
+ end
73
+
74
+ def test_vars_transporeted_across_teraup_and_tests
75
+ puts $config_load
76
+ puts $config
77
+ end
78
+
79
+ def test_2_iterate_through_file_list_for_disks
80
+ # puts("(#{__FILE__}) WEIRD THING: This test is flaky. SKipping for now until I complete the LocalFolder.parse() code")
81
+ folders = Storazzo::Media::LocalFolder.list_all
82
+ puts "Folders: #{folders}"
83
+ config = Storazzo::RicDiskSampleConfig.safe_instance()
84
+ config.load
85
+ puts "config1: #{config}"
86
+ puts "config2: #{config.load}"
87
+ test_dir = folders.first
88
+ puts "test_first_directory_parsing_actually_works() TestDir: #{test_dir}"
89
+ puts "TEST S:M:LF methods: #{folders}" # methods
90
+
91
+ disk = Storazzo::Media::LocalFolder.new(test_dir)
92
+ stats_file = disk.stats_filename_default_fullpath
93
+ # puts "stats_file: #{stats_file}"
94
+ # disk.parse()
95
+ # puts "[DEB] config: ''#{config}''"
96
+
97
+ # TEST2: config + iterate
98
+ config.iterate_through_file_list_for_disks([test_dir])
99
+ assert(
100
+ File.exists?(stats_file),
101
+ "parse on LocalFolder should create file '#{stats_file}'"
102
+ )
103
+ end
104
+
105
+ def test_readonly_directory_creates_configfile_outside_of_dir
106
+ test_dir = "/etc/ssh/"
107
+ disk = Storazzo::Media::LocalFolder.new(test_dir)
108
+ stats_file = disk.stats_filename_default_fullpath
109
+ config = Storazzo::RicDiskSampleConfig.safe_instance()
110
+ config.load
111
+ config.iterate_through_file_list_for_disks([test_dir])
112
+ assert(
113
+ not(File.exists?(stats_file)),
114
+ "parse on LocalFolder should NOT create file '#{stats_file}' but another in another TODO place"
115
+ )
116
+ # ...
117
+ end
118
+
119
+ def test_readonly_directory_is_indeed_readonly
120
+ test_dir = "/etc/ssh"
121
+ readonly_rdisk = Storazzo::Media::LocalFolder.new(test_dir)
122
+ if_deb? do
123
+ ppp(readonly_rdisk.to_verbose_s)
124
+ end
125
+ assert_equal(
126
+ readonly_rdisk.wr,
127
+ false,
128
+ "Folder #{test_dir} is NOT writeble to the author's knowledge."
129
+ )
130
+ # ...
131
+ end
132
+
133
+ def test_writeable_tmp_directory_is_indeed_writeable
134
+ test_dir = '/tmp/'
135
+ # test_dir = '~'
136
+ writeable_rdisk = Storazzo::Media::LocalFolder.new(test_dir)
137
+ # writeable_rdisk = Storazzo::RicDisk.new(test_dir)
138
+ if_deb? { ppp(writeable_rdisk.to_verbose_s) }
139
+ assert_equal(
140
+ true,
141
+ writeable_rdisk.wr,
142
+ "Folder #{test_dir} is INDEED writeble to the author's knowledge, although triggers lot of noise => wr=#{writeable_rdisk.wr}"
143
+ )
144
+ end
145
+ end
@@ -0,0 +1,25 @@
1
+ require "minitest/autorun"
2
+ require "storazzo"
3
+
4
+ # require 'pry' # must install the gem... but you ALWAYS want pry installed anyways
5
+
6
+ class MediaMountPointTest < Minitest::Test
7
+ def test_test_in_subfolder
8
+ # raise "Does this even work?!?"
9
+ puts "Looks like this only works if you run this: ruby -I test test/media/test_media_mount_point.rb"
10
+ end
11
+
12
+ def test_mount_point_creation
13
+ # x = Storazzo::Media::MountPoint.new
14
+ # assert class inherits from ...
15
+ skip "TODO Code is still missing but TODO implement that this class inherits from **ther class"
16
+ # assert(
17
+ # false,
18
+ # "TODO Code is still missing but TODO implement that this class inherits from **ther class"
19
+ # )
20
+ end
21
+
22
+ def test_what_skip_means
23
+ skip 'Check for affiliate link, credit card details, pledge history. Foujnd example online. Please Riccardo fix'
24
+ end
25
+ end
@@ -0,0 +1,16 @@
1
+ require "minitest/autorun"
2
+ require "storazzo"
3
+
4
+ class RicDiskTest < Minitest::Test
5
+ def TODO_test_factory_works_for_gcs
6
+ # actual_list = Storazzo::RicDisk::GcsBucket.list_all($sample_config_obj)
7
+ rd1 = Storazzo::RicDisk.new('Doesnt accept a string, should be a Gcs Something... Plus why is this test here and not under TestGcsBucket?!?')
8
+ hash = rd1.to_verbose_s()
9
+ pp hash
10
+ assert_equal(
11
+ hash.class,
12
+ Hash,
13
+ "rd1.to_verbose_s should return a Hash"
14
+ )
15
+ end
16
+ end