aro 0.2.2 → 0.2.4

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.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/Gemfile.lock +1 -1
  4. data/aro.gemspec +9 -9
  5. data/bin/aos +10 -3
  6. data/bin/aro +26 -13
  7. data/checksums/aro-0.2.3.gem.sha512 +1 -0
  8. data/locale/en.abot.yml +81 -0
  9. data/locale/en.amg.yml +7 -7
  10. data/locale/en.aos.yml +11 -7
  11. data/locale/en.cards.yml +361 -312
  12. data/locale/en.cor.yml +47 -0
  13. data/locale/en.data.yml +3 -3
  14. data/locale/en.dom.yml +15 -13
  15. data/locale/en.flie.yml +29 -0
  16. data/locale/en.usage.yml +103 -63
  17. data/locale/en.yml +5 -49
  18. data/sys/aos/abot.rb +255 -0
  19. data/sys/aos/aos.rb +381 -164
  20. data/sys/aos/cor.rb +770 -0
  21. data/sys/aos/data.rb +3 -3
  22. data/sys/aos/db/migrate/1765148774_create_yous.rb +1 -1
  23. data/sys/aos/db/migrate/1765933985_create_agodos.rb +22 -0
  24. data/sys/aos/db/migrate/1766203888_create_fpxies.rb +18 -0
  25. data/sys/aos/db.rb +15 -17
  26. data/sys/aos/flie.rb +144 -0
  27. data/sys/aos/models/agodo.rb +95 -0
  28. data/sys/aos/models/fpxy.rb +26 -0
  29. data/sys/aos/models/ilog.rb +3 -3
  30. data/sys/aos/models/you.rb +56 -4
  31. data/sys/aos/s.rb +2 -1
  32. data/sys/aos/vws/base.rb +64 -25
  33. data/sys/aos/vws/dom.rb +1 -1
  34. data/sys/aos/vws/games/abot.rb +21 -0
  35. data/sys/aos/vws/games/{game.rb → teck.rb} +35 -28
  36. data/sys/aos/vws/home.rb +23 -0
  37. data/sys/aos/vws/root/config.rb +4 -4
  38. data/sys/aos/vws/root/flie.rb +21 -0
  39. data/sys/aos/vws/welcome.rb +40 -4
  40. data/sys/aro/d.rb +4 -2
  41. data/sys/aro/db.rb +16 -9
  42. data/sys/aro/mancy.rb +16 -20
  43. data/sys/aro/models/base_model.rb +13 -0
  44. data/sys/aro/models/teck.rb +40 -23
  45. data/sys/aro/models/tlog.rb +2 -1
  46. data/sys/aro/p.rb +1 -1
  47. data/sys/aro/r.rb +2 -1
  48. data/sys/aro/v.rb +2 -2
  49. data/sys/cli/constants.rb +5 -10
  50. data/sys/cli/create.rb +3 -4
  51. data/sys/cli/dom.rb +3 -4
  52. data/sys/cli/nterface.rb +15 -9
  53. data/sys/cli/teck.rb +29 -38
  54. data/sys/cli/usage.rb +11 -1
  55. data/sys/cli.rb +7 -9
  56. data/sys/dom/d.rb +38 -29
  57. data/sys/dom/dom.rb +62 -37
  58. data/sys/dom/p.rb +1 -1
  59. data/sys/fpx.rb +104 -0
  60. data/sys/reiquire.rb +3 -2
  61. data/sys/shr/prompt.rb +2 -2
  62. data/sys/shr/t.rb +13 -15
  63. data/sys/shr/version.rb +1 -1
  64. data/tasks/make.rake +1 -1
  65. metadata +54 -43
  66. data/sys/aos/vws/games/abpps.rb +0 -19
  67. data/sys/aos/vws/games/hbpps.rb +0 -19
  68. data/sys/aos/vws/games/shpps.rb +0 -19
  69. data/sys/aos/vws/games/vipps.rb +0 -19
  70. 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
