aro 0.2.9 → 0.3.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e01261ca4ed5bbcd2cc2201a4c6848d189edd299b71cb3bcd19680e6f7587714
4
- data.tar.gz: 32e93c9a8c4e1104ce378c9eb59f96e042345332246f5572a30c7bbd1d085ece
3
+ metadata.gz: cc3f0a78f7877d2544884c051c685690f6f165c7542a30148a9c4a9a2b9515d9
4
+ data.tar.gz: 1baace7ed33148a2cb78c132460275c7592fb10c09e2baca3e3b78255a74a31f
5
5
  SHA512:
6
- metadata.gz: 3ac9214dbb4d14810eb5770be3329bee6d36e328196c108875e5a3b25715659f6953add8196201ac4164f37e2f7a51fcda4f048ef953051133fcd92b3c11ff8f
7
- data.tar.gz: f87cdd3ce23098cece61484954e2fff0538c9f847f9e751d22d5b8aa8f0e5a27ca3b2f9857e05067a5bc795f09e22ad17e348fcf399796741e8ba023dc78caf5
6
+ metadata.gz: 205eccd21e0327f192eab4188841b88c03e66a0d59969f0f3d63251ea5680e9f73c9e7d76282f8894f5abe14a1ebcba9eabaf05fe0fb72abcfc42794ccd6af05
7
+ data.tar.gz: 8aebe9cbea26d808de6c8fb74d99406e138cafe00a014b8b8f4fd11bca9f6437ab9d17936eb51a46914b2186b511e17f93abc3667d1ff71157ae243db6ab1b38
data/.gitignore CHANGED
@@ -6,3 +6,4 @@
6
6
  *.sql
