aro 0.2.0 → 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.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/Gemfile.lock +3 -2
  4. data/aro.gemspec +1 -0
  5. data/bin/aos +2 -2
  6. data/bin/aro +1 -1
  7. data/listen.rb +1 -1
  8. data/locale/en.aos.yml +44 -5
  9. data/locale/en.dom.yml +2 -2
  10. data/locale/en.usage.yml +2 -2
  11. data/locale/en.yml +1 -0
  12. data/sys/aos/amg.rb +182 -0
  13. data/sys/aos/aos.rb +144 -63
  14. data/sys/aos/db/migrate/1765762724_create_libs.rb +22 -0
  15. data/sys/aos/db.rb +8 -9
  16. data/sys/aos/{views → vws}/base.rb +64 -61
  17. data/sys/aos/{views → vws}/dom.rb +6 -9
  18. data/sys/aos/vws/games/abpps.rb +19 -0
  19. data/sys/aos/{views → vws}/games/game.rb +16 -15
  20. data/sys/aos/vws/games/hbpps.rb +19 -0
  21. data/sys/aos/vws/games/shpps.rb +19 -0
  22. data/sys/aos/vws/games/vipps.rb +19 -0
  23. data/sys/aos/{views → vws}/games.rb +3 -3
  24. data/sys/aos/{views → vws}/know/library.rb +3 -3
  25. data/sys/aos/{views → vws}/know/temple.rb +3 -3
  26. data/sys/aos/{views → vws}/know.rb +3 -3
  27. data/sys/aos/vws/setup/amg.rb +22 -0
  28. data/sys/aos/vws/setup/config.rb +21 -0
  29. data/sys/aos/{views → vws}/setup.rb +3 -3
  30. data/sys/aos/vws/welcome/waite.rb +30 -0
  31. data/sys/aos/{views → vws}/welcome/winner.rb +3 -3
  32. data/sys/aos/{views → vws}/welcome.rb +3 -3
  33. data/sys/aos/you.rb +6 -4
  34. data/sys/aro/db.rb +6 -5
  35. data/sys/aro/mancy.rb +1 -0
  36. data/sys/aro/v.rb +1 -1
  37. data/sys/cli/deck.rb +9 -4
  38. data/sys/cli.rb +8 -9
  39. data/sys/{cli → dom}/config.rb +153 -157
  40. data/sys/dom/d.rb +10 -5
  41. data/sys/dom/dom.rb +3 -2
  42. data/sys/models/deck.rb +13 -18
  43. data/sys/reiquire.rb +4 -3
  44. data/sys/shr/lib/crs/CMakeLists.txt +12 -0
  45. data/sys/shr/lib/crs/compile.sh +5 -0
  46. data/sys/shr/lib/crs/crs.c +24 -0
  47. data/sys/shr/lib/crs/crs.o +0 -0
  48. data/sys/shr/lib/crs/libcrs.so +0 -0
  49. data/sys/shr/lib/lib.rb +43 -0
  50. data/sys/shr/prompt.rb +2 -2
  51. data/sys/shr/t.rb +14 -8
  52. data/sys/shr/version.rb +1 -1
  53. metadata +50 -21
  54. data/sys/aos/views/games/abpps.rb +0 -21
  55. data/sys/aos/views/games/hbpps.rb +0 -21
  56. data/sys/aos/views/games/shpps.rb +0 -21
  57. data/sys/aos/views/games/vipps.rb +0 -21
  58. data/sys/aos/views/setup/settings.rb +0 -37
  59. data/sys/aos/views/welcome/waite.rb +0 -19
  60. /data/{db → sys/aos/db}/migrate/1765148774_create_yous.rb +0 -0
  61. /data/{db → sys/aro/db}/migrate/1763374647_create_decks.rb +0 -0
  62. /data/{db → sys/aro/db}/migrate/1763432541_create_logs.rb +0 -0
data/sys/aos/aos.rb CHANGED
@@ -29,14 +29,21 @@ module Aos
29
29
  class Os
30
30
  include Singleton
