storazzo 0.5.7 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +7 -5
  3. data/Makefile +8 -6
  4. data/Rakefile +15 -13
  5. data/VERSION +1 -1
  6. data/bin/hello-storazzo +1 -0
  7. data/bin/ricdisk-magic +33 -30
  8. data/bin/stats-with-md5 +182 -157
  9. data/bin/storazzo +112 -114
  10. data/bin/storazzo-symlink.rb +1 -0
  11. data/lib/storazzo/colors.rb +77 -36
  12. data/lib/storazzo/common.rb +72 -68
  13. data/lib/storazzo/debug.rb +2 -0
  14. data/lib/storazzo/hashify.rb +7 -5
  15. data/lib/storazzo/main.rb +59 -49
  16. data/lib/storazzo/media/abstract_ric_disk.rb +188 -179
  17. data/lib/storazzo/media/gcs_bucket.rb +76 -58
  18. data/lib/storazzo/media/local_folder.rb +56 -42
  19. data/lib/storazzo/media/mount_point.rb +20 -12
  20. data/lib/storazzo/ric_disk.rb +386 -383
  21. data/lib/storazzo/ric_disk_config.rb +227 -209
  22. data/lib/storazzo/ric_disk_sample_config.rb +26 -24
  23. data/lib/storazzo/ric_disk_statsfile.rb +19 -17
  24. data/lib/storazzo/ric_disk_ugly.rb +1 -0
  25. data/lib/storazzo/version.rb +3 -3
  26. data/lib/storazzo.rb +6 -7
  27. data/storazzo.gemspec +24 -16
  28. data/test/benchmark/for_future_use.rb +4 -2
  29. data/test/benchmark/test_hashing_functions-speed.rb +17 -0
  30. data/test/bin/new-idea.rb +17 -0
  31. data/test/bin/storazzo.rb +22 -25
  32. data/test/media/test_abstract_ric_disk.rb +5 -3
  33. data/test/media/test_gcs_bucket.rb +24 -23
  34. data/test/media/test_local_folder.rb +24 -23
  35. data/test/media/test_mount_point.rb +6 -5
  36. data/test/test_ric_disk.rb +6 -4
  37. data/test/test_ric_disk_config.rb +12 -11
  38. data/test/test_ric_disk_stats_file.rb +5 -3
  39. data/test/test_storazzo.rb +6 -4
  40. data/var/test/disks/disk02-full/Rakefile +7 -5
  41. data/var/test/disks/ricdisk_stats_v11.rds +11 -0
  42. metadata +13 -21
@@ -1,261 +1,279 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'English'
4
+
1
5
  require 'singleton'
2
6
  require 'yaml'
3
7
 
4
- # require 'storazzo/media/abstract_ric_disk'
5
- Dir[File.dirname(__FILE__) + '/../lib/*.rb'].each do |file|
8
+ Dir["#{File.dirname(__FILE__)}/../lib/*.rb"].each do |file|
6
9
  require File.basename(file, File.extname(file))
7
10
  end
8
- # require_all 'media/directory'
9
-
10
- =begin
11
- This is a singleton class. You call me this way..
12
- You call me with:
13
-
14
- Storazzo::RicDiskConfig.instance()
15
11
 
16
- or better
17
-
18
- Storazzo::RicDiskConfig.safe_instance()
19
-
20
- Note that being a Singleton, in Unit Tests it's hard to use the /etc/storazzo_config.sample.yaml instead
21
- of the real one - yiikes. How do I fix it? Do I unsingleton it? :) Or do I create TWO singletons? :)
22
- =end
12
+ # This is a singleton class. You call me this way..
13
+ # You call me with:
14
+ #
15
+ # Storazzo::RicDiskConfig.instance()
16
+ #
17
+ # or better
18
+ #
19
+ # Storazzo::RicDiskConfig.safe_instance()
20
+ #
21
+ # Note that being a Singleton, in Unit Tests it's hard to use the /etc/storazzo_config.sample.yaml instead
22
+ # of the real one - yiikes. How do I fix it? Do I unsingleton it? :) Or do I create TWO singletons? :)
23
23
 
24
24
  module Storazzo
25
25
  # class Storazzo::Blah
26
26
  # end
27
27
 
