aro 0.2.6 → 0.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +5 -2
- data/README.md +10 -54
- data/aro.gemspec +6 -3
- data/bin/oss_om +2 -0
- data/checksums/aro-0.2.7.gem.sha512 +1 -0
- data/checksums/aro-0.2.8.gem.sha512 +1 -0
- data/listen.rb +1 -1
- data/locale/en.cor.yml +28 -35
- data/locale/en.yml +23 -60
- data/sys/aro/action.rb +132 -0
- data/sys/aro/book.rb +150 -0
- data/sys/aro/d.rb +3 -1
- data/sys/aro/db/migrate/1793913747_create_data_bases.rb +2 -0
- data/sys/aro/db/migrate/1793913777_create_data_base_directories.rb +2 -0
- data/sys/aro/db/migrate/1793913796_create_data_base_files.rb +2 -0
- data/sys/aro/db/migrate/1793913841_create_menus.rb +2 -0
- data/sys/aro/db/migrate/1793913861_create_menu_items.rb +3 -2
- data/sys/aro/db.rb +19 -33
- data/sys/aro/designer.rb +291 -102
- data/sys/aro/imports.rb +78 -0
- data/sys/aro/library.rb +202 -0
- data/sys/aro/locale.rb +4 -2
- data/sys/aro/mancy.rb +6 -39
- data/sys/aro/models/concerns/tar_go_for_root_sec.rb +34 -0
- data/sys/aro/models/concerns/uuid.rb +2 -0
- data/sys/aro/models/data_base.rb +73 -11
- data/sys/aro/models/directory.rb +3 -5
- data/sys/aro/models/file.rb +3 -1
- data/sys/aro/models/menu.rb +65 -1
- data/sys/aro/models/menu_item.rb +68 -4
- data/sys/aro/oss_open_menu.rb +307 -0
- data/sys/aro/p.rb +15 -9
- data/sys/aro/plugins.rb +104 -0
- data/sys/aro/r.rb +2 -0
- data/sys/aro/{cor.rb → settings/cor.rb} +163 -220
- data/sys/aro/settings/git.rb +44 -0
- data/sys/aro/settings/ssh.rb +108 -0
- data/sys/aro/store.rb +111 -37
- data/sys/aro/v.rb +3 -1
- data/sys/aro.rb +2 -0
- data/sys/ma_ain.rb +271 -0
- data/sys/reiquire.rb +41 -54
- data/sys/shr/prompt.rb +6 -1
- data/sys/shr/version.rb +8 -8
- data/tasks/make.rake +2 -3
- metadata +39 -24
- data/locale/en.cards.yml +0 -519
- data/locale/en.cmd.yml +0 -34
- data/locale/en.usage.yml +0 -142
- data/sys/aro/cmd.rb +0 -96
- data/sys/aro/db/migrate/1763374647_create_tecks.rb +0 -20
- data/sys/aro/db/migrate/1763432541_create_tlogs.rb +0 -20
- data/sys/aro/ma_ain.rb +0 -54
- data/sys/aro/models/teck.rb +0 -251
- data/sys/aro/models/tlog.rb +0 -21
- data/sys/aro/views/base.rb +0 -25
- data/sys/aro/views/teck.rb +0 -30
- data/sys/cli/constants.rb +0 -45
- data/sys/cli/create.rb +0 -23
- data/sys/cli/nterface.rb +0 -37
- data/sys/cli/teck.rb +0 -107
- data/sys/cli/usage.rb +0 -25
- data/sys/cli.rb +0 -23
- data/sys/shr/t.rb +0 -74
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
=begin
|
|
4
|
+
|
|
5
|
+
ssh.rb
|
|
6
|
+
|
|
7
|
+
aro dom ssh.
|
|
8
|
+
|
|
9
|
+
by i2097i
|
|
10
|
+
|
|
11
|
+
=end
|
|
12
|
+
|
|
13
|
+
module Aro
|
|
14
|
+
module Dom
|
|
15
|
+
class Ssh
|
|
16
|
+
EXEC_METHODS = [
|
|
17
|
+
:print_public_key,
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
ID_KEY_BASE = :id_oss_om
|
|
21
|
+
|
|
22
|
+
def self.open!
|
|
23
|
+
Aro::Dom::Ma_ain.open!(:ssh)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def self.encryption_installed?
|
|
27
|
+
::File.exist?(id_key_path) &&
|
|
28
|
+
::File.exist?("#{id_key_path}.pub") &&
|
|
29
|
+
!encrypt!({not: :equal}).kind_of?(Hash)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def self.print_public_key
|
|
33
|
+
Aro::P.less(::File.read("#{id_key_path}.pub"))
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def self.write_encrypted_file!(file_path, decrypted_json)
|
|
37
|
+
# todo: validations
|
|
38
|
+
#
|
|
39
|
+
# 1) encrypt decrypted_json
|
|
40
|
+
# 2) write encrypted contents
|
|
41
|
+
# 3) return success/failure
|
|
42
|
+
begin
|
|
43
|
+
# open and write
|
|
44
|
+
::File.open(file_path, "w+") do |f|
|
|
45
|
+
f.write(
|
|
46
|
+
encrypt!(decrypted_json)
|
|
47
|
+
)
|
|
48
|
+
end
|
|
49
|
+
rescue StandardError => e
|
|
50
|
+
Aro::P.say("#{self.name}:#{__method__}")
|
|
51
|
+
Aro::P.say(e.inspect)
|
|
52
|
+
return e
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
return true
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def self.decrypt_file!(file_path)
|
|
59
|
+
# 1) open file
|
|
60
|
+
# 2) decrypt contents
|
|
61
|
+
# 3) return decrypted contents
|
|
62
|
+
begin
|
|
63
|
+
# read and decrypt
|
|
64
|
+
decrypted_json = decrypt!(
|
|
65
|
+
JSON.parse(
|
|
66
|
+
::File.read(file_path, encoding: "UTF-8")
|
|
67
|
+
)
|
|
68
|
+
)
|
|
69
|
+
rescue JSON::ParserError => e
|
|
70
|
+
Aro::P.say("#{self.name}:#{__method__}")
|
|
71
|
+
Aro::P.say(e.inspect)
|
|
72
|
+
return e
|
|
73
|
+
rescue StandardError => e
|
|
74
|
+
Aro::P.say("#{self.name}:#{__method__}")
|
|
75
|
+
Aro::P.say(e.inspect)
|
|
76
|
+
return e
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
decrypted_json
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def self.id_key_path
|
|
83
|
+
id_path = ::File.join(Aro::Cor.ivar(:OSS_OM_HOME), Aro::Dom::Ssh::ID_KEY_BASE.to_s)
|
|
84
|
+
raise "missing_id_key!" if Aro::Dom::Ma_ain.is_initialized? && !::File.exist?(id_path)
|
|
85
|
+
id_path
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
private
|
|
89
|
+
|
|
90
|
+
def self.encrypt!(decrypted_json)
|
|
91
|
+
# Aro::Dom::Ma_ain.sane_backtrace!
|
|
92
|
+
# puts __method__
|
|
93
|
+
# puts :expects_decrypted_json
|
|
94
|
+
|
|
95
|
+
return decrypted_json
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def self.decrypt!(encrypted_json)
|
|
99
|
+
# Aro::Dom::Ma_ain.sane_backtrace!
|
|
100
|
+
# puts __method__
|
|
101
|
+
# puts :expects_encrypted_json
|
|
102
|
+
|
|
103
|
+
return encrypted_json
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
end
|
data/sys/aro/store.rb
CHANGED
|
@@ -32,22 +32,93 @@ class Aro::Dom::Store
|
|
|
32
32
|
def self.edit(aro_file, updates)
|
|
33
33
|
return if aro_file.nil?
|
|
34
34
|
unless ::File.exist?(aro_file.aro_file_path)
|
|
35
|
-
::File.write(aro_file.aro_file_path,
|
|
35
|
+
::File.write(aro_file.aro_file_path, {}.to_json)
|
|
36
36
|
end
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
Aro::Dom::Ma_ain.sane_backtrace!
|
|
39
|
+
puts :todo_validate_updates_or_depricate
|
|
40
|
+
puts __method__
|
|
41
|
+
|
|
42
|
+
store_instance = Aro::Dom::Ma_ain.instance.get_store_for(aro_file)
|
|
43
|
+
updates.each{|k, v|
|
|
44
|
+
store_instance.save_key_value_pair(k, v)
|
|
45
|
+
Aro::D.say([
|
|
46
|
+
"reading in #{k} after setting to #{v} in #{aro_file.aro_file_path}",
|
|
47
|
+
"got value => #{store_instance.safe_get_key(k)}"
|
|
48
|
+
])
|
|
49
|
+
}
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def save_key_value_pair(k, v)
|
|
53
|
+
set_key(k, v)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def save_exec_oss_om_params!(
|
|
57
|
+
label,
|
|
58
|
+
oss_om_const,
|
|
59
|
+
oss_om_method,
|
|
60
|
+
oss_om_params = [],
|
|
61
|
+
oss_om_data = {}
|
|
62
|
+
)
|
|
63
|
+
Aro::P.say(__method__)
|
|
64
|
+
Aro::Dom::Ma_ain.instance.store_mutex.synchronize do
|
|
65
|
+
built = self.class.build_exec_oss_om_params!(
|
|
66
|
+
label,
|
|
67
|
+
oss_om_const,
|
|
68
|
+
oss_om_method,
|
|
69
|
+
oss_om_params,
|
|
70
|
+
oss_om_data
|
|
71
|
+
)
|
|
72
|
+
built.each{|k, v| self.set_key(k, v)}
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def self.build_exec_oss_om_params!(
|
|
77
|
+
label,
|
|
78
|
+
oss_om_const,
|
|
79
|
+
oss_om_method,
|
|
80
|
+
oss_om_params = [],
|
|
81
|
+
oss_om_data = {}
|
|
82
|
+
)
|
|
83
|
+
Aro::P.say(__method__)
|
|
84
|
+
# {
|
|
85
|
+
# action_name:,
|
|
86
|
+
# action_key: Aro::Dom::Action::TYPES[:OSS_OM][:key],
|
|
87
|
+
# action_params: {
|
|
88
|
+
# aro_class_name:,
|
|
89
|
+
# aro_class_method:,
|
|
90
|
+
# aro_call_params:,
|
|
91
|
+
# }
|
|
92
|
+
# action_data:
|
|
93
|
+
# }
|
|
94
|
+
raise "invalid oss_om_const! #{oss_om_const}" unless Aro::Dom::Oss_OpenMenu::EXEC_CLASSES.include?(oss_om_const.name)
|
|
95
|
+
raise "invalid oss_om_method! #{oss_om_method}" unless oss_om_const.methods.include?(oss_om_method.to_sym)
|
|
96
|
+
|
|
97
|
+
# todo: validate oss_om_params && oss_om_data
|
|
98
|
+
|
|
99
|
+
{
|
|
100
|
+
action_name: label,
|
|
101
|
+
action_key: :exec_oss_om,
|
|
102
|
+
action_params: {
|
|
103
|
+
aro_class_name: oss_om_const.name,
|
|
104
|
+
aro_class_method: oss_om_method,
|
|
105
|
+
aro_call_params: oss_om_params || []
|
|
106
|
+
},
|
|
107
|
+
action_data: oss_om_data.stringify_keys
|
|
108
|
+
}
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def safe_get_key(k)
|
|
112
|
+
safe_key = nil
|
|
39
113
|
Aro::Dom::Ma_ain.instance.store_mutex.synchronize do
|
|
40
|
-
|
|
41
|
-
updates.each{|k, v|
|
|
42
|
-
store_instance.set_key(k, v)
|
|
43
|
-
Aro::P.say([
|
|
44
|
-
"reading in #{k} after setting to #{v} in #{aro_file.aro_file_path}",
|
|
45
|
-
"got value => #{store_instance.get_key(k)}"
|
|
46
|
-
])
|
|
47
|
-
}
|
|
114
|
+
safe_key = get_key(k)
|
|
48
115
|
end
|
|
116
|
+
|
|
117
|
+
safe_key
|
|
49
118
|
end
|
|
50
119
|
|
|
120
|
+
private
|
|
121
|
+
|
|
51
122
|
def get_key(key)
|
|
52
123
|
return if open_file_path.nil?
|
|
53
124
|
|
|
@@ -62,20 +133,19 @@ class Aro::Dom::Store
|
|
|
62
133
|
# open storage
|
|
63
134
|
@is_open = true
|
|
64
135
|
storage_contents = {}
|
|
65
|
-
|
|
136
|
+
@parser_error = Aro::Dom::Ssh.decrypt_file!(open_file_path)
|
|
137
|
+
unless @parser_error.kind_of?(StandardError) ||
|
|
138
|
+
StandardError.subclasses.include?(@parser_error.class)
|
|
139
|
+
|
|
140
|
+
# return value from Aro::Dom::Ssh.decrypt_file!
|
|
141
|
+
# is not an error.
|
|
142
|
+
storage_contents = @parser_error
|
|
66
143
|
@parser_error = nil
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
)
|
|
71
|
-
rescue StandardError => e
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
unless @parser_error.nil?
|
|
72
147
|
@is_open = false
|
|
73
|
-
|
|
74
|
-
@parser_error = e
|
|
75
|
-
return get_key(key)
|
|
76
|
-
else
|
|
77
|
-
raise @parser_error
|
|
78
|
-
end
|
|
148
|
+
raise @parser_error
|
|
79
149
|
end
|
|
80
150
|
|
|
81
151
|
# only update the cache value if present in storage
|
|
@@ -106,25 +176,25 @@ class Aro::Dom::Store
|
|
|
106
176
|
|
|
107
177
|
# return if storage open
|
|
108
178
|
# non-persisted cache values update next cycle
|
|
109
|
-
return if @is_open
|
|
179
|
+
return true if @is_open
|
|
110
180
|
|
|
111
181
|
# open storage
|
|
112
182
|
@is_open = true
|
|
113
183
|
storage_contents = {}
|
|
114
|
-
|
|
184
|
+
|
|
185
|
+
@parser_error = Aro::Dom::Ssh.decrypt_file!(open_file_path)
|
|
186
|
+
unless @parser_error.kind_of?(StandardError) ||
|
|
187
|
+
StandardError.subclasses.include?(@parser_error.class)
|
|
188
|
+
|
|
189
|
+
# return value from Aro::Dom::Ssh.decrypt_file!
|
|
190
|
+
# is not an error.
|
|
191
|
+
storage_contents = @parser_error
|
|
115
192
|
@parser_error = nil
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
)
|
|
120
|
-
rescue StandardError => e
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
unless @parser_error.nil?
|
|
121
196
|
@is_open = false
|
|
122
|
-
|
|
123
|
-
@parser_error = e
|
|
124
|
-
return get_key(key)
|
|
125
|
-
else
|
|
126
|
-
raise @parser_error
|
|
127
|
-
end
|
|
197
|
+
raise @parser_error
|
|
128
198
|
end
|
|
129
199
|
|
|
130
200
|
# update storage and cache
|
|
@@ -136,12 +206,16 @@ class Aro::Dom::Store
|
|
|
136
206
|
}
|
|
137
207
|
|
|
138
208
|
# write storage
|
|
139
|
-
::
|
|
140
|
-
|
|
209
|
+
write_result = Aro::Dom::Ssh.write_encrypted_file!(open_file_path, storage_contents.to_json)
|
|
210
|
+
unless write_result == true
|
|
211
|
+
@is_open = false
|
|
212
|
+
raise write_result
|
|
141
213
|
end
|
|
142
214
|
|
|
143
215
|
# close storage
|
|
144
216
|
@is_open = false
|
|
145
217
|
clear_cache! if @clear_flag
|
|
218
|
+
|
|
219
|
+
write_result
|
|
146
220
|
end
|
|
147
221
|
end
|
data/sys/aro/v.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
=begin
|
|
2
4
|
|
|
3
5
|
v.rb
|
|
@@ -18,7 +20,7 @@ module Aro
|
|
|
18
20
|
end
|
|
19
21
|
|
|
20
22
|
def self.should_print?
|
|
21
|
-
Aro::Cor.ivar(:VERBOSE).to_s == Aro::Cor::BOOLS[:TRUE].to_s
|
|
23
|
+
Aro::Cor.ivar(:VERBOSE).to_s == Aro::Cor::BOOLS[:TRUE].to_s
|
|
22
24
|
end
|
|
23
25
|
end
|
|
24
26
|
end
|
data/sys/aro.rb
CHANGED
data/sys/ma_ain.rb
ADDED
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
=begin
|
|
4
|
+
|
|
5
|
+
ma_ain.rb
|
|
6
|
+
|
|
7
|
+
aro dom ma_ain.
|
|
8
|
+
|
|
9
|
+
by i2097i
|
|
10
|
+
|
|
11
|
+
=end
|
|
12
|
+
|
|
13
|
+
module Aro
|
|
14
|
+
module Dom
|
|
15
|
+
class Ma_ain < Aro::Mancy
|
|
16
|
+
# inherits Singleton
|
|
17
|
+
|
|
18
|
+
# evolution planning
|
|
19
|
+
#
|
|
20
|
+
# Cor (copy of Aro::Cor)
|
|
21
|
+
# Engine
|
|
22
|
+
# Designer
|
|
23
|
+
# Git
|
|
24
|
+
# Ssh
|
|
25
|
+
# Block (copy of Aro::Dom::DataBase)
|
|
26
|
+
# Chain (copy of Aro::Dom::Directory)
|
|
27
|
+
# Node (copy of Aro::Dom::File)
|
|
28
|
+
# List (copy of Aro::Dom::Menu)
|
|
29
|
+
# ListItem (copy of Aro::Dom::MenuItem)
|
|
30
|
+
#
|
|
31
|
+
#
|
|
32
|
+
|
|
33
|
+
EXEC_METHODS = [
|
|
34
|
+
:exec_library!,
|
|
35
|
+
:exec_settings!,
|
|
36
|
+
:exec_quit!
|
|
37
|
+
]
|
|
38
|
+
|
|
39
|
+
RUN_MODES = [
|
|
40
|
+
:design,
|
|
41
|
+
:run
|
|
42
|
+
]
|
|
43
|
+
|
|
44
|
+
UNICODE_KEYS = {
|
|
45
|
+
bang: "\u0021",
|
|
46
|
+
check: "\u2713",
|
|
47
|
+
close: "\u2A2F",
|
|
48
|
+
integral: "\u222B",
|
|
49
|
+
secure: "\u266F",
|
|
50
|
+
unsecure: "\u266D",
|
|
51
|
+
yinyang: "\u262F",
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
attr_accessor :current_menu, :previous_menu
|
|
55
|
+
attr_accessor :data_mutex, :store_mutex
|
|
56
|
+
attr_accessor :stores
|
|
57
|
+
# todo: unused currently. init instance with hashing algo stuff
|
|
58
|
+
attr_accessor :valid_security
|
|
59
|
+
attr_accessor :run_mode
|
|
60
|
+
|
|
61
|
+
def reign!
|
|
62
|
+
begin
|
|
63
|
+
# default mode is :run
|
|
64
|
+
self.run_mode = Aro::Dom::Ma_ain::S
|
|
65
|
+
Aro::P.say("Aro::Dom::Oss_OpenMenu.install!")
|
|
66
|
+
if Aro::Dom::Oss_OpenMenu.install!
|
|
67
|
+
Aro::P.say("Aro::Dom::Oss_OpenMenu.boot!")
|
|
68
|
+
Aro::Dom::Oss_OpenMenu.boot!
|
|
69
|
+
else
|
|
70
|
+
Aro::P.say("installation failed. exiting now...")
|
|
71
|
+
exit
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
self.run_mode = !Aro::Cor.is_production? ? Aro::Dom::Ma_ain::O : Aro::Dom::Ma_ain::S
|
|
75
|
+
Aro::P.say("Aro::Dom::Designer.design")
|
|
76
|
+
Aro::Dom::Designer.design
|
|
77
|
+
rescue RuntimeError => e
|
|
78
|
+
Aro::P.say("#{e.class}! #{e.inspect}")
|
|
79
|
+
raise e
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def initialize
|
|
84
|
+
self.data_mutex = Mutex.new
|
|
85
|
+
self.store_mutex = Mutex.new
|
|
86
|
+
|
|
87
|
+
@stores = {}
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def self.sane_backtrace!
|
|
91
|
+
return if Aro::Cor.is_production?
|
|
92
|
+
|
|
93
|
+
backtrace = Thread.current.backtrace[Aro::Mancy::S..].reverse.map{|l|
|
|
94
|
+
l.gsub("#{Reiquire.gem_dir}", "").gsub(Aro::Mancy.root_dir, "")
|
|
95
|
+
}.last(Aro::Mancy::V).join("\n")
|
|
96
|
+
|
|
97
|
+
if Aro::Cor.ivar(:VERBOSE).to_s == :true.to_s
|
|
98
|
+
Aro::P.less(backtrace)
|
|
99
|
+
else
|
|
100
|
+
puts(backtrace)
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def self.init!
|
|
105
|
+
root_dir_path = Aro::Cor.ivar(:OSS_OM_HOME)
|
|
106
|
+
return false if root_dir_path.nil? || !Dir.exist?(root_dir_path)
|
|
107
|
+
Aro::P.say("#{self.name} initializing in #{root_dir_path}")
|
|
108
|
+
Aro::Mancy.init(root_dir_path)
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def self.is_encrypted?
|
|
112
|
+
Aro::Dom::Ssh.encryption_installed? &&
|
|
113
|
+
!self.instance.valid_security.nil?
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
def self.domain
|
|
117
|
+
self.instance.current_menu.nil? ? super : "#{Aro::Mancy.aro_mancy_name}#{Aro::Mancy::A}#{Aro::Dom::Ma_ain}"
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
def self.mini_hud_for(display_text = nil)
|
|
121
|
+
cryption_text = UNICODE_KEYS[
|
|
122
|
+
is_encrypted? ? :secure : :unsecure
|
|
123
|
+
] + UNICODE_KEYS[:bang]
|
|
124
|
+
|
|
125
|
+
if is_encrypted?
|
|
126
|
+
cryption_text = "#{UNICODE_KEYS[:secure]}#{UNICODE_KEYS[:bang]}"
|
|
127
|
+
else
|
|
128
|
+
cryption_text = "#{UNICODE_KEYS[:unsecure]}#{UNICODE_KEYS[:bang]}"
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
mode_text = Aro::Dom::Ma_ain::RUN_MODES[self.instance.run_mode || Aro::Mancy::O]
|
|
132
|
+
[
|
|
133
|
+
"(#{cryption_text})[#{mode_text}: ",
|
|
134
|
+
display_text
|
|
135
|
+
].join("")
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
def self.ps1_display(cls_name = nil)
|
|
139
|
+
super(domain)
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
def self.navigate_to!(menu)
|
|
143
|
+
|
|
144
|
+
raise "invalid menu!" if menu.nil? || !menu.kind_of?(Aro::Dom::Menu)
|
|
145
|
+
raise "invalid directory for #{menu.inspect}!" if menu.directory.nil?
|
|
146
|
+
data_base = menu.directory.data_base
|
|
147
|
+
raise "invalid data_base!" if data_base.nil?
|
|
148
|
+
|
|
149
|
+
open_menu(menu)
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
def self.open!(data_base = :ma_ain)
|
|
153
|
+
Aro::P.say("Aro::Dom::DataBase.open_menu(#{data_base})")
|
|
154
|
+
staged_menu = nil
|
|
155
|
+
begin
|
|
156
|
+
staged_menu = Aro::Dom::DataBase.open_menu(data_base)
|
|
157
|
+
rescue StandardError => e
|
|
158
|
+
raise "#{self.name} error opening data_base '#{data_base}'! #{e.inspect}"
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
if data_base.to_sym == :ma_ain && self.instance.valid_security.nil?
|
|
162
|
+
self.instance.valid_security = staged_menu.uuid
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
open_menu(staged_menu)
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
def self.toggle_run_mode
|
|
169
|
+
self.instance.run_mode = self.instance.run_mode == 0 ? 1 : 0
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
def self.running?
|
|
173
|
+
Aro::Dom::Ma_ain::RUN_MODES[self.instance.run_mode || Aro::Mancy::O] == :run
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
def self.get_current_options
|
|
177
|
+
options = []
|
|
178
|
+
|
|
179
|
+
options << {back: :back, value: :back} unless self.instance.current_menu.uuid == self.instance.valid_security
|
|
180
|
+
|
|
181
|
+
unless Aro::Cor.ivar(:HIDE_F_OSS_OM_MENU).to_s == "true"
|
|
182
|
+
options << {name: "#{UNICODE_KEYS[:integral]}(#{Aro::Mancy::ARO_DIRECTORY})", value: :open_menu}
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
options += self.instance.current_menu.menu_items.select{|mi| mi.user?}.map{|mi| mi.as_tty}
|
|
186
|
+
options += self.instance.current_menu.menu_items.select{|mi| mi.system?}.map{|mi| mi.as_tty}
|
|
187
|
+
|
|
188
|
+
options
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
def self.exec_library!
|
|
192
|
+
Aro::Dom::Ma_ain.open!(:library)
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
def self.exec_settings!
|
|
196
|
+
Aro::Dom::Ma_ain.open!(:settings)
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
def self.exec_quit!
|
|
200
|
+
exit
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
def get_store_for(aro_file)
|
|
204
|
+
raise "invalid aro_file!" if aro_file.nil?
|
|
205
|
+
|
|
206
|
+
if @stores[aro_file.uuid].nil?
|
|
207
|
+
new_store = Aro::Dom::Store.new
|
|
208
|
+
new_store.open_file_path = aro_file.aro_file_path
|
|
209
|
+
@stores[aro_file.uuid] = new_store
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
return Aro::Dom::Ma_ain.instance.stores[aro_file.uuid]
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
def self.run_plugin!(chapter_menu_item, action_data)
|
|
216
|
+
plugin_file_path = action_data["plugin_file_path"]
|
|
217
|
+
|
|
218
|
+
raise "invalid plugin_file_path! #{plugin_file_path}" if plugin_file_path.nil? ||
|
|
219
|
+
!::File.exist?(plugin_file_path)
|
|
220
|
+
|
|
221
|
+
new_action_data = action_data.dup
|
|
222
|
+
|
|
223
|
+
data_callback = Proc.new{|d|
|
|
224
|
+
if d.kind_of?(Hash)
|
|
225
|
+
d["plugin_file_path"] = action_data["plugin_file_path"]
|
|
226
|
+
d["oss_om_type"] = action_data["oss_om_type"]
|
|
227
|
+
# self.instance.store_mutex.synchronize do
|
|
228
|
+
chapter_menu_item.aro_file.write!({
|
|
229
|
+
action_data: d
|
|
230
|
+
})
|
|
231
|
+
# end
|
|
232
|
+
end
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
require action_data["plugin_file_path"]
|
|
236
|
+
plugin_thread_action_data = action_data.dup
|
|
237
|
+
plugin_const = nil
|
|
238
|
+
begin
|
|
239
|
+
plugin_const = "Aro::Dom::#{
|
|
240
|
+
::File.basename(
|
|
241
|
+
action_data[:plugin_file_path.to_s]
|
|
242
|
+
).to_s.downcase.split(".")[
|
|
243
|
+
Aro::Dom::Ma_ain::O
|
|
244
|
+
].split("_").map{|w| w.capitalize}.join("")
|
|
245
|
+
}".constantize
|
|
246
|
+
|
|
247
|
+
raise "must respond_to :oss_om_start!" unless plugin_const.respond_to?(:oss_om_start!)
|
|
248
|
+
|
|
249
|
+
if plugin_const.respond_to?(:configure_plugin_callback)
|
|
250
|
+
plugin_const.configure_plugin_callback(data_callback)
|
|
251
|
+
data_callback.call(plugin_const.oss_om_start!(plugin_thread_action_data))
|
|
252
|
+
new_action_data = nil
|
|
253
|
+
else
|
|
254
|
+
new_action_data = plugin_const.oss_om_start!(plugin_thread_action_data)
|
|
255
|
+
end
|
|
256
|
+
rescue StandardError => e
|
|
257
|
+
Aro::P.say("plugin thread threw an error: #{e}")
|
|
258
|
+
new_action_data = nil
|
|
259
|
+
end
|
|
260
|
+
|
|
261
|
+
data_callback.call(new_action_data) unless new_action_data.nil?
|
|
262
|
+
end
|
|
263
|
+
|
|
264
|
+
private
|
|
265
|
+
|
|
266
|
+
def self.open_menu(menu)
|
|
267
|
+
self.instance.current_menu = menu
|
|
268
|
+
end
|
|
269
|
+
end
|
|
270
|
+
end
|
|
271
|
+
end
|