storazzo 0.5.1 → 0.6.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.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +7 -5
  3. data/LICENSE +20 -1
  4. data/Makefile +9 -5
  5. data/Rakefile +22 -9
  6. data/VERSION +1 -1
  7. data/bin/hello-storazzo +1 -0
  8. data/bin/ricdisk-magic +33 -30
  9. data/bin/stats-with-md5 +146 -176
  10. data/bin/storazzo +158 -0
  11. data/bin/storazzo-symlink.rb +1 -0
  12. data/bin/storazzo-util +1 -0
  13. data/lib/storazzo/colors.rb +77 -36
  14. data/lib/storazzo/common.rb +72 -65
  15. data/lib/storazzo/debug.rb +2 -0
  16. data/lib/storazzo/hashify.rb +7 -5
  17. data/lib/storazzo/main.rb +59 -49
  18. data/lib/storazzo/media/abstract_ric_disk.rb +190 -161
  19. data/lib/storazzo/media/gcs_bucket.rb +78 -47
  20. data/lib/storazzo/media/local_folder.rb +56 -42
  21. data/lib/storazzo/media/mount_point.rb +22 -6
  22. data/lib/storazzo/ric_disk.rb +386 -383
  23. data/lib/storazzo/ric_disk_config.rb +229 -197
  24. data/lib/storazzo/ric_disk_sample_config.rb +26 -24
  25. data/lib/storazzo/ric_disk_statsfile.rb +19 -17
  26. data/lib/storazzo/ric_disk_ugly.rb +1 -0
  27. data/lib/storazzo/version.rb +3 -3
  28. data/lib/storazzo.rb +6 -7
  29. data/storazzo.gemspec +31 -19
  30. data/test/benchmark/for_future_use.rb +15 -0
  31. data/test/benchmark/test_hashing_functions-speed.rb +17 -0
  32. data/test/bin/new-idea.rb +17 -0
  33. data/test/bin/storazzo.rb +25 -0
  34. data/test/media/test_abstract_ric_disk.rb +6 -4
  35. data/test/media/test_gcs_bucket.rb +55 -21
  36. data/test/media/test_local_folder.rb +28 -29
  37. data/test/media/test_mount_point.rb +7 -5
  38. data/test/test_ric_disk.rb +8 -6
  39. data/test/test_ric_disk_config.rb +13 -12
  40. data/test/test_ric_disk_stats_file.rb +5 -3
  41. data/test/test_storazzo.rb +6 -4
  42. data/var/test/disks/disk02-full/Rakefile +7 -5
  43. data/var/test/disks/ricdisk_stats_v11.rds +11 -22
  44. metadata +22 -22
