aro 0.1.3 → 0.1.4

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: 112a9db053a27471ff5444243b12bd55426a81491695134c269c5bb4f3513cac
4
- data.tar.gz: c6d23c2cb1f9ab42d45711e9f42d91f32aa1f01d0d56896fe73751814eaa8d35
3
+ metadata.gz: a276927c911f1781041e6d5c274c1611f0a23a948edb9b0fb6bc17518d22eee5
4
+ data.tar.gz: 415a4ad29297c5c8815127fb4bae7c5dc97f4f8eb12cda4aacf2235997cb895e
5
5
  SHA512:
6
- metadata.gz: 7b6c85313304ddb52defa7c17b32bbab9bd90fbb79a77235bd065ca67fb88b94a9a5005092599f85d31363cf7a922f5e625c15ced470ac49a1d9aa8b9ea04543
7
- data.tar.gz: '06156495bdd7718b9655b1dc56337ba42231d3cd15a6f971a025b3941f2eaa819a2fe65d0e33890669f8b0b302a4b30eead4a50687632230b0ce220df3f49e57'
6
+ metadata.gz: a91cb814964c27d4aa6c53aea311dc530ecd897d4534f19b3295ad8954c7611268102b8113dc4ecaea52d23fb975dbf890bcfbcfc575727741c497942f3ea36f
7
+ data.tar.gz: b8270db12a879b8738d014f748929641d234234f61cbba5cc351907319d5616bfef2ae1f58616827930673703258841c2ee6c70d732ab247ae87941cf1bf0073
data/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ .DS_Store
2
+ .aro
3
+ .aro_test
4
+ .name
5
+ *.sql
6
+ *.log
data/.release ADDED
@@ -0,0 +1,20 @@
1
+ # helper script for consistency when doing releases
2
+
3
+ # start on latest develop branch
4
+
5
+ # 1) update version and release notes (manually)
6
+ # 2) test and build
7
+ # $ rake make
8
+ # 3) build checksum
9
+ # $ rake build:checksum
10
+ # 4) create a commit
11
+ # 5) generate tag
12
+ # tag message format:
13
+ # vx.x.x
14
+ # <release_note_text>
15
+ # $ gitaga vx.x.x && gush tag vx.x.x
16
+ # 6) push develop
17
+ # 7) pull request develop -> master & merge
18
+ # 8) checkout and pull master
19
+ # 9) publish to rubygems
20
+ # $ gem push pkg/aro-x.x.x.gem
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ ruby-3.4.7
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source :"https://rubygems.org".to_s
2
+ gemspec
3
+
4
+ # do not modify
5
+ # add dependencies to the gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,105 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ aro (0.1.3)
5
+ activerecord (~> 8.1, >= 8.1.1)
6
+ i18n (~> 1.14, >= 1.14.7)
7
+ sqlite3 (~> 2.8, >= 2.8.0)
8
+ tty-prompt (~> 0.23.1, >= 0.23.1)
9
+
10
+ GEM
11
+ remote: https://rubygems.org/
12
+ specs:
13
+ activemodel (8.1.1)
14
+ activesupport (= 8.1.1)
15
+ activerecord (8.1.1)
16
+ activemodel (= 8.1.1)
17
+ activesupport (= 8.1.1)
18
+ timeout (>= 0.4.0)
19
+ activesupport (8.1.1)
20
+ base64
21
+ bigdecimal
22
+ concurrent-ruby (~> 1.0, >= 1.3.1)
23
+ connection_pool (>= 2.2.5)
24
+ drb
25
+ i18n (>= 1.6, < 2)
26
+ json
27
+ logger (>= 1.4.2)
28
+ minitest (>= 5.1)
29
+ securerandom (>= 0.3)
30
+ tzinfo (~> 2.0, >= 2.0.5)
31
+ uri (>= 0.13.1)
32
+ base64 (0.3.0)
33
+ bigdecimal (3.3.1)
34
+ concurrent-ruby (1.3.5)
35
+ connection_pool (2.5.4)
36
+ diff-lcs (1.6.2)
37
+ drb (2.2.3)
38
+ i18n (1.14.7)
39
+ concurrent-ruby (~> 1.0)
40
+ json (2.16.0)
41
+ logger (1.7.0)
42
+ minitest (5.26.1)
43
+ pastel (0.8.0)
44
+ tty-color (~> 0.5)
45
+ rake (13.3.1)
46
+ rspec (3.13.2)
47
+ rspec-core (~> 3.13.0)
48
+ rspec-expectations (~> 3.13.0)
49
+ rspec-mocks (~> 3.13.0)
50
+ rspec-core (3.13.6)
51
+ rspec-support (~> 3.13.0)
52
+ rspec-expectations (3.13.5)
53
+ diff-lcs (>= 1.2.0, < 2.0)
54
+ rspec-support (~> 3.13.0)
55
+ rspec-mocks (3.13.7)
56
+ diff-lcs (>= 1.2.0, < 2.0)
57
+ rspec-support (~> 3.13.0)
58
+ rspec-support (3.13.6)
59
+ securerandom (0.4.1)
60
+ sqlite3 (2.8.0-aarch64-linux-gnu)
61
+ sqlite3 (2.8.0-aarch64-linux-musl)
62
+ sqlite3 (2.8.0-arm-linux-gnu)
63
+ sqlite3 (2.8.0-arm-linux-musl)
64
+ sqlite3 (2.8.0-arm64-darwin)
65
+ sqlite3 (2.8.0-x86-linux-gnu)
66
+ sqlite3 (2.8.0-x86-linux-musl)
67
+ sqlite3 (2.8.0-x86_64-darwin)
68
+ sqlite3 (2.8.0-x86_64-linux-gnu)
69
+ sqlite3 (2.8.0-x86_64-linux-musl)
70
+ timeout (0.4.4)
71
+ tty-color (0.6.0)
72
+ tty-cursor (0.7.1)
73
+ tty-prompt (0.23.1)
74
+ pastel (~> 0.8)
75
+ tty-reader (~> 0.8)
76
+ tty-reader (0.9.0)
77
+ tty-cursor (~> 0.7)
78
+ tty-screen (~> 0.8)
79
+ wisper (~> 2.0)
80
+ tty-screen (0.8.2)
81
+ tzinfo (2.0.6)
82
+ concurrent-ruby (~> 1.0)
83
+ uri (1.1.1)
84
+ wisper (2.0.1)
85
+
86
+ PLATFORMS
87
+ aarch64-linux-gnu
88
+ aarch64-linux-musl
89
+ arm-linux-gnu
90
+ arm-linux-musl
91
+ arm64-darwin
92
+ x86-linux-gnu
93
+ x86-linux-musl
94
+ x86_64-darwin
95
+ x86_64-linux-gnu
96
+ x86_64-linux-musl
97
+
98
+ DEPENDENCIES
99
+ aro!
100
+ bundler (~> 2.7, >= 2.7.2)
101
+ rake (~> 13.3, >= 13.3.1)
102
+ rspec (~> 3.13, >= 3.13.2)
103
+
104
+ BUNDLED WITH
105
+ 2.7.2
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (C) 2025 Scot Reichman
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this
6
+ software and associated documentation files (the “Software”), to deal in the Software
7
+ without restriction, including without limitation the rights to use, copy, modify,
8
+ merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
9
+ permit persons to whom the Software is furnished to do so, subject to the following
10
+ conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all copies
13
+ or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
16
+ INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
17
+ PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
18
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
19
+ CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
20
+ OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
data/README.md ADDED
@@ -0,0 +1,70 @@
1
+ # aro
2
+ >__a cli for tarot__ - follow the way of the aro eht.
3
+
4
+ ##### __current version:__
5
+ [![Gem Version](https://badge.fury.io/rb/aro.svg)](https://badge.fury.io/rb/aro)
6
+
7
+ aro is a command line interface that allows you to manage multiple tarot decks.
8
+
9
+
10
+ ### install
11
+
12
+ ```bash
13
+ $ gem install aro
14
+ ```
15
+
16
+ ### use
17
+
18
+ ```bash
19
+ $ aro -h
20
+ ```
21
+
22
+ [usage documentation](https://raw.githubusercontent.com/i2097i/aro/refs/heads/master/locale/en.usage.yml)
23
+
24
+
25
+ [card definitions](https://raw.githubusercontent.com/i2097i/aro/refs/heads/master/locale/en.cards.yml)
26
+
27
+
28
+ ### develop
29
+
30
+ [rubygems.org guides](https://guides.rubygems.org)
31
+
32
+ ```ruby
33
+ # the Rakefile contains bundler's gem_tasks,
34
+ # which are used for gem development.
35
+
36
+ # Rakefile
37
+ require "bundler/gem_tasks"
38
+ ```
39
+
40
+ ```bash
41
+ # list tasks
42
+ $ rake --tasks
43
+
44
+ # build gem
45
+ $ rake build
46
+
47
+ # build and install
48
+ $ rake install
49
+ ```
50
+
51
+ ### test
52
+
53
+ ```bash
54
+ $ rspec
55
+ ```
56
+
57
+ #### pre-commit hook:
58
+ ```bash
59
+ : cat .git/hooks/pre-commit
60
+ #!/bin/sh
61
+
62
+ echo "running pre-commit hooks"
63
+ echo "exec rspec -f d -o ./spec/spec.log"
64
+ exec rspec -f d -o ./spec/spec.log
65
+ ```
66
+
67
+ [license](http://opensource.org/licenses/MIT)
68
+ [issues](https://github.com/i2097i/aro/issues)
69
+
70
+ >aro by i2097i is copyright (2025)
data/Rakefile ADDED
@@ -0,0 +1,5 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ task :default => :rspec
4
+
5
+ Rake.add_rakelib :"tasks".to_s
data/aro.gemspec ADDED
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+
3
+ require :aro.to_s
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "aro"
7
+ spec.version = Aro::VERSION
8
+ spec.authors = ["i2097i"]
9
+ spec.email = ["i2097i@hotmail.com"]
10
+ spec.description = "a cli for tarot."
11
+ spec.summary = "follow the way of the aro eht."
12
+ spec.homepage = "https://github.com/i2097i/aro"
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files`.split("\n").reject{|f| f.match(%r{^(spec)/})}
16
+ spec.bindir = "bin"
17
+ spec.executables = ["aro"]
18
+ spec.require_paths = ["lib", "bin/cli"]
19
+
20
+ # development gems
21
+ spec.add_development_dependency "bundler", "~> 2.7", ">= 2.7.2"
22
+ spec.add_development_dependency "rake", "~> 13.3", ">= 13.3.1"
23
+ spec.add_development_dependency "rspec", "~> 3.13", ">= 3.13.2"
24
+
25
+ # runtime gems
26
+ spec.add_runtime_dependency "i18n", "~> 1.14", ">= 1.14.7"
27
+ spec.add_runtime_dependency "activerecord", "~> 8.1", ">= 8.1.1"
28
+ spec.add_runtime_dependency "sqlite3", "~> 2.8", ">= 2.8.0"
29
+ spec.add_runtime_dependency "tty-prompt", "~> 0.23.1", ">= 0.23.1"
30
+ end
data/bin/aro CHANGED
@@ -15,11 +15,6 @@ require_relative :cli.to_s
15
15
  # todo: add tab completion using abbrev gem
16
16
  # https://stackoverflow.com/a/11627931
17
17
 
18
- # todo: response formats
19
- # text (default)
20
- # json
21
- #
22
-
23
18
  module CLI
24
19
  if CLI::FLAGS[:VERSION].include?(CLI::ARGV0)
25
20
  Aro::P.say(Aro::VERSION)
data/bin/cli/config.rb CHANGED
@@ -7,17 +7,167 @@ module CLI
7
7
  CONFIG_FILE = :".config".to_s
8
8
  CONFIG_FILE_PATH = "#{Aro::Db.base_aro_dir(Aro::Db.get_name_from_namefile)}/#{CLI::Config::CONFIG_FILE}"
9
9
 
10
- DEFAULT_CONFIG = {
10
+ INTS = {
11
+ O: 0,
12
+ I: 1,
13
+ VII: 7,
14
+ XXII: 22,
15
+ MMXCVII: Aro::Mancy::I2097I[1..4].to_i,
16
+ }
17
+
18
+ # possible formats
19
+ #
20
+ # example usage:
21
+ # CLI::Config::FORMATS[:TEXT]
22
+ FORMATS = {
23
+ TEXT: :text,
24
+ JSON: :json,
25
+ }
26
+
27
+ # possible dimensions
28
+ #
29
+ # example usage:
30
+ # CLI::Config::DMS[:DEV_TAROT]
31
+ DMS = {
32
+ DEV_TAROT: :dev_tarot,
33
+ RUBY_FACOT: :ruby_facot,
34
+ }
35
+
36
+ # types used in definition
37
+ #
38
+ # example usage:
39
+ # CLI::Config::DEF_TYPES[:INT][:validator].call(unvalid, CLI::Config::DEF[:DIMENSION])
40
+ DEF_TYPES = {
41
+ INT: {
42
+ name: :int,
43
+ description: I18n.t("cli.config.type_int_description"),
44
+ validator: Proc.new{|unvalid, deff, key|
45
+ CLI::Config.def_valid?(deff, key) &&
46
+ CLI::Config.int_valid?(unvalid) &&
47
+ unvalid.to_i <= deff[:min] &&
48
+ unvalid.to_i >= deff[:max]
49
+ }
50
+ },
51
+ VALUES: {
52
+ name: :values,
53
+ description: I18n.t("cli.config.type_values_description"),
54
+ validator: Proc.new{|unvalid, deff, key|
55
+ CLI::Config.def_valid?(deff, key) &&
56
+ deff[:possible_values].keys.include?(unvalid.to_sym)
57
+ }
58
+ },
59
+ }
60
+
61
+ # adapts I18n translations to generate bash environment vars.
62
+ #
63
+ # example usage:
64
+ # CLI::Config::DEF[:Z_MAX]
65
+ DEF = {
11
66
  FORMAT: {
67
+ type: :values,
68
+ description: I18n.t(
69
+ "cli.config.format_description",
70
+ possible_values: CLI::Config::FORMATS.values.join(", ")
71
+ ),
12
72
  value: :text,
13
- possible_values: [
14
- {name: :text, description: I18n.t("cli.config.text_format_description")},
15
- {name: :json, description: I18n.t("cli.config.json_format_description")},
16
- ]
17
- }
73
+ possible_values: {
74
+ text: I18n.t("cli.config.text_format_description"),
75
+ json: I18n.t("cli.config.json_format_description")
76
+ }
77
+ },
78
+ DIMENSION: {
79
+ type: :values,
80
+ description: I18n.t(
81
+ "cli.config.dimension_description",
82
+ possible_values: CLI::Config::DMS.values.join(", ")
83
+ ),
84
+ value: :dev_tarot,
85
+ possible_values: {
86
+ dev_tarot: I18n.t("cli.config.dimension_dev_tarot_description"),
87
+ ruby_facot: I18n.t("cli.config.dimension_ruby_facot_description"),
88
+ }
89
+ },
90
+ # not implemented. replace Aro::Deck::DRAW_COUNT with this
91
+ # DRAW_COUNT: {
92
+ # type: :int,
93
+ # description: I18n.t(
94
+ # "cli.config.draw_count_description",
95
+ # min: CLI::Config::INTS[:I],
96
+ # max: CLI::Config::INTS[:XXII],
97
+ # ),
98
+ # value: CLI::Config::INTS[:VII],
99
+ # min: CLI::Config::INTS[:I],
100
+ # max: CLI::Config::INTS[:XXII],
101
+ # },
102
+ Z: {
103
+ type: :int,
104
+ description: I18n.t(
105
+ "cli.config.z_description",
106
+ min: CLI::Config::INTS[:I],
107
+ max: CLI::Config::INTS[:MMXCVII],
108
+ ),
109
+ value: CLI::Config::INTS[:I],
110
+ min: CLI::Config::INTS[:I],
111
+ max: CLI::Config::INTS[:MMXCVII],
112
+ },
113
+ Z_MAX: {
114
+ type: :int,
115
+ description: I18n.t(
116
+ "cli.config.z_max_description",
117
+ min: CLI::Config::INTS[:I],
118
+ max: CLI::Config::INTS[:XXII],
119
+ ),
120
+ value: CLI::Config::INTS[:VII],
121
+ min: CLI::Config::INTS[:I],
122
+ max: CLI::Config::INTS[:XXII],
123
+ },
124
+
18
125
  # ...
19
126
  }
20
127
 
128
+ def generate_config
129
+ # todo: localize generated config text
130
+ Aro::P.say(I18n.t("cli.config.generating_default_config", name: CLI::Config::CONFIG_FILE_PATH))
131
+ File.open(CLI::Config::CONFIG_FILE_PATH, "w+") do |file|
132
+ file.write("# #{Aro::Mancy::PS1} configuration file.\n")
133
+ file.write("# this file was auto generated by the aro cli.\n")
134
+ Aro::Mancy::OS.times do
135
+ file.write("#\n")
136
+ end
137
+ file.write("# CLI::Config::DEF_TYPES\n")
138
+ file.write("# describes the possible types of variables.\n")
139
+ CLI::Config::DEF_TYPES.each{|k, v|
140
+ file.write("# #{k}: #{v[:description]}\n")
141
+ }
142
+ Aro::Mancy::OS.times do
143
+ file.write("#\n")
144
+ end
145
+ file.write("# CLI::Config::DEF\n")
146
+ file.write("# define & expose an aro bash api via ENV variables.\n")
147
+ file.write("# modifying them in this file will change aro's behavior.\n")
148
+ Aro::Mancy::OS.times do
149
+ file.write("#\n")
150
+ end
151
+ CLI::Config::DEF.each{|k, v|
152
+ var_name = CLI::Config.var_key_with_suffix(k)
153
+ file.write("# [#{var_name}]\n")
154
+ file.write("# => #{I18n.t("cli.config.def_type")}: #{v[:type]}\n")
155
+ case v[:type]
156
+ when CLI::Config::DEF_TYPES[:INT][:name]
157
+ file.write("# => #{I18n.t("cli.config.minimum")}: #{v[:min]}\n")
158
+ file.write("# => #{I18n.t("cli.config.maximum")}: #{v[:max]}\n")
159
+ when CLI::Config::DEF_TYPES[:VALUES][:name]
160
+ file.write("# => #{I18n.t("cli.config.possible_values")}:\n")
161
+ v[:possible_values].each{|name, description|
162
+ file.write("# => #{name} - #{description}\n")
163
+ }
164
+ end
165
+ file.write("export #{var_name}=#{v[:value]}\n\n")
166
+ }
167
+ file.write("\n")
168
+ end
169
+ end
170
+
21
171
  def initialize
22
172
  return unless Aro::Mancy.is_aro_dir?
23
173
  unless File.exist?(CLI::Config::CONFIG_FILE_PATH)
@@ -27,8 +177,15 @@ module CLI
27
177
  source_config
28
178
  end
29
179
 
30
- def self.format
31
- CLI::Config.var_value_with_suffix(:FORMAT)
180
+ def self.def_valid?(deff, key)
181
+ deff == CLI::Config::DEF[key]
182
+ end
183
+
184
+ def self.int_valid?(unvalid)
185
+ return !unvalid.nil? && (
186
+ unvalid.kind_of?(Integer) ||
187
+ ("0" != unvalid && unvalid.respond_to?(:to_i))
188
+ )
32
189
  end
33
190
 
34
191
  def self.var_value_with_suffix(suffix)
@@ -39,33 +196,28 @@ module CLI
39
196
  "#{CLI::Config::VAR_PREFIX}#{suffix}"
40
197
  end
41
198
 
42
- def generate_config
43
- Aro::P.say(I18n.t("cli.config.generating_default_config", name: CLI::Config::CONFIG_FILE_PATH))
44
- File.open(CLI::Config::CONFIG_FILE_PATH, "w+") do |file|
45
- file.write("# #{Aro::Mancy::PS1} configuration file.\n")
46
- file.write("# this file is auto generated by the aro cli.\n")
47
- 2.times do
48
- file.write("#\n")
49
- end
50
- DEFAULT_CONFIG.each{|k, v|
51
- var_name = CLI::Config.var_key_with_suffix(k)
52
- file.write("# [#{var_name}]\n")
53
- file.write("# => #{I18n.t("cli.config.possible_values")}:\n")
54
- v[:possible_values].each{|pv|
55
- file.write("# => #{pv[:name]} - #{pv[:description]}\n")
56
- }
57
- file.write("export #{var_name}=#{v[:value]}")
58
- }
59
- file.write("\n")
60
- end
61
- end
62
-
63
199
  def source_config
200
+ invalid_defs = validate_config
64
201
  Aro::P.say(I18n.t("cli.config.sourcing_config", name: CLI::Config::CONFIG_FILE_PATH))
65
202
  system("source #{CLI::Config::CONFIG_FILE_PATH}")
66
- DEFAULT_CONFIG.keys.each{|dfk|
203
+ CLI::Config::DEF.keys.each{|dfk|
204
+ next if invalid_defs.include?(dfk)
67
205
  Aro::P.say("$#{CLI::Config.var_key_with_suffix(dfk)}=#{CLI::Config.var_value_with_suffix(dfk)}")
68
206
  }
207
+
208
+ # todo: set all invalid_refs to default in ENV
209
+ end
210
+
211
+ def validate_config
212
+ invalid_defs = []
213
+ CLI::Config::DEF.each{|k, v|
214
+ var_value = CLI::Config.var_value_with_suffix(k)
215
+ is_valid = CLI::Config::DEF_TYPES[v[:type].to_s.upcase.to_sym][:validator]
216
+ .call(var_value, v, k)
217
+ invalid_defs << k unless is_valid
218
+ }
219
+ invalid_defs
69
220
  end
221
+
70
222
  end
71
- end
223
+ end
data/bin/cli/create.rb CHANGED
@@ -10,7 +10,7 @@
10
10
 
11
11
  module CLI
12
12
  def self.create
13
- CLI.exit_error_missing_args! if CLI::ARGV1.nil?
13
+ CLI::Aroface.exit_error_missing_args! if CLI::ARGV1.nil?
14
14
  name = CLI::ARGV1&.to_s
15
15
  Aro::P.say(I18n.t("cli.messages.creation_attempt", name: name))
16
16
  if Aro::Create.new(name).initialized
data/bin/cli/deck.rb CHANGED
@@ -20,7 +20,7 @@ module CLI
20
20
  Aro::Create.new(Aro::Db.get_name_from_namefile)
21
21
  Aro::Deck.display_selection_menu
22
22
  elsif action == CLI::CREATE_DECK_ACTIONS[:CREATE]
23
- CLI.exit_error_missing_args! if CLI::ARGV2.nil?
23
+ CLI::Aroface.exit_error_missing_args! if CLI::ARGV2.nil?
24
24
  deck = Aro::Deck.make(CLI::ARGV2.to_s)
25
25
  Aro::P.say(I18n.t("cli.messages.deck_created_sucessfully", name: Aro::Mancy.game.name))
26
26
  Aro::Deck.display_selection_menu
@@ -39,7 +39,12 @@ module CLI
39
39
  Aro::Mancy.game.shuffle
40
40
  when CLI::LOAD_DECK_ACTIONS[:DRAW]
41
41
  Aro::P.say(I18n.t("cli.messages.drawing", name: Aro::Mancy.game.name))
42
- Aro::Mancy.game.draw
42
+ Aro::P.p.say(I18n.t("cli.messages.drawing_from_dimension", dimension: "#{CLI::Config.var_value_with_suffix(:DIMENSION)}"))
43
+ Aro::Mancy.game.draw(
44
+ is_dt_dimension: CLI::Config.var_value_with_suffix(:DIMENSION).to_sym == CLI::Config::DMS[:DEV_TAROT],
45
+ z_max: CLI::Config.var_value_with_suffix(:Z_MAX).to_i,
46
+ z: CLI::Config.var_value_with_suffix(:Z)
47
+ )
43
48
  when CLI::LOAD_DECK_ACTIONS[:REPLACE]
44
49
  Aro::P.say(I18n.t("cli.messages.replacing_drawn", name: Aro::Mancy.game.name))
45
50
  Aro::Mancy.game.replace
data/bin/cli.rb CHANGED
@@ -14,7 +14,6 @@ ENV[:ARO_ENV.to_s] = :production.to_s
14
14
  # ENV[:ARO_ENV.to_s] = :development.to_s
15
15
 
16
16
  module CLI
17
-
18
17
  if CLI::LOAD_DECK_ACTIONS.keys.map{|k| k.downcase.to_sym}.include?(ARGV[0]&.to_sym)
19
18
  # enable deck shortcut (skip typing deck while in-game)
20
19
  ARGV0 = :deck
@@ -27,10 +26,14 @@ module CLI
27
26
  ARGV2 = ARGV[2]&.to_sym
28
27
  end
29
28
 
30
- def self.exit_error_missing_args!
31
- Aro::P.say(I18n.t("cli.errors.header"))
32
- Aro::P.say(I18n.t("cli.errors.missing_args", cmd: "#{CLI::ARGV0} #{CLI::ARGV1} #{CLI::ARGV2}".strip))
33
- exit(CLI::EXIT_CODES[:INVALID_ARG])
29
+ class Aroface
30
+
31
+ def self.exit_error_missing_args!
32
+ Aro::P.say(I18n.t("cli.errors.header"))
33
+ Aro::P.say(I18n.t("cli.errors.missing_args", cmd: "#{CLI::ARGV0} #{CLI::ARGV1} #{CLI::ARGV2}".strip))
34
+ exit(CLI::EXIT_CODES[:INVALID_ARG])
35
+ end
36
+
34
37
  end
35
38
 
36
39
  end
@@ -0,0 +1 @@
1
+ 5a6af41ca8e0e2eee62a129aca162bc709d5c3ded0c4ec7b6326fa6768d949313f320bd659cf00d5a0056c1adced4898fdd6d9c91c2a79f7d06018cc9cc61ad7
data/lib/aro/i18n.rb CHANGED
@@ -1,5 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
1
  require :i18n.to_s
4
2
 
5
3
  module Aro
data/lib/aro/prompt.rb CHANGED
@@ -15,7 +15,7 @@ module Aro
15
15
  end
16
16
 
17
17
  def self.say(message)
18
- Aro::P::p.say("[#{Aro::Mancy::PS1}@#{Time.now.to_i}]: #{message}")
18
+ Aro::P::p.say(">[#{Aro::Mancy::PS1}::#{Time.now.to_i}]>: #{message}")
19
19
  end
20
20
 
21
21
  def self.less(display_text = "")
data/lib/aro/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Aro
2
- VERSION = :"0.1.3"
3
- RELEASE_NOTES = :"added deck show options for count and order."
2
+ VERSION = :"0.1.4"
3
+ RELEASE_NOTES = :"add multiple config variables, add much improved randomness"
4
4
  end
data/lib/aro.rb CHANGED
@@ -16,8 +16,10 @@ module Aro
16
16
 
17
17
  attr_accessor :game
18
18
 
19
+ OS = 2
19
20
  PS1 = Aro::Mancy.name
20
- NAME_FILE = ".name"
21
+ NAME_FILE = :".name".to_s
22
+ I2097I = :i2097i
21
23
 
22
24
  def initialize
23
25
  Aro::Create.new(Aro::Db.get_name_from_namefile)
data/lib/models/deck.rb CHANGED
@@ -76,13 +76,6 @@ class Aro::Deck < ActiveRecord::Base
76
76
  end
77
77
  end
78
78
 
79
- def self.read_dev_tarot
80
- dt = nil
81
- return dt unless File.exist?(Aro::Deck::DEV_TAROT_FILE)
82
-
83
- File.open(Aro::Deck::DEV_TAROT_FILE, "r"){|dtf| dt = dtf.read(4)}
84
- end
85
-
86
79
  def self.card_strip(card)
87
80
  card.gsub(/[+-]/, "").strip
88
81
  end
@@ -198,48 +191,97 @@ class Aro::Deck < ActiveRecord::Base
198
191
  update(drawn: "", cards: cards_arr.join(Aro::Deck::CARD_DELIM))
199
192
  end
200
193
 
201
- def draw
202
- # draw a random card from the current deck.
194
+ # read dev_tarot
195
+ def self.read_dev_tarot
196
+ dt = nil
197
+ return dt unless File.exist?(Aro::Deck::DEV_TAROT_FILE)
198
+
199
+ File.open(Aro::Deck::DEV_TAROT_FILE, "r"){|dtf| dt = dtf.read(4)}
200
+
201
+ # VERY IMPORTANT!
202
+ Aro::P.say(I18n.t("cli.very_important", dev_tarot: dt))
203
+ return dt
204
+ end
205
+
206
+ # summon ruby_facot
207
+ def summon_ruby_facot(cards_arr)
208
+ Aro::P.say(I18n.t("cli.messages.ruby_facot_random"))
209
+ ruby_facot = cards_arr.sample.split("")
210
+
211
+ # get orientation
212
+ ruby_facot_str = ["+","-"].sample
213
+
214
+ # get suite
215
+ ruby_facot_str += ruby_facot[1]
216
+
217
+ # calculate the sym
218
+ symm = ruby_facot.select{|c|
219
+ # loops through the characters in ruby_facot
220
+ # return all characters not matching:
221
+ # => character[0]: orientation
222
+ # => character[1]: suite
223
+
224
+ # the first two characters in the dev_tarot format designate the
225
+ !ruby_facot.first(Aro::Mancy::OS).include?(c)
226
+ }.join("").to_sym
227
+ ruby_facot_str += Aro::NUMERALS[symm].to_s
228
+
229
+ # return ruby_facot_str
230
+ ruby_facot_str
231
+ end
232
+
233
+ def draw(is_dt_dimension: true, z_max: 7, z: 1)
234
+ # the true card
235
+ abs_dev_tarot = nil
236
+
237
+ # oriented card
203
238
  dev_tarot = nil
204
239
 
240
+ # get cards
241
+ cards_arr = cards.split(Aro::Deck::CARD_DELIM) || []
242
+ # get abs_cards
243
+ abs_cards_arr = cards_arr.map{|c| Aro::Deck.card_strip(c)}
244
+ # get drawn
245
+ drawn_arr = drawn&.split(Aro::Deck::CARD_DELIM) || []
246
+
247
+ # use fallback randomness if /dev/tarot unavailable
248
+ if !is_dt_dimension || !File.exist?(Aro::Deck::DEV_TAROT_FILE)
249
+ dev_tarot = summon_ruby_facot(cards_arr)
250
+ abs_dev_tarot = Aro::Deck.card_strip(dev_tarot)
251
+ end
252
+
253
+ sleeps = 0
254
+ sleeps_max = z_max
255
+
205
256
  # find a card that is not already drawn
206
- while dev_tarot.nil? do
257
+ while sleeps <= sleeps_max && dev_tarot.nil? do
207
258
  # preferred randomness
208
- dev_tarot = nil # Aro::Deck.read_dev_tarot&.strip&.split("")
209
-
210
- cards_arr = cards.split(Aro::Deck::CARD_DELIM) || []
211
- cards_arr_stripped = cards_arr.map{|c| Aro::Deck.card_strip(c)}
212
-
213
- if dev_tarot.nil?
214
- # assume user does not have /dev/tarot device.
215
- # generate random facade
216
- facade = cards_arr.sample.split("")
217
- dev_tarot = (
218
- facade.first(2).join("") +
219
- Aro::NUMERALS[
220
- facade.select{|c| !facade.first(2).include?(c)}.join("").to_sym
221
- ].to_s
222
- ).split("")
223
- end
224
-
225
- dev_tarot_converted = dev_tarot[1] + Aro::NUMERALS.key(
226
- dev_tarot.select{|c| !dev_tarot.first(2).include?(c)}.join("").to_i
227
- ).to_s
228
- if cards_arr_stripped.include?(dev_tarot_converted)
229
- # dev_tarot is valid
230
- drawn_arr = drawn&.split(Aro::Deck::CARD_DELIM) || []
231
- dev_tarot = dev_tarot[0] + dev_tarot_converted
232
- drawn_arr << dev_tarot
233
- cards_arr.delete_at(cards_arr_stripped.index(dev_tarot_converted))
234
- update(
235
- cards: cards_arr.join(Aro::Deck::CARD_DELIM),
236
- drawn: drawn_arr.join(Aro::Deck::CARD_DELIM)
237
- )
259
+ dev_tarot = Aro::Deck.read_dev_tarot&.strip&.split("")
260
+ if dev_tarot.present?
261
+ abs_dev_tarot = dev_tarot[1] + Aro::NUMERALS.key(
262
+ dev_tarot.select{|c| !dev_tarot.first(2).include?(c)}.join("").to_i
263
+ ).to_s
264
+ if abs_cards_arr.include?(abs_dev_tarot)
265
+ # dev_tarot is valid
266
+ dev_tarot = dev_tarot[0] + abs_dev_tarot
267
+ end
238
268
  else
239
269
  # dev_tarot is invalid
240
- dev_tarot = nil
241
- sleep(1)
270
+ sleeps += 1
271
+ sleep(z)
242
272
  end
243
273
  end
274
+
275
+ # remove from cards
276
+ cards_arr.delete(cards_arr.select{|c| c.include?(abs_dev_tarot)}.first)
277
+
278
+ # insert dev_tarot to drawn
279
+ drawn_arr << dev_tarot
280
+
281
+ # update database
282
+ update(
283
+ cards: cards_arr.join(Aro::Deck::CARD_DELIM),
284
+ drawn: drawn_arr.join(Aro::Deck::CARD_DELIM)
285
+ )
244
286
  end
245
- end
287
+ end
data/locale/en.usage.yml CHANGED
@@ -27,6 +27,9 @@ en:
27
27
 
28
28
  $ aro create <name>
29
29
 
30
+ config
31
+ manage your aro config - not yet implemented
32
+
30
33
  deck
31
34
  perform operations on the deck(s) in current aro instance
32
35
 
data/locale/en.yml CHANGED
@@ -1,11 +1,27 @@
1
1
  en:
2
2
  cli:
3
+ # VERY IMPORTANT!
4
+ very_important: "VERY IMPORTANT! %{dev_tarot}"
5
+ # VERY IMPORTANT!
6
+
3
7
  config:
8
+ format_description: "aro output format. possible values: [${possible values}]"
9
+ def_type: "CLI::Config::DEF_TYPES"
10
+ dimension_description: "chosen dimension of aro space. possible values: [${possible values}]"
11
+ dimension_dev_tarot_description: "reads from /dev/tarot device if available."
12
+ dimension_ruby_facot_description: "generated ruby_facot (facade randomness)."
13
+ draw_count_description: "number of cards in one line of draws. valid range: (${min}-${max})"
4
14
  generating_default_config: "missing config. generating default config file at %{name}."
5
15
  json_format_description: "show aro responses in json format."
16
+ maximum: "max"
17
+ minimum: "min"
6
18
  possible_values: "possible values"
7
19
  text_format_description: "show aro responses in text format (default)"
20
+ type_int_description: "a primitive decimal-less numeric."
21
+ type_values_description: "an enumerated type."
8
22
  sourcing_config: "loading configuration from %{name}..."
23
+ z_description: "sleep time between attempts to read /dev/tarot. valid range (%{min}-%{max})"
24
+ z_max_description: "max number of z long sleeps before giving up. valid range (%{min}-%{max})"
9
25
  errors:
10
26
  header: "error! something is out of place."
11
27
  missing_args: "the command you entered, '%{cmd}', is missing required argument(s)"
@@ -27,7 +43,12 @@ en:
27
43
 
28
44
  see aro --help for usage.
29
45
  deck_created_sucessfully: "%{name} deck created successfully"
30
- drawing: "drawing a card from %{name}..."
46
+ drawing: "drawing a card from %{name}"
47
+ drawing_from_dimension: "in the the %{dimension} dimension..."
48
+ ruby_facot_random: |
49
+ unable to read from /dev/tarot - using facade randomness instead.
50
+ for more information visit:
51
+ https://github.com/arowmancy/dev_tarot
31
52
  history_drawn: "drawn cards"
32
53
  no_decks: |
33
54
  no decks created yet.
@@ -37,7 +58,7 @@ en:
37
58
  $ aro deck create <deck_name>
38
59
 
39
60
  see aro --help for usage.
40
- showing: "%{name}: (count: [%{count}], order: [%{order}])..."
61
+ showing: "showing %{name} [count:%{count}, order:%{order}]..."
41
62
  shuffling: "shuffling %{name}'s cards..."
42
63
  replacing_drawn: "all drawn cards to %{name}..."
43
64
  resetting: "resetting %{name}'s cards..."
data/pkg/aro-0.1.0.gem ADDED
Binary file
data/pkg/aro-0.1.1.gem ADDED
Binary file
data/pkg/aro-0.1.2.gem ADDED
Binary file
data/pkg/aro-0.1.3.gem ADDED
Binary file
data/pkg/aro-0.1.4.gem ADDED
Binary file
@@ -0,0 +1,8 @@
1
+ desc "run irb console with aro and autocomplete"
2
+ task :console do
3
+ require :irb.to_s
4
+ require :"irb/completion".to_s
5
+ require :aro.to_s
6
+ ARGV.clear
7
+ IRB.start
8
+ end
data/tasks/make.rake ADDED
@@ -0,0 +1,4 @@
1
+ desc "rspec && rake install"
2
+ task :make do
3
+ exec "rspec && rake install"
4
+ 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.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - i2097i
@@ -69,26 +69,6 @@ dependencies:
69
69
  - - ">="
70
70
  - !ruby/object:Gem::Version
71
71
  version: 3.13.2
72
- - !ruby/object:Gem::Dependency
73
- name: x
74
- requirement: !ruby/object:Gem::Requirement
75
- requirements:
76
- - - "~>"
77
- - !ruby/object:Gem::Version
78
- version: '0.16'
79
- - - ">="
80
- - !ruby/object:Gem::Version
81
- version: 0.16.0
82
- type: :runtime
83
- prerelease: false
84
- version_requirements: !ruby/object:Gem::Requirement
85
- requirements:
86
- - - "~>"
87
- - !ruby/object:Gem::Version
88
- version: '0.16'
89
- - - ">="
90
- - !ruby/object:Gem::Version
91
- version: 0.16.0
92
72
  - !ruby/object:Gem::Dependency
93
73
  name: i18n
94
74
  requirement: !ruby/object:Gem::Requirement
@@ -177,6 +157,15 @@ executables:
177
157
  extensions: []
178
158
  extra_rdoc_files: []
179
159
  files:
160
+ - ".gitignore"
161
+ - ".release"
162
+ - ".ruby-version"
163
+ - Gemfile
164
+ - Gemfile.lock
165
+ - LICENSE
166
+ - README.md
167
+ - Rakefile
168
+ - aro.gemspec
180
169
  - bin/aro
181
170
  - bin/cli.rb
182
171
  - bin/cli/config.rb
@@ -184,6 +173,7 @@ files:
184
173
  - bin/cli/create.rb
185
174
  - bin/cli/deck.rb
186
175
  - bin/cli/usage.rb
176
+ - checksums/aro-0.1.4.gem.sha512
187
177
  - db/migrate/1763374647_create_decks.rb
188
178
  - db/migrate/1763432541_create_logs.rb
189
179
  - lib/aro.rb
@@ -199,6 +189,13 @@ files:
199
189
  - locale/en.cards.yml
200
190
  - locale/en.usage.yml
201
191
  - locale/en.yml
192
+ - pkg/aro-0.1.0.gem
193
+ - pkg/aro-0.1.1.gem
194
+ - pkg/aro-0.1.2.gem
195
+ - pkg/aro-0.1.3.gem
196
+ - pkg/aro-0.1.4.gem
197
+ - tasks/console.rake
198
+ - tasks/make.rake
202
199
  homepage: https://github.com/i2097i/aro
203
200
  licenses:
204
201
  - MIT
@@ -206,6 +203,7 @@ metadata: {}
206
203
  rdoc_options: []
207
204
  require_paths:
208
205
  - lib
206
+ - bin/cli
209
207
  required_ruby_version: !ruby/object:Gem::Requirement
210
208
  requirements:
211
209
  - - ">="