aro 0.2.4 → 0.2.6
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/.gitignore +2 -2
- data/Gemfile.lock +126 -50
- data/LICENSE +1 -1
- data/README.md +1 -1
- data/aro.gemspec +10 -11
- data/bin/oss_om +15 -0
- data/checksums/aro-0.2.4.gem.sha512 +1 -0
- data/checksums/aro-0.2.5.gem.sha512 +1 -0
- data/checksums/aro-0.2.6.gem.sha512 +1 -0
- data/locale/en.cards.yml +19 -21
- data/locale/en.cmd.yml +34 -0
- data/locale/en.cor.yml +5 -8
- data/locale/en.menu_items.yml +2 -0
- data/locale/en.menus.yml +2 -0
- data/locale/en.usage.yml +24 -45
- data/locale/en.yml +61 -49
- data/sys/aro/cmd.rb +96 -0
- data/sys/{aos → aro}/cor.rb +224 -268
- data/sys/aro/d.rb +4 -3
- data/sys/aro/db/migrate/.DS_Store +0 -0
- data/sys/aro/db/migrate/1793913747_create_data_bases.rb +13 -0
- data/sys/aro/db/migrate/1793913777_create_data_base_directories.rb +14 -0
- data/sys/aro/db/migrate/1793913796_create_data_base_files.rb +12 -0
- data/sys/aro/db/migrate/1793913841_create_menus.rb +11 -0
- data/sys/aro/db/migrate/1793913861_create_menu_items.rb +14 -0
- data/sys/aro/db.rb +72 -33
- data/sys/aro/designer.rb +281 -0
- data/sys/aro/locale.rb +136 -0
- data/sys/aro/ma_ain.rb +54 -0
- data/sys/aro/mancy.rb +53 -28
- data/sys/aro/models/concerns/.keep +0 -0
- data/sys/aro/models/concerns/uuid.rb +29 -0
- data/sys/aro/models/data_base.rb +97 -0
- data/sys/aro/models/directory.rb +44 -0
- data/sys/aro/models/file.rb +27 -0
- data/sys/aro/models/menu.rb +27 -0
- data/sys/aro/models/menu_item.rb +47 -0
- data/sys/aro/models/teck.rb +40 -31
- data/sys/aro/p.rb +6 -3
- data/sys/aro/r.rb +1 -2
- data/sys/aro/store.rb +147 -0
- data/sys/aro/v.rb +2 -2
- data/sys/aro/views/base.rb +25 -0
- data/sys/aro/views/teck.rb +30 -0
- data/sys/aro.rb +1 -2
- data/sys/cli/constants.rb +1 -7
- data/sys/cli/create.rb +3 -3
- data/sys/cli/nterface.rb +8 -8
- data/sys/cli/teck.rb +17 -18
- data/sys/cli/usage.rb +4 -4
- data/sys/cli.rb +0 -1
- data/sys/reiquire.rb +146 -25
- data/sys/shr/.DS_Store +0 -0
- data/sys/shr/prompt.rb +8 -2
- data/sys/shr/t.rb +5 -5
- data/sys/shr/version.rb +9 -2
- data/tasks/make.rake +2 -1
- metadata +57 -103
- data/bin/aos +0 -31
- data/bin/aro +0 -60
- data/locale/en.abot.yml +0 -81
- data/locale/en.amg.yml +0 -44
- data/locale/en.aos.yml +0 -40
- data/locale/en.data.yml +0 -30
- data/locale/en.dom.yml +0 -46
- data/locale/en.flie.yml +0 -29
- data/sys/aos/abot.rb +0 -255
- data/sys/aos/amg.rb +0 -184
- data/sys/aos/aos.rb +0 -665
- data/sys/aos/data.rb +0 -117
- data/sys/aos/db/migrate/1765148774_create_yous.rb +0 -20
- data/sys/aos/db/migrate/1765762724_create_ilibs.rb +0 -22
- data/sys/aos/db/migrate/1765907766_create_ilogs.rb +0 -18
- data/sys/aos/db/migrate/1765933985_create_agodos.rb +0 -22
- data/sys/aos/db/migrate/1766203888_create_fpxies.rb +0 -18
- data/sys/aos/db.rb +0 -105
- data/sys/aos/flie.rb +0 -144
- data/sys/aos/models/agodo.rb +0 -95
- data/sys/aos/models/fpxy.rb +0 -26
- data/sys/aos/models/ilib.rb +0 -46
- data/sys/aos/models/ilog.rb +0 -27
- data/sys/aos/models/you.rb +0 -102
- data/sys/aos/s.rb +0 -26
- data/sys/aos/vws/base.rb +0 -159
- data/sys/aos/vws/dom.rb +0 -32
- data/sys/aos/vws/games/abot.rb +0 -21
- data/sys/aos/vws/games/teck.rb +0 -124
- data/sys/aos/vws/games.rb +0 -19
- data/sys/aos/vws/home.rb +0 -23
- data/sys/aos/vws/know/body.rb +0 -19
- data/sys/aos/vws/know/mind.rb +0 -19
- data/sys/aos/vws/know/spirit.rb +0 -19
- data/sys/aos/vws/know.rb +0 -19
- data/sys/aos/vws/root/amg.rb +0 -21
- data/sys/aos/vws/root/config.rb +0 -21
- data/sys/aos/vws/root/data.rb +0 -21
- data/sys/aos/vws/root/flie.rb +0 -21
- data/sys/aos/vws/root.rb +0 -19
- data/sys/aos/vws/welcome/waite.rb +0 -31
- data/sys/aos/vws/welcome/winner.rb +0 -19
- data/sys/aos/vws/welcome.rb +0 -66
- data/sys/aro/models/base_model.rb +0 -13
- data/sys/cli/dom.rb +0 -43
- data/sys/dom/d.rb +0 -138
- data/sys/dom/dom.rb +0 -210
- data/sys/dom/p.rb +0 -17
- data/sys/fpx.rb +0 -104
- data/sys/shr/ilib/crs/CMakeLists.txt +0 -12
- data/sys/shr/ilib/crs/compile.sh +0 -5
- data/sys/shr/ilib/crs/crs.c +0 -24
- data/sys/shr/ilib/crs/crs.o +0 -0
- data/sys/shr/ilib/crs/libcrs.so +0 -0
data/sys/aro/ma_ain.rb
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
|
|
3
|
+
ma_ain.rb
|
|
4
|
+
|
|
5
|
+
aro dom ma_ain.
|
|
6
|
+
|
|
7
|
+
by i2097i
|
|
8
|
+
|
|
9
|
+
=end
|
|
10
|
+
|
|
11
|
+
module Aro
|
|
12
|
+
module Dom
|
|
13
|
+
class Ma_ain < Aro::Mancy
|
|
14
|
+
# inherits Singleton
|
|
15
|
+
|
|
16
|
+
attr_accessor :current_menu
|
|
17
|
+
attr_accessor :data_mutex, :store_mutex
|
|
18
|
+
attr_accessor :stores
|
|
19
|
+
|
|
20
|
+
def reign!
|
|
21
|
+
Aro::P.say("opening #{Aro::Dom::Designer.name}...")
|
|
22
|
+
Aro::Dom::Designer.design
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def initialize
|
|
26
|
+
self.data_mutex = Mutex.new
|
|
27
|
+
self.store_mutex = Mutex.new
|
|
28
|
+
@stores = {}
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def self.domain
|
|
32
|
+
self.instance.current_menu.nil? ? super : "#{Aro::Mancy.aro_mancy_name}#{Aro::Mancy::A}#{Aro::Dom::Ma_ain}"
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def self.ps1_display(cls_name = nil)
|
|
36
|
+
super(domain)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def get_store_for(aro_file)
|
|
40
|
+
return if aro_file.nil?
|
|
41
|
+
|
|
42
|
+
# todo validate aro_file
|
|
43
|
+
if @stores[aro_file.uuid].nil?
|
|
44
|
+
new_store = Aro::Dom::Store.new
|
|
45
|
+
new_store.open_file_path = aro_file.aro_file_path
|
|
46
|
+
@stores[aro_file.uuid] = new_store
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
return Aro::Dom::Ma_ain.instance.stores[aro_file.uuid]
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
data/sys/aro/mancy.rb
CHANGED
|
@@ -8,21 +8,25 @@
|
|
|
8
8
|
|
|
9
9
|
=end
|
|
10
10
|
|
|
11
|
+
#
|
|
12
|
+
|
|
11
13
|
module Aro
|
|
12
14
|
class Mancy
|
|
13
15
|
include Singleton
|
|
14
16
|
|
|
15
|
-
attr_accessor :current
|
|
17
|
+
attr_accessor :current, :db_busy, :db_thread
|
|
16
18
|
|
|
19
|
+
A = :"@"
|
|
17
20
|
O = 0
|
|
18
21
|
S = 1
|
|
19
22
|
OS = 2
|
|
20
23
|
E = 3
|
|
21
24
|
N = 4
|
|
22
25
|
V = 5
|
|
23
|
-
|
|
26
|
+
DATE_FORMAT = "%A %d %b %Y %I:%M:%S %p"
|
|
24
27
|
NAME_FILE = :".aro_space"
|
|
25
|
-
|
|
28
|
+
ARO_DIRECTORY = :".oss_om"
|
|
29
|
+
|
|
26
30
|
I2097I = :i2097i
|
|
27
31
|
YES = :aroyes
|
|
28
32
|
ALL = :all
|
|
@@ -58,49 +62,46 @@ module Aro
|
|
|
58
62
|
MMXCVII: Aro::Mancy::I2097I[Aro::Mancy::S..Aro::Mancy::N].to_i,
|
|
59
63
|
}
|
|
60
64
|
|
|
65
|
+
def remember!
|
|
66
|
+
# start monitoring
|
|
67
|
+
self.start_db_thread
|
|
68
|
+
end
|
|
69
|
+
|
|
61
70
|
def self.teck
|
|
71
|
+
self.init(root_dir)
|
|
62
72
|
if Aro::Mancy.in_aro? && Aro::Mancy.is_initialized?
|
|
63
73
|
self.instance.current = Aro::Teck.current_teck
|
|
64
74
|
end
|
|
65
75
|
self.instance.current
|
|
66
76
|
end
|
|
67
77
|
|
|
68
|
-
def self.create(
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
# explicitly only allow String/Symbol types for name
|
|
72
|
-
return false unless name.kind_of?(String) || name.kind_of?(Symbol)
|
|
73
|
-
name = name.to_s.strip
|
|
74
|
-
# create the new aro directory and database
|
|
75
|
-
if !Dir.exist?(name)
|
|
76
|
-
Aro::P.say(I18n.t("cli.messages.no_tecks"))
|
|
77
|
-
FileUtils.mkdir(name)
|
|
78
|
-
else
|
|
79
|
-
return false
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
Dir.chdir(name) do
|
|
83
|
-
Aos::Cor.instance.load
|
|
84
|
-
Aro::Mancy.init
|
|
85
|
-
end
|
|
78
|
+
def self.create(aro_name, is_test: false)
|
|
79
|
+
Aro::D.say(__method__)
|
|
80
|
+
Aro::D.say(:depricated)
|
|
86
81
|
return true
|
|
87
82
|
end
|
|
88
83
|
|
|
89
|
-
def self.init
|
|
90
|
-
unless Aro::Mancy.in_aro? ||
|
|
91
|
-
Aro::P.say("init aro running in
|
|
92
|
-
new_name = File.basename(
|
|
84
|
+
def self.init(root_dir_path)
|
|
85
|
+
unless Aro::Mancy.in_aro? || Aro::Cor.is_test?
|
|
86
|
+
Aro::P.say("init aro running in #{root_dir_path} directory...")
|
|
87
|
+
new_name = File.basename(root_dir_path)
|
|
93
88
|
Aro::P.say("echo #{new_name} > #{Aro::Mancy::NAME_FILE.to_s}")
|
|
94
89
|
File.open(Aro::Mancy::NAME_FILE.to_s, "w") do |file|
|
|
95
90
|
file.write(new_name)
|
|
91
|
+
file.write("\n")
|
|
96
92
|
end
|
|
97
93
|
end
|
|
94
|
+
end
|
|
98
95
|
|
|
99
|
-
|
|
96
|
+
def self.root_dir
|
|
97
|
+
::File.join(
|
|
98
|
+
Aro::Cor.ivar(:OSS_OM_HOME) || Dir.pwd,
|
|
99
|
+
Aro::Mancy::ARO_DIRECTORY.to_s
|
|
100
|
+
)
|
|
100
101
|
end
|
|
101
102
|
|
|
102
103
|
def self.is_initialized?
|
|
103
|
-
|
|
104
|
+
in_aro? && in_aro? && Aro::Db.instance.connected?
|
|
104
105
|
end
|
|
105
106
|
|
|
106
107
|
def self.in_aro?
|
|
@@ -108,11 +109,35 @@ module Aro
|
|
|
108
109
|
end
|
|
109
110
|
|
|
110
111
|
def self.domain
|
|
111
|
-
"#{Aro::Mancy}#{
|
|
112
|
+
is_initialized? ? "#{Aro::Mancy.aro_mancy_name}#{Aro::Mancy::A}#{Aro::Mancy}" : `whoami`.strip
|
|
112
113
|
end
|
|
113
114
|
|
|
114
115
|
def self.aro_mancy_name
|
|
115
116
|
File.read(Aro::Mancy::NAME_FILE.to_s).strip
|
|
116
117
|
end
|
|
118
|
+
|
|
119
|
+
def self.ps1_display(cls_name = nil)
|
|
120
|
+
:">[#{cls_name || Aro::Mancy.domain || aro_mancy_name}]>: ".to_s
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
private
|
|
124
|
+
|
|
125
|
+
def start_db_thread
|
|
126
|
+
return if @db_busy
|
|
127
|
+
@db_busy = true
|
|
128
|
+
self.db_thread&.exit
|
|
129
|
+
self.db_thread&.kill
|
|
130
|
+
self.db_thread = Thread.new do
|
|
131
|
+
loop do
|
|
132
|
+
@db_busy = true
|
|
133
|
+
Aro::V.say(Aro::Mancy.instance.db_thread.inspect)
|
|
134
|
+
Aro::V.say(__method__)
|
|
135
|
+
Aro::Db.ensure_connected!
|
|
136
|
+
@db_busy = false
|
|
137
|
+
sleep(Aro::Db::HEARTBEAT_DURATION)
|
|
138
|
+
end
|
|
139
|
+
end
|
|
140
|
+
end
|
|
141
|
+
|
|
117
142
|
end
|
|
118
143
|
end
|
|
File without changes
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
|
|
3
|
+
uuid.rb
|
|
4
|
+
|
|
5
|
+
basic uuid generator for active record
|
|
6
|
+
|
|
7
|
+
by i2097i
|
|
8
|
+
|
|
9
|
+
=end
|
|
10
|
+
|
|
11
|
+
require "securerandom"
|
|
12
|
+
|
|
13
|
+
module Aro::Dom::Uuid
|
|
14
|
+
extend ActiveSupport::Concern
|
|
15
|
+
|
|
16
|
+
included do
|
|
17
|
+
before_create :generate_uuid
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
private
|
|
21
|
+
|
|
22
|
+
def generate_uuid
|
|
23
|
+
self.uuid = SecureRandom.send([
|
|
24
|
+
:uuid,
|
|
25
|
+
:uuid_v7,
|
|
26
|
+
:uuid_v4
|
|
27
|
+
].sample) if self.uuid.nil?
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
|
|
3
|
+
data.rb
|
|
4
|
+
|
|
5
|
+
aro dom data.
|
|
6
|
+
|
|
7
|
+
by i2097i
|
|
8
|
+
|
|
9
|
+
=end
|
|
10
|
+
|
|
11
|
+
class Aro::Dom::DataBase < ActiveRecord::Base
|
|
12
|
+
include Aro::Dom::Uuid
|
|
13
|
+
self.table_name = :data_bases
|
|
14
|
+
|
|
15
|
+
has_many :data_base_directories, class_name: "Aro::Dom::DataBase::Directory"
|
|
16
|
+
|
|
17
|
+
after_commit :sync
|
|
18
|
+
|
|
19
|
+
def self.open_menu(menu_sym)
|
|
20
|
+
# get the menu directory
|
|
21
|
+
data_base_directory = menu_data_base.data_base_directories.find_or_create_by(
|
|
22
|
+
unix_path: menu_sym
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
menu = Aro::Dom::Menu.find_by(uuid: data_base_directory.uuid)
|
|
26
|
+
if menu.nil?
|
|
27
|
+
# find or create the new menu
|
|
28
|
+
menu = Aro::Dom::Menu.create(uuid: data_base_directory.uuid)
|
|
29
|
+
Aro::Dom::Locale.add_i18n_key(
|
|
30
|
+
menu_sym.to_s,
|
|
31
|
+
new_i18n_display_key: menu.uuid
|
|
32
|
+
)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# return the menu
|
|
36
|
+
return menu
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def self.menu_data_base
|
|
40
|
+
Aro::Dom::DataBase.find_or_create_by(unix_path: Aro::Dom::Menu.table_name)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def self.sync_menu_item(menu_item)
|
|
44
|
+
# todo:
|
|
45
|
+
puts "todo: #{__method__} #{menu_item.inspect}"
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def self.ensure_data_base_exist!
|
|
49
|
+
unless Dir.exist?(root_aro_unix_data_dir)
|
|
50
|
+
Aro::P.say(__method__)
|
|
51
|
+
Aro::P.say("creating #{root_aro_unix_data_dir}")
|
|
52
|
+
FileUtils.mkdir(root_aro_unix_data_dir)
|
|
53
|
+
ensure_data_base_git!
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def self.ensure_data_base_git!
|
|
59
|
+
ensure_data_base_exist! unless Dir.exist?(root_aro_unix_data_dir)
|
|
60
|
+
FileUtils.chdir(root_aro_unix_data_dir) do
|
|
61
|
+
Aro::P.say("todo:")
|
|
62
|
+
Aro::P.say(__method__)
|
|
63
|
+
# system("git init")
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def unix_path_valid?
|
|
68
|
+
unix_path.kind_of?(String) && !unix_path.empty?
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def aro_data_base_path
|
|
72
|
+
::File.join(Aro::Dom::DataBase.root_aro_unix_data_dir, unix_path)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def self.root_aro_unix_data_dir
|
|
76
|
+
::File.join(Aro::Mancy.root_dir, table_name)
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def ensure_unix_exists!
|
|
80
|
+
raise "unix_path invalid! #{(unix_path)}" unless unix_path_valid?
|
|
81
|
+
unless Dir.exist?(aro_data_base_path)
|
|
82
|
+
Aro::P.say(__method__)
|
|
83
|
+
Aro::P.say("creating #{aro_data_base_path}")
|
|
84
|
+
FileUtils.mkdir(aro_data_base_path)
|
|
85
|
+
::File.write(::File.join(aro_data_base_path, ".uuid"), uuid)
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
private
|
|
90
|
+
|
|
91
|
+
def sync
|
|
92
|
+
Aro::Dom::Ma_ain.instance.data_mutex.synchronize do
|
|
93
|
+
self.class.ensure_data_base_git!
|
|
94
|
+
ensure_unix_exists!
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
end
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
|
|
3
|
+
data.rb
|
|
4
|
+
|
|
5
|
+
aro dom table.
|
|
6
|
+
|
|
7
|
+
by i2097i
|
|
8
|
+
|
|
9
|
+
=end
|
|
10
|
+
|
|
11
|
+
class Aro::Dom::DataBase::Directory < ActiveRecord::Base
|
|
12
|
+
include Aro::Dom::Uuid
|
|
13
|
+
self.table_name = :data_base_directories
|
|
14
|
+
belongs_to :data_base, class_name: "Aro::Dom::DataBase"
|
|
15
|
+
|
|
16
|
+
has_many :data_base_files, class_name: "Aro::Dom::DataBase::File"
|
|
17
|
+
|
|
18
|
+
after_create :sync
|
|
19
|
+
after_commit :sync
|
|
20
|
+
|
|
21
|
+
def ensure_unix_exists!
|
|
22
|
+
unless Dir.exist?(aro_directory_path)
|
|
23
|
+
Aro::P.say("creating #{Aro::Dom::DataBase::Directory} for #{aro_directory_path}")
|
|
24
|
+
FileUtils.mkdir(aro_directory_path)
|
|
25
|
+
::File.write(::File.join(aro_directory_path, ".uuid"), uuid)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def aro_directory_path
|
|
30
|
+
::File.join(data_base.aro_data_base_path, unix_path)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def schema
|
|
34
|
+
::File.join(aro_directory_path, :def_directory, ".json")
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
private
|
|
38
|
+
|
|
39
|
+
def sync
|
|
40
|
+
Aro::Dom::Ma_ain.instance.data_mutex.synchronize do
|
|
41
|
+
ensure_unix_exists!
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
|
|
3
|
+
row.rb
|
|
4
|
+
|
|
5
|
+
aro dom data file.
|
|
6
|
+
|
|
7
|
+
by i2097i
|
|
8
|
+
|
|
9
|
+
=end
|
|
10
|
+
|
|
11
|
+
class Aro::Dom::DataBase::File < ActiveRecord::Base
|
|
12
|
+
include Aro::Dom::Uuid
|
|
13
|
+
self.table_name = :data_base_files
|
|
14
|
+
belongs_to :data_base_directory, class_name: "Aro::Dom::DataBase::Directory"
|
|
15
|
+
|
|
16
|
+
def write!(updates = {})
|
|
17
|
+
Aro::Dom::Store.edit(self, updates)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def aro_file_path
|
|
21
|
+
::File.join(
|
|
22
|
+
data_base_directory.aro_directory_path,
|
|
23
|
+
"#{uuid}.json"
|
|
24
|
+
)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
|
|
3
|
+
menu.rb
|
|
4
|
+
|
|
5
|
+
aro dom menu.
|
|
6
|
+
|
|
7
|
+
by i2097i
|
|
8
|
+
|
|
9
|
+
=end
|
|
10
|
+
|
|
11
|
+
class Aro::Dom::Menu < ActiveRecord::Base
|
|
12
|
+
include Aro::Dom::Uuid
|
|
13
|
+
|
|
14
|
+
has_many :menu_items, class_name: "Aro::Dom::MenuItem"
|
|
15
|
+
|
|
16
|
+
def localized_name
|
|
17
|
+
I18n.t(full_i18n_path)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def full_i18n_path
|
|
21
|
+
"#{self.class.table_name}.#{uuid}"
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def directory
|
|
25
|
+
Aro::Dom::DataBase::Directory.find_by(uuid: uuid)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
|
|
3
|
+
menu.rb
|
|
4
|
+
|
|
5
|
+
aro dom menu item.
|
|
6
|
+
|
|
7
|
+
by i2097i
|
|
8
|
+
|
|
9
|
+
=end
|
|
10
|
+
|
|
11
|
+
class Aro::Dom::MenuItem < ActiveRecord::Base
|
|
12
|
+
include Aro::Dom::Uuid
|
|
13
|
+
belongs_to :menu, class_name: "Aro::Dom::Menu"
|
|
14
|
+
|
|
15
|
+
after_create :sync
|
|
16
|
+
|
|
17
|
+
def as_tty
|
|
18
|
+
{name: localized_name, value: uuid}
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def localized_name
|
|
22
|
+
I18n.t(full_i18n_path)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def full_i18n_path
|
|
26
|
+
"#{self.class.table_name}.#{uuid}"
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def aro_directory
|
|
30
|
+
return if menu.nil?
|
|
31
|
+
Aro::Dom::DataBase::Directory.find_by(uuid: menu.uuid)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def aro_file
|
|
35
|
+
return if aro_directory.nil?
|
|
36
|
+
Aro::Dom::DataBase::File.find_or_create_by(
|
|
37
|
+
uuid: uuid,
|
|
38
|
+
data_base_directory: aro_directory
|
|
39
|
+
)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
private
|
|
43
|
+
|
|
44
|
+
def sync
|
|
45
|
+
Aro::Dom::DataBase.sync_menu_item(self)
|
|
46
|
+
end
|
|
47
|
+
end
|
data/sys/aro/models/teck.rb
CHANGED
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
=end
|
|
10
10
|
|
|
11
11
|
require :base64.to_s
|
|
12
|
-
require_relative :"./base_model".to_s
|
|
13
12
|
|
|
14
13
|
class Aro::Teck < ActiveRecord::Base
|
|
15
14
|
has_many :tlogs
|
|
@@ -21,7 +20,6 @@ class Aro::Teck < ActiveRecord::Base
|
|
|
21
20
|
after_commit :generate_log
|
|
22
21
|
|
|
23
22
|
def self.make(new_name)
|
|
24
|
-
Aro::Db.load
|
|
25
23
|
return nil unless Aro::Mancy.is_initialized?
|
|
26
24
|
new_teck = Aro::Teck.create(name: new_name)
|
|
27
25
|
Aro::Teck.select_teck(new_teck) if Aro::Teck.current_teck.nil?
|
|
@@ -33,13 +31,14 @@ class Aro::Teck < ActiveRecord::Base
|
|
|
33
31
|
end
|
|
34
32
|
|
|
35
33
|
def populate_cards
|
|
36
|
-
Aro::Db.load
|
|
37
34
|
self.cards = Aro::Teck.fresh_cards
|
|
38
35
|
end
|
|
39
36
|
|
|
40
37
|
def generate_log
|
|
41
38
|
prev_cards = Base64::decode64(tlogs.last.card_data) if tlogs.any?
|
|
42
|
-
if (prev_cards.present? && prev_cards != cards) ||
|
|
39
|
+
if (prev_cards.present? && prev_cards != cards) ||
|
|
40
|
+
(prev_cards.nil? || prev_cards.empty?)
|
|
41
|
+
|
|
43
42
|
tlogs.create(
|
|
44
43
|
card_data: Base64::encode64(cards || ""),
|
|
45
44
|
drawn_data: Base64::encode64(drawn || "")
|
|
@@ -48,9 +47,8 @@ class Aro::Teck < ActiveRecord::Base
|
|
|
48
47
|
end
|
|
49
48
|
|
|
50
49
|
def self.display_selection_menu
|
|
51
|
-
Aro::Db.load
|
|
52
50
|
unless Aro::Teck.any?
|
|
53
|
-
Aro::P.say(I18n.t("
|
|
51
|
+
Aro::P.say(I18n.t("messages.no_tecks"))
|
|
54
52
|
exit(CLI::EXIT_CODES[:SUCCESS])
|
|
55
53
|
end
|
|
56
54
|
c_d = Aro::Teck.current_teck
|
|
@@ -61,16 +59,15 @@ class Aro::Teck < ActiveRecord::Base
|
|
|
61
59
|
|
|
62
60
|
def self.select_teck(teck)
|
|
63
61
|
return unless teck.present?
|
|
64
|
-
Aro::P.say(I18n.t("
|
|
65
|
-
File.open(File.join(Aro::
|
|
62
|
+
Aro::P.say(I18n.t("messages.teck_selected", name: teck.name, room: Aro::Mancy::aro_mancy_name))
|
|
63
|
+
File.open(File.join(Aro::Mancy.root_dir, Aro::Teck::TECK_FILE.to_s), "w") do |file|
|
|
66
64
|
file.write(teck.id)
|
|
67
65
|
end
|
|
68
66
|
end
|
|
69
67
|
|
|
70
68
|
def self.current_teck
|
|
71
|
-
Aro::
|
|
72
|
-
|
|
73
|
-
current_teck_id = File.read(File.join(Aro::Db.base_aro_dir, TECK_FILE.to_s))
|
|
69
|
+
if File.exist?(File.join(Aro::Mancy.root_dir, TECK_FILE.to_s))
|
|
70
|
+
current_teck_id = File.read(File.join(Aro::Mancy.root_dir, TECK_FILE.to_s))
|
|
74
71
|
return Aro::Teck.find_by(id: current_teck_id)
|
|
75
72
|
end
|
|
76
73
|
end
|
|
@@ -93,37 +90,31 @@ class Aro::Teck < ActiveRecord::Base
|
|
|
93
90
|
Aro::V.say("order_o: #{order_o}")
|
|
94
91
|
|
|
95
92
|
unless Aro::Tlog::ORDERING.values.include?(order_o)
|
|
96
|
-
Aro::P.say(I18n.t("
|
|
93
|
+
Aro::P.say(I18n.t("warnings.invalid_order"))
|
|
97
94
|
order_o = Aro::Tlog::ORDERING[:DESC]
|
|
98
95
|
end
|
|
99
96
|
|
|
100
97
|
# perform query
|
|
101
|
-
Aro::Db.load
|
|
102
98
|
tlog_records = tlogs.order(created_at: order_o).first(count_n)
|
|
103
99
|
|
|
104
100
|
# todo: this is doing more work than it needs to. needs debugging.
|
|
105
101
|
# Aro::V.say("tlog_records.count: #{tlog_records.count}")
|
|
106
102
|
|
|
107
103
|
# for now tests just expect count
|
|
108
|
-
return tlog_records if
|
|
104
|
+
return tlog_records if Aro::Cor.is_test?
|
|
109
105
|
|
|
110
|
-
Aro::D.say(I18n.t("
|
|
106
|
+
Aro::D.say(I18n.t("messages.showing", name: name, count: count_n, order: order_o))
|
|
111
107
|
|
|
112
|
-
|
|
113
|
-
teck: self,
|
|
114
|
-
tlog_records: tlog_records,
|
|
115
|
-
count_n: count_n,
|
|
116
|
-
order_o: order_o
|
|
117
|
-
})
|
|
108
|
+
Aro::Views::Teck.show
|
|
118
109
|
end
|
|
119
110
|
|
|
120
111
|
def explore
|
|
121
112
|
# allows user to browse each card in the current teck.
|
|
122
|
-
answer =
|
|
123
|
-
Aro::Mancy::
|
|
113
|
+
answer = Aro::P.p.select(
|
|
114
|
+
Aro::Mancy::ps1_display.to_s + I18n.t("messages.choose_card"),
|
|
124
115
|
# formatted for tty-prompt gem
|
|
125
116
|
cards.split(Aro::Teck::CARD_DELIM.to_s).map{|c| [I18n.t("cards.#{Aro::Teck.card_strip(c)}.name"), c]}.to_h,
|
|
126
|
-
per_page:
|
|
117
|
+
per_page: TTY::Screen.height - Aro::Mancy::OS,
|
|
127
118
|
cycle: true,
|
|
128
119
|
default: Aro::Mancy::S
|
|
129
120
|
)
|
|
@@ -138,14 +129,33 @@ class Aro::Teck < ActiveRecord::Base
|
|
|
138
129
|
orientation = "-"
|
|
139
130
|
end
|
|
140
131
|
|
|
141
|
-
|
|
132
|
+
Aro::P.say(I18n.t("messages.printing_card", card: card_code))
|
|
133
|
+
width = Aro::Cor.discon[:WIDTH]
|
|
134
|
+
divider = Aro::Cor.discon[:DIVIDER]
|
|
135
|
+
card_lookup = Aro::Teck.card_strip(card_code)
|
|
136
|
+
suit_lookup = card_lookup[Aro::Mancy::O]
|
|
137
|
+
definition = I18n.t("cards.#{card_lookup}")
|
|
138
|
+
suit_definition = I18n.t("suits.#{suit_lookup}")
|
|
142
139
|
output = []
|
|
143
|
-
output <<
|
|
144
|
-
output
|
|
140
|
+
output << "".ljust(width, divider)
|
|
141
|
+
output << ""
|
|
142
|
+
output << "(#{orientation}) #{definition[:name].upcase}"
|
|
143
|
+
output << ""
|
|
144
|
+
unless suit_definition.nil?
|
|
145
|
+
suit_definition[:summary].split(".").each{|sentence| output << sentence + ".\n"}
|
|
146
|
+
output << suit_definition[:tags].sort.join(" | ")
|
|
147
|
+
end
|
|
148
|
+
output << "".ljust(width, divider)
|
|
149
|
+
output << ""
|
|
150
|
+
card_tags = definition["#{orientation}tags".to_sym].sort
|
|
151
|
+
max_word = card_tags.max_by{|t| t.length}.length
|
|
152
|
+
card_tags.each{|t|
|
|
153
|
+
output << t.center(max_word)
|
|
154
|
+
}
|
|
145
155
|
# todo: add an actual summary
|
|
146
156
|
# Aro::P.say(definition["#{orientation}summary".to_sym])
|
|
147
|
-
|
|
148
|
-
Aro::P.say("#{card_code}\n#{output.map{|l| l.center(width
|
|
157
|
+
output << "".ljust(width, divider)
|
|
158
|
+
Aro::P.say("#{card_code}\n#{output.map{|l| l.center(width)}.join("\n")}")
|
|
149
159
|
end
|
|
150
160
|
|
|
151
161
|
def shuffle
|
|
@@ -172,7 +182,7 @@ class Aro::Teck < ActiveRecord::Base
|
|
|
172
182
|
update(drawn: "", cards: cards_arr.join(Aro::Teck::CARD_DELIM.to_s))
|
|
173
183
|
end
|
|
174
184
|
|
|
175
|
-
def draw(
|
|
185
|
+
def draw(z_max: 7, z: 1)
|
|
176
186
|
# the true card
|
|
177
187
|
abs_dev_tarot = nil
|
|
178
188
|
|
|
@@ -231,7 +241,6 @@ class Aro::Teck < ActiveRecord::Base
|
|
|
231
241
|
# insert dev_tarot to drawn
|
|
232
242
|
drawn_arr << dev_tarot
|
|
233
243
|
Aro::Teck.print_card(dev_tarot)
|
|
234
|
-
Aro::Db.load
|
|
235
244
|
|
|
236
245
|
# update database
|
|
237
246
|
update(
|
data/sys/aro/p.rb
CHANGED
|
@@ -14,10 +14,13 @@ require_relative :"./r".to_s
|
|
|
14
14
|
module Aro
|
|
15
15
|
class P < Aro::Prompt
|
|
16
16
|
def self.say(message)
|
|
17
|
-
if Aro::
|
|
18
|
-
Aro::
|
|
17
|
+
if Aro::Dom::Ma_ain.instance.nil? &&
|
|
18
|
+
Aro::Mancy.in_aro? &&
|
|
19
|
+
!Aro::T.is_dev_tarot?
|
|
20
|
+
|
|
21
|
+
Aro::R.say(normalize_message(message))
|
|
19
22
|
else
|
|
20
|
-
super(
|
|
23
|
+
super("#{Aro::Dom::Ma_ain.ps1_display || Aro::Mancy.ps1_display}#{normalize_message(message)}")
|
|
21
24
|
end
|
|
22
25
|
end
|
|
23
26
|
end
|
data/sys/aro/r.rb
CHANGED
|
@@ -12,9 +12,8 @@ require_relative :"../shr/prompt".to_s
|
|
|
12
12
|
|
|
13
13
|
module Aro
|
|
14
14
|
class R < Aro::Prompt
|
|
15
|
-
PS1 = :">[#{Aro::T::RUBY_FACOT}]>:"
|
|
16
15
|
def self.say(message)
|
|
17
|
-
super(
|
|
16
|
+
super("#{Aro::Mancy.ps1_display(Aro::R.name)} #{normalize_message(message)}")
|
|
18
17
|
end
|
|
19
18
|
end
|
|
20
19
|
end
|