storazzo 0.5.1 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
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,247 +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
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}] VERBOSE 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
- puts "[VERBOSE] Searching these paths in order: #{possible_locations}" if verbose
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
- # puts "[VERBOSE] RicDiskConfig.to_s: #{self}" if verbose
94
104
  @load_called = true
95
- return self.config
105
+ return config
96
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}"
97
110
  end
98
- @load_called = true
99
- # only get here if nothing is found
100
- raise "No config found across these locations: #{possible_locations}. Consider copying and editing: #{RicDiskConfig.gem_default_config_path}"
101
- end
102
111
 
103
- # Obsolete, call another class instead.
104
- def load_sample_version
105
- raise "DEPRECATED! USE SampleRicDiskConfig.load() instead!"
106
- end
112
+ # Obsolete, call another class instead.
113
+ def load_sample_version
114
+ raise 'DEPRECATED! USE SampleRicDiskConfig.load() instead!'
115
+ end
107
116
 
108
- def config_ver
109
- 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?
110
119
 
111
- @config['apiVersion'] # rescue :StillUnknown
112
- # config['ConfigVersion']
113
- end
120
+ @config['apiVersion'] # rescue :StillUnknown
121
+ # config['ConfigVersion']
122
+ end
114
123
 
115
- def config_default_folder
116
- # self.
117
- @config['Config']['DefaultFolder'] # rescue "Unknown config_default_folder: #{$!}"
118
- end
124
+ def config_default_folder
125
+ # self.
126
+ @config['Config']['DefaultFolder'] # rescue "Unknown config_default_folder: #{$!}"
127
+ end
119
128
 
120
- def config_project_id
121
- @config['Config']['Backends']['GoogleCloudStorage']['ProjectId']
122
- end
129
+ def config_project_id
130
+ @config['Config']['Backends']['GoogleCloudStorage']['ProjectId']
131
+ end
123
132
 
124
- def already_loaded?
125
- # return
126
- load_called == true
127
- end
133
+ # doesnt work :/ alias :project_id, :config_project_id
134
+ def project_id
135
+ config_project_id
136
+ end
128
137
 
129
- def to_s
130
- size = File.size(@config_file) rescue -1
131
- # puts yellow "DEB: #{@config["apiVersion"]}"
132
- # "RicDiskConfig(ver=#{config_ver}, file=#{config_file}), #{white(size)} bytes" # - config_default_folder=#{self.config_default_folder}"
133
- "POLY_#{self.class}_(ver=#{config_ver}, file=#{config_file}), #{white(size)} bytes" # - config_default_folder=#{self.config_default_folder}"
134
- 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
135
147
 
136
- def to_verbose_s
137
- h = {}
138
- h[:description] =
139
- "This is a Verbose Hash describing a RicDiskConfig or its child RicDiskSampleConfig to understand why it keeps failing.."
140
- h[:to_s] = self.to_s
141
- h[:class] = self.class
142
- h[:file] = __FILE__
143
- h[:id] = self.object_id
144
- h[:get_bucket_paths] = self.get_bucket_paths()
145
- h[:get_local_folders] = self.get_local_folders()
146
- h[:config_project_id] = self.config_project_id()
147
- return h
148
- end
148
+ def already_loaded?
149
+ # return
150
+ load_called == true
151
+ end
149
152
 
150
- def get_config(opts = {})
151
- return load(opts) if @config.nil?
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
152
163
 
153
- @config
154
- 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
155
177
 
156
- def self.gem_default_config_path
157
- Storazzo.root + "/etc/storazzo_config.sample.yaml"
158
- end
178
+ def get_config(opts = {})
179
+ return load(opts) if @config.nil?
159
180
 
160
- # Storazzo::RicDiskConfig
161
-
162
- # returns all folders from file which are Directories
163
- # This method is FLAKY! Sometimes gives error.
164
- # LocalFolderTest#test_show_all_shouldnt_fail_and_should_return_a_non_empty_array:
165
- # TypeError: no implicit conversion of Hash into String
166
- # /Users/ricc/git/storazzo/lib/storazzo/ric_disk_config.rb:38:in `expand_path'
167
- # /Users/ricc/git/storazzo/lib/storazzo/ric_disk_config.rb:38:in `block in load'
168
- # /Users/ricc/git/storazzo/lib/storazzo/ric_disk_config.rb:37:in `each'
169
- # /Users/ricc/git/storazzo/lib/storazzo/ric_disk_config.rb:37:in `load'
170
- # /Users/ricc/git/storazzo/lib/storazzo/ric_disk_config.rb:83:in `get_config'
171
- # /Users/ricc/git/storazzo/lib/storazzo/ric_disk_config.rb:95:in `get_local_folders'
172
- def get_local_folders
173
- config = get_config
174
- # puts config['Config']['AdditionalMountDirs']
175
- config['Config']['AdditionalMountDirs'].map { |folder|
176
- File.expand_path(folder) rescue folder # TypeError: no implicit conversion of Hash into String
177
- }.filter { |f| File.directory?(f) }
178
- end
181
+ @config
182
+ end
179
183
 