31
31
 
32
- attr_accessor :you, :running, :view, :db
32
+ attr_accessor :you, :libs, :running, :view, :db, :display_lines
33
33
 
34
34
  A = :"@"
35
35
  STAR = :"*"
36
+ YOU = :you.to_s
37
+ YOU_FLAG = :"--you".to_s
36
38
  PS1 = :">[#{Aos::Os}]>: "
37
39
  DATE_FORMAT = "%A %d %b %Y %I:%M:%S %p"
38
40
 
39
41
  CMDS = {
42
+ AMG: {
43
+ key: :amg,
44
+ description: I18n.t("aos.commands.description.amg"),
45
+ usage: I18n.t("aos.commands.usage.amg"),
46
+ },
40
47
  CD: {
41
48
  key: :cd,
42
49
  description: I18n.t("aos.commands.description.cd"),
@@ -49,7 +56,7 @@ module Aos
49
56
  cmds: {
50
57
  SET: {
51
58
  key: :set,
52
- description: I18n.t("aos.commands.description.config_set", prefix: CLI::Config::ARO_CONFIG_PREFIX),
59
+ description: I18n.t("aos.commands.description.config_set", prefix: Aro::Config::ARO_CONFIG_PREFIX),
53
60
  usage: I18n.t("aos.commands.usage.config_set"),
54
61
  }
55
62
  }
@@ -59,6 +66,11 @@ module Aos
59
66
  description: I18n.t("aos.commands.description.exit"),
60
67
  usage: I18n.t("aos.commands.usage.exit"),
61
68
  },
69
+ HELP: {
70
+ key: :help,
71
+ description: I18n.t("aos.commands.description.help"),
72
+ usage: I18n.t("aos.commands.usage.help"),
73
+ },
62
74
  LS: {
63
75
  key: :ls,
64
76
  description: I18n.t("aos.commands.description.ls"),
@@ -76,32 +88,86 @@ module Aos
76
88
  },
77
89
  }
78
90
 
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
+
79
125
  def initialize
126
+ Aro::Config.instance.load
80
127
  if Aro::Dom.in_arodom? && !Aro::Dom.is_initialized?
81
128
  Aro::Dom.new.generate
82
129
  end
83
130
  @db = Aos::Db.new
131
+ load_libs
84
132
  load_you
85
133
  end
86
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
+
87
145
  def load_you
88
- @you = Aos::You.where(name: :you).first
89
- @you = Aos::You.create(name: :you, pwd: Dir.pwd) if @you.nil?
90
- Aro::D.say(@you.inspect)
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)]
91
157
  end
92
158
 
93
159
  def load_view
94
160
  view_name = Aos::Os.osify(@you.pwd).split("/").last || :dom.to_s
95
161
  view_cls = nil
96
162
  begin
97
- view_cls = (Aos::Vi.name + "::#{view_name.capitalize}").constantize
163
+ view_cls = (Aos::Vw.name + "::#{view_name.capitalize}").constantize
98
164
  rescue
99
- view_cls = Aos::Vi::Base
165
+ view_cls = Aos::Vw::Base
100
166
  end
101
167
 
102
168
  Dir.chdir(@you.pwd) do
103
169
  if Aro::Mancy.in_aro? && Aro::Mancy.is_initialized?
104
- view_cls = Aos::Vi::Game
170
+ view_cls = Aos::Vw::Game
105
171
  end
106
172
  end
107
173
 
@@ -109,19 +175,6 @@ module Aos
109
175
  @view = view_cls
110
176
  end
111
177
 
112
- def self.osify(path)
113
- return path unless Aro::Dom.in_arodom?
114
- path_arr = path.split("/")
115
- Aro::Dom::dom_root.split("/").each{|rdp| path_arr.delete(rdp)}
116
- path_arr.join("/")
117
- end
118
-
119
- def self.is_aos_command?(arg)
120
- # determine if command is Aos::Os::CMDS
121
- # passthrough to system if command is not in Aos::Os::CMDS
122
- Aos::Os::CMDS.values.map{|v| v[:key]}.include?(arg.to_sym)
123
- end
124
-
125
178
  def render
