aro 0.2.1 → 0.2.3
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 +4 -4
- data/.gitignore +1 -0
- data/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/aro.gemspec +3 -3
- data/bin/aos +10 -3
- data/bin/aro +18 -11
- data/checksums/aro-0.2.1.gem.sha512 +1 -0
- data/checksums/aro-0.2.2.gem.sha512 +1 -0
- data/checksums/aro-0.2.3.gem.sha512 +1 -0
- data/locale/en.abot.yml +81 -0
- data/locale/en.amg.yml +44 -0
- data/locale/en.aos.yml +8 -38
- data/locale/en.cor.yml +47 -0
- data/locale/en.data.yml +30 -0
- data/locale/en.dom.yml +22 -18
- data/locale/en.flie.yml +29 -0
- data/locale/en.usage.yml +39 -26
- data/locale/en.yml +10 -51
- data/sys/aos/abot.rb +256 -0
- data/sys/aos/amg.rb +58 -56
- data/sys/aos/aos.rb +425 -180
- data/sys/aos/cor.rb +773 -0
- data/sys/aos/data.rb +117 -0
- data/sys/aos/db/migrate/1765148774_create_yous.rb +1 -0
- data/sys/aos/db/migrate/{1765762724_create_libs.rb → 1765762724_create_ilibs.rb} +5 -5
- data/sys/aos/db/migrate/1765907766_create_ilogs.rb +18 -0
- data/sys/aos/db/migrate/1765933985_create_agodos.rb +22 -0
- data/sys/aos/db/migrate/1766203888_create_fpxies.rb +18 -0
- data/sys/aos/db.rb +47 -27
- data/sys/aos/flie.rb +144 -0
- data/sys/aos/models/agodo.rb +96 -0
- data/sys/aos/models/base_model.rb +13 -0
- data/sys/aos/models/fpxy.rb +28 -0
- data/sys/{shr/lib/lib.rb → aos/models/ilib.rb} +11 -6
- data/sys/aos/models/ilog.rb +29 -0
- data/sys/aos/models/you.rb +98 -0
- data/sys/aos/s.rb +2 -1
- data/sys/aos/vws/base.rb +69 -78
- data/sys/aos/vws/dom.rb +1 -2
- data/sys/aos/vws/games/abot.rb +21 -0
- data/sys/aos/vws/games/{game.rb → teck.rb} +27 -24
- data/sys/aos/vws/home.rb +23 -0
- data/sys/aos/vws/know/{temple.rb → body.rb} +3 -3
- data/sys/aos/vws/know/{library.rb → mind.rb} +3 -3
- data/sys/aos/vws/know/spirit.rb +19 -0
- data/sys/aos/vws/{setup → root}/amg.rb +1 -2
- data/sys/aos/vws/{setup → root}/config.rb +4 -4
- data/sys/aos/vws/root/data.rb +21 -0
- data/sys/aos/vws/root/flie.rb +21 -0
- data/sys/aos/vws/{setup.rb → root.rb} +3 -3
- data/sys/aos/vws/welcome/waite.rb +1 -0
- data/sys/aos/vws/welcome.rb +47 -0
- data/sys/aro/d.rb +4 -2
- data/sys/aro/db/migrate/{1763374647_create_decks.rb → 1763374647_create_tecks.rb} +5 -5
- data/sys/aro/db/migrate/1763432541_create_tlogs.rb +20 -0
- data/sys/aro/db.rb +28 -19
- data/sys/aro/mancy.rb +18 -22
- data/sys/aro/models/base_model.rb +13 -0
- data/sys/{models/deck.rb → aro/models/teck.rb} +60 -57
- data/sys/aro/models/tlog.rb +21 -0
- data/sys/aro/p.rb +1 -1
- data/sys/aro/r.rb +2 -1
- data/sys/aro/v.rb +2 -2
- data/sys/cli/constants.rb +4 -10
- data/sys/cli/create.rb +2 -3
- data/sys/cli/dom.rb +1 -2
- data/sys/cli/{deck.rb → teck.rb} +38 -45
- data/sys/cli.rb +10 -11
- data/sys/dom/d.rb +68 -46
- data/sys/dom/dom.rb +79 -44
- data/sys/dom/p.rb +1 -1
- data/sys/fpx.rb +116 -0
- data/sys/reiquire.rb +8 -8
- data/sys/shr/prompt.rb +2 -6
- data/sys/shr/t.rb +11 -13
- data/sys/shr/version.rb +1 -1
- data/tasks/make.rake +1 -1
- metadata +82 -62
- data/locale/en.cngelog.yml +0 -5
- data/sys/aos/vws/games/abpps.rb +0 -19
- data/sys/aos/vws/games/hbpps.rb +0 -19
- data/sys/aos/vws/games/shpps.rb +0 -19
- data/sys/aos/vws/games/vipps.rb +0 -19
- data/sys/aos/you.rb +0 -21
- data/sys/aro/db/migrate/1763432541_create_logs.rb +0 -20
- data/sys/dom/config.rb +0 -665
- data/sys/models/log.rb +0 -20
- /data/sys/shr/{lib → ilib}/crs/CMakeLists.txt +0 -0
- /data/sys/shr/{lib → ilib}/crs/compile.sh +0 -0
- /data/sys/shr/{lib → ilib}/crs/crs.c +0 -0
- /data/sys/shr/{lib → ilib}/crs/crs.o +0 -0
- /data/sys/shr/{lib → ilib}/crs/libcrs.so +0 -0
data/sys/aos/cor.rb
ADDED
|
@@ -0,0 +1,773 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
|
|
3
|
+
cor.rb
|
|
4
|
+
|
|
5
|
+
aos cor interface.
|
|
6
|
+
|
|
7
|
+
by i2097i
|
|
8
|
+
|
|
9
|
+
=end
|
|
10
|
+
|
|
11
|
+
module Aos
|
|
12
|
+
# cli entrypoint
|
|
13
|
+
def self.cor
|
|
14
|
+
Aos::Cor.instance.load
|
|
15
|
+
Aos::Cor.process_command(ARGV)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
class Cor
|
|
19
|
+
include Singleton
|
|
20
|
+
|
|
21
|
+
attr_accessor :base_lines_def, :cor_path, :display_lines
|
|
22
|
+
|
|
23
|
+
ARO_IVA_PREFIX = :ARO_IVA_
|
|
24
|
+
ARO_OVA_PREFIX = :ARO_OVA_
|
|
25
|
+
|
|
26
|
+
COR_FILE = :".cor"
|
|
27
|
+
|
|
28
|
+
DATE_FORMAT = "%Y:%m:%d:%H:%M:%S"
|
|
29
|
+
|
|
30
|
+
DBG_MODES = [:development, :test]
|
|
31
|
+
|
|
32
|
+
# possible envs
|
|
33
|
+
#
|
|
34
|
+
# example usage:
|
|
35
|
+
# Aos::Cor::ENVS[:PRODUCTION]
|
|
36
|
+
ENVS = {
|
|
37
|
+
DEVELOPMENT: :development,
|
|
38
|
+
PRODUCTION: :production,
|
|
39
|
+
TEST: :test
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
# possible formats
|
|
43
|
+
#
|
|
44
|
+
# example usage:
|
|
45
|
+
# Aos::Cor::FORMATS[:TEXT]
|
|
46
|
+
FORMATS = {
|
|
47
|
+
TEXT: :text,
|
|
48
|
+
JSON: :json,
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
# possible interfaces
|
|
52
|
+
#
|
|
53
|
+
# example usage:
|
|
54
|
+
# Aos::Cor::INTERFACES[:TERMINAL]
|
|
55
|
+
INTERFACES = {
|
|
56
|
+
TERMINAL: :terminal,
|
|
57
|
+
LANIMRET: :lanimret,
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
# possible dimensions
|
|
61
|
+
#
|
|
62
|
+
# example usage:
|
|
63
|
+
# Aos::Cor::DMS[:DEV_TAROT]
|
|
64
|
+
DMS = {
|
|
65
|
+
DEV_TAROT: :dev_tarot,
|
|
66
|
+
RUBY_FACOT: :ruby_facot
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
# ovar and ivar access
|
|
70
|
+
#
|
|
71
|
+
# example usage:
|
|
72
|
+
# Aos::Cor::DEF_ACCESS[:READ]
|
|
73
|
+
DEF_ACCESS = {
|
|
74
|
+
READ: :read,
|
|
75
|
+
WRITE: :write
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
BOOLS = {
|
|
79
|
+
FALSE: false,
|
|
80
|
+
TRUE: true,
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
TYPES = {
|
|
84
|
+
BOOL: :bool,
|
|
85
|
+
INT: :int,
|
|
86
|
+
STRING: :string,
|
|
87
|
+
VALUES: :values
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
# types used in definition
|
|
91
|
+
#
|
|
92
|
+
# example usage:
|
|
93
|
+
# Aos::Cor::DEF_TYPES[:INT][:validator].call(unvalid, Aos::Cor::DEF[:DIMENSION])
|
|
94
|
+
DEF_TYPES = {
|
|
95
|
+
BOOL: {
|
|
96
|
+
name: Aos::Cor::TYPES[:BOOL],
|
|
97
|
+
description: I18n.t("cor.type.bool_description"),
|
|
98
|
+
converter: Proc.new{|v|
|
|
99
|
+
if [Aos::Cor::BOOLS[:TRUE].to_s, Aro::Mancy::S].include?(v)
|
|
100
|
+
Aos::Cor::BOOLS[:TRUE]
|
|
101
|
+
else
|
|
102
|
+
Aos::Cor::BOOLS[:FALSE]
|
|
103
|
+
end
|
|
104
|
+
},
|
|
105
|
+
validator: Proc.new{|unvalid, k, v|
|
|
106
|
+
Aos::Cor.def_valid?(k, v) &&
|
|
107
|
+
Aos::Cor.bool_valid?(unvalid)
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
INT: {
|
|
111
|
+
name: Aos::Cor::TYPES[:INT],
|
|
112
|
+
description: I18n.t("cor.type.int_description"),
|
|
113
|
+
converter: Proc.new{|v| v.to_i},
|
|
114
|
+
validator: Proc.new{|unvalid, k, v|
|
|
115
|
+
Aro::V.say("validating #{k} (#{Aos::Cor::DEF_TYPES[:INT][:name]})")
|
|
116
|
+
Aro::V.say("unvalid = #{unvalid}")
|
|
117
|
+
Aro::V.say("[min, max] = [#{v[:min]}, #{v[:max]}]")
|
|
118
|
+
int_valid = Aos::Cor.def_valid?(k, v) &&
|
|
119
|
+
Aos::Cor.int_valid?(unvalid) &&
|
|
120
|
+
unvalid.to_i >= v[:min] &&
|
|
121
|
+
unvalid.to_i <= v[:max]
|
|
122
|
+
Aro::V.say("unvalid(#{unvalid}) is#{int_valid ? " " : :" not ".to_s}valid.")
|
|
123
|
+
int_valid
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
STRING: {
|
|
127
|
+
name: Aos::Cor::TYPES[:STRING],
|
|
128
|
+
description: I18n.t("cor.type.string_description"),
|
|
129
|
+
converter: Proc.new{|v| v.to_s},
|
|
130
|
+
validator: Proc.new{|unvalid, k, v|
|
|
131
|
+
Aos::Cor.def_valid?(k, v) &&
|
|
132
|
+
Aos::Cor.string_valid?(unvalid)
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
VALUES: {
|
|
136
|
+
name: Aos::Cor::TYPES[:VALUES],
|
|
137
|
+
description: I18n.t("cor.type.values_description"),
|
|
138
|
+
converter: Proc.new{|v| v.to_s},
|
|
139
|
+
validator: Proc.new{|unvalid, k, v|
|
|
140
|
+
Aos::Cor.def_valid?(k, v) &&
|
|
141
|
+
v[:possible_values].keys.include?(unvalid&.to_sym)
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
def self.bool_valid?(unvalid)
|
|
147
|
+
Aos::Cor::BOOLS.values.map{|b| b.to_s.to_sym}.include?(unvalid&.to_s&.to_sym)
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
def self.int_valid?(unvalid)
|
|
151
|
+
!unvalid&.to_i.nil?
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
def self.string_valid?(unvalid)
|
|
155
|
+
unvalid.is_a?(String)
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
def self.def_valid?(key, deff)
|
|
159
|
+
def_valid = deff == Aos::Cor::DEF[key]
|
|
160
|
+
unless def_valid
|
|
161
|
+
Aro::V.say("invalid def! #{key} => #{deff}")
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
def_valid
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
def validate_config
|
|
168
|
+
invalid_vars = []
|
|
169
|
+
Aos::Cor::DEF.each{|k, v|
|
|
170
|
+
is_valid = v[:access] == Aos::Cor::DEF_ACCESS[:READ]
|
|
171
|
+
unless is_valid
|
|
172
|
+
is_valid = valid_var?(Aos::Cor.ivar(k), k, v)
|
|
173
|
+
end
|
|
174
|
+
invalid_vars << k unless is_valid
|
|
175
|
+
}
|
|
176
|
+
invalid_vars
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
def valid_var?(var_value, k, v)
|
|
180
|
+
Aro::V.say(v)
|
|
181
|
+
return true if v[:access] == Aos::Cor::DEF_ACCESS[:READ]
|
|
182
|
+
|
|
183
|
+
Aos::Cor::DEF_TYPES[
|
|
184
|
+
v[:type].to_s.upcase.to_sym
|
|
185
|
+
][:validator].call(var_value, k, v)
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
def convert_var_for_def(k)
|
|
189
|
+
Aos::Cor::DEF_TYPES[
|
|
190
|
+
Aos::Cor::DEF[k][:type].upcase
|
|
191
|
+
][:converter].call(ENV[Aos::Cor.ivar_k(k)])
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
# adapts I18n translations to generate bash environment vars.
|
|
195
|
+
#
|
|
196
|
+
# example usage:
|
|
197
|
+
# Aos::Cor::DEF[:Z_MAX]
|
|
198
|
+
DEF = {
|
|
199
|
+
|
|
200
|
+
#
|
|
201
|
+
# => ivars
|
|
202
|
+
#
|
|
203
|
+
ENV: {
|
|
204
|
+
type: Aos::Cor::TYPES[:VALUES],
|
|
205
|
+
access: Aos::Cor::DEF_ACCESS[:WRITE],
|
|
206
|
+
value: Aos::Cor::ENVS[:PRODUCTION],
|
|
207
|
+
description: I18n.t("cor.env.description"),
|
|
208
|
+
possible_values: {
|
|
209
|
+
development: I18n.t("cor.env.development_description"),
|
|
210
|
+
production: I18n.t("cor.env.production_description"),
|
|
211
|
+
test: I18n.t("cor.env.test_description"),
|
|
212
|
+
}
|
|
213
|
+
},
|
|
214
|
+
VERBOSE: {
|
|
215
|
+
type: Aos::Cor::TYPES[:BOOL],
|
|
216
|
+
access: Aos::Cor::DEF_ACCESS[:WRITE],
|
|
217
|
+
value: Aos::Cor::BOOLS[:FALSE],
|
|
218
|
+
description: I18n.t("cor.verbose_description"),
|
|
219
|
+
},
|
|
220
|
+
LOG_AOS_DB: {
|
|
221
|
+
type: Aos::Cor::TYPES[:BOOL],
|
|
222
|
+
access: Aos::Cor::DEF_ACCESS[:WRITE],
|
|
223
|
+
value: Aos::Cor::BOOLS[:FALSE],
|
|
224
|
+
description: I18n.t("cor.log_aos_db_description"),
|
|
225
|
+
},
|
|
226
|
+
LOG_ARO_DB: {
|
|
227
|
+
type: Aos::Cor::TYPES[:BOOL],
|
|
228
|
+
access: Aos::Cor::DEF_ACCESS[:WRITE],
|
|
229
|
+
value: Aos::Cor::BOOLS[:FALSE],
|
|
230
|
+
description: I18n.t("cor.log_aro_db_description"),
|
|
231
|
+
},
|
|
232
|
+
FORMAT: {
|
|
233
|
+
type: Aos::Cor::TYPES[:VALUES],
|
|
234
|
+
implemented: false,
|
|
235
|
+
access: Aos::Cor::DEF_ACCESS[:WRITE],
|
|
236
|
+
value: Aos::Cor::FORMATS[:TEXT],
|
|
237
|
+
description: I18n.t("cor.format.description"),
|
|
238
|
+
possible_values: {
|
|
239
|
+
text: I18n.t("cor.format.text_description"),
|
|
240
|
+
json: I18n.t("cor.format.json_description")
|
|
241
|
+
}
|
|
242
|
+
},
|
|
243
|
+
INTERFACE: {
|
|
244
|
+
type: Aos::Cor::TYPES[:VALUES],
|
|
245
|
+
implemented: false,
|
|
246
|
+
access: Aos::Cor::DEF_ACCESS[:WRITE],
|
|
247
|
+
value: Aos::Cor::INTERFACES[:TERMINAL],
|
|
248
|
+
description: I18n.t("cor.interface.description"),
|
|
249
|
+
possible_values: {
|
|
250
|
+
terminal: I18n.t("cor.interface.terminal_description"),
|
|
251
|
+
lanimret: I18n.t("cor.interface.lanimret_description")
|
|
252
|
+
}
|
|
253
|
+
},
|
|
254
|
+
DIMENSION: {
|
|
255
|
+
type: Aos::Cor::TYPES[:VALUES],
|
|
256
|
+
access: Aos::Cor::DEF_ACCESS[:WRITE],
|
|
257
|
+
value: Aos::Cor::DMS[:DEV_TAROT],
|
|
258
|
+
description: I18n.t("cor.dimension.description"),
|
|
259
|
+
possible_values: {
|
|
260
|
+
dev_tarot: I18n.t("cor.dimension.dev_tarot_description"),
|
|
261
|
+
ruby_facot: I18n.t("cor.dimension.ruby_facot_description"),
|
|
262
|
+
}
|
|
263
|
+
},
|
|
264
|
+
HEIGHT: {
|
|
265
|
+
type: Aos::Cor::TYPES[:INT],
|
|
266
|
+
access: Aos::Cor::DEF_ACCESS[:WRITE],
|
|
267
|
+
value: Aro::Mancy::NUMERALS[:XLII],
|
|
268
|
+
min: Aro::Mancy::NUMERALS[:I],
|
|
269
|
+
max: Aro::Mancy::NUMERALS[:MMXCVII],
|
|
270
|
+
description: I18n.t(
|
|
271
|
+
"cor.height_description",
|
|
272
|
+
min: Aro::Mancy::NUMERALS[:I],
|
|
273
|
+
max: Aro::Mancy::NUMERALS[:MMXCVII],
|
|
274
|
+
),
|
|
275
|
+
},
|
|
276
|
+
WIDTH: {
|
|
277
|
+
type: Aos::Cor::TYPES[:INT],
|
|
278
|
+
access: Aos::Cor::DEF_ACCESS[:WRITE],
|
|
279
|
+
value: Aro::Mancy::NUMERALS[:C] + Aro::Mancy::NUMERALS[:XXXVII] - Aro::Mancy::S,
|
|
280
|
+
min: Aro::Mancy::NUMERALS[:I],
|
|
281
|
+
max: Aro::Mancy::NUMERALS[:MMXCVII],
|
|
282
|
+
description: I18n.t(
|
|
283
|
+
"cor.width_description",
|
|
284
|
+
min: Aro::Mancy::NUMERALS[:I],
|
|
285
|
+
max: Aro::Mancy::NUMERALS[:MMXCVII],
|
|
286
|
+
),
|
|
287
|
+
},
|
|
288
|
+
Z: {
|
|
289
|
+
type: Aos::Cor::TYPES[:INT],
|
|
290
|
+
access: Aos::Cor::DEF_ACCESS[:WRITE],
|
|
291
|
+
value: Aro::Mancy::NUMERALS[:I],
|
|
292
|
+
min: Aro::Mancy::NUMERALS[:I],
|
|
293
|
+
max: Aro::Mancy::NUMERALS[:MMXCVII],
|
|
294
|
+
description: I18n.t(
|
|
295
|
+
"cor.z_description",
|
|
296
|
+
min: Aro::Mancy::NUMERALS[:I],
|
|
297
|
+
max: Aro::Mancy::NUMERALS[:MMXCVII],
|
|
298
|
+
),
|
|
299
|
+
},
|
|
300
|
+
Z_MAX: {
|
|
301
|
+
type: Aos::Cor::TYPES[:INT],
|
|
302
|
+
access: Aos::Cor::DEF_ACCESS[:WRITE],
|
|
303
|
+
value: Aro::Mancy::NUMERALS[:VII],
|
|
304
|
+
min: Aro::Mancy::NUMERALS[:I],
|
|
305
|
+
max: Aro::Mancy::NUMERALS[:XXII],
|
|
306
|
+
description: I18n.t(
|
|
307
|
+
"cor.z_max_description",
|
|
308
|
+
min: Aro::Mancy::NUMERALS[:I],
|
|
309
|
+
max: Aro::Mancy::NUMERALS[:XXII],
|
|
310
|
+
),
|
|
311
|
+
},
|
|
312
|
+
|
|
313
|
+
#
|
|
314
|
+
# => ovars
|
|
315
|
+
#
|
|
316
|
+
O: {
|
|
317
|
+
type: Aos::Cor::TYPES[:INT],
|
|
318
|
+
access: Aos::Cor::DEF_ACCESS[:READ],
|
|
319
|
+
value: Aro::Mancy::O,
|
|
320
|
+
description: I18n.t("cor.aro_env.O_description"),
|
|
321
|
+
},
|
|
322
|
+
S: {
|
|
323
|
+
type: Aos::Cor::TYPES[:INT],
|
|
324
|
+
access: Aos::Cor::DEF_ACCESS[:READ],
|
|
325
|
+
value: Aro::Mancy::S,
|
|
326
|
+
description: I18n.t("cor.aro_env.S_description"),
|
|
327
|
+
},
|
|
328
|
+
OS: {
|
|
329
|
+
type: Aos::Cor::TYPES[:INT],
|
|
330
|
+
access: Aos::Cor::DEF_ACCESS[:READ],
|
|
331
|
+
value: Aro::Mancy::OS,
|
|
332
|
+
description: I18n.t("cor.aro_env.OS_description"),
|
|
333
|
+
},
|
|
334
|
+
E: {
|
|
335
|
+
type: Aos::Cor::TYPES[:INT],
|
|
336
|
+
access: Aos::Cor::DEF_ACCESS[:READ],
|
|
337
|
+
value: Aro::Mancy::E,
|
|
338
|
+
description: I18n.t("cor.aro_env.E_description"),
|
|
339
|
+
},
|
|
340
|
+
N: {
|
|
341
|
+
type: Aos::Cor::TYPES[:INT],
|
|
342
|
+
access: Aos::Cor::DEF_ACCESS[:READ],
|
|
343
|
+
value: Aro::Mancy::N,
|
|
344
|
+
description: I18n.t("cor.aro_env.N_description"),
|
|
345
|
+
},
|
|
346
|
+
PS1: {
|
|
347
|
+
type: Aos::Cor::TYPES[:STRING],
|
|
348
|
+
access: Aos::Cor::DEF_ACCESS[:READ],
|
|
349
|
+
value: Aro::Mancy::PS1,
|
|
350
|
+
description: I18n.t("cor.aro_env.PS1_description"),
|
|
351
|
+
},
|
|
352
|
+
NAME_FILE: {
|
|
353
|
+
type: Aos::Cor::TYPES[:STRING],
|
|
354
|
+
access: Aos::Cor::DEF_ACCESS[:READ],
|
|
355
|
+
value: Aro::Mancy::NAME_FILE,
|
|
356
|
+
description: I18n.t("cor.aro_env.NAME_FILE_description"),
|
|
357
|
+
},
|
|
358
|
+
I2097I: {
|
|
359
|
+
type: Aos::Cor::TYPES[:STRING],
|
|
360
|
+
access: Aos::Cor::DEF_ACCESS[:READ],
|
|
361
|
+
value: Aro::Mancy::I2097I,
|
|
362
|
+
description: I18n.t("cor.aro_env.I2097I_description"),
|
|
363
|
+
},
|
|
364
|
+
YES: {
|
|
365
|
+
type: Aos::Cor::TYPES[:STRING],
|
|
366
|
+
access: Aos::Cor::DEF_ACCESS[:READ],
|
|
367
|
+
value: Aro::Mancy::YES,
|
|
368
|
+
description: I18n.t("cor.aro_env.YES_description"),
|
|
369
|
+
},
|
|
370
|
+
ALL: {
|
|
371
|
+
type: Aos::Cor::TYPES[:STRING],
|
|
372
|
+
access: Aos::Cor::DEF_ACCESS[:READ],
|
|
373
|
+
value: Aro::Mancy::ALL,
|
|
374
|
+
description: I18n.t("cor.aro_env.ALL_description"),
|
|
375
|
+
},
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
def load
|
|
379
|
+
self.cor_path = nil
|
|
380
|
+
self.base_lines_def = nil
|
|
381
|
+
Aro::Dom.instance.eg_path = nil
|
|
382
|
+
return if Aos::Cor.get_cor_path.nil?
|
|
383
|
+
unless File.exist?(Aos::Cor.cor_filepath)
|
|
384
|
+
generate_config
|
|
385
|
+
end
|
|
386
|
+
|
|
387
|
+
source_config
|
|
388
|
+
Aro::D.say("running in #{Aos::Cor.ivar(:ENV)} env.")
|
|
389
|
+
|
|
390
|
+
self.display_lines = Aos::Cor.base_lines
|
|
391
|
+
end
|
|
392
|
+
|
|
393
|
+
def self.base_lines(args = nil)
|
|
394
|
+
if self.instance.base_lines_def.nil? || args.present?
|
|
395
|
+
args = [] if args.nil?
|
|
396
|
+
# print Aos::Cor::DEF
|
|
397
|
+
lines = []
|
|
398
|
+
lines << "loaded config at: #{Aos::Os.osify(Aos::Cor.cor_filepath)}"
|
|
399
|
+
lines << "<Aos::Cor::DEF>"
|
|
400
|
+
case args[Aro::Mancy::S]&.to_sym
|
|
401
|
+
when :ivars
|
|
402
|
+
lines += Aos::Cor.ivars_dump
|
|
403
|
+
when :ovars
|
|
404
|
+
lines += Aos::Cor.ovars_dump
|
|
405
|
+
else
|
|
406
|
+
lines += Aos::Cor.ivars_dump
|
|
407
|
+
end
|
|
408
|
+
# print config commands
|
|
409
|
+
lines << ""
|
|
410
|
+
lines << I18n.t("aos.constants.commands")
|
|
411
|
+
lines << ""
|
|
412
|
+
lines += Aos::Vw::Base.lines_for_cmd(Aos::Os::CMDS[:COR])
|
|
413
|
+
lines
|
|
414
|
+
|
|
415
|
+
self.instance.base_lines_def = lines
|
|
416
|
+
end
|
|
417
|
+
|
|
418
|
+
return self.instance.base_lines_def
|
|
419
|
+
end
|
|
420
|
+
|
|
421
|
+
Mutex.new.synchronize do
|
|
422
|
+
def self.get_cor_path
|
|
423
|
+
if self.instance.cor_path.nil?
|
|
424
|
+
if Aro::Dom.in_arodom?
|
|
425
|
+
Aos::Os.instance.load_you!
|
|
426
|
+
if Aos::Os.instance.you.root? ||
|
|
427
|
+
Aos::Os.instance.you.agodo?
|
|
428
|
+
self.instance.cor_path = Aos::Cor.dom_cor_path
|
|
429
|
+
else
|
|
430
|
+
self.instance.cor_path = Aos::Os.instance.you_flag.home
|
|
431
|
+
end
|
|
432
|
+
elsif Aro::Mancy.in_aro?
|
|
433
|
+
self.instance.cor_path = Aos::Cor.aro_cor_path
|
|
434
|
+
end
|
|
435
|
+
end
|
|
436
|
+
|
|
437
|
+
return self.instance.cor_path
|
|
438
|
+
end
|
|
439
|
+
end
|
|
440
|
+
|
|
441
|
+
def self.aro_cor_path
|
|
442
|
+
File.join(Dir.pwd, Aro::Db.base_aro_dir)
|
|
443
|
+
end
|
|
444
|
+
|
|
445
|
+
def self.dom_cor_path
|
|
446
|
+
File.join(Aro::Dom::dom_root, Aro::Dom.room_path(:cor))
|
|
447
|
+
end
|
|
448
|
+
|
|
449
|
+
def self.cor_filepath
|
|
450
|
+
File.join(
|
|
451
|
+
Aos::Cor.get_cor_path,
|
|
452
|
+
Aos::Cor::COR_FILE.to_s
|
|
453
|
+
)
|
|
454
|
+
end
|
|
455
|
+
|
|
456
|
+
def self.is_test?
|
|
457
|
+
Aos::Cor.ivar(:ENV) == Aos::Cor::ENVS[:TEST].to_s
|
|
458
|
+
end
|
|
459
|
+
|
|
460
|
+
def self.display_configuration
|
|
461
|
+
height = Aos::Cor.ivar(:HEIGHT).to_i
|
|
462
|
+
width = Aos::Cor.ivar(:WIDTH).to_i
|
|
463
|
+
if !Aro::Dom.in_arodom? ||
|
|
464
|
+
Aos::Cor.ivar(:INTERFACE) == Aos::Cor::INTERFACES[:TERMINAL].to_s
|
|
465
|
+
# use console for terminal always
|
|
466
|
+
h_con, w_con = IO.console.winsize
|
|
467
|
+
height = h_con if h_con > 0
|
|
468
|
+
width = w_con if w_con > 0
|
|
469
|
+
end
|
|
470
|
+
|
|
471
|
+
result = {
|
|
472
|
+
HEIGHT: height,
|
|
473
|
+
WIDTH: width,
|
|
474
|
+
DIVIDER: :".".to_s
|
|
475
|
+
}
|
|
476
|
+
# Aro::V.say(result)
|
|
477
|
+
|
|
478
|
+
result
|
|
479
|
+
end
|
|
480
|
+
|
|
481
|
+
def self.is_format_text?
|
|
482
|
+
Aos::Cor.ivar(:FORMAT)&.to_sym == Aos::Cor::FORMATS[:TEXT]
|
|
483
|
+
end
|
|
484
|
+
|
|
485
|
+
def self.process_command(args)
|
|
486
|
+
args = Aos::Os.sanitize_you(args)
|
|
487
|
+
k = Aos::Cor::DEF.keys.filter{|k| k == args[Aro::Mancy::S]&.upcase&.to_sym}&.first
|
|
488
|
+
unless k.nil?
|
|
489
|
+
unless args[Aro::Mancy::OS].nil?
|
|
490
|
+
# config <var_name> <var_value>
|
|
491
|
+
Aos::Cor.set_ivar(args[Aro::Mancy::S], args[Aro::Mancy::OS])
|
|
492
|
+
end
|
|
493
|
+
|
|
494
|
+
# basic show var description and value
|
|
495
|
+
self.instance.display_lines = self.instance.lines_var(k, Aos::Cor::DEF[k], ENV[Aos::Cor.ivar_k(k)])
|
|
496
|
+
else
|
|
497
|
+
self.instance.display_lines = Aos::Cor.base_lines(args)
|
|
498
|
+
end
|
|
499
|
+
|
|
500
|
+
if Aro::Mancy.in_aro? && !Aro::Dom.in_arodom?
|
|
501
|
+
Aro::P.say(self.instance.display_lines.join("\n"))
|
|
502
|
+
end
|
|
503
|
+
end
|
|
504
|
+
|
|
505
|
+
# out vars
|
|
506
|
+
def self.ovar(suffix)
|
|
507
|
+
Aos::Cor::DEF[suffix][:value]
|
|
508
|
+
end
|
|
509
|
+
# out vars
|
|
510
|
+
def self.ovar_k(suffix)
|
|
511
|
+
"#{Aos::Cor::ARO_OVA_PREFIX}#{suffix}"
|
|
512
|
+
end
|
|
513
|
+
|
|
514
|
+
# in vars
|
|
515
|
+
def self.ivar(suffix)
|
|
516
|
+
ENV[Aos::Cor.ivar_k(suffix)]
|
|
517
|
+
end
|
|
518
|
+
# in vars
|
|
519
|
+
def self.ivar_k(suffix)
|
|
520
|
+
"#{Aos::Cor::ARO_IVA_PREFIX}#{suffix}"
|
|
521
|
+
end
|
|
522
|
+
|
|
523
|
+
def self.set_ivar(k, new_value)
|
|
524
|
+
k = k.upcase.to_sym
|
|
525
|
+
|
|
526
|
+
current_value = Aos::Cor.ivar(k)
|
|
527
|
+
if k == :DIMENSION &&
|
|
528
|
+
new_value == Aos::Cor::DMS[:DEV_TAROT].to_s &&
|
|
529
|
+
!Aro::T.is_dev_tarot_avail?
|
|
530
|
+
Aro::Dom::P.say("unable to set dimension dev_tarot. device not present.")
|
|
531
|
+
return
|
|
532
|
+
end
|
|
533
|
+
|
|
534
|
+
# ensure the var name is valid
|
|
535
|
+
unless current_value.nil?
|
|
536
|
+
Aro::Dom::P.say("validating #{k} with value #{new_value}")
|
|
537
|
+
if Aos::Cor.instance.valid_var?(new_value, k, Aos::Cor::DEF[k])
|
|
538
|
+
# set ENV value
|
|
539
|
+
ENV[Aos::Cor.ivar_k(k)] = new_value
|
|
540
|
+
Aro::Dom::P.say("#{k} set to #{new_value}")
|
|
541
|
+
Aro::V.say(ENV[Aos::Cor.ivar_k(k)])
|
|
542
|
+
|
|
543
|
+
# flush existing config and regen
|
|
544
|
+
Aos::Cor.instance.generate_config(true)
|
|
545
|
+
Aos::Cor.instance.source_config
|
|
546
|
+
Aro::Db.configure_logger
|
|
547
|
+
Aos::Db.configure_logger
|
|
548
|
+
else
|
|
549
|
+
Aro::Dom::P.say("the ivar value you entered is invalid. ignoring.")
|
|
550
|
+
end
|
|
551
|
+
else
|
|
552
|
+
Aro::Dom::P.say("the ivar name you entered is invalid. ignoring.")
|
|
553
|
+
end
|
|
554
|
+
end
|
|
555
|
+
|
|
556
|
+
def self.ivars_dump
|
|
557
|
+
dump = []
|
|
558
|
+
Aos::Cor::DEF.select{|k, v|
|
|
559
|
+
v[:access] == Aos::Cor::DEF_ACCESS[:WRITE]
|
|
560
|
+
}.each{|k, v|
|
|
561
|
+
dump << "#{Aos::Cor.ivar_k(k).ljust(Aro::Mancy::NUMERALS[:XIV] * Aro::Mancy::OS)}=#{Aos::Cor.ivar(k)}"
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
dump
|
|
565
|
+
end
|
|
566
|
+
|
|
567
|
+
def self.ovars_dump
|
|
568
|
+
dump = []
|
|
569
|
+
Aos::Cor::DEF.select{|k, v|
|
|
570
|
+
v[:access] == Aos::Cor::DEF_ACCESS[:READ]
|
|
571
|
+
}.each{|k, v|
|
|
572
|
+
dump << "#{Aos::Cor.ovar_k(k).ljust(Aro::Mancy::NUMERALS[:XIV] * Aro::Mancy::OS)}=#{Aos::Cor.ovar(k)}"
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
dump
|
|
576
|
+
end
|
|
577
|
+
|
|
578
|
+
def source_config
|
|
579
|
+
Aro::D.say(I18n.t("cor.source", name: Aos::Cor.cor_filepath))
|
|
580
|
+
File.read(Aos::Cor.cor_filepath).split("\n").select{|line|
|
|
581
|
+
line.match?(/export #{Aos::Cor::ARO_IVA_PREFIX}/)
|
|
582
|
+
}.map{|line|
|
|
583
|
+
line.gsub("export ", "").split("=")
|
|
584
|
+
}.each{|kv|
|
|
585
|
+
Aro::V.say("variable to set: #{kv}")
|
|
586
|
+
ENV[kv[0]] = kv[1] # source
|
|
587
|
+
Aro::V.say("value actually set: #{ENV[kv[0]]}")
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
invalid_defs = validate_config
|
|
591
|
+
Aos::Cor.ivars_dump.each{|l| Aro::V.say(l)}
|
|
592
|
+
Aos::Cor.ovars_dump.each{|l| Aro::V.say(l)}
|
|
593
|
+
invalid_defs.each{|k|
|
|
594
|
+
v = Aos::Cor::DEF[k.to_sym]
|
|
595
|
+
if v[:access] == Aos::Cor::DEF_ACCESS[:WRITE]
|
|
596
|
+
ENV[Aos::Cor.ivar_k(k)] = v[:value]
|
|
597
|
+
else
|
|
598
|
+
ENV[Aos::Cor.ovar_k(k)] = v[:value]
|
|
599
|
+
end
|
|
600
|
+
}
|
|
601
|
+
end
|
|
602
|
+
|
|
603
|
+
# from_memory true means write current config to file
|
|
604
|
+
def generate_config(from_memory = false)
|
|
605
|
+
# todo: localize generated config text
|
|
606
|
+
Aro::D.say(I18n.t("cor.generate", name: Aos::Cor.cor_filepath))
|
|
607
|
+
|
|
608
|
+
lines = []
|
|
609
|
+
|
|
610
|
+
# intro
|
|
611
|
+
Aro::Mancy::OS.times do
|
|
612
|
+
lines += lines_div
|
|
613
|
+
end
|
|
614
|
+
|
|
615
|
+
# header
|
|
616
|
+
lines += lines_div
|
|
617
|
+
lines += lines_newline_comment
|
|
618
|
+
lines += lines_config_header
|
|
619
|
+
lines += lines_newline_comment
|
|
620
|
+
lines += lines_div
|
|
621
|
+
|
|
622
|
+
lines += lines_newline_comment_os
|
|
623
|
+
|
|
624
|
+
# def_types
|
|
625
|
+
lines += lines_div
|
|
626
|
+
lines += lines_newline_comment
|
|
627
|
+
lines += lines_def_type_description
|
|
628
|
+
lines += lines_newline_comment
|
|
629
|
+
lines += lines_div
|
|
630
|
+
|
|
631
|
+
lines += lines_newline_comment_os
|
|
632
|
+
|
|
633
|
+
# var section
|
|
634
|
+
lines += lines_div
|
|
635
|
+
lines += lines_newline_comment
|
|
636
|
+
lines += lines_var_section_div
|
|
637
|
+
lines += lines_newline_comment
|
|
638
|
+
lines += lines_div
|
|
639
|
+
|
|
640
|
+
lines += lines_newline_comment_os
|
|
641
|
+
|
|
642
|
+
# vars
|
|
643
|
+
Aos::Cor::DEF.each{|k, v|
|
|
644
|
+
lines += lines_var(k, v, (from_memory ? ENV[Aos::Cor.ivar_k(k)] : nil))
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
lines += lines_newline_comment_os
|
|
648
|
+
|
|
649
|
+
# var section
|
|
650
|
+
lines += lines_div
|
|
651
|
+
lines += lines_newline_comment
|
|
652
|
+
lines += lines_var_section_div
|
|
653
|
+
lines += lines_newline_comment
|
|
654
|
+
lines += lines_div
|
|
655
|
+
|
|
656
|
+
lines += lines_newline_comment_os
|
|
657
|
+
# outro
|
|
658
|
+
Aro::Mancy::OS.times do
|
|
659
|
+
lines += lines_div
|
|
660
|
+
end
|
|
661
|
+
write_config(lines)
|
|
662
|
+
end
|
|
663
|
+
|
|
664
|
+
def write_config(lines)
|
|
665
|
+
to_write = Aos::Cor.cor_filepath
|
|
666
|
+
File.open(to_write, "w") do |file|
|
|
667
|
+
file.write(lines.join("\n"))
|
|
668
|
+
file.write("\n")
|
|
669
|
+
end
|
|
670
|
+
|
|
671
|
+
# unless (to_write == Aos::Cor.aro_cor_path) && Aro::Mancy.in_aro?
|
|
672
|
+
# File.open(Aos::Cor.aro_cor_path, "w") do |file|
|
|
673
|
+
# file.write(lines.join("\n"))
|
|
674
|
+
# file.write("\n")
|
|
675
|
+
# end
|
|
676
|
+
# end
|
|
677
|
+
end
|
|
678
|
+
|
|
679
|
+
def lines_div
|
|
680
|
+
["#" * Aro::Mancy::NUMERALS[:XXI].pow(Aro::Mancy::OS)]
|
|
681
|
+
end
|
|
682
|
+
|
|
683
|
+
def lines_newline_comment
|
|
684
|
+
["#"]
|
|
685
|
+
end
|
|
686
|
+
|
|
687
|
+
def lines_newline_comment_os
|
|
688
|
+
lines = []
|
|
689
|
+
Aro::Mancy::OS.times do
|
|
690
|
+
lines += lines_newline_comment
|
|
691
|
+
end
|
|
692
|
+
lines
|
|
693
|
+
end
|
|
694
|
+
|
|
695
|
+
def lines_config_header
|
|
696
|
+
[
|
|
697
|
+
"# this #{Aos::Os} cor configuration file",
|
|
698
|
+
"# was auto generated by the #{Aos::Cor.name}."
|
|
699
|
+
]
|
|
700
|
+
end
|
|
701
|
+
|
|
702
|
+
def lines_var_section_div
|
|
703
|
+
["# VARIABLE SECTION!"]
|
|
704
|
+
end
|
|
705
|
+
|
|
706
|
+
def lines_def_type_description
|
|
707
|
+
lines = []
|
|
708
|
+
lines << "# Aos::Cor::DEF_TYPES"
|
|
709
|
+
lines << "# describes the possible types of variables."
|
|
710
|
+
Aos::Cor::DEF_TYPES.each{|k, v|
|
|
711
|
+
lines << "# #{k}: #{v[:description]}"
|
|
712
|
+
}
|
|
713
|
+
lines += lines_newline_comment_os
|
|
714
|
+
lines << "# Aos::Cor::DEF"
|
|
715
|
+
lines << "# define & expose an aos cor bash api via ENV variables."
|
|
716
|
+
lines << "# there are two types of bash vars in aos."
|
|
717
|
+
lines << "# 1) in vars (ivars). "
|
|
718
|
+
lines << "# => ivars enter aos from this file during aos init."
|
|
719
|
+
lines << "# => cor validates them and uses them unless unvalid."
|
|
720
|
+
lines << "# => otherwise aos will use the defaults listed below."
|
|
721
|
+
lines << "# 2) out vars (ovars)."
|
|
722
|
+
lines << "# => ovars are read-only vars that aos cor exposes to bash."
|
|
723
|
+
lines << "# => this is useful because it provides a bash interface"
|
|
724
|
+
lines << "# => which can be used to write programs on top of aos."
|
|
725
|
+
end
|
|
726
|
+
|
|
727
|
+
def lines_var(k, v, mem_v = nil)
|
|
728
|
+
lines = []
|
|
729
|
+
is_ovar = Aos::Cor::DEF[k][:access] == Aos::Cor::DEF_ACCESS[:READ]
|
|
730
|
+
if is_ovar
|
|
731
|
+
var_name = Aos::Cor.ovar_k(k)
|
|
732
|
+
else
|
|
733
|
+
var_name = Aos::Cor.ivar_k(k)
|
|
734
|
+
end
|
|
735
|
+
Aro::V.say("access for #{k} is #{Aos::Cor::DEF[k][:access]}")
|
|
736
|
+
Aro::V.say("using var_name: #{var_name}")
|
|
737
|
+
lines << "# [#{var_name}] (#{is_ovar ? :ovar : :ivar})"
|
|
738
|
+
lines << "# => Aos::Cor::DEF_TYPES: #{v[:type]}"
|
|
739
|
+
case v[:type]
|
|
740
|
+
when Aos::Cor::DEF_TYPES[:BOOL][:name]
|
|
741
|
+
lines << "# => #{I18n.t("cor.type.bool_description")}"
|
|
742
|
+
when Aos::Cor::DEF_TYPES[:INT][:name]
|
|
743
|
+
lines << "# => #{I18n.t("cor.type.int_description")}"
|
|
744
|
+
lines << "# => #{I18n.t("cor.minimum")}: #{v[:min]}"
|
|
745
|
+
lines << "# => #{I18n.t("cor.maximum")}: #{v[:max]}"
|
|
746
|
+
when Aos::Cor::DEF_TYPES[:STRING][:name]
|
|
747
|
+
lines << "# => #{I18n.t("cor.type.string_description")}"
|
|
748
|
+
lines << "# => use \"double quotes\" if there are any spaces."
|
|
749
|
+
when Aos::Cor::DEF_TYPES[:VALUES][:name]
|
|
750
|
+
lines << "# => #{I18n.t("cor.type.values_description")}"
|
|
751
|
+
lines << "# => #{I18n.t("cor.possible_values")}:"
|
|
752
|
+
lines += lines_newline_comment
|
|
753
|
+
v[:possible_values].each{|name, description|
|
|
754
|
+
lines << "# => #{name}"
|
|
755
|
+
lines += lines_newline_comment
|
|
756
|
+
lines << "# =>#{description}"
|
|
757
|
+
lines += lines_newline_comment
|
|
758
|
+
}
|
|
759
|
+
end
|
|
760
|
+
lines += lines_newline_comment_os
|
|
761
|
+
lines << "# => description:"
|
|
762
|
+
lines << "# => #{v[:description]}"
|
|
763
|
+
if is_ovar && Aos::Cor::DEF_TYPES[:STRING][:name] == v[:type]
|
|
764
|
+
lines << "export #{var_name}=\"#{v[:value]}\""
|
|
765
|
+
else
|
|
766
|
+
lines << "export #{var_name}=#{mem_v || v[:value]}"
|
|
767
|
+
end
|
|
768
|
+
lines += lines_newline_comment_os
|
|
769
|
+
lines
|
|
770
|
+
end
|
|
771
|
+
|
|
772
|
+
end
|
|
773
|
+
end
|