aro 0.2.7 → 0.2.9

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 (46) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +7 -2
  3. data/README.md +8 -7
  4. data/aro.gemspec +6 -3
  5. data/bin/oss_om +14 -1
  6. data/checksums/aro-0.2.8.gem.sha512 +1 -0
  7. data/checksums/aro-0.2.9.gem.sha512 +1 -0
  8. data/craft_docker-compose.template +59 -0
  9. data/locale/en.cor.yml +15 -11
  10. data/locale/en.yml +25 -1
  11. data/sys/aro/action.rb +35 -56
  12. data/sys/aro/book.rb +150 -0
  13. data/sys/aro/db/migrate/1793913841_create_menus.rb +1 -0
  14. data/sys/aro/db/migrate/1793913861_create_menu_items.rb +1 -0
  15. data/sys/aro/designer.rb +157 -37
  16. data/sys/aro/imports.rb +78 -0
  17. data/sys/aro/library.rb +202 -0
  18. data/sys/aro/locale.rb +4 -4
  19. data/sys/aro/mancy.rb +2 -2
  20. data/sys/aro/models/concerns/tar_go_for_root_sec.rb +1 -4
  21. data/sys/aro/models/cubicus.rb +39 -0
  22. data/sys/aro/models/data_base.rb +60 -13
  23. data/sys/aro/models/directory.rb +1 -5
  24. data/sys/aro/models/file.rb +1 -1
  25. data/sys/aro/models/glyph.rb +69 -0
  26. data/sys/aro/models/menu.rb +43 -14
  27. data/sys/aro/models/menu_item.rb +6 -10
  28. data/sys/aro/models/objecticus.rb +28 -0
  29. data/sys/aro/models/perspecticus.rb +28 -0
  30. data/sys/aro/open_system/projector.rb +103 -0
  31. data/sys/aro/oss_open_menu.rb +29 -48
  32. data/sys/aro/oss_open_system.rb +117 -0
  33. data/sys/aro/p.rb +0 -11
  34. data/sys/aro/plugins.rb +106 -0
  35. data/sys/aro/settings/cor.rb +97 -54
  36. data/sys/aro/settings/git.rb +0 -25
  37. data/sys/aro/settings/ssh.rb +15 -30
  38. data/sys/aro/store.rb +34 -15
  39. data/sys/aro/v.rb +1 -1
  40. data/sys/ma_ain.rb +115 -36
  41. data/sys/reiquire.rb +1 -0
  42. data/sys/shr/prompt.rb +14 -3
  43. data/sys/shr/version.rb +1 -4
  44. data/tasks/make.rake +2 -3
  45. metadata +38 -5
  46. data/sys/aro/r.rb +0 -22
data/sys/aro/designer.rb CHANGED
@@ -13,9 +13,7 @@
13
13
  module Aro
14
14
  module Dom
15
15
  class Designer
16
- ACTION_LJUST = 27
17
- VALUE_LJUST = 27
18
- CLASS_LJUST = 27
16
+ ITEM_TITLE_JUSTIFY = 28
19
17
 
20
18
  def self.design_oss_om
21
19
  oss_home_path = File.expand_path(Dir.pwd)
@@ -37,10 +35,9 @@ module Aro
37
35
  Aro::P.say("run the following commands to continue:")
38
36
  Aro::P.say("$ cd #{Aro::Cor.ivar(:OSS_OM_HOME)} && oss_om")
39
37
  Aro::P.say("exiting...")
40
- exit
38
+ Aro::Dom::Ma_ain.exec_quit!
41
39
  else
42
- # restarts Aro::Dom::Ma_ain.reign!
43
- raise "needs install!"
40
+ Aro::Dom::Ma_ain.instance.reign!
44
41
  end
45
42
  design
46
43
  end
@@ -62,7 +59,7 @@ module Aro
62
59
  case selected_menu_item_uuid.to_sym
63
60
  when :back
64
61
  # todo: call_stack_bread_crumbs
