aro 0.2.1 → 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.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/bin/aro +3 -3
- data/checksums/aro-0.2.1.gem.sha512 +1 -0
- data/checksums/aro-0.2.2.gem.sha512 +1 -0
- data/locale/en.amg.yml +44 -0
- data/locale/en.aos.yml +4 -38
- data/locale/en.data.yml +30 -0
- data/locale/en.dom.yml +8 -6
- data/locale/en.usage.yml +20 -20
- data/locale/en.yml +16 -12
- data/sys/aos/amg.rb +58 -56
- data/sys/aos/aos.rb +82 -49
- 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.rb +37 -17
- data/sys/{shr/lib/lib.rb → aos/models/ilib.rb} +9 -6
- data/sys/aos/models/ilog.rb +27 -0
- data/sys/aos/models/you.rb +50 -0
- data/sys/aos/vws/base.rb +9 -58
- data/sys/aos/vws/dom.rb +0 -1
- data/sys/aos/vws/games/game.rb +10 -10
- 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 +1 -1
- data/sys/aos/vws/root/data.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 +11 -0
- 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 +11 -11
- data/sys/aro/mancy.rb +4 -4
- data/sys/{models/deck.rb → aro/models/teck.rb} +51 -52
- data/sys/aro/models/tlog.rb +20 -0
- data/sys/cli/constants.rb +1 -1
- data/sys/cli/dom.rb +1 -1
- data/sys/cli/{deck.rb → teck.rb} +15 -15
- data/sys/cli.rb +4 -3
- data/sys/dom/config.rb +196 -143
- data/sys/dom/d.rb +32 -19
- data/sys/dom/dom.rb +22 -13
- data/sys/reiquire.rb +6 -7
- data/sys/shr/prompt.rb +0 -4
- data/sys/shr/version.rb +1 -1
- metadata +28 -20
- data/locale/en.cngelog.yml +0 -5
- data/sys/aos/you.rb +0 -21
- data/sys/aro/db/migrate/1763432541_create_logs.rb +0 -20
- 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/aos.rb
CHANGED
|
@@ -29,7 +29,11 @@ module Aos
|
|
|
29
29
|
class Os
|
|
30
30
|
include Singleton
|
|
31
31
|
|
|
32
|
-
attr_accessor :
|
|
32
|
+
attr_accessor :display_lines,
|
|
33
|
+
:running,
|
|
34
|
+
:view,
|
|
35
|
+
:you,
|
|
36
|
+
:you_flag
|
|
33
37
|
|
|
34
38
|
A = :"@"
|
|
35
39
|
STAR = :"*"
|
|
@@ -53,13 +57,11 @@ module Aos
|
|
|
53
57
|
key: :config,
|
|
54
58
|
description: I18n.t("aos.commands.description.config"),
|
|
55
59
|
usage: I18n.t("aos.commands.usage.config"),
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
}
|
|
60
|
+
},
|
|
61
|
+
DATA: {
|
|
62
|
+
key: :data,
|
|
63
|
+
description: I18n.t("aos.commands.description.data"),
|
|
64
|
+
usage: I18n.t("aos.commands.usage.data"),
|
|
63
65
|
},
|
|
64
66
|
EXIT: {
|
|
65
67
|
key: :exit,
|
|
@@ -102,12 +104,11 @@ module Aos
|
|
|
102
104
|
|
|
103
105
|
def self.is_aos_command?(arg)
|
|
104
106
|
# determine if command is Aos::Os::CMDS
|
|
105
|
-
# passthrough to system if command is not in Aos::Os::CMDS
|
|
106
107
|
Aos::Os::CMDS.values.map{|v| v[:key]}.include?(arg.to_sym)
|
|
107
108
|
end
|
|
108
109
|
|
|
109
110
|
def self.you_flagd?
|
|
110
|
-
self.instance.
|
|
111
|
+
self.instance.you_flag
|
|
111
112
|
end
|
|
112
113
|
|
|
113
114
|
def self.sanitize_you(cmd)
|
|
@@ -123,20 +124,21 @@ module Aos
|
|
|
123
124
|
end
|
|
124
125
|
|
|
125
126
|
def initialize
|
|
127
|
+
self.you_flag = false
|
|
126
128
|
Aro::Config.instance.load
|
|
127
|
-
if Aro::Dom.in_arodom? && !Aro::Dom.is_initialized?
|
|
128
|
-
Aro::Dom.new.generate
|
|
129
|
-
end
|
|
130
|
-
|
|
131
|
-
|
|
129
|
+
# if Aro::Dom.in_arodom? && !Aro::Dom.is_initialized?
|
|
130
|
+
# Aro::Dom.new.generate unless Aro::Mancy.in_aro?
|
|
131
|
+
# end
|
|
132
|
+
Aos::Db.load
|
|
133
|
+
load_ilibs
|
|
132
134
|
load_you
|
|
133
135
|
end
|
|
134
136
|
|
|
135
|
-
def
|
|
136
|
-
# todo: load from directory of
|
|
137
|
+
def load_ilibs
|
|
138
|
+
# todo: load from directory of ilibs.
|
|
137
139
|
# something like:
|
|
138
140
|
#
|
|
139
|
-
# Dir[lib_something_something].each do{|l| Aos::
|
|
141
|
+
# Dir[lib_something_something].each do{|l| Aos::Ilib.install(l)}
|
|
140
142
|
|
|
141
143
|
# for now static
|
|
142
144
|
Aos::Amg.load(:crs)
|
|
@@ -145,22 +147,29 @@ module Aos
|
|
|
145
147
|
def load_you
|
|
146
148
|
return if @you.present?
|
|
147
149
|
|
|
148
|
-
you_name = Aos::Os::YOU
|
|
149
150
|
if ARGV.include?(Aos::Os::YOU_FLAG)
|
|
151
|
+
self.you_flag = true
|
|
150
152
|
you_name = ARGV[ARGV.index(Aos::Os::YOU_FLAG) + Aro::Mancy::S]
|
|
153
|
+
@you = Aos::You.find_by(name: you_name)
|
|
154
|
+
if @you.nil?
|
|
155
|
+
@you = Aos::You.create(name: you_name)
|
|
156
|
+
end
|
|
157
|
+
else
|
|
158
|
+
# todo: make more secure
|
|
159
|
+
@you = Aos::You.find_by(access: :root)
|
|
151
160
|
end
|
|
152
161
|
|
|
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
162
|
self.display_lines = [Aos::Os.osify(@you.pwd, true)]
|
|
157
163
|
end
|
|
158
164
|
|
|
159
165
|
def load_view
|
|
160
166
|
view_name = Aos::Os.osify(@you.pwd).split("/").last || :dom.to_s
|
|
161
167
|
view_cls = nil
|
|
168
|
+
|
|
169
|
+
cls_name = (Aos::Vw.name + "::#{view_name.capitalize}")
|
|
170
|
+
Aro::D.say("attempting to load view class #{cls_name}")
|
|
162
171
|
begin
|
|
163
|
-
view_cls =
|
|
172
|
+
view_cls = cls_name.constantize
|
|
164
173
|
rescue
|
|
165
174
|
view_cls = Aos::Vw::Base
|
|
166
175
|
end
|
|
@@ -190,12 +199,12 @@ module Aos
|
|
|
190
199
|
def process_cmd(cmd)
|
|
191
200
|
Dir.chdir(@you.reload.pwd) do
|
|
192
201
|
configure_readline
|
|
193
|
-
|
|
202
|
+
send_to_system_call = main(cmd)
|
|
194
203
|
if Aro::Config.is_format_text?
|
|
195
204
|
# IO.console.goto(Aro::Mancy::O, Aro::Mancy::O)
|
|
196
205
|
end
|
|
197
206
|
nothing = nil
|
|
198
|
-
if
|
|
207
|
+
if send_to_system_call
|
|
199
208
|
nothing = system(cmd)
|
|
200
209
|
Aos::S.say(nothing) if nothing.nil?
|
|
201
210
|
end
|
|
@@ -203,6 +212,10 @@ module Aos
|
|
|
203
212
|
if nothing.nil?
|
|
204
213
|
render
|
|
205
214
|
end
|
|
215
|
+
|
|
216
|
+
unless cmd.nil?
|
|
217
|
+
@you.generate_ilog(cmd)
|
|
218
|
+
end
|
|
206
219
|
end
|
|
207
220
|
|
|
208
221
|
CLI::EXIT_CODES[:SUCCESS]
|
|
@@ -263,51 +276,67 @@ module Aos
|
|
|
263
276
|
|
|
264
277
|
args = handle_aro_override(args)
|
|
265
278
|
|
|
266
|
-
|
|
279
|
+
# send to "system" call in process_cmd method
|
|
280
|
+
# if args[Aro::Mancy::O] is not in Aos::Os::CMDS
|
|
281
|
+
send_to_system_call = !Aos::Os.is_aos_command?(args[Aro::Mancy::O]) ||
|
|
267
282
|
args.include?(:aos.to_s)
|
|
268
283
|
|
|
269
284
|
# set aos pwd
|
|
270
|
-
unless
|
|
285
|
+
unless send_to_system_call
|
|
271
286
|
Dir.chdir(@you.pwd) do
|
|
272
287
|
# process commands
|
|
273
288
|
case args[Aro::Mancy::O].to_sym
|
|
274
289
|
when Aos::Os::CMDS[:AMG][:key]
|
|
275
|
-
#
|
|
276
|
-
|
|
290
|
+
# amg
|
|
291
|
+
send_to_system_call = handle_amg(args)
|
|
292
|
+
when Aos::Os::CMDS[:CD][:key]
|
|
293
|
+
# cd
|
|
294
|
+
handle_cd(args)
|
|
277
295
|
when Aos::Os::CMDS[:CONFIG][:key]
|
|
278
296
|
# config
|
|
279
|
-
|
|
280
|
-
when Aos::Os::CMDS[:
|
|
281
|
-
#
|
|
282
|
-
|
|
297
|
+
send_to_system_call = handle_config(args)
|
|
298
|
+
when Aos::Os::CMDS[:DATA][:key]
|
|
299
|
+
# data
|
|
300
|
+
send_to_system_call = handle_data(args)
|
|
301
|
+
when Aos::Os::CMDS[:EXIT][:key]
|
|
302
|
+
# exit
|
|
303
|
+
send_to_system_call = true
|
|
304
|
+
handle_exit(args)
|
|
305
|
+
when Aos::Os::CMDS[:HELP][:key]
|
|
306
|
+
# help
|
|
307
|
+
send_to_system_call = handle_help(args)
|
|
283
308
|
when Aos::Os::CMDS[:LL][:key]
|
|
284
309
|
# ll
|
|
285
310
|
handle_ll(args)
|
|
311
|
+
when Aos::Os::CMDS[:LS][:key]
|
|
312
|
+
# ls
|
|
313
|
+
handle_ls(args)
|
|
286
314
|
when Aos::Os::CMDS[:PWD][:key]
|
|
287
315
|
# pwd
|
|
288
316
|
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
317
|
end
|
|
300
318
|
end
|
|
301
319
|
end
|
|
302
320
|
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
321
|
+
if send_to_system_call
|
|
322
|
+
# process ilib commands
|
|
323
|
+
ilib = Aos::Ilib.find_by(
|
|
324
|
+
name: args[Aro::Mancy::O],
|
|
325
|
+
status: :installed
|
|
326
|
+
)
|
|
327
|
+
unless ilib.nil?
|
|
328
|
+
self.display_lines = [ilib.usage]
|
|
329
|
+
send_to_system_call = false
|
|
330
|
+
end
|
|
331
|
+
|
|
332
|
+
# if system is going to run, but redirect happens,
|
|
333
|
+
# cancel system run.
|
|
334
|
+
if redirect_to_room(args[Aro::Mancy::O])
|
|
335
|
+
send_to_system_call = false
|
|
336
|
+
end
|
|
308
337
|
end
|
|
309
338
|
|
|
310
|
-
return
|
|
339
|
+
return send_to_system_call
|
|
311
340
|
end
|
|
312
341
|
|
|
313
342
|
def calc_ps1
|
|
@@ -345,6 +374,10 @@ module Aos
|
|
|
345
374
|
Aos::Amg.process_cmd(args)
|
|
346
375
|
end
|
|
347
376
|
|
|
377
|
+
def handle_data(args)
|
|
378
|
+
Aos::Data.process_cmd(args)
|
|
379
|
+
end
|
|
380
|
+
|
|
348
381
|
def handle_help(args)
|
|
349
382
|
redirect_to_room(Aro::Dom::WAITE)
|
|
350
383
|
return false
|
data/sys/aos/data.rb
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
|
|
3
|
+
data.rb
|
|
4
|
+
|
|
5
|
+
aos data management.
|
|
6
|
+
|
|
7
|
+
by i2097i
|
|
8
|
+
|
|
9
|
+
=end
|
|
10
|
+
|
|
11
|
+
module Aos
|
|
12
|
+
class Data
|
|
13
|
+
include Singleton
|
|
14
|
+
|
|
15
|
+
attr_accessor :display_lines
|
|
16
|
+
|
|
17
|
+
CMDS = {
|
|
18
|
+
ILOGS: {
|
|
19
|
+
key: :ilogs,
|
|
20
|
+
description: I18n.t("data.commands.description.ilogs"),
|
|
21
|
+
usage: I18n.t("data.commands.usage.ilogs"),
|
|
22
|
+
},
|
|
23
|
+
YOUS: {
|
|
24
|
+
key: :yous,
|
|
25
|
+
description: I18n.t("data.commands.description.yous"),
|
|
26
|
+
usage: I18n.t("data.commands.usage.yous"),
|
|
27
|
+
},
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
def initialize
|
|
31
|
+
self.display_lines = Aos::Data.base_lines
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def self.process_cmd(args)
|
|
35
|
+
self.instance.display_lines = []
|
|
36
|
+
if args[Aro::Mancy::S].nil? ||
|
|
37
|
+
CLI::FLAGS[:HELP].include?(args[Aro::Mancy::S].to_sym)
|
|
38
|
+
Aos::Data.data
|
|
39
|
+
return true
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
case args[Aro::Mancy::S].to_sym
|
|
43
|
+
when Aos::Data::CMDS[:ILOGS][:key]
|
|
44
|
+
Aos::Data.ilogs
|
|
45
|
+
return true
|
|
46
|
+
when Aos::Data::CMDS[:YOUS][:key]
|
|
47
|
+
Aos::Data.yous
|
|
48
|
+
return true
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
return false
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def self.ilogs
|
|
55
|
+
self.instance.display_lines = Aos::Data.ilog_lines
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def self.yous
|
|
59
|
+
self.instance.display_lines = Aos::Data.you_lines
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def self.data
|
|
63
|
+
self.instance.display_lines = Aos::Data.base_lines
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def self.base_lines
|
|
67
|
+
# print data commands
|
|
68
|
+
lines = []
|
|
69
|
+
lines << ""
|
|
70
|
+
lines << I18n.t("aos.constants.commands")
|
|
71
|
+
lines += Aos::Vw::Base.lines_for_cmd(Aos::Os::CMDS[:DATA])
|
|
72
|
+
lines << I18n.t("aos.constants.subcommands")
|
|
73
|
+
Aos::Data::CMDS.keys.each{|k|
|
|
74
|
+
lines += Aos::Vw::Base.lines_for_cmd(Aos::Data::CMDS[k])
|
|
75
|
+
}
|
|
76
|
+
lines << ""
|
|
77
|
+
|
|
78
|
+
lines
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def self.ilog_lines
|
|
82
|
+
# list input ilogs
|
|
83
|
+
lines = []
|
|
84
|
+
lines << ""
|
|
85
|
+
iilogs = Aos::Ilog.all
|
|
86
|
+
unless iilogs.any?
|
|
87
|
+
lines << I18n.t("data.messages.no_ilogs")
|
|
88
|
+
else
|
|
89
|
+
lines << I18n.t("data.messages.listing_ilogs")
|
|
90
|
+
iilogs.each{|il|
|
|
91
|
+
lines += il.get_lines
|
|
92
|
+
}
|
|
93
|
+
end
|
|
94
|
+
lines << ""
|
|
95
|
+
|
|
96
|
+
lines
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
def self.you_lines
|
|
100
|
+
# list yous
|
|
101
|
+
lines = []
|
|
102
|
+
lines << ""
|
|
103
|
+
yous = Aos::You.all
|
|
104
|
+
unless yous.any?
|
|
105
|
+
lines << I18n.t("data.messages.no_yous")
|
|
106
|
+
else
|
|
107
|
+
lines << I18n.t("data.messages.listing_yous")
|
|
108
|
+
yous.each{|y|
|
|
109
|
+
lines += y.get_lines
|
|
110
|
+
}
|
|
111
|
+
end
|
|
112
|
+
lines << ""
|
|
113
|
+
|
|
114
|
+
lines
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
end
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
class
|
|
1
|
+
class CreateIlibs < ActiveRecord::Migration[8.1]
|
|
2
2
|
|
|
3
3
|
def self.up
|
|
4
|
-
create_table :
|
|
4
|
+
create_table :ilibs do |t|
|
|
5
5
|
t.string :name, null: false
|
|
6
6
|
t.string :so_path, null: false
|
|
7
7
|
t.integer :status, default: Aro::Mancy::O
|
|
@@ -14,9 +14,9 @@ class CreateLibs < ActiveRecord::Migration[8.1]
|
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
def self.down
|
|
17
|
-
remove_index :
|
|
18
|
-
remove_index :
|
|
19
|
-
drop_table :
|
|
17
|
+
remove_index :ilibs, :name
|
|
18
|
+
remove_index :ilibs, :so_path
|
|
19
|
+
drop_table :ilibs
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
class CreateIlogs < ActiveRecord::Migration[8.1]
|
|
2
|
+
|
|
3
|
+
def self.up
|
|
4
|
+
create_table :ilogs do |t|
|
|
5
|
+
t.belongs_to :you, null: false, foreign_key: true
|
|
6
|
+
t.string :cmd, null: false
|
|
7
|
+
t.string :pwd, null: false
|
|
8
|
+
|
|
9
|
+
t.timestamps
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def self.down
|
|
14
|
+
remove_index :ilogs, :pwd
|
|
15
|
+
drop_table :ilogs
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
end
|
data/sys/aos/db.rb
CHANGED
|
@@ -9,14 +9,19 @@
|
|
|
9
9
|
=end
|
|
10
10
|
|
|
11
11
|
module Aos
|
|
12
|
-
class Db
|
|
12
|
+
class Db
|
|
13
|
+
include Singleton
|
|
14
|
+
|
|
15
|
+
DATABASE_YML = :"database.yml"
|
|
13
16
|
GEM_DB_PATH = :"sys/aos/db"
|
|
17
|
+
MIGRATIONS_DIR = :"db/migrate"
|
|
18
|
+
SCHEMA_FILE = :"schema.rb"
|
|
14
19
|
SQL_FILE = :"aos.sql"
|
|
15
20
|
|
|
16
|
-
def
|
|
21
|
+
def self.load(password = nil)
|
|
17
22
|
Aos::Db.configure_logger
|
|
18
23
|
if Aro::Dom.in_arodom?
|
|
19
|
-
set_up_aos
|
|
24
|
+
self.instance.set_up_aos(password)
|
|
20
25
|
else
|
|
21
26
|
Aro::P.say(I18n.t("cli.errors.not_in_aro" , cmd: Aro::Dom.name))
|
|
22
27
|
end
|
|
@@ -31,7 +36,8 @@ module Aos
|
|
|
31
36
|
end
|
|
32
37
|
|
|
33
38
|
def self.base_aro_dir
|
|
34
|
-
Aro::Dom.ethergeist_path
|
|
39
|
+
# Aro::Dom.ethergeist_path
|
|
40
|
+
File.join(Aro::Dom.dom_root, Aro::Dom.room_path(:data))
|
|
35
41
|
end
|
|
36
42
|
|
|
37
43
|
def db_config_filepath
|
|
@@ -39,7 +45,7 @@ module Aos
|
|
|
39
45
|
File.join(Aos::Db.base_aro_dir, Aro::Db::DATABASE_YML.to_s)
|
|
40
46
|
end
|
|
41
47
|
|
|
42
|
-
def set_up_aos
|
|
48
|
+
def set_up_aos(password)
|
|
43
49
|
name = Aro::Dom.ethergeist_name
|
|
44
50
|
return if name.nil?
|
|
45
51
|
|
|
@@ -49,21 +55,35 @@ module Aos
|
|
|
49
55
|
end
|
|
50
56
|
|
|
51
57
|
unless File.exist?(db_config_filepath)
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
58
|
+
unless password.nil?
|
|
59
|
+
Aro::D.say("creating database: #{db_config_filepath}")
|
|
60
|
+
# create database config yaml file
|
|
61
|
+
db_file_path = File.join(Aos::Db.base_aro_dir, Aos::Db::SQL_FILE.to_s)
|
|
62
|
+
File.open(db_config_filepath, "w") do |file|
|
|
63
|
+
file.write({
|
|
64
|
+
adapter: :sqlite3.to_s,
|
|
65
|
+
database: db_file_path,
|
|
66
|
+
username: name,
|
|
67
|
+
password: password,
|
|
68
|
+
}.to_yaml)
|
|
69
|
+
end
|
|
70
|
+
else
|
|
71
|
+
Aro::D.say("unable to create database without root password.")
|
|
62
72
|
end
|
|
63
73
|
end
|
|
64
74
|
|
|
65
|
-
|
|
66
|
-
|
|
75
|
+
if File.exist?(db_config_filepath)
|
|
76
|
+
connect(name)
|
|
77
|
+
migrate(name)
|
|
78
|
+
else
|
|
79
|
+
Aro::D.say("unable to set up database without root password.")
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def connect(name)
|
|
84
|
+
ActiveRecord::Base.establish_connection(
|
|
85
|
+
YAML.load_file(db_config_filepath)
|
|
86
|
+
)
|
|
67
87
|
end
|
|
68
88
|
|
|
69
89
|
def migrate(name)
|
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
=begin
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
ilib.rb
|
|
4
4
|
|
|
5
|
-
aos
|
|
5
|
+
aos ilib object.
|
|
6
6
|
|
|
7
7
|
by i2097i
|
|
8
8
|
|
|
9
9
|
=end
|
|
10
10
|
|
|
11
|
-
# todo: put in separate file and require it
|
|
12
11
|
# installed lib modules section
|
|
13
12
|
|
|
14
13
|
module CRS
|
|
15
14
|
SO_FILE = :"libcrs.so".to_s
|
|
16
|
-
SO_PATH = File.join(
|
|
15
|
+
SO_PATH = File.join(
|
|
16
|
+
Reiquire::GEM_PATH,
|
|
17
|
+
:"sys/shr/ilib/crs".to_s,
|
|
18
|
+
CRS::SO_FILE
|
|
19
|
+
)
|
|
17
20
|
extend FFI::Library
|
|
18
21
|
ffi_lib CRS::SO_PATH
|
|
19
22
|
attach_function :hello, [], :string
|
|
@@ -21,7 +24,7 @@ end
|
|
|
21
24
|
|
|
22
25
|
# installed lib modules section
|
|
23
26
|
|
|
24
|
-
class Aos::
|
|
27
|
+
class Aos::Ilib < ActiveRecord::Base
|
|
25
28
|
before_create :set_so_path
|
|
26
29
|
|
|
27
30
|
enum :status, [
|
|
@@ -37,7 +40,7 @@ class Aos::Lib < ActiveRecord::Base
|
|
|
37
40
|
private
|
|
38
41
|
|
|
39
42
|
def set_so_path
|
|
40
|
-
# todo make configurable
|
|
43
|
+
# todo make configurable for other modules
|
|
41
44
|
self.so_path = CRS::SO_PATH
|
|
42
45
|
end
|
|
43
46
|
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
|
|
3
|
+
ilog.rb
|
|
4
|
+
|
|
5
|
+
aos ilog object.
|
|
6
|
+
|
|
7
|
+
by i2097i
|
|
8
|
+
|
|
9
|
+
=end
|
|
10
|
+
|
|
11
|
+
module Aos
|
|
12
|
+
class Ilog < ActiveRecord::Base
|
|
13
|
+
belongs_to :you
|
|
14
|
+
|
|
15
|
+
def get_lines
|
|
16
|
+
[
|
|
17
|
+
I18n.t(
|
|
18
|
+
"data.ilogs.display",
|
|
19
|
+
you: self.you.name,
|
|
20
|
+
cmd: self.cmd,
|
|
21
|
+
timestamp: self.created_at.strftime(Aos::Os::DATE_FORMAT),
|
|
22
|
+
pwd: Aos::Os.osify(self.pwd)
|
|
23
|
+
)
|
|
24
|
+
]
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
|
|
3
|
+
you.rb
|
|
4
|
+
|
|
5
|
+
aos you object.
|
|
6
|
+
|
|
7
|
+
by i2097i
|
|
8
|
+
|
|
9
|
+
=end
|
|
10
|
+
|
|
11
|
+
module Aos
|
|
12
|
+
class You < ActiveRecord::Base
|
|
13
|
+
has_many :ilogs
|
|
14
|
+
before_validation :set_pwd
|
|
15
|
+
after_update :clear_aos_display
|
|
16
|
+
|
|
17
|
+
enum :access, [
|
|
18
|
+
:user,
|
|
19
|
+
:root,
|
|
20
|
+
]
|
|
21
|
+
|
|
22
|
+
def generate_ilog(cmd)
|
|
23
|
+
ilogs.create(
|
|
24
|
+
pwd: Aos::Os.osify(pwd),
|
|
25
|
+
cmd: cmd
|
|
26
|
+
)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def get_lines
|
|
30
|
+
[
|
|
31
|
+
I18n.t(
|
|
32
|
+
"data.yous.display",
|
|
33
|
+
name: name,
|
|
34
|
+
access: Aos::You::accesses[access],
|
|
35
|
+
pwd: Aos::Os.osify(pwd)
|
|
36
|
+
)
|
|
37
|
+
]
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
private
|
|
41
|
+
|
|
42
|
+
def set_pwd
|
|
43
|
+
self.pwd = Dir.pwd if self.pwd.nil?
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def clear_aos_display
|
|
47
|
+
Aos::Os.instance.display_lines = [Aos::Os.osify(pwd, true)]
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|