7
7
  pkg/*
8
8
  success/*
9
+ *.DS_Store
data/Gemfile.lock CHANGED
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- aro (0.2.9)
4
+ aro (0.3.0)
5
5
  activerecord (~> 8.1, >= 8.1.4.1)
6
- f_dot (~> 0.0.2, >= 0.0.2)
6
+ f_dot (~> 0.0.3, >= 0.0.3)
7
7
  i18n (~> 1.15, >= 1.15.2)
8
8
  sqlite3 (~> 2.10, >= 2.10.2)
9
9
  tty-font (~> 0.5, >= 0.5.0)
@@ -37,7 +37,7 @@ GEM
37
37
  connection_pool (3.0.2)
38
38
  diff-lcs (1.6.2)
39
39
  drb (2.2.3)
40
- f_dot (0.0.2)
40
+ f_dot (0.0.3)
41
41
  tty-font (~> 0.5, >= 0.5.0)
42
42
  tty-prompt (~> 0.23, >= 0.23.1)
43
43
  ffi (1.17.4-aarch64-linux-gnu)
@@ -140,7 +140,7 @@ CHECKSUMS
140
140
  activemodel (8.1.4.1) sha256=063caf105372fbc98b2d789e4be23de63ac5c043f7d9330f04e2caddb7012805
141
141
  activerecord (8.1.4.1) sha256=bd65599ca0b5d210937f835d42c7aff69d271741c75aab022730be6cbce67e87
142
142
  activesupport (8.1.4.1) sha256=16ac4f341ca65c85a1fcdb8ac73f68891aae9e3c4a6f9c3a27daed8b00017ed7
143
- aro (0.2.9)
143
+ aro (0.3.0)
144
144
  base64 (0.3.0) sha256=27337aeabad6ffae05c265c450490628ef3ebd4b67be58257393227588f5a97b
145
145
  bigdecimal (4.1.3) sha256=61ebe1e5e559bdc3cc6f2c0ee7f427321fc838f59611c294356eb04d6e21cf66
146
146
  bundler (4.0.24) sha256=16ca64e20816a0cf151a948fb141d788602996d2b4d73577b74388fe84fa98bc
@@ -148,7 +148,7 @@ CHECKSUMS
148
148
  connection_pool (3.0.2) sha256=33fff5ba71a12d2aa26cb72b1db8bba2a1a01823559fb01d29eb74c286e62e0a
149
149
  diff-lcs (1.6.2) sha256=9ae0d2cba7d4df3075fe8cd8602a8604993efc0dfa934cff568969efb1909962
150
150
  drb (2.2.3) sha256=0b00d6fdb50995fe4a45dea13663493c841112e4068656854646f418fda13373
151
- f_dot (0.0.2)
151
+ f_dot (0.0.3)
152
152
  ffi (1.17.4-aarch64-linux-gnu) sha256=b208f06f91ffd8f5e1193da3cae3d2ccfc27fc36fba577baf698d26d91c080df
153
153
  ffi (1.17.4-aarch64-linux-musl) sha256=9286b7a615f2676245283aef0a0a3b475ae3aae2bb5448baace630bb77b91f39
154
154
  ffi (1.17.4-arm-linux-gnu) sha256=d6dbddf7cb77bf955411af5f187a65b8cd378cb003c15c05697f5feee1cb1564
data/aro.gemspec CHANGED
@@ -39,5 +39,5 @@ Gem::Specification.new do |spec|
39
39
  spec.add_runtime_dependency "sqlite3", "~> 2.10", ">= 2.10.2"
40
40
  spec.add_runtime_dependency "tty-prompt", "~> 0.23", ">= 0.23.1"
41
41
  spec.add_runtime_dependency "tty-font", "~> 0.5", ">= 0.5.0"
42
- spec.add_runtime_dependency "f_dot", "~> 0.0.2", ">= 0.0.2"
42
+ spec.add_runtime_dependency "f_dot", "~> 0.0.3", ">= 0.0.3"
43
43
  end
data/bin/oss_om CHANGED
@@ -20,11 +20,23 @@ begin
20
20
  # start websocket thread
21
21
  FDot::Based::Processor.instance.f_dot_space_override_path = Aro::Mancy.root_dir
22
22
  FDot::Based::Cubicus.instance.start_ws_thread
23
+ Thread.new{
24
+ begin
25
+ Aro::Dom::Ma_ain.instance.reign!
26
+ rescue StandardError => e
27
+ FDot::Based::Cubicus.run_exit_cleanup!
28
+ puts "rescued in aro binary: #{e}"
29
+ puts "exiting..."
30
+ exit
31
+ ensure
32
+ FDot::Based::Cubicus.run_exit_cleanup!
33
+ end
34
+ }.join
35
+ else
36
+ Aro::Dom::Ma_ain.instance.reign!
23
37
  end
24
-
25
- Aro::Dom::Ma_ain.instance.reign!
26
38
  rescue StandardError => e
27
- puts "rescued in aro bin for #{e}"
39
+ puts "rescued in aro binary: #{e}"
28
40
  puts Thread.current.backtrace
29
41
  raise e
30
42
  end
@@ -1 +1 @@
1
- 59c1276f49f9d1dc48f518df845f786e45a262dad963bb0e5ceda66dd88e7baa3f602e9da0605499d0bc987f78d0360e3929e20a3d904c081f91e910b44c5b65
1
+ 3105ae158bd9e2baed7e8a78ee4a4a4db70adc9e1275994ebdce7e31b5749f0aa9b912e4965989980cf5097721392f2f6a49a7d7cb34f95be13915385a270dab
@@ -0,0 +1 @@
1
+ 27a910ae76baaff66ca5e791feb0396a29047426e9250c76d7cb3bc201b9f2492d0ea653b05632711509743b2fbc2ba88aa8393446c34df591c524cb230dddaf
@@ -12,7 +12,7 @@
12
12
  # display (a regular browser tab can also be used)
13
13
  # for controls processing and rendering display to
14
14
  # the display (firefox docker container)
15
- # oss_om has three components within a project
15
+ # oss_om has four components within a project
16
16
  # 1) display:
17
17
  # a) a browser tab visiting the same url as the display docker container.
18
18
  # b) the display docker container
@@ -21,15 +21,16 @@
21
21
  # 3) history:
22
22
  # this is a gitea instance for oss_om encrypted storage
23
23
  # note: this is not implemented yet
24
+ # 4) editor:
25
+ # this is a linuxserver/code-server instance for local code editing
24
26
  #
25
-
26
27
  services:
27
28
  display:
28
29
  image: lscr.io/linuxserver/firefox:latest
29
30
  container_name: display
30
31
  environment:
31
- - PUID=1000
32
- - PGID=1000
32
+ - PUID=1000 # replace with host user id
33
+ - PGID=1000 # replace with host user group
33
34
  - TZ=Etc/UTC
34
35
  - FIREFOX_CLI=--kiosk http://host.docker.internal:8080/
35
36
  - SELKIES_UI_SHOW_SIDEBAR=false
@@ -39,7 +40,7 @@ services:
39
40
  volumes:
40
41
  - ./.oss_om/open_system/display:/config
41
42
  ports:
42
- - "3001:3001"
43
+ - "3001:3001" # use this to access display
43
44
  - "3000:3000"
44
45
  shm_size: "1gb"
45
46
  restart: unless-stopped
@@ -57,3 +58,23 @@ services:
57
58
  ports:
58
59
  - "2997:3000"
59
60
  - "2222:22"
61
+ editor:
62
+ image: lscr.io/linuxserver/code-server:latest
63
+ container_name: editor
64
+ environment:
65
+ - PUID=1000
66
+ - PGID=1000
67
+ - TZ=America/New_York
68
+ - PASSWORD=${EDITOR_PASSWORD-insecure_password}
69
+ volumes:
70
+ - ./.oss_om/open_system/editor:/config
71
+ ports:
72
+ # artificial intelligence tells me this keeps my editor web traffic local.
73
+ - "127.0.0.1:8443:8443"
74
+ networks:
75
+ - editor_network
76
+ restart: unless-stopped
77
+ networks:
78
+ editor_network:
79
+ driver: bridge
80
+
@@ -0,0 +1 @@
1
+ EDITOR_PASSWORD=vs_oss_om_editor
@@ -0,0 +1,8 @@
1
+ #! /bin/bash
2
+
3
+ # example run command for lan mode
4
+ # LOCAL_THREEJS=$HOME/base/three.js LOCALHOST_ONLY=false oss_om cubicus
5
+
6
+ gem install ../aro/pkg/aro-0.3.0.gem
7
+ gem install ../f_dot/pkg/f_dot-0.0.3.gem
8
+
data/locale/en.yml CHANGED
@@ -15,6 +15,8 @@ en:
15
15
  new_ivar_value_prompt: "enter new %{value_type} for %{def_key} (current is '%{current_value}'"
16
16
  edit_ivars_possible_values_select: "listing possible values for %{def_key}"
17
17
  design_schema_for: "designing schema for %{localized_name}"
18
+ design_json_schema_for: "designing json schema for %{localized_name}"
19
+ design_json_schema_new_key: "what type of data will %{localized_name} hold?"
18
20
  designer:
19
21
  create_menu: "enter display text for the new menu"
20
22
  imports:
data/sys/aro/action.rb CHANGED
@@ -108,7 +108,7 @@ module Aro
108
108
  end
109
109
 
110
110
  if data.keys.count > Aro::Mancy::O
111
- method_call_params << data.dup.stringify_keys
111
+ method_call_params << data.stringify_keys
112
112
  end
113
113
 
114
114
  oss_om_const = params[:aro_class_name].constantize
@@ -121,7 +121,7 @@ module Aro
121
121
  oss_om_const.send(params[:aro_class_method])
122
122
  end
123
123
  rescue NoMethodError => e
124
- puts Thread.main.backtrace
124
+ puts Thread.current.backtrace
125
125
  Aro::P.say("exec_oss_om error! #{e}")
126
126
  end
127
127
  end
data/sys/aro/book.rb CHANGED
@@ -36,12 +36,12 @@ module Aro
36
36
  unless action_data["oss_om_type"].nil?
37
37
  case action_data["oss_om_type"].to_sym
38
38
  when :key_value_store
39
- Aro::P.less(:going_to_design_schema)
40
39
  Aro::Dom::Designer.design_schema_for(chapter_menu_item)
41
40
  when :plugin
42
41
  Aro::P.less("Aro::Dom::Ma_ain.running? #{Aro::Dom::Ma_ain.running?}")
43
- if Aro::Dom::Ma_ain.running?
44
- Aro::P.less(:going_to_run_plugin_from_book)
42
+ if action_data.keys.include?(:plugin_file_path.to_s) &&
43
+ !action_data["plugin_file_path"].nil? &&
44
+ Aro::Dom::Ma_ain.running?
45
45
 
46
46
  Aro::Dom::Ma_ain.run_plugin!(chapter_menu_item, action_data)
47
47
  else
@@ -51,6 +51,8 @@ module Aro
51
51
  else
52
52
  Aro::Dom::Designer.design_schema_for(chapter_menu_item)
53
53
  end
54
+
55
+ Aro::Dom::Ma_ain.navigate_to!(chapter_menu_item.menu)
54
56
  end
55
57
 
56
58
  #
@@ -69,19 +71,9 @@ module Aro
69
71
 
70
72
  chapter_params = {
71
73
  title: "chapter_#{contents_menu.menu_items.count}", # auto-increment
72
- text: nil
73
74
  }
74
75
 
75
- while chapter_params[:text].nil?
76
- chapter_params[:text] = Aro::Dom::Imports.get_plain_text_import(
77
- "import plain text from file for #{chapter_params[:title]}: (choose file)"
78
- )
79
-
80
- return if chapter_params[:text] == false
81
- end
82
-
83
76
  chapter_menu_item = contents_menu.generate_new_item(chapter_params[:title], for_type: :system)
84
-
85
77
  chapter_menu_item.aro_file.write!(
86
78
  Aro::Dom::Store.build_exec_oss_om_params!(
87
79
  chapter_params[:title],
@@ -92,7 +84,7 @@ module Aro
92
84
  )
93
85
  )
94
86
 
95
- Aro::Dom::Ma_ain.navigate_to!(contents_menu)
87
+ open_chapter!(chapter_menu_item.uuid, chapter_params.stringify_keys)
96
88
  end
97
89
 
98
90
  # the table_of_contents menu_item:
data/sys/aro/db.rb CHANGED
@@ -63,7 +63,7 @@ module Aro
63
63
  end
64
64
 
65
65
  unless File.exist?(db_config_filepath)
66
- pw = Aro::P.p.ask(
66
+ pw = Aro::Prompt.ask(
67
67
  I18n.t(
68
68
  "open_menu.base_db_password_prompt",
69
69
  sql_filepath: self.class.sql_filepath.gsub(
data/sys/aro/designer.rb CHANGED
@@ -49,6 +49,7 @@ module Aro
49
49
  end
50
50
 
51
51
  Aro::P.say("Aro::Dom::Ma_ain.open!")
52
+ Aro::P.say("loading aro gem v#{Aro::VERSION}...")
52
53
  Aro::Dom::Ma_ain.open!
53
54
  loop do
54
55
  selected_menu_item_uuid = Aro::P.default_select(
@@ -196,6 +197,11 @@ module Aro
196
197
  Aro::Dom::Ma_ain.toggle_run_mode
197
198
  return
198
199
  when :open_shell
200
+ if FDot::DISPLAY_MODES[:websockets] == FDot::Based::Interface.instance.display_mode
201
+ Aro::P.say("cannot open bash from FDot::DISPLAY_MODES[:websockets] display mode!")
202
+ Aro::P.say("bash must be run in FDot::DISPLAY_MODES[:terminal] display mode.")
203
+ return
204
+ end
199
205
  Aro::P.say("starting bash session for #{`whoami`.strip}")
200
206
  system(:bash.to_s)
201
207
  else
@@ -334,6 +340,7 @@ module Aro
334
340
  action_data = ensure_action_data_oss_om_type_exists!(action_data)
335
341
 
336
342
  return design_schema_for(chapter_menu_item) if action_data["oss_om_type"].to_s == :key_value_store.to_s
343
+ return design_json_schema_for(chapter_menu_item) if action_data["oss_om_type"].to_s == :json_store.to_s
337
344
 
338
345
  plugin_file_path = Aro::Dom::Plugins.choose_plugin
339
346
 
@@ -352,6 +359,123 @@ module Aro
352
359
  })
353
360
  end
354
361
 
362
+ def self.design_json_schema_for(chapter_menu_item)
363
+ action_data = chapter_menu_item.store.safe_get_key("action_data") || {}
364
+ raise "missing action data for #{chapter_menu_item.inspect}!" if action_data.nil? ||
365
+ !action_data.kind_of?(Hash)
366
+
367
+ action_data = ensure_action_data_oss_om_type_exists!(action_data)
368
+ return design_plugin_for(chapter_menu_item) if action_data["oss_om_type"].to_s == :plugin.to_s
369
+ return design_schema_for(chapter_menu_item) if action_data["oss_om_type"].to_s == :key_value_store.to_s
370
+ action_data_copy = action_data.dup
371
+ loop do
372
+ options = [
373
+ {name: :back, value: :back},
374
+ {name: "new_key(+)", value: :new_key}
375
+ ] + action_data_copy.keys.map{|k|
376
+ value_display = action_data_copy[k].to_s
377
+ value_display = value_display.length > 5 ? value_display[0..5] + "..." : value_display
378
+ {name: "#{k}(#{value_display})", value: k}
379
+ } + [
380
+ {name: :save, value: :save}
381
+ ]
382
+
383
+ selected_option = Aro::P.default_select(
384
+ I18n.t("open_menu.design_json_schema_for", localized_name: chapter_menu_item.localized_name),
385
+ options
386
+ )
387
+
388
+ case selected_option.to_sym
389
+ when :back
390
+ confirmed = true
391
+ if action_data_copy.any?{|k, v| action_data[k] != v} ||
392
+ (action_data_copy.keys & action_data.keys).count != action_data.keys.count
393
+ confirmed = get_new_value_from_user(
394
+ "unsaved changes exist. leave schema designer?",
395
+ "press enter to confirm ('n' to cancel):"
396
+ ).nil?
397
+ end
398
+ break if confirmed
399
+ when :save
400
+ action_data_copy[:oss_om_type.to_s] = action_data["oss_om_type"].to_s
401
+ chapter_menu_item.aro_file.write!({
402
+ action_data: action_data_copy
403
+ })
404
+ break
405
+ when :new_key
406
+ # create new key
407
+ new_key = get_new_value_from_user("enter new key: ")
408
+ next if new_key.nil?
409
+ new_key = new_key.strip.gsub(/[\n\W]/, "_")
410
+ if action_data_copy.keys.include?(new_key)
411
+ # confirm overwrite?
412
+ confirm_overwrite = get_new_value_from_user(
413
+ "key #{new_key} already exists.",
414
+ "press enter to confirm ('n' to cancel):"
415
+ )
416
+ unless confirm_overwrite.nil?
417
+ Aro::P.say("user cancelled")
418
+ next
419
+ end
420
+ end
421
+
422
+ selected_data_type = Aro::P.default_select(
423
+ I18n.t("open_menu.design_json_schema_new_key", localized_name: new_key),
424
+ [{name: :cancel, value: :cancel}] + [
425
+ :boolean,
426
+ :number,
427
+ :string,
428
+ :hash,
429
+ :array
430
+ ].map{|k| {name: k, value: k}}
431
+ )
432
+
433
+ next if selected_data_type == :cancel
434
+
435
+ new_value = nil
436
+ case selected_data_type
437
+ when :boolean
438
+ new_value = true
439
+ new_value = Aro::P.default_select(
440
+ "new_value is set to #{new_value}",
441
+ [{name: :toggle, value: :toggle}, {name: :keep, value: :keep}]
442
+ ) == :keep
443
+ when :number
444
+ while !new_value.kind_of?(Numeric)
445
+ new_value = get_new_value_from_user(
446
+ "enter new #{selected_data_type} value for #{selected_option}:",
447
+ )
448
+ if !new_value.kind_of?(Numeric)
449
+ Aro::P.say("#{new_value} is invalid! expected numeric value.")
450
+ new_value = nil
451
+ end
452
+ end
453
+ when :string
454
+ new_value = get_new_value_from_user(
455
+ "enter new #{selected_data_type} value for #{selected_option}:",
456
+ )
457
+ when :hash
458
+ new_value = {}
459
+ when :array
460
+ new_value = []
461
+ end
462
+ action_data_copy[new_key] = new_value
463
+ Aro::P.say("set #{new_key} to #{action_data_copy[new_key]}")
464
+ else
465
+ # todo:
466
+ # Aro::P.say("todo: edit selected key #{selected_option}")
467
+ # case action_data_copy[selected_option]&.class
468
+ # when TrueClass, FalseClass:
469
+ # when Numeric:
470
+ # when String:
471
+ # when Hash:
472
+ # when Array:
473
+ # end
474
+ end
475
+ end
476
+
477
+ end
478
+
355
479
  def self.design_schema_for(chapter_menu_item)
356
480
  action_data = chapter_menu_item.store.safe_get_key("action_data") || {}
357
481
  raise "missing action data for #{chapter_menu_item.inspect}!" if action_data.nil? ||
@@ -360,6 +484,7 @@ module Aro
360
484
  action_data = ensure_action_data_oss_om_type_exists!(action_data)
361
485
 
362
486
  return design_plugin_for(chapter_menu_item) if action_data["oss_om_type"].to_s == :plugin.to_s
487
+ return design_json_schema_for(chapter_menu_item) if action_data["oss_om_type"].to_s == :json_store.to_s
363
488
 
364
489
  action_data_copy = action_data.except(:oss_om_type.to_s).dup
365
490
  loop do
@@ -433,6 +558,8 @@ module Aro
433
558
  Aro::P.say(ask_text)
434
559
  puts "\n"
435
560
  new_val = Aro::Prompt.ask(prompt_text_override || I18n.t("open_menu.get_new_value_from_user"))
561
+
562
+ puts "#{self.class.name} got new_val: #{new_val}"
436
563
  user_cancelled = new_val.nil? || new_val.empty?
437
564
  new_val = nil if user_cancelled
438
565
  end
@@ -448,18 +575,14 @@ module Aro
448
575
  # ensure oss_om_type is set
449
576
  options = [
450
577
  {name: :key_value_store, value: :key_value_store},
451
- {name: :plugin, value: :plugin}
578
+ {name: :plugin, value: :plugin},
579
+ {name: :json_store, value: :json_store}
452
580
  ]
453
581
 
454
- selected_option = Aro::P.default_select(
582
+ data["oss_om_type"] = Aro::P.default_select(
455
583
  "select chapter schema oss_om_type: ",
456
584
  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
585
+ ).to_s
463
586
  end
464
587
 
465
588
  data
data/sys/aro/imports.rb CHANGED
@@ -34,7 +34,7 @@ module Aro
34
34
  raise "invalid file path! #{selected_option}" unless File.exist?(selected_option)
35
35
 
36
36
  Aro::P.say("selected import: #{selected_option}")
37
- confirmed = Aro::P.p.ask(
37
+ confirmed = Aro::Prompt.ask(
38
38
  I18n.t(
39
39
  "open_menu.imports.confirm_import",
40
40
  file_name: File.basename(selected_option),
data/sys/aro/library.rb CHANGED
@@ -35,7 +35,7 @@ module Aro
35
35
  is_valid = true
36
36
  raise "invalid book_yaml" unless is_valid
37
37
 
38
- puts :todo_import_book_yaml
38
+ puts "todo_import_book_yaml"
39
39
  Aro::Dom::Ma_ain.sane_backtrace!
40
40
  end
41
41
 
@@ -95,8 +95,8 @@ module Aro
95
95
  case selected_option.to_sym
96
96
  when :back
97
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
98
+ unless book_params.all?{|k, v| v.nil?}
99
+ confirmed = Aro::Prompt.ask(I18n.t("open_menu.library.unsaved_changes_confirm")).to_sym
100
100
  confirmed = confirmed == :y
101
101
  end
102
102
  return Aro::Dom::Library.open! if confirmed
@@ -66,4 +66,12 @@ class Aro::Dom::Glyph < Aro::Dom::MenuItem
66
66
 
67
67
  Aro::Dom::Ma_ain.navigate_to!(create_glyph_menu_item.menu)
68
68
  end
69
+
70
+ def cubicus
71
+ self.menu
72
+ end
73
+
74
+ def open_system_action_data
75
+ self.store.safe_get_key("action_data") || {}
76
+ end
69
77
  end
@@ -103,7 +103,7 @@ class Aro::Dom::MenuItem < ActiveRecord::Base
103
103
  Aro::Dom::Ma_ain.sane_backtrace!
104
104
  puts __method__
105
105
  puts inspect
106
- puts :todo_implement_invalid_action_handling
106
+ puts "todo_implement_invalid_action_handling"
107
107
  end
108
108
  end
109
109
  end
@@ -28,12 +28,18 @@ module Aro
28
28
 
29
29
  DEFAULT_GLYPH = {
30
30
  "direction": 0,
31
- "position": {"x": 0, "y": 0, "z": 0}
31
+ "position": {"x": 0, "y": 0, "z": 0},
32
+ "oss_om_type": :json_store
33
+ }
34
+
35
+ DEFAULT_SPACE = {
36
+ "perspecticus": [],
37
+ "objecticus": [],
38
+ "camera_position": {"x": 1, "y": 1, "z": 1},
39
+ "camera_rotation": {"x": 1, "y": 1, "z": 1},
32
40
  }
33
41
 
34
- DEFAULT_SPACE = []
35
42
  attr_accessor :is_projecting
36
- attr_accessor :cubicus_uuid
37
43
  attr_accessor :glyph_uuid
38
44
  attr_accessor :open_system_space
39
45
  attr_accessor :glyph_action_data
@@ -43,33 +49,125 @@ module Aro
43
49
  # a projector receives user input on behalf of the glyph
44
50
  # a projector modifies the attributes of a glyph in accordance with user input
45
51
 
46
- def initialize(cubicus, glyph, glyph_action_data)
52
+ def self.valid_open_system_space_data?(data = {})
53
+ default_space_keys = Aro::Dom::Projector::DEFAULT_SPACE.keys.map{|k| k.to_s}
54
+ !data.nil? &&
55
+ !data.empty? &&
56
+ data.kind_of?(Hash) &&
57
+ (default_space_keys & data.keys).count == default_space_keys.count
58
+ end
59
+
60
+ def self.valid_open_system_glyph_data?(data = {})
61
+ default_glyph_keys = Aro::Dom::Projector::DEFAULT_GLYPH.keys.map{|k| k.to_s}
62
+ !data.nil? &&
63
+ !data.empty? &&
64
+ data.kind_of?(Hash) &&
65
+ (default_glyph_keys & data.keys).count == default_glyph_keys.count
66
+ end
67
+
68
+ def initialize(projected_from_glyph)
47
69
  self.glyph_action_data = {} # initialize
48
70
  self.open_system_space = {} # initialize
49
71
  self.is_projecting = false
50
- self.cubicus_uuid = cubicus.uuid
51
- self.glyph_uuid = glyph.uuid
72
+ self.glyph_uuid = projected_from_glyph.uuid
73
+ reload!
74
+ end
75
+
76
+ def reload!
77
+ unless self.class.valid_open_system_glyph_data?(
78
+ glyph.open_system_action_data
79
+ )
80
+ glyph.aro_file.write!(
81
+ {
82
+ "action_data": Aro::Dom::Projector::DEFAULT_GLYPH.dup.deep_stringify_keys
83
+ }
84
+ )
52
85
 
53
- self.glyph_action_data = glyph_action_data.empty? ? Aro::Dom::Projector::DEFAULT_GLYPH : glyph_action_data
86
+ glyph.store.clear_cache!
87
+ end
54
88
 
55
- # get open_system_data
56
- open_system_item = Aro::Dom::Oss_OpenSystem.instance.get_menu_item
57
- open_system_data = open_system_item.store.safe_get_key("action_data") || {}
58
- raise "missing action data for #{open_system_item}!" if open_system_data.nil? ||
59
- !open_system_data.kind_of?(Hash)
89
+ self.glyph_action_data = glyph.open_system_action_data.merge({uuid: glyph.uuid})
90
+
91
+ open_system_data = Aro::Dom::Oss_OpenSystem.instance.runtime_data["open_system_action_data"]
60
92
 
61
93
  # load projector with open_system_space
62
- self.open_system_space = open_system_data["open_system_space"] || Aro::Dom::Projector::DEFAULT_SPACE
94
+ if open_system_data.nil? ||
95
+ !open_system_data.kind_of?(Hash) ||
96
+ !self.class.valid_open_system_space_data?(open_system_data)
97
+
98
+ # set up default open_system_space
99
+ self.open_system_space = Aro::Dom::Projector::DEFAULT_SPACE.dup.deep_stringify_keys
100
+ else
101
+ self.open_system_space = open_system_data
102
+ end
103
+ self.open_system_space["perspecticus"] = []
104
+ self.open_system_space["objecticus"] = []
105
+ glyph.cubicus.menu_items.each{|menu_item|
106
+ # get open_system_action_data
107
+ item_data = menu_item.open_system_action_data
108
+ unless self.class.valid_open_system_glyph_data?(item_data)
109
+ # add new item to open space
110
+
111
+ menu_item.aro_file.write!({
112
+ "action_data": Aro::Dom::Projector::DEFAULT_GLYPH.dup.deep_stringify_keys
113
+ })
114
+ end
115
+
116
+ # only store the menu_item uuid references in open_system_space cubicus data
117
+ self.open_system_space[
118
+ menu_item.kind_of?(Aro::Dom::Objecticus) ? "objecticus" : "perspecticus"
119
+ ] << menu_item.open_system_action_data.merge(
120
+ {uuid: menu_item.uuid, localized_name: menu_item.localized_name}
121
+ );
122
+ }
123
+
124
+ # this writes the cubicus open_system space action_data
125
+ Aro::Dom::Oss_OpenSystem.instance.update_runtime_open_system(self.open_system_space)
126
+
63
127
  end
64
128
 
65
129
  def project!
130
+ if FDot::DISPLAY_MODES[:terminal] == FDot::Based::Interface.instance.display_mode
131
+ Aro::P.say(self.class.name)
132
+ Aro::P.say("open_system_space cannot be run in FDot::DISPLAY_MODES[:terminal] display mode!")
133
+ Aro::P.say("this must be done in the FDot::DISPLAY_MODES[:websockets] display mode.")
134
+ return
135
+ end
136
+ Aro::V.say(__method__)
66
137
  self.is_projecting = true
138
+ FDot::Based::Cubicus.project_open_system(
139
+ {
140
+ open_system_space: self.open_system_space,
141
+ projected_from_data: self.glyph_action_data
142
+ },
143
+ Proc.new{|projector_input|
144
+ raise "invalid position! #{projector_input["position"]}" unless projector_input["position"].kind_of?(Hash) &&
145
+ ["x", "y", "z"].all?{|k|
146
+ projector_input["position"].keys.include?(k) &&
147
+ !projector_input["position"][k].nil?
148
+ }
149
+ if projector_input["uuid"].nil?
150
+ Aro::Dom::Oss_OpenSystem.instance.current_projector.open_system_space["camera_position"] = projector_input["position"]
151
+ Aro::Dom::Oss_OpenSystem.instance.current_projector.open_system_space["camera_rotation"] = projector_input["rotation"]
152
+ Aro::Dom::Oss_OpenSystem.instance.update_runtime_open_system(
153
+ Aro::Dom::Oss_OpenSystem.instance.current_projector.open_system_space
154
+ )
155
+ else
156
+ raise "invalid projector_input!" unless projector_input["uuid"] == Aro::Dom::Oss_OpenSystem.instance.current_projector.glyph_uuid
157
+ d = Aro::Dom::Oss_OpenSystem.instance.current_projector.glyph.open_system_action_data
158
+ d["position"] = projector_input["position"]
159
+ Aro::Dom::Oss_OpenSystem.instance.current_projector.glyph.aro_file.write!({"action_data": d})
160
+ end
161
+ Aro::Dom::Oss_OpenSystem.instance.current_projector.reload!
162
+ Aro::Dom::Oss_OpenSystem.instance.current_projector.project!
163
+ }
164
+ )
67
165
 
68
166
  self.is_projecting = false
69
167
  end
70
168
 
71
169
  def glyph
72
- Aro::Dom::Glyph.find_by(uuid: self.glyph_uuid)
170
+ @glyph ||= Aro::Dom::Glyph.find_by(uuid: self.glyph_uuid)
73
171
  end
74
172
 
75
173
  def direction_name
@@ -167,6 +167,8 @@ module Aro
167
167
  "# ignore entire '.oss_om/' directory!",
168
168
  "#{Aro::Dom::Ma_ain::ARO_DIRECTORY.to_s}/*",
169
169
  "#",
170
+ "# ignore .env file",
171
+ "*.env",
170
172
  "#"
171
173
  ].join("\n"))
172
174
  f.write("\n")
@@ -19,19 +19,22 @@ module Aro
19
19
  attr_accessor :runtime_data
20
20
  attr_accessor :access_validated
21
21
  attr_accessor :f_dot_mutex
22
+ attr_accessor :current_projector
22
23
 
23
24
  EXEC_METHODS = [
24
25
  :start!
25
26
  ]
26
27
 
27
28
  DEFAULT_RUNTIME = {
28
- f_dot_action_data: nil
29
+ f_dot_action_data: nil,
30
+ open_system_action_data: nil
29
31
  }
30
32
 
31
33
  def initialize
32
34
  self.menu_item_uuid = nil
33
35
  self.runtime_data = Aro::Dom::Oss_OpenSystem::DEFAULT_RUNTIME.dup.stringify_keys
34
36
  self.f_dot_mutex = Mutex.new
37
+ self.current_projector = nil
35
38
  end
36
39
 
37
40
  def self.start!(menu_item_uuid = nil, action_data = {})
@@ -81,6 +84,18 @@ module Aro
81
84
  )
82
85
  end
83
86
 
87
+ def update_runtime_open_system(action_data)
88
+ if action_data.nil? ||
89
+ !action_data.kind_of?(Hash)
90
+
91
+ raise "invalid action data for #{action_data.inspect} in #{__method__}!"
92
+ end
93
+
94
+ self.runtime_data["open_system_action_data"] = action_data
95
+
96
+ self.write_runtime!
97
+ end
98
+
84
99
  def update_runtime_f_dot(action_data)
85
100
  if action_data.nil? ||
86
101
  !action_data.kind_of?(Hash)
@@ -98,18 +113,17 @@ module Aro
98
113
  end
99
114
 
100
115
  def self.open_projector!(glyph)
101
- cubicus_menu = glyph.menu
102
- raise "invalid cubicus for glyph!: #{glyph}" if cubicus_menu.nil? ||
103
- !cubicus_menu.kind_of?(Aro::Dom::Cubicus)
104
-
105
- action_data = glyph.store.safe_get_key("action_data") || {}
106
-
107
- raise "invalid action data! #{action_data}" unless action_data.kind_of?(Hash)
108
-
109
- projector = Aro::Dom::Projector.new(cubicus_menu, glyph, action_data)
110
- projector.project!
111
-
112
- Aro::P.less(projector.inspect)
116
+ raise "invalid cubicus for glyph!: #{glyph}" if glyph.cubicus.nil? ||
117
+ !glyph.cubicus.kind_of?(Aro::Dom::Cubicus)
118
+
119
+ begin
120
+ self.instance.current_projector = Aro::Dom::Projector.new(glyph)
121
+ self.instance.current_projector.project!
122
+ rescue StandardError => e
123
+ Aro::P.say(Thread.main.backtrace)
124
+ Aro::P.say("open_system projection error! #{e}")
125
+ raise e
126
+ end
113
127
  end
114
128
 
115
129
  end
data/sys/aro/plugins.rb CHANGED
@@ -36,7 +36,7 @@ module Aro
36
36
  raise "invalid file path! #{selected_option}" unless File.exist?(selected_option)
37
37
 
38
38
  Aro::P.say("selected plugin: #{selected_option}")
39
- confirmed = Aro::P.p.ask(
39
+ confirmed = Aro::Prompt.ask(
40
40
  I18n.t(
41
41
  "open_menu.plugins.confirm_plugin",
42
42
  file_name: File.basename(selected_option)
@@ -69,7 +69,7 @@ module Aro
69
69
  when :bool
70
70
  new_value = !(ivar(selected_def_key) == :true.to_s)
71
71
  when :int, :string
72
- new_value = Aro::P.p.ask(
72
+ new_value = Aro::Prompt.ask(
73
73
  I18n.t(
74
74
  "open_menu.new_ivar_value_prompt",
75
75
  def_key: selected_def_key,
data/sys/ma_ain.rb CHANGED
@@ -175,7 +175,7 @@ module Aro
175
175
  def self.get_current_options
176
176
  options = []
177
177
 
178
- options << {back: :back, value: :back} unless self.instance.current_menu.uuid == self.instance.valid_security
178
+ options << {name: :back, value: :back} unless self.instance.current_menu.uuid == self.instance.valid_security
179
179
 
180
180
  # show open_menu if not running or Aro::Cor ivar is set to false
181
181
  hide_preference = Aro::Cor.ivar(:HIDE_F_OSS_OM_MENU).to_s == "true"
@@ -223,6 +223,12 @@ module Aro
223
223
  end
224
224
 
225
225
  def self.run_plugin!(chapter_menu_item, action_data)
226
+ if FDot::DISPLAY_MODES[:websockets] == FDot::Based::Interface.instance.display_mode
227
+ Aro::P.say("plugins cannot be run in FDot::DISPLAY_MODES[:websockets] display mode!")
228
+ Aro::P.say("they must be run directly in the FDot::DISPLAY_MODES[:terminal] display mode.")
229
+ return
230
+ end
231
+
226
232
  plugin_file_path = action_data["plugin_file_path"]
227
233
 
228
234
  raise "invalid plugin_file_path! #{plugin_file_path}" if plugin_file_path.nil? ||
@@ -234,11 +240,9 @@ module Aro
234
240
  if d.kind_of?(Hash)
235
241
  d["plugin_file_path"] = action_data["plugin_file_path"]
236
242
  d["oss_om_type"] = action_data["oss_om_type"]
237
- # self.instance.store_mutex.synchronize do
238
- chapter_menu_item.aro_file.write!({
239
- action_data: d
240
- })
241
- # end
243
+ chapter_menu_item.aro_file.write!({
244
+ action_data: d
245
+ })
242
246
  end
243
247
  }
244
248
 
data/sys/shr/version.rb CHANGED
@@ -11,7 +11,7 @@
11
11
  =end
12
12
 
13
13
  module Aro
14
- VERSION = :"0.2.9"
14
+ VERSION = :"0.3.0"
15
15
  RELEASE_NOTES = [
16
16
  ].join(" | ")
17
17
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aro
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.9
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - i2097i
@@ -195,21 +195,21 @@ dependencies:
195
195
  requirements:
196
196
  - - "~>"
197
197
  - !ruby/object:Gem::Version
198
- version: 0.0.2
198
+ version: 0.0.3
199
199
  - - ">="
200
200
  - !ruby/object:Gem::Version
201
- version: 0.0.2
201
+ version: 0.0.3
202
202
  type: :runtime
203
203
  prerelease: false
204
204
  version_requirements: !ruby/object:Gem::Requirement
205
205
  requirements:
206
206
  - - "~>"
207
207
  - !ruby/object:Gem::Version
208
- version: 0.0.2
208
+ version: 0.0.3
209
209
  - - ">="
210
210
  - !ruby/object:Gem::Version
211
- version: 0.0.2
212
- description: "aro is a unix utility for designing and creating linux applications.\n0.2.9
211
+ version: 0.0.3
212
+ description: "aro is a unix utility for designing and creating linux applications.\n0.3.0
213
213
  release notes: "
214
214
  email:
215
215
  - i2097i@hotmail.com
@@ -243,7 +243,10 @@ files:
243
243
  - checksums/aro-0.2.7.gem.sha512
244
244
  - checksums/aro-0.2.8.gem.sha512
245
245
  - checksums/aro-0.2.9.gem.sha512
246
+ - checksums/aro-0.3.0.gem.sha512
246
247
  - craft_docker-compose.template
248
+ - craft_env.template
249
+ - craft_reinstall_gems.sh
247
250
  - listen.rb
248
251
  - locale/en.cor.yml
249
252
  - locale/en.menu_items.yml