@@ -1,165 +1,194 @@
1
- module Storazzo::Media
2
- class Storazzo::Media::AbstractRicDisk
3
- # include Storazzo::Common
4
- extend Storazzo::Common
5
-
6
- # DefaultStatsFilename = Storazzo::RicDiskStatsFile.default_name
7
-
8
- # looks like there's not Abstract Class in Ruby, but also SO says he best
9
- # way to do this is this:
10
-
11
- # attr_accessor :name, :description, :ricdisk_file, :local_mountpoint, :wr, :path, :ricdisk_file_empty, :size, :active_dirs
12
- attr_accessor :description
13
-
14
- ########################
15
- # Abstract methods START
16
- ########################
17
- def initialize(local_mount)
18
- deb "[AbstractRicDisk.init()] Some child of AbstractRicDisk (#{self}) called me! Yummie." # disable when you dont need me anymore..
19
- @description ||= "Not provided"
20
- # validate
21
- end
22
-
23
- def self.list_all
24
- raise "[AbstractRicDiskc::self.list_all] You should override this, says StackOverflow and Riccardo"
25
- end
26
-
27
- def self.list_all_with_type
28
- raise "[AbstractRicDiskc::self.list_all_with_type] You should override this, says StackOverflow and Riccardo"
29
- end
30
-
31
- def self.super_duper_list_all_with_type
32
- deb "Would be cool to be able to enumerate them all.."
33
- GcsBucket.list_all_with_type +
34
- MountPoint.list_all_with_type +
35
- LocalFolder.list_all_with_type
36
- end
37
-
38
- def parse(opts = {})
39
- raise "[AbstractRicDiskc::parse] You should override this, says StackOverflow and Riccardo"
40
- end
41
-
42
- def writeable?
43
- raise "[AbstractRicDiskc::writeable] You should override this in #{self.class}, says StackOverflow and Riccardo"
44
- end
45
-
46
- def get_local_mountpoint
47
- # raise "[AbstractRicDiskc::get_local_mountpoint] You should override this, says StackOverflow and Riccardo"
48
- raise "You forgot to set local_mountpoint in the constructor for your class, you cheeky little one!" if local_mountpoint.nil?
49
-
50
- local_mountpoint
51
- end
52
-
53
- def check_implemented_correctly
54
- # raise "[AbstractRicDiskc] You should override this, says StackOverflow and Riccardo"
55
- raise "no @local_mountpoint" unless exists?(@local_mountpoint)
56
- end
57
- ########################
58
- # Abstract methods END
59
- ########################
60
-
61
- ########################
62
- # Automated methods now...
63
- ########################
64
- def stats_file_smart_fullpath # stats_file_default_location()
65
- # if its writeable... if not we'll think about it later.
66
- if writeable?
67
- return "#{get_local_mountpoint}/#{self.default_stats_filename}"
68
- else
69
- # if not writeable, I will:
70
- # 1. create a dir based on its unique format.
71
- # 2. create a file of same look and feel (alternative - used a DASH)
72
- return "TODO FIXME {get_local_folder}/#{unique_id}::#{self.default_stats_filename}"
73
- # "{get_local_folder}"/#{unique_id}/#{Storazzo::RicDiskStatsFile.default_name}"
74
- end
75
- end
76
-
77
- # Needs to be some unique id based on its thingy, but might change in the future:
78
- # Solutions:
79
- # {PHILOSOPHY}::{ID}
80
- def unique_id
81
- # Expand path to make it as unique as possible...
82
- hash = Digest::MD5.hexdigest(File.expand_path(get_local_mountpoint))
83
- "MD5::v1::#{hash}"
84
- end
85
-
86
- def to_s(verbose = false)
87
- return to_verbose_s() if verbose
88
-
89
- readable_class = self.class.to_s.split('::').last # Storazzo::Media::LocalFolder => LocalFolder
90
- my_keys = self.instance_variables # wow!
91
- "S:M:#{readable_class}(path=#{path}, r/w=#{wr}, keys=#{my_keys})"
92
- end
93
-
94
- def to_verbose_s
95
- h = {}
96
- h[:class] = self.class
97
- h[:unique_id] = self.unique_id
98
- h[:inspect] = self.inspect
99
- h[:to_s] = self.to_s
100
- h[:local_mountpoint] = local_mountpoint
101
- h[:writeable] = self.writeable?
102
- h[:stats_file_smart_fullpath] = stats_file_smart_fullpath
103
- return h
104
- end
105
-
106
- # # Todo check on instances these 3 methods exist
107
- def self.abstract_class_mandatory_methods
108
- %W{
109
- self.list_all
110
- self.list_all_with_type
111
- local_mountpoint
112
- parse
113
- writeable?
114
- }
115
- end
116
-
117
- # Putting here since its same code for MountPoint or generic folder.
118
- def parse_block_storage_folder(opts = {})
119
- # Storazzo::RicDiskUgly.calculate_stats_files(get_local_mountpoint)
120
- rd = Storazzo::RicDisk.new(self)
121
- # Storazzo::RicDisk
122
- rd.compute_stats_files(opts)
123
- # return "42"
124
- end
125
-
126
- def self.default_stats_filename
127
- raise "Unknown Storazzo::RicDiskStatsFile.default_name 1!!" if Storazzo::RicDiskStatsFile.default_name.nil?
128
-
129
- Storazzo::RicDiskStatsFile.default_name
130
- end
131
-
132
- def stats_filename_default_fullpath # if not writeable we need to pick another from stats_file_smart_fullpath()
133
- # REDUNDANT, should use stats_file_smart_fullpath instead except on the writeable? part since it would go recursive otherwise.
134
- my_stats_filename = self.default_stats_filename
135
- # raise "Unknown Storazzo::RicDiskStatsFile.default_name 2 !!" if Storazzo::RicDiskStatsFile.default_name.nil?
136
- "#{local_mountpoint}/#{my_stats_filename}"
137
- end
138
-
139
- def validate(opts = {})
140
- verbose = opts.fetch(:verbose, true)
141
- puts "[VERBOSE] validate(): We're trying to see if your object is valid, across 3 possible sub-classes." if verbose
142
- # 1. check for
143
- raise "Unknown local mount " unless local_mount.is_a?(String)
144
-
145
- # 2. check thaty writeable? is true or false
146
- my_writeable = wr
147
- raise "Writeable is not boolean" unless (my_writeable.is_a? TrueClass or my_writeable.is_a? FalseClass)
148
- end
149
-
150
- # TODO use a proper Factory pattern.
151
- def self.DirFactory(path)
152
- raise "I need a path/directory string: #{path}" unless path.is_a?(String)
153
-
154
- deb "TODO: if coincides with MountPoint, instance THAT"
155
- # if path in Storazzo::Media::MountPoint.list_all_mount_points
156
- # then return ...
157
- if path =~ /^gs:\/\//
158
- deb "Smells like GCS"
159
- return GcsBucket.new(path)
1
+ # frozen_string_literal: true
2
+
3
+ # require "storazzo/ric_disk/abstract_ric_disk"
4
+ # require "storazzo/ric_disk/gcs_bucket"
5
+ # require "gcs_bucket"
6
+ # require "abstract_ric_disk"
7
+
8
+ # This class is an Abstract Class which forces its 3 inquilines to implement
9
+ # a number of functions, namely:
10
+ #
11
+ # def self.list_all()
12
+ # def self.list_all_with_type()
13
+ #
14
+ # Note this needs to work without weird overrides, like:
15
+ #
16
+ # def self.list_all_with_type(config=nil) # BAD
17
+ # def self.list_all_with_type() # GOOD
18
+ #
19
+ #
20
+
21
+ module Storazzo
22
+ module Media
23
+ module Storazzo
24
+ module Media
25
+ class AbstractRicDisk
26
+ # include Storazzo::Common
27
+ extend Storazzo::Common
28
+
29
+ # DefaultStatsFilename = Storazzo::RicDiskStatsFile.default_name
30
+
31
+ # looks like there's not Abstract Class in Ruby, but also SO says he best
32
+ # way to do this is this:
33
+
34
+ # attr_accessor :name, :description, :ricdisk_file, :local_mountpoint, :wr, :path, :ricdisk_file_empty, :size, :active_dirs
35
+ attr_accessor :description
36
+
37
+ ########################
38
+ # Abstract methods START
39
+ ########################
40
+ def initialize(_local_mount)
41
+ deb "[AbstractRicDisk.init()] Some child of AbstractRicDisk (#{self}) called me! Yummie." # disable when you dont need me anymore..
42
+ @description ||= 'Not provided'
43
+ # validate
44
+ end
45
+
46
+ def self.list_all
47
+ raise "[AbstractRicDiskc::self.list_all] You should override this, says StackOverflow and Riccardo. Class=#{self.class}. Self=#{self}"
48
+ end
49
+
50
+ def self.list_all_with_type
51
+ raise "[AbstractRicDisk::self.list_all_with_type] You should override this, says StackOverflow and Riccardo. Class=#{self.class}. Self=#{self}"
52
+ end
53
+
54
+ def self.super_duper_list_all_with_type
55
+ deb 'Would be cool to be able to enumerate them all..'
56
+ GcsBucket.list_all_with_type +
57
+ MountPoint.list_all_with_type +
58
+ LocalFolder.list_all_with_type
59
+ end
60
+
61
+ def parse(_opts = {})
62
+ raise "[AbstractRicDiskc::parse] You should override this, says StackOverflow and Riccardo. Class=#{self.class}."
63
+ end
64
+
65
+ def writeable?
66
+ raise "[AbstractRicDiskc::writeable] You should override this in class=#{self.class}, says StackOverflow and Riccardo"
67
+ end
68
+
69
+ def get_local_mountpoint
70
+ # raise "[AbstractRicDiskc::get_local_mountpoint] You should override this, says StackOverflow and Riccardo"
71
+ raise 'You forgot to set local_mountpoint in the constructor for your class, you cheeky little one!' if local_mountpoint.nil?
72
+
73
+ local_mountpoint
74
+ end
75
+
76
+ def check_implemented_correctly
77
+ # raise "[AbstractRicDiskc] You should override this, says StackOverflow and Riccardo"
78
+ raise 'no @local_mountpoint' unless exists?(@local_mountpoint)
79
+ end
80
+ ########################
81
+ # Abstract methods END
82
+ ########################
83
+
84
+ ########################
85
+ # Automated methods now...
86
+ ########################
87
+ # stats_file_default_location()
88
+ def stats_file_smart_fullpath
89
+ # if its writeable... if not we'll think about it later.
90
+ if writeable?
91
+ "#{get_local_mountpoint}/#{default_stats_filename}"
92
+ else
93
+ # if not writeable, I will:
94
+ # 1. create a dir based on its unique format.
95
+ # 2. create a file of same look and feel (alternative - used a DASH)
96
+ "TODO FIXME {get_local_folder}/#{unique_id}::#{default_stats_filename}"
97
+ # "{get_local_folder}"/#{unique_id}/#{Storazzo::RicDiskStatsFile.default_name}"
98
+ end
99
+ end
100
+
101
+ # Needs to be some unique id based on its thingy, but might change in the future:
102
+ # Solutions:
103
+ # {PHILOSOPHY}::{ID}
104
+ def unique_id
105
+ # Expand path to make it as unique as possible...
106
+ hash = Digest::MD5.hexdigest(File.expand_path(get_local_mountpoint))
107
+ "MD5::v1::#{hash}"
108
+ end
109
+
110
+ def to_s(verbose = false)
111
+ return to_verbose_s if verbose
112
+
113
+ readable_class = self.class.to_s.split('::').last # Storazzo::Media::LocalFolder => LocalFolder
114
+ my_keys = instance_variables # wow!
115
+ "S:M:#{readable_class}(path=#{path}, r/w=#{wr}, keys=#{my_keys})"
116
+ end
117
+
118
+ def to_verbose_s
119
+ h = {}
120
+ h[:class] = self.class
121
+ h[:unique_id] = unique_id
122
+ h[:inspect] = inspect
123
+ h[:to_s] = to_s
124
+ h[:local_mountpoint] = local_mountpoint
125
+ h[:writeable] = writeable?
126
+ h[:stats_file_smart_fullpath] = stats_file_smart_fullpath
127
+ h
128
+ end
129
+
130
+ # # Todo check on instances these 3 methods exist
131
+ def self.abstract_class_mandatory_methods
132
+ %w[
133
+ self.list_all
134
+ self.list_all_with_type
135
+ local_mountpoint
136
+ parse
137
+ writeable?
138
+ ]
139
+ end
140
+
141
+ # Putting here since its same code for MountPoint or generic folder.
142
+ def parse_block_storage_folder(opts = {})
143
+ # Storazzo::RicDiskUgly.calculate_stats_files(get_local_mountpoint)
144
+ rd = Storazzo::RicDisk.new(self)
145
+ # Storazzo::RicDisk
146
+ rd.compute_stats_files(opts)
147
+ # return "42"
148
+ end
149
+
150
+ def self.default_stats_filename
151
+ raise 'Unknown Storazzo::RicDiskStatsFile.default_name 1!!' if Storazzo::RicDiskStatsFile.default_name.nil?
152
+
153
+ Storazzo::RicDiskStatsFile.default_name
154
+ end
155
+
156
+ # if not writeable we need to pick another from stats_file_smart_fullpath()
157
+ def stats_filename_default_fullpath
158
+ # REDUNDANT, should use stats_file_smart_fullpath instead except on the writeable? part since it would go recursive otherwise.
159
+ my_stats_filename = default_stats_filename
160
+ # raise "Unknown Storazzo::RicDiskStatsFile.default_name 2 !!" if Storazzo::RicDiskStatsFile.default_name.nil?
161
+ "#{local_mountpoint}/#{my_stats_filename}"
162
+ end
163
+
164
+ def validate(opts = {})
165
+ opt_verbose = opts.fetch :verbose, false
166
+ pverbose opt_verbose,
167
+ "validate(): [BROKEN] We're trying to see if your object is valid, across 3 possible sub-classes."
168
+ # 1. check for
169
+ raise 'Unknown local mount ' unless local_mount.is_a?(String)
170
+
171
+ # 2. check thaty writeable? is true or false
172
+ my_writeable = wr
173
+ raise 'Writeable is not boolean' unless my_writeable.is_a?(TrueClass) || my_writeable.is_a?(FalseClass)
174
+ end
175
+
176
+ # TODO: use a proper Factory pattern.
177
+ def self.DirFactory(path)
178
+ raise "I need a path/directory string: #{path}" unless path.is_a?(String)
179
+
180
+ deb 'TODO: if coincides with MountPoint, instance THAT'
181
+ # if path in Storazzo::Media::MountPoint.list_all_mount_points
182
+ # then return ...
183
+ if path =~ %r{^gs://}
184
+ deb 'Smells like GCS'
185
+ return GcsBucket.new(path)
186
+ end
187
+ deb 'Smells like LocalFolder :)'
188
+ LocalFolder.new(path)
189
+ end
190
+ end
160
191
  end
161
- deb "Smells like LocalFolder :)"
162
- return LocalFolder.new(path)
163
192
  end
164
193
  end
165
194
  end
@@ -1,58 +1,89 @@
1
- module Storazzo::Media
2
- class Storazzo::RicDisk::GcsBucket
3
- extend Storazzo::Common
1
+ # frozen_string_literal: true
4
2
 
5
- attr_accessor :project_id
3
+ require 'English'
6
4
 
7
- def initialize(local_mount, project_id = nil)
8
- deb "[Storazzo::Media::GcsBucket] initialize"
5
+ module Storazzo
6
+ module Media
7
+ # class Storazzo::Media::AbstractRicDisk
8
+ module Storazzo
9
+ module Media
10
+ class GcsBucket < Storazzo::Media::AbstractRicDisk
11
+ extend Storazzo::Common
9
12
 
10
- @local_mountpoint = File.expand_path(local_mount)
11
- @description = "MountPoint in '#{local_mount}' pointing at TODO with mount options = TODO"
12
- @project_id = project_id
13
- raise "Sorry local mount doesnt exist!" unless File.exist?(@local_mountpoint)
13
+ attr_accessor :project_id
14
14
 
15
- @wr = writeable? # File.writable?(stats_filename_default_fullpath) # .writeable? stats_file_smart_fullpath
16
- super(local_mount) rescue "SUPER_ERROR(#{local_mount}): #{$!}"
17
- end
15
+ def initialize(local_mount, project_id = nil)
16
+ deb '[Storazzo::Media::GcsBucket] initialize'
18
17
 
19
- def self.list_all(config = nil)
20
- # get lisrts from Config singletone
21
- # puts " self.list_all: loading config "
22
- config ||= Storazzo::RicDiskConfig.instance # # ).get_config
23
-
24
- config.load # in case I need to load it for the first time
25
- # puts config['Config']['AdditionalMountDirs']
26
- # puts "TODO see config: #{config}"
27
- # [42, 43]
28
- # deb config.get_local_folders
29
- # TODO
30
- pverbose true,
31
- "TODO(ricc): also add gsutil ls. For that please use the new 'list_all_with_type' (Id refactor it but Im afraid of leaving bad code dangling so before a proper refactor lets implement both side by side"
32
- config.get_bucket_paths
33
- end
18
+ @local_mountpoint = File.expand_path(local_mount)
19
+ @description = "MountPoint in '#{local_mount}' pointing at TODO with mount options = TODO"
20
+ project_id ||= _autodetect_project_id
21
+ @project_id = project_id
22
+ raise 'Sorry local mount doesnt exist!' unless File.exist?(@local_mountpoint)
34
23
 
35
- def self.list_all_with_type(config = nil)
36
- config ||= Storazzo::RicDiskConfig.instance
37
- config.load # in case I need to load it for the first time
38
- deb "TODO(ricc): also add gsutil ls"
39
- # getFromConfig
40
- deb "I'm now returning a 'complex' array to tell the caller what kind of element they're getting, eg: GCS from Config Yaml, vs GCS from gsutil ls "
41
- list_from_config_with_type = config.get_bucket_paths.map { |path| [:config_gcs_bucket, path] }
42
- if (config.project_id)
43
- # so I concatenate Apples with Bananas with names
44
- return list_from_config_with_type + list_available_buckets(config.project_id).map { |path|
45
- [:gsutil_ls_gcs_bucket, path]
46
- }
47
- end
24
+ @wr = writeable? # File.writable?(stats_filename_default_fullpath) # .writeable? stats_file_smart_fullpath
25
+ begin
26
+ super(local_mount)
27
+ rescue StandardError
28
+ "SUPER_ERROR(#{local_mount}): #{$ERROR_INFO}"
29
+ end
30
+ end
48
31
 
49
- return list_from_config_with_type
50
- end
32
+ def _autodetect_project_id
33
+ 'todo-my-project-id-123' # TODO: fix
34
+ end
35
+
36
+ # (config = nil)
37
+ def self.list_all
38
+ # get lisrts from Config singletone
39
+ # puts " self.list_all: loading config "
40
+ config ||= Storazzo::RicDiskConfig.instance # # ).get_config
51
41
 
52
- def self.list_available_buckets(project_id, opts = {})
53
- list_of_buckets = `gsutil ls --project '#{project_id}'`.chomp.split("\n")
54
- deb "list_of_buckets: #{list_of_buckets}"
55
- list_of_buckets
42
+ config.load # in case I need to load it for the first time
43
+ # puts config['Config']['AdditionalMountDirs']
44
+ # puts "TODO see config: #{config}"
45
+ # [42, 43]
46
+ # deb config.get_local_folders
47
+ # TODO
48
+ pverbose true,
49
+ "TODO(ricc): also add gsutil ls. For that please use the new 'list_all_with_type' (Id refactor it but Im afraid of leaving bad code dangling so before a proper refactor lets implement both side by side"
50
+ config.get_bucket_paths
51
+ end
52
+
53
+ # (config = nil)
54
+ def self.list_all_with_type
55
+ deb 'GCS::list_all_with_type() -- pull config'
56
+ config ||= Storazzo::RicDiskConfig.instance
57
+ config.load # in case I need to load it for the first time
58
+ # puts "GCS::list_all_with_type() -- TODO(ricc): also add gsutil ls"
59
+ # getFromConfig
60
+ deb "I'm now returning a 'complex' array to tell the caller what kind of element they're getting, eg: GCS from Config Yaml, vs GCS from gsutil ls "
61
+ list_from_config_with_type = config.get_bucket_paths.map do |path|
62
+ [:config_gcs_bucket, path]
63
+ end
64
+ ret_list = list_from_config_with_type
65
+ if config.gcs_enabled? # should be if GCS enabled :) project_id
66
+ # so I concatenate Apples with Bananas with names
67
+ # ret_list += list_available_buckets(config.project_id).map { |path|
68
+ ret_list += list_available_buckets.map do |path|
69
+ [:gsutil_ls_gcs_bucket, path]
70
+ end
71
+ else
72
+ deb 'list_all_with_type(): empty project id. Skipping'
73
+ end
74
+
75
+ ret_list
76
+ end
77
+
78
+ def self.list_available_buckets(_opts = {})
79
+ # project_id = opts.fetch :project_id, nil
80
+ # list_of_buckets = `gsutil ls --project '#{project_id}'`.chomp.split("\n")
81
+ list_of_buckets = `gsutil ls`.chomp.split("\n")
82
+ deb "list_of_buckets: #{list_of_buckets}"
83
+ list_of_buckets
84
+ end
85
+ end
86
+ end
56
87
  end
57
88
  end
58
89
  end
@@ -1,48 +1,62 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # require "storazzo/ric_disk/abstract_ric_disk"
2
4
  # require "abstract_ric_disk"
3
5
 
4
- module Storazzo::Media
5
- class Storazzo::Media::LocalFolder < Storazzo::Media::AbstractRicDisk
6
- # extend Storazzo::Common
7
- include Storazzo::Common
8
-
9
- attr_accessor :local_mountpoint, :wr
10
-
11
- def initialize(local_mount)
12
- deb "[Storazzo::Media::LocalFolder] initialize"
13
-
14
- @local_mountpoint = File.expand_path(local_mount)
15
- @description = "Local Folder originally in '#{local_mount}'"
16
- raise "Sorry local mount doesnt exist!" unless File.exist?(@local_mountpoint)
17
-
18
- @wr = writeable? # File.writable?(stats_filename_default_fullpath) # .writeable? stats_file_smart_fullpath
19
- # super.initialize(local_mount) rescue "SUPER_ERROR: #{$!}"
20
- super(local_mount) rescue "SUPER_ERROR(#{local_mount}): #{$!}"
21
- end
22
-
23
- def self.list_all(config = nil)
24
- # get lists from Config singleton
25
- config ||= Storazzo::RicDiskConfig.instance # # ).get_config
26
- config.load
27
- config.get_local_folders
28
- end
29
-
30
- def parse(opts = {})
31
- puts "LF.parse(#{opts}): TODO Sbrodola inside the dir: #{local_mountpoint}"
32
- parse_block_storage_folder()
33
- end
34
-
35
- def path
36
- @local_mountpoint
37
- end
38
-
39
- def writeable?
40
- File.writable?(@local_mountpoint)
41
- end
42
-
43
- def default_stats_filename
44
- # '42'
45
- Storazzo::RicDiskStatsFile.default_name
6
+ require 'English'
7
+ module Storazzo
8
+ module Media
9
+ module Storazzo
10
+ module Media
11
+ class LocalFolder < Storazzo::Media::AbstractRicDisk
12
+ # extend Storazzo::Common
13
+ include Storazzo::Common
14
+
15
+ attr_accessor :local_mountpoint, :wr
16
+
17
+ def initialize(local_mount)
18
+ deb '[Storazzo::Media::LocalFolder] initialize'
19
+
20
+ @local_mountpoint = File.expand_path(local_mount)
21
+ @description = "Local Folder originally in '#{local_mount}'"
22
+ raise 'Sorry local mount doesnt exist!' unless File.exist?(@local_mountpoint)
23
+
24
+ @wr = writeable? # File.writable?(stats_filename_default_fullpath) # .writeable? stats_file_smart_fullpath
25
+ # super.initialize(local_mount) rescue "SUPER_ERROR: #{$!}"
26
+ begin
27
+ super(local_mount)
28
+ rescue StandardError
29
+ "SUPER_ERROR(#{local_mount}): #{$ERROR_INFO}"
30
+ end
31
+ end
32
+
33
+ # WRONG: config = nil
34
+ def self.list_all
35
+ # get lists from Config singleton
36
+ config = Storazzo::RicDiskConfig.instance # # ).get_config
37
+ config.load
38
+ config.get_local_folders
39
+ end
40
+
41
+ def parse(opts = {})
42
+ puts "LF.parse(#{opts}): TODO Sbrodola inside the dir: #{local_mountpoint}"
43
+ parse_block_storage_folder
44
+ end
45
+
46
+ def path
47
+ @local_mountpoint
48
+ end
49
+
50
+ def writeable?
51
+ File.writable?(@local_mountpoint)
52
+ end
53
+
54
+ def default_stats_filename
55
+ # '42'
56
+ Storazzo::RicDiskStatsFile.default_name
57
+ end
58
+ end
59
+ end
46
60
  end
47
61
  end
48
62
  end
@@ -1,11 +1,27 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # TODO
2
- module Storazzo::Media
3
- class Storazzo::Media::MountPoint < Storazzo::Media::AbstractRicDisk
4
- # puts "[REMOVEME] Storazzo::Media::MountPoint being read. REMOVEME when you see this :)"
4
+ module Storazzo
5
+ module Media
6
+ module Storazzo
7
+ module Media
8
+ class MountPoint < Storazzo::Media::AbstractRicDisk
9
+ # puts "[REMOVEME] Storazzo::Media::MountPoint being read. REMOVEME when you see this :)"
10
+
11
+ def self.list_local_mount_points
12
+ deb 'Maybe its abuot time you refactor that method here :)'
13
+ RicDisk.interesting_mount_points
14
+ end
15
+
16
+ def self.list_all
17
+ RicDisk.interesting_mount_points
18
+ end
5
19
 
6
- def self.list_local_mount_points()
7
- deb "Maybe its abuot time you refactor that method here :)"
8
- RicDisk.interesting_mount_points()
20
+ def self.list_all_with_type
21
+ list_all.map { |x| [:mount_point_todo_less_generic, x] }
22
+ end
23
+ end
24
+ end
9
25
  end
10
26
  end
11
27
  end