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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2d38dfc3076510642fc060178b2de03eb366c527ac6e88c2bfeb746f85b0e6b9
4
- data.tar.gz: c58bdbb118b84d1bd05709cf19942cf7ac69c1ab66cbdb91b916fe42fb7b0ab0
3
+ metadata.gz: 526b2b77c9a4a0315c096cf27028a45a3294113ea198d36771a690d34efbcb25
4
+ data.tar.gz: a3f5c221245676bf831498b1517fcb654deeec2c5ecd6ad1aa5b7ba3b4bf3c67
5
5
  SHA512:
6
- metadata.gz: 4cf670b3a0bfefd708c9a6286218a4474394eb10b9669e359f3eec157052e0f6762a88e9f93ee31299bea09f9d0a41e51dbbf5019e42f1870ece83093dad00fe
7
- data.tar.gz: 9ca02e7c6b8f772ae6ff92b4f392c32c4d8fa830611af35d8ddd3b1b455536d2b1af37e4ea4ed2a1e3ab1f0ec49d930b30a3e2c0c1f1498e841feb05ead09549
6
+ metadata.gz: 311cb1b3d8df2da508f73b954c3169c92cb3fb5a0532b08ba60b96e31f6cf0a0681ee70d166ee68fcedeae8064a07b05498b491585c5a4f7aca3d1f8da3b25bd
7
+ data.tar.gz: 2ec454c0546e13d18ea541b40cf29308aa443e986559ced667918cc63bac3dcaa1406f02a2a93ed0383a7f9c7d7b378bb945897e850b8f0f123f579a8fb34fc2
data/.gitignore CHANGED
@@ -1,6 +1,6 @@
1
- .DS_Store
2
- .aro
3
- .aro_test
4
- .name
1
+ *.aro
2
+ *.aro_test
3
+ *.log
4
+ *.name
5
5
  *.sql
