aro 0.1.6 → 0.1.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.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +5 -5
  3. data/.ruby-version +1 -1
  4. data/Gemfile.lock +32 -14
  5. data/aro.gemspec +16 -7
  6. data/bin/aro +24 -24
  7. data/checksums/aro-0.1.6.gem.sha512 +1 -0
  8. data/listen.rb +10 -0
  9. data/locale/en.usage.yml +57 -39
  10. data/locale/en.yml +23 -6
  11. data/sys/aro/d.rb +25 -0
  12. data/sys/aro/db.rb +96 -0
  13. data/sys/aro/mancy.rb +117 -0
  14. data/sys/aro/p.rb +25 -0
  15. data/sys/aro/r.rb +20 -0
  16. data/sys/aro/v.rb +25 -0
  17. data/sys/aro.rb +15 -0
  18. data/sys/cli/config.rb +518 -0
  19. data/sys/cli/constants.rb +53 -0
  20. data/{bin → sys}/cli/create.rb +6 -4
  21. data/sys/cli/deck.rb +98 -0
  22. data/sys/cli/dom.rb +45 -0
  23. data/sys/cli/nterface.rb +25 -0
  24. data/{bin → sys}/cli/usage.rb +1 -1
  25. data/sys/cli.rb +26 -0
  26. data/sys/dom/d.rb +106 -0
  27. data/sys/dom/dom.rb +194 -0
  28. data/sys/dom/p.rb +17 -0
  29. data/sys/models/deck.rb +212 -0
  30. data/sys/models/log.rb +10 -0
  31. data/sys/reiquire.rb +45 -0
  32. data/{lib/aro → sys/shr}/prompt.rb +11 -3
  33. data/sys/shr/t.rb +60 -0
  34. data/sys/shr/version.rb +18 -0
  35. data/sys/views/base.rb +29 -0
  36. data/sys/views/dom.rb +27 -0
  37. data/sys/views/games/deck.rb +97 -0
  38. data/sys/views/games/menu.rb +27 -0
  39. data/sys/views/setup/setup.rb +27 -0
  40. data/tasks/make.rake +2 -2
  41. metadata +55 -22
  42. data/.release +0 -20
  43. data/bin/cli/config.rb +0 -231
  44. data/bin/cli/constants.rb +0 -39
  45. data/bin/cli/deck.rb +0 -100
  46. data/bin/cli.rb +0 -39
  47. data/lib/aro/c.rb +0 -32
  48. data/lib/aro/create.rb +0 -29
  49. data/lib/aro/db.rb +0 -107
  50. data/lib/aro/environment.rb +0 -3
  51. data/lib/aro/i18n.rb +0 -12
  52. data/lib/aro/version.rb +0 -4
  53. data/lib/aro.rb +0 -45
  54. data/lib/models/deck.rb +0 -294
  55. data/lib/models/log.rb +0 -12