28
- class Storazzo::RicDiskConfig
29
- include Singleton
30
- include Storazzo::Common
31
- include Storazzo::Colors
32
-
33
- DefaultConfigLocation = File.expand_path "~/.storazzo.yaml"
28
+ module Storazzo
29
+ class RicDiskConfig
30
+ include Singleton
31
+ include Storazzo::Common
32
+ include Storazzo::Colors
34
33
 
35
- DefaultConfigLocations = [
36
- File.expand_path("~/.storazzo.yaml"), # HOME
37
- File.expand_path("./.storazzo.yaml"), # LOCAL DIR
38
- ]
34
+ DefaultConfigLocation = File.expand_path '~/.storazzo.yaml'
39
35
 
40
- DefaultGemLocationForTests =
41
- File.expand_path('../../../', __FILE__) +
42
- "/etc/storazzo_config.sample.yaml"
36
+ DEFAULT_CONFIG_LOCATIONS = [
37
+ File.expand_path('~/.storazzo.yaml'), # HOME
38
+ File.expand_path('./.storazzo.yaml') # LOCAL DIR
39
+ ].freeze
43
40
 
44
- attr_accessor :config, :config_file, :load_called, :project_id
41
+ DefaultGemLocationForTests =
42
+ "#{File.expand_path('../..', __dir__)}/etc/storazzo_config.sample.yaml"
45
43
 
46
- public
44
+ attr_accessor :config, :config_file, :load_called, :project_id
47
45
 
48
- # Load from the first valid config.
49
- def load(config_path = nil, opts = {})
50
- verbose = opts.fetch :verbose, false
46
+ # Load from the first valid config.
47
+ def load(config_path = nil, opts = {})
48
+ verbose = opts.fetch :verbose, false
51
49
 
52
- if already_loaded? # and not self.config.nil?
53
- pverbose verbose, "[#{self.class}] Config.Load: already loaded"
54
- return self.config
55
- end
56
- pverbose verbose, "Storazzo::RicDiskConfig.load(): BEGIN"
57
- # trying default location
58
- raise "DefaultConfigLocation is not a string" unless DefaultConfigLocation.is_a?(String)
59
-
60
- possible_locations = DefaultConfigLocations # [ default_config_locations .. , "./.storazzo.yaml"]
61
- deb "[Config.load] Possible Locations: #{possible_locations}"
62
- if config_path.is_a?(String)
63
- # possible_locations = [config_path] + possible_locations # .append()
64
- possible_locations = possible_locations.unshift(config_path) # append to front
65
- # OR: possible_locations.instert(0, config_path)
66
- pverbose verbose, "[LOAD] possible_locations: #{possible_locations}"
67
- end
68
- pverbose verbose, "Searching these paths in order: #{possible_locations}"
69
- # bug "This is not always an array of sTRINGS."
70
- raise "possible_locations is not an array" unless possible_locations.is_a?(Array)
71
-
72
- possible_locations.each do |possible_path|
73
- # ASSERT is a string
74
- raise "possible_path is not a string" unless possible_path.is_a?(String)
50
+ if already_loaded? # and not self.config.nil?
51
+ pverbose verbose, "[#{self.class}] Config.Load: already loaded"
52
+ return config
53
+ end
54
+ pverbose verbose, 'Storazzo::RicDiskConfig.load(): BEGIN'
55
+ # trying default location
56
+ raise 'DefaultConfigLocation is not a string' unless DefaultConfigLocation.is_a?(String)
57
+
58
+ possible_locations = DEFAULT_CONFIG_LOCATIONS # [ default_config_locations .. , "./.storazzo.yaml"]
59
+ deb "[Config.load] Possible Locations: #{possible_locations}"
60
+ if config_path.is_a?(String)
61
+ # possible_locations = [config_path] + possible_locations # .append()
62
+ possible_locations.unshift(config_path) # append to front
63
+ # OR: possible_locations.instert(0, config_path)
64
+ pverbose verbose, "[LOAD] possible_locations: #{possible_locations}"
65
+ end
66
+ pverbose verbose, "Searching these paths in order: #{possible_locations}"
67
+ # bug "This is not always an array of sTRINGS."
68
+ raise 'possible_locations is not an array' unless possible_locations.is_a?(Array)
69
+
70
+ possible_locations.each do |possible_path|
71
+ # ASSERT is a string
72
+ raise 'possible_path is not a string' unless possible_path.is_a?(String)
73
+
74
+ deb "before buggy expand_path paz: '#{possible_path}''"
75
+ paz = begin
76
+ File.expand_path(possible_path)
77
+ rescue StandardError
78
+ possible_path
79
+ end
80
+ raise "Not a string: #{paz}" unless paz.is_a?(String)
75
81
 
