aro 0.2.1 → 0.2.3

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 (93) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/Gemfile.lock +1 -1
  4. data/README.md +1 -1
  5. data/aro.gemspec +3 -3
  6. data/bin/aos +10 -3
  7. data/bin/aro +18 -11
  8. data/checksums/aro-0.2.1.gem.sha512 +1 -0
  9. data/checksums/aro-0.2.2.gem.sha512 +1 -0
  10. data/checksums/aro-0.2.3.gem.sha512 +1 -0
  11. data/locale/en.abot.yml +81 -0
  12. data/locale/en.amg.yml +44 -0
  13. data/locale/en.aos.yml +8 -38
  14. data/locale/en.cor.yml +47 -0
  15. data/locale/en.data.yml +30 -0
  16. data/locale/en.dom.yml +22 -18
  17. data/locale/en.flie.yml +29 -0
  18. data/locale/en.usage.yml +39 -26
  19. data/locale/en.yml +10 -51
  20. data/sys/aos/abot.rb +256 -0
  21. data/sys/aos/amg.rb +58 -56
  22. data/sys/aos/aos.rb +425 -180
  23. data/sys/aos/cor.rb +773 -0
  24. data/sys/aos/data.rb +117 -0
  25. data/sys/aos/db/migrate/1765148774_create_yous.rb +1 -0
  26. data/sys/aos/db/migrate/{1765762724_create_libs.rb → 1765762724_create_ilibs.rb} +5 -5
  27. data/sys/aos/db/migrate/1765907766_create_ilogs.rb +18 -0
  28. data/sys/aos/db/migrate/1765933985_create_agodos.rb +22 -0
  29. data/sys/aos/db/migrate/1766203888_create_fpxies.rb +18 -0
  30. data/sys/aos/db.rb +47 -27
  31. data/sys/aos/flie.rb +144 -0
  32. data/sys/aos/models/agodo.rb +96 -0
  33. data/sys/aos/models/base_model.rb +13 -0
  34. data/sys/aos/models/fpxy.rb +28 -0
  35. data/sys/{shr/lib/lib.rb → aos/models/ilib.rb} +11 -6
  36. data/sys/aos/models/ilog.rb +29 -0
  37. data/sys/aos/models/you.rb +98 -0
  38. data/sys/aos/s.rb +2 -1
  39. data/sys/aos/vws/base.rb +69 -78
  40. data/sys/aos/vws/dom.rb +1 -2
  41. data/sys/aos/vws/games/abot.rb +21 -0
  42. data/sys/aos/vws/games/{game.rb → teck.rb} +27 -24
  43. data/sys/aos/vws/home.rb +23 -0
  44. data/sys/aos/vws/know/{temple.rb → body.rb} +3 -3
  45. data/sys/aos/vws/know/{library.rb → mind.rb} +3 -3
  46. data/sys/aos/vws/know/spirit.rb +19 -0
  47. data/sys/aos/vws/{setup → root}/amg.rb +1 -2
  48. data/sys/aos/vws/{setup → root}/config.rb +4 -4
  49. data/sys/aos/vws/root/data.rb +21 -0
  50. data/sys/aos/vws/root/flie.rb +21 -0
  51. data/sys/aos/vws/{setup.rb → root.rb} +3 -3
  52. data/sys/aos/vws/welcome/waite.rb +1 -0
  53. data/sys/aos/vws/welcome.rb +47 -0
  54. data/sys/aro/d.rb +4 -2
  55. data/sys/aro/db/migrate/{1763374647_create_decks.rb → 1763374647_create_tecks.rb} +5 -5
  56. data/sys/aro/db/migrate/1763432541_create_tlogs.rb +20 -0
  57. data/sys/aro/db.rb +28 -19
  58. data/sys/aro/mancy.rb +18 -22
  59. data/sys/aro/models/base_model.rb +13 -0
  60. data/sys/{models/deck.rb → aro/models/teck.rb} +60 -57
  61. data/sys/aro/models/tlog.rb +21 -0
  62. data/sys/aro/p.rb +1 -1
  63. data/sys/aro/r.rb +2 -1
  64. data/sys/aro/v.rb +2 -2
  65. data/sys/cli/constants.rb +4 -10
  66. data/sys/cli/create.rb +2 -3
  67. data/sys/cli/dom.rb +1 -2
  68. data/sys/cli/{deck.rb → teck.rb} +38 -45
  69. data/sys/cli.rb +10 -11
  70. data/sys/dom/d.rb +68 -46
  71. data/sys/dom/dom.rb +79 -44
  72. data/sys/dom/p.rb +1 -1
  73. data/sys/fpx.rb +116 -0
  74. data/sys/reiquire.rb +8 -8
  75. data/sys/shr/prompt.rb +2 -6
  76. data/sys/shr/t.rb +11 -13
  77. data/sys/shr/version.rb +1 -1
  78. data/tasks/make.rake +1 -1
  79. metadata +82 -62
  80. data/locale/en.cngelog.yml +0 -5
  81. data/sys/aos/vws/games/abpps.rb +0 -19
  82. data/sys/aos/vws/games/hbpps.rb +0 -19
  83. data/sys/aos/vws/games/shpps.rb +0 -19
  84. data/sys/aos/vws/games/vipps.rb +0 -19
  85. data/sys/aos/you.rb +0 -21
  86. data/sys/aro/db/migrate/1763432541_create_logs.rb +0 -20
  87. data/sys/dom/config.rb +0 -665
  88. data/sys/models/log.rb +0 -20
  89. /data/sys/shr/{lib → ilib}/crs/CMakeLists.txt +0 -0
  90. /data/sys/shr/{lib → ilib}/crs/compile.sh +0 -0
  91. /data/sys/shr/{lib → ilib}/crs/crs.c +0 -0
  92. /data/sys/shr/{lib → ilib}/crs/crs.o +0 -0
  93. /data/sys/shr/{lib → ilib}/crs/libcrs.so +0 -0