data/sys/cli/deck.rb ADDED
@@ -0,0 +1,98 @@
1
+ =begin
2
+
3
+ deck.rb
4
+
5
+ process deck commands.
6
+
7
+ by i2097i
8
+
9
+ =end
10
+
11
+ module CLI
12
+ # cli entrypoint
13
+ def self.deck
14
+ action = CLI::ARGV1&.to_sym
15
+
16
+ if CLI::FLAGS[:HELP].include?(CLI::ARGV1)
17
+ # todo: breakout usage into subcommand-specific verbiage
18
+ CLI.usage::usage
19
+ exit(CLI::EXIT_CODES[:SUCCESS])
20
+ elsif CLI::ARGV1.nil?
21
+ # no args, open deck menu
22
+ Aro::Db.new
23
+ Aro::Deck.display_selection_menu
24
+ elsif action == CLI::CMDS[:DECK][:NEW]
25
+ CLI::Nterface.exit_error_missing_args! if CLI::ARGV2.nil?
26
+ deck = Aro::Deck.make(CLI::ARGV2.to_s)
27
+ Aro::P.say(I18n.t("cli.messages.deck_created_sucessfully", name: Aro::Mancy.game.name))
28
+ Aro::Deck.display_selection_menu
29
+ elsif CLI::CMDS[:DECK].values.include?(action)
30
+ if Aro::Mancy.game.nil?
31
+ Aro::P.say(I18n.t("cli.errors.missing_deck", cmd: Aro::Mancy::I2097I))
32
+ exit(CLI::EXIT_CODES[:GENERAL_ERROR])
33
+ end
34
+
35
+ case action
36
+ when CLI::CMDS[:DECK][:EXPLORE]
37
+ Aro::Mancy.game.explore
38
+ exit(CLI::EXIT_CODES[:SUCCESS])
39
+ when CLI::CMDS[:DECK][:SHUFFLE]
40
+ Aro::P.say(I18n.t("cli.messages.shuffling", name: Aro::Mancy.game.name))
41
+ Aro::Mancy.game.shuffle
42
+ when CLI::CMDS[:DECK][:DRAW]
43
+ Aro::P.say(I18n.t("cli.messages.drawing", name: Aro::Mancy.game.name))
44
+ Aro::P.say(I18n.t("cli.messages.drawing_from_dimension", dimension: "#{CLI::Config.ivar(:DIMENSION)}"))
45
+ Aro::Mancy.game.draw(
46
+ is_dt_dimension: Aro::T::is_dev_tarot?,
47
+ z_max: CLI::Config.ivar(:Z_MAX).to_i,
48
+ z: CLI::Config.ivar(:Z)
49
+ )
50
+ when CLI::CMDS[:DECK][:REPLACE]
51
+ Aro::P.say(I18n.t("cli.messages.replacing_drawn", name: Aro::Mancy.game.name))
52
+ Aro::Mancy.game.replace
53
+ when CLI::CMDS[:DECK][:RESET]
54
+ if Aro::Mancy::YES.to_s != Aro::P.p.ask(I18n.t("cli.messages.confirmation_prompt", name: Aro::Mancy.game.name))
55
+ Aro::P.say(I18n.t("cli.messages.understood", name: Aro::Mancy.game.name))
56
+ exit(CLI::EXIT_CODES[:SUCCESS])
57
+ end
58
+
59
+ Aro::P.say(I18n.t("cli.messages.resetting", name: Aro::Mancy.game.name))
60
+ Aro::Mancy.game.reset
61
+ end
62
+
63
+ Aro::Mancy.game.show(**CLI::shoptions)
64
+ end
65
+ end
66
+
67
+ # parse show options
68
+ # todo: better naming
69
+ def self.shoptions
70
+ show_options_count = Aro::Mancy::S
71
+ show_options_order = Aro::Log::ORDERING[:DESC]
72
+
73
+ # Aro::P.say("ARGV.map{|a| a.to_sym} => #{ARGV.map{|a| a.to_sym}}")
74
+
75
+ count_option_flags = ARGV.map{|a| a.to_sym} & CLI::FLAGS[:SHOW_COUNT]
76
+ # Aro::P.say("count_option_flags: #{count_option_flags}")
77
+ if count_option_flags.any?
78
+ # get the ARGV index element after flag index
79
+ show_options_count = ARGV[ARGV.index(count_option_flags.first.to_s) + 1]
80
+ show_options_count = show_options_count.to_i unless [0, nil].include?(show_options_count&.to_i)
81
+ # Aro::P.say("show_options_count: #{show_options_count}")
82
+ end
83
+
84
+ order_option_flags = ARGV.map{|a| a.to_sym} & CLI::FLAGS[:SHOW_ORDER]
85
+ # Aro::P.say("count_option_flags: #{order_option_flags}")
86
+ if order_option_flags.any?
87
+ # get the ARGV index element after flag index
88
+ show_options_order = ARGV[ARGV.index(order_option_flags.first.to_s) + 1].to_sym
89
+ Aro::P.say("show_options_order: #{show_options_order}")
90
+ end
91
+
92
+ {
93
+ count_n: show_options_count,
94
+ order_o: show_options_order
95
+ }
96
+ end
97
+
98
+ end
data/sys/cli/dom.rb ADDED
@@ -0,0 +1,45 @@
1
+ =begin
2
+
3
+ dom.rb
4
+
5
+ process dom commands.
6
+
7
+ by i2097i
8
+
9
+ =end
10
+
11
+ module CLI
12
+ def self.dom
13
+ action = CLI::ARGV1&.to_sym
14
+
15
+ CLI::Nterface.exit_error_invalid_usage! unless CLI::CMDS[:DOM].values.include?(action)
16
+
17
+ if CLI::FLAGS[:HELP].include?(CLI::ARGV1)
18
+ CLI.usage::usage
19
+ exit(CLI::EXIT_CODES[:SUCCESS])
20
+ elsif CLI::ARGV1.nil?
21
+ # no args, default dom action
22
+ Aro::Dom.map
23
+ end
24
+
25
+ case action
26
+ when CLI::CMDS[:DOM][:MAP]
27
+ Aro::Dom.map
28
+ when CLI::CMDS[:DOM][:INIT]
29
+ arodome = Aro::Dom.new
30
+ arodome.generate
31
+ when CLI::CMDS[:DOM][:NEW]
32
+ CLI::Nterface.exit_error_missing_args! if CLI::ARGV2.nil?
33
+ if Aro::Dom.in_arodom?
34
+ # todo: i18n
35
+ Aro::P.say("unable to create an arodome because you are already in arodom.")
36
+ else
37
+ Aro::Dom.create(CLI::ARGV2.to_s)
38
+ end
39
+ else
40
+ if CLI::CMDS[:DOM].values.include?(action)
41
+ # todo:
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,25 @@
1
+ =begin
2
+
3
+ nterface.rb
4
+
5
+ cli nterface.
6
+
7
+ by i2097i
8
+
9
+ =end
10
+
11
+ module CLI
12
+ class Nterface
13
+ def self.exit_error_missing_args!
14
+ Aro::P.say(I18n.t("cli.errors.header", cmd: Aro::Mancy::I2097I))
15
+ Aro::P.say(I18n.t("cli.errors.missing_args", cmd: Aro::Mancy::I2097I))
16
+ exit(CLI::EXIT_CODES[:INVALID_ARG])
17
+ end
18
+
19
+ def self.exit_error_invalid_usage!
20
+ Aro::P.say(I18n.t("cli.errors.header", cmd: Aro::Mancy::I2097I))
21
+ Aro::P.say(I18n.t("cli.errors.invalid_usage", cmd: Aro::Mancy::I2097I))
22
+ exit(CLI::EXIT_CODES[:INVALID_ARG])
23
+ end
24
+ end
25
+ end
@@ -10,6 +10,6 @@
10
10
 
