aro 0.1.7 → 0.1.8

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 (57) hide show
  1. checksums.yaml +4 -4
  2. data/aro.gemspec +3 -3
  3. data/bin/aos +19 -0
  4. data/checksums/aro-0.1.7.gem.sha512 +1 -0
  5. data/checksums/aro-0.1.8.gem.sha512 +1 -0
  6. data/db/migrate/1763374647_create_decks.rb +3 -0
  7. data/db/migrate/1763432541_create_logs.rb +1 -0
  8. data/db/migrate/1765148774_create_yous.rb +19 -0
  9. data/locale/en.aos.yml +27 -0
  10. data/locale/en.cngelog.yml +5 -0
  11. data/locale/en.usage.yml +9 -10
  12. data/locale/en.yml +46 -31
  13. data/sys/aos/aos.rb +199 -0
  14. data/sys/aos/db.rb +81 -0
  15. data/sys/aos/s.rb +25 -0
  16. data/sys/aos/views/base.rb +139 -0
  17. data/sys/aos/views/dom.rb +45 -0
  18. data/sys/aos/views/games/abpps.rb +21 -0
  19. data/sys/aos/views/games/deck.rb +95 -0
  20. data/sys/aos/views/games/game.rb +24 -0
  21. data/sys/aos/views/games/hbpps.rb +21 -0
  22. data/sys/aos/views/games/shpps.rb +21 -0
  23. data/sys/aos/views/games/vipps.rb +21 -0
  24. data/sys/aos/views/games.rb +19 -0
  25. data/sys/aos/views/know/library.rb +19 -0
  26. data/sys/aos/views/know/temple.rb +19 -0
  27. data/sys/aos/views/know.rb +19 -0
  28. data/sys/aos/views/setup/settings.rb +50 -0
  29. data/sys/aos/views/setup.rb +19 -0
  30. data/sys/aos/views/welcome/waite.rb +19 -0
  31. data/sys/aos/views/welcome/winner.rb +19 -0
  32. data/sys/aos/views/welcome.rb +19 -0
  33. data/sys/aos/you.rb +15 -0
  34. data/sys/aro/d.rb +1 -1
  35. data/sys/aro/db.rb +5 -12
  36. data/sys/aro/mancy.rb +12 -15
  37. data/sys/aro/p.rb +1 -1
  38. data/sys/aro/v.rb +2 -3
  39. data/sys/aro.rb +1 -0
  40. data/sys/cli/config.rb +168 -104
  41. data/sys/cli/constants.rb +5 -2
  42. data/sys/cli/dom.rb +5 -13
  43. data/sys/cli/nterface.rb +6 -0
  44. data/sys/dom/d.rb +0 -5
  45. data/sys/dom/dom.rb +52 -85
  46. data/sys/models/deck.rb +13 -7
  47. data/sys/models/log.rb +12 -2
  48. data/sys/reiquire.rb +2 -2
  49. data/sys/shr/prompt.rb +8 -4
  50. data/sys/shr/t.rb +1 -1
  51. data/sys/shr/version.rb +2 -4
  52. metadata +50 -27
  53. data/sys/views/base.rb +0 -29
  54. data/sys/views/dom.rb +0 -27
  55. data/sys/views/games/deck.rb +0 -97
  56. data/sys/views/games/menu.rb +0 -27
  57. data/sys/views/setup/setup.rb +0 -27
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 526b2b77c9a4a0315c096cf27028a45a3294113ea198d36771a690d34efbcb25
4
- data.tar.gz: a3f5c221245676bf831498b1517fcb654deeec2c5ecd6ad1aa5b7ba3b4bf3c67
3
+ metadata.gz: 345792256f8f05280325a6624e2b48f4dffbd0215edd29e166d299c9b43a1824
4
+ data.tar.gz: ede644cd354d9a8e51ec0081284122546266d1e74ddc7af263eddf7f97e150fc
5
5
  SHA512:
