aro 0.2.2 → 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/aro.gemspec +3 -3
- data/bin/aos +10 -3
- data/bin/aro +18 -11
- data/checksums/aro-0.2.3.gem.sha512 +1 -0
- data/locale/en.abot.yml +81 -0
- data/locale/en.aos.yml +6 -2
- data/locale/en.cor.yml +47 -0
- data/locale/en.data.yml +2 -2
- data/locale/en.dom.yml +15 -13
- data/locale/en.flie.yml +29 -0
- data/locale/en.usage.yml +24 -11
- data/locale/en.yml +2 -47
- data/sys/aos/abot.rb +256 -0
- data/sys/aos/aos.rb +373 -161
- data/sys/aos/cor.rb +773 -0
- data/sys/aos/data.rb +3 -3
- data/sys/aos/db/migrate/1765148774_create_yous.rb +1 -1
- 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 +16 -16
- 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/aos/models/ilib.rb +2 -0
- data/sys/aos/models/ilog.rb +5 -3
- data/sys/aos/models/you.rb +52 -4
- data/sys/aos/s.rb +2 -1
- data/sys/aos/vws/base.rb +62 -22
- data/sys/aos/vws/dom.rb +1 -1
- data/sys/aos/vws/games/abot.rb +21 -0
- data/sys/aos/vws/games/{game.rb → teck.rb} +19 -16
- data/sys/aos/vws/home.rb +23 -0
- data/sys/aos/vws/root/config.rb +4 -4
- data/sys/aos/vws/root/flie.rb +21 -0
- data/sys/aos/vws/welcome.rb +40 -4
- data/sys/aro/d.rb +4 -2
- data/sys/aro/db.rb +19 -10
- data/sys/aro/mancy.rb +16 -20
- data/sys/aro/models/base_model.rb +13 -0
- data/sys/aro/models/teck.rb +16 -12
- data/sys/aro/models/tlog.rb +2 -1
- 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/teck.rb +26 -33
- data/sys/cli.rb +7 -9
- data/sys/dom/d.rb +38 -29
- data/sys/dom/dom.rb +62 -36
- data/sys/dom/p.rb +1 -1
- data/sys/fpx.rb +116 -0
- data/sys/reiquire.rb +3 -2
- data/sys/shr/prompt.rb +2 -2
- data/sys/shr/t.rb +11 -13
- data/sys/shr/version.rb +1 -1
- data/tasks/make.rake +1 -1
- metadata +55 -43
- 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/dom/config.rb +0 -718
data/sys/aos/data.rb
CHANGED
|
@@ -82,12 +82,12 @@ module Aos
|
|
|
82
82
|
# list input ilogs
|
|
83
83
|
lines = []
|
|
84
84
|
lines << ""
|
|
85
|
-
|
|
86
|
-
unless
|
|
85
|
+
ilogs = Aos::Ilog.all
|
|
86
|
+
unless ilogs.any?
|
|
87
87
|
lines << I18n.t("data.messages.no_ilogs")
|
|
88
88
|
else
|
|
89
89
|
lines << I18n.t("data.messages.listing_ilogs")
|
|
90
|
-
|
|
90
|
+
ilogs.each{|il|
|
|
91
91
|
lines += il.get_lines
|
|
92
92
|
}
|
|
93
93
|
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
class CreateAgodos < ActiveRecord::Migration[8.1]
|
|
2
|
+
|
|
3
|
+
def self.up
|
|
4
|
+
create_table :agodos do |t|
|
|
5
|
+
t.integer :power, default: Aro::Mancy::O
|
|
6
|
+
t.belongs_to :you, null: false, foreign_key: true
|
|
7
|
+
t.string :home
|
|
8
|
+
t.string :go, null: false
|
|
9
|
+
t.string :do, null: false, default: ""
|
|
10
|
+
|
|
11
|
+
# rate is commands-per-minute (default 1)
|
|
12
|
+
t.integer :rate, default: Aro::Mancy::S
|
|
13
|
+
|
|
14
|
+
t.timestamps
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def self.down
|
|
19
|
+
drop_table :agodos
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
class CreateFpxies < ActiveRecord::Migration[8.1]
|
|
2
|
+
|
|
3
|
+
def self.up
|
|
4
|
+
create_table :fpxies do |t|
|
|
5
|
+
t.belongs_to :you, null: false, foreign_key: true
|
|
6
|
+
t.string :cmd, null: false
|
|
7
|
+
|
|
8
|
+
t.timestamps
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
add_index :fpxies, [:you_id, :cmd], unique: true
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def self.down
|
|
15
|
+
drop_table :fpxies
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
end
|
data/sys/aos/db.rb
CHANGED
|
@@ -20,15 +20,17 @@ module Aos
|
|
|
20
20
|
|
|
21
21
|
def self.load(password = nil)
|
|
22
22
|
Aos::Db.configure_logger
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
Mutex.new.synchronize do
|
|
24
|
+
if Aro::Dom.in_arodom?
|
|
25
|
+
self.instance.set_up_aos(password)
|
|
26
|
+
else
|
|
27
|
+
Aro::P.say(I18n.t("cli.errors.not_in_aro" , cmd: Aro::Dom.name))
|
|
28
|
+
end
|
|
27
29
|
end
|
|
28
30
|
end
|
|
29
31
|
|
|
30
32
|
def self.configure_logger
|
|
31
|
-
if
|
|
33
|
+
if Aos::Cor.ivar(:LOG_AOS_DB).to_s == Aos::Cor::BOOLS[:TRUE].to_s
|
|
32
34
|
ActiveRecord::Base.logger = Logger.new(STDOUT)
|
|
33
35
|
else
|
|
34
36
|
ActiveRecord::Base.logger = nil
|
|
@@ -36,19 +38,16 @@ module Aos
|
|
|
36
38
|
end
|
|
37
39
|
|
|
38
40
|
def self.base_aro_dir
|
|
39
|
-
# Aro::Dom.ethergeist_path
|
|
40
41
|
File.join(Aro::Dom.dom_root, Aro::Dom.room_path(:data))
|
|
41
42
|
end
|
|
42
43
|
|
|
43
44
|
def db_config_filepath
|
|
44
45
|
# intentionally using Aro::Db::DATABASE_YML here
|
|
45
|
-
File.join(Aos::Db.base_aro_dir, Aro::Db::DATABASE_YML.to_s)
|
|
46
|
+
@db_config_filepath = File.join(Aos::Db.base_aro_dir, Aro::Db::DATABASE_YML.to_s)
|
|
46
47
|
end
|
|
47
48
|
|
|
48
49
|
def set_up_aos(password)
|
|
49
|
-
|
|
50
|
-
return if name.nil?
|
|
51
|
-
|
|
50
|
+
ActiveRecord::Base.connection_pool.flush! unless password.nil?
|
|
52
51
|
# create local /.ethergeist directory
|
|
53
52
|
unless File.exist?(Aos::Db.base_aro_dir)
|
|
54
53
|
FileUtils.mkdir(Aos::Db.base_aro_dir)
|
|
@@ -63,8 +62,9 @@ module Aos
|
|
|
63
62
|
file.write({
|
|
64
63
|
adapter: :sqlite3.to_s,
|
|
65
64
|
database: db_file_path,
|
|
66
|
-
username:
|
|
65
|
+
username: Aro::Dom.ethergeist_name,
|
|
67
66
|
password: password,
|
|
67
|
+
pool: Aos::Os::DB_POOL
|
|
68
68
|
}.to_yaml)
|
|
69
69
|
end
|
|
70
70
|
else
|
|
@@ -73,23 +73,23 @@ module Aos
|
|
|
73
73
|
end
|
|
74
74
|
|
|
75
75
|
if File.exist?(db_config_filepath)
|
|
76
|
-
connect
|
|
77
|
-
migrate
|
|
76
|
+
connect
|
|
77
|
+
migrate
|
|
78
78
|
else
|
|
79
79
|
Aro::D.say("unable to set up database without root password.")
|
|
80
80
|
end
|
|
81
81
|
end
|
|
82
82
|
|
|
83
|
-
def connect
|
|
83
|
+
def connect
|
|
84
84
|
ActiveRecord::Base.establish_connection(
|
|
85
85
|
YAML.load_file(db_config_filepath)
|
|
86
86
|
)
|
|
87
87
|
end
|
|
88
88
|
|
|
89
|
-
def migrate
|
|
89
|
+
def migrate
|
|
90
90
|
local_migrate_dir = File.join(Aos::Db.base_aro_dir, Aro::Db::MIGRATIONS_DIR.to_s)
|
|
91
91
|
unless Dir.exist?(local_migrate_dir)
|
|
92
|
-
gem_dir = Dir[
|
|
92
|
+
gem_dir = Dir[Reiquire::GEM_PATH || '.'].first
|
|
93
93
|
FileUtils.cp_r(File.join(gem_dir, Aos::Db::GEM_DB_PATH.to_s), Aos::Db::base_aro_dir)
|
|
94
94
|
end
|
|
95
95
|
|
data/sys/aos/flie.rb
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
|
|
3
|
+
flie.rb
|
|
4
|
+
|
|
5
|
+
aos flie management.
|
|
6
|
+
|
|
7
|
+
by i2097i
|
|
8
|
+
|
|
9
|
+
=end
|
|
10
|
+
|
|
11
|
+
module Aos
|
|
12
|
+
class Flie
|
|
13
|
+
include Singleton
|
|
14
|
+
|
|
15
|
+
attr_accessor :display_lines, :pxy_running
|
|
16
|
+
|
|
17
|
+
CMDS = {
|
|
18
|
+
PXY: {
|
|
19
|
+
key: :pxy,
|
|
20
|
+
description: I18n.t("flie.commands.description.pxy"),
|
|
21
|
+
usage: I18n.t("flie.commands.usage.pxy"),
|
|
22
|
+
},
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
def initialize
|
|
26
|
+
self.pxy_running = false
|
|
27
|
+
self.display_lines = Aos::Flie.base_lines
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
PXY_CMDS = {
|
|
31
|
+
CREATE: :create,
|
|
32
|
+
LIST: :list,
|
|
33
|
+
DEREZ: :derez,
|
|
34
|
+
HELP: :help,
|
|
35
|
+
EXIT: :exit,
|
|
36
|
+
}
|
|
37
|
+
def self.pxy
|
|
38
|
+
Aos::Os.say(I18n.t("flie.messages.enter_email"))
|
|
39
|
+
Aos::Os.say("\n")
|
|
40
|
+
em = Aos::S.p.ask("#{Aos::Os::PS1}")
|
|
41
|
+
if you = Aos::You.find_by(name: em)
|
|
42
|
+
Aos::Os.instance.display_lines = []
|
|
43
|
+
self.instance.pxy_running = true
|
|
44
|
+
self.instance.display_lines = [I18n.t("flie.messages.pxy_starting")]
|
|
45
|
+
while self.instance.pxy_running
|
|
46
|
+
answer = Aos::S.p.select(
|
|
47
|
+
Aos::Os::PS1.to_s + I18n.t("flie.messages.main_menu", name: you.name),
|
|
48
|
+
Aos::Flie::PXY_CMDS,
|
|
49
|
+
default: Aro::Mancy::S
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
case answer.to_sym
|
|
53
|
+
when Aos::Flie::PXY_CMDS[:CREATE]
|
|
54
|
+
Aos::Os.say(I18n.t("flie.messages.enter_cmd"))
|
|
55
|
+
Aos::Os.say("\n")
|
|
56
|
+
cmd = Aos::S.p.ask("#{Aos::Os::PS1}")
|
|
57
|
+
you.fpxies.create(cmd: cmd)
|
|
58
|
+
self.instance.display_lines = you.fpxies.map{|f| f.get_lines.join("\n")}
|
|
59
|
+
when Aos::Flie::PXY_CMDS[:LIST]
|
|
60
|
+
if you.fpxies.any?
|
|
61
|
+
self.instance.display_lines = you.fpxies.map{|f| f.get_lines.join("\n")}
|
|
62
|
+
else
|
|
63
|
+
self.instance.display_lines = [I18n.t("flie.messages.no_fpxies")]
|
|
64
|
+
end
|
|
65
|
+
when Aos::Flie::PXY_CMDS[:DEREZ]
|
|
66
|
+
unless you.fpxies.any?
|
|
67
|
+
self.instance.display_lines = [I18n.t("flie.messages.no_fpxies")]
|
|
68
|
+
else
|
|
69
|
+
derez_answer = Aos::S.p.select(
|
|
70
|
+
Aos::Os::PS1.to_s + I18n.t("flie.messages.derez_menu"),
|
|
71
|
+
([[:cancel, Aro::Mancy::O]] + you.fpxies.map{|f| [f.cmd, f.id]}).to_h,
|
|
72
|
+
default: Aro::Mancy::S
|
|
73
|
+
)
|
|
74
|
+
unless derez_answer == Aro::Mancy::O
|
|
75
|
+
you.fpxies.find_by(id: derez_answer)&.destroy
|
|
76
|
+
you.reload
|
|
77
|
+
self.instance.display_lines = [I18n.t("flie.messages.fpxy_derez_success")]
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
when Aos::Flie::PXY_CMDS[:HELP]
|
|
81
|
+
Aos::Flie.flie
|
|
82
|
+
when Aos::Flie::PXY_CMDS[:EXIT]
|
|
83
|
+
self.instance.pxy_running = false
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
Aos::Os.instance.render
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
# exit display
|
|
90
|
+
Aos::Flie.flie
|
|
91
|
+
self.instance.display_lines += [I18n.t("flie.messages.pxy_exited")]
|
|
92
|
+
else
|
|
93
|
+
self.instance.display_lines += [I18n.t("flie.messages.invalid_email")]
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def self.pxies(email_address)
|
|
99
|
+
self.instance.get_pxies_for_email_address(email_address)
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def get_pxies_for_email_address(email_address)
|
|
103
|
+
you = Aos::You.find_by(name: email_address)
|
|
104
|
+
return you.fpxies.to_a unless you.nil?
|
|
105
|
+
return []
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
def self.flie
|
|
109
|
+
self.instance.display_lines = Aos::Flie.base_lines
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
def self.process_cmd(args)
|
|
113
|
+
self.instance.display_lines = []
|
|
114
|
+
if args[Aro::Mancy::S].nil? ||
|
|
115
|
+
CLI::FLAGS[:HELP].include?(args[Aro::Mancy::S].to_sym)
|
|
116
|
+
Aos::Flie.flie
|
|
117
|
+
return true
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
case args[Aro::Mancy::S].to_sym
|
|
121
|
+
when Aos::Flie::CMDS[:PXY][:key]
|
|
122
|
+
Aos::Flie.pxy
|
|
123
|
+
return true
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
return false
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
def self.base_lines
|
|
130
|
+
# print flie commands
|
|
131
|
+
lines = []
|
|
132
|
+
lines << ""
|
|
133
|
+
lines << I18n.t("aos.constants.commands")
|
|
134
|
+
lines += Aos::Vw::Base.lines_for_cmd(Aos::Os::CMDS[:FLIE])
|
|
135
|
+
lines << I18n.t("aos.constants.subcommands")
|
|
136
|
+
Aos::Flie::CMDS.keys.each{|k|
|
|
137
|
+
lines += Aos::Vw::Base.lines_for_cmd(Aos::Flie::CMDS[k])
|
|
138
|
+
}
|
|
139
|
+
lines << ""
|
|
140
|
+
|
|
141
|
+
lines
|
|
142
|
+
end
|
|
143
|
+
end
|
|
144
|
+
end
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
|
|
3
|
+
agodo.rb
|
|
4
|
+
|
|
5
|
+
agodo object.
|
|
6
|
+
|
|
7
|
+
by i2097i
|
|
8
|
+
|
|
9
|
+
=end
|
|
10
|
+
|
|
11
|
+
require :base64.to_s
|
|
12
|
+
require_relative :"./base_model".to_s
|
|
13
|
+
|
|
14
|
+
class Aos::Agodo < ActiveRecord::Base
|
|
15
|
+
belongs_to :you
|
|
16
|
+
validate :run_validations
|
|
17
|
+
|
|
18
|
+
enum :power, [
|
|
19
|
+
:off,
|
|
20
|
+
:on
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
def godo
|
|
24
|
+
godos_per_minute = Aro::Mancy::NUMERALS[:LX].to_f / rate.to_f
|
|
25
|
+
|
|
26
|
+
if Time.now - updated_at >= godos_per_minute
|
|
27
|
+
system("#{:aos} #{self.go} #{Aos::Os::YOU_FLAG} #{self.you.name}")
|
|
28
|
+
system("#{:aos} #{self.do.gsub("_", " ")} #{Aos::Os::YOU_FLAG} #{self.you.name}")
|
|
29
|
+
system("#{:aos} #{self.home.nil? ? "cd" : self.home} #{Aos::Os::YOU_FLAG} #{self.you.name}")
|
|
30
|
+
reload.touch
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def get_lines
|
|
35
|
+
[
|
|
36
|
+
I18n.t(
|
|
37
|
+
"abot.agodo.display",
|
|
38
|
+
power: Aos::Agodo::powers[self.power],
|
|
39
|
+
go: self.go,
|
|
40
|
+
do: self.do,
|
|
41
|
+
rate: self.rate,
|
|
42
|
+
home: self.home.nil? ? "/" : Aos::Os.osify(self.home)
|
|
43
|
+
)
|
|
44
|
+
]
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
private
|
|
48
|
+
|
|
49
|
+
def create_you
|
|
50
|
+
# todo: deal with potential name clashes
|
|
51
|
+
self.you = Aos::You.create(
|
|
52
|
+
access: :agodo,
|
|
53
|
+
pwd: Aos::Os.instance.you.pwd,
|
|
54
|
+
name: [
|
|
55
|
+
Aro::T.read_dev_tarot(false),
|
|
56
|
+
Aro::T.summon_ruby_facot(false),
|
|
57
|
+
rand(99..999)
|
|
58
|
+
].join("_").strip
|
|
59
|
+
)
|
|
60
|
+
self.home = self.you.pwd.split("/").last
|
|
61
|
+
if self.home == Aro::Dom.ethergeist_name
|
|
62
|
+
self.home = nil
|
|
63
|
+
end
|
|
64
|
+
Aro::P.say("spawned agodo named #{you.name}")
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def run_validations
|
|
68
|
+
# validate args
|
|
69
|
+
room_path = Aro::Dom.room_path(self.go)
|
|
70
|
+
unless !room_path.nil? && !room_path.empty?
|
|
71
|
+
errors.add(
|
|
72
|
+
:go,
|
|
73
|
+
:invalid,
|
|
74
|
+
message: I18n.t("abot.messages.invalid_go")
|
|
75
|
+
)
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
# unless errors.empty? && Aos::Os.is_aos_command?(self.do)
|
|
79
|
+
# errors.add(
|
|
80
|
+
# :do,
|
|
81
|
+
# :invalid,
|
|
82
|
+
# message: I18n.t("abot.messages.invalid_do")
|
|
83
|
+
# )
|
|
84
|
+
# end
|
|
85
|
+
|
|
86
|
+
unless errors.empty? && Aos::Cor.int_valid?(self.rate)
|
|
87
|
+
errors.add(
|
|
88
|
+
:rate,
|
|
89
|
+
:invalid,
|
|
90
|
+
message: I18n.t("abot.messages.invalid_rate")
|
|
91
|
+
)
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
create_you if self.you.nil? && errors.empty?
|
|
95
|
+
end
|
|
96
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
|
|
3
|
+
fpxy.rb
|
|
4
|
+
|
|
5
|
+
aos fpxy object.
|
|
6
|
+
|
|
7
|
+
by i2097i
|
|
8
|
+
|
|
9
|
+
=end
|
|
10
|
+
|
|
11
|
+
require_relative :"./base_model".to_s
|
|
12
|
+
|
|
13
|
+
module Aos
|
|
14
|
+
class Fpxy < ActiveRecord::Base
|
|
15
|
+
# table_name :fpxies
|
|
16
|
+
belongs_to :you
|
|
17
|
+
|
|
18
|
+
def get_lines
|
|
19
|
+
[
|
|
20
|
+
I18n.t(
|
|
21
|
+
"flie.fpxies.display",
|
|
22
|
+
you: self.you.name.ljust(Aro::Mancy::NUMERALS[:XIV]),
|
|
23
|
+
cmd: self.cmd.ljust(Aro::Mancy::NUMERALS[:XXXVII])
|
|
24
|
+
)
|
|
25
|
+
]
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
data/sys/aos/models/ilib.rb
CHANGED
data/sys/aos/models/ilog.rb
CHANGED
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
|
|
9
9
|
=end
|
|
10
10
|
|
|
11
|
+
require_relative :"./base_model".to_s
|
|
12
|
+
|
|
11
13
|
module Aos
|
|
12
14
|
class Ilog < ActiveRecord::Base
|
|
13
15
|
belongs_to :you
|
|
@@ -16,10 +18,10 @@ module Aos
|
|
|
16
18
|
[
|
|
17
19
|
I18n.t(
|
|
18
20
|
"data.ilogs.display",
|
|
19
|
-
you: self.you.name,
|
|
20
|
-
cmd: self.cmd,
|
|
21
|
+
you: self.you.name.ljust(Aro::Mancy::NUMERALS[:XIV]),
|
|
22
|
+
cmd: self.cmd.ljust(Aro::Mancy::NUMERALS[:XXXVII]),
|
|
21
23
|
timestamp: self.created_at.strftime(Aos::Os::DATE_FORMAT),
|
|
22
|
-
pwd: Aos::Os.osify(self.pwd)
|
|
24
|
+
pwd: Aos::Os.osify(self.pwd).ljust(Aro::Mancy::NUMERALS[:XIV])
|
|
23
25
|
)
|
|
24
26
|
]
|
|
25
27
|
end
|
data/sys/aos/models/you.rb
CHANGED
|
@@ -8,17 +8,25 @@
|
|
|
8
8
|
|
|
9
9
|
=end
|
|
10
10
|
|
|
11
|
+
require_relative :"./base_model".to_s
|
|
12
|
+
|
|
11
13
|
module Aos
|
|
12
14
|
class You < ActiveRecord::Base
|
|
13
15
|
has_many :ilogs
|
|
16
|
+
has_one :agodo
|
|
17
|
+
has_many :fpxies
|
|
14
18
|
before_validation :set_pwd
|
|
19
|
+
before_create :create_home_directory
|
|
15
20
|
after_update :clear_aos_display
|
|
16
21
|
|
|
17
22
|
enum :access, [
|
|
23
|
+
:agodo,
|
|
18
24
|
:user,
|
|
19
25
|
:root,
|
|
20
26
|
]
|
|
21
27
|
|
|
28
|
+
ARO_SRT_FILE = :".aro_srt"
|
|
29
|
+
|
|
22
30
|
def generate_ilog(cmd)
|
|
23
31
|
ilogs.create(
|
|
24
32
|
pwd: Aos::Os.osify(pwd),
|
|
@@ -26,25 +34,65 @@ module Aos
|
|
|
26
34
|
)
|
|
27
35
|
end
|
|
28
36
|
|
|
37
|
+
def fpx
|
|
38
|
+
{
|
|
39
|
+
name: self.name,
|
|
40
|
+
home: self.home,
|
|
41
|
+
pwd: self.pwd,
|
|
42
|
+
}
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def home!
|
|
46
|
+
h = home
|
|
47
|
+
Aro::D.say("#{__method__}#{Aos::Os::A}#{h}")
|
|
48
|
+
update(pwd: h)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def home?
|
|
52
|
+
self.pwd == self.home
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def home
|
|
56
|
+
File.join(
|
|
57
|
+
Aro::Dom::dom_root,
|
|
58
|
+
Aro::Dom.room_path(root? ? Aro::Dom::COR : Aro::Dom::HOME),
|
|
59
|
+
root? ? "" : self.name
|
|
60
|
+
)
|
|
61
|
+
end
|
|
62
|
+
|
|
29
63
|
def get_lines
|
|
30
64
|
[
|
|
31
65
|
I18n.t(
|
|
32
66
|
"data.yous.display",
|
|
33
|
-
name: name,
|
|
34
|
-
access:
|
|
35
|
-
pwd: Aos::Os.osify(pwd)
|
|
67
|
+
name: name&.ljust(Aro::Mancy::NUMERALS[:XIV]),
|
|
68
|
+
access: access&.ljust(Aro::Mancy::NUMERALS[:XIV]),
|
|
69
|
+
pwd: Aos::Os.osify(pwd)&.ljust(Aro::Mancy::NUMERALS[:XIV])
|
|
36
70
|
)
|
|
37
71
|
]
|
|
38
72
|
end
|
|
39
73
|
|
|
74
|
+
def stream(lines)
|
|
75
|
+
File.open(File.join(self.home, Aos::You::ARO_SRT_FILE.to_s), "a+") do |aro_srt|
|
|
76
|
+
aro_srt.write(lines.join("\n"))
|
|
77
|
+
aro_srt.write("\n")
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
40
81
|
private
|
|
41
82
|
|
|
42
83
|
def set_pwd
|
|
43
84
|
self.pwd = Dir.pwd if self.pwd.nil?
|
|
44
85
|
end
|
|
45
86
|
|
|
87
|
+
def create_home_directory
|
|
88
|
+
return if root? || agodo? || Dir.exist?(File.join(Aro::Dom.room_path(Aro::Dom::HOME), self.name))
|
|
89
|
+
Aro::Dom.instance.generate_room(Aro::Dom::D::LAYOUT[:HOME], {name: self.name.to_sym})
|
|
90
|
+
end
|
|
91
|
+
|
|
46
92
|
def clear_aos_display
|
|
47
|
-
Aos::Os.instance.
|
|
93
|
+
return unless Aos::Os.instance.you == self || Aos::Os.instance.you_flag == self
|
|
94
|
+
Aos::Os.instance.display_lines ||= []
|
|
95
|
+
Aos::Os.instance.display_lines << ">" + Aos::Os.osify(pwd, true)
|
|
48
96
|
end
|
|
49
97
|
end
|
|
50
98
|
end
|