6
- *.log
6
+ pkg/*
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- ruby-3.4.7
1
+ 3.4.7
data/Gemfile.lock CHANGED
@@ -1,9 +1,10 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- aro (0.1.3)
4
+ aro (0.1.7)
5
5
  activerecord (~> 8.1, >= 8.1.1)
6
6
  i18n (~> 1.14, >= 1.14.7)
7
+ listen (~> 3.9, >= 3.9.0)
7
8
  sqlite3 (~> 2.8, >= 2.8.0)
8
9
  tty-prompt (~> 0.23.1, >= 0.23.1)
9
10
 
@@ -32,17 +33,33 @@ GEM
32
33
  base64 (0.3.0)
33
34
  bigdecimal (3.3.1)
34
35
  concurrent-ruby (1.3.5)
35
- connection_pool (2.5.4)
36
+ connection_pool (3.0.2)
36
37
  diff-lcs (1.6.2)
37
38
  drb (2.2.3)
39
+ ffi (1.17.2-aarch64-linux-gnu)
40
+ ffi (1.17.2-aarch64-linux-musl)
41
+ ffi (1.17.2-arm-linux-gnu)
42
+ ffi (1.17.2-arm-linux-musl)
43
+ ffi (1.17.2-arm64-darwin)
44
+ ffi (1.17.2-x86-linux-gnu)
45
+ ffi (1.17.2-x86-linux-musl)
46
+ ffi (1.17.2-x86_64-darwin)
47
+ ffi (1.17.2-x86_64-linux-gnu)
48
+ ffi (1.17.2-x86_64-linux-musl)
38
49
  i18n (1.14.7)
39
50
  concurrent-ruby (~> 1.0)
40
- json (2.16.0)
51
+ json (2.17.1)
52
+ listen (3.9.0)
53
+ rb-fsevent (~> 0.10, >= 0.10.3)
54
+ rb-inotify (~> 0.9, >= 0.9.10)
41
55
  logger (1.7.0)
42
- minitest (5.26.1)
56
+ minitest (5.26.2)
43
57
  pastel (0.8.0)
44
58
  tty-color (~> 0.5)
45
59
  rake (13.3.1)
60
+ rb-fsevent (0.11.2)
61
+ rb-inotify (0.11.1)
62
+ ffi (~> 1.0)
46
63
  rspec (3.13.2)
47
64
  rspec-core (~> 3.13.0)
48
65
  rspec-expectations (~> 3.13.0)
@@ -57,16 +74,16 @@ GEM
57
74
  rspec-support (~> 3.13.0)
58
75
  rspec-support (3.13.6)
59
76
  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)
77
+ sqlite3 (2.8.1-aarch64-linux-gnu)
78
+ sqlite3 (2.8.1-aarch64-linux-musl)
79
+ sqlite3 (2.8.1-arm-linux-gnu)
80
+ sqlite3 (2.8.1-arm-linux-musl)
81
+ sqlite3 (2.8.1-arm64-darwin)
82
+ sqlite3 (2.8.1-x86-linux-gnu)
83
+ sqlite3 (2.8.1-x86-linux-musl)
84
+ sqlite3 (2.8.1-x86_64-darwin)
85
+ sqlite3 (2.8.1-x86_64-linux-gnu)
86
+ sqlite3 (2.8.1-x86_64-linux-musl)
70
87
  timeout (0.4.4)
71
88
  tty-color (0.6.0)
72
89
  tty-cursor (0.7.1)
@@ -92,6 +109,7 @@ PLATFORMS
92
109
  x86-linux-gnu
93
110
  x86-linux-musl
94
111
  x86_64-darwin
112
+ x86_64-linux
95
113
  x86_64-linux-gnu
96
114
  x86_64-linux-musl
97
115
 
data/aro.gemspec CHANGED
@@ -1,21 +1,29 @@
1
- # coding: utf-8
1
+ =begin
2
+
3
+ aro.gemspec
2
4
 
3
- require :aro.to_s
5
+ aro gem specification.
6
+
7
+ by i2097i
8
+
9
+ =end
10
+
11
+ require_relative :"sys/shr/version".to_s
4
12
 
5
13
  Gem::Specification.new do |spec|
6
14
  spec.name = "aro"
7
- spec.version = Aro::VERSION
15
+ spec.version = Aro::VERSION.to_s
8
16
  spec.authors = ["i2097i"]
9
17
  spec.email = ["i2097i@hotmail.com"]
10
18
  spec.description = "a cli for tarot."
11
- spec.summary = "follow the way of the aro eht."
19
+ spec.summary = Aro::RELEASE_NOTES.to_s
12
20
  spec.homepage = "https://github.com/i2097i/aro"
13
21
  spec.license = "MIT"
14
-
15
- spec.files = `git ls-files`.split("\n").reject{|f| f.match(%r{^(spec|pkg)/})}
22
+ spec.files = `git ls-files`.split("\n").reject{|p| p.match?(/^(spec|.release|.*.gem$)/)}
16
23
  spec.bindir = "bin"
17
24
  spec.executables = ["aro"]
18
- spec.require_paths = ["lib", "bin/cli"]
25
+ spec.require_paths = ["sys"]
26
+ spec.required_ruby_version = ">= 3.4.7"
19
27
 
20
28
  # development gems
21
29
  spec.add_development_dependency "bundler", "~> 2.7", ">= 2.7.2"
@@ -27,4 +35,5 @@ Gem::Specification.new do |spec|
27
35
  spec.add_runtime_dependency "activerecord", "~> 8.1", ">= 8.1.1"
28
36
  spec.add_runtime_dependency "sqlite3", "~> 2.8", ">= 2.8.0"
29
37
  spec.add_runtime_dependency "tty-prompt", "~> 0.23.1", ">= 0.23.1"
38
+ spec.add_runtime_dependency "listen", "~> 3.9", ">= 3.9.0"
30
39
  end
data/bin/aro CHANGED
@@ -4,41 +4,41 @@
4
4
 
5
5
  aro
6
6
 
7
- entry point for the aro cli
7
+ entry point for the aro cli.
8
8
 
9
9
  by i2097i
10
10
 
11
11
  =end
12
12
 
13
- require_relative :cli.to_s
13
+ require :aro.to_s
14
14
 
15
15
  # todo: add tab completion using abbrev gem
16
16
  # https://stackoverflow.com/a/11627931
17
17
 
18
- module CLI
19
- if CLI::FLAGS[:VERSION].include?(CLI::ARGV0)
20
- Aro::P.say(Aro::VERSION)
21
- exit(CLI::EXIT_CODES[:SUCCESS])
22
- end
18
+ if CLI::FLAGS[:VERSION].include?(CLI::ARGV0)
19
+ Aro::P.say(Aro::VERSION)
20
+ exit(CLI::EXIT_CODES[:SUCCESS])
21
+ end
23
22
 
24
- # initialize config
25
- CLI::Config.instance
26
-
27
- # cli parser
28
- case CLI::ARGV0
29
- when :create
30
- CLI::create
31
- when :deck
32
- CLI::deck
33
- else
34
- unless Aro::Mancy.game.nil? || CLI::FLAGS[:HELP].include?(CLI::ARGV0)
35
- Aro::P.say(I18n.t("cli.messages.welcome", name: "#{Aro::Mancy.name}.game.show"))
36
- Aro::Mancy.game.show
37
- exit(CLI::EXIT_CODES[:SUCCESS])
38
- end
39
-
40
- CLI::usage
23
+ # cli parser
24
+ case CLI::ARGV0
25
+ when CLI::CMDS[:ARO][:CONFIG]
26
+ CLI::config
27
+ when CLI::CMDS[:ARO][:CREATE]
28
+ CLI::create
29
+ when CLI::CMDS[:ARO][:DECK]
30
+ CLI::deck
31
+ when CLI::CMDS[:ARO][:DOM]
32
+ CLI::dom
33
+ when CLI::CMDS[:ARO][:INIT]
34
+ Aro::Mancy.init
35
+ else
36
+ unless Aro::Mancy.game.nil? || CLI::FLAGS[:HELP].include?(CLI::ARGV0)
37
+ Aro::P.say(I18n.t("cli.messages.welcome", name: "#{Aro::Mancy.name}.game"))
38
+ Aro::Mancy.game.show
41
39
  exit(CLI::EXIT_CODES[:SUCCESS])
42
40
  end
43
41
 
42
+ CLI.usage
43
+ exit(CLI::EXIT_CODES[:SUCCESS])
44
44
  end
@@ -0,0 +1 @@
1
+ 52fd8d90abad947eb27a4dc634f2048128d42349005d1b9f93a52518332cf8e14433b05170d077453b5753b83a6f6b7c9df36fc575e792ca2a5dbf3312e06f59
data/listen.rb ADDED
@@ -0,0 +1,10 @@
1
+ require :listen.to_s
2
+
3
+ listener = Listen.to(*[:sys.to_s, :bin.to_s, :spec.to_s, :locale.to_s], only: /[\.rb\.yml]/) {|modified, added, removed|
4
+ # puts modified
5
+ # puts added
6
+ # puts removed
7
+ system("exec rake make")
8
+ }
9
+ listener.start
10
+ sleep
data/locale/en.usage.yml CHANGED
@@ -1,63 +1,76 @@
1
1
  en:
2
- cli:
3
- usage: |
2
+ usage:
3
+ main: |
4
4
  NAME
5
5
 
6
- aro - a cli for tarot.
6
+ aro - a cli for tarot games in the arodom.
7
7
 
8
8
  SYNOPSIS
9
9
 
10
10
  aro [-v | --version] [-h | --help] <command1> <command2>
11
11
 
12
- to pick up where you left off, simply enter the following command:
13
-
14
- $ aro
15
-
16
12
  COMMANDS
17
-
18
- there are two primary commands in the aro. one is to create and the
19
- other is to play.
20
-
21
13
  create
22
- create an aro directory named <name>. if directory already exists, abort.
23
-
24
- aro create <name>
25
-
26
- examples:
14
+ create and init an aro game room named <name>:
27
15
 
28
16
  $ aro create <name>
29
17
 
18
+ init
19
+ set up the .aro directory that contains database and config
20
+
21
+ note:
22
+ this runs by default after create and has no effect if init is complete.
23
+
30
24
  config
31
- todo: manage your aro config - not yet implemented
25
+ config management (ex: update preferences)
26
+ todo:
32
27
 
33
28
  deck
34
- perform operations on the deck(s) in current aro instance
29
+ manage decks in the current room
30
+
31
+ $ aro deck <commands>
32
+
33
+ note:
34
+
35
+ deck subcommands do not require typing 'deck'. for example,
35
36
 
36
- aro deck [-h | --help] <command>
37
+ $ aro deck show
37
38
 
38
- running `aro deck` with no arguments prompts user to select a deck.
39
+ is the same thing as:
39
40
 
40
- $ aro deck
41
+ $ aro show
41
42
 
42
- COMMANDS
43
+ SUBCOMMANDS
44
+ draw
45
+ draw a random card from the current deck.
43
46
 
44
- create
47
+ explore
48
+ allows user to browse each card in the current deck.
45
49
 
46
- creates a new deck with the specified name.
50
+ new
51
+ create a new deck with the specified name.
47
52
 
48
53
  example:
49
54
 
50
- $ aro deck create <name_of_new_deck>
55
+ $ aro deck create <name>
51
56
 
52
- show
57
+ replace
58
+ replaces all drawn cards FIFO and puts them on the bottom of
59
+ the deck. this will preserve all card orientations.
60
+
61
+ reset
62
+ completely reset the deck. replace all drawn and reset order.
63
+ all orientations will be set to upright. you must enter 'aroyes'
64
+ to continue.
53
65
 
66
+ show
54
67
  displays the current deck's log record(s).
55
68
 
56
69
  the default behavior is to display only the most recent log record.
57
70
 
58
71
  note:
59
72
 
60
- 'less' is automatically used to display records if --count > 1
73
+ 'less' is automatically used to view text output log count > 1
61
74
 
62
75
  OPTIONS
63
76
 
@@ -74,26 +87,31 @@ en:
74
87
  possible values: ['asc', 'desc']
75
88
 
76
89
  shuffle
77
-
78
90
  shuffles the current deck and generates a log record.
79
91
 
80
- explore
92
+ dom
93
+ create or manage an arodome (ex: list game rooms)
81
94
 
82
- allows user to browse each card in the current deck.
95
+ $ aro dom <commands>
83
96
 
84
- draw
97
+ SUBCOMMANDS
98
+ init
99
+ generate the arodome
85
100
 
86
- draw a random card from the current deck.
101
+ map
102
+ display arodome map
87
103
 
88
- replace
104
+ example
105
+
106
+ $ aro dom map
107
+ new
108
+ create a new arodome with the specified name.
109
+
110
+ example:
111
+
112
+ $ aro dom new <name>
89
113
 
90
- replaces all drawn cards FIFO and puts them on the bottom of
91
- the deck. this will preserve all card orientations.
92
-
93
- reset
94
114
 
95
- completely reset the deck. replace all drawn and reset order.
96
- all orientations will be set to upright.
97
115
 
98
116
 
99
117
 
data/locale/en.yml CHANGED
@@ -5,12 +5,24 @@ en:
5
5
  # VERY IMPORTANT!
6
6
 
7
7
  config:
8
- format_description: "aro output format. possible values: [${possible values}]"
8
+ aro_env_O_description: "read-only env var for holding O."
9
+ aro_env_S_description: "read-only env var for holding S."
10
+ aro_env_OS_description: "read-only env var for holding OS."
11
+ aro_env_N_description: "read-only env var for holding N"
12
+ aro_env_PS1_description: "read-only env var for holding default PS1."
13
+ aro_env_NAME_FILE_description: "read-only env var for name file."
14
+ aro_env_I2097I_description: "read-only env var for i2097i."
15
+ aro_env_YES_description: "read-only env var for 'aroyes'."
16
+ format_description: "aro output format."
9
17
  def_type: "CLI::Config::DEF_TYPES"
10
- dimension_description: "chosen dimension of aro space. possible values: [${possible values}]"
18
+ dimension_description: "selected dimension of aro space."
11
19
  dimension_dev_tarot_description: "reads from /dev/tarot device if available."
12
20
  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})"
21
+ display_columns_description: "display width multiplier. valid range: (${min}-${max})"
22
+ env_description: "aro run environment."
23
+ env_development_description: "basic development logs and features."
24
+ env_production_description: "game logging only."
25
+ env_test_description: "logging and features tailored for tests."
14
26
  generating_default_config: "missing config. generating default config file at %{name}."
15
27
  json_format_description: "show aro responses in json format."
16
28
  maximum: "max"
@@ -18,16 +30,21 @@ en:
18
30
  possible_values: "possible values"
19
31
  text_format_description: "show aro responses in text format (default)"
20
32
  type_int_description: "a primitive decimal-less numeric."
33
+ type_string_description: "a blank-space-terminated string of characters."
21
34
  type_values_description: "an enumerated type."
22
35
  sourcing_config: "loading configuration from %{name}..."
23
36
  z_description: "sleep time between attempts to read /dev/tarot. valid range (%{min}-%{max})"
24
37
  z_max_description: "max number of z long sleeps before giving up. valid range (%{min}-%{max})"
25
38
  errors:
26
- header: "error! something is out of place."
27
- missing_args: "the command you entered, '%{cmd}', is missing required argument(s)"
28
- missing_deck: "no deck selected. use 'aro deck' to select one or 'aro deck create deck_name' to create one."
39
+ # , cmd: Aro::Mancy::I2097I))
40
+ header: "$ %{cmd}: !error."
41
+ invalid_usage: "$ %{cmd}: !says you're not supposed to be here."
42
+ missing_args: "$ %{cmd}: !says missing required argument(s)."
43
+ missing_deck: "$ %{cmd}: !no deck selected. use 'aro deck' to select one or 'aro deck create <name>' to create one."
44
+ not_in_aro: "$ %{cmd}: !you are not in aro space. that command will not work here."
29
45
  warnings:
30
46
  invalid_order: "the order specified for displaying logs in invalid. using default (desc)."
47
+ not_initialized: "warning - you need to initialize aro. run 'aro init' to do so"
31
48
  messages:
32
49
  choose_card: "choose a card."
33
50
  confirmation_prompt: "input 'aroyes' to reset %{name}, or enter to cancel (cancel): "
data/sys/aro/d.rb ADDED
@@ -0,0 +1,25 @@
1
+ =begin
2
+
3
+ d.rb
4
+
5
+ d logger for i2097i.
6
+
7
+ by i2097i
8
+
9
+ =end
10
+
11
+ require_relative :"../shr/prompt".to_s
12
+
13
+ module Aro
14
+ class D < Aro::Prompt
15
+ def self.say(message)
16
+ return unless Aro::D.should_print?
17
+ Aro::P::p.say(">[#{Aro::Mancy::I2097I}]>: #{message}\n")
18
+ end
19
+
20
+ def self.should_print?
21
+ Aro::Mancy::ARO_ENV_DEBUG_MODES.include?(ENV[:ARO_ENV.to_s]&.to_sym)
22
+ end
23
+ end
24
+ end
25
+
data/sys/aro/db.rb ADDED
@@ -0,0 +1,96 @@
1
+ =begin
2
+
3
+ db.rb
4
+
5
+ database for aro room.
6
+
7
+ by i2097i
8
+
9
+ =end
10
+
11
+ module Aro
12
+ class Db
13
+ DATABASE_YML = :"database.yml"
14
+ SQL_FILE = :"database.sql"
15
+ SCHEMA_FILE = :"schema.rb"
16
+ MIGRATIONS_DIR = :"db/migrate"
17
+
18
+ def initialize
19
+ unless Aro::Mancy.is_aro_space?
20
+ Aro::P.say(I18n.t("cli.errors.not_in_aro" , cmd: Aro::Mancy::I2097I))
21
+ return
22
+ end
23
+
24
+ if Aro::Mancy.is_initialized?
25
+ setup_local_aro
26
+ else
27
+ Aro::P.say(I18n.t("cli.warnings.not_initialized"))
28
+ end
29
+ end
30
+
31
+ def connect(name)
32
+ ActiveRecord::Base.establish_connection(config)
33
+ end
34
+
35
+ def config
36
+ @config ||= YAML.load_file(db_config_filepath)
37
+ end
38
+
39
+ def self.base_aro_dir
40
+ base_aro_file = Aro::Mancy::ARO_FILE.to_s
41
+ CLI::Config.is_test? ? "#{base_aro_file}_test" : base_aro_file
42
+ end
43
+
44
+ def db_config_filepath
45
+ File.join(Aro::Db.base_aro_dir, Aro::Db::DATABASE_YML.to_s)
46
+ end
47
+
48
+ def self.get_name_from_namefile
49
+ Aro::Mancy.is_aro_space? ? File.read(Aro::Mancy::NAME_FILE.to_s).strip : nil
50
+ end
51
+
52
+ def setup_local_aro
53
+ name = Aro::Db.get_name_from_namefile
54
+ return if name.nil?
55
+
56
+ # create local .aro/ directory
57
+ unless File.exist?(Aro::Db.base_aro_dir)
58
+ FileUtils.mkdir(Aro::Db.base_aro_dir)
59
+ end
60
+
61
+ unless File.exist?(db_config_filepath)
62
+ # create database config yaml file
63
+ c = {
64
+ adapter: :sqlite3.to_s,
65
+ database: File.join(Aro::Db.base_aro_dir, Aro::Db::SQL_FILE.to_s),
66
+ username: name,
67
+ password: name
68
+ }.to_yaml
69
+ File.open(db_config_filepath, "w") do |file|
70
+ file.write(c)
71
+ end
72
+ end
73
+
74
+ connect(name)
75
+ migrate(name)
76
+ end
77
+
78
+ def migrate(name)
79
+ local_migrate_dir = File.join(Aro::Db.base_aro_dir, Aro::Db::MIGRATIONS_DIR.to_s)
80
+ unless Dir.exist?(local_migrate_dir)
81
+ gem_dir = Dir[Gem.loaded_specs[:aro.to_s]&.full_gem_path || '.'].first
82
+ FileUtils.cp_r(File.join(gem_dir, "db"), Aro::Db::base_aro_dir)
83
+ end
84
+
85
+ migration_version = Dir["#{local_migrate_dir}/*.rb"].map{|n|
86
+ Pathname.new(n).basename.to_s.split("_")[0].to_i
87
+ }.max
88
+ ActiveRecord::MigrationContext.new(local_migrate_dir).migrate(migration_version)
89
+
90
+ filename = File.join(Aro::Db.base_aro_dir, Aro::Db::SCHEMA_FILE.to_s)
91
+ File.open(filename, "w+") do |f|
92
+ ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection_pool, f)
93
+ end
94
+ end
95
+ end
96
+ end
data/sys/aro/mancy.rb ADDED
@@ -0,0 +1,117 @@
1
+ =begin
2
+
3
+ aro.rb
4
+
5
+ aro and mancy.
6
+
7
+ by i2097i
8
+
9
+ =end
10
+
11
+ module Aro
12
+ class Mancy
13
+ include Singleton
14
+
15
+ attr_accessor :game
16
+
17
+ O = 0
18
+ S = 1
19
+ OS = 2
20
+ N = 4
21
+ PS1 = Aro::Mancy.name
22
+ NAME_FILE = :".name"
23
+ ARO_FILE = :".aro"
24
+ I2097I = :i2097i
25
+ YES = :aroyes
26
+ ALL = :all
27
+
28
+ ARO_ENV_DEBUG_MODES = [:development, :test]
29
+ DEBUG_VERBOSE = false
30
+
31
+ NUMERALS = {
32
+ O: 0,
33
+ I: 1,
34
+ II: 2,
35
+ III: 3,
36
+ IV: 4,
37
+ V: 5,
38
+ VI: 6,
39
+ VII: 7,
40
+ VIII: 8,
41
+ IX: 9,
42
+ X: 10,
43
+ XI: 11,
44
+ XII: 12,
45
+ XIII: 13,
46
+ XIV: 14,
47
+ XV: 15,
48
+ XVI: 16,
49
+ XVII: 17,
50
+ XVIII: 18,
51
+ XIX: 19,
52
+ XX: 20,
53
+ XXI: 21,
54
+ XXII: 22,
55
+ MMXCVII: Aro::Mancy::I2097I[Aro::Mancy::S..Aro::Mancy::N].to_i,
56
+ }
57
+
58
+ def initialize
59
+ # ENV bindings
60
+ ENV[:ARO_ENV_O.to_s] = "#{Aro::Mancy::O}"
61
+ ENV[:ARO_ENV_S.to_s] = "#{Aro::Mancy::S}"
62
+ ENV[:ARO_ENV_OS.to_s] = "#{Aro::Mancy::OS}"
63
+ ENV[:ARO_ENV_N.to_s] = "#{Aro::Mancy::N}"
64
+ ENV[:ARO_ENV_PS1.to_s] = "#{Aro::Mancy::PS1}"
65
+ ENV[:ARO_ENV_NAME_FILE.to_s] = "#{Aro::Mancy::NAME_FILE}"
66
+ ENV[:ARO_ENV_I2097I.to_s] = "#{Aro::Mancy::I2097I}"
67
+ ENV[:ARO_ENV_YES.to_s] = "#{Aro::Mancy::YES}"
68
+
69
+ if Aro::Mancy.is_aro_space?
70
+ Aro::Db.new
71
+ self.game = Aro::Deck.current_deck
72
+ end
73
+ end
74
+
75
+ def self.game
76
+ Aro::Mancy.instance.game
77
+ end
78
+
79
+ def self.create(name)
80
+ return false if Aro::Mancy.is_aro_space? || name.nil?
81
+
82
+ # explicitly only allow String/Symbol types for name
83
+ return false unless name.kind_of?(String) || name.kind_of?(Symbol)
84
+ name = name.to_s.strip
85
+
86
+ # create the new aro directory and database
87
+ if !Dir.exist?(name)
88
+ Aro::P.say(I18n.t("cli.messages.no_decks"))
89
+ FileUtils.mkdir(name)
90
+ else
91
+ return false
92
+ end
93
+
94
+ # create name file
95
+ File.open(File.join(name, Aro::Mancy::NAME_FILE.to_s), "w+") do |file|
96
+ file.write(name)
97
+ end
98
+
99
+ Dir.chdir(name) do
100
+ Aro::Db.new.setup_local_aro
101
+ end
102
+ return true
103
+ end
104
+
105
+ def self.init
106
+ Aro::Db.new.setup_local_aro
107
+ end
108
+
109
+ def self.is_initialized?
110
+ Dir.exist?(Aro::Db.base_aro_dir)
111
+ end
112
+
113
+ def self.is_aro_space?
114
+ File.exist?(Aro::Mancy::NAME_FILE.to_s)
115
+ end
116
+ end
117
+ end