6
- metadata.gz: 311cb1b3d8df2da508f73b954c3169c92cb3fb5a0532b08ba60b96e31f6cf0a0681ee70d166ee68fcedeae8064a07b05498b491585c5a4f7aca3d1f8da3b25bd
7
- data.tar.gz: 2ec454c0546e13d18ea541b40cf29308aa443e986559ced667918cc63bac3dcaa1406f02a2a93ed0383a7f9c7d7b378bb945897e850b8f0f123f579a8fb34fc2
6
+ metadata.gz: af57fefc8b44ce65dea0f8b94e1d2a6de610875b15a1d3682d5a07d9fcd8537b54f94461da569b877269933fbe4c27c0e84770118b7221904bf8ec0364e27fdf
7
+ data.tar.gz: 8a4a5bd92dd6056a3af2e76760912e2785d2bf95c535a0046302e9d67fa4e227c974f1f607125c9723d8912b7bd28d1c1cc2056fbc66186dfd81ee203f54025f
data/aro.gemspec CHANGED
@@ -1,5 +1,5 @@
1
1
  =begin
2
-
2
+
3
3
  aro.gemspec
4
4
 
5
5
  aro gem specification.
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
21
21
  spec.license = "MIT"
22
22
  spec.files = `git ls-files`.split("\n").reject{|p| p.match?(/^(spec|.release|.*.gem$)/)}
23
23
  spec.bindir = "bin"
24
- spec.executables = ["aro"]
24
+ spec.executables = ["aro", "aos"]
25
25
  spec.require_paths = ["sys"]
26
26
  spec.required_ruby_version = ">= 3.4.7"
27
27
 
@@ -29,11 +29,11 @@ Gem::Specification.new do |spec|
29
29
  spec.add_development_dependency "bundler", "~> 2.7", ">= 2.7.2"
30
30
  spec.add_development_dependency "rake", "~> 13.3", ">= 13.3.1"
31
31
  spec.add_development_dependency "rspec", "~> 3.13", ">= 3.13.2"
32
+ spec.add_development_dependency "listen", "~> 3.9", ">= 3.9.0"
32
33
 
33
34
  # runtime gems
34
35
  spec.add_runtime_dependency "i18n", "~> 1.14", ">= 1.14.7"
35
36
  spec.add_runtime_dependency "activerecord", "~> 8.1", ">= 8.1.1"
36
37
  spec.add_runtime_dependency "sqlite3", "~> 2.8", ">= 2.8.0"
37
38
  spec.add_runtime_dependency "tty-prompt", "~> 0.23.1", ">= 0.23.1"
38
- spec.add_runtime_dependency "listen", "~> 3.9", ">= 3.9.0"
39
39
  end
data/bin/aos ADDED
@@ -0,0 +1,19 @@
1
+ #! /usr/bin/env ruby
2
+
3
+ =begin
4
+
5
+ aos
6
+
7
+ entry point for aos.
8
+
9
+ by i2097i
10
+
11
+ =end
12
+
13
+ require :aro.to_s
14
+
15
+ if CLI::ARGV0 == CLI::CMDS[:AOS][:WATCH]
16
+ Aos::watch
17
+ else CLI::ARGV0 == CLI::CMDS[:AOS][:RUN] || CLI::ARGV0.nil?
18
+ exit(Aos::run)
19
+ end
@@ -0,0 +1 @@
1
+ e514a75bfef8d203ecb961b0488476804a588baf5ba04d43457adf3ae554028233205e289e633198bb88b46eac2a4a896a0c6beac350e742c82d04992b65a9ad
@@ -0,0 +1 @@
1
+ a81a98088e88fd7b8a12c6919a8b4b3b27fc11258e1a453006b0c1eb856eb023c6219aab39343bbceeab6349bac0e2491176734fc840eb8945efa72d742ee9e8
@@ -8,9 +8,12 @@ class CreateDecks < ActiveRecord::Migration[8.1]
8
8
 
9
9
  t.timestamps
10
10
  end
11
+
12
+ add_index :decks, :name, unique: true
11
13
  end
12
14
 
13
15
  def self.down
16
+ remove_index :decks, :name
14
17
  drop_table :decks
15
18
  end
16
19
 
@@ -13,6 +13,7 @@ class CreateLogs < ActiveRecord::Migration[8.1]
13
13
  end
14
14
 
15
15
  def self.down
16
+ remove_index :logs, :deck_id
16
17
  drop_table :logs
17
18
  end
18
19
 
