aromancer 0.0.1 → 0.0.2

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: 679dfbd1cfcb2efaae7fab06fa1018d44ce4884f1bee0f994f69305e5438e126
4
- data.tar.gz: 582e34ec3c8af5f0ea64a60a576c1c343cb0eaac464f2af263e527c97749452c
3
+ metadata.gz: 66d69a666530ce5120cfb52365a583212e69a1917754dbf7aff7191f83342bb1
4
+ data.tar.gz: 18ecd2a9cbc8e0f9495cc2234ff4d1b7dff033820f8c889942b45886a3a2bc85
5
5
  SHA512:
6
- metadata.gz: 6d132065b282b92f774b6ce1cc8def08abfb8fe775d03f0ce3be1594b70fc913acadde9af7475f4c697e04757b1586118d1142c55de9228cf77e4e351f99da39
7
- data.tar.gz: 3f7058b2d39db6eebe39ac84b7a3fa4521ca22c20a88e159c80be22c2bd737315c722c5436dda181e72b5779a5df57e5ade0542164eef91cf8088758f28414b0
6
+ metadata.gz: d0946a20e0158ede2f6eae9ddd589916948e934a1a258903e6ea6be853c7cee1b5a9b53d415dbb14a30d16c1519961842beb202eee6ec75bac634d54155c83ce
7
+ data.tar.gz: 3eb1d8a77285e530272c700a83278dd41328f7661c02f870430abbdeb78a66fa27b0f117fa892510962d09236bf7f45ad77cba6ee3283d0ec86154b58d4d6c5f
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --require aromancer
2
+ --require spec_helper
data/.ruby-version ADDED
@@ -0,0 +1,2 @@
1
+ 4.0.7
2
+
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ plugin 'bundler-graph'
2
+ source :"https://rubygems.org".to_s
3
+ gemspec
4
+
5
+ # do not modify
6
+ # add dependencies to the gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,224 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ aromancer (0.0.2)
5
+ activesupport (~> 8.1.4)
6
+ faraday (~> 2.14.4)
7
+ fileutils (~> 1.8.0)
8
+ i18n (~> 1.15.2)
9
+ tty-cursor (~> 0.7.1)
10
+ tty-font (~> 0.5.0)
11
+ tty-prompt (~> 0.23.1)
12
+ tty-screen (~> 0.8.2)
13
+ tty-table (~> 0.12.0)
14
+
15
+ GEM
16
+ remote: https://rubygems.org/
17
+ specs:
18
+ activesupport (8.1.4)
19
+ base64
20
+ bigdecimal
21
+ concurrent-ruby (~> 1.0, >= 1.3.1)
22
+ connection_pool (>= 2.2.5)
23
+ drb
24
+ i18n (>= 1.6, < 2)
25
+ json
26
+ logger (>= 1.4.2)
27
+ minitest (>= 5.1)
28
+ securerandom (>= 0.3)
29
+ tzinfo (~> 2.0, >= 2.0.5)
30
+ uri (>= 0.13.1)
31
+ base64 (0.3.0)
32
+ bigdecimal (4.1.3)
33
+ concurrent-ruby (1.3.8)
34
+ connection_pool (3.0.2)
35
+ diff-lcs (1.6.2)
36
+ drb (2.2.3)
37
+ erb (6.0.7)
38
+ faraday (2.14.4)
39
+ faraday-net_http (>= 2.0, < 3.5)
40
+ json
41
+ logger
42
+ faraday-net_http (3.4.4)
43
+ net-http (~> 0.5)
44
+ ffi (1.17.4)
45
+ ffi (1.17.4-aarch64-linux-gnu)
46
+ ffi (1.17.4-aarch64-linux-musl)
47
+ ffi (1.17.4-arm-linux-gnu)
48
+ ffi (1.17.4-arm-linux-musl)
49
+ ffi (1.17.4-arm64-darwin)
50
+ ffi (1.17.4-x86-linux-gnu)
51
+ ffi (1.17.4-x86-linux-musl)
52
+ ffi (1.17.4-x86_64-darwin)
53
+ ffi (1.17.4-x86_64-linux-gnu)
54
+ ffi (1.17.4-x86_64-linux-musl)
55
+ fileutils (1.8.0)
56
+ i18n (1.15.2)
57
+ concurrent-ruby (~> 1.0)
58
+ io-console (0.9.4)
59
+ irb (1.18.0)
60
+ pp (>= 0.6.0)
61
+ prism (>= 1.3.0)
62
+ rdoc (>= 4.0.0)
63
+ reline (>= 0.4.2)
64
+ json (3.0.2)
65
+ listen (3.10.0)
66
+ logger
67
+ rb-fsevent (~> 0.10, >= 0.10.3)
68
+ rb-inotify (~> 0.9, >= 0.9.10)
69
+ logger (1.7.0)
70
+ minitest (6.0.6)
71
+ drb (~> 2.0)
72
+ prism (~> 1.5)
73
+ net-http (0.9.1)
74
+ uri (>= 0.11.1)
75
+ pastel (0.8.0)
76
+ tty-color (~> 0.5)
77
+ pp (0.6.4)
78
+ prettyprint
79
+ prettyprint (0.2.0)
80
+ prism (1.9.0)
81
+ rake (13.4.2)
82
+ rb-fsevent (0.11.2)
83
+ rb-inotify (0.11.1)
84
+ ffi (~> 1.0)
85
+ rbs (4.2.0)
86
+ logger
87
+ prism (>= 1.6.0)
88
+ tsort
89
+ rdoc (8.0.0)
90
+ erb
91
+ prism (>= 1.6.0)
92
+ rbs (>= 4.0.0)
93
+ tsort
94
+ reline (0.7.0)
95
+ io-console (~> 0.5)
96
+ rspec (3.13.2)
97
+ rspec-core (~> 3.13.0)
98
+ rspec-expectations (~> 3.13.0)
99
+ rspec-mocks (~> 3.13.0)
100
+ rspec-core (3.13.6)
101
+ rspec-support (~> 3.13.0)
102
+ rspec-expectations (3.13.5)
103
+ diff-lcs (>= 1.2.0, < 2.0)
104
+ rspec-support (~> 3.13.0)
105
+ rspec-mocks (3.13.8)
106
+ diff-lcs (>= 1.2.0, < 2.0)
107
+ rspec-support (~> 3.13.0)
108
+ rspec-support (3.13.7)
109
+ securerandom (0.4.1)
110
+ strings (0.2.1)
111
+ strings-ansi (~> 0.2)
112
+ unicode-display_width (>= 1.5, < 3.0)
113
+ unicode_utils (~> 1.4)
114
+ strings-ansi (0.2.0)
115
+ tsort (0.2.0)
116
+ tty-color (0.6.0)
117
+ tty-cursor (0.7.1)
118
+ tty-font (0.5.0)
119
+ tty-prompt (0.23.1)
120
+ pastel (~> 0.8)
121
+ tty-reader (~> 0.8)
122
+ tty-reader (0.9.0)
123
+ tty-cursor (~> 0.7)
124
+ tty-screen (~> 0.8)
125
+ wisper (~> 2.0)
126
+ tty-screen (0.8.2)
127
+ tty-table (0.12.0)
128
+ pastel (~> 0.8)
129
+ strings (~> 0.2.0)
130
+ tty-screen (~> 0.8)
131
+ tzinfo (2.0.6)
132
+ concurrent-ruby (~> 1.0)
133
+ unicode-display_width (2.6.0)
134
+ unicode_utils (1.4.0)
135
+ uri (1.1.1)
136
+ wisper (2.0.1)
137
+
138
+ PLATFORMS
139
+ aarch64-linux-gnu
140
+ aarch64-linux-musl
141
+ arm-linux-gnu
142
+ arm-linux-musl
143
+ arm64-darwin
144
+ x86-linux-gnu
145
+ x86-linux-musl
146
+ x86_64-darwin
147
+ x86_64-linux-gnu
148
+ x86_64-linux-musl
149
+
150
+ DEPENDENCIES
151
+ aromancer!
152
+ bundler (~> 4.0.21)
153
+ irb (~> 1.18)
154
+ listen (~> 3.10)
155
+ rake (~> 13.4.2)
156
+ rspec (~> 3.13.2)
157
+
158
+ CHECKSUMS
159
+ activesupport (8.1.4) sha256=891dd3fe43c4fc8391934b237b1189bb1f661c932a84a840043db9d46a4e80df
160
+ aromancer (0.0.2)
161
+ base64 (0.3.0) sha256=27337aeabad6ffae05c265c450490628ef3ebd4b67be58257393227588f5a97b
162
+ bigdecimal (4.1.3) sha256=61ebe1e5e559bdc3cc6f2c0ee7f427321fc838f59611c294356eb04d6e21cf66
163
+ bundler (4.0.21) sha256=7cbf5499b426076aa16c8d28a59e4c2c3aad5a438402abcd961f0119f29f1dd0
164
+ concurrent-ruby (1.3.8) sha256=b2f1be836e968ccc78ccfce277ea79c72a88633f22306782c16ff23fb415d1e1
165
+ connection_pool (3.0.2) sha256=33fff5ba71a12d2aa26cb72b1db8bba2a1a01823559fb01d29eb74c286e62e0a
166
+ diff-lcs (1.6.2) sha256=9ae0d2cba7d4df3075fe8cd8602a8604993efc0dfa934cff568969efb1909962
167
+ drb (2.2.3) sha256=0b00d6fdb50995fe4a45dea13663493c841112e4068656854646f418fda13373
168
+ erb (6.0.7) sha256=c5ca6dc25b0ef974a44dc8f59fe847577122483b1968a38dec305c60bf91ee92
169
+ faraday (2.14.4) sha256=9bb4408c44621b0dbaaaa39e5dbfc4dbe58cc6751b6eb94d16ae9e1f2f2fab6e
170
+ faraday-net_http (3.4.4) sha256=0e78af151747ed1b00f33e25973b4bc220d7f16c00c39676817c8b12331eb588
171
+ ffi (1.17.4) sha256=bcd1642e06f0d16fc9e09ac6d49c3a7298b9789bcb58127302f934e437d60acf
172
+ ffi (1.17.4-aarch64-linux-gnu) sha256=b208f06f91ffd8f5e1193da3cae3d2ccfc27fc36fba577baf698d26d91c080df
173
+ ffi (1.17.4-aarch64-linux-musl) sha256=9286b7a615f2676245283aef0a0a3b475ae3aae2bb5448baace630bb77b91f39
174
+ ffi (1.17.4-arm-linux-gnu) sha256=d6dbddf7cb77bf955411af5f187a65b8cd378cb003c15c05697f5feee1cb1564
175
+ ffi (1.17.4-arm-linux-musl) sha256=9d4838ded0465bef6e2426935f6bcc93134b6616785a84ffd2a3d82bc3cf6f95
176
+ ffi (1.17.4-arm64-darwin) sha256=19071aaf1419251b0a46852abf960e77330a3b334d13a4ab51d58b31a937001b
177
+ ffi (1.17.4-x86-linux-gnu) sha256=38e150df5f4ca555e25beca4090823ae09657bceded154e3c52f8631c1ed72cf
178
+ ffi (1.17.4-x86-linux-musl) sha256=fbeec0fc7c795bcf86f623bb18d31ea1820f7bd580e1703a3d3740d527437809
179
+ ffi (1.17.4-x86_64-darwin) sha256=aa70390523cf3235096cf64962b709b4cfbd5c082a2cb2ae714eb0fe2ccda496
180
+ ffi (1.17.4-x86_64-linux-gnu) sha256=9d3db14c2eae074b382fa9c083fe95aec6e0a1451da249eab096c34002bc752d
181
+ ffi (1.17.4-x86_64-linux-musl) sha256=3fdf9888483de005f8ef8d1cf2d3b20d86626af206cbf780f6a6a12439a9c49e
182
+ fileutils (1.8.0) sha256=8c6b1df54e2540bdb2f39258f08af78853aa70bad52b4d394bbc6424593c6e02
183
+ i18n (1.15.2) sha256=00f9eb62412fe593b2a65a97daa75300d37abb8f7202ec748e94b6d46a9dd1b5
184
+ io-console (0.9.4) sha256=a403304f32928ee85e56d457b4612ca43f2703b561a3258844992bd24085fbb1
185
+ irb (1.18.0) sha256=de9454a0703a54704b9811a5ef31a60c86949fbf4013fcf244fabc7c775248e3
186
+ json (3.0.2) sha256=8e6d7e7b11384c21230430cef90b71f14849a34a1f4452796670f7c981bd19df
187
+ listen (3.10.0) sha256=c6e182db62143aeccc2e1960033bebe7445309c7272061979bb098d03760c9d2
188
+ logger (1.7.0) sha256=196edec7cc44b66cfb40f9755ce11b392f21f7967696af15d274dde7edff0203
189
+ minitest (6.0.6) sha256=153ea36d1d987a62942382b61075745042a2b3123b1cd48f4c3675af9cc7d6f1
190
+ net-http (0.9.1) sha256=25ba0b67c63e89df626ed8fac771d0ad24ad151a858af2cc8e6a716ca4336996
191
+ pastel (0.8.0) sha256=481da9fb7d2f6e6b1a08faf11fa10363172dc40fd47848f096ae21209f805a75
192
+ pp (0.6.4) sha256=dfcb0fce700c41456265922884f9fe195d7fbb0674a3578e6c0f69588e82b570
193
+ prettyprint (0.2.0) sha256=2bc9e15581a94742064a3cc8b0fb9d45aae3d03a1baa6ef80922627a0766f193
194
+ prism (1.9.0) sha256=7b530c6a9f92c24300014919c9dcbc055bf4cdf51ec30aed099b06cd6674ef85
195
+ rake (13.4.2) sha256=cb825b2bd5f1f8e91ca37bddb4b9aaf345551b4731da62949be002fa89283701
196
+ rb-fsevent (0.11.2) sha256=43900b972e7301d6570f64b850a5aa67833ee7d87b458ee92805d56b7318aefe
197
+ rb-inotify (0.11.1) sha256=a0a700441239b0ff18eb65e3866236cd78613d6b9f78fea1f9ac47a85e47be6e
198
+ rbs (4.2.0) sha256=51f7b886dcc05bc09e10b901daa6a81829f6adc03101d6ca9ea4aac6103e0674
199
+ rdoc (8.0.0) sha256=03bf8c08a9639658855a0cfd77c0abca8325c227693f7f33f82957811348c469
200
+ reline (0.7.0) sha256=5b012d8e55dbf9d450f12bde2cf7d15ff546ae80b3f8f3b30e570d431815583d
201
+ rspec (3.13.2) sha256=206284a08ad798e61f86d7ca3e376718d52c0bc944626b2349266f239f820587
202
+ rspec-core (3.13.6) sha256=a8823c6411667b60a8bca135364351dda34cd55e44ff94c4be4633b37d828b2d
203
+ rspec-expectations (3.13.5) sha256=33a4d3a1d95060aea4c94e9f237030a8f9eae5615e9bd85718fe3a09e4b58836
204
+ rspec-mocks (3.13.8) sha256=086ad3d3d17533f4237643de0b5c42f04b66348c28bf6b9c2d3f4a3b01af1d47
205
+ rspec-support (3.13.7) sha256=0640e5570872aafefd79867901deeeeb40b0c9875a36b983d85f54fb7381c47c
206
+ securerandom (0.4.1) sha256=cc5193d414a4341b6e225f0cb4446aceca8e50d5e1888743fac16987638ea0b1
207
+ strings (0.2.1) sha256=933293b3c95cf85b81eb44b3cf673e3087661ba739bbadfeadf442083158d6fb
208
+ strings-ansi (0.2.0) sha256=90262d760ea4a94cc2ae8d58205277a343409c288cbe7c29416b1826bd511c88
209
+ tsort (0.2.0) sha256=9650a793f6859a43b6641671278f79cfead60ac714148aabe4e3f0060480089f
210
+ tty-color (0.6.0) sha256=6f9c37ca3a4e2367fb2e6d09722762647d6f455c111f05b59f35730eeb24332a
211
+ tty-cursor (0.7.1) sha256=79534185e6a777888d88628b14b6a1fdf5154a603f285f80b1753e1908e0bf48
212
+ tty-font (0.5.0) sha256=495ee588701be4abaf03da8b14382794003cb2d836127b02c78cda18aaf451e2
213
+ tty-prompt (0.23.1) sha256=fcdbce905238993f27eecfdf67597a636bc839d92192f6a0eef22b8166449ec8
214
+ tty-reader (0.9.0) sha256=c62972c985c0b1566f0e56743b6a7882f979d3dc32ff491ed490a076f899c2b1
215
+ tty-screen (0.8.2) sha256=c090652115beae764336c28802d633f204fb84da93c6a968aa5d8e319e819b50
216
+ tty-table (0.12.0) sha256=fdc27a4750835c1a16efe19a0b857e3ced3652cc7aceafe6dca94908965b9939
217
+ tzinfo (2.0.6) sha256=8daf828cc77bcf7d63b0e3bdb6caa47e2272dcfaf4fbfe46f8c3a9df087a829b
218
+ unicode-display_width (2.6.0) sha256=12279874bba6d5e4d2728cef814b19197dbb10d7a7837a869bab65da943b7f5a
219
+ unicode_utils (1.4.0) sha256=b922d0cf2313b6b7136ada6645ce7154ffc86418ca07d53b058efe9eb72f2a40
220
+ uri (1.1.1) sha256=379fa58d27ffb1387eaada68c749d1426738bd0f654d812fcc07e7568f5c57c6
221
+ wisper (2.0.1) sha256=ce17bc5c3a166f241a2e6613848b025c8146fce2defba505920c1d1f3f88fae6
222
+
223
+ BUNDLED WITH
224
+ 4.0.21
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 i2097i
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/Rakefile CHANGED
@@ -1,4 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "bundler/gem_tasks"
4
- task default: %i[]
4
+
5
+ task :default => :rspec
6
+
7
+ Rake.add_rakelib :"tasks".to_s
data/aromancer.gemspec ADDED
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ =begin
4
+
5
+ aromancer.gemspec
6
+
7
+ aromancer gem specification.
8
+
9
+ by i2097i
10
+
11
+ =end
12
+
13
+ require_relative "lib/aromancer/version"
14
+
15
+ Gem::Specification.new do |spec|
16
+ spec.name = "aromancer"
17
+ spec.version = Aromancer::VERSION
18
+ spec.authors = ["i2097i"]
19
+ spec.email = ["i2097i@hotmail.com"]
20
+
21
+ spec.description = ""
22
+ spec.summary = ""
23
+ spec.homepage = "https://github.com/i2097i/aromancer"
24
+ spec.license = "MIT"
25
+ spec.files = `git ls-files`.split("\n").reject{|p| p.match?(/^(spec|.release|.*.gem$)/)}
26
+ spec.bindir = "bin"
27
+ spec.executables = ["aromancer"]
28
+ spec.require_paths = ["lib", "db"]
29
+ spec.required_ruby_version = ">= 4.0.7"
30
+
31
+ # development gems
32
+ spec.add_development_dependency "irb", "~> 1.18"
33
+ spec.add_development_dependency "bundler", "~> 4.0.21"
34
+ spec.add_development_dependency "listen", "~> 3.10"
35
+ spec.add_development_dependency "rake", "~> 13.4.2"
36
+ spec.add_development_dependency "rspec", "~> 3.13.2"
37
+
38
+ # runtime gems
39
+ spec.add_runtime_dependency "activesupport", "~> 8.1.4"
40
+ spec.add_runtime_dependency "i18n", "~> 1.15.2"
41
+ spec.add_runtime_dependency "faraday", "~> 2.14.4"
42
+ spec.add_runtime_dependency "fileutils", "~> 1.8.0"
43
+ # spec.add_runtime_dependency "websocket-client-simple", "~> 0.9.0"
44
+
45
+ # spec.add_runtime_dependency "tty-box", "~> 0.7.0"
46
+ # spec.add_runtime_dependency "tty-color", "~> 0.6.0"
47
+ spec.add_runtime_dependency "tty-cursor", "~> 0.7.1"
48
+ spec.add_runtime_dependency "tty-font", "~> 0.5.0"
49
+ spec.add_runtime_dependency "tty-table", "~> 0.12.0"
50
+ spec.add_runtime_dependency "tty-prompt", "~> 0.23.1"
51
+ # spec.add_runtime_dependency "tty-reader", "~> 0.9.0"
52
+ spec.add_runtime_dependency "tty-screen", "~> 0.8.2"
53
+ end
data/bin/aromancer ADDED
@@ -0,0 +1,25 @@
1
+ #! /usr/bin/env ruby
2
+
3
+ =begin
4
+
5
+ aromancer
6
+
7
+ entry point for aromancer.
8
+
9
+ by i2097i
10
+
11
+ =end
12
+
13
+ require :aromancer.to_s
14
+
15
+ begin
16
+ Aromancer::Prompt.say(I18n.t("shared.welcome", version: Aromancer::VERSION))
17
+ if Aromancer::Storage.get_player
18
+ Aromancer::Routes.main_menu
19
+ else
20
+ Aromancer::Routes.authentication
21
+ end
22
+ rescue Interrupt => e
23
+ exit
24
+ end
25
+
@@ -0,0 +1 @@
1
+ 25f5172d741b178cda9b2388d4fc404c00cf472b2418677f0b44532b6f178cc53807606b685f1298e3c8627e1eb1f3cb732c4f19ffe47df6f550e2fee4c64ebb
data/gem_graph.png ADDED
Binary file
Binary file
@@ -0,0 +1,193 @@
1
+ # frozen_string_literal: true
2
+
3
+ =begin
4
+
5
+ api.rb
6
+
7
+ aromancer api.
8
+
9
+ by i2097i
10
+
11
+ =end
12
+
13
+ module Aromancer
14
+ class Api
15
+
16
+ DATE_FORMAT = "%A %d %b %Y %I:%M:%S %p"
17
+
18
+ def self.storage_headers(result)
19
+ result.kind_of?(Aromancer::Server::InternalError) ? nil : result.headers
20
+ end
21
+
22
+ def self.register_error(response)
23
+ Aromancer::Storage.set_last_error({
24
+ status: response.status,
25
+ headers: storage_headers(response),
26
+ body: response.body.to_s[0..444]
27
+ })
28
+
29
+ signed_out = false
30
+ signed_out = response.status == 401
31
+ error_body = nil
32
+ begin
33
+ error_body = JSON.parse(response.body)
34
+ rescue StandardError => e
35
+ end
36
+
37
+ signed_out = signed_out &&
38
+ !error_body.nil? &&
39
+ error_body.keys.include?(:error_message.to_s) &&
40
+ error_body["error_message"] == "not signed in"
41
+ Aromancer::Storage.set_signed_out_flag(signed_out)
42
+ end
43
+
44
+ def self.sign_in
45
+ email_address = nil
46
+ password = nil
47
+ while email_address.nil? || email_address.blank?
48
+ email_address = Aromancer::Prompt.p.ask("enter email address:")
49
+ end
50
+
51
+ while password.nil? || password.blank?
52
+ password = Aromancer::Prompt.p.mask("enter password:")
53
+ end
54
+
55
+ result = Aromancer::Server.sign_in(email_address, password)
56
+ if result.status == 201
57
+ response = JSON.parse(result.body)
58
+ Aromancer::Storage.set_player(response)
59
+ else
60
+ Aromancer::Storage.set_player(nil)
61
+ register_error(result)
62
+ end
63
+ end
64
+
65
+ def self.sign_up
66
+ email_address = nil
67
+ password = nil
68
+ password_confirmation = nil
69
+ while email_address.nil? || email_address.blank?
70
+ email_address = Aromancer::Prompt.p.ask("enter email address:")
71
+ end
72
+
73
+ while password.nil? || password.blank?
74
+ password = Aromancer::Prompt.p.mask("enter password:")
75
+ end
76
+
77
+ while password_confirmation.nil? || password_confirmation.blank?
78
+ password_confirmation = Aromancer::Prompt.p.mask("confirm password:")
79
+ end
80
+
81
+ result = Aromancer::Server.sign_up(email_address, password, password_confirmation)
82
+ if result.status == 201
83
+ response = JSON.parse(result.body)
84
+ Aromancer::Storage.set_player(response)
85
+ else
86
+ Aromancer::Storage.set_player(nil)
87
+ register_error(result)
88
+ end
89
+ end
90
+
91
+ def self.sign_out
92
+ result = Aromancer::Server.sign_out
93
+ # clear storage
94
+ Aromancer::Storage.set_player(nil)
95
+ Aromancer::Storage.set_last_error(nil)
96
+ FileUtils.rm_rf(Aromancer::Storage.storage_filepath)
97
+
98
+ register_error(result) if result.status != 200
99
+ end
100
+
101
+ DEFAULT_LEGEND_PARAMS = {
102
+ status: :created,
103
+ player_count: 1,
104
+ story_count: 1
105
+ }
106
+
107
+ def self.create_legend(params = Aromancer::Api::DEFAULT_LEGEND_PARAMS)
108
+ result = Aromancer::Server.create_legend({legend: params})
109
+ if result.status == 201
110
+ response = JSON.parse(result.body)
111
+ set_active_legend_id(response["id"])
112
+ else
113
+ register_error(result)
114
+ end
115
+ end
116
+
117
+ def self.get_legends
118
+ result = Aromancer::Server.get_legends
119
+ if result.status == 200
120
+ response = JSON.parse(result.body)
121
+ Aromancer::Storage.set_legends(response)
122
+ else
123
+ Aromancer::Storage.set_legends([])
124
+ register_error(result)
125
+ end
126
+ end
127
+
128
+ def self.set_active_legend_id(active_legend_id)
129
+ result = Aromancer::Server.update_player({player: {active_legend_id: active_legend_id, status: active_legend_id.nil? ? :lobby : :playing}})
130
+ if result.status == 200
131
+ response = JSON.parse(result.body)
132
+ Aromancer::Storage.set_player(response)
133
+ else
134
+ register_error(result)
135
+ end
136
+ end
137
+
138
+ def self.load_arena
139
+ result = Aromancer::Server.get_arena
140
+ if result.status == 200
141
+ response = JSON.parse(result.body)
142
+ Aromancer::Storage.set_arena(response)
143
+ else
144
+ Aromancer::Storage.set_arena(nil)
145
+ register_error(result)
146
+ end
147
+ end
148
+
149
+ def self.load_stream
150
+ result = Aromancer::Server.get_stream
151
+
152
+ if result.status == 200
153
+ response = JSON.parse(result.body)
154
+
155
+ Aromancer::Storage.set_stream(response)
156
+ else
157
+ Aromancer::Storage.set_stream(nil)
158
+ register_error(result)
159
+ end
160
+ end
161
+
162
+ def self.load_word_possibilities(selected_word_id)
163
+ result = Aromancer::Server.get_word_possibilities(selected_word_id)
164
+ if result.status == 200
165
+ return JSON.parse(result.body)
166
+ else
167
+ register_error(result)
168
+ end
169
+ end
170
+
171
+ def self.create_turn(arena_params)
172
+ result = Aromancer::Server.create_turn({arena: arena_params})
173
+ if result.status == 201
174
+ response = JSON.parse(result.body)
175
+ load_arena
176
+ else
177
+ register_error(result)
178
+ end
179
+ end
180
+
181
+ def self.update_turn(arena_params)
182
+ result = Aromancer::Server.update_turn({arena: arena_params})
183
+ if result.status == 200
184
+ response = JSON.parse(result.body)
185
+ load_arena
186
+ else
187
+ register_error(result)
188
+ end
189
+ end
190
+
191
+ end
192
+
193
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ =begin
4
+
5
+ prompt.rb
6
+
7
+ tty-prompt gem wrapper.
8
+
9
+ by i2097i
10
+
11
+ =end
12
+
13
+ module Aromancer
14
+ class Prompt
15
+ include Singleton
16
+
17
+ attr_accessor :prompt
18
+
19
+ def initialize
20
+ self.prompt = TTY::Prompt.new
21
+ end
22
+
23
+ def self.p
24
+ Aromancer::Prompt.instance.prompt
25
+ end
26
+
27
+ def self.say(message)
28
+ (message.kind_of?(String) ? message.split("\n").each{|l| p.say(l.to_s.center(TTY::Screen.width))} : message)
29
+ end
30
+ end
31
+
32
+ end