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/aos/aos.rb
CHANGED
|
@@ -13,38 +13,37 @@ require :aro.to_s
|
|
|
13
13
|
module Aos
|
|
14
14
|
|
|
15
15
|
def self.run
|
|
16
|
-
Aos::Db.new
|
|
17
|
-
Aos::Os::boot(Aos::you)
|
|
18
16
|
begin
|
|
19
17
|
Aos::Os.instance.run
|
|
20
18
|
rescue Interrupt => e
|
|
21
|
-
Aos
|
|
19
|
+
Aos.run
|
|
22
20
|
end
|
|
23
21
|
end
|
|
24
22
|
|
|
25
|
-
def self.
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
Aos::Os::instance.
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
def self.you
|
|
32
|
-
you = Aos::You.where(name: :you).first
|
|
33
|
-
you = Aos::You.create(name: :you, pwd: Dir.pwd) if you.nil?
|
|
34
|
-
you
|
|
23
|
+
def self.process
|
|
24
|
+
cmd = ARGV.join(" ")
|
|
25
|
+
Aro::D.say("processing cmd #{cmd}...")
|
|
26
|
+
Aos::Os::instance.process_cmd(cmd)
|
|
35
27
|
end
|
|
36
28
|
|
|
37
29
|
class Os
|
|
38
30
|
include Singleton
|
|
39
31
|
|
|
40
|
-
attr_accessor :you, :running, :view
|
|
32
|
+
attr_accessor :you, :libs, :running, :view, :db, :display_lines
|
|
41
33
|
|
|
42
34
|
A = :"@"
|
|
43
35
|
STAR = :"*"
|
|
36
|
+
YOU = :you.to_s
|
|
37
|
+
YOU_FLAG = :"--you".to_s
|
|
44
38
|
PS1 = :">[#{Aos::Os}]>: "
|
|
45
39
|
DATE_FORMAT = "%A %d %b %Y %I:%M:%S %p"
|
|
46
40
|
|
|
47
41
|
CMDS = {
|
|
42
|
+
AMG: {
|
|
43
|
+
key: :amg,
|
|
44
|
+
description: I18n.t("aos.commands.description.amg"),
|
|
45
|
+
usage: I18n.t("aos.commands.usage.amg"),
|
|
46
|
+
},
|
|
48
47
|
CD: {
|
|
49
48
|
key: :cd,
|
|
50
49
|
description: I18n.t("aos.commands.description.cd"),
|
|
@@ -57,7 +56,7 @@ module Aos
|
|
|
57
56
|
cmds: {
|
|
58
57
|
SET: {
|
|
59
58
|
key: :set,
|
|
60
|
-
description: I18n.t("aos.commands.description.config_set", prefix:
|
|
59
|
+
description: I18n.t("aos.commands.description.config_set", prefix: Aro::Config::ARO_CONFIG_PREFIX),
|
|
61
60
|
usage: I18n.t("aos.commands.usage.config_set"),
|
|
62
61
|
}
|
|
63
62
|
}
|
|
@@ -67,6 +66,11 @@ module Aos
|
|
|
67
66
|
description: I18n.t("aos.commands.description.exit"),
|
|
68
67
|
usage: I18n.t("aos.commands.usage.exit"),
|
|
69
68
|
},
|
|
69
|
+
HELP: {
|
|
70
|
+
key: :help,
|
|
71
|
+
description: I18n.t("aos.commands.description.help"),
|
|
72
|
+
usage: I18n.t("aos.commands.usage.help"),
|
|
73
|
+
},
|
|
70
74
|
LS: {
|
|
71
75
|
key: :ls,
|
|
72
76
|
description: I18n.t("aos.commands.description.ls"),
|
|
@@ -84,110 +88,252 @@ module Aos
|
|
|
84
88
|
},
|
|
85
89
|
}
|
|
86
90
|
|
|
87
|
-
def self.
|
|
88
|
-
|
|
89
|
-
|
|
91
|
+
def self.osify(path, leading_slash = false)
|
|
92
|
+
return path unless Aro::Dom.in_arodom?
|
|
93
|
+
path_arr = path.split("/")
|
|
94
|
+
Aro::Dom::dom_root.split("/").each{|rdp| path_arr.delete(rdp)}
|
|
95
|
+
result = path_arr.join("/")
|
|
96
|
+
if leading_slash
|
|
97
|
+
result = "/" + result
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
result
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
def self.is_aos_command?(arg)
|
|
104
|
+
# determine if command is Aos::Os::CMDS
|
|
105
|
+
# passthrough to system if command is not in Aos::Os::CMDS
|
|
106
|
+
Aos::Os::CMDS.values.map{|v| v[:key]}.include?(arg.to_sym)
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
def self.you_flagd?
|
|
110
|
+
self.instance.you&.name != Aos::Os::YOU
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
def self.sanitize_you(cmd)
|
|
114
|
+
if cmd.present? && cmd.include?(Aos::Os::YOU_FLAG)
|
|
115
|
+
cmd_split = cmd.split(" ")
|
|
116
|
+
i = cmd_split.index(Aos::Os::YOU_FLAG)
|
|
117
|
+
cmd_split.delete_at(i)
|
|
118
|
+
cmd_split.delete_at(i)
|
|
119
|
+
cmd = cmd_split.join(" ")
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
cmd
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
def initialize
|
|
126
|
+
Aro::Config.instance.load
|
|
127
|
+
if Aro::Dom.in_arodom? && !Aro::Dom.is_initialized?
|
|
128
|
+
Aro::Dom.new.generate
|
|
129
|
+
end
|
|
130
|
+
@db = Aos::Db.new
|
|
131
|
+
load_libs
|
|
132
|
+
load_you
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
def load_libs
|
|
136
|
+
# todo: load from directory of libs.
|
|
137
|
+
# something like:
|
|
138
|
+
#
|
|
139
|
+
# Dir[lib_something_something].each do{|l| Aos::Lib.install(l)}
|
|
140
|
+
|
|
141
|
+
# for now static
|
|
142
|
+
Aos::Amg.load(:crs)
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
def load_you
|
|
146
|
+
return if @you.present?
|
|
147
|
+
|
|
148
|
+
you_name = Aos::Os::YOU
|
|
149
|
+
if ARGV.include?(Aos::Os::YOU_FLAG)
|
|
150
|
+
you_name = ARGV[ARGV.index(Aos::Os::YOU_FLAG) + Aro::Mancy::S]
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
@you = Aos::You.find_by(name: you_name)
|
|
154
|
+
@you = Aos::You.create(name: you_name, pwd: Dir.pwd) if @you.nil?
|
|
155
|
+
|
|
156
|
+
self.display_lines = [Aos::Os.osify(@you.pwd, true)]
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
def load_view
|
|
160
|
+
view_name = Aos::Os.osify(@you.pwd).split("/").last || :dom.to_s
|
|
161
|
+
view_cls = nil
|
|
162
|
+
begin
|
|
163
|
+
view_cls = (Aos::Vw.name + "::#{view_name.capitalize}").constantize
|
|
164
|
+
rescue
|
|
165
|
+
view_cls = Aos::Vw::Base
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
Dir.chdir(@you.pwd) do
|
|
169
|
+
if Aro::Mancy.in_aro? && Aro::Mancy.is_initialized?
|
|
170
|
+
view_cls = Aos::Vw::Game
|
|
171
|
+
end
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
Aro::D.say("loading view #{view_cls}")
|
|
175
|
+
@view = view_cls
|
|
90
176
|
end
|
|
91
177
|
|
|
92
178
|
def render
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
179
|
+
load_view
|
|
180
|
+
return if @view.nil?
|
|
181
|
+
Dir.chdir(@you.reload.pwd) do
|
|
182
|
+
if Aro::Mancy.in_aro? && Aro::Mancy.is_initialized?
|
|
183
|
+
system(:aro.to_s)
|
|
184
|
+
else
|
|
185
|
+
@view.show
|
|
186
|
+
end
|
|
96
187
|
end
|
|
97
188
|
end
|
|
98
189
|
|
|
99
|
-
def
|
|
100
|
-
|
|
101
|
-
|
|
190
|
+
def process_cmd(cmd)
|
|
191
|
+
Dir.chdir(@you.reload.pwd) do
|
|
192
|
+
configure_readline
|
|
193
|
+
passthrough = main(cmd)
|
|
194
|
+
if Aro::Config.is_format_text?
|
|
195
|
+
# IO.console.goto(Aro::Mancy::O, Aro::Mancy::O)
|
|
196
|
+
end
|
|
197
|
+
nothing = nil
|
|
198
|
+
if passthrough
|
|
199
|
+
nothing = system(cmd)
|
|
200
|
+
Aos::S.say(nothing) if nothing.nil?
|
|
201
|
+
end
|
|
102
202
|
|
|
103
|
-
|
|
104
|
-
|
|
203
|
+
if nothing.nil?
|
|
204
|
+
render
|
|
205
|
+
end
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
CLI::EXIT_CODES[:SUCCESS]
|
|
209
|
+
end
|
|
105
210
|
|
|
211
|
+
def configure_readline
|
|
106
212
|
# configure Readline
|
|
107
|
-
|
|
213
|
+
Readline.completion_append_character = "/"
|
|
108
214
|
Readline.completion_proc = Proc.new{|str|
|
|
109
|
-
#
|
|
110
|
-
|
|
111
|
-
Dir
|
|
215
|
+
# Aro::V.say(str)
|
|
216
|
+
dir_matcher = @you.pwd + "/" + str + Aos::Os::STAR.to_s
|
|
217
|
+
dir_listing = Dir.glob(dir_matcher, File::FNM_DOTMATCH).map{|d| Aos::Os.osify(d)}
|
|
218
|
+
r_str = Regexp.escape(str)
|
|
219
|
+
|
|
220
|
+
# Aro::V.say(dir_listing.join(" ")) if dir_listing.any?
|
|
221
|
+
# checks pwd
|
|
222
|
+
matches = dir_listing.grep(/^#{r_str}/)
|
|
223
|
+
if matches.any?
|
|
224
|
+
matches
|
|
225
|
+
else
|
|
226
|
+
# checks reserved words
|
|
227
|
+
Aro::Dom::D.reserved_words.grep(/^#{r_str}/)
|
|
228
|
+
end
|
|
112
229
|
}
|
|
230
|
+
end
|
|
113
231
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
when Aos::Os::CMDS[:CONFIG][:key]
|
|
128
|
-
# config
|
|
129
|
-
handle_config(args)
|
|
130
|
-
when Aos::Os::CMDS[:LS][:key]
|
|
131
|
-
# ls
|
|
132
|
-
handle_ls(args)
|
|
133
|
-
when Aos::Os::CMDS[:LL][:key]
|
|
134
|
-
# ll
|
|
135
|
-
handle_ll(args)
|
|
136
|
-
when Aos::Os::CMDS[:PWD][:key]
|
|
137
|
-
# pwd
|
|
138
|
-
handle_pwd(args)
|
|
139
|
-
when Aos::Os::CMDS[:EXIT][:key]
|
|
140
|
-
# exit
|
|
141
|
-
handle_exit(args)
|
|
142
|
-
when Aos::Os::CMDS[:CD][:key]
|
|
143
|
-
# cd
|
|
144
|
-
handle_cd(args)
|
|
232
|
+
def run
|
|
233
|
+
# run condition
|
|
234
|
+
@running = true
|
|
235
|
+
|
|
236
|
+
original_stdout = $stdout
|
|
237
|
+
$stdout = StringIO.open do |out|
|
|
238
|
+
cmd = nil
|
|
239
|
+
loop do
|
|
240
|
+
# erase before cursor
|
|
241
|
+
process_cmd(cmd)
|
|
242
|
+
IO.console.goto(Aro::Config.display_configuration[:HEIGHT], Aro::Mancy::O)
|
|
243
|
+
break unless @running && cmd = Readline.readline(calc_ps1, true)
|
|
244
|
+
IO.console.erase_screen(Aro::Mancy::S)
|
|
145
245
|
end
|
|
146
246
|
|
|
147
|
-
|
|
247
|
+
out
|
|
148
248
|
end
|
|
149
249
|
|
|
150
250
|
CLI::EXIT_CODES[:SUCCESS]
|
|
251
|
+
ensure
|
|
252
|
+
$stdout = original_stdout
|
|
151
253
|
end
|
|
152
254
|
|
|
153
|
-
def
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
255
|
+
def main(cmd)
|
|
256
|
+
# begin game loop
|
|
257
|
+
return false if cmd.nil?
|
|
258
|
+
|
|
259
|
+
# get args
|
|
260
|
+
args = Aos::Os.sanitize_you(cmd).split(" ")
|
|
261
|
+
return false if args[0].nil?
|
|
262
|
+
return false if args[0] == :aos.to_s
|
|
263
|
+
|
|
264
|
+
args = handle_aro_override(args)
|
|
265
|
+
|
|
266
|
+
passthrough = !Aos::Os.is_aos_command?(args[Aro::Mancy::O]) ||
|
|
267
|
+
args.include?(:aos.to_s)
|
|
268
|
+
|
|
269
|
+
# set aos pwd
|
|
270
|
+
unless passthrough
|
|
271
|
+
Dir.chdir(@you.pwd) do
|
|
272
|
+
# process commands
|
|
273
|
+
case args[Aro::Mancy::O].to_sym
|
|
274
|
+
when Aos::Os::CMDS[:AMG][:key]
|
|
275
|
+
# inst
|
|
276
|
+
passthrough = handle_amg(args)
|
|
277
|
+
when Aos::Os::CMDS[:CONFIG][:key]
|
|
278
|
+
# config
|
|
279
|
+
passthrough = handle_config(args)
|
|
280
|
+
when Aos::Os::CMDS[:LS][:key]
|
|
281
|
+
# ls
|
|
282
|
+
handle_ls(args)
|
|
283
|
+
when Aos::Os::CMDS[:LL][:key]
|
|
284
|
+
# ll
|
|
285
|
+
handle_ll(args)
|
|
286
|
+
when Aos::Os::CMDS[:PWD][:key]
|
|
287
|
+
# pwd
|
|
288
|
+
handle_pwd(args)
|
|
289
|
+
when Aos::Os::CMDS[:EXIT][:key]
|
|
290
|
+
# exit
|
|
291
|
+
passthrough = true
|
|
292
|
+
handle_exit(args)
|
|
293
|
+
when Aos::Os::CMDS[:HELP][:key]
|
|
294
|
+
# help
|
|
295
|
+
passthrough = handle_help(args)
|
|
296
|
+
when Aos::Os::CMDS[:CD][:key]
|
|
297
|
+
# cd
|
|
298
|
+
handle_cd(args)
|
|
299
|
+
end
|
|
300
|
+
end
|
|
160
301
|
end
|
|
161
302
|
|
|
162
|
-
|
|
163
|
-
|
|
303
|
+
# if system is going to run
|
|
304
|
+
# but redirect happens
|
|
305
|
+
# cancel system run
|
|
306
|
+
if passthrough && redirect_to_room(args[Aro::Mancy::O])
|
|
307
|
+
return false
|
|
308
|
+
end
|
|
309
|
+
|
|
310
|
+
return passthrough
|
|
164
311
|
end
|
|
165
312
|
|
|
166
313
|
def calc_ps1
|
|
167
|
-
you_pwd = Aos::Os::osify(you.pwd)
|
|
168
|
-
"#{Aos::Os::PS1}
|
|
314
|
+
you_pwd = Aos::Os::osify(@you.pwd)
|
|
315
|
+
"#{Aos::Os::PS1}"
|
|
169
316
|
end
|
|
170
317
|
|
|
171
|
-
def
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
318
|
+
def handle_aro_override(args)
|
|
319
|
+
if args[0].include?(:aro.to_s)
|
|
320
|
+
args = "#{args.join(" ")} #{:aos.to_s}".split(" ")
|
|
321
|
+
end
|
|
322
|
+
args
|
|
176
323
|
end
|
|
177
324
|
|
|
178
|
-
def
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
Aos::Os::CMDS.values.map{|v| v[:key]}.include?(arg.to_sym)
|
|
325
|
+
def handle_config(args)
|
|
326
|
+
Aro::Config.process_config_command(args)
|
|
327
|
+
return true
|
|
182
328
|
end
|
|
183
329
|
|
|
184
|
-
def
|
|
330
|
+
def redirect_to_room(arg)
|
|
185
331
|
# search for reserved room path
|
|
186
332
|
handled = false
|
|
187
333
|
room_path = Aro::Dom.room_path(arg)
|
|
188
334
|
if !room_path.empty?
|
|
189
335
|
handled = true
|
|
190
|
-
you.update(pwd: File.join(
|
|
336
|
+
@you.update(pwd: File.join(
|
|
191
337
|
File.dirname(Aro::Dom.ethergeist_path),
|
|
192
338
|
room_path
|
|
193
339
|
))
|
|
@@ -195,67 +341,54 @@ module Aos
|
|
|
195
341
|
handled
|
|
196
342
|
end
|
|
197
343
|
|
|
198
|
-
def
|
|
199
|
-
|
|
200
|
-
handled = false
|
|
201
|
-
if args[0].include?(:aro.to_s)
|
|
202
|
-
# passthrough aro cmd with aos appended
|
|
203
|
-
handled = true
|
|
204
|
-
system("#{args.join(" ")} #{:aos.to_s}")
|
|
205
|
-
end
|
|
206
|
-
handled
|
|
344
|
+
def handle_amg(args)
|
|
345
|
+
Aos::Amg.process_cmd(args)
|
|
207
346
|
end
|
|
208
347
|
|
|
209
|
-
def
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
you.update(pwd:
|
|
213
|
-
File.join(
|
|
214
|
-
File.dirname(Aro::Dom.ethergeist_path),
|
|
215
|
-
Aro::Dom::SETUP.to_s,
|
|
216
|
-
Aro::Dom::SETTINGS.to_s
|
|
217
|
-
)
|
|
218
|
-
)
|
|
219
|
-
else
|
|
220
|
-
CLI::Config.process_config_command(args)
|
|
221
|
-
end
|
|
348
|
+
def handle_help(args)
|
|
349
|
+
redirect_to_room(Aro::Dom::WAITE)
|
|
350
|
+
return false
|
|
222
351
|
end
|
|
223
352
|
|
|
224
353
|
def handle_ls(args)
|
|
225
|
-
|
|
354
|
+
self.display_lines = [
|
|
355
|
+
Dir.glob(File.join(@you.pwd, (args[1] || "") + Aos::Os::STAR.to_s), File::FNM_EXTGLOB).map{|p| "/" + Aos::Os::osify(p)}.join("\n")
|
|
356
|
+
]
|
|
226
357
|
end
|
|
227
358
|
|
|
228
359
|
def handle_ll(args)
|
|
229
|
-
|
|
360
|
+
self.display_lines = [
|
|
361
|
+
Dir.glob(File.join(@you.pwd, (args[1] || "") + Aos::Os::STAR.to_s), File::FNM_DOTMATCH).map{|p| Aos::Os::osify(p.strip, true)}.join("\n")
|
|
362
|
+
]
|
|
230
363
|
end
|
|
231
364
|
|
|
232
365
|
def handle_pwd(args)
|
|
233
|
-
osified = "/" + Aos::Os::osify(you.pwd)
|
|
234
|
-
|
|
366
|
+
osified = "/" + Aos::Os::osify(@you.pwd)
|
|
367
|
+
self.display_lines = [osified]
|
|
235
368
|
end
|
|
236
369
|
|
|
237
370
|
def handle_exit(args)
|
|
238
371
|
Aos::S.say("#{Aos::Os} is exiting...")
|
|
239
|
-
|
|
372
|
+
@running = false
|
|
240
373
|
end
|
|
241
374
|
|
|
242
375
|
def handle_cd(args)
|
|
243
376
|
if args[1].nil? || args[1] == "~/"
|
|
244
377
|
# no arg takes you to arodom root
|
|
245
|
-
you.update(pwd: File.dirname(Aro::Dom.ethergeist_path))
|
|
378
|
+
@you.update(pwd: File.dirname(Aro::Dom.ethergeist_path))
|
|
246
379
|
else
|
|
247
380
|
if args[1].include?(Aro::Dom::DOTT.to_s)
|
|
248
381
|
# going up
|
|
249
|
-
if File.dirname(Aro::Dom.ethergeist_path) == you.pwd
|
|
250
|
-
|
|
382
|
+
if File.dirname(Aro::Dom.ethergeist_path) == @you.pwd
|
|
383
|
+
self.display_lines = ["within #{Aos::Os}, one cannot leave the #{Aro::Dom}."]
|
|
251
384
|
else
|
|
252
385
|
# todo: support dots in paths
|
|
253
386
|
# this only supports moving one level up
|
|
254
387
|
|
|
255
|
-
pwd_arr = you.pwd.split("/")
|
|
388
|
+
pwd_arr = @you.pwd.split("/")
|
|
256
389
|
new_pwd = (pwd_arr.first(pwd_arr.length - 1)).join("/")
|
|
257
390
|
|
|
258
|
-
you.update(pwd: new_pwd)
|
|
391
|
+
@you.update(pwd: new_pwd)
|
|
259
392
|
end
|
|
260
393
|
else
|
|
261
394
|
# this particular block needs to be better
|
|
@@ -266,14 +399,14 @@ module Aos
|
|
|
266
399
|
args[1] = args[1][1..]
|
|
267
400
|
new_pwd = File.join(Aro::Dom.dom_root, args[1])
|
|
268
401
|
if Dir.exist?(new_pwd)
|
|
269
|
-
you.update(pwd: new_pwd)
|
|
402
|
+
@you.update(pwd: new_pwd)
|
|
270
403
|
end
|
|
271
404
|
elsif Dir.exist?(args[1]) && args[1] != Aro::Dom::DOT.to_s
|
|
272
|
-
new_pwd = File.join(you.pwd, args[1])
|
|
405
|
+
new_pwd = File.join(@you.pwd, args[1])
|
|
273
406
|
Aro::V.say("new_pwd: #{new_pwd}")
|
|
274
|
-
you.update(pwd: new_pwd)
|
|
407
|
+
@you.update(pwd: new_pwd)
|
|
275
408
|
else
|
|
276
|
-
|
|
409
|
+
self.display_lines = ["that directory is invalid."]
|
|
277
410
|
end
|
|
278
411
|
end
|
|
279
412
|
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
class CreateLibs < ActiveRecord::Migration[8.1]
|
|
2
|
+
|
|
3
|
+
def self.up
|
|
4
|
+
create_table :libs do |t|
|
|
5
|
+
t.string :name, null: false
|
|
6
|
+
t.string :so_path, null: false
|
|
7
|
+
t.integer :status, default: Aro::Mancy::O
|
|
8
|
+
|
|
9
|
+
t.timestamps
|
|
10
|
+
|
|
11
|
+
t.index :name, unique: true
|
|
12
|
+
t.index :so_path, unique: true
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def self.down
|
|
17
|
+
remove_index :libs, :name
|
|
18
|
+
remove_index :libs, :so_path
|
|
19
|
+
drop_table :libs
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
end
|
data/sys/aos/db.rb
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
db.rb
|
|
4
4
|
|
|
5
|
-
database for aos
|
|
5
|
+
database for aos.
|
|
6
6
|
|
|
7
7
|
by i2097i
|
|
8
8
|
|
|
@@ -10,13 +10,11 @@
|
|
|
10
10
|
|
|
11
11
|
module Aos
|
|
12
12
|
class Db < Aro::Db
|
|
13
|
-
|
|
14
|
-
SQL_FILE = :"
|
|
15
|
-
SCHEMA_FILE = :"schema.rb"
|
|
16
|
-
MIGRATIONS_DIR = :"db/migrate"
|
|
13
|
+
GEM_DB_PATH = :"sys/aos/db"
|
|
14
|
+
SQL_FILE = :"aos.sql"
|
|
17
15
|
|
|
18
16
|
def initialize
|
|
19
|
-
|
|
17
|
+
Aos::Db.configure_logger
|
|
20
18
|
if Aro::Dom.in_arodom?
|
|
21
19
|
set_up_aos
|
|
22
20
|
else
|
|
@@ -24,12 +22,21 @@ module Aos
|
|
|
24
22
|
end
|
|
25
23
|
end
|
|
26
24
|
|
|
25
|
+
def self.configure_logger
|
|
26
|
+
if Aro::Config.ivar(:LOG_AOS_DB).to_s == Aro::Config::BOOLS[:TRUE].to_s
|
|
27
|
+
ActiveRecord::Base.logger = Logger.new(STDOUT)
|
|
28
|
+
else
|
|
29
|
+
ActiveRecord::Base.logger = nil
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
27
33
|
def self.base_aro_dir
|
|
28
34
|
Aro::Dom.ethergeist_path
|
|
29
35
|
end
|
|
30
36
|
|
|
31
37
|
def db_config_filepath
|
|
32
|
-
|
|
38
|
+
# intentionally using Aro::Db::DATABASE_YML here
|
|
39
|
+
File.join(Aos::Db.base_aro_dir, Aro::Db::DATABASE_YML.to_s)
|
|
33
40
|
end
|
|
34
41
|
|
|
35
42
|
def set_up_aos
|
|
@@ -60,10 +67,10 @@ module Aos
|
|
|
60
67
|
end
|
|
61
68
|
|
|
62
69
|
def migrate(name)
|
|
63
|
-
local_migrate_dir = File.join(Aos::Db.base_aro_dir,
|
|
70
|
+
local_migrate_dir = File.join(Aos::Db.base_aro_dir, Aro::Db::MIGRATIONS_DIR.to_s)
|
|
64
71
|
unless Dir.exist?(local_migrate_dir)
|
|
65
72
|
gem_dir = Dir[Gem.loaded_specs[:aro.to_s]&.full_gem_path || '.'].first
|
|
66
|
-
FileUtils.cp_r(File.join(gem_dir,
|
|
73
|
+
FileUtils.cp_r(File.join(gem_dir, Aos::Db::GEM_DB_PATH.to_s), Aos::Db::base_aro_dir)
|
|
67
74
|
end
|
|
68
75
|
|
|
69
76
|
migration_version = Dir["#{local_migrate_dir}/*.rb"].map{|n|
|
|
@@ -71,7 +78,7 @@ module Aos
|
|
|
71
78
|
}.max
|
|
72
79
|
ActiveRecord::MigrationContext.new(local_migrate_dir).migrate(migration_version)
|
|
73
80
|
|
|
74
|
-
filename = File.join(Aos::Db.base_aro_dir,
|
|
81
|
+
filename = File.join(Aos::Db.base_aro_dir, Aro::Db::SCHEMA_FILE.to_s)
|
|
75
82
|
File.open(filename, "w+") do |f|
|
|
76
83
|
ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection_pool, f)
|
|
77
84
|
end
|