65
- Aro::Dom::Ma_ain.back!
62
+ Aro::Dom::Ma_ain.open!
66
63
  when :open_menu
67
64
  design_menu(
68
65
  Aro::Dom::Ma_ain.instance.current_menu
@@ -128,9 +125,9 @@ module Aro
128
125
 
129
126
  item_mapper = Proc.new{|mi|
130
127
  {
131
- name: "(edit_item)".ljust(ACTION_LJUST) +
132
- "#{mi.localized_name}".ljust(VALUE_LJUST) +
133
- "#{mi.class.name}(#{mi.id})".ljust(CLASS_LJUST),
128
+ name: "(edit_item)".ljust(ITEM_TITLE_JUSTIFY) +
129
+ "#{mi.localized_name}".ljust(ITEM_TITLE_JUSTIFY) +
130
+ "#{mi.class.name}(#{mi.id})".ljust(ITEM_TITLE_JUSTIFY),
134
131
  value: mi.uuid
135
132
  }
136
133
  }
@@ -142,20 +139,20 @@ module Aro
142
139
  value: :back
143
140
  },
144
141
  {
145
- name: "(#{Aro::Dom::Ma_ain::UNICODE_KEYS[:yinyang]}) toggle_run_mode".ljust(ACTION_LJUST) +
146
- ":#{Aro::Dom::Ma_ain::RUN_MODES[Aro::Dom::Ma_ain.instance.run_mode || Aro::Mancy::O]}".ljust(VALUE_LJUST) +
147
- "available_modes: #{Aro::Dom::Ma_ain::RUN_MODES.to_s}".ljust(CLASS_LJUST),
142
+ name: "(#{Aro::Dom::Ma_ain::UNICODE_KEYS[:yinyang]}) toggle_run_mode".ljust(ITEM_TITLE_JUSTIFY) +
143
+ ":#{Aro::Dom::Ma_ain::RUN_MODES[Aro::Dom::Ma_ain.instance.run_mode || Aro::Mancy::O]}".ljust(ITEM_TITLE_JUSTIFY) +
144
+ "available_modes: #{Aro::Dom::Ma_ain::RUN_MODES.to_s}".ljust(ITEM_TITLE_JUSTIFY),
148
145
  value: :toggle_run_mode
149
146
  },
150
147
  {
151
- name: "(#{Aro::Dom::Ma_ain::UNICODE_KEYS[:yinyang]}) open_shell".ljust(ACTION_LJUST) +
152
- "open a bash session".ljust(VALUE_LJUST),
148
+ name: "(#{Aro::Dom::Ma_ain::UNICODE_KEYS[:yinyang]}) open_shell".ljust(ITEM_TITLE_JUSTIFY) +
149
+ "open a bash session".ljust(ITEM_TITLE_JUSTIFY),
153
150
  value: :open_shell
154
151
  },
155
152
  {
156
- name: "(edit_title)".ljust(ACTION_LJUST) +
157
- "#{menu.localized_name}".ljust(VALUE_LJUST) +
158
- "#{menu.class.name}(#{menu.id})".ljust(CLASS_LJUST),
153
+ name: "(edit_title)".ljust(ITEM_TITLE_JUSTIFY) +
154
+ "#{menu.localized_name}".ljust(ITEM_TITLE_JUSTIFY) +
155
+ "#{menu.class.name}(#{menu.id})".ljust(ITEM_TITLE_JUSTIFY),
159
156
  value: :edit_title
160
157
  }
161
158
  ] +
@@ -163,9 +160,9 @@ module Aro
163
160
  menu.menu_items.select{|mi| mi.system?}.map{|mi| item_mapper.call(mi)} +
164
161
  [
165
162
  {
166
- name: "(create_item)".ljust(ACTION_LJUST) +
167
- "add new item to #{menu.localized_name}".ljust(VALUE_LJUST) +
168
- "#{Aro::Dom::MenuItem.name}(+)".ljust(CLASS_LJUST),
163
+ name: "(create_item)".ljust(ITEM_TITLE_JUSTIFY) +
164
+ "add new item to #{menu.localized_name}".ljust(ITEM_TITLE_JUSTIFY) +
165
+ "#{Aro::Dom::MenuItem.name}(+)".ljust(ITEM_TITLE_JUSTIFY),
169
166
  value: :create_item
170
167
  }
171
168
  ]