11
11
  module CLI
12
12
  def self.usage
13
- Aro::P.less(I18n.t("cli.usage"))
13
+ Aro::P.less(I18n.t("usage.main"))
14
14
  end
15
15
  end
data/sys/cli.rb ADDED
@@ -0,0 +1,26 @@
1
+ =begin
2
+
3
+ cli
4
+
5
+ the very first file loaded.
6
+
7
+ by i2097i
8
+
9
+ =end
10
+
11
+ module CLI
12
+ # init config
13
+ CLI::Config.instance
14
+
15
+ if CLI::CMDS[:DECK].values.include?(ARGV[0]&.to_sym)
16
+ # enable deck shortcut (skip typing deck while in-game)
17
+ ARGV0 = :deck
18
+ ARGV1 = ARGV[0]&.to_sym
19
+ ARGV2 = ARGV[1]&.to_sym
20
+ else
21
+ # default
22
+ ARGV0 = ARGV[0]&.to_sym
23
+ ARGV1 = ARGV[1]&.to_sym
24
+ ARGV2 = ARGV[2]&.to_sym
25
+ end
26
+ end
data/sys/dom/d.rb ADDED
@@ -0,0 +1,106 @@
1
+ =begin
2
+
3
+ d.rb
4
+
5
+ dom definition.
6
+
7
+ by i2097i
8
+
9
+ =end
10
+
11
+ require_relative :dom.to_s
12
+
13
+ module Aro
14
+ class Dom::D
15
+ # definition of rooms in each layout section
16
+ WINGS = {
17
+ WELCOME: {
18
+ WAITE: {
19
+ name: Aro::Dom::WAITE,
20
+ description: "sign up."
21
+ },
22
+ WELCOME: {
23
+ name: Aro::Dom::WELCOME,
24
+ description: "sign in."
25
+ },
26
+ WINNER: {
27
+ name: Aro::Dom::WINNER,
28
+ description: "win."
29
+ },
30
+ },
31
+ GAMES: {
32
+ ABPPS: {
33
+ name: Aro::Dom::ABPPS,
34
+ description: "artificial beings."
35
+ },
36
+ HBPPS: {
37
+ name: Aro::Dom::HBPPS,
38
+ description: "human beings."
39
+ },
40
+ SHPPS: {
41
+ name: Aro::Dom::SHPPS,
42
+ description: "human and artificial beings."
43
+ },
44
+ VIPPS: {
45
+ name: Aro::Dom::VIPPS,
46
+ description: "very important - 100% /dev/tarot users."
47
+ },
48
+ },
49
+ KNOW: {
50
+ LIBRARY: {
51
+ name: Aro::Dom::LIBRARY,
52
+ description: "definition management."
53
+ },
54
+ TEMPLE: {
55
+ name: Aro::Dom::TEMPLE,
56
+ description: "mindfulness management."
57
+ },
58
+ },
59
+ SETUP: {
60
+ SETTINGS: {
61
+ name: Aro::Dom::SETTINGS,
62
+ description: "user settings and configuration."
63
+ },
64
+ },
65
+ }
66
+
67
+ # overall layout
68
+ LAYOUT = {
69
+ WELCOME: {
70
+ name: Aro::Dom::WELCOME,
71
+ description: "sign up process.",
72
+ rooms: [
73
+ Aro::Dom::D::WINGS[:WELCOME][:WAITE],
74
+ Aro::Dom::D::WINGS[:WELCOME][:WELCOME],
75
+ Aro::Dom::D::WINGS[:WELCOME][:WINNER],
76
+ ]
77
+ },
78
+ GAMES: {
79
+ name: Aro::Dom::GAMES,
80
+ description: "aroflie game rooms.",
81
+ rooms: [
82
+ Aro::Dom::D::WINGS[:GAMES][:ABPPS],
83
+ Aro::Dom::D::WINGS[:GAMES][:HBPPS],
84
+ Aro::Dom::D::WINGS[:GAMES][:SHPPS],
85
+ Aro::Dom::D::WINGS[:GAMES][:VIPPS],
86
+ ],
87
+ },
88
+ KNOW: {
89
+ name: Aro::Dom::KNOW,
90
+ description: "information space.",
91
+ rooms: [
92
+ Aro::Dom::D::WINGS[:KNOW][:LIBRARY],
93
+ Aro::Dom::D::WINGS[:KNOW][:TEMPLE]
94
+ ],
95
+ },
96
+ SETUP: {
97
+ name: Aro::Dom::SETUP,
98
+ description: "user configuration space.",
99
+ rooms: [
100
+ Aro::Dom::D::WINGS[:SETUP][:SETTINGS]
101
+ ],
102
+ }
103
+ }
104
+
105
+ end
106
+ end
data/sys/dom/dom.rb ADDED
@@ -0,0 +1,194 @@
1
+ =begin
2
+
3
+ d.rb
4
+
5
+ aro and dom.
6
+
7
+ by i2097i
8
+
9
+ =end
10
+
11
+ module Aro
12
+ class Dom
13
+ PS1 = Aro::Dom.name
14
+ DOT = :"."
15
+ DOTT = :"#{DOT}#{DOT}"
16
+ ETHERGEIST = :ethergeist
17
+ ETHER_FILE = :".#{Aro::Dom::ETHERGEIST}"
18
+
19
+ # < root space
20
+ ARODOME = :arodome
21
+
22
+ # < user spaces
23
+ WELCOME = :welcome
24
+ GAMES = :games
25
+ KNOW = :know
26
+ SETUP = :setup
27
+
28
+ # > welcome spaces
29
+ WAITE = :waite
30
+ WINNER = :winner
31
+
32
+ # > game spaces
33
+ ABPPS = :abpps
34
+ HBPPS = :hbpps
35
+ SHPPS = :shpps
36
+ VIPPS = :vipps
37
+
38
+ # > know spaces
39
+ LIBRARY = :library
40
+ TEMPLE = :temple
41
+ # ...
42
+
43
+ # > setup spaces
44
+ SETTINGS = :settings
45
+ # ...
46
+
47
+ def self.create(name)
48
+ if Dir.exist?(name) || File.exist?(name)
49
+ # todo: i18n
50
+ Aro::Dom::P.say("unable to create arodome at #{name}. file or directory already exists.")
51
+ end
52
+
53
+ # todo: i18n
54
+ Aro::Dom::P.say("creating arodome named #{name}")
55
+ FileUtils.mkdir(name)
56
+ ether_file_path = "#{name}/#{Aro::Dom::ETHER_FILE}"
57
+ FileUtils.mkdir(ether_file_path)
58
+ File.open(File.join(ether_file_path, Aro::Mancy::NAME_FILE.to_s), "w+") do |file|
59
+ file.write(name)
60
+ end
61
+
62
+ # todo: i18n
63
+ Aro::Dom::P.say("#{name} arodome created. enter the following commands to begin.")
64
+ Aro::Dom::P.say("$ cd #{name}")
65
+ Aro::Dom::P.say("$ aro dom init")
66
+ end
67
+
68
+ def self.in_arodom?
69
+ pwd_path = Dir.pwd.split("/").reject{|p| p.empty?}
70
+ pwd = "/"
71
+
72
+ pwd_path.any?{|step|
73
+ pwd = File.join(pwd, step)
74
+ ls = Dir.glob("#{pwd}/#{ETHER_FILE}", File::FNM_DOTMATCH)
75
+ ls.any?
76
+ }
77
+ end
78
+
79
+ def self.ethergeist_path
80
+ # todo: traverse up pwd and locate etherfile/.name
81
+ # pwd_path = Dir.pwd.split("/").reject{|p| p.empty?}
82
+ # pwd = "/"
83
+
84
+ # for now assume in arodome root
85
+ File.join(Aro::Dom::ETHER_FILE.to_s, Aro::Mancy::NAME_FILE.to_s)
86
+ end
87
+
88
+ def dom_root
89
+ # todo:
90
+ end
91
+
92
+ def generate
93
+ return unless Aro::Dom.in_arodom?
94
+
95
+ # todo: add file permissions to Aro::Dom::ARODOME and all WINGS
96
+
97
+ Aro::Dom::P.say("generating wings...")
98
+ Aro::Dom::D::LAYOUT.values.each{|w| generate_wing w}
99
+
100
+ Aro::Dom::P.say("#{Aro::Dom.name} initialization complete!")
101
+ end
102
+
103
+ def generate_wing(wing)
104
+ return unless Aro::Dom::D::LAYOUT.values.include?(wing)
105
+
106
+ Aro::Dom::P.say("generating the #{wing[:name]} wing...")
107
+ FileUtils.mkdir(wing[:name].to_s)
108
+
109
+ wing[:rooms].each{|r| generate_room(wing, r)}
110
+ end
111
+
112
+ def generate_room(wing, room)
113
+ return unless Aro::Dom::D::WINGS[wing[:name].upcase].values.include?(room)
114
+
115
+ Aro::Dom::P.say("generating the #{room[:name]} room.")
116
+ room_path = File.join(wing[:name].to_s, room[:name].to_s)
117
+ FileUtils.mkdir(room_path)
118
+
119
+ if wing[:name] == Aro::Dom::GAMES
120
+ File.open(File.join(room_path, Aro::Mancy::NAME_FILE.to_s), "w+") do |f|
121
+ f.write(room[:name])
122
+ end
123
+ end
124
+ end
125
+
126
+ def self.map
127
+ return unless Aro::Dom.in_arodom?
128
+
129
+ dc = CLI::Config.display_config
130
+ width = dc[:WIDTH]
131
+ divider = dc[:DIVIDER] * width + "\n"
132
+
133
+ map_str = "\n"
134
+ map_str += divider
135
+
136
+ # todo: ethergeist_path
137
+ map_name = File.read(Aro::Dom.ethergeist_path).upcase
138
+ Aro::V.say("map_name: #{map_name}")
139
+ title_divider = dc[:DIVIDER] * ((width - map_name.length) / Aro::Mancy::OS)
140
+ map_str += (title_divider + map_name).ljust(width, dc[:DIVIDER]) + "\n"
141
+ map_str += divider
142
+
143
+
144
+
145
+ Aro::P.say(map_str)
146
+ end
147
+ end
148
+ end # aroadhome
149
+
150
+ =begin
151
+ -----------------------------------------------------------------------------
152
+ -----------------------------------------------------------------------------
153
+ -------------------------------ARODOME MAP-----------------------------------
154
+ -----------------------------------------------------------------------------
155
+ -----------------------------------------------------------------------------
156
+ | |
157
+ | |
158
+ | |
159
+ | |
160
+ | |
161
+ | GAMES |
162
+ | |
163
+ | |
164
+ | |
165
+ | |
166
+ | |
167
+ | |
168
+ | |
169
+ | |
170
+ | WELCOME KNOW |
171
+ | |
172
+ | |
173
+ | |
174
+ | |
175
+ | . |
176
+ | |
177
+ | |
178
+ | |
179
+ | |
180
+ | |
181
+ | |
182
+ | |
183
+ | |
184
+ | .. SETUP |
185
+ | |
186
+ | |
187
+ | |
188
+ | |
189
+ -----------------------------------------------------------------------------
190
+ -----------------------------------------------------------------------------
191
+ -----------------------------------------------------------------------------
192
+
193
+
194
+ =end
data/sys/dom/p.rb ADDED
@@ -0,0 +1,17 @@
1
+ =begin
2
+
3
+ p.rb
4
+
5
+ p logger for dom space.
6
+
7
+ by i2097i
8
+
9
+ =end
10
+
11
+ module Aro
12
+ class Dom::P < Aro::Prompt
13
+ def self.say(message)
14
+ Aro::Dom::P.p.say(">[#{Aro::Dom::PS1}]>: #{message}")
15
+ end
16
+ end
17
+ end