@@ -0,0 +1,19 @@
1
+ class CreateYous < ActiveRecord::Migration[8.1]
2
+
3
+ def self.up
4
+ create_table :yous do |t|
5
+ t.string :name, null: false
6
+ t.string :pwd
7
+
8
+ t.timestamps
9
+
10
+ t.index :name, unique: true
11
+ end
12
+ end
13
+
14
+ def self.down
15
+ remove_index :yous, :name
16
+ drop_table :yous
17
+ end
18
+
19
+ end
data/locale/en.aos.yml ADDED
@@ -0,0 +1,27 @@
1
+ en:
2
+ aos:
3
+ commands:
4
+ description:
5
+ cd: "change directory. no args navigates to arodom root."
6
+ config: "open settings."
7
+ config_set: "set a ivar config variable to a specified value."
8
+ exit: "exit."
9
+ ls: "list files and folders in the pwd."
10
+ pwd: "show pwd."
11
+ usage:
12
+ cd: "$ cd <name>"
13
+ config: "$ config"
14
+ config_set: "$ config set <var_name> <var_value>"
15
+ exit: "$ exit"
16
+ ls: "$ ls"
17
+ pwd: "$ pwd"
18
+ constants:
19
+ commands: "COMMANDS"
20
+ views:
21
+ dom:
22
+ title: "welcome to the dom. this is the hub of the arodome running on Aos::Os."
23
+ description: "this is the root space where you begin. available commands are listed below."
24
+ quick_navigation: "the following room names are reserved for quick navigation. enter any of them to navigate to that room."
25
+ game:
26
+ title: "aro"
27
+ description: "enter commands to play."
@@ -0,0 +1,5 @@
1
+ # record of changes that could impact old versions
2
+ en:
3
+ cngelog:
4
+ 1765093549_rename_display_column: "rename(ivar): ARO_CONFIG_DISPLAY_COLUMN -> ARO_CONFIG_WIDTH"
5
+ 1765094034_add_height_env_var: "add(ivar): ARO_CONFIG_HEIGHT"
data/locale/en.usage.yml CHANGED
@@ -17,7 +17,7 @@ en:
17
17
 
18
18
  init
19
19
  set up the .aro directory that contains database and config
20
-
20
+
21
21
  note:
22
22
  this runs by default after create and has no effect if init is complete.
23
23
 
@@ -52,12 +52,12 @@ en:
52
52
 
53
53
  example:
54
54
 
55
- $ aro deck create <name>
55
+ $ aro deck new <name>
56
56
 
57
57
  replace
58
58
  replaces all drawn cards FIFO and puts them on the bottom of
59
59
  the deck. this will preserve all card orientations.
60
-
60
+
61
61
  reset
62
62
  completely reset the deck. replace all drawn and reset order.
63
63
  all orientations will be set to upright. you must enter 'aroyes'
@@ -94,16 +94,15 @@ en:
94
94
 
95
95
  $ aro dom <commands>
96
96
 
97
- SUBCOMMANDS
98
- init
99
- generate the arodome
97
+ note: passing no arguments displays the main dom.
100
98
 
101
- map
102
- display arodome map
99
+ example
103
100
 
104
- example
101
+ $ aro dom
105
102
 
106
- $ aro dom map
103
+ SUBCOMMANDS
104
+ init
105
+ generate the arodome
107
106
  new
108
107
  create a new arodome with the specified name.
109
108
 
data/locale/en.yml CHANGED
@@ -5,46 +5,61 @@ en:
5
5
  # VERY IMPORTANT!
6
6
 
7
7
  config:
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."
8
+ aro_env:
9
+ O_description: "read-only env var for holding O."
10
+ S_description: "read-only env var for holding S."
11
+ OS_description: "read-only env var for holding OS."
12
+ E_description: "read-only env var for holding E."
13
+ N_description: "read-only env var for holding N"
14
+ PS1_description: "read-only env var for holding default PS1."
15
+ NAME_FILE_description: "read-only env var for name file."
16
+ I2097I_description: "read-only env var for i2097i."
17
+ YES_description: "read-only env var for 'aroyes'."
18
+ ALL_description: "read-only env var for 'all'."
17
19
  def_type: "CLI::Config::DEF_TYPES"