126
179
  load_view
127
180
  return if @view.nil?
@@ -129,21 +182,25 @@ module Aos
129
182
  if Aro::Mancy.in_aro? && Aro::Mancy.is_initialized?
130
183
  system(:aro.to_s)
131
184
  else
132
- @view.show(@you)
185
+ @view.show
133
186
  end
134
187
  end
135
188
  end
136
189
 
137
190
  def process_cmd(cmd)
138
191
  Dir.chdir(@you.reload.pwd) do
192
+ configure_readline
139
193
  passthrough = main(cmd)
140
- if CLI::Config.is_format_text?
141
- IO.console.goto(Aro::Mancy::O, Aro::Mancy::O)
194
+ if Aro::Config.is_format_text?
195
+ # IO.console.goto(Aro::Mancy::O, Aro::Mancy::O)
142
196
  end
197
+ nothing = nil
143
198
  if passthrough
144
- system(cmd)
145
- Aos::S.say("\n")
146
- else
199
+ nothing = system(cmd)
200
+ Aos::S.say(nothing) if nothing.nil?
201
+ end
202
+
203
+ if nothing.nil?
147
204
  render
148
205
  end
149
206
  end
@@ -151,13 +208,24 @@ module Aos
151
208
  CLI::EXIT_CODES[:SUCCESS]
152
209
  end
153
210
 
154
- def confgiure_readline
211
+ def configure_readline
155
212
  # configure Readline