@@ -218,15 +215,15 @@ module Aro
218
215
  value: :back
219
216
  },
220
217
  {
221
- name: "(edit_title)".ljust(ACTION_LJUST) +
222
- "#{menu_item.localized_name}".ljust(VALUE_LJUST) +
223
- "#{menu_item.class.name}(#{menu_item.id})".ljust(CLASS_LJUST),
218
+ name: "(edit_title)".ljust(ITEM_TITLE_JUSTIFY) +
219
+ "#{menu_item.localized_name}".ljust(ITEM_TITLE_JUSTIFY) +
220
+ "#{menu_item.class.name}(#{menu_item.id})".ljust(ITEM_TITLE_JUSTIFY),
224
221
  value: :edit_title
225
222
  },
226
223
  {
227
- name: "(edit_action)".ljust(ACTION_LJUST) +
228
- "#{menu_item.action_display_text}".ljust(VALUE_LJUST) +
229
- "Aro::Dom::MenuItem::Action(+)".ljust(CLASS_LJUST),
224
+ name: "(edit_action)".ljust(ITEM_TITLE_JUSTIFY) +
225
+ "#{menu_item.action_display_text}".ljust(ITEM_TITLE_JUSTIFY) +
226
+ "Aro::Dom::MenuItem::Action(+)".ljust(ITEM_TITLE_JUSTIFY),
230
227
  value: :edit_action
231
228
  }
232
229
  ]
@@ -271,15 +268,15 @@ module Aro
271
268
  value: :back
272
269
  },
273
270
  {
274
- name: "(edit_type)".ljust(ACTION_LJUST) +
275
- "#{menu_item.action_storage_key}".ljust(VALUE_LJUST) +
276
- "#{Aro::Dom::Action.name}(#{action_name})".ljust(CLASS_LJUST),
271
+ name: "(edit_type)".ljust(ITEM_TITLE_JUSTIFY) +
272
+ "#{menu_item.action_storage_key}".ljust(ITEM_TITLE_JUSTIFY) +
273
+ "#{Aro::Dom::Action.name}(#{action_name})".ljust(ITEM_TITLE_JUSTIFY),
277
274
  value: :edit_type
278
275
  },
279
276
  {
280
- name: "(edit_method)".ljust(ACTION_LJUST) +
281
- "#{menu_item.action_display_text}".ljust(VALUE_LJUST) +
282
- "Aro::Dom::MenuItem::Action(#{action_name})".ljust(CLASS_LJUST),
277
+ name: "(edit_method)".ljust(ITEM_TITLE_JUSTIFY) +
278
+ "#{menu_item.action_display_text}".ljust(ITEM_TITLE_JUSTIFY) +
279
+ "Aro::Dom::MenuItem::Action(#{action_name})".ljust(ITEM_TITLE_JUSTIFY),
283
280
  value: :edit_method
284
281
  }
285
282
  ]
@@ -309,9 +306,9 @@ module Aro
309
306
  }
310
307
  ] + Aro::Dom::Action::TYPES.keys.map{|k|
311
308
  {
312
- name: "(#{k})".ljust(ACTION_LJUST) +
313
- "#{menu_item.localized_name}".ljust(VALUE_LJUST) +
314
- "#{menu_item.class.name}(#{menu_item.id})".ljust(CLASS_LJUST),
309
+ name: "(#{k})".ljust(ITEM_TITLE_JUSTIFY) +
310
+ "#{menu_item.localized_name}".ljust(ITEM_TITLE_JUSTIFY) +
311
+ "#{menu_item.class.name}(#{menu_item.id})".ljust(ITEM_TITLE_JUSTIFY),
315
312
  value: k
316
313
  }
317
314
  }