76
- deb "before buggy expand_path paz: '#{possible_path}''"
77
- paz = File.expand_path(possible_path) rescue possible_path
78
- raise "Not a string: #{paz}" unless paz.is_a?(String)
82
+ next unless File.exist?(paz)
79
83
 
80
- if File.exists?(paz)
81
84
  @config_file = paz
82
- @config = YAML.load(File.read paz) # YAML.load(File.read("file_path"))
85
+ @config = YAML.safe_load(File.read(paz)) # YAML.load(File.read("file_path"))
83
86
 
84
- unless (@config["kind"] == 'StorazzoConfig' rescue false)
85
- puts white "RicDiskConfig.load(): Sorry this is wrong Config File. Kind=#{@config["kind"] rescue $!}"
87
+ unless begin
88
+ @config['kind'] == 'StorazzoConfig'
89
+ rescue StandardError
90
+ false
91
+ end
92
+ puts white "RicDiskConfig.load(): Sorry this is wrong Config File. Kind=#{begin
93
+ @config['kind']
94
+ rescue StandardError
95
+ $ERROR_INFO
96
+ end}"
86
97
  next
87
98
  end
88
99
  #
89
100
  # pp @config if verbose
90
- config_ver = @config["apiVersion"]
101
+ config_ver = @config['apiVersion']
91
102
  # puts @config[:ConfigVersion]
92
103
  deb("OK. Storazzo::RicDiskConfig v'#{config_ver}' parsed correctly")
93
104
  @load_called = true
94
- return self.config
105
+ return config
95
106
  end
107
+ @load_called = true
108
+ # only get here if nothing is found
109
+ raise "No config found across these locations: #{possible_locations}. Consider copying and editing: #{RicDiskConfig.gem_default_config_path}"
96
110
  end
97
- @load_called = true
98
- # only get here if nothing is found
99
- raise "No config found across these locations: #{possible_locations}. Consider copying and editing: #{RicDiskConfig.gem_default_config_path}"
100
- end
101
111
 
102
- # Obsolete, call another class instead.
103
- def load_sample_version
104
- raise "DEPRECATED! USE SampleRicDiskConfig.load() instead!"
105
- end
112
+ # Obsolete, call another class instead.
113
+ def load_sample_version
114
+ raise 'DEPRECATED! USE SampleRicDiskConfig.load() instead!'
115
+ end
106
116
 
107
- def config_ver
108
- raise "I cant compute Version since I cant compute @config. Are you sure you didnt instance this Singleton without calling load?" if @config.nil?
117
+ def config_ver
118
+ raise 'I cant compute Version since I cant compute @config. Are you sure you didnt instance this Singleton without calling load?' if @config.nil?
109
119
 
110
- @config['apiVersion'] # rescue :StillUnknown
111
- # config['ConfigVersion']
112
- end
120
+ @config['apiVersion'] # rescue :StillUnknown
121
+ # config['ConfigVersion']
122
+ end
113
123
 
114
- def config_default_folder
115
- # self.
116
- @config['Config']['DefaultFolder'] # rescue "Unknown config_default_folder: #{$!}"
117
- end
124
+ def config_default_folder
125
+ # self.
126
+ @config['Config']['DefaultFolder'] # rescue "Unknown config_default_folder: #{$!}"
127
+ end
118
128
 
119
- def config_project_id
120
- @config['Config']['Backends']['GoogleCloudStorage']['ProjectId']
121
- end
129
+ def config_project_id
130
+ @config['Config']['Backends']['GoogleCloudStorage']['ProjectId']
131
+ end
122
132
 
123
- #doesnt work :/ alias :project_id, :config_project_id
124
- def project_id
125
- config_project_id
126
- end
133
+ # doesnt work :/ alias :project_id, :config_project_id
134
+ def project_id
135
+ config_project_id
136
+ end
127
137
 
