storazzo 0.5.7 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +7 -5
- data/Makefile +8 -6
- data/Rakefile +15 -13
- data/VERSION +1 -1
- data/bin/hello-storazzo +1 -0
- data/bin/ricdisk-magic +33 -30
- data/bin/stats-with-md5 +182 -157
- data/bin/storazzo +112 -114
- data/bin/storazzo-symlink.rb +1 -0
- data/lib/storazzo/colors.rb +77 -36
- data/lib/storazzo/common.rb +72 -68
- data/lib/storazzo/debug.rb +2 -0
- data/lib/storazzo/hashify.rb +7 -5
- data/lib/storazzo/main.rb +59 -49
- data/lib/storazzo/media/abstract_ric_disk.rb +188 -179
- data/lib/storazzo/media/gcs_bucket.rb +76 -58
- data/lib/storazzo/media/local_folder.rb +56 -42
- data/lib/storazzo/media/mount_point.rb +20 -12
- data/lib/storazzo/ric_disk.rb +386 -383
- data/lib/storazzo/ric_disk_config.rb +227 -209
- data/lib/storazzo/ric_disk_sample_config.rb +26 -24
- data/lib/storazzo/ric_disk_statsfile.rb +19 -17
- data/lib/storazzo/ric_disk_ugly.rb +1 -0
- data/lib/storazzo/version.rb +3 -3
- data/lib/storazzo.rb +6 -7
- data/storazzo.gemspec +24 -16
- data/test/benchmark/for_future_use.rb +4 -2
- data/test/benchmark/test_hashing_functions-speed.rb +17 -0
- data/test/bin/new-idea.rb +17 -0
- data/test/bin/storazzo.rb +22 -25
- data/test/media/test_abstract_ric_disk.rb +5 -3
- data/test/media/test_gcs_bucket.rb +24 -23
- data/test/media/test_local_folder.rb +24 -23
- data/test/media/test_mount_point.rb +6 -5
- data/test/test_ric_disk.rb +6 -4
- data/test/test_ric_disk_config.rb +12 -11
- data/test/test_ric_disk_stats_file.rb +5 -3
- data/test/test_storazzo.rb +6 -4
- data/var/test/disks/disk02-full/Rakefile +7 -5
- data/var/test/disks/ricdisk_stats_v11.rds +11 -0
- 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
|
-
#
|
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
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
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
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
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
|
-
|
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
|
-
|
41
|
-
|
42
|
-
|
36
|
+
DEFAULT_CONFIG_LOCATIONS = [
|
37
|
+
File.expand_path('~/.storazzo.yaml'), # HOME
|
38
|
+
File.expand_path('./.storazzo.yaml') # LOCAL DIR
|
39
|
+
].freeze
|
43
40
|
|
44
|
-
|
41
|
+
DefaultGemLocationForTests =
|
42
|
+
"#{File.expand_path('../..', __dir__)}/etc/storazzo_config.sample.yaml"
|
45
43
|
|
46
|
-
|
44
|
+
attr_accessor :config, :config_file, :load_called, :project_id
|
47
45
|
|
48
|
-
|
49
|
-
|
50
|
-
|
46
|
+
# Load from the first valid config.
|
47
|
+
def load(config_path = nil, opts = {})
|
48
|
+
verbose = opts.fetch :verbose, false
|
51
49
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
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
|
-
|
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.
|
85
|
+
@config = YAML.safe_load(File.read(paz)) # YAML.load(File.read("file_path"))
|
83
86
|
|
84
|
-
unless
|
85
|
-
|
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[
|
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
|
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
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
112
|
+
# Obsolete, call another class instead.
|
113
|
+
def load_sample_version
|
114
|
+
raise 'DEPRECATED! USE SampleRicDiskConfig.load() instead!'
|
115
|
+
end
|
106
116
|
|
107
|
-
|
108
|
-
|
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
|
-
|
111
|
-
|
112
|
-
|
120
|
+
@config['apiVersion'] # rescue :StillUnknown
|
121
|
+
# config['ConfigVersion']
|
122
|
+
end
|
113
123
|
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
124
|
+
def config_default_folder
|
125
|
+
# self.
|
126
|
+
@config['Config']['DefaultFolder'] # rescue "Unknown config_default_folder: #{$!}"
|
127
|
+
end
|
118
128
|
|
119
|
-
|
120
|
-
|
121
|
-
|
129
|
+
def config_project_id
|
130
|
+
@config['Config']['Backends']['GoogleCloudStorage']['ProjectId']
|
131
|
+
end
|
122
132
|
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
133
|
+
# doesnt work :/ alias :project_id, :config_project_id
|
134
|
+
def project_id
|
135
|
+
config_project_id
|
136
|
+
end
|
127
137
|
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
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
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
148
|
+
def already_loaded?
|
149
|
+
# return
|
150
|
+
load_called == true
|
151
|
+
end
|
142
152
|
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
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
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
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
|
-
|
165
|
-
|
178
|
+
def get_config(opts = {})
|
179
|
+
return load(opts) if @config.nil?
|
166
180
|
|
167
|
-
|
168
|
-
|
181
|
+
@config
|
182
|
+
end
|
169
183
|
|
170
|
-
|
171
|
-
|
172
|
-
|
184
|
+
def self.gem_default_config_path
|
185
|
+
"#{Storazzo.root}/etc/storazzo_config.sample.yaml"
|
186
|
+
end
|
173
187
|
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
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
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
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
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
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
|
-
|
237
|
-
|
238
|
-
|
253
|
+
def config_hash
|
254
|
+
config['Config']
|
255
|
+
end
|
239
256
|
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
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
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
264
|
+
def self.get_config
|
265
|
+
instance.load unless instance.load_called
|
266
|
+
instance.get_config
|
267
|
+
end
|
251
268
|
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
end
|
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
|
5
|
-
require_relative
|
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
|
-
|
17
|
-
#
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
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
|
33
|
+
end
|
@@ -1,24 +1,26 @@
|
|
1
|
-
#
|
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
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
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
|
-
|
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
|
-
|
17
|
-
|
18
|
-
|
17
|
+
def self.default_name
|
18
|
+
DefaultName
|
19
|
+
end
|
19
20
|
|
20
|
-
|
21
|
-
|
21
|
+
def self.version
|
22
|
+
Version
|
23
|
+
end
|
22
24
|
end
|
23
25
|
end
|
24
26
|
end
|
data/lib/storazzo/version.rb
CHANGED
@@ -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(
|
6
|
-
|
7
|
-
public
|
7
|
+
RICC_VERSION = File.read('../VERSION').chomp
|
8
8
|
|
9
9
|
def self.version
|
10
10
|
RICC_VERSION
|