data/sys/cli/dom.rb CHANGED
@@ -25,8 +25,7 @@ module CLI
25
25
  if Aro::Dom.is_initialized?
26
26
  Aro::P.say(I18n.t("dom.errors.failed_already_initialized"))
27
27
  elsif Aro::Dom.in_arodom? && !Aro::Dom.is_initialized?
28
- arodome = Aro::Dom.new
29
- arodome.generate
28
+ Aro::Dom.instance.generate(ARGV[Aro::Mancy::OS], ARGV[Aro::Mancy::E])
30
29
  else
31
30
  CLI::Nterface.exit_error_invalid_usage!
32
31
  end
@@ -1,16 +1,16 @@
1
1
  =begin
2
2
 
3
- deck.rb
3
+ teck.rb
4
4
 
5
- process deck commands.
5
+ process teck commands.
6
6
 
7
7
  by i2097i
8
8
 
9
9
  =end
10
10
 
11
11
  module CLI
12
- # cli entrypoint
13
- def self.deck
12
+ def self.teck
13
+ Aro::Mancy.init
14
14
  action = CLI::ARGV1&.to_sym
15
15
 
16
16
  if CLI::FLAGS[:HELP].include?(action.to_s)
@@ -18,67 +18,60 @@ module CLI
18
18
  CLI.usage::usage
19
19
  exit(CLI::EXIT_CODES[:SUCCESS])
20
20
  elsif action.nil? || action == :aos
21
- # no args, open deck menu
21
+ # no args, open teck menu
22
22
  if Aro::Mancy.in_aro?
23
- Aro::Db.new
24
- Aro::Deck.display_selection_menu
23
+ Aro::Teck.display_selection_menu
25
24
  else
26
25
  Aro::P.say(I18n.t("cli.errors.not_in_aro" , cmd: Aro::Mancy::I2097I))
27
26
  end
28
- elsif action == CLI::CMDS[:DECK][:NEW]
27
+ elsif action == CLI::CMDS[:TECK][:NEW]
29
28
  CLI::Nterface.exit_error_missing_args! if CLI::ARGV2.nil?
30
29
  if Aro::Mancy.in_aro?
31
- Aro::Db.new
32
- deck = Aro::Deck.make(CLI::ARGV2.to_s)
33
- Aro::P.say(I18n.t("cli.messages.deck_created_sucessfully", name: deck.name))
34
- Aro::Deck.display_selection_menu
30
+ teck = Aro::Teck.make(CLI::ARGV2.to_s)
31
+ Aro::P.say(I18n.t("cli.messages.teck_created_sucessfully", name: teck.name))
32
+ Aro::Teck.display_selection_menu
35
33
  else
36
34
  Aro::P.say(I18n.t("cli.errors.not_in_aro" , cmd: Aro::Mancy::I2097I))
