aro 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/Gemfile.lock +3 -2
  4. data/README.md +1 -1
  5. data/aro.gemspec +1 -0
  6. data/bin/aos +2 -2
  7. data/bin/aro +4 -4
  8. data/checksums/aro-0.2.1.gem.sha512 +1 -0
  9. data/checksums/aro-0.2.2.gem.sha512 +1 -0
  10. data/listen.rb +1 -1
  11. data/locale/en.amg.yml +44 -0
  12. data/locale/en.aos.yml +13 -8
  13. data/locale/en.data.yml +30 -0
  14. data/locale/en.dom.yml +10 -8
  15. data/locale/en.usage.yml +22 -22
  16. data/locale/en.yml +16 -11
  17. data/sys/aos/amg.rb +184 -0
  18. data/sys/aos/aos.rb +203 -89
  19. data/sys/aos/data.rb +117 -0
  20. data/{db → sys/aos/db}/migrate/1765148774_create_yous.rb +1 -0
  21. data/sys/aos/db/migrate/1765762724_create_ilibs.rb +22 -0
  22. data/sys/aos/db/migrate/1765907766_create_ilogs.rb +18 -0
  23. data/sys/aos/db.rb +44 -25
  24. data/sys/aos/models/ilib.rb +46 -0
  25. data/sys/aos/models/ilog.rb +27 -0
  26. data/sys/aos/models/you.rb +50 -0
  27. data/sys/aos/vws/base.rb +120 -0
  28. data/sys/aos/{views → vws}/dom.rb +6 -10
  29. data/sys/aos/vws/games/abpps.rb +19 -0
  30. data/sys/aos/{views → vws}/games/game.rb +26 -25
  31. data/sys/aos/vws/games/hbpps.rb +19 -0
  32. data/sys/aos/vws/games/shpps.rb +19 -0
  33. data/sys/aos/vws/games/vipps.rb +19 -0
  34. data/sys/aos/{views → vws}/games.rb +3 -3
  35. data/sys/aos/vws/know/body.rb +19 -0
  36. data/sys/aos/vws/know/mind.rb +19 -0
  37. data/sys/aos/vws/know/spirit.rb +19 -0
  38. data/sys/aos/{views → vws}/know.rb +3 -3
  39. data/sys/aos/vws/root/amg.rb +21 -0
  40. data/sys/aos/vws/root/config.rb +21 -0
  41. data/sys/aos/vws/root/data.rb +21 -0
  42. data/sys/aos/{views/setup.rb → vws/root.rb} +4 -4
  43. data/sys/aos/vws/welcome/waite.rb +31 -0
  44. data/sys/aos/{views → vws}/welcome/winner.rb +3 -3
  45. data/sys/aos/vws/welcome.rb +30 -0
  46. data/{db/migrate/1763374647_create_decks.rb → sys/aro/db/migrate/1763374647_create_tecks.rb} +5 -5
  47. data/sys/aro/db/migrate/1763432541_create_tlogs.rb +20 -0
  48. data/sys/aro/db.rb +16 -15
  49. data/sys/aro/mancy.rb +4 -3
  50. data/sys/{models/deck.rb → aro/models/teck.rb} +56 -62
  51. data/sys/aro/models/tlog.rb +20 -0
  52. data/sys/aro/v.rb +1 -1
  53. data/sys/cli/constants.rb +1 -1
  54. data/sys/cli/dom.rb +1 -1
  55. data/sys/cli/{deck.rb → teck.rb} +20 -15
  56. data/sys/cli.rb +12 -12
  57. data/sys/dom/config.rb +718 -0
  58. data/sys/dom/d.rb +36 -18
  59. data/sys/dom/dom.rb +24 -14
  60. data/sys/reiquire.rb +8 -8
  61. data/sys/shr/ilib/crs/CMakeLists.txt +12 -0
  62. data/sys/shr/ilib/crs/compile.sh +5 -0
  63. data/sys/shr/ilib/crs/crs.c +24 -0
  64. data/sys/shr/ilib/crs/crs.o +0 -0
  65. data/sys/shr/ilib/crs/libcrs.so +0 -0
  66. data/sys/shr/prompt.rb +1 -5
  67. data/sys/shr/t.rb +14 -8
  68. data/sys/shr/version.rb +1 -1
  69. metadata +63 -26
  70. data/db/migrate/1763432541_create_logs.rb +0 -20
  71. data/locale/en.cngelog.yml +0 -5
  72. data/sys/aos/views/base.rb +0 -166
  73. data/sys/aos/views/games/abpps.rb +0 -21
  74. data/sys/aos/views/games/hbpps.rb +0 -21
  75. data/sys/aos/views/games/shpps.rb +0 -21
  76. data/sys/aos/views/games/vipps.rb +0 -21
  77. data/sys/aos/views/know/library.rb +0 -19
  78. data/sys/aos/views/know/temple.rb +0 -19
  79. data/sys/aos/views/setup/settings.rb +0 -37
  80. data/sys/aos/views/welcome/waite.rb +0 -19
  81. data/sys/aos/views/welcome.rb +0 -19
  82. data/sys/aos/you.rb +0 -19
  83. data/sys/cli/config.rb +0 -669
  84. data/sys/models/log.rb +0 -20