156
- # Readline.completion_append_character = "/"
213
+ Readline.completion_append_character = "/"
157
214
  Readline.completion_proc = Proc.new{|str|
158
- # todo: the reserved_words search is working but the || case is not
159
- Aro::Dom::D.reserved_words.grep(/^#{Regexp.escape(str)}/) ||
160
- Dir[@you.pwd + str + Aos::Os::STAR.to_s].grep(/^#{Regexp.escape(str)}/)
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
161
229
  }
162
230
  end
163
231
 
@@ -170,10 +238,10 @@ module Aos
170
238
  cmd = nil
171
239
  loop do
172
240
  # erase before cursor
173
- IO.console.erase_screen(Aro::Mancy::S)
174
241
  process_cmd(cmd)
175
- IO.console.goto(CLI::Config.display_config[:HEIGHT], Aro::Mancy::O)
242
+ IO.console.goto(Aro::Config.display_configuration[:HEIGHT], Aro::Mancy::O)
176
243
  break unless @running && cmd = Readline.readline(calc_ps1, true)
244
+ IO.console.erase_screen(Aro::Mancy::S)
177
245
  end
178
246
 
179
247
  out
@@ -189,26 +257,23 @@ module Aos
189
257
  return false if cmd.nil?
190
258
 
191
259
  # get args
192
- args = cmd.split(" ")
260
+ args = Aos::Os.sanitize_you(cmd).split(" ")
193
261
  return false if args[0].nil?
194
262
  return false if args[0] == :aos.to_s
195
263
 
196
- # reconfigure for updates to pwd
197
- # todo: not working for tab completion
198
- confgiure_readline
199
-
200
264
  args = handle_aro_override(args)
201
265
 
202
266
  passthrough = !Aos::Os.is_aos_command?(args[Aro::Mancy::O]) ||
203
267
  args.include?(:aos.to_s)
204
268
 
205
- return false if handle_room_path(args[Aro::Mancy::O])
206
-
207
269
  # set aos pwd
208
270
  unless passthrough
209
271
  Dir.chdir(@you.pwd) do
210
272
  # process commands
211
273
  case args[Aro::Mancy::O].to_sym
274
+ when Aos::Os::CMDS[:AMG][:key]
275
+ # inst
276
+ passthrough = handle_amg(args)
212
277
  when Aos::Os::CMDS[:CONFIG][:key]
213
278
  # config
214
279
  passthrough = handle_config(args)
@@ -225,6 +290,9 @@ module Aos
225
290
  # exit
226
291
  passthrough = true
227
292
  handle_exit(args)
293
+ when Aos::Os::CMDS[:HELP][:key]
294
+ # help
295
+ passthrough = handle_help(args)
228
296
  when Aos::Os::CMDS[:CD][:key]
229
297
  # cd
230
298
  handle_cd(args)
@@ -232,15 +300,34 @@ module Aos
232
300
  end
233
301
  end
234
302
 
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
+
235
310
  return passthrough
236
311
  end
237
312
 
238
313
  def calc_ps1
239
314
  you_pwd = Aos::Os::osify(@you.pwd)
240
- "#{Aos::Os::PS1}" # #{you_pwd.empty? ? "" : "#{you_pwd}:"}$ "
315
+ "#{Aos::Os::PS1}"
316
+ end
317
+
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
323
+ end
324
+
325
+ def handle_config(args)
326
+ Aro::Config.process_config_command(args)
327
+ return true
241
328
  end
242
329
 
243
- def handle_room_path(arg)
330
+ def redirect_to_room(arg)
244
331
  # search for reserved room path
245
332
  handled = false
246
333
  room_path = Aro::Dom.room_path(arg)
@@ -254,36 +341,30 @@ module Aos
254
341
  handled
255
342
  end
256
343
 
257
- def handle_aro_override(args)
258
- if args[0].include?(:aro.to_s)
259
- args = "#{args.join(" ")} #{:aos.to_s}".split(" ")
260
- end
261
- args
344
+ def handle_amg(args)
345
+ Aos::Amg.process_cmd(args)
262
346
  end
263
347
 
264
- def handle_config(args)
265
- passthrough = false
266
- if args[1].nil?
267
- # show settings
268
- passthrough = true
269
- CLI::Config.dump_config.each{|l| Aos::S.say(l)}
270
- else
271
- CLI::Config.process_config_command(args)
272
- end
273
- passthrough
348
+ def handle_help(args)
349
+ redirect_to_room(Aro::Dom::WAITE)
350
+ return false
274
351
  end
275
352
 
276
353
  def handle_ls(args)
277
- Aos::S.say(Dir.glob(File.join(@you.pwd, (args[1] || "") + Aos::Os::STAR.to_s), File::FNM_EXTGLOB).map{|p| "/" + Aos::Os::osify(p)}.join("\n"))
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
+ ]
278
357
  end
279
358
 
280
359
  def handle_ll(args)
281
- Aos::S.say(Dir.glob(File.join(@you.pwd, (args[1] || "") + Aos::Os::STAR.to_s), File::FNM_DOTMATCH).map{|p| "/" + Aos::Os::osify(p)}.join("\n"))
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
+ ]
282
363
  end
283
364
 
284
365
  def handle_pwd(args)
285
366
  osified = "/" + Aos::Os::osify(@you.pwd)
286
- Aos::S.say(osified)
367
+ self.display_lines = [osified]
287
368
  end
288
369
 
289
370
  def handle_exit(args)
@@ -299,7 +380,7 @@ module Aos
299
380
  if args[1].include?(Aro::Dom::DOTT.to_s)
300
381
  # going up
301
382
  if File.dirname(Aro::Dom.ethergeist_path) == @you.pwd
302
- Aos::S.say("within #{Aos::Os}, one cannot leave the #{Aro::Dom}.")
383
+ self.display_lines = ["within #{Aos::Os}, one cannot leave the #{Aro::Dom}."]
303
384
  else
304
385
  # todo: support dots in paths
305
386
  # this only supports moving one level up
@@ -325,7 +406,7 @@ module Aos
325
406
  Aro::V.say("new_pwd: #{new_pwd}")
326
407
  @you.update(pwd: new_pwd)
327
408
  else
328
- Aos::S.say("that directory is invalid.")
409
+ self.display_lines = ["that directory is invalid."]
329
410
  end
330
411
  end
331
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 room.
5
+ database for aos.
6
6
 
7
7
  by i2097i
8
8
 