128
- # This should return true if and only if the user has configured the YAML
129
- # to use GCS. For now we can just say TRUE since gsutil ls returns without project_id.
130
- # However, we might have a flag enabled in storazzo config in next versions.
131
- def gcs_enabled?
132
- #true
133
- defined?(get_config['Config']['Backends']['GoogleCloudStorage'])
134
- #get_config['Config']['Backends']['GoogleCloudStorage DOESNT EXIST']
135
- # defined? Backends: GoogleCloudStorage
136
- end
138
+ # This should return true if and only if the user has configured the YAML
139
+ # to use GCS. For now we can just say TRUE since gsutil ls returns without project_id.
140
+ # However, we might have a flag enabled in storazzo config in next versions.
141
+ def gcs_enabled?
142
+ # true
143
+ defined?(get_config['Config']['Backends']['GoogleCloudStorage'])
144
+ # get_config['Config']['Backends']['GoogleCloudStorage DOESNT EXIST']
145
+ # defined? Backends: GoogleCloudStorage
146
+ end
137
147
 
138
- def already_loaded?
139
- # return
140
- load_called == true
141
- end
148
+ def already_loaded?
149
+ # return
150
+ load_called == true
151
+ end
142
152
 
143
- def to_s
144
- size = File.size(@config_file) rescue -1
145
- # puts yellow "DEB: #{@config["apiVersion"]}"
146
- # "RicDiskConfig(ver=#{config_ver}, file=#{config_file}), #{white(size)} bytes" # - config_default_folder=#{self.config_default_folder}"
147
- "POLY_#{self.class}_(ver=#{config_ver}, file=#{config_file}), #{white(size)} bytes" # - config_default_folder=#{self.config_default_folder}"
148
- end
153
+ def to_s
154
+ size = begin
155
+ File.size(@config_file)
156
+ rescue StandardError
157
+ -1
158
+ end
159
+ # puts yellow "DEB: #{@config["apiVersion"]}"
160
+ # "RicDiskConfig(ver=#{config_ver}, file=#{config_file}), #{white(size)} bytes" # - config_default_folder=#{self.config_default_folder}"
161
+ "POLY_#{self.class}_(ver=#{config_ver}, file=#{config_file}), #{white(size)} bytes" # - config_default_folder=#{self.config_default_folder}"
162
+ end
149
163
 
150
- def to_verbose_s
151
- h = {}
152
- h[:description] =
153
- "This is a Verbose Hash describing a RicDiskConfig or its child RicDiskSampleConfig to understand why it keeps failing.."
154
- h[:to_s] = self.to_s
155
- h[:class] = self.class
156
- h[:file] = __FILE__
157
- h[:id] = self.object_id
158
- h[:get_bucket_paths] = self.get_bucket_paths()
159
- h[:get_local_folders] = self.get_local_folders()
160
- h[:config_project_id] = self.config_project_id()
161
- return h
162
- end
164
+ def to_verbose_s
165
+ h = {}
166
+ h[:description] =
167
+ 'This is a Verbose Hash describing a RicDiskConfig or its child RicDiskSampleConfig to understand why it keeps failing..'
168
+ h[:to_s] = to_s
169
+ h[:class] = self.class
170
+ h[:file] = __FILE__
171
+ h[:id] = object_id
172
+ h[:get_bucket_paths] = get_bucket_paths
173
+ h[:get_local_folders] = get_local_folders
174
+ h[:config_project_id] = config_project_id
175
+ h
176
+ end
163
177
 
164
- def get_config(opts = {})
165
- return load(opts) if @config.nil?
178
+ def get_config(opts = {})
179
+ return load(opts) if @config.nil?
166
180
 
167
- @config
168
- end
181
+ @config
182
+ end
169
183
 
170
- def self.gem_default_config_path
171
- Storazzo.root + "/etc/storazzo_config.sample.yaml"
172
- end
184
+ def self.gem_default_config_path
185
+ "#{Storazzo.root}/etc/storazzo_config.sample.yaml"
186
+ end
173
187
 