@@ -329,6 +326,105 @@ module Aro
329
326
  end
330
327
  end
331
328
 
329
+ def self.design_plugin_for(chapter_menu_item)
330
+ action_data = chapter_menu_item.store.safe_get_key("action_data") || {}
331
+ raise "missing action data for #{chapter_menu_item.inspect}!" if action_data.nil? ||
332
+ !action_data.kind_of?(Hash)
333
+
334
+ action_data = ensure_action_data_oss_om_type_exists!(action_data)
335
+
336
+ return design_schema_for(chapter_menu_item) if action_data["oss_om_type"].to_s == :key_value_store.to_s
337
+
338
+ plugin_file_path = Aro::Dom::Plugins.choose_plugin
339
+
340
+ return if plugin_file_path == false
341
+
342
+ raise "missing plugin! #{plugin_file_path}" unless ::File.exist?(plugin_file_path)
343
+
344
+ new_action_data = {
345
+ plugin_file_path: plugin_file_path,
346
+ oss_om_type: action_data["oss_om_type"].to_s
347
+ }
348
+ Aro::P.say("enabled #{plugin_file_path} plugin.")
349
+ puts JSON.pretty_generate(new_action_data)
350
+ chapter_menu_item.aro_file.write!({
351
+ action_data: new_action_data
352
+ })
353
+ end
354
+
355
+ def self.design_schema_for(chapter_menu_item)
356
+ action_data = chapter_menu_item.store.safe_get_key("action_data") || {}
357
+ raise "missing action data for #{chapter_menu_item.inspect}!" if action_data.nil? ||
358
+ !action_data.kind_of?(Hash)
359
+
360
+ action_data = ensure_action_data_oss_om_type_exists!(action_data)
361
+
362
+ return design_plugin_for(chapter_menu_item) if action_data["oss_om_type"].to_s == :plugin.to_s
363
+
364
+ action_data_copy = action_data.except(:oss_om_type.to_s).dup
365
+ loop do
366
+ options = [
367
+ {name: :back, value: :back},
368
+ {name: "new_key(+)", value: :new_key}
369
+ ] + action_data_copy.map{|k, v|
370
+ {name: "#{k}(#{v})", value: k}
371
+ } + [
372
+ {name: :save, value: :save},
373
+ ]
374
+
375
+ selected_option = Aro::P.default_select(
376
+ I18n.t("open_menu.design_schema_for", localized_name: chapter_menu_item.localized_name),
377
+ options
378
+ )
379
+
380
+ case selected_option.to_sym
381
+ when :back
382
+ confirmed = true
383
+ if action_data_copy.any?{|k, v| action_data[k] != v} ||
384
+ (action_data_copy.keys & action_data.keys).count != action_data.keys.count
385
+ confirmed = get_new_value_from_user(
386
+ "unsaved changes exist. leave schema designer?",
387
+ "press enter to confirm ('n' to cancel):"
388
+ ).nil?
389
+ end
390
+ break if confirmed
391
+ when :save
392
+ action_data_copy[:oss_om_type.to_s] = action_data["oss_om_type"].to_s
393
+ chapter_menu_item.aro_file.write!({
394
+ action_data: action_data_copy
395
+ })
396
+ break
397
+ when :new_key
398
+ # create new key
399
+ new_key = get_new_value_from_user("enter new key: ")
400
+ next if new_key.nil?
401
+ if action_data_copy.keys.include?(new_key)
402
+ # confirm overwrite?
403
+ confirm_overwrite = get_new_value_from_user(
404
+ "key #{new_key} already exists.",
405
+ "press enter to confirm ('n' to cancel):"
406
+ )
407
+ unless confirm_overwrite.nil?
408
+ Aro::P.say("user cancelled")
409
+ next
410
+ end
411
+ end
412
+ action_data_copy[new_key] = get_new_value_from_user(
413
+ "enter new value for #{new_key}:",
414
+ )
415
+ Aro::P.say("set #{new_key} to #{action_data_copy[new_key]}")
416
+ else
417
+ # edit selected key
418
+ action_data_copy[selected_option] = get_new_value_from_user(
419
+ "enter new value for #{selected_option}:",
420
+ )
421
+ Aro::P.say("set #{selected_option} to #{action_data_copy[selected_option]}")
422
+ end
423
+ end
424
+
425
+ Aro::Dom::Ma_ain.navigate_to!(chapter_menu_item.menu)
426
+ end
427
+
332
428
  def self.get_new_value_from_user(ask_text, prompt_text_override = nil)