@@ -10,10 +10,8 @@
10
10
 
11
11
  module Aos
12
12
  class Db < Aro::Db
13
- DATABASE_YML = :"database.yml"
13
+ GEM_DB_PATH = :"sys/aos/db"
14
14
  SQL_FILE = :"aos.sql"
15
- SCHEMA_FILE = :"schema.rb"
16
- MIGRATIONS_DIR = :"db/migrate"
17
15
 
18
16
  def initialize
19
17
  Aos::Db.configure_logger
@@ -25,7 +23,7 @@ module Aos
25
23
  end
26
24
 
27
25
  def self.configure_logger
28
- if CLI::Config.ivar(:LOG_AOS_DB).to_s == CLI::Config::BOOLS[:TRUE].to_s
26
+ if Aro::Config.ivar(:LOG_AOS_DB).to_s == Aro::Config::BOOLS[:TRUE].to_s
29
27
  ActiveRecord::Base.logger = Logger.new(STDOUT)
30
28
  else
31
29
  ActiveRecord::Base.logger = nil
@@ -37,7 +35,8 @@ module Aos
37
35
  end
38
36
 
39
37
  def db_config_filepath
40
- File.join(Aos::Db.base_aro_dir, Aos::Db::DATABASE_YML.to_s)
38
+ # intentionally using Aro::Db::DATABASE_YML here
39
+ File.join(Aos::Db.base_aro_dir, Aro::Db::DATABASE_YML.to_s)
41
40
  end
42
41
 
43
42
  def set_up_aos
@@ -68,10 +67,10 @@ module Aos
68
67
  end
69
68
 
70
69
  def migrate(name)
71
- local_migrate_dir = File.join(Aos::Db.base_aro_dir, Aos::Db::MIGRATIONS_DIR.to_s)
70
+ local_migrate_dir = File.join(Aos::Db.base_aro_dir, Aro::Db::MIGRATIONS_DIR.to_s)
72
71
  unless Dir.exist?(local_migrate_dir)
73
72
  gem_dir = Dir[Gem.loaded_specs[:aro.to_s]&.full_gem_path || '.'].first
74
- FileUtils.cp_r(File.join(gem_dir, "db"), Aos::Db::base_aro_dir)
73
+ FileUtils.cp_r(File.join(gem_dir, Aos::Db::GEM_DB_PATH.to_s), Aos::Db::base_aro_dir)
75
74
  end
76
75
 
77
76
  migration_version = Dir["#{local_migrate_dir}/*.rb"].map{|n|
@@ -79,7 +78,7 @@ module Aos
79
78
  }.max
80
79
  ActiveRecord::MigrationContext.new(local_migrate_dir).migrate(migration_version)
81
80
 
82
- filename = File.join(Aos::Db.base_aro_dir, Aos::Db::SCHEMA_FILE.to_s)
81
+ filename = File.join(Aos::Db.base_aro_dir, Aro::Db::SCHEMA_FILE.to_s)
83
82
  File.open(filename, "w+") do |f|
84
83
  ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection_pool, f)
85
84
  end
@@ -1,6 +1,6 @@
1
1
  =begin
2
2
 
3
- views/base.rb
3
+ vws/base.rb
4
4
 
5
5
  the base view (abstract).
6
6
 
@@ -11,21 +11,21 @@
11
11
  require :aro.to_s
12
12
 
13
13
  module Aos
14
- module Vi
14
+ module Vw
15
15
  class Base
16
16
  BAR = :"".to_s
17
17
  COL_POW = Proc.new{|n| n.pow(Aro::Mancy::S.to_f / Aro::Mancy::OS.to_f).to_i}
18
18
  MARGIN_V = Aro::Mancy::S
19
19
  MARGIN_H = Aro::Mancy::S
20
20
 
21
- def self.show(model)
22
- draw([self.name], model)
21
+ def self.show
22
+ draw([self.name])
23
23
  end
24
24
 