18
- dimension_description: "selected dimension of aro space."
19
- dimension_dev_tarot_description: "reads from /dev/tarot device if available."
20
- dimension_ruby_facot_description: "generated ruby_facot (facade randomness)."
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."
26
- generating_default_config: "missing config. generating default config file at %{name}."
27
- json_format_description: "show aro responses in json format."
20
+ dimension:
21
+ description: "selected dimension of aro space."
22
+ dev_tarot_description: "reads from /dev/tarot device if available."
23
+ ruby_facot_description: "generated ruby_facot (facade randomness)."
24
+ format:
25
+ description: "aro output format."
26
+ text_description: "show aro responses in text format (default)"
27
+ json_description: "show aro responses in json format."
28
+
29
+ height_description: "display height. valid range: (${min}-${max})"
30
+ width_description: "display width. valid range: (${min}-${max})"
31
+
32
+ env:
33
+ description: "aro run environment."
34
+ development_description: "basic development logs and features."
35
+ production_description: "game logging only."
36
+ test_description: "logging and features tailored for tests."
37
+
38
+ generate: "generating default config file at %{name}."
39
+ source: "installing ivars from %{name}..."
40
+
28
41
  maximum: "max"
29
42
  minimum: "min"
30
43
  possible_values: "possible values"
31
- text_format_description: "show aro responses in text format (default)"
32
- type_int_description: "a primitive decimal-less numeric."
33
- type_string_description: "a blank-space-terminated string of characters."
34
- type_values_description: "an enumerated type."
35
- sourcing_config: "loading configuration from %{name}..."
44
+
45
+ type:
46
+ bool_description: "true or false."
47
+ int_description: "a primitive decimal-less numeric."
48
+ string_description: "a blank-space-terminated string of characters."
49
+ values_description: "an enumerated type."
50
+
36
51
  z_description: "sleep time between attempts to read /dev/tarot. valid range (%{min}-%{max})"
37
52
  z_max_description: "max number of z long sleeps before giving up. valid range (%{min}-%{max})"
38
53
  errors:
39
54
  # , 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."
55
+ header: "$%{cmd}: !error."
56
+ invalid_usage: "$%{cmd}: !says you're not supposed to be here."
57
+ missing_args: "$%{cmd}: !says missing required argument(s)."
58
+ missing_deck: "$%{cmd}: !no deck selected. use 'aro deck' to select one or 'aro deck new <name>' to create one."
59
+ not_in_aro: "$%{cmd}: !you are not in aro space. that command will not work here."
60
+ not_initialized: "$%{cmd}: you need to initialize aro. run 'aro init' to do so"
45
61
  warnings:
46
62
  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"
48
63
  messages:
49
64
  choose_card: "choose a card."
50
65
  confirmation_prompt: "input 'aroyes' to reset %{name}, or enter to cancel (cancel): "
@@ -72,7 +87,7 @@ en:
72
87
 
73
88
  use the following command to create one:
74
89
 
75
- $ aro deck create <deck_name>
90
+ $ aro deck new <deck_name>
76
91
 
77
92
  see aro --help for usage.
78
93
  showing: "showing %{name} [count:%{count}, order:%{order}]..."