333
429
  Aro::P.say(__method__)
334
430
  new_val = nil
@@ -336,7 +432,7 @@ module Aro
336
432
  while new_val.nil? && !user_cancelled
337
433
  Aro::P.say(ask_text)
338
434
  puts "\n"
339
- new_val = Aro::P.p.ask(prompt_text_override || I18n.t("open_menu.get_new_value_from_user"))
435
+ new_val = Aro::Prompt.ask(prompt_text_override || I18n.t("open_menu.get_new_value_from_user"))
340
436
  user_cancelled = new_val.nil? || new_val.empty?
341
437
  new_val = nil if user_cancelled
342
438
  end
@@ -345,6 +441,30 @@ module Aro
345
441
  return new_val
346
442
  end
347
443
 
444
+ private
445
+
446
+ def self.ensure_action_data_oss_om_type_exists!(data)
447
+ unless data.keys.include?(:oss_om_type.to_s)
448
+ # ensure oss_om_type is set
449
+ options = [
450
+ {name: :key_value_store, value: :key_value_store},
451
+ {name: :plugin, value: :plugin}
452
+ ]
453
+
454
+ selected_option = Aro::P.default_select(
455
+ "select chapter schema oss_om_type: ",
456
+ options
457
+ )
458
+
459
+ case selected_option.to_sym
460
+ when :key_value_store, :plugin
461
+ data["oss_om_type"] = selected_option.to_s
462
+ end
463
+ end
464
+
465
+ data
466
+ end
467
+
348
468
  end
349
469
  end
350
470
  end