25
- def self.get_json(lines, you = nil)
25
+ def self.get_json(lines)
26
26
  {
27
27
  body: lines,
28
- you: you&.to_json,
28
+ you: Aos::Os.instance.you.to_json,
29
29
  domain: self.get_domain,
30
30
  clock: self.get_clock,
31
31
  dimension: self.get_dimension,
@@ -33,68 +33,78 @@ module Aos
33
33
  }
34
34
  end
35
35
 
36
- def self.draw(lines, you = nil)
37
- unless CLI::Config.is_format_text?
38
- Aos::S.say(self.get_json(lines, you))
36
+ def self.draw(body_lines)
37
+ unless Aro::Config.is_format_text?
38
+ Aos::S.say(self.get_json(lines))
39
39
  return true
40
40
  end
41
41
 
42
- return false unless lines.kind_of?(Array)
43
-
44
- dc = CLI::Config.display_config
42
+ return false unless body_lines.kind_of?(Array)
43
+ lines = []
44
+ dc = Aro::Config.display_configuration
45
45
  height = dc[:HEIGHT]
46
46
  width = dc[:WIDTH]
47
47
 
48
- print_aos_div
49
-
50
48
  # header
51
- Aro::Mancy::S.times do |i|
52
- Aos::S.say("".center(width, dc[:DIVIDER]))
53
- Aos::S.say("".center(width))
54
- Aos::S.say("\n")
55
- end
49
+ # lines << "".center(width, "=")
50
+ # lines << "".center(width)
56
51
 
57
- half = ((width - self.name.length) / Aro::Mancy::OS.to_f).ceil
58
- domain = self.get_domain
59
- clock = self.get_clock
60
- Aos::S.say(
61
- (
62
- domain.ljust(half) + self.name.to_s.upcase
63
- ).ljust(width - clock.length) + clock
64
- )
65
-
66
- Aro::Mancy::S.times do
67
- Aos::S.say("".center(width, dc[:DIVIDER]))
68
- end
52
+ # half = ((width - self.name.length) / Aro::Mancy::OS.to_f).ceil
53
+ # domain = self.get_domain
54
+ # clock = self.get_clock
55
+ # lines << (
56
+ # (
57
+ # domain.ljust(half) + self.name.to_s.upcase
58
+ # ).ljust(width - clock.length) + clock
59
+ # )
60
+
61
+ # lines << "".center(width, dc[:DIVIDER])
69
62
 
70
63
  # top vertical margin
71
- Aos::Vi::Base::MARGIN_V.times do
72
- Aos::S.say(get_body_line(""))
64
+ Aos::Vw::Base::MARGIN_V.times do
65
+ lines << get_body_line("")
73
66
  end
74
67
 
75
68
  # yield => print lines
