aro 0.2.6 → 0.2.7
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 +2 -1
- data/bin/oss_om +2 -0
- data/checksums/aro-0.2.7.gem.sha512 +1 -0
- data/listen.rb +1 -1
- data/locale/en.cor.yml +21 -32
- data/locale/en.yml +8 -60
- data/sys/aro/action.rb +153 -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 +166 -97
- 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 +37 -0
- data/sys/aro/models/concerns/uuid.rb +2 -0
- data/sys/aro/models/data_base.rb +33 -8
- data/sys/aro/models/directory.rb +2 -0
- data/sys/aro/models/file.rb +3 -1
- data/sys/aro/models/menu.rb +64 -0
- data/sys/aro/models/menu_item.rb +70 -4
- data/sys/aro/oss_open_menu.rb +331 -0
- data/sys/aro/p.rb +15 -9
- data/sys/aro/r.rb +2 -0
- data/sys/aro/{cor.rb → settings/cor.rb} +91 -215
- data/sys/aro/settings/git.rb +69 -0
- data/sys/aro/settings/ssh.rb +123 -0
- data/sys/aro/store.rb +87 -36
- data/sys/aro/v.rb +2 -0
- data/sys/aro.rb +2 -0
- data/sys/ma_ain.rb +202 -0
- data/sys/reiquire.rb +41 -54
- data/sys/shr/prompt.rb +6 -1
- data/sys/shr/version.rb +7 -8
- metadata +31 -23
- 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
data/locale/en.cmd.yml
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
en:
|
|
2
|
-
cmd:
|
|
3
|
-
commands:
|
|
4
|
-
console_description: "open irb with aro"
|
|
5
|
-
console_usage: "$ aro console"
|
|
6
|
-
create_description: "create and init an aro space."
|
|
7
|
-
create_usage: "$ aro create var_name"
|
|
8
|
-
cor_description: "aro cor unix env bindings."
|
|
9
|
-
cor_usage: "$ aro cor [-h | --help]"
|
|
10
|
-
data_description: "aro data commands."
|
|
11
|
-
data_usage: "$ aro data [-h | --help]"
|
|
12
|
-
teck_description: "aro teck commands."
|
|
13
|
-
teck_usage: "aro teck [-h | --help]"
|
|
14
|
-
init_description: "sets up the .aro directory that contains database and cor"
|
|
15
|
-
init_usage: "$ aro init"
|
|
16
|
-
subcommands:
|
|
17
|
-
ivars_description: "print ivars"
|
|
18
|
-
ivars_usage: "$ aro cor ivars"
|
|
19
|
-
ovars_description: "print ovars"
|
|
20
|
-
ovars_usage: "$ aro cor ovars"
|
|
21
|
-
draw_description: "draw a card from the current teck."
|
|
22
|
-
draw_usage: "$ aro draw; or $ aro teck draw"
|
|
23
|
-
explore_description: "explore the tarot."
|
|
24
|
-
explore_usage: "$ aro explore OR $ aro teck explore"
|
|
25
|
-
teck_new_description: "todo: new_description"
|
|
26
|
-
teck_new_usage: "$ aro teck new teck_name"
|
|
27
|
-
replace_description: "todo: replace_description"
|
|
28
|
-
replace_usage: "$ aro replace OR $ aro teck replace"
|
|
29
|
-
reset_description: "todo: reset_description"
|
|
30
|
-
reset_usage: "$ aro reset OR $ aro teck reset"
|
|
31
|
-
show_description: "todo: show_description"
|
|
32
|
-
show_usage: "$ aro show OR $ aro teck show"
|
|
33
|
-
shuffle_description: "todo: shuffle_description"
|
|
34
|
-
shuffle_usage: "$ aro shuffle OR $ aro teck shuffle"
|
data/locale/en.usage.yml
DELETED
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
en:
|
|
2
|
-
usage:
|
|
3
|
-
cor: |
|
|
4
|
-
aro cor management.
|
|
5
|
-
|
|
6
|
-
$ aro cor [-h | --help]
|
|
7
|
-
|
|
8
|
-
$ aro cor var_name var_value
|
|
9
|
-
|
|
10
|
-
basic usage:
|
|
11
|
-
|
|
12
|
-
no params prints the cor (writable) ivars.
|
|
13
|
-
|
|
14
|
-
$ aro cor [ivars|ovars]
|
|
15
|
-
|
|
16
|
-
param var_name prints the var named var_name.
|
|
17
|
-
|
|
18
|
-
$ aro cor var_name
|
|
19
|
-
|
|
20
|
-
param var_name & param var_value updates a var named var_name with var_value.
|
|
21
|
-
|
|
22
|
-
$ aro cor var_name var_value
|
|
23
|
-
|
|
24
|
-
main: |
|
|
25
|
-
SUMMARY
|
|
26
|
-
|
|
27
|
-
aro.
|
|
28
|
-
|
|
29
|
-
SYNOPSIS
|
|
30
|
-
|
|
31
|
-
aro [-v | --version] [-h | --help] [(+|-)(T|C|S|P|W)(var_numeral)] var_command
|
|
32
|
-
|
|
33
|
-
quickstart or tldr; example:
|
|
34
|
-
|
|
35
|
-
$ aro create var_name && cd var_name && aro teck new var_teck_name && aro
|
|
36
|
-
|
|
37
|
-
card lookup example:
|
|
38
|
-
|
|
39
|
-
$ aro +TXXI
|
|
40
|
-
|
|
41
|
-
or, equivalently:
|
|
42
|
-
|
|
43
|
-
$ aro +txxi
|
|
44
|
-
|
|
45
|
-
COMMANDS
|
|
46
|
-
create
|
|
47
|
-
create and init an aro space named var_name:
|
|
48
|
-
|
|
49
|
-
$ aro create var_name
|
|
50
|
-
|
|
51
|
-
init
|
|
52
|
-
sets up the .aro directory that contains database and cor
|
|
53
|
-
|
|
54
|
-
note:
|
|
55
|
-
this runs by default after create and has no effect if init is complete.
|
|
56
|
-
|
|
57
|
-
cor
|
|
58
|
-
aro cor unix env bindings.
|
|
59
|
-
|
|
60
|
-
$ aro cor [-h | --help]
|
|
61
|
-
|
|
62
|
-
teck
|
|
63
|
-
aro teck commands.
|
|
64
|
-
|
|
65
|
-
$ aro teck [-h | --help]
|
|
66
|
-
|
|
67
|
-
data
|
|
68
|
-
aro data commands.
|
|
69
|
-
|
|
70
|
-
$ aro data [-h | --help]
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
aro by i2097i is copyright (2026)
|
|
74
|
-
teck: |
|
|
75
|
-
aro teck
|
|
76
|
-
manage tecks in the aro space.
|
|
77
|
-
|
|
78
|
-
$ aro teck var_command
|
|
79
|
-
|
|
80
|
-
passing no params opens the selection menu.
|
|
81
|
-
|
|
82
|
-
note:
|
|
83
|
-
|
|
84
|
-
teck subcommands do not require typing 'teck'. for example,
|
|
85
|
-
|
|
86
|
-
$ aro teck show
|
|
87
|
-
|
|
88
|
-
is the same thing as:
|
|
89
|
-
|
|
90
|
-
$ aro show
|
|
91
|
-
|
|
92
|
-
COMMANDS
|
|
93
|
-
draw
|
|
94
|
-
draw a random card from the current teck.
|
|
95
|
-
|
|
96
|
-
explore
|
|
97
|
-
allows user to browse each card in the current teck.
|
|
98
|
-
|
|
99
|
-
new
|
|
100
|
-
create a new teck with the specified name.
|
|
101
|
-
|
|
102
|
-
example:
|
|
103
|
-
|
|
104
|
-
$ aro teck new var_name
|
|
105
|
-
|
|
106
|
-
replace
|
|
107
|
-
replaces all drawn cards FIFO and puts them on the bottom of
|
|
108
|
-
the teck. this will preserve all card orientations.
|
|
109
|
-
|
|
110
|
-
reset
|
|
111
|
-
completely reset the teck. replace all drawn and reset order.
|
|
112
|
-
all orientations will be set to upright. you must enter 'aroyes'
|
|
113
|
-
to continue.
|
|
114
|
-
|
|
115
|
-
show
|
|
116
|
-
displays the current teck's log record(s).
|
|
117
|
-
|
|
118
|
-
the default behavior is to display only the most recent log record.
|
|
119
|
-
|
|
120
|
-
note:
|
|
121
|
-
|
|
122
|
-
'less' is automatically used to view text output log count > 1
|
|
123
|
-
|
|
124
|
-
OPTIONS
|
|
125
|
-
|
|
126
|
-
[-n | --count] specify number of teck tlogs to show.
|
|
127
|
-
|
|
128
|
-
default is 1 (latest/current state)
|
|
129
|
-
|
|
130
|
-
passing 'all' display all tlogs
|
|
131
|
-
|
|
132
|
-
[-o | --order] specify the output order of the log records.
|
|
133
|
-
|
|
134
|
-
default is 'desc'
|
|
135
|
-
|
|
136
|
-
possible values: ['asc', 'desc']
|
|
137
|
-
|
|
138
|
-
shuffle
|
|
139
|
-
shuffles the current teck and generates a log record.
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
aro by i2097i is copyright (2026)
|
data/sys/aro/cmd.rb
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
=begin
|
|
2
|
-
|
|
3
|
-
cmd.rb
|
|
4
|
-
|
|
5
|
-
cmd interface.
|
|
6
|
-
|
|
7
|
-
by i2097i
|
|
8
|
-
|
|
9
|
-
=end
|
|
10
|
-
|
|
11
|
-
module Aro
|
|
12
|
-
class Cmd
|
|
13
|
-
include Singleton
|
|
14
|
-
|
|
15
|
-
CMDS = {
|
|
16
|
-
CONSOLE: {
|
|
17
|
-
key: :console,
|
|
18
|
-
description: I18n.t("cmd.commands.console_description"),
|
|
19
|
-
usage: I18n.t("cmd.commands.console_usage")
|
|
20
|
-
},
|
|
21
|
-
CREATE: {
|
|
22
|
-
key: :create,
|
|
23
|
-
description: I18n.t("cmd.commands.create_description"),
|
|
24
|
-
usage: I18n.t("cmd.commands.create_usage")
|
|
25
|
-
},
|
|
26
|
-
COR: {
|
|
27
|
-
key: :cor,
|
|
28
|
-
description: I18n.t("cmd.commands.cor_description"),
|
|
29
|
-
usage: I18n.t("cmd.commands.cor_usage"),
|
|
30
|
-
subcommands: {
|
|
31
|
-
IVARS: {
|
|
32
|
-
key: :ivars,
|
|
33
|
-
description: I18n.t("cmd.subcommands.ivars_description"),
|
|
34
|
-
usage: I18n.t("cmd.subcommands.ivars_usage")
|
|
35
|
-
},
|
|
36
|
-
OVARS: {
|
|
37
|
-
key: :ovars,
|
|
38
|
-
description: I18n.t("cmd.subcommands.ovars_description"),
|
|
39
|
-
usage: I18n.t("cmd.subcommands.ovars_usage")
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
},
|
|
43
|
-
TECK: {
|
|
44
|
-
key: :teck,
|
|
45
|
-
description: I18n.t("cmd.commands.teck_description"),
|
|
46
|
-
usage: I18n.t("cmd.commands.teck_usage"),
|
|
47
|
-
subcommands: {
|
|
48
|
-
DRAW: {
|
|
49
|
-
key: :draw,
|
|
50
|
-
description: I18n.t("cmd.subcommands.draw_description"),
|
|
51
|
-
usage: I18n.t("cmd.subcommands.draw_usage")
|
|
52
|
-
},
|
|
53
|
-
EXPLORE: {
|
|
54
|
-
key: :explore,
|
|
55
|
-
description: I18n.t("cmd.subcommands.explore_description"),
|
|
56
|
-
usage: I18n.t("cmd.subcommands.explore_usage")
|
|
57
|
-
},
|
|
58
|
-
NEW: {
|
|
59
|
-
key: :new,
|
|
60
|
-
description: I18n.t("cmd.subcommands.teck_new_description"),
|
|
61
|
-
usage: I18n.t("cmd.subcommands.teck_new_usage")
|
|
62
|
-
},
|
|
63
|
-
REPLACE: {
|
|
64
|
-
key: :replace,
|
|
65
|
-
description: I18n.t("cmd.subcommands.replace_description"),
|
|
66
|
-
usage: I18n.t("cmd.subcommands.replace_usage")
|
|
67
|
-
},
|
|
68
|
-
RESET: {
|
|
69
|
-
key: :reset,
|
|
70
|
-
description: I18n.t("cmd.subcommands.reset_description"),
|
|
71
|
-
usage: I18n.t("cmd.subcommands.reset_usage")
|
|
72
|
-
},
|
|
73
|
-
SHOW: {
|
|
74
|
-
key: :show,
|
|
75
|
-
description: I18n.t("cmd.subcommands.show_description"),
|
|
76
|
-
usage: I18n.t("cmd.subcommands.show_usage")
|
|
77
|
-
},
|
|
78
|
-
SHUFFLE: {
|
|
79
|
-
key: :shuffle,
|
|
80
|
-
description: I18n.t("cmd.subcommands.shuffle_description"),
|
|
81
|
-
usage: I18n.t("cmd.subcommands.shuffle_usage")
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
},
|
|
85
|
-
INIT: {
|
|
86
|
-
key: :init,
|
|
87
|
-
description: I18n.t("cmd.commands.init_description"),
|
|
88
|
-
usage: I18n.t("cmd.commands.init_usage")
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
def self.display_lines
|
|
93
|
-
JSON.pretty_generate(CMDS).split("\n")
|
|
94
|
-
end
|
|
95
|
-
end
|
|
96
|
-
end
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
class CreateTecks < ActiveRecord::Migration[8.1]
|
|
2
|
-
|
|
3
|
-
def self.up
|
|
4
|
-
create_table :tecks do |t|
|
|
5
|
-
t.string :name
|
|
6
|
-
t.string :cards, null: false, default: ""
|
|
7
|
-
t.string :drawn, null: false, default: ""
|
|
8
|
-
|
|
9
|
-
t.timestamps
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
add_index :tecks, :name, unique: true
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def self.down
|
|
16
|
-
remove_index :tecks, :name
|
|
17
|
-
drop_table :tecks
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
end
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
class CreateTlogs < ActiveRecord::Migration[8.1]
|
|
2
|
-
|
|
3
|
-
def self.up
|
|
4
|
-
create_table :tlogs do |t|
|
|
5
|
-
t.string :card_data
|
|
6
|
-
t.string :drawn_data
|
|
7
|
-
|
|
8
|
-
t.timestamps
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
add_column :tlogs, :teck_id, :integer
|
|
12
|
-
add_index :tlogs, :teck_id
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def self.down
|
|
16
|
-
remove_index :tlogs, :teck_id
|
|
17
|
-
drop_table :tlogs
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
end
|
data/sys/aro/ma_ain.rb
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
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/models/teck.rb
DELETED
|
@@ -1,251 +0,0 @@
|
|
|
1
|
-
=begin
|
|
2
|
-
|
|
3
|
-
teck.rb
|
|
4
|
-
|
|
5
|
-
teck object.
|
|
6
|
-
|
|
7
|
-
by i2097i
|
|
8
|
-
|
|
9
|
-
=end
|
|
10
|
-
|
|
11
|
-
require :base64.to_s
|
|
12
|
-
|
|
13
|
-
class Aro::Teck < ActiveRecord::Base
|
|
14
|
-
has_many :tlogs
|
|
15
|
-
|
|
16
|
-
TECK_FILE = :".aro_teck"
|
|
17
|
-
CARD_DELIM = :","
|
|
18
|
-
|
|
19
|
-
before_create :populate_cards
|
|
20
|
-
after_commit :generate_log
|
|
21
|
-
|
|
22
|
-
def self.make(new_name)
|
|
23
|
-
return nil unless Aro::Mancy.is_initialized?
|
|
24
|
-
new_teck = Aro::Teck.create(name: new_name)
|
|
25
|
-
Aro::Teck.select_teck(new_teck) if Aro::Teck.current_teck.nil?
|
|
26
|
-
new_teck
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def self.fresh_cards
|
|
30
|
-
I18n.t("cards.index").map{|c| "+#{c}"}.join(Aro::Teck::CARD_DELIM.to_s)
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def populate_cards
|
|
34
|
-
self.cards = Aro::Teck.fresh_cards
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def generate_log
|
|
38
|
-
prev_cards = Base64::decode64(tlogs.last.card_data) if tlogs.any?
|
|
39
|
-
if (prev_cards.present? && prev_cards != cards) ||
|
|
40
|
-
(prev_cards.nil? || prev_cards.empty?)
|
|
41
|
-
|
|
42
|
-
tlogs.create(
|
|
43
|
-
card_data: Base64::encode64(cards || ""),
|
|
44
|
-
drawn_data: Base64::encode64(drawn || "")
|
|
45
|
-
)
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
def self.display_selection_menu
|
|
50
|
-
unless Aro::Teck.any?
|
|
51
|
-
Aro::P.say(I18n.t("messages.no_tecks"))
|
|
52
|
-
exit(CLI::EXIT_CODES[:SUCCESS])
|
|
53
|
-
end
|
|
54
|
-
c_d = Aro::Teck.current_teck
|
|
55
|
-
Aro::Teck.all.each do |d|
|
|
56
|
-
Aro::P.say("#{d.id == c_d.id ? :*.to_s : " "}#{d.id}): #{d.name}")
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
def self.select_teck(teck)
|
|
61
|
-
return unless teck.present?
|
|
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|
|
|
64
|
-
file.write(teck.id)
|
|
65
|
-
end
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
def self.current_teck
|
|
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))
|
|
71
|
-
return Aro::Teck.find_by(id: current_teck_id)
|
|
72
|
-
end
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
def self.card_strip(card)
|
|
76
|
-
card.gsub(/[+-]/, "").strip
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
def show(count_n: Aro::Mancy::S, order_o: Aro::Tlog::ORDERING[:DESC])
|
|
80
|
-
tlogs_count = tlogs.count
|
|
81
|
-
unless count_n.kind_of?(Numeric) && count_n.to_i > Aro::Mancy::O
|
|
82
|
-
if count_n&.to_s&.to_sym == Aro::Mancy::ALL
|
|
83
|
-
count_n = tlogs_count
|
|
84
|
-
else
|
|
85
|
-
count_n = Aro::Mancy::S
|
|
86
|
-
end
|
|
87
|
-
end
|
|
88
|
-
count_n = [[Aro::Mancy::S, count_n.to_i].max, tlogs_count].min
|
|
89
|
-
Aro::V.say("count_n: #{count_n}")
|
|
90
|
-
Aro::V.say("order_o: #{order_o}")
|
|
91
|
-
|
|
92
|
-
unless Aro::Tlog::ORDERING.values.include?(order_o)
|
|
93
|
-
Aro::P.say(I18n.t("warnings.invalid_order"))
|
|
94
|
-
order_o = Aro::Tlog::ORDERING[:DESC]
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
# perform query
|
|
98
|
-
tlog_records = tlogs.order(created_at: order_o).first(count_n)
|
|
99
|
-
|
|
100
|
-
# todo: this is doing more work than it needs to. needs debugging.
|
|
101
|
-
# Aro::V.say("tlog_records.count: #{tlog_records.count}")
|
|
102
|
-
|
|
103
|
-
# for now tests just expect count
|
|
104
|
-
return tlog_records if Aro::Cor.is_test?
|
|
105
|
-
|
|
106
|
-
Aro::D.say(I18n.t("messages.showing", name: name, count: count_n, order: order_o))
|
|
107
|
-
|
|
108
|
-
Aro::Views::Teck.show
|
|
109
|
-
end
|
|
110
|
-
|
|
111
|
-
def explore
|
|
112
|
-
# allows user to browse each card in the current teck.
|
|
113
|
-
answer = Aro::P.p.select(
|
|
114
|
-
Aro::Mancy::ps1_display.to_s + I18n.t("messages.choose_card"),
|
|
115
|
-
# formatted for tty-prompt gem
|
|
116
|
-
cards.split(Aro::Teck::CARD_DELIM.to_s).map{|c| [I18n.t("cards.#{Aro::Teck.card_strip(c)}.name"), c]}.to_h,
|
|
117
|
-
per_page: TTY::Screen.height - Aro::Mancy::OS,
|
|
118
|
-
cycle: true,
|
|
119
|
-
default: Aro::Mancy::S
|
|
120
|
-
)
|
|
121
|
-
|
|
122
|
-
Aro::Teck.print_card(answer)
|
|
123
|
-
end
|
|
124
|
-
|
|
125
|
-
def self.print_card(card_code)
|
|
126
|
-
card_code = card_code.to_s.upcase
|
|
127
|
-
orientation = "+"
|
|
128
|
-
if card_code.include?("-")
|
|
129
|
-
orientation = "-"
|
|
130
|
-
end
|
|
131
|
-
|
|
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}")
|
|
139
|
-
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
|
-
}
|
|
155
|
-
# todo: add an actual summary
|
|
156
|
-
# Aro::P.say(definition["#{orientation}summary".to_sym])
|
|
157
|
-
output << "".ljust(width, divider)
|
|
158
|
-
Aro::P.say("#{card_code}\n#{output.map{|l| l.center(width)}.join("\n")}")
|
|
159
|
-
end
|
|
160
|
-
|
|
161
|
-
def shuffle
|
|
162
|
-
# shuffles the current teck and generates a log record.
|
|
163
|
-
update(cards: cards.split(Aro::Teck::CARD_DELIM.to_s).shuffle.join(Aro::Teck::CARD_DELIM.to_s))
|
|
164
|
-
end
|
|
165
|
-
|
|
166
|
-
def reset
|
|
167
|
-
# completely reset the teck. replace all drawn and reset order.
|
|
168
|
-
# all orientations will be set to upright.
|
|
169
|
-
update(cards: Aro::Teck.fresh_cards, drawn: "")
|
|
170
|
-
end
|
|
171
|
-
|
|
172
|
-
def replace
|
|
173
|
-
# replaces all drawn cards FIFO and puts them on the bottom of
|
|
174
|
-
# the teck. this will preserve all card orientations.
|
|
175
|
-
cards_arr = cards.split(Aro::Teck::CARD_DELIM.to_s) || []
|
|
176
|
-
drawn_arr = drawn&.split(Aro::Teck::CARD_DELIM.to_s) || []
|
|
177
|
-
|
|
178
|
-
# append each drawn card to cards
|
|
179
|
-
drawn_arr.each{|dc| cards_arr << dc }
|
|
180
|
-
|
|
181
|
-
# clear drawn
|
|
182
|
-
update(drawn: "", cards: cards_arr.join(Aro::Teck::CARD_DELIM.to_s))
|
|
183
|
-
end
|
|
184
|
-
|
|
185
|
-
def draw(z_max: 7, z: 1)
|
|
186
|
-
# the true card
|
|
187
|
-
abs_dev_tarot = nil
|
|
188
|
-
|
|
189
|
-
# oriented card
|
|
190
|
-
dev_tarot = nil
|
|
191
|
-
|
|
192
|
-
# get cards
|
|
193
|
-
cards_arr = cards.split(Aro::Teck::CARD_DELIM.to_s) || []
|
|
194
|
-
# get abs_cards
|
|
195
|
-
abs_cards_arr = cards_arr.map{|c| Aro::Teck.card_strip(c)}
|
|
196
|
-
# get drawn
|
|
197
|
-
drawn_arr = drawn&.split(Aro::Teck::CARD_DELIM.to_s) || []
|
|
198
|
-
|
|
199
|
-
if cards_arr.empty?
|
|
200
|
-
Aro::P.say("there are no cards left to draw.")
|
|
201
|
-
return
|
|
202
|
-
end
|
|
203
|
-
sleeps = 0
|
|
204
|
-
sleeps_max = z_max
|
|
205
|
-
|
|
206
|
-
# find a card that is not already drawn
|
|
207
|
-
while sleeps <= sleeps_max && dev_tarot.nil? do
|
|
208
|
-
# use fallback randomness if /dev/tarot unavailable
|
|
209
|
-
unless Aro::T.is_dev_tarot? && Aro::T.is_dev_tarot_avail?
|
|
210
|
-
dev_tarot = Aro::T.summon_ruby_facot.split("")
|
|
211
|
-
else
|
|
212
|
-
# preferred randomness
|
|
213
|
-
read_value = Aro::T.read_dev_tarot&.strip&.split("")
|
|
214
|
-
if read_value.count >= Aro::Mancy::N - 1
|
|
215
|
-
dev_tarot = read_value
|
|
216
|
-
end
|
|
217
|
-
end
|
|
218
|
-
|
|
219
|
-
unless dev_tarot.nil?
|
|
220
|
-
abs_dev_tarot = dev_tarot[Aro::Mancy::S] + Aro::Mancy::NUMERALS.key(
|
|
221
|
-
dev_tarot.join("")[Aro::Mancy::OS..].to_i
|
|
222
|
-
).to_s
|
|
223
|
-
if abs_cards_arr.include?(abs_dev_tarot)
|
|
224
|
-
# dev_tarot is valid
|
|
225
|
-
dev_tarot = dev_tarot[Aro::Mancy::O] + abs_dev_tarot
|
|
226
|
-
else
|
|
227
|
-
dev_tarot = nil
|
|
228
|
-
end
|
|
229
|
-
end
|
|
230
|
-
|
|
231
|
-
if dev_tarot.nil?
|
|
232
|
-
# dev_tarot is invalid
|
|
233
|
-
sleeps += 1
|
|
234
|
-
sleep(z.to_i)
|
|
235
|
-
end
|
|
236
|
-
end
|
|
237
|
-
|
|
238
|
-
# remove from cards
|
|
239
|
-
cards_arr.delete(cards_arr.select{|c| c.include?(abs_dev_tarot)}.first)
|
|
240
|
-
|
|
241
|
-
# insert dev_tarot to drawn
|
|
242
|
-
drawn_arr << dev_tarot
|
|
243
|
-
Aro::Teck.print_card(dev_tarot)
|
|
244
|
-
|
|
245
|
-
# update database
|
|
246
|
-
update(
|
|
247
|
-
cards: cards_arr.join(Aro::Teck::CARD_DELIM.to_s),
|
|
248
|
-
drawn: drawn_arr.join(Aro::Teck::CARD_DELIM.to_s)
|
|
249
|
-
)
|
|
250
|
-
end
|
|
251
|
-
end
|
data/sys/aro/models/tlog.rb
DELETED
data/sys/aro/views/base.rb
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
=begin
|
|
2
|
-
|
|
3
|
-
views/base.rb
|
|
4
|
-
|
|
5
|
-
the base view (abstract or supposed to be).
|
|
6
|
-
|
|
7
|
-
by i2097i
|
|
8
|
-
|
|
9
|
-
=end
|
|
10
|
-
|
|
11
|
-
module Aro
|
|
12
|
-
module Views
|
|
13
|
-
class Base
|
|
14
|
-
|
|
15
|
-
def self.show
|
|
16
|
-
draw([])
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def self.draw(lines)
|
|
20
|
-
Aro::P.say(lines)
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
data/sys/aro/views/teck.rb
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
=begin
|
|
2
|
-
|
|
3
|
-
vws/games/game.rb
|
|
4
|
-
|
|
5
|
-
the game view.
|
|
6
|
-
|
|
7
|
-
by i2097i
|
|
8
|
-
|
|
9
|
-
=end
|
|
10
|
-
|
|
11
|
-
require_relative :"../models/teck".to_s
|
|
12
|
-
require_relative :"./base".to_s
|
|
13
|
-
|
|
14
|
-
module Aro
|
|
15
|
-
module Views
|
|
16
|
-
class Teck < Aro::Views::Base
|
|
17
|
-
|
|
18
|
-
def self.show
|
|
19
|
-
# if Aro::Mancy.teck.nil?
|
|
20
|
-
# draw(["no teck loaded...exiting..."])
|
|
21
|
-
# return
|
|
22
|
-
# end
|
|
23
|
-
|
|
24
|
-
# Aro::P.say(:"Aro::Dom::Ma_ain.run".to_s)
|
|
25
|
-
# draw(Aro::Dom::Ma_ain.run)
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
end
|