data/sys/cli/config.rb DELETED
@@ -1,669 +0,0 @@
1
- =begin
2
-
3
- config.rb
4
-
5
- configuration interface.
6
-
7
- by i2097i
8
-
9
- =end
10
-
11
- module CLI
12
-
13
- # cli entrypoint
14
- def self.config
15
- CLI::Config.process_config_command(ARGV)
16
- end
17
-
18
- class Config
19
- include Singleton
20
-
21
- ARO_CONFIG_PREFIX = :ARO_CONFIG_
22
- ARO_ENV_PREFIX = :ARO_ENV_
23
-
24
- CONFIG_FILE = :".config"
25
-
26
- DATE_FORMAT = "%Y:%m:%d:%H:%M:%S"
27
-
28
- # possible envs
29
- #
30
- # example usage:
31
- # CLI::Config::ENVS[:PRODUCTION]
32
- ENVS = {
33
- DEVELOPMENT: :development,
34
- PRODUCTION: :production,
35
- TEST: :test,
36
- }
37
-
38
- # possible formats
39
- #
40
- # example usage:
41
- # CLI::Config::FORMATS[:TEXT]
42
- FORMATS = {
43
- TEXT: :text,
44
- JSON: :json,
45
- }
46
-
47
- # possible dimensions
48
- #
49
- # example usage:
50
- # CLI::Config::DMS[:DEV_TAROT]
51
- DMS = {
52
- DEV_TAROT: :dev_tarot,
53
- RUBY_FACOT: :ruby_facot,
54
- }
55
-
56
- # ovar and ivar access
57
- #
58
- # example usage:
59
- # CLI::Config::DEF_ACCESS[:READ]
60
- DEF_ACCESS = {
61
- READ: :read,
62
- WRITE: :write
63
- }
64
-
65
- BOOLS = {
66
- FALSE: false,
67
- TRUE: true,
68
- }
69
-
70
- TYPES = {
71
- BOOL: :bool,
72
- INT: :int,
73
- STRING: :string,
74
- VALUES: :values
75
- }
76
-
77
- # types used in definition
78
- #
79
- # example usage:
80
- # CLI::Config::DEF_TYPES[:INT][:validator].call(unvalid, CLI::Config::DEF[:DIMENSION])
81
- DEF_TYPES = {
82
- BOOL: {
83
- name: CLI::Config::TYPES[:BOOL],
84
- description: I18n.t("cli.config.type.bool_description"),
85
- converter: Proc.new{|v|
86
- if [CLI::Config::BOOLS[:TRUE].to_s, Aro::Mancy::S].include?(v)
87
- CLI::Config::BOOLS[:TRUE]
88
- else
89
- CLI::Config::BOOLS[:FALSE]
90
- end
91
- },
92
- validator: Proc.new{|unvalid, k, v|
93
- CLI::Config.def_valid?(k, v) &&
94
- CLI::Config.bool_valid?(unvalid)
95
- }
96
- },
97
- INT: {
98
- name: :int,
99
- description: I18n.t("cli.config.type.int_description"),
100
- converter: Proc.new{|v| v.to_i},
101
- validator: Proc.new{|unvalid, k, v|
102
- Aro::V.say("validating #{k} (#{CLI::Config::DEF_TYPES[:INT][:name]})")
103
- Aro::V.say("unvalid = #{unvalid}")
104
- Aro::V.say("[min, max] = [#{v[:min]}, #{v[:max]}]")
105
- int_valid = CLI::Config.def_valid?(k, v) &&
106
- CLI::Config.int_valid?(unvalid) &&
107
- unvalid.to_i >= v[:min] &&
108
- unvalid.to_i <= v[:max]
109
- Aro::V.say("unvalid(#{unvalid}) is#{int_valid ? " " : :" not ".to_s}valid.")
110
- int_valid
111
- }
112
- },
113
- STRING: {
114
- name: :string,
115
- description: I18n.t("cli.config.type.string_description"),
116
- converter: Proc.new{|v| v.to_s},
117
- validator: Proc.new{|unvalid, k, v|
118
- CLI::Config.def_valid?(k, v) &&
119
- CLI::Config.string_valid?(unvalid)
120
- }
121
- },
122
- VALUES: {
123
- name: :values,
124
- description: I18n.t("cli.config.type.values_description"),
125
- converter: Proc.new{|v| v.to_s},
126
- validator: Proc.new{|unvalid, k, v|
127
- CLI::Config.def_valid?(k, v) &&
128
- v[:possible_values].keys.include?(unvalid&.to_sym)
129
- }
130
- },
131
- }
132
-
133
- def self.bool_valid?(unvalid)
134
- CLI::Config::BOOLS.values.map{|b| b.to_s.to_sym}.include?(unvalid&.to_s&.to_sym)
135
- end
136
-
137
- def self.int_valid?(unvalid)
138
- !unvalid&.to_i.nil?
139
- end
140
-
141
- def self.string_valid?(unvalid)
142
- unvalid.is_a?(String)
143
- end
144
-
145
- def self.def_valid?(key, deff)
146
- def_valid = deff == CLI::Config::DEF[key]
147
- unless def_valid
148
- Aro::V.say("invalid def! #{key} => #{deff}")
149
- end
150
-
151
- def_valid
152
- end
153
-
154
- def validate_config
155
- invalid_vars = []
156
- CLI::Config::DEF.each{|k, v|
157
- is_valid = v[:access] == CLI::Config::DEF_ACCESS[:READ]
158
- unless is_valid
159
- is_valid = valid_var?(CLI::Config.ivar(k), k, v)
160
- end
161
- invalid_vars << k unless is_valid
162
- }
163
- invalid_vars
164
- end
165
-
166
- def valid_var?(var_value, k, v)
167
- Aro::V.say(v)
168
- return true if v[:access] == CLI::Config::DEF_ACCESS[:READ]
169
-
170
- CLI::Config::DEF_TYPES[
171
- v[:type].to_s.upcase.to_sym
172
- ][:validator].call(var_value, k, v)
173
- end
174
-
175
- def convert_var_for_def(k)
176
- CLI::Config::DEF_TYPES[
177
- CLI::Config::DEF[k][:type].upcase
178
- ][:converter].call(ENV[CLI::Config.ivar_k(k)])
179
- end
180
-
181
- # adapts I18n translations to generate bash environment vars.
182
- #
183
- # example usage:
184
- # CLI::Config::DEF[:Z_MAX]
185
- DEF = {
186
-
187
- #
188
- # => ivars
189
- #
190
- ENV: {
191
- type: CLI::Config::TYPES[:VALUES],
192
- access: CLI::Config::DEF_ACCESS[:WRITE],
193
- value: CLI::Config::ENVS[:PRODUCTION],
194
- description: I18n.t("cli.config.env.description"),
195
- possible_values: {
196
- development: I18n.t("cli.config.env.development_description"),
197
- production: I18n.t("cli.config.env.production_description"),
198
- test: I18n.t("cli.config.env.test_description"),
199
- }
200
- },
201
- VERBOSE: {
202
- type: CLI::Config::TYPES[:BOOL],
203
- access: CLI::Config::DEF_ACCESS[:WRITE],
204
- value: CLI::Config::BOOLS[:FALSE],
205
- description: I18n.t("cli.config.verbose_description"),
206
- },
207
- LOG_AOS_DB: {
208
- type: CLI::Config::TYPES[:BOOL],
209
- access: CLI::Config::DEF_ACCESS[:WRITE],
210
- value: CLI::Config::BOOLS[:FALSE],
211
- description: I18n.t("cli.config.log_aos_db_description"),
212
- },
213
- LOG_ARO_DB: {
214
- type: CLI::Config::TYPES[:BOOL],
215
- access: CLI::Config::DEF_ACCESS[:WRITE],
216
- value: CLI::Config::BOOLS[:FALSE],
217
- description: I18n.t("cli.config.log_aro_db_description"),
218
- },
219
- FORMAT: { # not implemented yet.
220
- type: CLI::Config::TYPES[:VALUES],
221
- implemented: false,
222
- access: CLI::Config::DEF_ACCESS[:WRITE],
223
- value: CLI::Config::FORMATS[:TEXT],
224
- description: I18n.t("cli.config.format.description"),
225
- possible_values: {
226
- text: I18n.t("cli.config.format.text_description"),
227
- json: I18n.t("cli.config.format.json_description")
228
- }
229
- },
230
- DIMENSION: {
231
- type: CLI::Config::TYPES[:VALUES],
232
- access: CLI::Config::DEF_ACCESS[:WRITE],
233
- value: CLI::Config::DMS[:DEV_TAROT],
234
- description: I18n.t("cli.config.dimension.description"),
235
- possible_values: {
236
- dev_tarot: I18n.t("cli.config.dimension.dev_tarot_description"),
237
- ruby_facot: I18n.t("cli.config.dimension.ruby_facot_description"),
238
- }
239
- },
240
- HEIGHT: {
241
- type: CLI::Config::TYPES[:INT],
242
- access: CLI::Config::DEF_ACCESS[:WRITE],
243
- value: Aro::Mancy::NUMERALS[:XLII],
244
- min: Aro::Mancy::NUMERALS[:I],
245
- max: Aro::Mancy::NUMERALS[:MMXCVII],
246
- description: I18n.t(
247
- "cli.config.height_description",
248
- min: Aro::Mancy::NUMERALS[:I],
249
- max: Aro::Mancy::NUMERALS[:VII].pow(Aro::Mancy::OS),
250
- ),
251
- },
252
- WIDTH: {
253
- type: CLI::Config::TYPES[:INT],
254
- access: CLI::Config::DEF_ACCESS[:WRITE],
255
- value: Aro::Mancy::NUMERALS[:C] + Aro::Mancy::NUMERALS[:XXXVII] - Aro::Mancy::S,
256
- min: Aro::Mancy::NUMERALS[:I],
257
- max: Aro::Mancy::NUMERALS[:MMXCVII],
258
- description: I18n.t(
259
- "cli.config.width_description",
260
- min: Aro::Mancy::NUMERALS[:I],
261
- max: Aro::Mancy::NUMERALS[:XI].pow(Aro::Mancy::OS),
262
- ),
263
- },
264
- Z: {
265
- type: CLI::Config::TYPES[:INT],
266
- access: CLI::Config::DEF_ACCESS[:WRITE],
267
- value: Aro::Mancy::NUMERALS[:I],
268
- min: Aro::Mancy::NUMERALS[:I],
269
- max: Aro::Mancy::NUMERALS[:MMXCVII],
270
- description: I18n.t(
271
- "cli.config.z_description",
272
- min: Aro::Mancy::NUMERALS[:I],
273
- max: Aro::Mancy::NUMERALS[:MMXCVII],
274
- ),
275
- },
276
- Z_MAX: {
277
- type: CLI::Config::TYPES[:INT],
278
- access: CLI::Config::DEF_ACCESS[:WRITE],
279
- value: Aro::Mancy::NUMERALS[:VII],
280
- min: Aro::Mancy::NUMERALS[:I],
281
- max: Aro::Mancy::NUMERALS[:XXII],
282
- description: I18n.t(
283
- "cli.config.z_max_description",
284
- min: Aro::Mancy::NUMERALS[:I],
285
- max: Aro::Mancy::NUMERALS[:XXII],
286
- ),
287
- },
288
-
289
- #
290
- # => ovars
291
- #
292
- ARO_ENV_O: {
293
- type: CLI::Config::TYPES[:INT],
294
- access: CLI::Config::DEF_ACCESS[:READ],
295
- value: Aro::Mancy::O,
296
- description: I18n.t("cli.config.aro_env.O_description"),
297
- },
298
- ARO_ENV_S: {
299
- type: CLI::Config::TYPES[:INT],
300
- access: CLI::Config::DEF_ACCESS[:READ],
301
- value: Aro::Mancy::S,
302
- description: I18n.t("cli.config.aro_env.S_description"),
303
- },
304
- ARO_ENV_OS: {
305
- type: CLI::Config::TYPES[:INT],
306
- access: CLI::Config::DEF_ACCESS[:READ],
307
- value: Aro::Mancy::OS,
308
- description: I18n.t("cli.config.aro_env.OS_description"),
309
- },
310
- ARO_ENV_E: {
311
- type: CLI::Config::TYPES[:INT],
312
- access: CLI::Config::DEF_ACCESS[:READ],
313
- value: Aro::Mancy::E,
314
- description: I18n.t("cli.config.aro_env.E_description"),
315
- },
316
- ARO_ENV_N: {
317
- type: CLI::Config::TYPES[:INT],
318
- access: CLI::Config::DEF_ACCESS[:READ],
319
- value: Aro::Mancy::N,
320
- description: I18n.t("cli.config.aro_env.N_description"),
321
- },
322
- ARO_ENV_PS1: {
323
- type: CLI::Config::TYPES[:STRING],
324
- access: CLI::Config::DEF_ACCESS[:READ],
325
- value: Aro::Mancy::PS1,
326
- description: I18n.t("cli.config.aro_env.PS1_description"),
327
- },
328
- ARO_ENV_NAME_FILE: {
329
- type: CLI::Config::TYPES[:STRING],
330
- access: CLI::Config::DEF_ACCESS[:READ],
331
- value: Aro::Mancy::NAME_FILE,
332
- description: I18n.t("cli.config.aro_env.NAME_FILE_description"),
333
- },
334
- ARO_ENV_I2097I: {
335
- type: CLI::Config::TYPES[:STRING],
336
- access: CLI::Config::DEF_ACCESS[:READ],
337
- value: Aro::Mancy::I2097I,
338
- description: I18n.t("cli.config.aro_env.I2097I_description"),
339
- },
340
- ARO_ENV_YES: {
341
- type: CLI::Config::TYPES[:STRING],
342
- access: CLI::Config::DEF_ACCESS[:READ],
343
- value: Aro::Mancy::YES,
344
- description: I18n.t("cli.config.aro_env.YES_description"),
345
- },
346
- ARO_ENV_ALL: {
347
- type: CLI::Config::TYPES[:STRING],
348
- access: CLI::Config::DEF_ACCESS[:READ],
349
- value: Aro::Mancy::ALL,
350
- description: I18n.t("cli.config.aro_env.ALL_description"),
351
- },
352
- }
353
-
354
- def initialize
355
- @@context = nil
356
- if Aro::Mancy.in_aro? && Aro::Mancy.is_initialized?
357
- @@context = Aro::Db
358
- elsif Aro::Dom.in_arodom? && Aro::Dom.is_initialized?
359
- @@context = Aos::Db
360
- end
361
-
362
- return if @@context.nil?
363
- Aro::V.say(@@context)
364
-
365
- unless File.exist?(CLI::Config.config_filepath)
366
- generate_config
367
- end
368
-
369
- source_config
370
- setup_env
371
- end
372
-
373
- def self.context
374
- @@context
375
- end
376
-
377
- def self.config_filepath
378
- cfp = nil
379
- if @@context == Aro::Db &&
380
- Aro::Dom.in_arodom? &&
381
- Aro::Dom.is_initialized?
382
-
383
- # override when in arodome game room
384
- # this ensures the arodome config is being used
385
- cfp = File.join(Aos::Db.base_aro_dir, CLI::Config::CONFIG_FILE.to_s)
386
- else
387
- cfp = File.join(@@context.base_aro_dir, CLI::Config::CONFIG_FILE.to_s)
388
- end
389
-
390
- cfp
391
- end
392
-
393
- def self.is_test?
394
- ENV[:ARO_ENV.to_s] == CLI::Config::ENVS[:TEST].to_s
395
- end
396
-
397
- def self.display_config
398
- height, width = IO.console.winsize
399
- result = {
400
- HEIGHT: height, #CLI::Config.ivar(:HEIGHT).to_i,
401
- WIDTH: width - Aro::Mancy::O,
402
- DIVIDER: :"_".to_s
403
- }
404
- # Aro::V.say(result)
405
-
406
- result
407
- end
408
-
409
- def self.is_format_text?
410
- CLI::Config.ivar(:FORMAT)&.to_sym == CLI::Config::FORMATS[:TEXT]
411
- end
412
-
413
- def self.process_config_command(args)
414
- if args[1].nil? || args[1] == :aos.to_s
415
- # print config
416
- Aro::P.say((
417
- ["config loaded from #{CLI::Config.config_filepath}"] +
418
- CLI::Config.dump_config
419
- ).join("\n"))
420
- elsif [args[2],args[3]].compact.any? && args[1] == Aos::Os::CMDS[:CONFIG][:cmds][:SET][:key].to_s
421
- CLI::Config.set_ivar(args[2], args[3])
422
- end
423
- end
424
-
425
- # out vars
426
- def self.ovar(suffix)
427
- CLI::Config::DEF[suffix][:value]
428
- end
429
- # out vars
430
- def self.ovar_k(suffix)
431
- "#{CLI::Config::ARO_ENV_PREFIX}#{suffix}"
432
- end
433
-
434
- # in vars
435
- def self.ivar(suffix)
436
- ENV[CLI::Config.ivar_k(suffix)]
437
- end
438
- # in vars
439
- def self.ivar_k(suffix)
440
- "#{CLI::Config::ARO_CONFIG_PREFIX}#{suffix}"
441
- end
442
-
443
- def self.set_ivar(k, new_value)
444
- k = k.upcase.to_sym
445
-
446
- current_value = CLI::Config.ivar(k)
447
- # ensure the var name is valid
448
- unless current_value.nil?
449
- Aro::Dom::P.say("validating #{k} with value #{new_value}")
450
- if CLI::Config.instance.valid_var?(new_value, k, CLI::Config::DEF[k])
451
- # set ENV value
452
- ENV[CLI::Config.ivar_k(k)] = new_value
453
- Aro::Dom::P.say("#{k} set to #{new_value}")
454
- Aro::V.say(ENV[CLI::Config.ivar_k(k)])
455
-
456
- # flush existing config and regen
457
- CLI::Config.instance.generate_config(true)
458
- CLI::Config.instance.source_config
459
- CLI::Config.instance.setup_env
460
- @@context.configure_logger
461
- else
462
- Aro::Dom::P.say("the ivar value you entered is invalid. ignoring.")
463
- end
464
- else
465
- Aro::Dom::P.say("the ivar name you entered is invalid. ignoring.")
466
- end
467
- end
468
-
469
- def setup_env
470
- # do not change - update $ARO_CONFIG_ENV .aro/.config file
471
- #
472
- # default is production
473
- varenv = CLI::Config.ivar(:ENV)
474
- is_valid = valid_var?(varenv, :ENV, CLI::Config::DEF[:ENV])
475
- ENV[:ARO_ENV.to_s] = is_valid ? varenv : CLI::Config::ENVS[:PRODUCTION].to_s
476
- Aro::D.say("setup_env: #{ENV[:ARO_ENV.to_s]}")
477
- end
478
-
479
- def self.dump_config
480
- dump = []
481
- CLI::Config::DEF.each{|k, v|
482
- if v[:access] == CLI::Config::DEF_ACCESS[:WRITE]
483
- dump << "$#{CLI::Config.ivar_k(k).ljust(Aro::Mancy::NUMERALS[:XIV] * Aro::Mancy::OS)}=#{CLI::Config.ivar(k)}"
484
- else
485
- dump << "$#{CLI::Config.ovar_k(k).ljust(Aro::Mancy::NUMERALS[:XIV] * Aro::Mancy::OS)}=#{CLI::Config.ovar(k)}"
486
- end
487
- }
488
-
489
- dump
490
- end
491
-
492
- def source_config
493
- Aro::D.say(I18n.t("cli.config.source", name: CLI::Config.config_filepath))
494
- File.read(CLI::Config.config_filepath).split("\n").select{|line|
495
- line.match?(/export #{CLI::Config::ARO_CONFIG_PREFIX}/)
496
- }.map{|line|
497
- line.gsub("export ", "").split("=")
498
- }.each{|kv|
499
- Aro::V.say("variable to set: #{kv}")
500
- ENV[kv[0]] = kv[1] # source
501
- Aro::V.say("value actually set: #{ENV[kv[0]]}")
502
- }
503
-
504
- # todo: implement
505
- invalid_defs = validate_config
506
- CLI::Config.dump_config.each{|l| Aro::V.say(l)}
507
- invalid_defs.each{|k|
508
- v = CLI::Config::DEF[k.to_sym]
509
- if v[:access] == CLI::Config::DEF_ACCESS[:WRITE]
510
- ENV[CLI::Config.ivar_k(k)] = v[:value]
511
- else
512
- ENV[CLI::Config.ovar_k(k)] = v[:value]
513
- end
514
- }
515
- end
516
-
517
- def generate_config(from_memory = false)
518
- # todo: localize generated config text
519
- Aro::D.say(I18n.t("cli.config.generate", name: CLI::Config.config_filepath))
520
- File.open(CLI::Config.config_filepath, "w+") do |file|
521
- # intro
522
- Aro::Mancy::OS.times do
523
- print_div file.object_id
524
- end
525
- # header
526
- print_div file.object_id
527
- print_sr file.object_id
528
- print_config_header file.object_id
529
- print_sr file.object_id
530
- print_div file.object_id
531
-
532
- print_osr file.object_id
533
-
534
- # def_types
535
- print_div file.object_id
536
- print_sr file.object_id
537
- print_def_types file.object_id
538
- print_sr file.object_id
539
- print_div file.object_id
540
-
541
- print_osr file.object_id
542
-
543
- # var section
544
- print_div file.object_id
545
- print_sr file.object_id
546
- print_var_section file.object_id
547
- print_sr file.object_id
548
- print_div file.object_id
549
-
550
- print_osr file.object_id
551
-
552
- # vars
553
- CLI::Config::DEF.each{|k, v|
554
- print_var file.object_id, k, v, (from_memory ? ENV[CLI::Config.ivar_k(k)] : nil)
555
- }
556
-
557
- print_osr file.object_id
558
-
559
- # var section
560
- print_div file.object_id
561
- print_sr file.object_id
562
- print_var_section file.object_id
563
- print_sr file.object_id
564
- print_div file.object_id
565
-
566
- print_osr file.object_id
567
- # outro
568
- Aro::Mancy::OS.times do
569
- print_div file.object_id
570
- end
571
- file.write("\n")
572
- end
573
- end
574
-
575
- def print_div f_object_id
576
- file = ObjectSpace._id2ref f_object_id
577
- file.write("#{"#" * Aro::Mancy::NUMERALS[:VIII].pow(2)}\n")
578
- end
579
-
580
- def print_sr f_object_id
581
- file = ObjectSpace._id2ref f_object_id
582
- Aro::Mancy::S.times do
583
- file.write("#\n")
584
- end
585
- end
586
-
587
- def print_osr f_object_id
588
- Aro::Mancy::OS.times do
589
- print_sr f_object_id
590
- end
591
- end
592
-
593
- def print_config_header f_object_id
594
- file = ObjectSpace._id2ref f_object_id
595
- file.write("# #{Aro::Mancy::PS1} configuration file.\n")
596
- file.write("# this file was auto generated by the aro cli.\n")
597
- end
598
-
599
- def print_var_section f_object_id
600
- file = ObjectSpace._id2ref f_object_id
601
- file.write("# VARIABLE SECTION!\n")
602
- end
603
-
604
- def print_def_types f_object_id
605
- file = ObjectSpace._id2ref f_object_id
606
- file.write("# CLI::Config::DEF_TYPES\n")
607
- file.write("# describes the possible types of variables.\n")
608
- CLI::Config::DEF_TYPES.each{|k, v|
609
- file.write("# #{k}: #{v[:description]}\n")
610
- }
611
- print_osr f_object_id
612
- file.write("# CLI::Config::DEF\n")
613
- file.write("# define & expose an aro bash api via ENV variables.\n")
614
- file.write("# there are two types of bash vars in aro.\n")
615
- file.write("# 1) in vars (ivars). \n")
616
- file.write("# => ivars enter aro from this file during aro init.\n")
617
- file.write("# => aro validates them and uses them unless unvalid.\n")
618
- file.write("# => otherwise aro will use the defaults listed below.\n")
619
- file.write("# 2) out vars (ovars).\n")
620
- file.write("# => ovars are read-only vars that aro exposes to bash.\n")
621
- file.write("# => this is useful because it provides a bash interface\n")
622
- file.write("# => which can be used to write programs on top of aro.\n")
623
- end
624
-
625
- def print_var f_object_id, k, v, mem_v
626
- file = ObjectSpace._id2ref f_object_id
627
-
628
- is_ovar = CLI::Config::DEF[k][:access] == CLI::Config::DEF_ACCESS[:READ]
629
- if is_ovar
630
- var_name = k
631
- else
632
- var_name = CLI::Config.ivar_k(k)
633
- end
634
- Aro::V.say("access for #{k} is #{CLI::Config::DEF[k][:access]}")
635
- Aro::V.say("using var_name: #{var_name}")
636
- file.write("# [#{var_name}] (#{is_ovar ? :ovar : :ivar})\n")
637
- file.write("# => CLI::Config::DEF_TYPES: #{v[:type]}\n")
638
- case v[:type]
639
- when CLI::Config::DEF_TYPES[:INT][:name]
640
- file.write("# => #{I18n.t("cli.config.type.int_description")}\n")
641
- file.write("# => #{I18n.t("cli.config.minimum")}: #{v[:min]}\n")
642
- file.write("# => #{I18n.t("cli.config.maximum")}: #{v[:max]}\n")
643
- when CLI::Config::DEF_TYPES[:STRING][:name]
644
- file.write("# => #{I18n.t("cli.config.type.string_description")}\n")
645
- file.write("# => use \"double quotes\" if there are any spaces.\n")
646
- when CLI::Config::DEF_TYPES[:VALUES][:name]
647
- file.write("# => #{I18n.t("cli.config.type.values_description")}\n")
648
- file.write("# => #{I18n.t("cli.config.possible_values")}:\n")
649
- print_sr f_object_id
650
- v[:possible_values].each{|name, description|
651
- file.write("# => #{name}\n")
652
- print_sr f_object_id
653
- file.write("# =>#{description}\n")
654
- print_sr f_object_id
655
- }
656
- end
657
- print_osr f_object_id
658
- file.write("# => description:\n")
659
- file.write("# => #{v[:description]}\n")
660
- if is_ovar && CLI::Config::DEF_TYPES[:STRING][:name] == v[:type]
661
- file.write("export #{var_name}=\"#{v[:value]}\"\n")
662
- else
663
- file.write("export #{var_name}=#{mem_v || v[:value]}\n")
664
- end
665
- print_osr f_object_id
666
- end
667
-
668
- end
669
- end
data/sys/models/log.rb DELETED
@@ -1,20 +0,0 @@
1
- =begin
2
-
3
- log.rb
4
-
5
- log object.
6
-
7
- by i2097i
8
-
9
- =end
10
-
11
- require_relative :"./deck".to_s
12
-
13
- class Aro::Log < ActiveRecord::Base
14
- belongs_to :deck, :class_name => :"#{Aro::Deck.name}".to_s
15
-
16
- ORDERING = {
17
- ASC: :asc,
18
- DESC: :desc
19
- }
20
- end