safedb 0.01.0001
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.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/.yardopts +3 -0
- data/Gemfile +10 -0
- data/LICENSE +21 -0
- data/README.md +793 -0
- data/Rakefile +16 -0
- data/bin/safe +5 -0
- data/lib/configs/README.md +58 -0
- data/lib/extension/array.rb +162 -0
- data/lib/extension/dir.rb +35 -0
- data/lib/extension/file.rb +123 -0
- data/lib/extension/hash.rb +33 -0
- data/lib/extension/string.rb +572 -0
- data/lib/factbase/facts.safedb.net.ini +38 -0
- data/lib/interprete.rb +462 -0
- data/lib/keytools/PRODUCE_RAND_SEQ_USING_DEV_URANDOM.txt +0 -0
- data/lib/keytools/kdf.api.rb +243 -0
- data/lib/keytools/kdf.bcrypt.rb +265 -0
- data/lib/keytools/kdf.pbkdf2.rb +262 -0
- data/lib/keytools/kdf.scrypt.rb +190 -0
- data/lib/keytools/key.64.rb +326 -0
- data/lib/keytools/key.algo.rb +109 -0
- data/lib/keytools/key.api.rb +1391 -0
- data/lib/keytools/key.db.rb +330 -0
- data/lib/keytools/key.docs.rb +195 -0
- data/lib/keytools/key.error.rb +110 -0
- data/lib/keytools/key.id.rb +271 -0
- data/lib/keytools/key.ident.rb +243 -0
- data/lib/keytools/key.iv.rb +107 -0
- data/lib/keytools/key.local.rb +259 -0
- data/lib/keytools/key.now.rb +402 -0
- data/lib/keytools/key.pair.rb +259 -0
- data/lib/keytools/key.pass.rb +120 -0
- data/lib/keytools/key.rb +585 -0
- data/lib/logging/gem.logging.rb +132 -0
- data/lib/modules/README.md +43 -0
- data/lib/modules/cryptology/aes-256.rb +154 -0
- data/lib/modules/cryptology/amalgam.rb +70 -0
- data/lib/modules/cryptology/blowfish.rb +130 -0
- data/lib/modules/cryptology/cipher.rb +207 -0
- data/lib/modules/cryptology/collect.rb +138 -0
- data/lib/modules/cryptology/crypt.io.rb +225 -0
- data/lib/modules/cryptology/engineer.rb +99 -0
- data/lib/modules/mappers/dictionary.rb +288 -0
- data/lib/modules/storage/coldstore.rb +186 -0
- data/lib/modules/storage/git.store.rb +399 -0
- data/lib/session/fact.finder.rb +334 -0
- data/lib/session/require.gem.rb +112 -0
- data/lib/session/time.stamp.rb +340 -0
- data/lib/session/user.home.rb +49 -0
- data/lib/usecase/cmd.rb +487 -0
- data/lib/usecase/config/README.md +57 -0
- data/lib/usecase/docker/README.md +146 -0
- data/lib/usecase/docker/docker.rb +49 -0
- data/lib/usecase/edit/README.md +43 -0
- data/lib/usecase/edit/delete.rb +46 -0
- data/lib/usecase/export.rb +40 -0
- data/lib/usecase/files/README.md +37 -0
- data/lib/usecase/files/eject.rb +56 -0
- data/lib/usecase/files/file_me.rb +78 -0
- data/lib/usecase/files/read.rb +169 -0
- data/lib/usecase/files/write.rb +89 -0
- data/lib/usecase/goto.rb +57 -0
- data/lib/usecase/id.rb +36 -0
- data/lib/usecase/import.rb +157 -0
- data/lib/usecase/init.rb +63 -0
- data/lib/usecase/jenkins/README.md +146 -0
- data/lib/usecase/jenkins/jenkins.rb +208 -0
- data/lib/usecase/login.rb +71 -0
- data/lib/usecase/logout.rb +28 -0
- data/lib/usecase/open.rb +71 -0
- data/lib/usecase/print.rb +40 -0
- data/lib/usecase/put.rb +81 -0
- data/lib/usecase/set.rb +44 -0
- data/lib/usecase/show.rb +138 -0
- data/lib/usecase/terraform/README.md +91 -0
- data/lib/usecase/terraform/terraform.rb +121 -0
- data/lib/usecase/token.rb +35 -0
- data/lib/usecase/update/README.md +55 -0
- data/lib/usecase/update/rename.rb +180 -0
- data/lib/usecase/use.rb +41 -0
- data/lib/usecase/verse.rb +20 -0
- data/lib/usecase/view.rb +71 -0
- data/lib/usecase/vpn/README.md +150 -0
- data/lib/usecase/vpn/vpn.ini +31 -0
- data/lib/usecase/vpn/vpn.rb +54 -0
- data/lib/version.rb +3 -0
- data/safedb.gemspec +34 -0
- metadata +193 -0
@@ -0,0 +1,334 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
module SafeDb
|
4
|
+
|
5
|
+
# --
|
6
|
+
# -- -----------------
|
7
|
+
# -- Fact Production
|
8
|
+
# -- -----------------
|
9
|
+
# --
|
10
|
+
# -- The fact tree is tasked with fact production
|
11
|
+
# -- (population). Fact production is done by [consuming]
|
12
|
+
# --
|
13
|
+
# -- [1] - simple string, number of boolean facts
|
14
|
+
# -- [2] - facts already produced
|
15
|
+
# -- [3] - identity facts from command line and environment
|
16
|
+
# -- [4] - software (behaviour) that derives facts
|
17
|
+
# -- [5] - inherited (extended) facts from (OO) parents
|
18
|
+
# --
|
19
|
+
# --
|
20
|
+
# --
|
21
|
+
# -- -----------------------------------------
|
22
|
+
# -- The 4 Universal (DevOps) Creation Facts
|
23
|
+
# -- -----------------------------------------
|
24
|
+
# --
|
25
|
+
# -- No matter the (DevOps) eco-system being fabricated, these four
|
26
|
+
# -- facts prevail and stand out.
|
27
|
+
# --
|
28
|
+
# -- Every time a DevOps [eco-system] is created, cloned, or recovered,
|
29
|
+
# -- a small cluster of core facts endure to define the instance and act
|
30
|
+
# -- as the identification basis of all new eco-system resources.
|
31
|
+
# --
|
32
|
+
# -- The 4 facts underpinning eco-system creation are
|
33
|
+
# --
|
34
|
+
# -- [1] - [what] is being built
|
35
|
+
# -- [2] - [when] did the building begin
|
36
|
+
# -- [3] - [who] instigated it (and from)
|
37
|
+
# -- [4] - [which] workstation.
|
38
|
+
# --
|
39
|
+
# -- ---------------------------------------
|
40
|
+
# -- DevOps 4 Creational [Instance] Facts
|
41
|
+
# -- ---------------------------------------
|
42
|
+
# --
|
43
|
+
# -- The core instance identities used and reused time and again relate to
|
44
|
+
# --
|
45
|
+
# -- [1] - plugin (eg) wordpress.hub or jenkins.hub
|
46
|
+
# -- [2] - time (eg) 18036.0952.065
|
47
|
+
# -- [3] - user (eg) peterpan
|
48
|
+
# -- [4] - workstation (eg) laptop_susie or hp_desktop
|
49
|
+
# --
|
50
|
+
# --
|
51
|
+
class FactFind
|
52
|
+
|
53
|
+
@@eval_prefix = "rb>>"
|
54
|
+
|
55
|
+
# The fact tree values can be referenced using the @f
|
56
|
+
# specifier with a 2 dimensional key.
|
57
|
+
attr_reader :f
|
58
|
+
|
59
|
+
|
60
|
+
# This method constructs the FactFind object and tree database
|
61
|
+
# and initializers the root fact container structures.
|
62
|
+
def initialize
|
63
|
+
|
64
|
+
@f = {}
|
65
|
+
@s = {}
|
66
|
+
|
67
|
+
# ---> @f.store symbol(plugin_id), {}
|
68
|
+
# ---> @p = @f[symbol(plugin_id)]
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
|
73
|
+
# Assimilate the gem's main factbase fact file into
|
74
|
+
# the structure that is exposed to outside classes
|
75
|
+
# as the instance variable @f (a 2D array type).
|
76
|
+
#
|
77
|
+
# The factfile to assimilate is always expected to
|
78
|
+
# exist in folder [ ../factbase ]
|
79
|
+
#
|
80
|
+
# The factfile name within the above folder is expected
|
81
|
+
# to be presented in the parameter.
|
82
|
+
#
|
83
|
+
# @param factfile_name [String] name of factfile to assimilate
|
84
|
+
def assimilate factfile_name
|
85
|
+
|
86
|
+
factfile_dir = File.join(File.dirname(File.expand_path(__FILE__)), "../factbase")
|
87
|
+
factfile_path = File.join factfile_dir, factfile_name
|
88
|
+
|
89
|
+
log.info(x) { "Assimilating factfile in folder => #{factfile_dir}" }
|
90
|
+
log.info(x) { "Assimilating factfile with name => #{factfile_name}" }
|
91
|
+
|
92
|
+
assimilate_ini_file factfile_path
|
93
|
+
|
94
|
+
end
|
95
|
+
|
96
|
+
|
97
|
+
# ----> -------------------------------------------------->
|
98
|
+
# ----> How to Write a Custom Error
|
99
|
+
# ----> -------------------------------------------------->
|
100
|
+
# ----> Add a custom data attributes to your exception
|
101
|
+
# ----> You can add custom data to your exception just like you'd do it in any other class. Let's add an attribute reader to our class and update the constructor.
|
102
|
+
# ----> class MyError < StandardError
|
103
|
+
# ----> attr_reader :thing
|
104
|
+
# ----> def initialize(msg="My default message", thing="apple")
|
105
|
+
# ----> @thing = thing
|
106
|
+
# ----> super(msg)
|
107
|
+
# ----> end
|
108
|
+
# ----> end
|
109
|
+
# ----> -------------------------------------------------->
|
110
|
+
# ----> Using the Custom Error Class
|
111
|
+
# ----> -------------------------------------------------->
|
112
|
+
# ----> begin
|
113
|
+
# ----> raise MyError.new("my message", "my thing")
|
114
|
+
# ----> rescue => e
|
115
|
+
# ----> puts e.thing # "my thing"
|
116
|
+
# ----> end
|
117
|
+
# ----> -------------------------------------------------->
|
118
|
+
|
119
|
+
|
120
|
+
# -- ------------------------------------------- -- #
|
121
|
+
# -- -- #
|
122
|
+
# -- Template -- #
|
123
|
+
# -- -- #
|
124
|
+
# -- The longest river in africa is without -- #
|
125
|
+
# -- doubt the @[africa|longest.river]. Now -- #
|
126
|
+
# -- @[south.america|most.spoken] is the -- #
|
127
|
+
# -- most common language in south america. -- #
|
128
|
+
# -- -- #
|
129
|
+
# -- The population of the americas -- #
|
130
|
+
# -- is @[americas|population] according to
|
131
|
+
# -- the Harvard 2015 census.
|
132
|
+
# -- -- #
|
133
|
+
# -- ------------------------------------------- -- #
|
134
|
+
# -- -- #
|
135
|
+
# -- Ruby Code -- #
|
136
|
+
# -- -- #
|
137
|
+
# -- double_north_america_pop = @f[:north_america][:population] * 2
|
138
|
+
# -- -- #
|
139
|
+
# -- ------------------------------------------- -- #
|
140
|
+
# -- Parameters -- #
|
141
|
+
# -- factory_facts : instantiated 2D hash -- #
|
142
|
+
# -- ini_filepath : path to factfile to read -- #
|
143
|
+
# -- -- #
|
144
|
+
# -- Dependencies and Assumptions -- #
|
145
|
+
# -- the [inifile] gem is installed -- #
|
146
|
+
# -- file exists at the ini_filepath -- #
|
147
|
+
# -- factory_facts are instantiated -- #
|
148
|
+
# -- identity facts like @i[:plugin] exist -- #
|
149
|
+
# -- ------------------------------------------- -- #
|
150
|
+
def assimilate_ini_file ini_filepath
|
151
|
+
|
152
|
+
fact_filename = File.basename ini_filepath
|
153
|
+
log_begin fact_filename
|
154
|
+
|
155
|
+
no_file = "No (ini) factfile found here => #{ini_filepath}"
|
156
|
+
raise ArgumentError.new no_file unless File.exists? ini_filepath
|
157
|
+
|
158
|
+
# --
|
159
|
+
# -- Use the inifile gem to parse and read the fact
|
160
|
+
# -- file contents into Ruby's map structures.
|
161
|
+
# --
|
162
|
+
begin
|
163
|
+
|
164
|
+
map_facts = IniFile.load ini_filepath
|
165
|
+
map_facts.each do | group_str, key_str, input_value |
|
166
|
+
assimilate_fact group_str, key_str, input_value
|
167
|
+
end
|
168
|
+
|
169
|
+
rescue Exception => e
|
170
|
+
|
171
|
+
log.fatal(x) { "## ############################ #################################" }
|
172
|
+
log.fatal(x) { "## Fact File Assimilation Error ---------------------------------" }
|
173
|
+
log.fatal(x) { "## ############################ #################################" }
|
174
|
+
log.fatal(x) { "## File => #{ini_filepath}" }
|
175
|
+
log.fatal(x) { "## Error => #{e.message}" }
|
176
|
+
log.fatal(x) { "## ############################ #################################" }
|
177
|
+
e.backtrace.log_lines
|
178
|
+
log.fatal(x) { "## ############################ #################################" }
|
179
|
+
|
180
|
+
raise e
|
181
|
+
|
182
|
+
end
|
183
|
+
|
184
|
+
log_end fact_filename
|
185
|
+
|
186
|
+
end
|
187
|
+
|
188
|
+
|
189
|
+
|
190
|
+
# This method assimilates a two-dimensional fact bringing it into the
|
191
|
+
# fact tree fold.
|
192
|
+
#
|
193
|
+
# Once assimilated, this fact with a 2D index can be reused
|
194
|
+
# - for future fact resolution
|
195
|
+
# - by classes with access to the fact tree
|
196
|
+
# - for dynamic template resolution
|
197
|
+
#
|
198
|
+
# @param fact_group_str the first dimensional fact key
|
199
|
+
# @param fact_key_str the second dimensional fact key
|
200
|
+
# @param fact_value_str value of the fact to assimilate
|
201
|
+
def assimilate_fact fact_group_str, fact_key_str, fact_value_str
|
202
|
+
|
203
|
+
grp_symbol = fact_group_str.gsub(".", "_").to_sym
|
204
|
+
key_symbol = fact_key_str.gsub(".", "_").to_sym
|
205
|
+
|
206
|
+
raise ArgumentError, "Assimilating Fact [ #{fact_group_str} ][ #{fact_key_str} ] => Value is NIL" if fact_value_str.nil?
|
207
|
+
fact_string = fact_value_str.strip
|
208
|
+
|
209
|
+
begin
|
210
|
+
|
211
|
+
raise ArgumentError, "Fact object in section #{fact_group_str} with key #{fact_key_str} is nil." if fact_string.nil?
|
212
|
+
eval_value = evaluate( fact_string )
|
213
|
+
add_fact grp_symbol, to_symbol(fact_key_str), eval_value
|
214
|
+
|
215
|
+
rescue Exception => e
|
216
|
+
|
217
|
+
log.fatal(x) { "## ##################### #################################" }
|
218
|
+
log.fatal(x) { "## Fact Evaluation Error ---------------------------------" }
|
219
|
+
log.fatal(x) { "## ##################### #################################" }
|
220
|
+
log.fatal(x) { "## Fact Family => #{fact_group_str}" }
|
221
|
+
log.fatal(x) { "## Fact Key => #{fact_key_str}" }
|
222
|
+
log.fatal(x) { "## Fact Stmt => #{fact_string}" }
|
223
|
+
log.fatal(x) { "## Fact Error => #{e.message}" }
|
224
|
+
log.fatal(x) { "## ##################### #################################" }
|
225
|
+
e.backtrace.log_lines
|
226
|
+
|
227
|
+
raise e
|
228
|
+
|
229
|
+
end
|
230
|
+
|
231
|
+
unless @f.has_key? grp_symbol then
|
232
|
+
|
233
|
+
log.debug(x){ "# @@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ #" }
|
234
|
+
log.debug(x){ "# @@ the [#{fact_group_str}] silo facts." }
|
235
|
+
log.debug(x){ "# @@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ #" }
|
236
|
+
|
237
|
+
end
|
238
|
+
|
239
|
+
id_keystring = "#{grp_symbol}#{key_symbol}".downcase
|
240
|
+
sensitive = id_keystring.includes_any? [ "secret", "password", "credential", "creds" ]
|
241
|
+
print_value = "****************"
|
242
|
+
print_value = eval_value unless sensitive
|
243
|
+
|
244
|
+
fw_key = sprintf '%-33s', "@f[:#{grp_symbol}][:#{key_symbol}]"
|
245
|
+
log.debug(x){ "#{fw_key} => #{print_value}" }
|
246
|
+
|
247
|
+
end
|
248
|
+
|
249
|
+
|
250
|
+
|
251
|
+
# This static method converts from string to symbol.
|
252
|
+
# @param from_string the neither nil nor empty string to convert to a symbol
|
253
|
+
# @return a symbol representation of the input string
|
254
|
+
def to_symbol from_string
|
255
|
+
return from_string.strip.gsub(".", "_").to_sym
|
256
|
+
end
|
257
|
+
|
258
|
+
|
259
|
+
|
260
|
+
private
|
261
|
+
|
262
|
+
|
263
|
+
|
264
|
+
def add_fact group_symbol, key_symbol, key_value
|
265
|
+
|
266
|
+
fact_component = "[group]=> #{group_symbol} [key]=> #{key_symbol} [value]=> #{key_value}"
|
267
|
+
nil_error_text = "Neither fact coordinates nor values can be nil. #{fact_component}"
|
268
|
+
raise ArgumentError.new nil_error_text if group_symbol.nil? || key_symbol.nil? || key_value.nil?
|
269
|
+
|
270
|
+
if @f.has_key? group_symbol then
|
271
|
+
|
272
|
+
# -- This isn't the first fact within this group
|
273
|
+
# -- so store the new fact key/value pair within
|
274
|
+
# -- the group's namespace.
|
275
|
+
@f[group_symbol][key_symbol] = key_value
|
276
|
+
|
277
|
+
else
|
278
|
+
|
279
|
+
# -- Create a new umbrella grouping against which
|
280
|
+
# -- the new key-value pairing will be inserted.
|
281
|
+
@f.store group_symbol, { key_symbol => key_value }
|
282
|
+
|
283
|
+
end
|
284
|
+
|
285
|
+
# -- The @s sibling hash is updated to reflect the
|
286
|
+
# -- key-value pairs within the current group. This
|
287
|
+
# -- allows @s to be used as shorthand within INI
|
288
|
+
# -- file fact definition statements.
|
289
|
+
@s = @f[group_symbol]
|
290
|
+
|
291
|
+
end
|
292
|
+
|
293
|
+
|
294
|
+
def evaluate string
|
295
|
+
|
296
|
+
# -----> @todo raise a FactError here
|
297
|
+
|
298
|
+
raise RuntimeError.new "Fact to Evaluate is Nil." if string.nil?
|
299
|
+
return string unless string.start_with? @@eval_prefix
|
300
|
+
return eval( string.gsub @@eval_prefix, "" )
|
301
|
+
|
302
|
+
end
|
303
|
+
|
304
|
+
|
305
|
+
def log_begin the_filename
|
306
|
+
|
307
|
+
log.info(x) { "- -" }
|
308
|
+
log.info(x) { "# @@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@ #" }
|
309
|
+
log.info(x) { "# -- ------------------------------------------------- -- #" }
|
310
|
+
log.info(x) { "# -- [= BEGIN THE ASSIMILATION =] #{the_filename}" }
|
311
|
+
log.info(x) { "# -- ------------------------------------------------- -- #" }
|
312
|
+
log.info(x) { "# @@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@ #" }
|
313
|
+
|
314
|
+
end
|
315
|
+
|
316
|
+
|
317
|
+
def log_end the_filename
|
318
|
+
|
319
|
+
log.info(x) { "# @@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@ #" }
|
320
|
+
log.info(x) { "# -- ------------------------------------------------- -- #" }
|
321
|
+
log.info(x) { "# -- [= END ASSIMILATION =] #{the_filename}" }
|
322
|
+
log.info(x) { "# -- ------------------------------------------------- -- #" }
|
323
|
+
log.info(x) { "# @@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@ #" }
|
324
|
+
log.info(x) { "- -" }
|
325
|
+
log.info(x) { "- -" }
|
326
|
+
log.info(x) { "- -" }
|
327
|
+
|
328
|
+
end
|
329
|
+
|
330
|
+
|
331
|
+
end
|
332
|
+
|
333
|
+
|
334
|
+
end
|
@@ -0,0 +1,112 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
# coding: utf-8
|
3
|
+
|
4
|
+
module OpenSession
|
5
|
+
|
6
|
+
|
7
|
+
# Require every file with a dot rb extension that is
|
8
|
+
# +either directly in or recursively below+ the calling gem's
|
9
|
+
# directory.
|
10
|
+
#
|
11
|
+
# Note that this class and its methods depend on an initialized
|
12
|
+
# logger so as a pre-condition, ensure the logging has been
|
13
|
+
# instantiated before calling.
|
14
|
+
#
|
15
|
+
# == The Base Require Path
|
16
|
+
#
|
17
|
+
# Here is an example of the base require path being derived.
|
18
|
+
#
|
19
|
+
# @example
|
20
|
+
# Let's assume that the
|
21
|
+
#
|
22
|
+
# - ruby gems version is <tt>2.3.0</tt>, and the
|
23
|
+
# - safe version is <tt>0.0.944</tt>, and the
|
24
|
+
# - calling class is in the <tt>lib</tt> directory
|
25
|
+
#
|
26
|
+
# +then+ the gem base path would be
|
27
|
+
#
|
28
|
+
# <tt>/var/lib/gems/2.3.0/gems/safe-0.0.944/lib</tt>
|
29
|
+
#
|
30
|
+
# This means every ruby (.rb) file both +directly in+ and
|
31
|
+
# +recursively below+ the <tt>lib</tt> directory will be
|
32
|
+
# required.
|
33
|
+
#
|
34
|
+
#
|
35
|
+
# == Requiring Parental Classes Before Child Classes
|
36
|
+
#
|
37
|
+
# This is a common problem when bringing classes in to join
|
38
|
+
# the fray. We must require the +Planet+ class before
|
39
|
+
# we require the +Neptune+ class.
|
40
|
+
#
|
41
|
+
# <tt>class Neptune < Planet</tt>
|
42
|
+
#
|
43
|
+
# The solution lies in the directory structure between parent
|
44
|
+
# and child classes and this is illustrated by +plugins+.
|
45
|
+
#
|
46
|
+
# ------------------------
|
47
|
+
# Plugins Folder Structure
|
48
|
+
# ------------------------
|
49
|
+
#
|
50
|
+
# In the plugins hierarchy, you'll notice that the child classes
|
51
|
+
# are always below the parents. This strategy works if the +inheritors+
|
52
|
+
# are in the same gem as the +inherited+.
|
53
|
+
class RecursivelyRequire
|
54
|
+
|
55
|
+
# Require every file with a dot rb extension that is
|
56
|
+
# +either in or recursively below+ the file path given
|
57
|
+
# in the parameter.
|
58
|
+
#
|
59
|
+
# This method logs every file that is required using
|
60
|
+
# the INFO log level.
|
61
|
+
#
|
62
|
+
# == Requiring Parental Classes Before Child Classes
|
63
|
+
#
|
64
|
+
# This is a common problem when bringing classes in to join
|
65
|
+
# the fray. We must require the +Planet+ class before
|
66
|
+
# we require the +Neptune+ class.
|
67
|
+
#
|
68
|
+
# <tt>class Neptune < Planet</tt>
|
69
|
+
#
|
70
|
+
# The solution lies in the directory structure between parent
|
71
|
+
# and child classes and this is illustrated by +plugins+.
|
72
|
+
#
|
73
|
+
# ------------------------
|
74
|
+
# Plugins Folder Structure
|
75
|
+
# ------------------------
|
76
|
+
#
|
77
|
+
# In the plugins hierarchy, you'll notice that the child classes
|
78
|
+
# are always below the parents. This strategy works if the +inheritors+
|
79
|
+
# are in the same gem as the +inherited+.
|
80
|
+
#
|
81
|
+
# This require loop is <tt>breadth first</tt> not <tt>depth first</tt>
|
82
|
+
# so all the parent (base) classes in plugins will be required before
|
83
|
+
# their extension classes in the lower subdirectories.
|
84
|
+
#
|
85
|
+
# @param gem_filepath [String] path to callling gem (use <tt>__FILE</tt>)
|
86
|
+
def self.now gem_filepath
|
87
|
+
|
88
|
+
|
89
|
+
############ require_relative "../cryptools/keygen"
|
90
|
+
require_relative "../usecase/cmd"
|
91
|
+
|
92
|
+
|
93
|
+
gem_basepath = File.expand_path "..", gem_filepath
|
94
|
+
|
95
|
+
log.info(x) { "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" }
|
96
|
+
log.info(x) { "@@@@ Require Gems In or Under [#{gem_basepath}]" }
|
97
|
+
log.info(x) { "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" }
|
98
|
+
|
99
|
+
Dir["#{gem_basepath}/**/*.rb"].each do |gem_path|
|
100
|
+
|
101
|
+
log.info(x) { "@@@@ => #{gem_path}" }
|
102
|
+
require gem_path
|
103
|
+
|
104
|
+
end
|
105
|
+
|
106
|
+
log.info(x) { "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" }
|
107
|
+
|
108
|
+
end
|
109
|
+
|
110
|
+
end
|
111
|
+
|
112
|
+
end
|