174
- # Storazzo::RicDiskConfig
175
-
176
- # returns all folders from file which are Directories
177
- # This method is FLAKY! Sometimes gives error.
178
- # LocalFolderTest#test_show_all_shouldnt_fail_and_should_return_a_non_empty_array:
179
- # TypeError: no implicit conversion of Hash into String
180
- # /Users/ricc/git/storazzo/lib/storazzo/ric_disk_config.rb:38:in `expand_path'
181
- # /Users/ricc/git/storazzo/lib/storazzo/ric_disk_config.rb:38:in `block in load'
182
- # /Users/ricc/git/storazzo/lib/storazzo/ric_disk_config.rb:37:in `each'
183
- # /Users/ricc/git/storazzo/lib/storazzo/ric_disk_config.rb:37:in `load'
184
- # /Users/ricc/git/storazzo/lib/storazzo/ric_disk_config.rb:83:in `get_config'
185
- # /Users/ricc/git/storazzo/lib/storazzo/ric_disk_config.rb:95:in `get_local_folders'
186
- def get_local_folders
187
- config = get_config
188
- # puts config['Config']['AdditionalMountDirs']
189
- config['Config']['AdditionalMountDirs'].map { |folder|
190
- File.expand_path(folder) rescue folder # TypeError: no implicit conversion of Hash into String
191
- }.filter { |f| File.directory?(f) }
192
- end
188
+ # Storazzo::RicDiskConfig
189
+
190
+ # returns all folders from file which are Directories
191
+ # This method is FLAKY! Sometimes gives error.
192
+ # LocalFolderTest#test_show_all_shouldnt_fail_and_should_return_a_non_empty_array:
193
+ # TypeError: no implicit conversion of Hash into String
194
+ # /Users/ricc/git/storazzo/lib/storazzo/ric_disk_config.rb:38:in `expand_path'
195
+ # /Users/ricc/git/storazzo/lib/storazzo/ric_disk_config.rb:38:in `block in load'
196
+ # /Users/ricc/git/storazzo/lib/storazzo/ric_disk_config.rb:37:in `each'
197
+ # /Users/ricc/git/storazzo/lib/storazzo/ric_disk_config.rb:37:in `load'
198
+ # /Users/ricc/git/storazzo/lib/storazzo/ric_disk_config.rb:83:in `get_config'
199
+ # /Users/ricc/git/storazzo/lib/storazzo/ric_disk_config.rb:95:in `get_local_folders'
200
+ def get_local_folders
201
+ config = get_config
202
+ # puts config['Config']['AdditionalMountDirs']
203
+ config['Config']['AdditionalMountDirs'].map do |folder|
204
+ File.expand_path(folder)
205
+ rescue StandardError
206
+ folder
207
+ end.filter { |f| File.directory?(f) }
208
+ end
193
209
 
194
- def get_bucket_paths
195
- get_config['Config']['Backends']['GoogleCloudStorage']['BucketPaths'].map { |complex_gcs_struct|
196
- complex_gcs_struct['path']
197
- }
198
- end
210
+ def get_bucket_paths
211
+ get_config['Config']['Backends']['GoogleCloudStorage']['BucketPaths'].map do |complex_gcs_struct|
212
+ complex_gcs_struct['path']
213
+ end
214
+ end
199
215
 