76
- lines.each{|line|
77
- Aos::S.say(get_body_line(line))
69
+ body_lines.each{|line|
70
+ lines << get_body_line(line)
78
71
  }
79
72
 
80
- # bottom vertical margin
81
- Aos::Vi::Base::MARGIN_V.times do
82
- Aos::S.say("[#{Aos::Os} v#{Aro::VERSION.to_s}]".center(width))
83
- end
73
+ lines += get_aos_display_lines
84
74
 
85
75
  # footer
86
- display_dim = self.get_display_dimension
87
- Aos::S.say(
88
- (
89
- ">[#{domain}]>#{Aos::Os::osify(you&.pwd || Dir.pwd)}"
90
- ).ljust(width - display_dim.length) + display_dim
91
- )
92
-
93
- print_aos_div
76
+ # display_dim = self.get_display_dimension
77
+ # lines << (
78
+ # (
79
+ # ">[#{domain}]>#{Aos::Os::osify(Aos::Os.instance.you&.pwd || Dir.pwd)}"
80
+ # ).ljust(width - display_dim.length) + display_dim
81
+ # )
82
+
83
+ # print everything
84
+ Aos::S.say(lines.join("\n"))
85
+
94
86
  # explicitly return true
95
87
  true
96
88
  end
97
89
 
90
+ def self.get_aos_display_lines
91
+ # current Aos::Os output
92
+ lines = []
93
+ unless Aos::Os.instance.display_lines.empty?
94
+ dc = Aro::Config.display_configuration
95
+ width = dc[:WIDTH]
96
+ lines << "".center(width)
97
+ display_dim = get_display_dimension
98
+ Aos::Os.instance.display_lines.each{|line|
99
+ lines << line
100
+ }
101
+ lines << "".center(width)
102
+ lines << "v#{Aro::VERSION.to_s}".ljust(width - display_dim.length) + display_dim
103
+ # lines << "".center(width, "=")
104
+ end
105
+ lines
106
+ end
107
+
98
108
  def self.get_display_dimension
99
109
  "#{self.get_dt.rjust(Aro::Mancy::V)} :<[#{self.get_dimension}]<"
100
110
  end
@@ -115,27 +125,20 @@ module Aos
115
125
  Time.now.strftime(Aos::Os::DATE_FORMAT)
116
126
  end
117
127
 
118
- def self.print_aos_div
119
- Aro::Mancy::S.times do
120
- Aos::S.say("\n")
121
- Aos::S.say("".center(CLI::Config.display_config[:WIDTH], "="))
122
- end
123
- end
124
-
125
128
  def self.viewport_width
126
- dc = CLI::Config.display_config
129
+ dc = Aro::Config.display_configuration
127
130
  width = dc[:WIDTH]
128
- bar_width = (Aos::Vi::Base::BAR.length * Aro::Mancy::OS)
129
- h_margin_width = (Aos::Vi::Base::MARGIN_H * Aro::Mancy::OS)
131
+ bar_width = (Aos::Vw::Base::BAR.length * Aro::Mancy::OS)
132
+ h_margin_width = (Aos::Vw::Base::MARGIN_H * Aro::Mancy::OS)
130
133
 
131
134
  (width - (bar_width + h_margin_width))
132
135
  end
133
136
 
134
137
  def self.get_body_line(line)
135
- hm = Aos::Vi::Base::MARGIN_H
136
- bar = Aos::Vi::Base::BAR
137
- hm_space = " " * Aos::Vi::Base::MARGIN_H
138
- just = CLI::Config.display_config[:WIDTH] - (hm_space.length + bar.length)
138
+ hm = Aos::Vw::Base::MARGIN_H
139
+ bar = Aos::Vw::Base::BAR
140
+ hm_space = " " * Aos::Vw::Base::MARGIN_H
141
+ just = Aro::Config.display_configuration[:WIDTH] - (hm_space.length + bar.length)
139
142
  (bar + hm_space + (line || "")).ljust(just) + hm_space + bar
140
143
  end
141
144
 
@@ -1,6 +1,6 @@
1
1
  =begin
2
2
 
3
- views/dom.rb
3
+ vws/dom.rb
4
4
 
5
5
  the dom view.
6
6
 
@@ -11,25 +11,22 @@
11
11
  require_relative :"./base".to_s
12
12
 
13
13
  module Aos
14
- module Vi
15
- class Dom < Aos::Vi::Base
14
+ module Vw
15
+ class Dom < Aos::Vw::Base
16
16
 
17
- def self.show(model)
17
+ def self.show
18
18
  lines = []
19
19
  lines << I18n.t("aos.views.dom.title")
20
20
  lines << I18n.t("aos.views.dom.description")
21
21
  lines << ""
22
22
  lines << I18n.t("aos.constants.commands")
23
- Aos::Os::CMDS.keys.sort.each{|cmd|
24
- lines += lines_for_cmd(Aos::Os::CMDS[cmd])
25
- }
26
-
23
+ lines += lines_for_cmd(Aos::Os::CMDS[:HELP])
27
24
  lines << ""
28
25
  lines << I18n.t("aos.views.dom.quick_navigation")
29
26
  lines << ""
30
27
  lines << " => #{Aro::Dom::D.reserved_words.join(" ")}"
31
28
  lines << ""
32
- draw(lines, model)
29
+ draw(lines)
33
30
  end
34
31
  end
35
32
  end