37
35
  end
38
- elsif CLI::CMDS[:DECK].values.include?(action)
39
- if Aro::Mancy.game.nil?
40
- Aro::P.say(I18n.t("cli.errors.missing_deck", cmd: Aro::Mancy::I2097I))
36
+ elsif CLI::CMDS[:TECK].values.include?(action)
37
+ if Aro::Mancy.teck.nil?
38
+ Aro::P.say(I18n.t("cli.errors.missing_teck", cmd: Aro::Mancy::I2097I))
41
39
  exit(CLI::EXIT_CODES[:GENERAL_ERROR])
42
40
  end
43
41
 
44
42
  case action
45
- when CLI::CMDS[:DECK][:EXPLORE]
46
- Aro::Mancy.game.explore
43
+ when CLI::CMDS[:TECK][:EXPLORE]
44
+ Aro::Mancy.teck.explore
47
45
  exit(CLI::EXIT_CODES[:SUCCESS])
48
- when CLI::CMDS[:DECK][:SHUFFLE]
49
- Aro::P.say(I18n.t("cli.messages.shuffling", name: Aro::Mancy.game.name))
50
- Aro::Mancy.game.shuffle
51
- when CLI::CMDS[:DECK][:DRAW]
52
- Aro::P.say(I18n.t("cli.messages.drawing", name: Aro::Mancy.game.name))
53
- Aro::P.say(I18n.t("cli.messages.drawing_from_dimension", dimension: "#{Aro::Config.ivar(:DIMENSION)}"))
54
- Aro::Mancy.game.draw(
46
+ when CLI::CMDS[:TECK][:SHUFFLE]
47
+ Aro::P.say(I18n.t("cli.messages.shuffling", name: Aro::Mancy.teck.name))
48
+ Aro::Mancy.teck.shuffle
49
+ when CLI::CMDS[:TECK][:DRAW]
50
+ Aro::P.say(I18n.t("cli.messages.drawing", name: Aro::Mancy.teck.name))
51
+ Aro::P.say(I18n.t("cli.messages.drawing_from_dimension", dimension: "#{Aos::Cor.ivar(:DIMENSION)}"))
52
+ Aro::Mancy.teck.draw(
55
53
  is_dt_dimension: Aro::T::is_dev_tarot?,
56
- z_max: Aro::Config.ivar(:Z_MAX).to_i,
57
- z: Aro::Config.ivar(:Z)
54
+ z_max: Aos::Cor.ivar(:Z_MAX).to_i,
55
+ z: Aos::Cor.ivar(:Z)
58
56
  )
59
- when CLI::CMDS[:DECK][:REPLACE]
60
- Aro::P.say(I18n.t("cli.messages.replacing_drawn", name: Aro::Mancy.game.name))
61
- Aro::Mancy.game.replace
62
- when CLI::CMDS[:DECK][:RESET]
63
- if Aro::Mancy::YES.to_s != Aro::P.p.ask("#{Aro::Mancy::PS1}#{I18n.t("cli.messages.confirmation_prompt", name: Aro::Mancy.game.name)}")
64
- Aro::P.say(I18n.t("cli.messages.understood", name: Aro::Mancy.game.name))
57
+ when CLI::CMDS[:TECK][:REPLACE]
58
+ Aro::P.say(I18n.t("cli.messages.replacing_drawn", name: Aro::Mancy.teck.name))
59
+ Aro::Mancy.teck.replace
60
+ when CLI::CMDS[:TECK][:RESET]
61
+ Aro::P.say("#{I18n.t("cli.messages.confirmation_prompt", name: Aro::Mancy.teck.name)}")
62
+ Aro::P.say("\n")
63
+ if Aro::Mancy::YES.to_s != Aos::S.p.ask("\n#{Aro::Mancy::PS1}$")
64
+ Aro::P.say(I18n.t("cli.messages.understood", name: Aro::Mancy.teck.name))
65
65
  exit(CLI::EXIT_CODES[:SUCCESS])
66
66
  end
67
67
 
68
- Aro::P.say(I18n.t("cli.messages.resetting", name: Aro::Mancy.game.name))
69
- Aro::Mancy.game.reset
68
+ Aro::P.say(I18n.t("cli.messages.resetting", name: Aro::Mancy.teck.name))
69
+ Aro::Mancy.teck.reset
70
70
  end
71
-
72
- if ARGV.include?(:aos.to_s)
73
- # run silent
74
- exit(CLI::EXIT_CODES[:SUCCESS])
75
- end
76
-
77
- Aro::Mancy.game.show(**CLI::shoptions)
71
+ Aro::Mancy.teck.show(**CLI::shoptions)
78
72
  else
79
- Aro::Db.new
80
- Aro::Deck.select_deck(
81
- Aro::Deck.find_by(name: action)
73
+ Aro::Teck.select_teck(
74
+ Aro::Teck.find_by(name: action)
82
75
  )
83
76
  end
84
77
  end
@@ -87,7 +80,7 @@ module CLI
87
80
  # todo: better naming
88
81
  def self.shoptions
89
82
  show_options_count = Aro::Mancy::S
90
- show_options_order = Aro::Log::ORDERING[:DESC]
83
+ show_options_order = Aro::Tlog::ORDERING[:DESC]
91
84
 
92
85
  # Aro::D.say("ARGV.map{|a| a.to_sym} => #{ARGV.map{|a| a.to_sym}}")
93
86
 
data/sys/cli.rb CHANGED
@@ -2,24 +2,23 @@
2
2
 
3
3
  cli
4
4
 
5
- the very first file loaded.
5
+ aro cli module.
6
6
 
7
7
  by i2097i
8
8
 
9
9
  =end
10
10
 
11
11
  module CLI
12
- argv_sanitized = Aos::Os.sanitize_you(ARGV.join(" ")).split(" ")
13
-
14
- if CLI::CMDS[:DECK].values.include?(argv_sanitized[0]&.to_sym)
15
- # enable deck shortcut (skip typing deck while in-game)
16
- ARGV0 = :deck
17
- ARGV1 = argv_sanitized[0]&.to_sym
18
- ARGV2 = argv_sanitized[1]&.to_sym
12
+ # todo: make this filtering better. dom uses :new as well
13
+ if CLI::CMDS[:TECK].values.filter{|k| ![:new].include?(k)}.include?(ARGV[0]&.to_sym)
14
+ # enable teck shortcut (skip typing teck while in-game)
15
+ ARGV0 = :teck
16
+ ARGV1 = ARGV[0]&.to_sym
17
+ ARGV2 = ARGV[1]&.to_sym
19
18
  else
20
19
  # default
21
- ARGV0 = argv_sanitized[0]&.to_sym
22
- ARGV1 = argv_sanitized[1]&.to_sym
23
- ARGV2 = argv_sanitized[2]&.to_sym
20
+ ARGV0 = ARGV[0]&.to_sym
21
+ ARGV1 = ARGV[1]&.to_sym
22
+ ARGV2 = ARGV[2]&.to_sym
24
23
  end
25
24
  end
data/sys/dom/d.rb CHANGED
@@ -9,23 +9,39 @@
9
9
  =end
10
10
 
11
11
  require_relative :dom.to_s
12
+ require_relative :"../shr/prompt".to_s
12
13
 
13
14
  module Aro
14
15
  class Dom::D
15
- def self.reserved_words
16
- reserved = []
17
- Aro::Dom::D::LAYOUT.values.each{|wing|
18
- reserved << wing[:name].to_s
19
- wing[:rooms].each{|room| reserved << room[:name].to_s}
20
- }
16
+ include Singleton
17
+
18
+ attr_accessor :reserved_words_def
19
+
20
+ def self.reserved_words(include_root = false)
21
+ if Aro::Dom::D.instance.reserved_words_def.nil?
22
+
23
+ reserved = []
24
+ Aro::Dom::D::LAYOUT.values.each{|wing|
25
+ if wing == Aro::Dom::D::LAYOUT[:ROOT]&& !include_root
26
+ next
27
+ end
28
+
29
+ reserved << wing[:name].to_s
30
+ wing[:rooms].each{|room| reserved << room[:name].to_s}
31
+ }
21
32
 
22
- reserved.sort
33
+ Aro::Dom::D.instance.reserved_words_def = reserved.sort
34
+ end
35
+
36
+ return Aro::Dom::D.instance.reserved_words_def
23
37
  end
24
38
 
25
39
  # definition of rooms in each layout wing
26
40
  WINGS = {
27
41
  WELCOME: {
28
42
  WAITE: {
43
+ # todo: make a wai/wait/wae learning tool for practicing
44
+ # command usage in a sandbox.
29
45
  name: Aro::Dom::WAITE,
30
46
  description: I18n.t("dom.rooms.waite.description"),
31
47
  },
@@ -35,42 +51,43 @@ module Aro
35
51
  },
36
52
  },
37
53
  GAMES: {
38
- ABPPS: {
39
- name: Aro::Dom::ABPPS,
40
- description: I18n.t("dom.rooms.abpps.description"),
41
- },
42
- HBPPS: {
43
- name: Aro::Dom::HBPPS,
44
- description: I18n.t("dom.rooms.hbpps.description"),
45
- },
46
- SHPPS: {
47
- name: Aro::Dom::SHPPS,
48
- description: I18n.t("dom.rooms.shpps.description"),
49
- },
50
- VIPPS: {
51
- name: Aro::Dom::VIPPS,
52
- description: I18n.t("dom.rooms.vipps.description"),
54
+ ABOT: {
55
+ name: Aro::Dom::ABOT,
56
+ description: I18n.t("dom.rooms.abot.description"),
53
57
  },
54
58
  },
55
- KNOW: {
56
- LIBRARY: {
57
- name: Aro::Dom::LIBRARY,
58
- description: I18n.t("dom.rooms.library.description"),
59
+ HOME: {},
60
+ KNOW: {
61
+ BODY: {
62
+ name: Aro::Dom::BODY,
63
+ description: I18n.t("dom.rooms.body.description"),
59
64
  },
60
- TEMPLE: {
61
- name: Aro::Dom::TEMPLE,
62
- description: I18n.t("dom.rooms.temple.description"),
65
+ MIND: {
66
+ name: Aro::Dom::MIND,
67
+ description: I18n.t("dom.rooms.mind.description"),
63
68
  },
64
- },
65
- SETUP: {
66
- CONFIG: {
67
- name: Aro::Dom::CONFIG,
68
- description: I18n.t("dom.rooms.config.description"),
69
+ SPIRIT: {
70
+ name: Aro::Dom::SPIRIT,
71
+ description: I18n.t("dom.rooms.spirit.description"),
69
72
  },
73
+ },
74
+ ROOT: {
70
75
  AMG: {
71
76
  name: Aro::Dom::AMG,
72
77
  description: I18n.t("dom.rooms.amg.description"),
73
78
  },
79
+ COR: {
80
+ name: Aro::Dom::COR,
81
+ description: I18n.t("dom.rooms.config.description"),
82
+ },
83
+ DATA: {
84
+ name: Aro::Dom::DATA,
85
+ description: I18n.t("dom.rooms.data.description"),
86
+ },
87
+ FLIE: {
88
+ name: Aro::Dom::FLIE,
89
+ description: I18n.t("dom.rooms.flie.description"),
90
+ }
74
91
  },
75
92
  }
76
93
 
@@ -88,29 +105,34 @@ module Aro
88
105
  name: Aro::Dom::GAMES,
89
106
  description: I18n.t("dom.wings.games.description"),
90
107
  rooms: [
91
- Aro::Dom::D::WINGS[:GAMES][:ABPPS],
92
- Aro::Dom::D::WINGS[:GAMES][:HBPPS],
93
- Aro::Dom::D::WINGS[:GAMES][:SHPPS],
94
- Aro::Dom::D::WINGS[:GAMES][:VIPPS],
108
+ Aro::Dom::D::WINGS[:GAMES][:ABOT],
95
109
  ],
96
110
  },
111
+ HOME: {
112
+ name: Aro::Dom::HOME,
113
+ description: I18n.t("dom.wings.home.description"),
114
+ rooms: [],
115
+ },
97
116
  KNOW: {
98
117
  name: Aro::Dom::KNOW,
99
118
  description: I18n.t("dom.wings.know.description"),
100
119
  rooms: [
101
- Aro::Dom::D::WINGS[:KNOW][:LIBRARY],
102
- Aro::Dom::D::WINGS[:KNOW][:TEMPLE],
120
+ Aro::Dom::D::WINGS[:KNOW][:BODY],
121
+ Aro::Dom::D::WINGS[:KNOW][:MIND],
122
+ Aro::Dom::D::WINGS[:KNOW][:SPIRIT],
103
123
  ],
104
124
  },
105
- SETUP: {
106
- name: Aro::Dom::SETUP,
107
- description: I18n.t("dom.wings.setup.description"),
125
+ ROOT: {
126
+ name: Aro::Dom::ROOT,
127
+ description: I18n.t("dom.wings.root.description"),
108
128
  rooms: [
109
- Aro::Dom::D::WINGS[:SETUP][:CONFIG],
110
- Aro::Dom::D::WINGS[:SETUP][:AMG],
129
+ Aro::Dom::D::WINGS[:ROOT][:AMG],
130
+ Aro::Dom::D::WINGS[:ROOT][:COR],
131
+ Aro::Dom::D::WINGS[:ROOT][:DATA],
132
+ Aro::Dom::D::WINGS[:ROOT][:FLIE],
111
133
  ],
112
134
  }
113
135
  }
114
136
 
115
137
  end
116
- end
138
+ end
data/sys/dom/dom.rb CHANGED
@@ -8,45 +8,52 @@
8
8
 
9
9
  =end
10
10
 
11
- require_relative :"../aos/s".to_s
12
-
13
11
  module Aro
14
12
  class Dom
15
- PS1 = :">[#{Aro::Dom.name}]>: "
13
+ include Singleton
14
+
15
+ attr_accessor :eg_path, :is_initializing
16
+
17
+ PS1 = :">[#{Aro::Dom.name}]>:"
16
18
  DOT = :"."
17
19
  DOTT = :"#{DOT}#{DOT}"
18
- ETHERGEIST = :ethergeist
20
+ ETHERGEIST = :eg
19
21
  ETHER_FILE = :".#{Aro::Dom::ETHERGEIST}"
20
22
 
21
- # < root space
23
+ # < aro space
22
24
  ARODOME = :arodome
23
25
 
24
26
  # < user spaces
25
27
  WELCOME = :welcome
26
28
  GAMES = :games
29
+ HOME = :home
27
30
  KNOW = :know
28
- SETUP = :setup
31
+ ROOT = :root
29
32
 
30
33
  # > welcome spaces
31
34
  WAITE = :waite
32
35
  WINNER = :winner
33
36
 
34
37
  # > game spaces
35
- ABPPS = :abpps
36
- HBPPS = :hbpps
37
- SHPPS = :shpps
38
- VIPPS = :vipps
38
+ ABOT = :abot
39
39
 
40
40
  # > know spaces
41
- LIBRARY = :library
42
- TEMPLE = :temple
41
+ BODY = :body
42
+ MIND = :mind
43
+ SPIRIT = :spirit
43
44
  # ...
44
45
 
45
- # > setup spaces
46
- CONFIG = :config
46
+ # > root spaces
47
47
  AMG = :amg
48
+ COR = :cor
49
+ DATA = :data
50
+ FLIE = :flie
48
51
  # ...
49
52
 
53
+ def initialize
54
+ self.is_initializing = false
55
+ end
56
+
50
57
  def self.create(name)
51
58
  if Dir.exist?(name) || File.exist?(name)
52
59
  Aro::Dom::P.say(I18n.t("dom.errors.failed_directory_exists", name: name))
@@ -69,9 +76,15 @@ module Aro
69
76
  end
70
77
 
71
78
  def self.is_initialized?
72
- return false if !Aro::Dom.in_arodom?
79
+ return false if !Aro::Dom.in_arodom? || self.instance.is_initializing
73
80
 
74
- File.exist?(File.join(Aro::Dom::ethergeist_path, Aos::Db::SQL_FILE.to_s))
81
+ File.exist?(
82
+ File.join(
83
+ Aro::Dom.dom_root,
84
+ Aro::Dom.room_path(:data),
85
+ Aos::Db::SQL_FILE.to_s
86
+ )
87
+ )
75
88
  end
76
89
 
77
90
  def self.domain
@@ -107,19 +120,22 @@ module Aro
107
120
  end
108
121
 
109
122
  def self.ethergeist_path
110
- path = nil
111
- search_path = Dir.pwd.split("/").reject{|p| p.empty?}
112
- search_pwd = "/"
113
-
114
- search_path.any?{|step|
115
- search_pwd = File.join(search_pwd, step)
116
- ls = Dir.glob("#{search_pwd}/#{ETHER_FILE}", File::FNM_DOTMATCH)
117
-
118
- path = ls.first if ls.any?
119
- !path.nil?
120
- }
123
+ if self.instance.eg_path.nil?
124
+ path = nil
125
+ search_path = Dir.pwd.split("/").reject{|p| p.empty?}
126
+ search_pwd = "/"
127
+ search_path.any?{|step|
128
+ search_pwd = File.join(search_pwd, step)
129
+ ls = Dir.glob("#{search_pwd}/#{ETHER_FILE}", File::FNM_DOTMATCH)
130
+
131
+ path = ls.first if ls.any?
132
+ !path.nil?
133
+ }
134
+
135
+ self.instance.eg_path = path unless path.nil?
136
+ end
121
137
 
122
- return path
138
+ return self.instance.eg_path
123
139
  end
124
140
 
125
141
  def self.ethergeist_name
@@ -132,14 +148,40 @@ module Aro
132
148
  )
133
149
  end
134
150
 
135
- def generate
136
- return unless Aro::Dom.in_arodom?
151
+ def generate(r_you, r_password)
152
+ if r_you.nil? || r_you.empty?
153
+ Aro::Dom::P.say(I18n.t("dom.messages.missing_root_username"))
154
+ return
155
+ end
137
156
 
138
- # todo: add file permissions to Aro::Dom::ARODOME and all WINGS
157
+ if r_password.nil? || r_password.empty?
158
+ Aro::Dom::P.say(I18n.t("dom.messages.missing_root_password"))
159
+ return
160
+ end
161
+
162
+ unless Aro::Dom.in_arodom?
163
+ Aro::Dom::P.say(I18n.t("dom.errors.failed_already_initialized"))
164
+ return
165
+ end
166
+
167
+ self.is_initializing = true
139
168
  Aro::Dom::P.say(I18n.t("dom.messages.generating_wings"))
140
169
  Aro::Dom::D::LAYOUT.values.each{|w| generate_wing w}
141
- Aos::Db::new
170
+ # generate a dom aro instance and teck named same as dom
171
+ Dir.chdir(Aro::Dom.ethergeist_path) do
172
+ Aro::Dom::P.say(I18n.t("dom.messages.generating_dom_aro"))
173
+ Aro::Mancy.init
174
+ Aro::Teck.select_teck(
175
+ Aro::Teck.make(Aro::Dom.ethergeist_name)
176
+ )
177
+ end
178
+ Aos::Db.load(r_password)
179
+ Aos::You.create(name: r_you, access: :root)
142
180
  Aro::Dom::P.say(I18n.t("dom.messages.initialization_complete", name: Aro::Dom.name))
181
+ # todo: make this better and make an initial commit
182
+ system(:"git init".to_s) if `which git`&.strip&.split("/")&.include?(:git.to_s)
183
+
184
+ self.is_initializing = false
143
185
  end
144
186
 
145
187
  def generate_wing(wing)
@@ -151,26 +193,19 @@ module Aro
151
193
  end
152
194
 
153
195
  def generate_room(wing, room)
154
- return unless Aro::Dom::D::WINGS[wing[:name].upcase].values.include?(room)
196
+ return unless Aro::Dom::D::WINGS[wing[:name].upcase].values.include?(room) ||
197
+ wing[:name] == Aro::Dom::HOME
155
198
 
156
199
  Aro::Dom::P.say(I18n.t("dom.messages.generating_room", room: room[:name].to_s))
157
200
 
158
- room_path = File.join(wing[:name].to_s, room[:name].to_s)
159
- FileUtils.mkdir(room_path)
201
+ r_path = File.join(wing[:name].to_s, room[:name].to_s)
202
+ FileUtils.mkdir(r_path)
160
203
 
161
204
  if wing[:name] == Aro::Dom::GAMES
162
- File.open(File.join(room_path, Aro::Mancy::NAME_FILE.to_s), "w") do |f|
205
+ File.open(File.join(r_path, Aro::Mancy::NAME_FILE.to_s), "w") do |f|
163
206
  f.write(room[:name])
164
207
  end
165
208
  end
166
209
  end
167
-
168
- def self.ethergeist_name
169
- File.read(
170
- File.join(
171
- Aro::Dom.ethergeist_path, Aro::Mancy::NAME_FILE.to_s
172
- )
173
- )
174
- end
175
210
  end
176
211
  end # aroadhome
data/sys/dom/p.rb CHANGED
@@ -11,7 +11,7 @@
11
11
  module Aro
12
12
  class Dom::P < Aro::Prompt
13
13
  def self.say(message)
14
- Aro::Dom::P.p.say("#{Aro::Dom::PS1}#{message}")
14
+ super(["#{Aro::Dom::PS1}#{message}"])
15
15
  end
16
16
  end
17
17
  end
data/sys/fpx.rb ADDED
@@ -0,0 +1,116 @@
1
+ =begin
2
+
3
+ fpx.rb
4
+
5
+ aos flie proxy.
6
+
7
+ by i2097i
8
+
9
+ =end
10
+
11
+ require :"rack/cors".to_s
12
+ require :sinatra.to_s
13
+
14
+ module Aos
15
+ module Fpx
16
+ def self.read_you(you_name)
17
+ url = URI.parse(File.join(Aos::Fpx::Server::URL, :"you/#{you_name}".to_s))
18
+ req = Net::HTTP::Get.new(url.to_s)
19
+ res = Net::HTTP.start(url.host, url.port) {|http|
20
+ http.request(req)
21
+ }
22
+ res.body
23
+ end
24
+
25
+ class Server < Sinatra::Base
26
+ PORT = 7474
27
+ HOST = :localhost
28
+ # no ssl for now
29
+ URL = :"http://#{Aos::Fpx::Server::HOST}:#{Aos::Fpx::Server::PORT}/".to_s
30
+ TIMEOUT = Aro::Mancy::NUMERALS[:VI] * Aro::Mancy::NUMERALS[:X]
31
+
32
+ def self.serve_pid_file
33
+ return "" if Aro::Dom.dom_root.nil? || Aro::Dom.room_path(:abot).nil?
34
+ File.join(Aro::Dom.dom_root, Aro::Dom.room_path(:flie), "fpx.pid")
35
+ end
36
+
37
+ # def self.log_file
38
+ # File.new(
39
+ # File.join(
40
+ # Aro::Dom.dom_root,
41
+ # Aro::Dom.room_path(:flie),
42
+ # "fpx.log"
43
+ # ),
44
+ # "a+"
45
+ # )
46
+ # end
47
+
48
+ def self.start
49
+ return if File.exist?(Aos::Fpx::Server.serve_pid_file)
50
+
51
+ serve_pid = fork {Aos::Fpx::Server.run!}
52
+ Process.detach(serve_pid)
53
+ File.open(Aos::Fpx::Server.serve_pid_file, "w") do |f|
54
+ f.write(serve_pid)
55
+ end
56
+ end
57
+
58
+ def self.stop
59
+ if File.exist?(Aos::Fpx::Server.serve_pid_file)
60
+ system("kill -9 #{File.read(Aos::Fpx::Server.serve_pid_file)}")
61
+ FileUtils.rm(Aos::Fpx::Server.serve_pid_file)
62
+ end
63
+ end
64
+
65
+ set :port, Aos::Fpx::Server::PORT
66
+ # set :bind, "0.0.0.0"
67
+ set :server_settings, timeout: Aos::Fpx::Server::TIMEOUT
68
+
69
+ # configure do
70
+ # enable :logging
71
+ # file = Aos::Fpx::Server.log_file
72
+ # file.sync = true
73
+ # use Rack::CommonLogger, file
74
+ # set :logging, Logger::DEBUG
75
+ # end
76
+
77
+ # after do
78
+ # ActiveRecord::Base.clear_active_connections!
79
+ # end
80
+
81
+ use Rack::Cors do |config|
82
+ config.allow do |allow|
83
+ allow.origins Aos::Fpx::Server::HOST.to_s + ":3000"
84
+ allow.resource "*"
85
+ # allow.resource "/file/list_all/", :headers => :any
86
+ # allow.resource "/file/at/*",
87
+ # :methods => [:get, :post, :put, :delete],
88
+ # :headers => :any,
89
+ # :max_age => 0
90
+ end
91
+ end
92
+
93
+ get "/" do
94
+ status 200
95
+ "".to_json
96
+ end
97
+
98
+ get "/you/:name" do
99
+ Aos::Db.load
100
+ you = Aos::You.find_by(name: params[:name])
101
+ content_type :json
102
+ if you.nil?
103
+ status 404
104
+ "".to_json
105
+ else
106
+ status 200
107
+ you.fpx.to_json
108
+ end
109
+ end
110
+
111
+ not_found do
112
+ redirect "/"
113
+ end
114
+ end
115
+ end
116
+ end