200
- # UGLY CODE, copipasted from binary for ARGV, ex autosbrodola
201
- def iterate_through_file_list_for_disks(files_list = [], opts = {})
202
- verbose = opts.fetch :verbose, false
203
- raise "[iterate_through_file_list_for_disks] Wrong input, I need an array here: #{files_list} " unless files_list.is_a?(Array)
204
-
205
- # I decided i wont accept an emopty list, this is not how you use the gem, you lazy XXX!
206
- # if files_list == [] # or files_list.nil? # empty -> ALL
207
- # deb "iterate_through_file_list_for_disks(): no args provided"
208
- # dirs = RicDisk.find_active_dirs()
209
- # puts "DEB find_active_dirs: #{green dirs}"
210
- # dirs.each {|dir|
211
- # RicDisk.write_config_yaml_to_disk(dir)
212
- # RicDisk.calculate_stats_files(dir) # dir is inutile
213
- # } # TODO refactor in option sbrodola_afterwards=true. :)
214
- # else
215
- pverbose verbose, "iterate_through_file_list_for_disks(): I consider files_list as a list of directories to parse :)"
216
-
217
- # dirs = RicDisk.find_active_dirs()
218
- files_list.each do |dir|
219
- dir = File.expand_path(dir)
220
- if File.directory?(dir)
221
- # if dirs.include?(dir)
222
- pverbose verbose, "iterate_through_file_list_for_disks() Legit dir: #{green dir}"
223
- rd = RicDisk.new(Storazzo::Media::AbstractRicDisk.DirFactory(dir))
224
- pverbose verbose, "RicDisk from Factory (woohoo): #{rd}"
225
- rd.write_config_yaml_to_disk(dir)
226
- # RicDisk.write_config_yaml_to_disk(dir)
227
- # RicDisk.calculate_stats_files (CLASS) => will become OBJECT compute_stats_files
228
- rd.compute_stats_files() # dir is inutile # TODO
229
- else
230
- raise("Doesnt seem a dir to me, quitting: #{dir}")
216
+ # UGLY CODE, copipasted from binary for ARGV, ex autosbrodola
217
+ def iterate_through_file_list_for_disks(files_list = [], opts = {})
218
+ verbose = opts.fetch :verbose, false
219
+ raise "[iterate_through_file_list_for_disks] Wrong input, I need an array here: #{files_list} " unless files_list.is_a?(Array)
220
+
221
+ # I decided i wont accept an emopty list, this is not how you use the gem, you lazy XXX!
222
+ # if files_list == [] # or files_list.nil? # empty -> ALL
223
+ # deb "iterate_through_file_list_for_disks(): no args provided"
224
+ # dirs = RicDisk.find_active_dirs()
225
+ # puts "DEB find_active_dirs: #{green dirs}"
226
+ # dirs.each {|dir|
227
+ # RicDisk.write_config_yaml_to_disk(dir)
228
+ # RicDisk.calculate_stats_files(dir) # dir is inutile
229
+ # } # TODO refactor in option sbrodola_afterwards=true. :)
230
+ # else
231
+ pverbose verbose,
232
+ 'iterate_through_file_list_for_disks(): I consider files_list as a list of directories to parse :)'
233
+
234
+ # dirs = RicDisk.find_active_dirs()
235
+ files_list.each do |dir|
236
+ dir = File.expand_path(dir)
237
+ if File.directory?(dir)
238
+ # if dirs.include?(dir)
239
+ pverbose verbose, "iterate_through_file_list_for_disks() Legit dir: #{green dir}"
240
+ rd = RicDisk.new(Storazzo::Media::AbstractRicDisk.DirFactory(dir))
241
+ pverbose verbose, "RicDisk from Factory (woohoo): #{rd}"
242
+ rd.write_config_yaml_to_disk(dir)
243
+ # RicDisk.write_config_yaml_to_disk(dir)
244
+ # RicDisk.calculate_stats_files (CLASS) => will become OBJECT compute_stats_files
245
+ rd.compute_stats_files # dir is inutile # TODO
246
+ else
247
+ raise("Doesnt seem a dir to me, quitting: #{dir}")
248
+ end
231
249
  end
250
+ # end
232
251
  end
233
- # end
234
- end # /iterate_through_file_list_for_disks
235
252
 
236
- def config_hash
237
- config['Config']
238
- end
253
+ def config_hash
254
+ config['Config']
255
+ end
239
256
 
240
- def self.safe_instance()
241
- puts "This is a safe instance :)"
242
- my_config = self.instance()
243
- my_config.load
244
- my_config
245
- end
257
+ def self.safe_instance
258
+ puts 'This is a safe instance :)'
259
+ my_config = instance
260
+ my_config.load
261
+ my_config
262
+ end
246
263
 
247
- def self.get_config
248
- self.instance.load unless self.instance.load_called
249
- self.instance.get_config
250
- end
264
+ def self.get_config
265
+ instance.load unless instance.load_called
266
+ instance.get_config
267
+ end
251
268
 
252
- # # gem 'after_do'
253
- # require 'after_do'
254
- # Storazzo::RicDiskConfig.extend AfterDo
255
- # Storazzo::RicDiskConfig.after :instance do # |activity| #:pause, :finish, :resurrect, :do_today, :do_another_day
256
- # puts yellow("after INSTANCE() has been called I call LOAD!!!")
257
- # self.load
258
- # #persistor.save activity
259
- # end
260
- end # class Storazzo::RicDiskConfig
261
- end # module Storazzo
269
+ # # gem 'after_do'
270
+ # require 'after_do'
271
+ # Storazzo::RicDiskConfig.extend AfterDo
272
+ # Storazzo::RicDiskConfig.after :instance do # |activity| #:pause, :finish, :resurrect, :do_today, :do_another_day
273
+ # puts yellow("after INSTANCE() has been called I call LOAD!!!")
274
+ # self.load
275
+ # #persistor.save activity
276
+ # end
277
+ end
278
+ end
279
+ end
@@ -1,31 +1,33 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'singleton'
2
4
  require 'yaml'
3
5
 
4
- require_relative "./common"
5
- require_relative "./ric_disk_config"
6
-
7
- =begin
8
- This is a singleton class. You call me this way..
9
- You call me with:
10
-
11
- Storazzo::RicDiskSampleConfig.instance()
12
-
13
- =end
6
+ require_relative './common'
7
+ require_relative './ric_disk_config'
14
8
 