@@ -0,0 +1,78 @@
1
+ # frozen_string_literal: true
2
+
3
+ =begin
4
+
5
+ imports.rb
6
+
7
+ aro dom imports.
8
+
9
+ by i2097i
10
+
11
+ =end
12
+
13
+ module Aro
14
+ module Dom
15
+ class Imports
16
+
17
+ def self.get_plain_text_import(prompt_text)
18
+ ensure_imports_dir_exists!
19
+
20
+ options = [
21
+ {name: :back, value: :back}
22
+ ] + Dir[::File.join(imports_dir, "*")].map{|f|
23
+ {name: ::File.basename(f), value: f}
24
+ }
25
+
26
+ selected_option = Aro::P.default_select(
27
+ prompt_text,
28
+ options
29
+ )
30
+
31
+ return false if selected_option.kind_of?(Symbol) &&
32
+ selected_option == :back
33
+
34
+ raise "invalid file path! #{selected_option}" unless File.exist?(selected_option)
35
+
36
+ Aro::P.say("selected import: #{selected_option}")
37
+ confirmed = Aro::P.p.ask(
38
+ I18n.t(
39
+ "open_menu.imports.confirm_import",
40
+ file_name: File.basename(selected_option),
41
+ prompt_text: prompt_text
42
+ )
43
+ )
44
+
45
+ if :y.to_s != confirmed
46
+ Aro::P.say(I18n.t("open_menu.imports.user_cancelled"))
47
+ return false
48
+ end
49
+
50
+ # ready to read import
51
+ ::File.read(selected_option)
52
+ end
53
+
54
+ def self.imports_dir
55
+ ::File.join(Aro::Cor.ivar(:OSS_OM_HOME), :imports.to_s)
56
+ end
57
+
58
+ private
59
+
60
+ def self.ensure_imports_dir_exists!
61
+ FileUtils.mkdir_p(imports_dir) unless Dir.exist?(imports_dir)
62
+ ensure_import_default_files_exists!
63
+ end
64
+
65
+ def self.ensure_import_default_files_exists!
66
+ [
67
+ [".keep", ""],
68
+ ["sample.txt", "sample text"]
69
+ ].each{|a|
70
+ file_path = ::File.join(imports_dir, a[Aro::Mancy::O])
71
+ ::File.open(file_path, "w+") {|f|
72
+ f.write(a[Aro::Mancy::S])
73
+ } unless ::File.exist?(file_path)
74
+ }
75
+ end
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,202 @@
1
+ # frozen_string_literal: true
2
+
3
+ =begin
4
+
5
+ library.rb
6
+
7
+ aro dom library.
8
+
9
+ by i2097i
10
+
11
+ =end
12
+
13
+ module Aro
14
+ module Dom
15
+ class Library
16
+
17
+ EXEC_METHODS = [
18
+ :create_book!,
19
+ ]
20
+
21
+ BOOK_PARAMS = {
22
+ title: nil,
23
+ author_name: nil,
24
+ isbn: nil,
25
+ copyright_year: nil,
26
+ published_by: nil
27
+ }
28
+
29
+ def self.open!
30
+ Aro::Dom::Ma_ain.open!(:library)
31
+ end
32
+
33
+ def self.import_book!(book_yaml)
34
+ # todo: validate book_yaml
35
+ is_valid = true
36
+ raise "invalid book_yaml" unless is_valid
37
+
38
+ puts :todo_import_book_yaml
39
+ Aro::Dom::Ma_ain.sane_backtrace!
40
+ end
41
+
42
+ def self.navigate_to_book!(menu_uuid = nil)
43
+ book_menu = Aro::Dom::Menu.find_by(uuid: menu_uuid)
44
+ raise "invalid uuid! #{menu_uuid}" if book_menu.nil?
45
+
46
+ Aro::Dom::Ma_ain.navigate_to!(book_menu)
47
+ end
48
+
49
+ def self.information!(menu_item_uuid = nil, data = {})
50
+ information_menu_item = Aro::Dom::MenuItem.find_by(uuid: menu_item_uuid)
51
+ raise "invalid uuid! #{menu_item_uuid}" if information_menu_item.nil?
52
+
53
+ puts TTY::Font.new(:standard).write(
54
+ information_menu_item.localized_name,
55
+ letter_spacing: 1
56
+ )
57
+ Aro::P.less(JSON.pretty_generate(data))
58
+ end
59
+
60
+ def self.table_of_contents!(menu_item_uuid = nil)
61
+ table_of_contents_menu_item = Aro::Dom::MenuItem.find_by(uuid: menu_item_uuid)
62
+ raise "invalid uuid! #{menu_item_uuid}" if table_of_contents_menu_item.nil?
63
+
64
+ puts TTY::Font.new(:standard).write(
65
+ :"f.open_chapter".to_s,
66
+ letter_spacing: 1
67
+ )
68
+
69
+ contents_menu = Aro::Dom::Book.open_table_of_contents!(
70
+ table_of_contents_menu_item
71
+ )
72
+
73
+ Aro::Dom::Ma_ain.navigate_to!(contents_menu)
74
+ end
75
+
76
+ def self.create_book!
77
+ # the book model is inline simple-form schema.
78
+ # every value treated as a string and not required.
79
+
80
+ # get a copy of the book params hash
81
+ book_params = Aro::Dom::Library::BOOK_PARAMS.dup
82
+
83
+ while book_params.any?{|k, v| v.nil?} do
84
+ options = [
85
+ {name: :back, value: :back}
86
+ ] + book_params.map{|k, v|
87
+ {name: "#{k.to_s.ljust(Aro::Dom::Designer::ITEM_TITLE_JUSTIFY)} (#{v.nil? ? :not_set : v})", value: k}
88
+ }
89
+
90
+ selected_option = Aro::P.default_select(
91
+ I18n.t("open_menu.library.new_book_select"),
92
+ options
93
+ )
94
+
95
+ case selected_option.to_sym
96
+ when :back
97
+ confirmed = true
98
+ if book_params.any?{|k, v| !v.nil?}
99
+ confirmed = Aro::P.p.ask(I18n.t("open_menu.library.unsaved_changes_confirm")).to_sym
100
+ confirmed = confirmed == :y
101
+ end
102
+ return Aro::Dom::Library.open! if confirmed
103
+ when :title, :author_name, :isbn, :copyright_year, :published_by
104
+ new_value = Aro::Dom::Designer.get_new_value_from_user(selected_option)
105
+ Aro::P.say("setting #{selected_option} to #{new_value}")
106
+ book_params[selected_option] = new_value
107
+ end
108
+ end
109
+
110
+ unless generate_new_book!(book_params)
111
+ raise "book title must be unique!"
112
+ end
113
+ end
114
+
115
+ private
116
+
117
+ def self.generate_new_book!(book_params)
118
+ new_book_title_key = "#{book_params[:title].downcase}".gsub(" ", "_").to_sym
119
+
120
+ book_menu = open_book(
121
+ new_book_title_key,
122
+ book_params
123
+ )
124
+
125
+ directory = book_data_base.data_base_directories.find_by(
126
+ unix_path: new_book_title_key
127
+ )
128
+ return false if directory.nil?
129
+
130
+ # generate menus data_base > library menu item for new book here
131
+ library_menu = Aro::Dom::DataBase.open_menu(:library)
132
+ library_contents_item = library_menu.generate_new_item(new_book_title_key, for_type: :system)
133
+ library_contents_item.aro_file.write!(
134
+ Aro::Dom::Store.build_exec_oss_om_params!(
135
+ new_book_title_key,
136
+ Aro::Dom::Library,
137
+ "navigate_to_book!",
138
+ [directory.uuid]
139
+ )
140
+ )
141
+
142
+ # open and navigate to new book
143
+ Aro::Dom::Ma_ain.navigate_to!(book_menu)
144
+ return true
145
+ end
146
+
147
+ def self.open_book(book_title_sym, book_params = nil)
148
+ # get the books directory
149
+ data_base_directory = book_data_base.data_base_directories.find_or_create_by(
150
+ unix_path: book_title_sym
151
+ )
152
+
153
+ book_menu = Aro::Dom::Menu.find_by(uuid: data_base_directory.uuid)
154
+ if book_menu.nil?
155
+ # find or create the new book_menu
156
+ book_menu = Aro::Dom::Menu.create(uuid: data_base_directory.uuid)
157
+ Aro::Dom::Locale.add_i18n_key(
158
+ book_title_sym.to_s,
159
+ new_i18n_display_key: book_menu.uuid
160
+ )
161
+ end
162
+
163
+ generate_book_items_for!(book_menu, book_params)
164
+
165
+ # return the book_menu
166
+ return book_menu
167
+ end
168
+
169
+ def self.book_data_base
170
+ Aro::Dom::DataBase.find_or_create_by(unix_path: :books)
171
+ end
172
+
173
+ def self.generate_book_items_for!(book_menu, book_params)
174
+ raise "invalid book_menu!" if book_menu.nil?
175
+ return unless !book_menu.nil? && book_menu.menu_items.empty?
176
+
177
+ # validate book_params
178
+ # todo: validate uniqueness of params
179
+ raise "invalid book_params! #{book_params}" unless book_params.all?{|k, v| !v.nil?} &&
180
+ book_params.keys.all?{|k| Aro::Dom::Library::BOOK_PARAMS.keys.include?(k.to_sym)}
181
+
182
+ [:information, :table_of_contents].each{|k|
183
+ i = book_menu.generate_new_item(k, for_type: :system)
184
+
185
+ # store book book_param values with :information menu item
186
+ action_data = k == :information ? book_params : {}
187
+
188
+ i.aro_file.write!(
189
+ Aro::Dom::Store.build_exec_oss_om_params!(
190
+ k,
191
+ Aro::Dom::Library,
192
+ "#{k}!",
193
+ [i.uuid],
194
+ action_data
195
+ )
196
+ )
197
+ }
198
+ end
199
+
200
+ end
201
+ end
202
+ end
data/sys/aro/locale.rb CHANGED
@@ -15,7 +15,7 @@ module Aro
15
15
  class Locale