180
- def get_bucket_paths
181
- get_config['Config']['Backends']['GoogleCloudStorage']['BucketPaths'].map { |complex_gcs_struct|
182
- complex_gcs_struct['path']
183
- }
184
- end
184
+ def self.gem_default_config_path
185
+ "#{Storazzo.root}/etc/storazzo_config.sample.yaml"
186
+ end
185
187
 
186
- # UGLY CODE, copipasted from binary for ARGV, ex autosbrodola
187
- def iterate_through_file_list_for_disks(files_list = [], opts = {})
188
- verbose = opts.fetch :verbose, false
189
- raise "[iterate_through_file_list_for_disks] Wrong input, I need an array here: #{files_list} " unless files_list.is_a?(Array)
190
-
191
- # I decided i wont accept an emopty list, this is not how you use the gem, you lazy XXX!
192
- # if files_list == [] # or files_list.nil? # empty -> ALL
193
- # deb "iterate_through_file_list_for_disks(): no args provided"
194
- # dirs = RicDisk.find_active_dirs()
195
- # puts "DEB find_active_dirs: #{green dirs}"
196
- # dirs.each {|dir|
197
- # RicDisk.write_config_yaml_to_disk(dir)
198
- # RicDisk.calculate_stats_files(dir) # dir is inutile
199
- # } # TODO refactor in option sbrodola_afterwards=true. :)
200
- # else
201
- puts "iterate_through_file_list_for_disks(): I consider files_list as a list of directories to parse :)" if verbose
202
-
203
- # dirs = RicDisk.find_active_dirs()
204
- files_list.each do |dir|
205
- dir = File.expand_path(dir)
206
- if File.directory?(dir)
207
- # if dirs.include?(dir)
208
- puts "iterate_through_file_list_for_disks() Legit dir: #{green dir}" if verbose
209
- rd = RicDisk.new(Storazzo::Media::AbstractRicDisk.DirFactory(dir))
210
- pverbose true, "RicDisk from Factory (woohoo): #{rd}"
211
- rd.write_config_yaml_to_disk(dir)
212
- # RicDisk.write_config_yaml_to_disk(dir)
213
- # RicDisk.calculate_stats_files (CLASS) => will become OBJECT compute_stats_files
214
- rd.compute_stats_files() # dir is inutile # TODO
215
- else
216
- raise("Doesnt seem a dir to me, quitting: #{dir}")
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
209
+
210
+ def get_bucket_paths
211
+ get_config['Config']['Backends']['GoogleCloudStorage']['BucketPaths'].map do |complex_gcs_struct|
212
+ complex_gcs_struct['path']
217
213
  end
218
214
  end
219
- # end
220
- end # /iterate_through_file_list_for_disks
221
215
 
222
- def config_hash
223
- config['Config']
224
- end
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
249
+ end
250
+ # end
251
+ end
225
252
 
226
- def self.safe_instance()
227
- puts "This is a safe instance :)"
228
- my_config = self.instance()
229
- my_config.load
230
- my_config
231
- end
253
+ def config_hash
254
+ config['Config']
255
+ end
232
256
 
233
- def self.get_config
234
- self.instance.load unless self.instance.load_called
235
- self.instance.get_config
236
- 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
263
+
264
+ def self.get_config
265
+ instance.load unless instance.load_called
266
+ instance.get_config
267
+ end
237
268
 
238
- # # gem 'after_do'
239
- # require 'after_do'
240
- # Storazzo::RicDiskConfig.extend AfterDo
241
- # Storazzo::RicDiskConfig.after :instance do # |activity| #:pause, :finish, :resurrect, :do_today, :do_another_day
242
- # puts yellow("after INSTANCE() has been called I call LOAD!!!")
243
- # self.load
244
- # #persistor.save activity
245
- # end
246
- end # class Storazzo::RicDiskConfig
247
- 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
data/lib/storazzo.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Inspired from https://guides.rubygems.org/make-your-own-gem/#introduction
2
4
 
3
5
  module Storazzo
@@ -5,17 +7,17 @@ module Storazzo
5
7
  # require 'storazzo/translator'
6
8
 
7
9
  def latest_parser_version
8
- "1.2"
10
+ '1.2'
9
11
  end
10
12
 
11
13
  # Finds RAILS_ROOT for Storazzo Gem. Copied from:
12
14
  # https://stackoverflow.com/questions/10132949/finding-the-gem-root
13
15
  def self.root
14
- File.expand_path '../..', __FILE__
16
+ File.expand_path '..', __dir__
15
17
  end
16
18
 
17
19
  def self.version
18
- File.read(self.root + '/VERSION').chomp # "10.0.0"
20
+ File.read("#{root}/VERSION").chomp # "10.0.0"
19
21
  end
20
22
 
21
23
  # alias_method :VERSION, :version
@@ -30,12 +32,9 @@ end
30
32
 
31
33
  # nice to paste nice output
32
34
  require 'pp'
33
- require 'require_all'
34
35
 
35
- # require_all './' , 'media/'
36
- # require_all 'lib/**/*.rb'
37
36
  # require_rel '.', 'media'
38
- Dir[File.dirname(__FILE__) + '/../lib/*.rb'].each do |file|
37
+ Dir["#{File.dirname(__FILE__)}/../lib/*.rb"].each do |file|
39
38
  puts "+ Requiring... #{file}"
40
39
  require File.basename(file, File.extname(file))
41
40
  end