aro 0.1.9 → 0.2.1
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 +3 -2
- data/aro.gemspec +1 -0
- data/bin/aos +3 -3
- data/bin/aro +3 -3
- data/checksums/aro-0.2.0.gem.sha512 +1 -0
- data/listen.rb +1 -1
- data/locale/en.aos.yml +46 -7
- data/locale/en.cards.yml +156 -156
- data/locale/en.dom.yml +2 -2
- data/locale/en.usage.yml +3 -9
- data/locale/en.yml +4 -0
- data/sys/aos/amg.rb +182 -0
- data/sys/aos/aos.rb +253 -120
- data/sys/aos/db/migrate/1765762724_create_libs.rb +22 -0
- data/sys/aos/db.rb +17 -10
- data/sys/aos/vws/base.rb +169 -0
- data/sys/aos/{views → vws}/dom.rb +6 -9
- data/sys/aos/vws/games/abpps.rb +19 -0
- data/sys/aos/{views → vws}/games/game.rb +19 -16
- data/sys/aos/vws/games/hbpps.rb +19 -0
- data/sys/aos/vws/games/shpps.rb +19 -0
- data/sys/aos/vws/games/vipps.rb +19 -0
- data/sys/aos/{views → vws}/games.rb +3 -3
- data/sys/aos/{views → vws}/know/library.rb +3 -3
- data/sys/aos/{views → vws}/know/temple.rb +3 -3
- data/sys/aos/{views → vws}/know.rb +3 -3
- data/sys/aos/vws/setup/amg.rb +22 -0
- data/sys/aos/vws/setup/config.rb +21 -0
- data/sys/aos/{views → vws}/setup.rb +3 -3
- data/sys/aos/vws/welcome/waite.rb +30 -0
- data/sys/aos/{views → vws}/welcome/winner.rb +3 -3
- data/sys/aos/{views → vws}/welcome.rb +3 -3
- data/sys/aos/you.rb +5 -3
- data/sys/aro/db.rb +13 -6
- data/sys/aro/mancy.rb +1 -0
- data/sys/aro/v.rb +1 -1
- data/sys/cli/deck.rb +22 -8
- data/sys/cli.rb +8 -9
- data/sys/{cli → dom}/config.rb +170 -144
- data/sys/dom/d.rb +10 -5
- data/sys/dom/dom.rb +7 -3
- data/sys/models/deck.rb +24 -20
- data/sys/reiquire.rb +5 -3
- data/sys/shr/lib/crs/CMakeLists.txt +12 -0
- data/sys/shr/lib/crs/compile.sh +5 -0
- data/sys/shr/lib/crs/crs.c +24 -0
- data/sys/shr/lib/crs/crs.o +0 -0
- data/sys/shr/lib/crs/libcrs.so +0 -0
- data/sys/shr/lib/lib.rb +43 -0
- data/sys/shr/prompt.rb +2 -2
- data/sys/shr/t.rb +17 -3
- data/sys/shr/version.rb +2 -6
- metadata +52 -23
- data/sys/aos/views/base.rb +0 -155
- data/sys/aos/views/games/abpps.rb +0 -21
- data/sys/aos/views/games/hbpps.rb +0 -21
- data/sys/aos/views/games/shpps.rb +0 -21
- data/sys/aos/views/games/vipps.rb +0 -21
- data/sys/aos/views/setup/settings.rb +0 -37
- data/sys/aos/views/welcome/waite.rb +0 -19
- /data/{db → sys/aos/db}/migrate/1765148774_create_yous.rb +0 -0
- /data/{db → sys/aro/db}/migrate/1763374647_create_decks.rb +0 -0
- /data/{db → sys/aro/db}/migrate/1763432541_create_logs.rb +0 -0
data/sys/{cli → dom}/config.rb
RENAMED
|
@@ -2,22 +2,24 @@
|
|
|
2
2
|
|
|
3
3
|
config.rb
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
dom config interface.
|
|
6
6
|
|
|
7
7
|
by i2097i
|
|
8
8
|
|
|
9
9
|
=end
|
|
10
10
|
|
|
11
|
-
module
|
|
11
|
+
module Aro
|
|
12
12
|
|
|
13
13
|
# cli entrypoint
|
|
14
14
|
def self.config
|
|
15
|
-
|
|
15
|
+
Aro::Config.process_config_command(ARGV)
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
class Config
|
|
19
19
|
include Singleton
|
|
20
20
|
|
|
21
|
+
attr_accessor :config_path, :display_lines
|
|
22
|
+
|
|
21
23
|
ARO_CONFIG_PREFIX = :ARO_CONFIG_
|
|
22
24
|
ARO_ENV_PREFIX = :ARO_ENV_
|
|
23
25
|
|
|
@@ -28,7 +30,7 @@ module CLI
|
|
|
28
30
|
# possible envs
|
|
29
31
|
#
|
|
30
32
|
# example usage:
|
|
31
|
-
#
|
|
33
|
+
# Aro::Config::ENVS[:PRODUCTION]
|
|
32
34
|
ENVS = {
|
|
33
35
|
DEVELOPMENT: :development,
|
|
34
36
|
PRODUCTION: :production,
|
|
@@ -38,7 +40,7 @@ module CLI
|
|
|
38
40
|
# possible formats
|
|
39
41
|
#
|
|
40
42
|
# example usage:
|
|
41
|
-
#
|
|
43
|
+
# Aro::Config::FORMATS[:TEXT]
|
|
42
44
|
FORMATS = {
|
|
43
45
|
TEXT: :text,
|
|
44
46
|
JSON: :json,
|
|
@@ -47,7 +49,7 @@ module CLI
|
|
|
47
49
|
# possible dimensions
|
|
48
50
|
#
|
|
49
51
|
# example usage:
|
|
50
|
-
#
|
|
52
|
+
# Aro::Config::DMS[:DEV_TAROT]
|
|
51
53
|
DMS = {
|
|
52
54
|
DEV_TAROT: :dev_tarot,
|
|
53
55
|
RUBY_FACOT: :ruby_facot,
|
|
@@ -56,7 +58,7 @@ module CLI
|
|
|
56
58
|
# ovar and ivar access
|
|
57
59
|
#
|
|
58
60
|
# example usage:
|
|
59
|
-
#
|
|
61
|
+
# Aro::Config::DEF_ACCESS[:READ]
|
|
60
62
|
DEF_ACCESS = {
|
|
61
63
|
READ: :read,
|
|
62
64
|
WRITE: :write
|
|
@@ -77,21 +79,21 @@ module CLI
|
|
|
77
79
|
# types used in definition
|
|
78
80
|
#
|
|
79
81
|
# example usage:
|
|
80
|
-
#
|
|
82
|
+
# Aro::Config::DEF_TYPES[:INT][:validator].call(unvalid, Aro::Config::DEF[:DIMENSION])
|
|
81
83
|
DEF_TYPES = {
|
|
82
84
|
BOOL: {
|
|
83
|
-
name:
|
|
85
|
+
name: Aro::Config::TYPES[:BOOL],
|
|
84
86
|
description: I18n.t("cli.config.type.bool_description"),
|
|
85
87
|
converter: Proc.new{|v|
|
|
86
|
-
if [
|
|
87
|
-
|
|
88
|
+
if [Aro::Config::BOOLS[:TRUE].to_s, Aro::Mancy::S].include?(v)
|
|
89
|
+
Aro::Config::BOOLS[:TRUE]
|
|
88
90
|
else
|
|
89
|
-
|
|
91
|
+
Aro::Config::BOOLS[:FALSE]
|
|
90
92
|
end
|
|
91
93
|
},
|
|
92
94
|
validator: Proc.new{|unvalid, k, v|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
+
Aro::Config.def_valid?(k, v) &&
|
|
96
|
+
Aro::Config.bool_valid?(unvalid)
|
|
95
97
|
}
|
|
96
98
|
},
|
|
97
99
|
INT: {
|
|
@@ -99,11 +101,11 @@ module CLI
|
|
|
99
101
|
description: I18n.t("cli.config.type.int_description"),
|
|
100
102
|
converter: Proc.new{|v| v.to_i},
|
|
101
103
|
validator: Proc.new{|unvalid, k, v|
|
|
102
|
-
Aro::V.say("validating #{k} (#{
|
|
104
|
+
Aro::V.say("validating #{k} (#{Aro::Config::DEF_TYPES[:INT][:name]})")
|
|
103
105
|
Aro::V.say("unvalid = #{unvalid}")
|
|
104
106
|
Aro::V.say("[min, max] = [#{v[:min]}, #{v[:max]}]")
|
|
105
|
-
int_valid =
|
|
106
|
-
|
|
107
|
+
int_valid = Aro::Config.def_valid?(k, v) &&
|
|
108
|
+
Aro::Config.int_valid?(unvalid) &&
|
|
107
109
|
unvalid.to_i >= v[:min] &&
|
|
108
110
|
unvalid.to_i <= v[:max]
|
|
109
111
|
Aro::V.say("unvalid(#{unvalid}) is#{int_valid ? " " : :" not ".to_s}valid.")
|
|
@@ -115,8 +117,8 @@ module CLI
|
|
|
115
117
|
description: I18n.t("cli.config.type.string_description"),
|
|
116
118
|
converter: Proc.new{|v| v.to_s},
|
|
117
119
|
validator: Proc.new{|unvalid, k, v|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
+
Aro::Config.def_valid?(k, v) &&
|
|
121
|
+
Aro::Config.string_valid?(unvalid)
|
|
120
122
|
}
|
|
121
123
|
},
|
|
122
124
|
VALUES: {
|
|
@@ -124,14 +126,14 @@ module CLI
|
|
|
124
126
|
description: I18n.t("cli.config.type.values_description"),
|
|
125
127
|
converter: Proc.new{|v| v.to_s},
|
|
126
128
|
validator: Proc.new{|unvalid, k, v|
|
|
127
|
-
|
|
129
|
+
Aro::Config.def_valid?(k, v) &&
|
|
128
130
|
v[:possible_values].keys.include?(unvalid&.to_sym)
|
|
129
131
|
}
|
|
130
132
|
},
|
|
131
133
|
}
|
|
132
134
|
|
|
133
135
|
def self.bool_valid?(unvalid)
|
|
134
|
-
|
|
136
|
+
Aro::Config::BOOLS.values.map{|b| b.to_s.to_sym}.include?(unvalid&.to_s&.to_sym)
|
|
135
137
|
end
|
|
136
138
|
|
|
137
139
|
def self.int_valid?(unvalid)
|
|
@@ -143,7 +145,7 @@ module CLI
|
|
|
143
145
|
end
|
|
144
146
|
|
|
145
147
|
def self.def_valid?(key, deff)
|
|
146
|
-
def_valid = deff ==
|
|
148
|
+
def_valid = deff == Aro::Config::DEF[key]
|
|
147
149
|
unless def_valid
|
|
148
150
|
Aro::V.say("invalid def! #{key} => #{deff}")
|
|
149
151
|
end
|
|
@@ -153,11 +155,10 @@ module CLI
|
|
|
153
155
|
|
|
154
156
|
def validate_config
|
|
155
157
|
invalid_vars = []
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
is_valid = v[:access] == CLI::Config::DEF_ACCESS[:READ]
|
|
158
|
+
Aro::Config::DEF.each{|k, v|
|
|
159
|
+
is_valid = v[:access] == Aro::Config::DEF_ACCESS[:READ]
|
|
159
160
|
unless is_valid
|
|
160
|
-
is_valid = valid_var?(
|
|
161
|
+
is_valid = valid_var?(Aro::Config.ivar(k), k, v)
|
|
161
162
|
end
|
|
162
163
|
invalid_vars << k unless is_valid
|
|
163
164
|
}
|
|
@@ -166,32 +167,32 @@ module CLI
|
|
|
166
167
|
|
|
167
168
|
def valid_var?(var_value, k, v)
|
|
168
169
|
Aro::V.say(v)
|
|
169
|
-
return true if v[:access] ==
|
|
170
|
+
return true if v[:access] == Aro::Config::DEF_ACCESS[:READ]
|
|
170
171
|
|
|
171
|
-
|
|
172
|
+
Aro::Config::DEF_TYPES[
|
|
172
173
|
v[:type].to_s.upcase.to_sym
|
|
173
174
|
][:validator].call(var_value, k, v)
|
|
174
175
|
end
|
|
175
176
|
|
|
176
177
|
def convert_var_for_def(k)
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
][:converter].call(ENV[
|
|
178
|
+
Aro::Config::DEF_TYPES[
|
|
179
|
+
Aro::Config::DEF[k][:type].upcase
|
|
180
|
+
][:converter].call(ENV[Aro::Config.ivar_k(k)])
|
|
180
181
|
end
|
|
181
182
|
|
|
182
183
|
# adapts I18n translations to generate bash environment vars.
|
|
183
184
|
#
|
|
184
185
|
# example usage:
|
|
185
|
-
#
|
|
186
|
+
# Aro::Config::DEF[:Z_MAX]
|
|
186
187
|
DEF = {
|
|
187
188
|
|
|
188
189
|
#
|
|
189
190
|
# => ivars
|
|
190
191
|
#
|
|
191
192
|
ENV: {
|
|
192
|
-
type:
|
|
193
|
-
access:
|
|
194
|
-
value:
|
|
193
|
+
type: Aro::Config::TYPES[:VALUES],
|
|
194
|
+
access: Aro::Config::DEF_ACCESS[:WRITE],
|
|
195
|
+
value: Aro::Config::ENVS[:PRODUCTION],
|
|
195
196
|
description: I18n.t("cli.config.env.description"),
|
|
196
197
|
possible_values: {
|
|
197
198
|
development: I18n.t("cli.config.env.development_description"),
|
|
@@ -200,16 +201,28 @@ module CLI
|
|
|
200
201
|
}
|
|
201
202
|
},
|
|
202
203
|
VERBOSE: {
|
|
203
|
-
type:
|
|
204
|
-
access:
|
|
205
|
-
value:
|
|
204
|
+
type: Aro::Config::TYPES[:BOOL],
|
|
205
|
+
access: Aro::Config::DEF_ACCESS[:WRITE],
|
|
206
|
+
value: Aro::Config::BOOLS[:FALSE],
|
|
206
207
|
description: I18n.t("cli.config.verbose_description"),
|
|
207
208
|
},
|
|
209
|
+
LOG_AOS_DB: {
|
|
210
|
+
type: Aro::Config::TYPES[:BOOL],
|
|
211
|
+
access: Aro::Config::DEF_ACCESS[:WRITE],
|
|
212
|
+
value: Aro::Config::BOOLS[:FALSE],
|
|
213
|
+
description: I18n.t("cli.config.log_aos_db_description"),
|
|
214
|
+
},
|
|
215
|
+
LOG_ARO_DB: {
|
|
216
|
+
type: Aro::Config::TYPES[:BOOL],
|
|
217
|
+
access: Aro::Config::DEF_ACCESS[:WRITE],
|
|
218
|
+
value: Aro::Config::BOOLS[:FALSE],
|
|
219
|
+
description: I18n.t("cli.config.log_aro_db_description"),
|
|
220
|
+
},
|
|
208
221
|
FORMAT: { # not implemented yet.
|
|
209
|
-
type:
|
|
222
|
+
type: Aro::Config::TYPES[:VALUES],
|
|
210
223
|
implemented: false,
|
|
211
|
-
access:
|
|
212
|
-
value:
|
|
224
|
+
access: Aro::Config::DEF_ACCESS[:WRITE],
|
|
225
|
+
value: Aro::Config::FORMATS[:TEXT],
|
|
213
226
|
description: I18n.t("cli.config.format.description"),
|
|
214
227
|
possible_values: {
|
|
215
228
|
text: I18n.t("cli.config.format.text_description"),
|
|
@@ -217,9 +230,9 @@ module CLI
|
|
|
217
230
|
}
|
|
218
231
|
},
|
|
219
232
|
DIMENSION: {
|
|
220
|
-
type:
|
|
221
|
-
access:
|
|
222
|
-
value:
|
|
233
|
+
type: Aro::Config::TYPES[:VALUES],
|
|
234
|
+
access: Aro::Config::DEF_ACCESS[:WRITE],
|
|
235
|
+
value: Aro::Config::DMS[:DEV_TAROT],
|
|
223
236
|
description: I18n.t("cli.config.dimension.description"),
|
|
224
237
|
possible_values: {
|
|
225
238
|
dev_tarot: I18n.t("cli.config.dimension.dev_tarot_description"),
|
|
@@ -227,8 +240,8 @@ module CLI
|
|
|
227
240
|
}
|
|
228
241
|
},
|
|
229
242
|
HEIGHT: {
|
|
230
|
-
type:
|
|
231
|
-
access:
|
|
243
|
+
type: Aro::Config::TYPES[:INT],
|
|
244
|
+
access: Aro::Config::DEF_ACCESS[:WRITE],
|
|
232
245
|
value: Aro::Mancy::NUMERALS[:XLII],
|
|
233
246
|
min: Aro::Mancy::NUMERALS[:I],
|
|
234
247
|
max: Aro::Mancy::NUMERALS[:MMXCVII],
|
|
@@ -239,8 +252,8 @@ module CLI
|
|
|
239
252
|
),
|
|
240
253
|
},
|
|
241
254
|
WIDTH: {
|
|
242
|
-
type:
|
|
243
|
-
access:
|
|
255
|
+
type: Aro::Config::TYPES[:INT],
|
|
256
|
+
access: Aro::Config::DEF_ACCESS[:WRITE],
|
|
244
257
|
value: Aro::Mancy::NUMERALS[:C] + Aro::Mancy::NUMERALS[:XXXVII] - Aro::Mancy::S,
|
|
245
258
|
min: Aro::Mancy::NUMERALS[:I],
|
|
246
259
|
max: Aro::Mancy::NUMERALS[:MMXCVII],
|
|
@@ -251,8 +264,8 @@ module CLI
|
|
|
251
264
|
),
|
|
252
265
|
},
|
|
253
266
|
Z: {
|
|
254
|
-
type:
|
|
255
|
-
access:
|
|
267
|
+
type: Aro::Config::TYPES[:INT],
|
|
268
|
+
access: Aro::Config::DEF_ACCESS[:WRITE],
|
|
256
269
|
value: Aro::Mancy::NUMERALS[:I],
|
|
257
270
|
min: Aro::Mancy::NUMERALS[:I],
|
|
258
271
|
max: Aro::Mancy::NUMERALS[:MMXCVII],
|
|
@@ -263,8 +276,8 @@ module CLI
|
|
|
263
276
|
),
|
|
264
277
|
},
|
|
265
278
|
Z_MAX: {
|
|
266
|
-
type:
|
|
267
|
-
access:
|
|
279
|
+
type: Aro::Config::TYPES[:INT],
|
|
280
|
+
access: Aro::Config::DEF_ACCESS[:WRITE],
|
|
268
281
|
value: Aro::Mancy::NUMERALS[:VII],
|
|
269
282
|
min: Aro::Mancy::NUMERALS[:I],
|
|
270
283
|
max: Aro::Mancy::NUMERALS[:XXII],
|
|
@@ -279,155 +292,168 @@ module CLI
|
|
|
279
292
|
# => ovars
|
|
280
293
|
#
|
|
281
294
|
ARO_ENV_O: {
|
|
282
|
-
type:
|
|
283
|
-
access:
|
|
295
|
+
type: Aro::Config::TYPES[:INT],
|
|
296
|
+
access: Aro::Config::DEF_ACCESS[:READ],
|
|
284
297
|
value: Aro::Mancy::O,
|
|
285
298
|
description: I18n.t("cli.config.aro_env.O_description"),
|
|
286
299
|
},
|
|
287
300
|
ARO_ENV_S: {
|
|
288
|
-
type:
|
|
289
|
-
access:
|
|
301
|
+
type: Aro::Config::TYPES[:INT],
|
|
302
|
+
access: Aro::Config::DEF_ACCESS[:READ],
|
|
290
303
|
value: Aro::Mancy::S,
|
|
291
304
|
description: I18n.t("cli.config.aro_env.S_description"),
|
|
292
305
|
},
|
|
293
306
|
ARO_ENV_OS: {
|
|
294
|
-
type:
|
|
295
|
-
access:
|
|
307
|
+
type: Aro::Config::TYPES[:INT],
|
|
308
|
+
access: Aro::Config::DEF_ACCESS[:READ],
|
|
296
309
|
value: Aro::Mancy::OS,
|
|
297
310
|
description: I18n.t("cli.config.aro_env.OS_description"),
|
|
298
311
|
},
|
|
299
312
|
ARO_ENV_E: {
|
|
300
|
-
type:
|
|
301
|
-
access:
|
|
313
|
+
type: Aro::Config::TYPES[:INT],
|
|
314
|
+
access: Aro::Config::DEF_ACCESS[:READ],
|
|
302
315
|
value: Aro::Mancy::E,
|
|
303
316
|
description: I18n.t("cli.config.aro_env.E_description"),
|
|
304
317
|
},
|
|
305
318
|
ARO_ENV_N: {
|
|
306
|
-
type:
|
|
307
|
-
access:
|
|
319
|
+
type: Aro::Config::TYPES[:INT],
|
|
320
|
+
access: Aro::Config::DEF_ACCESS[:READ],
|
|
308
321
|
value: Aro::Mancy::N,
|
|
309
322
|
description: I18n.t("cli.config.aro_env.N_description"),
|
|
310
323
|
},
|
|
311
324
|
ARO_ENV_PS1: {
|
|
312
|
-
type:
|
|
313
|
-
access:
|
|
325
|
+
type: Aro::Config::TYPES[:STRING],
|
|
326
|
+
access: Aro::Config::DEF_ACCESS[:READ],
|
|
314
327
|
value: Aro::Mancy::PS1,
|
|
315
328
|
description: I18n.t("cli.config.aro_env.PS1_description"),
|
|
316
329
|
},
|
|
317
330
|
ARO_ENV_NAME_FILE: {
|
|
318
|
-
type:
|
|
319
|
-
access:
|
|
331
|
+
type: Aro::Config::TYPES[:STRING],
|
|
332
|
+
access: Aro::Config::DEF_ACCESS[:READ],
|
|
320
333
|
value: Aro::Mancy::NAME_FILE,
|
|
321
334
|
description: I18n.t("cli.config.aro_env.NAME_FILE_description"),
|
|
322
335
|
},
|
|
323
336
|
ARO_ENV_I2097I: {
|
|
324
|
-
type:
|
|
325
|
-
access:
|
|
337
|
+
type: Aro::Config::TYPES[:STRING],
|
|
338
|
+
access: Aro::Config::DEF_ACCESS[:READ],
|
|
326
339
|
value: Aro::Mancy::I2097I,
|
|
327
340
|
description: I18n.t("cli.config.aro_env.I2097I_description"),
|
|
328
341
|
},
|
|
329
342
|
ARO_ENV_YES: {
|
|
330
|
-
type:
|
|
331
|
-
access:
|
|
343
|
+
type: Aro::Config::TYPES[:STRING],
|
|
344
|
+
access: Aro::Config::DEF_ACCESS[:READ],
|
|
332
345
|
value: Aro::Mancy::YES,
|
|
333
346
|
description: I18n.t("cli.config.aro_env.YES_description"),
|
|
334
347
|
},
|
|
335
348
|
ARO_ENV_ALL: {
|
|
336
|
-
type:
|
|
337
|
-
access:
|
|
349
|
+
type: Aro::Config::TYPES[:STRING],
|
|
350
|
+
access: Aro::Config::DEF_ACCESS[:READ],
|
|
338
351
|
value: Aro::Mancy::ALL,
|
|
339
352
|
description: I18n.t("cli.config.aro_env.ALL_description"),
|
|
340
353
|
},
|
|
341
354
|
}
|
|
342
355
|
|
|
343
|
-
def
|
|
344
|
-
|
|
345
|
-
if Aro::Mancy.in_aro? && Aro::Mancy.is_initialized?
|
|
346
|
-
@@context = Aro::Mancy.name
|
|
347
|
-
elsif Aro::Dom.in_arodom? && Aro::Dom.is_initialized?
|
|
348
|
-
@@context = Aro::Dom.name
|
|
349
|
-
end
|
|
350
|
-
|
|
351
|
-
return if @@context.nil?
|
|
352
|
-
|
|
353
|
-
unless File.exist?(CLI::Config.config_filepath)
|
|
356
|
+
def load
|
|
357
|
+
unless File.exist?(Aro::Config.config_filepath)
|
|
354
358
|
generate_config
|
|
355
359
|
end
|
|
356
360
|
|
|
357
361
|
source_config
|
|
358
362
|
setup_env
|
|
363
|
+
|
|
364
|
+
self.display_lines = Aro::Config.base_lines
|
|
365
|
+
end
|
|
366
|
+
|
|
367
|
+
def self.base_lines
|
|
368
|
+
# print Aro::Config::DEF
|
|
369
|
+
lines = []
|
|
370
|
+
lines << "loaded config at: #{Aos::Os.osify(Aro::Config.config_filepath)}"
|
|
371
|
+
lines << "<Aro::Config::DEF>"
|
|
372
|
+
lines += Aro::Config.dump_config
|
|
373
|
+
|
|
374
|
+
# print config commands
|
|
375
|
+
lines << ""
|
|
376
|
+
lines << I18n.t("aos.constants.commands")
|
|
377
|
+
lines += Aos::Vw::Base.lines_for_cmd(Aos::Os::CMDS[:CONFIG])
|
|
378
|
+
lines
|
|
359
379
|
end
|
|
360
380
|
|
|
361
381
|
def self.config_filepath
|
|
362
|
-
|
|
363
|
-
|
|
382
|
+
if Aro::Mancy.in_aro? && Aro::Mancy.is_initialized?
|
|
383
|
+
self.instance.config_path = File.join(Dir.pwd, Aro::Db.base_aro_dir)
|
|
384
|
+
elsif Aro::Dom.in_arodom? && Aro::Dom.is_initialized?
|
|
385
|
+
self.instance.config_path = File.join(Aro::Dom::dom_root, Aro::Dom.room_path(:config))
|
|
386
|
+
end
|
|
387
|
+
|
|
388
|
+
File.join(
|
|
389
|
+
self.instance.config_path,
|
|
390
|
+
Aro::Config::CONFIG_FILE.to_s
|
|
391
|
+
)
|
|
364
392
|
end
|
|
365
393
|
|
|
366
394
|
def self.is_test?
|
|
367
|
-
ENV[:ARO_ENV.to_s] ==
|
|
395
|
+
ENV[:ARO_ENV.to_s] == Aro::Config::ENVS[:TEST].to_s
|
|
368
396
|
end
|
|
369
397
|
|
|
370
|
-
def self.
|
|
371
|
-
|
|
372
|
-
width = CLI::Config.ivar(:WIDTH).to_i
|
|
373
|
-
columns = width.pow(Aro::Mancy::S.to_f / Aro::Mancy::OS.to_f).to_i
|
|
398
|
+
def self.display_configuration
|
|
399
|
+
height, width = IO.console.winsize
|
|
374
400
|
result = {
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
DIVIDER: :"_".to_s
|
|
401
|
+
HEIGHT: height, #Aro::Config.ivar(:HEIGHT).to_i,
|
|
402
|
+
WIDTH: width - Aro::Mancy::O,
|
|
403
|
+
DIVIDER: :".".to_s
|
|
379
404
|
}
|
|
380
405
|
# Aro::V.say(result)
|
|
381
406
|
|
|
382
407
|
result
|
|
383
408
|
end
|
|
384
409
|
|
|
410
|
+
def self.is_format_text?
|
|
411
|
+
Aro::Config.ivar(:FORMAT)&.to_sym == Aro::Config::FORMATS[:TEXT]
|
|
412
|
+
end
|
|
413
|
+
|
|
385
414
|
def self.process_config_command(args)
|
|
386
|
-
if args[
|
|
387
|
-
|
|
388
|
-
Aro::P.say((
|
|
389
|
-
["config loaded from #{CLI::Config.config_filepath}"] +
|
|
390
|
-
CLI::Config.dump_config
|
|
391
|
-
).join("\n"))
|
|
392
|
-
elsif [args[2],args[3]].compact.any? && args[1] == Aos::Os::CMDS[:CONFIG][:cmds][:SET][:key].to_s
|
|
393
|
-
CLI::Config.set_ivar(args[2], args[3])
|
|
415
|
+
if [args[2],args[3]].compact.any? && args[1] == Aos::Os::CMDS[:CONFIG][:cmds][:SET][:key].to_s
|
|
416
|
+
Aro::Config.set_ivar(args[2], args[3])
|
|
394
417
|
end
|
|
395
418
|
end
|
|
396
419
|
|
|
397
420
|
# out vars
|
|
398
421
|
def self.ovar(suffix)
|
|
399
|
-
|
|
422
|
+
Aro::Config::DEF[suffix][:value]
|
|
400
423
|
end
|
|
401
424
|
# out vars
|
|
402
425
|
def self.ovar_k(suffix)
|
|
403
|
-
"#{
|
|
426
|
+
"#{Aro::Config::ARO_ENV_PREFIX}#{suffix}"
|
|
404
427
|
end
|
|
405
428
|
|
|
406
429
|
# in vars
|
|
407
430
|
def self.ivar(suffix)
|
|
408
|
-
ENV[
|
|
431
|
+
ENV[Aro::Config.ivar_k(suffix)]
|
|
409
432
|
end
|
|
410
433
|
# in vars
|
|
411
434
|
def self.ivar_k(suffix)
|
|
412
|
-
"#{
|
|
435
|
+
"#{Aro::Config::ARO_CONFIG_PREFIX}#{suffix}"
|
|
413
436
|
end
|
|
414
437
|
|
|
415
438
|
def self.set_ivar(k, new_value)
|
|
416
439
|
k = k.upcase.to_sym
|
|
417
440
|
|
|
418
|
-
current_value =
|
|
441
|
+
current_value = Aro::Config.ivar(k)
|
|
419
442
|
# ensure the var name is valid
|
|
420
443
|
unless current_value.nil?
|
|
421
|
-
Aro::
|
|
422
|
-
if
|
|
444
|
+
Aro::Dom::P.say("validating #{k} with value #{new_value}")
|
|
445
|
+
if Aro::Config.instance.valid_var?(new_value, k, Aro::Config::DEF[k])
|
|
423
446
|
# set ENV value
|
|
424
|
-
ENV[
|
|
425
|
-
Aro::
|
|
447
|
+
ENV[Aro::Config.ivar_k(k)] = new_value
|
|
448
|
+
Aro::Dom::P.say("#{k} set to #{new_value}")
|
|
449
|
+
Aro::V.say(ENV[Aro::Config.ivar_k(k)])
|
|
426
450
|
|
|
427
451
|
# flush existing config and regen
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
452
|
+
Aro::Config.instance.generate_config(true)
|
|
453
|
+
Aro::Config.instance.source_config
|
|
454
|
+
Aro::Config.instance.setup_env
|
|
455
|
+
Aro::Db.configure_logger
|
|
456
|
+
Aos::Db.configure_logger
|
|
431
457
|
else
|
|
432
458
|
Aro::Dom::P.say("the ivar value you entered is invalid. ignoring.")
|
|
433
459
|
end
|
|
@@ -440,19 +466,19 @@ module CLI
|
|
|
440
466
|
# do not change - update $ARO_CONFIG_ENV .aro/.config file
|
|
441
467
|
#
|
|
442
468
|
# default is production
|
|
443
|
-
varenv =
|
|
444
|
-
is_valid = valid_var?(varenv, :ENV,
|
|
445
|
-
ENV[:ARO_ENV.to_s] = is_valid ? varenv :
|
|
469
|
+
varenv = Aro::Config.ivar(:ENV)
|
|
470
|
+
is_valid = valid_var?(varenv, :ENV, Aro::Config::DEF[:ENV])
|
|
471
|
+
ENV[:ARO_ENV.to_s] = is_valid ? varenv : Aro::Config::ENVS[:PRODUCTION].to_s
|
|
446
472
|
Aro::D.say("setup_env: #{ENV[:ARO_ENV.to_s]}")
|
|
447
473
|
end
|
|
448
474
|
|
|
449
475
|
def self.dump_config
|
|
450
476
|
dump = []
|
|
451
|
-
|
|
452
|
-
if v[:access] ==
|
|
453
|
-
dump << "$#{
|
|
477
|
+
Aro::Config::DEF.each{|k, v|
|
|
478
|
+
if v[:access] == Aro::Config::DEF_ACCESS[:WRITE]
|
|
479
|
+
dump << "$#{Aro::Config.ivar_k(k).ljust(Aro::Mancy::NUMERALS[:XIV] * Aro::Mancy::OS)}=#{Aro::Config.ivar(k)}"
|
|
454
480
|
else
|
|
455
|
-
dump << "$#{
|
|
481
|
+
dump << "$#{Aro::Config.ovar_k(k).ljust(Aro::Mancy::NUMERALS[:XIV] * Aro::Mancy::OS)}=#{Aro::Config.ovar(k)}"
|
|
456
482
|
end
|
|
457
483
|
}
|
|
458
484
|
|
|
@@ -460,9 +486,9 @@ module CLI
|
|
|
460
486
|
end
|
|
461
487
|
|
|
462
488
|
def source_config
|
|
463
|
-
Aro::D.say(I18n.t("cli.config.source", name:
|
|
464
|
-
File.read(
|
|
465
|
-
line.match?(/export #{
|
|
489
|
+
Aro::D.say(I18n.t("cli.config.source", name: Aro::Config.config_filepath))
|
|
490
|
+
File.read(Aro::Config.config_filepath).split("\n").select{|line|
|
|
491
|
+
line.match?(/export #{Aro::Config::ARO_CONFIG_PREFIX}/)
|
|
466
492
|
}.map{|line|
|
|
467
493
|
line.gsub("export ", "").split("=")
|
|
468
494
|
}.each{|kv|
|
|
@@ -473,21 +499,21 @@ module CLI
|
|
|
473
499
|
|
|
474
500
|
# todo: implement
|
|
475
501
|
invalid_defs = validate_config
|
|
476
|
-
|
|
502
|
+
Aro::Config.dump_config.each{|l| Aro::V.say(l)}
|
|
477
503
|
invalid_defs.each{|k|
|
|
478
|
-
v =
|
|
479
|
-
if v[:access] ==
|
|
480
|
-
ENV[
|
|
504
|
+
v = Aro::Config::DEF[k.to_sym]
|
|
505
|
+
if v[:access] == Aro::Config::DEF_ACCESS[:WRITE]
|
|
506
|
+
ENV[Aro::Config.ivar_k(k)] = v[:value]
|
|
481
507
|
else
|
|
482
|
-
ENV[
|
|
508
|
+
ENV[Aro::Config.ovar_k(k)] = v[:value]
|
|
483
509
|
end
|
|
484
510
|
}
|
|
485
511
|
end
|
|
486
512
|
|
|
487
513
|
def generate_config(from_memory = false)
|
|
488
514
|
# todo: localize generated config text
|
|
489
|
-
Aro::D.say(I18n.t("cli.config.generate", name:
|
|
490
|
-
File.open(
|
|
515
|
+
Aro::D.say(I18n.t("cli.config.generate", name: Aro::Config.config_filepath))
|
|
516
|
+
File.open(Aro::Config.config_filepath, "w+") do |file|
|
|
491
517
|
# intro
|
|
492
518
|
Aro::Mancy::OS.times do
|
|
493
519
|
print_div file.object_id
|
|
@@ -520,8 +546,8 @@ module CLI
|
|
|
520
546
|
print_osr file.object_id
|
|
521
547
|
|
|
522
548
|
# vars
|
|
523
|
-
|
|
524
|
-
print_var file.object_id, k, v, (from_memory ? ENV[
|
|
549
|
+
Aro::Config::DEF.each{|k, v|
|
|
550
|
+
print_var file.object_id, k, v, (from_memory ? ENV[Aro::Config.ivar_k(k)] : nil)
|
|
525
551
|
}
|
|
526
552
|
|
|
527
553
|
print_osr file.object_id
|
|
@@ -573,13 +599,13 @@ module CLI
|
|
|
573
599
|
|
|
574
600
|
def print_def_types f_object_id
|
|
575
601
|
file = ObjectSpace._id2ref f_object_id
|
|
576
|
-
file.write("#
|
|
602
|
+
file.write("# Aro::Config::DEF_TYPES\n")
|
|
577
603
|
file.write("# describes the possible types of variables.\n")
|
|
578
|
-
|
|
604
|
+
Aro::Config::DEF_TYPES.each{|k, v|
|
|
579
605
|
file.write("# #{k}: #{v[:description]}\n")
|
|
580
606
|
}
|
|
581
607
|
print_osr f_object_id
|
|
582
|
-
file.write("#
|
|
608
|
+
file.write("# Aro::Config::DEF\n")
|
|
583
609
|
file.write("# define & expose an aro bash api via ENV variables.\n")
|
|
584
610
|
file.write("# there are two types of bash vars in aro.\n")
|
|
585
611
|
file.write("# 1) in vars (ivars). \n")
|
|
@@ -595,25 +621,25 @@ module CLI
|
|
|
595
621
|
def print_var f_object_id, k, v, mem_v
|
|
596
622
|
file = ObjectSpace._id2ref f_object_id
|
|
597
623
|
|
|
598
|
-
is_ovar =
|
|
624
|
+
is_ovar = Aro::Config::DEF[k][:access] == Aro::Config::DEF_ACCESS[:READ]
|
|
599
625
|
if is_ovar
|
|
600
626
|
var_name = k
|
|
601
627
|
else
|
|
602
|
-
var_name =
|
|
628
|
+
var_name = Aro::Config.ivar_k(k)
|
|
603
629
|
end
|
|
604
|
-
Aro::V.say("access for #{k} is #{
|
|
630
|
+
Aro::V.say("access for #{k} is #{Aro::Config::DEF[k][:access]}")
|
|
605
631
|
Aro::V.say("using var_name: #{var_name}")
|
|
606
632
|
file.write("# [#{var_name}] (#{is_ovar ? :ovar : :ivar})\n")
|
|
607
|
-
file.write("# =>
|
|
633
|
+
file.write("# => Aro::Config::DEF_TYPES: #{v[:type]}\n")
|
|
608
634
|
case v[:type]
|
|
609
|
-
when
|
|
635
|
+
when Aro::Config::DEF_TYPES[:INT][:name]
|
|
610
636
|
file.write("# => #{I18n.t("cli.config.type.int_description")}\n")
|
|
611
637
|
file.write("# => #{I18n.t("cli.config.minimum")}: #{v[:min]}\n")
|
|
612
638
|
file.write("# => #{I18n.t("cli.config.maximum")}: #{v[:max]}\n")
|
|
613
|
-
when
|
|
639
|
+
when Aro::Config::DEF_TYPES[:STRING][:name]
|
|
614
640
|
file.write("# => #{I18n.t("cli.config.type.string_description")}\n")
|
|
615
641
|
file.write("# => use \"double quotes\" if there are any spaces.\n")
|
|
616
|
-
when
|
|
642
|
+
when Aro::Config::DEF_TYPES[:VALUES][:name]
|
|
617
643
|
file.write("# => #{I18n.t("cli.config.type.values_description")}\n")
|
|
618
644
|
file.write("# => #{I18n.t("cli.config.possible_values")}:\n")
|
|
619
645
|
print_sr f_object_id
|
|
@@ -627,7 +653,7 @@ module CLI
|
|
|
627
653
|
print_osr f_object_id
|
|
628
654
|
file.write("# => description:\n")
|
|
629
655
|
file.write("# => #{v[:description]}\n")
|
|
630
|
-
if is_ovar &&
|
|
656
|
+
if is_ovar && Aro::Config::DEF_TYPES[:STRING][:name] == v[:type]
|
|
631
657
|
file.write("export #{var_name}=\"#{v[:value]}\"\n")
|
|
632
658
|
else
|
|
633
659
|
file.write("export #{var_name}=#{mem_v || v[:value]}\n")
|