- iilogs = Aos::Ilog.all
86
- unless iilogs.any?
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
- iilogs.each{|il|
90
+ ilogs.each{|il|
91
91
  lines += il.get_lines
92
92
  }
93
93
  end
@@ -4,7 +4,7 @@ class CreateYous < ActiveRecord::Migration[8.1]
4
4
  create_table :yous do |t|
5
5
  t.string :name, null: false
6
6
  t.string :pwd
7
- t.integer :access, default: Aro::Mancy::O
7
+ t.integer :access, default: Aro::Mancy::S
8
8
 
9
9
  t.timestamps
10
10
 
@@ -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
@@ -19,16 +19,16 @@ module Aos
19
19
  SQL_FILE = :"aos.sql"
20
20
 
21
21
  def self.load(password = nil)
22
- Aos::Db.configure_logger
23
- if Aro::Dom.in_arodom?
24
- self.instance.set_up_aos(password)
25
- else
26
- Aro::P.say(I18n.t("cli.errors.not_in_aro" , cmd: Aro::Dom.name))
22
+ Mutex.new.synchronize do
23
+ if Aro::Dom.in_arodom?
24
+ Aos::Db.configure_logger
25
+ self.instance.set_up_aos(password)
26
+ end
27
27
  end
28
28
  end
29
29
 
30
30
  def self.configure_logger
31
- if Aro::Config.ivar(:LOG_AOS_DB).to_s == Aro::Config::BOOLS[:TRUE].to_s
31
+ if Aos::Cor.ivar(:LOG_AOS_DB).to_s == Aos::Cor::BOOLS[:TRUE].to_s
32
32
  ActiveRecord::Base.logger = Logger.new(STDOUT)
33
33
  else
34
34
  ActiveRecord::Base.logger = nil
@@ -36,19 +36,16 @@ module Aos
36
36
  end
37
37
 
38
38
  def self.base_aro_dir
39
- # Aro::Dom.ethergeist_path
40
39
  File.join(Aro::Dom.dom_root, Aro::Dom.room_path(:data))
41
40
  end
42
41
 
43
42
  def db_config_filepath
44
43
  # intentionally using Aro::Db::DATABASE_YML here
45
- File.join(Aos::Db.base_aro_dir, Aro::Db::DATABASE_YML.to_s)
44
+ @db_config_filepath = File.join(Aos::Db.base_aro_dir, Aro::Db::DATABASE_YML.to_s)
46
45
  end
47
46
 
48
47
  def set_up_aos(password)
49
- name = Aro::Dom.ethergeist_name
50
- return if name.nil?
51
-
48
+ ActiveRecord::Base.connection_pool.flush! unless password.nil?
52
49
  # create local /.ethergeist directory
53
50
  unless File.exist?(Aos::Db.base_aro_dir)
54
51
  FileUtils.mkdir(Aos::Db.base_aro_dir)
@@ -63,8 +60,9 @@ module Aos
63
60
  file.write({
64
61
  adapter: :sqlite3.to_s,
65
62
  database: db_file_path,
66
- username: name,
63
+ username: Aro::Dom.ethergeist_name,
67
64
  password: password,
65
+ pool: Aos::Os::DB_POOL
68
66
  }.to_yaml)
69
67
  end
70
68
  else
@@ -73,23 +71,23 @@ module Aos
73
71
  end
74
72
 
75
73
  if File.exist?(db_config_filepath)
76
- connect(name)
77
- migrate(name)
74
+ connect
75
+ migrate
78
76
  else
79
77
  Aro::D.say("unable to set up database without root password.")
80
78
  end
81
79
  end
82
80
 
83
- def connect(name)
81
+ def connect
84
82
  ActiveRecord::Base.establish_connection(
85
83
  YAML.load_file(db_config_filepath)
86
84
  )
87
85
  end
88
86
 
89
- def migrate(name)
87
+ def migrate
90
88
  local_migrate_dir = File.join(Aos::Db.base_aro_dir, Aro::Db::MIGRATIONS_DIR.to_s)
91
89
  unless Dir.exist?(local_migrate_dir)
92
- gem_dir = Dir[Gem.loaded_specs[:aro.to_s]&.full_gem_path || '.'].first
90
+ gem_dir = Dir[Reiquire::GEM_PATH || '.'].first
93
91
  FileUtils.cp_r(File.join(gem_dir, Aos::Db::GEM_DB_PATH.to_s), Aos::Db::base_aro_dir)
94
92
  end
95
93
 
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,95 @@
1
+ =begin
2
+
3
+ agodo.rb
4
+
5
+ agodo object.
6
+
7
+ by i2097i
8
+
9
+ =end
10
+
11
+ require :base64.to_s
12
+
13
+ class Aos::Agodo < ActiveRecord::Base
14
+ belongs_to :you
15
+ validate :run_validations
16
+
17
+ enum :power, [
18
+ :off,
19
+ :on
20
+ ]
21
+
22
+ def godo
23
+ godos_per_minute = Aro::Mancy::NUMERALS[:LX].to_f / rate.to_f
24
+ # todo: this is awful
25
+ if Time.now - updated_at >= godos_per_minute
26
+ system("#{:aos} #{self.go} #{Aos::Os::YOU_FLAG} #{self.you.name}")
27
+ system("#{:aos} #{self.do.gsub("_", " ")} #{Aos::Os::YOU_FLAG} #{self.you.name}")
28
+ system("#{:aos} #{self.home.nil? ? "cd" : self.home} #{Aos::Os::YOU_FLAG} #{self.you.name}")
29
+ reload.touch
30
+ end
31
+ end
32
+
33
+ def get_lines
34
+ [
35
+ I18n.t(
36
+ "abot.agodo.display",
37
+ power: Aos::Agodo::powers[self.power],
38
+ go: self.go,
39
+ do: self.do,
40
+ rate: self.rate,
41
+ home: self.home.nil? ? "/" : Aos::Os.osify(self.home)
42
+ )
43
+ ]
44
+ end
45
+
46
+ private
47
+
48
+ def create_you
49
+ # todo: deal with potential name clashes
50
+ self.you = Aos::You.create(
51
+ access: :agodo,
52
+ pwd: Aos::Os.instance.you.pwd,
53
+ name: [
54
+ Aro::T.read_dev_tarot(false),
55
+ Aro::T.summon_ruby_facot(false),
56
+ rand(99..999)
57
+ ].join("_").strip
58
+ )
59
+ self.home = self.you.pwd.split("/").last
60
+ if self.home == Aro::Dom.ethergeist_name
61
+ self.home = nil
62
+ end
63
+ Aro::P.say("spawned agodo named #{you.name}")
64
+ end
65
+
66
+ def run_validations
67
+ # validate args
68
+ room_path = Aro::Dom.room_path(self.go)
69
+ unless !room_path.nil? && !room_path.empty?
70
+ errors.add(
71
+ :go,
72
+ :invalid,
73
+ message: I18n.t("abot.messages.invalid_go")
74
+ )
75
+ end
76
+
77
+ # unless errors.empty? && Aos::Os.is_aos_command?(self.do)
78
+ # errors.add(
79
+ # :do,
80
+ # :invalid,
81
+ # message: I18n.t("abot.messages.invalid_do")
82
+ # )
83
+ # end
84
+
85
+ unless errors.empty? && Aos::Cor.int_valid?(self.rate)
86
+ errors.add(
87
+ :rate,
88
+ :invalid,
89
+ message: I18n.t("abot.messages.invalid_rate")
90
+ )
91
+ end
92
+
93
+ create_you if self.you.nil? && errors.empty?
94
+ end
95
+ end
@@ -0,0 +1,26 @@
1
+ =begin
2
+
3
+ fpxy.rb
4
+
5
+ aos fpxy object.
6
+
7
+ by i2097i
8
+
9
+ =end
10
+
11
+ module Aos
12
+ class Fpxy < ActiveRecord::Base
13
+ # table_name :fpxies
14
+ belongs_to :you
15
+
16
+ def get_lines
17
+ [
18
+ I18n.t(
19
+ "flie.fpxies.display",
20
+ you: self.you.name.ljust(Aro::Mancy::NUMERALS[:XIV]),
21
+ cmd: self.cmd.ljust(Aro::Mancy::NUMERALS[:XXXVII])
22
+ )
23
+ ]
24
+ end
25
+ end
26
+ end
@@ -16,10 +16,10 @@ module Aos
16
16
  [
17
17
  I18n.t(
18
18
  "data.ilogs.display",
19
- you: self.you.name,
20
- cmd: self.cmd,
19
+ you: self.you.name.ljust(Aro::Mancy::NUMERALS[:XIV]),
20
+ cmd: self.cmd.ljust(Aro::Mancy::NUMERALS[:XXXVII]),
21
21
  timestamp: self.created_at.strftime(Aos::Os::DATE_FORMAT),
22
- pwd: Aos::Os.osify(self.pwd)
22
+ pwd: Aos::Os.osify(self.pwd).ljust(Aro::Mancy::NUMERALS[:XIV])
23
23
  )
24
24
  ]
25
25
  end
@@ -11,14 +11,21 @@
11
11
  module Aos
12
12
  class You < ActiveRecord::Base
13
13
  has_many :ilogs
14
+ has_one :agodo
15
+ has_many :fpxies
16
+
14
17
  before_validation :set_pwd
18
+ before_create :create_home_directory
15
19
  after_update :clear_aos_display
16
20
 
17
21
  enum :access, [
22
+ :agodo,
18
23
  :user,
19
24
  :root,
20
25
  ]
21
26
 
27
+ ARO_SRT_FILE = :".aro_srt"
28
+
22
29
  def generate_ilog(cmd)
23
30
  ilogs.create(
24
31
  pwd: Aos::Os.osify(pwd),
@@ -26,25 +33,70 @@ module Aos
26
33
  )
27
34
  end
28
35
 
36
+ def fpx
37
+ {
38
+ name: self.name,
39
+ home: self.home,
40
+ pwd: self.pwd,
41
+ stream_bytes: File.stat(stream_file).size
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: Aos::You::accesses[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(stream_file, "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 stream_file
88
+ File.join(self.home, Aos::You::ARO_SRT_FILE.to_s)
89
+ end
90
+
91
+ def create_home_directory
92
+ return if root? || agodo? || Dir.exist?(File.join(Aro::Dom.room_path(Aro::Dom::HOME), self.name))
93
+ Aro::Dom.instance.generate_room(Aro::Dom::D::LAYOUT[:HOME], {name: self.name.to_sym})
94
+ end
95
+
46
96
  def clear_aos_display
47
- Aos::Os.instance.display_lines = [Aos::Os.osify(pwd, true)]
97
+ return unless Aos::Os.instance.you == self || Aos::Os.instance.you_flag == self
98
+ Aos::Os.instance.display_lines ||= []
99
+ Aos::Os.instance.display_lines << ">" + Aos::Os.osify(pwd, true)
48
100
  end
49
101
  end
50
102
  end
data/sys/aos/s.rb CHANGED
@@ -14,7 +14,8 @@ module Aos
14
14
  class S < Aro::Prompt
15
15
  def self.say(message)
16
16
  return unless Aos::S.should_print?
17
- Aro::P::p.say(message)
17
+ # todo: stream this
18
+ Aos::S.p.say(message)
18
19
  end
19
20
 
20
21
  def self.should_print?
data/sys/aos/vws/base.rb CHANGED
@@ -12,21 +12,30 @@ module Aos
12
12
  module Vw
13
13
  class Base
14
14
  BAR = :"".to_s
15
- COL_POW = Proc.new{|n| n.pow(Aro::Mancy::S.to_f / Aro::Mancy::OS.to_f).to_i}
16
15
  MARGIN_V = Aro::Mancy::S
17
16
  MARGIN_H = Aro::Mancy::S
18
17
 
19
18
  def self.show
20
- draw([self.name])
19
+ draw([
20
+ "the #{self.name} room.",
21
+ "",
22
+ "getting directory listing...",
23
+ "",
24
+ Aos::Os.instance.get_ls([])
25
+ ])
21
26
  end
22
27
 
23
28
  def self.draw(body_lines)
24
29
  return false unless body_lines.kind_of?(Array)
25
30
  lines = []
26
- dc = Aro::Config.display_configuration
27
- height = dc[:HEIGHT]
31
+
32
+ dc = Aos::Cor.discon
28
33
  width = dc[:WIDTH]
29
34
 
35
+ if Aro::Dom.in_arodom?
36
+ lines += get_main_divider(width, true)
37
+ end
38
+
30
39
  # top vertical margin
31
40
  Aos::Vw::Base::MARGIN_V.times do
32
41
  lines << get_body_line("")
@@ -37,39 +46,73 @@ module Aos
37
46
  lines << get_body_line(line)
38
47
  }
39
48
 
40
- lines += get_aos_display_lines if Aro::Dom.in_arodom?
49
+ if Aro::Dom.in_arodom?
50
+ lines += get_aos_display_lines
51
+ end
41
52
 
42
53
  # print everything
43
- Aos::S.say(lines.join("\n"))
54
+
55
+ Aro::Prompt.say(lines)
44
56
 
45
57
  # explicitly return true
46
58
  true
47
59
  end
48
60
 
61
+ def self.get_main_divider(width, clock = false)
62
+ left = "#{Aos::Os::PS1}"
63
+ if clock
64
+ left = "#{left}#{get_domain} >"
65
+ else
66
+ left = "#{left}v#{Aro::VERSION} >"
67
+ end
68
+ right = "< " + (clock ? get_clock : get_display_dimension.strip)
69
+ lines = []
70
+ lines << ""
71
+ lines << left.ljust(width - right.length, "-".to_s) + right
72
+ lines << ""
73
+ lines
74
+ end
75
+
49
76
  def self.get_aos_display_lines
50
77
  # current Aos::Os output
78
+
79
+ width = Aos::Cor.discon[:WIDTH]
51
80
  lines = []
81
+ Aos::Db.load
82
+
83
+ the_you = Aos::Os.instance.you_flag || Aos::Os.instance.you
84
+ Aro::V.say(Aos::Os.you_name_from_flag_arg)
85
+ Aro::V.say(the_you.inspect)
86
+ present_users = Aos::You.order(
87
+ name: :asc
88
+ ).where(
89
+ pwd: the_you.pwd,
90
+ access: [:agodo, :user]
91
+ ).map{|y|
92
+ (the_you == y ? Aos::Os::STAR.to_s : "") +
93
+ y.name
94
+ }
95
+
96
+ if present_users.any?
97
+ lines << "[ yous in the room ]".center(width)
98
+ lines << ("[ " + present_users.join(" ") + " ]").center(width)
99
+ end
100
+ lines << ":you_are_root".center(width) if the_you.root?
101
+ Aos::Os.instance.display_lines ||= []
52
102
  unless Aos::Os.instance.display_lines.empty?
53
- dc = Aro::Config.display_configuration
54
- width = dc[:WIDTH]
55
- lines << "".center(width)
56
- display_dim = get_display_dimension
103
+ lines << ""
57
104
  Aos::Os.instance.display_lines.each{|line|
58
105
  lines << line
59
106
  }
60
- lines << "".center(width)
61
- lines << "v#{Aro::VERSION.to_s}".ljust(width - display_dim.length) + display_dim
107
+ Aos::Os.instance.display_lines = []
108
+ lines << ""
62
109
  end
63
-
110
+ lines += get_main_divider(width)
64
111
  lines
65
112
  end
66
113
 
67
114
  def self.get_display_dimension
68
- "#{self.get_dt.rjust(Aro::Mancy::V)} :<[#{self.get_dimension}]<"
69
- end
70
-
71
- def self.get_dt
72
- Aro::T.read_dev_tarot.strip[Aro::Mancy::S..]
115
+ "#{Aro::T.read_dev_tarot(true).rjust(Aro::Mancy::V)} :<[#{self.get_dimension}]<"
73
116
  end
74
117
 
75
118
  def self.get_dimension
@@ -77,7 +120,7 @@ module Aos
77
120
  end
78
121
 
79
122
  def self.get_domain
80
- Aro::Dom.in_arodom? ? Aro::Dom::domain : Aro::Mancy.domain
123
+ Aro::Mancy.in_aro? ? Aro::Mancy.domain : Aro::Dom.domain
81
124
  end
82
125
 
83
126
  def self.get_clock
@@ -85,7 +128,7 @@ module Aos
85
128
  end
86
129
 
87
130
  def self.viewport_width
88
- dc = Aro::Config.display_configuration
131
+ dc = Aos::Cor.discon
89
132
  width = dc[:WIDTH]
90
133
  bar_width = (Aos::Vw::Base::BAR.length * Aro::Mancy::OS)
91
134
  h_margin_width = (Aos::Vw::Base::MARGIN_H * Aro::Mancy::OS)
@@ -97,7 +140,7 @@ module Aos
97
140
  hm = Aos::Vw::Base::MARGIN_H
98
141
  bar = Aos::Vw::Base::BAR
99
142
  hm_space = " " * Aos::Vw::Base::MARGIN_H
100
- just = Aro::Config.display_configuration[:WIDTH] - (hm_space.length + bar.length)
143
+ just = Aos::Cor.discon[:WIDTH] - (hm_space.length + bar.length)
101
144
  (bar + hm_space + (line || "")).ljust(just) + hm_space + bar
102
145
  end
103
146
 
@@ -111,10 +154,6 @@ module Aos
111
154
  lines << ""
112
155
  lines
113
156
  end
114
-
115
- def self.debug_log(lines)
116
- Aro::V.say(lines)
117
- end
118
157
  end
119
158
  end
120
159
  end