data/sys/aos/aos.rb ADDED
@@ -0,0 +1,199 @@
1
+ =begin
2
+
3
+ aos.rb
4
+
5
+ aos.
6
+
7
+ by i2097i
8
+
9
+ =end
10
+
11
+ require :aro.to_s
12
+
13
+ module Aos
14
+
15
+ def self.run
16
+ Aos::Os::boot(Aos::you)
17
+ Aos::Os.instance.run
18
+ end
19
+
20
+ def self.watch
21
+ Aos::Os::boot(Aos::you)
22
+ Aos::Os::instance.render
23
+ end
24
+
25
+ def self.you
26
+ Aos::Db.new
27
+ you = Aos::You.where(name: :you).first
28
+ if you.nil?
29
+ you = Aos::You.new(name: :you, pwd: Dir.pwd)
30
+ you.save
31
+ end
32
+
33
+ you
34
+ end
35
+
36
+ class Os
37
+ include Singleton
38
+
39
+ attr_accessor :you, :running, :view
40
+
41
+ PS1 = "@#{Aos::Os}$"
42
+
43
+ CMDS = {
44
+ CD: {
45
+ key: :cd,
46
+ description: I18n.t("aos.commands.description.cd"),
47
+ usage: I18n.t("aos.commands.usage.cd"),
48
+ },
49
+ CONFIG: {
50
+ key: :config,
51
+ description: I18n.t("aos.commands.description.config"),
52
+ usage: I18n.t("aos.commands.usage.config"),
53
+ cmds: {
54
+ SET: {
55
+ key: :set,
56
+ description: I18n.t("aos.commands.description.config_set"),
57
+ usage: I18n.t("aos.commands.usage.config_set"),
58
+ }
59
+ }
60
+ },
61
+ EXIT: {
62
+ key: :exit,
63
+ description: I18n.t("aos.commands.description.exit"),
64
+ usage: I18n.t("aos.commands.usage.exit"),
65
+ },
66
+ LS: {
67
+ key: :ls,
68
+ description: I18n.t("aos.commands.description.ls"),
69
+ usage: I18n.t("aos.commands.usage.ls"),
70
+ },
71
+ PWD: {
72
+ key: :pwd,
73
+ description: I18n.t("aos.commands.description.pwd"),
74
+ usage: I18n.t("aos.commands.usage.pwd"),
75
+ },
76
+ }
77
+
78
+ def self.boot(you)
79
+ self.instance.you = you
80
+ self.instance.load_view
81
+ end
82
+
83
+ def load_view
84
+ view_name = Aos::Os.osify(you.pwd).split("/").last || :dom.to_s
85
+ view_cls = (Aos::Vi.name + "::#{view_name.capitalize}").constantize
86
+ Aro::D.say("loading view #{view_cls}")
87
+ self.view = view_cls
88
+ end
89
+
90
+ def render
91
+ return if view.nil?
92
+
93
+ view.show(you)
94
+ end
95
+
96
+ def run
97
+ self.running = true
98
+
99
+ # begin game loop
100
+ while running do
101
+ # get input
102
+ cmd = Aos::S.p.ask(Aos::Os::PS1)
103
+
104
+ # default to passthrough
105
+ passthrough = true
106
+
107
+ # get args
108
+ args = cmd.split(" ")
109
+
110
+ # search for room path
111
+ room_path = Aro::Dom.room_path(args[0])
112
+ if !room_path.empty?
113
+ you.update(pwd: File.join(
114
+ File.dirname(Aro::Dom.ethergeist_path),
115
+ room_path
116
+ ))
117
+ Dir.chdir(you.pwd)
118
+ next
119
+ end
120
+
121
+ # determine if command is Aos::Os::CMDS
122
+ if Aos::Os::CMDS.values.map{|v| v[:key]}.include?(args[0].to_sym)
123
+ Dir.chdir(you.pwd)
124
+ passthrough = false
125
+ end
126
+
127
+ # config commands
128
+
129
+ if args[0].to_sym == Aos::Os::CMDS[:CONFIG][:key]
130
+ if args[1].nil?
131
+ # show settings
132
+ you.update(pwd:
133
+ File.join(
134
+ File.dirname(Aro::Dom.ethergeist_path),
135
+ Aro::Dom::SETUP.to_s,
136
+ Aro::Dom::SETTINGS.to_s
137
+ )
138
+ )
139
+ else
140
+ Aos::S.say("not implemented.")
141
+ end
142
+ elsif args[0] == Aos::Os::CMDS[:LS][:key].to_s
143
+ Aos::S.say(Dir[File.join(Dir.pwd, "*/")].map{|p| "@/" + Aos::Os::osify(p)}.join("\n"))
144
+ elsif args[0] == Aos::Os::CMDS[:PWD][:key].to_s
145
+ osified = "@/" + Aos::Os::osify(you.pwd)
146
+ Aos::S.say(osified)
147
+ elsif args[0] == Aos::Os::CMDS[:EXIT][:key].to_s
148
+ Aos::S.say("exiting...")
149
+ self.running = false
150
+ elsif args[0] == Aos::Os::CMDS[:CD][:key].to_s
151
+
152
+ if args[1].nil? || args[1] == "~/"
153
+ # no arg takes you to arodom root
154
+ you.update(pwd: File.dirname(Aro::Dom.ethergeist_path))
155
+ else
156
+ if args[1].include?("..")
157
+ # going up
158
+ if File.dirname(Aro::Dom.ethergeist_path) == you.pwd
159
+ Aos::S.say("within #{Aos::Os}, one cannot leave the #{Aro::Dom}.")
160
+ else
161
+ # todo: support dots in paths
162
+ # this only supports moving one level up
163
+
164
+ pwd_arr = you.pwd.split("/")
165
+ new_pwd = (pwd_arr.first(pwd_arr.length - 1)).join("/")
166
+
167
+ you.update(pwd: new_pwd)
168
+ end
169
+ elsif !args[1].nil?
170
+ if args[1][0] != "/" && Dir.exist?(args[1])
171
+ you.update(pwd: File.join(you.pwd, args[1]))
172
+ else
173
+ Aos::S.say("that directory is invalid.")
174
+ end
175
+ end
176
+ end
177
+ end
178
+
179
+ if passthrough
180
+ system(cmd)
181
+ end
182
+ end
183
+
184
+ CLI::EXIT_CODES[:SUCCESS]
185
+ end
186
+
187
+ def self.osify(path)
188
+ # strips off non-arodom part of path
189
+ # Aos::Os::osify()
190
+
191
+ path_arr = path.split("/")
192
+ Aro::Dom::dom_root.split("/").each{|rdp|
193
+ path_arr.delete(rdp)
194
+ }
195
+
196
+ path_arr.join("/")
197
+ end
198
+ end
199
+ end
data/sys/aos/db.rb ADDED
@@ -0,0 +1,81 @@
1
+ =begin
2
+
3
+ db.rb
4
+
5
+ database for aos room.
6
+
7
+ by i2097i
8
+
9
+ =end
10
+
11
+ module Aos
12
+ class Db < Aro::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
+ # ActiveRecord::Base.logger = Logger.new(STDOUT)
20
+ unless Aro::Dom.in_arodom?
21
+ Aro::P.say(I18n.t("cli.errors.not_in_aro" , cmd: Aro::Dom.name))
22
+ return
23
+ end
24
+
25
+ set_up_aos
26
+ end
27
+
28
+ def self.base_aro_dir
29
+ Aro::Dom.ethergeist_path
30
+ end
31
+
32
+ def db_config_filepath
33
+ File.join(Aos::Db.base_aro_dir, Aos::Db::DATABASE_YML.to_s)
34
+ end
35
+
36
+ def set_up_aos
37
+ name = Aro::Dom.ethergeist_name
38
+ return if name.nil?
39
+
40
+ # create local /.ethergeist directory
41
+ unless File.exist?(Aos::Db.base_aro_dir)
42
+ FileUtils.mkdir(Aos::Db.base_aro_dir)
43
+ end
44
+
45
+ Aro::D.say("creating database: #{db_config_filepath}")
46
+ unless File.exist?(db_config_filepath)
47
+ # create database config yaml file
48
+ c = {
49
+ adapter: :sqlite3.to_s,
50
+ database: File.join(Aos::Db.base_aro_dir, Aos::Db::SQL_FILE.to_s),
51
+ username: name,
52
+ password: name
53
+ }.to_yaml
54
+ File.open(db_config_filepath, "w") do |file|
55
+ file.write(c)
56
+ end
57
+ end
58
+
59
+ connect(name)
60
+ migrate(name)
61
+ end
62
+
63
+ def migrate(name)
64
+ local_migrate_dir = File.join(Aos::Db.base_aro_dir, Aos::Db::MIGRATIONS_DIR.to_s)
65
+ unless Dir.exist?(local_migrate_dir)
66
+ gem_dir = Dir[Gem.loaded_specs[:aro.to_s]&.full_gem_path || '.'].first
67
+ FileUtils.cp_r(File.join(gem_dir, "db"), Aos::Db::base_aro_dir)
68
+ end
69
+
70
+ migration_version = Dir["#{local_migrate_dir}/*.rb"].map{|n|
71
+ Pathname.new(n).basename.to_s.split("_")[0].to_i
72
+ }.max
73
+ ActiveRecord::MigrationContext.new(local_migrate_dir).migrate(migration_version)
74
+
75
+ filename = File.join(Aos::Db.base_aro_dir, Aos::Db::SCHEMA_FILE.to_s)
76
+ File.open(filename, "w+") do |f|
77
+ ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection_pool, f)
78
+ end
79
+ end
80
+ end
81
+ end
data/sys/aos/s.rb ADDED
@@ -0,0 +1,25 @@
1
+ =begin
2
+
3
+ s.rb
4
+
5
+ s logger for i2097i.
6
+
7
+ by i2097i
8
+
9
+ =end
10
+
11
+ require_relative :"../shr/prompt".to_s
12
+
13
+ module Aos
14
+ class S < Aro::Prompt
15
+ def self.say(message)
16
+ return unless Aos::S.should_print?
17
+ Aro::P::p.say(message)
18
+ end
19
+
20
+ def self.should_print?
21
+ true
22
+ end
23
+ end
24
+ end
25
+