15
9
  module Storazzo
16
- class Storazzo::RicDiskSampleConfig < Storazzo::RicDiskConfig
17
- # include Storazzo::Common
18
-
19
- public
20
-
21
- def load # _sample_version
22
- deb("[RicDiskSampleConfig] Wheew 1! We're NOT destroying the world here. We're actually instancing a second Singleton which is a child of the mother, and this time doing things nicely and Rubily.")
23
- super(DefaultGemLocationForTests, :verbose => false)
24
- end
25
-
26
- def load_sample_version
27
- deb white("[RicDiskSampleConfig] Wheew 2! We're NOT destroying the world here. We're actually instancing a second Singleton which is a child of the mother, and this time doing things nicely and Rubily.")
28
- super(DefaultGemLocationForTests, :verbose => false)
10
+ module Storazzo
11
+ # This is a singleton class. You call me this way..
12
+ # You call me with:
13
+ #
14
+ # Storazzo::RicDiskSampleConfig.instance()
15
+ #
16
+ # It loads a sample config in local gem etc/. Usuful for testing or if no other config is found..
17
+
18
+ class RicDiskSampleConfig < Storazzo::RicDiskConfig
19
+ # include Storazzo::Common
20
+
21
+ # _sample_version
22
+ def load
23
+ deb("[RicDiskSampleConfig] Wheew 1! We're NOT destroying the world here. We're actually instancing a second Singleton which is a child of the mother, and this time doing things nicely and Rubily.")
24
+ super(DefaultGemLocationForTests, verbose: false)
25
+ end
26
+
27
+ def load_sample_version
28
+ deb white("[RicDiskSampleConfig] Wheew 2! We're NOT destroying the world here. We're actually instancing a second Singleton which is a child of the mother, and this time doing things nicely and Rubily.")
29
+ super(DefaultGemLocationForTests, verbose: false)
30
+ end
29
31
  end
30
32
  end
31
- end # module Storazzo
33
+ end
@@ -1,24 +1,26 @@
1
- # This class wraps the RDS file: we're going to write this RDS file
2
- # directly in the disk: /mount/
3
- module Storazzo
4
- class Storazzo::RicDiskStatsFile
5
- # Please keep these two in sync, until you fix them and DRY the behaviour.
6
- DefaultName = "ricdisk_stats_v11.rds" # => RicDiskStatsFile
7
- Version = "1.1" # @@version
1
+ # frozen_string_literal: true
8
2
 
9
- # AttrAccessor for class - thanks StackOverflow from Android since Im in roaming :)
10
- class << self
11
- attr_accessor :default_name, :version
12
- end
3
+ module Storazzo
4
+ module Storazzo
5
+ # This class wraps the RDS file: we're going to write this RDS file
6
+ # directly in the disk: /mount/
7
+ class RicDiskStatsFile
8
+ # Please keep these two in sync, until you fix them and DRY the behaviour.
9
+ DefaultName = 'ricdisk_stats_v11.rds' # => RicDiskStatsFile
10
+ Version = '1.1' # @@version
13
11
 
14
- public
12
+ # AttrAccessor for class - thanks StackOverflow from Android since Im in roaming :)
13
+ class << self
14
+ attr_accessor :my_default_name, :my_version # without MY it redefines whats below :/
15
+ end
15
16
 
16
- def self.default_name
17
- DefaultName
18
- end
17
+ def self.default_name
18
+ DefaultName
19
+ end
19
20
 
20
- def self.version
21
- Version
21
+ def self.version
22
+ Version
23
+ end
22
24
  end
23
25
  end
24
26
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # # TODO remove this! Ugly code to just borrow and cleanup a bit,
2
3
 
3
4
  # module Storazzo
@@ -1,10 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # copied from https://github.com/rails/strong_parameters/edit/master/lib/strong_parameters/version.rb
2
4
  # I;'m copying the DHH philosophy here.
3
5
  module Storazzo
4
6
  # DHH_VERSION = "0.2.3._TODOFileRead.1" # TODO file.read ../../VERSION . chomp
5
- RICC_VERSION = File.read("../VERSION").chomp
6
-
7
- public
7
+ RICC_VERSION = File.read('../VERSION').chomp
8
8
 
9
9
  def self.version
10
10
  RICC_VERSION