16
16
 
17
17
  def self.add_i18n_key(user_input_text, library_name: :menus, new_i18n_display_key: nil)
18
- Aro::P.say(__method__)
18
+ Aro::D.say(__method__)
19
19
  library_yaml = load_library(library_name: library_name)
20
20
  new_i18n_display_key = i18n_keyify_text(user_input_text) if new_i18n_display_key.nil?
21
21
 
@@ -70,12 +70,12 @@ module Aro
70
70
 
71
71
  def self.i18n_keyify_text(text)
72
72
  # downcase'd, gsub non-word characters with "_"
73
- text.downcase.gsub(/[\W]/, "_")
73
+ "#{text.downcase}".gsub(/[\W]/, "_")
74
74
  end
75
75
 
76
76
  def self.i18n_valuify_text(text)
77
77
  # gsub non-word characters with " "
78
- text.to_s.gsub(/[\W]/, " ")
78
+ text.to_s.gsub(/[\W]/, " ")&.strip
79
79
  end
80
80
 
81
81
  private
@@ -94,7 +94,7 @@ module Aro
94
94
  Reiquire.configure_i18n
95
95
  return false
96
96
  end
97
- puts library_yaml.inspect
97
+ Aro::V.say(library_yaml.inspect)
98
98
 
99
99
  default_locale = library_yaml[
100
100
  I18n.default_locale.to_s
data/sys/aro/mancy.rb CHANGED
@@ -14,7 +14,7 @@
14
14
 
15
15
  module Aro
16
16
  class Mancy
17
- include Singleton
17
+
18
18
  A = :"@"
19
19
  O = 0
20
20
  S = 1
@@ -96,7 +96,7 @@ module Aro
96
96
  end
97
97
 
98
98
  def self.domain
99
- is_initialized? ? "#{Aro::Mancy.aro_mancy_name}#{Aro::Mancy::A}#{Aro::Mancy}" : `whoami`.strip
99
+ is_initialized? ? "#{Aro::Mancy.aro_mancy_name}#{Aro::Mancy::A}#{Aro::Mancy.name}" : `whoami`.strip
100
100
  end
101
101
 
102
102
  def self.aro_mancy_name
@@ -26,10 +26,7 @@ module Aro
26
26
  private
27
27
 
28
28
  def do_encryption_stuff
29
- Aro::P.say(__method__)
30
- Aro::P.say("todo: #{self.class.name}")
31
- Aro::P.say(self.class.inspect)
32
- Aro::Dom::Ma_ain.i2097i_bookmark
29
+ puts "todo: #{__method__}"
33
30
  end
34
31
  end
35
32
  end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ =begin
4
+
5
+ cubicus.rb
6
+
7
+ aro dom cubicus menu.
8
+
9
+ by i2097i
10
+
11
+ =end
12
+
13
+ require_relative "./menu"
14
+
15
+ class Aro::Dom::Cubicus < Aro::Dom::Menu
16
+
17
+ EXEC_METHODS = [
18
+ # ...
19
+ ]
20
+
21
+ def generate_open_system!
22
+ return unless is_menu_named?(:open_system) &&
23
+ menu_items.empty?
24
+
25
+ [:create_glyph].each{|k|
26
+ i = generate_new_item(k, for_type: :system)
27
+
28
+ i.aro_file.write!(
29
+ Aro::Dom::Store.build_exec_oss_om_params!(
30
+ k,
31
+ Aro::Dom::Glyph,
32
+ "#{k}!",
33
+ [i.uuid],
34
+ {}
35
+ )
36
+ )
37
+ }
38
+ end
39
+ end