syntropy 0.33.0 → 0.34.1

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 (115) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +11 -0
  3. data/cmd/console.rb +18 -7
  4. data/cmd/serve.rb +26 -18
  5. data/cmd/test.rb +37 -24
  6. data/examples/blog/.gitignore +1 -0
  7. data/examples/blog/app/_layout/default.rb +3 -0
  8. data/examples/blog/app/_lib/database.rb +13 -0
  9. data/examples/blog/app/_lib/{post_store.rb → posts.rb} +3 -1
  10. data/examples/blog/app/assets/style.css +20 -0
  11. data/examples/blog/app/index.rb +12 -2
  12. data/examples/blog/app/posts/[id]/edit.rb +2 -2
  13. data/examples/blog/app/posts/[id]/index.rb +4 -4
  14. data/examples/blog/app/posts/index.rb +4 -4
  15. data/examples/blog/app/posts/new.rb +1 -1
  16. data/examples/blog/app/test.rb +7 -0
  17. data/examples/blog/config/development.rb +5 -0
  18. data/examples/blog/config/production.rb +4 -0
  19. data/examples/blog/config/test.rb +5 -0
  20. data/examples/blog/test/test_posts.rb +65 -0
  21. data/examples/mcp-oauth/app/oauth/token.rb +1 -1
  22. data/examples/template/.gitignore +2 -0
  23. data/examples/template/Gemfile +3 -0
  24. data/examples/template/app/_layout/default.rb +14 -0
  25. data/examples/template/app/_lib/database.rb +13 -0
  26. data/examples/template/app/_schema/2026-01-01-initial.rb +9 -0
  27. data/examples/template/app/assets/style.css +25 -0
  28. data/examples/template/app/index.rb +27 -0
  29. data/examples/template/app/test.rb +7 -0
  30. data/examples/template/config/development.rb +5 -0
  31. data/examples/template/config/production.rb +4 -0
  32. data/examples/template/config/test.rb +5 -0
  33. data/examples/template/test/test_app.rb +14 -0
  34. data/lib/syntropy/app.rb +48 -40
  35. data/lib/syntropy/applets/builtin/auto_refresh/watch.sse.rb +1 -1
  36. data/lib/syntropy/applets/builtin/default_error_handler/style.css +4 -8
  37. data/lib/syntropy/applets/builtin/default_error_handler.rb +18 -9
  38. data/lib/syntropy/db/schema.rb +1 -1
  39. data/lib/syntropy/db/store.rb +2 -0
  40. data/lib/syntropy/errors.rb +6 -2
  41. data/lib/syntropy/http/client.rb +1 -0
  42. data/lib/syntropy/http/server_connection.rb +0 -4
  43. data/lib/syntropy/json_api.rb +27 -1
  44. data/lib/syntropy/logger.rb +81 -27
  45. data/lib/syntropy/markdown.rb +61 -32
  46. data/lib/syntropy/mime_types.rb +9 -5
  47. data/lib/syntropy/module_loader.rb +31 -9
  48. data/lib/syntropy/papercraft_extensions.rb +2 -2
  49. data/lib/syntropy/request/mock_adapter.rb +10 -8
  50. data/lib/syntropy/request/request_info.rb +91 -0
  51. data/lib/syntropy/request/response.rb +1 -12
  52. data/lib/syntropy/request/validation.rb +1 -0
  53. data/lib/syntropy/request.rb +51 -19
  54. data/lib/syntropy/routing_tree.rb +27 -28
  55. data/lib/syntropy/session.rb +198 -0
  56. data/lib/syntropy/side_run.rb +25 -2
  57. data/lib/syntropy/test.rb +105 -10
  58. data/lib/syntropy/utils.rb +53 -18
  59. data/lib/syntropy/version.rb +1 -1
  60. data/lib/syntropy.rb +44 -10
  61. data/test/bm_router_proc.rb +4 -4
  62. data/test/fixtures/app/class_instance.rb +5 -0
  63. data/test/fixtures/app/http.rb +5 -0
  64. data/test/fixtures/app/post_ct.rb +5 -0
  65. data/test/fixtures/app/singleton.rb +3 -0
  66. data/test/test_app.rb +13 -52
  67. data/test/test_caching.rb +2 -2
  68. data/test/test_db_schema.rb +1 -1
  69. data/test/test_http_server_connection.rb +3 -3
  70. data/test/test_module_loader.rb +5 -2
  71. data/test/test_response.rb +0 -19
  72. data/test/test_routing_tree.rb +69 -69
  73. data/test/test_server.rb +5 -9
  74. data/test/test_test.rb +70 -0
  75. metadata +66 -42
  76. data/examples/blog/app/_setup.rb +0 -4
  77. data/lib/syntropy/request/session.rb +0 -113
  78. /data/test/{app → fixtures/app}/.well-known/foo.rb +0 -0
  79. /data/test/{app → fixtures/app}/_hook.rb +0 -0
  80. /data/test/{app → fixtures/app}/_layout/default.rb +0 -0
  81. /data/test/{app → fixtures/app}/_lib/callable.rb +0 -0
  82. /data/test/{app → fixtures/app}/_lib/dep.rb +0 -0
  83. /data/test/{app → fixtures/app}/_lib/env.rb +0 -0
  84. /data/test/{app → fixtures/app}/_lib/klass.rb +0 -0
  85. /data/test/{app → fixtures/app}/_lib/missing-export.rb +0 -0
  86. /data/test/{app → fixtures/app}/_lib/self.rb +0 -0
  87. /data/test/{app → fixtures/app}/about/_error.rb +0 -0
  88. /data/test/{app → fixtures/app}/about/foo.md +0 -0
  89. /data/test/{app → fixtures/app}/about/index.rb +0 -0
  90. /data/test/{app → fixtures/app}/about/raise.rb +0 -0
  91. /data/test/{app → fixtures/app}/api+.rb +0 -0
  92. /data/test/{app → fixtures/app}/assets/style.css +0 -0
  93. /data/test/{app → fixtures/app}/bad_mod.rb +0 -0
  94. /data/test/{app → fixtures/app}/bar.rb +0 -0
  95. /data/test/{app → fixtures/app}/baz.rb +0 -0
  96. /data/test/{app → fixtures/app}/by_method.rb +0 -0
  97. /data/test/{app → fixtures/app}/deps.rb +0 -0
  98. /data/test/{app → fixtures/app}/index.html +0 -0
  99. /data/test/{app → fixtures/app}/mod/bar/index+.rb +0 -0
  100. /data/test/{app → fixtures/app}/mod/foo/index.rb +0 -0
  101. /data/test/{app → fixtures/app}/mod/path/a.rb +0 -0
  102. /data/test/{app → fixtures/app}/mod/path/b.rb +0 -0
  103. /data/test/{app → fixtures/app}/params/[foo].rb +0 -0
  104. /data/test/{app → fixtures/app}/rss.rb +0 -0
  105. /data/test/{app → fixtures/app}/tmp.rb +0 -0
  106. /data/test/{app_custom → fixtures/app_custom}/_site.rb +0 -0
  107. /data/test/{app_multi_site → fixtures/app_multi_site}/_site.rb +0 -0
  108. /data/test/{app_multi_site → fixtures/app_multi_site}/bar.baz/index.html +0 -0
  109. /data/test/{app_multi_site → fixtures/app_multi_site}/foo.bar/index.html +0 -0
  110. /data/test/{app_setup → fixtures/app_setup}/_setup.rb +0 -0
  111. /data/test/{app_setup → fixtures/app_setup}/index.rb +0 -0
  112. /data/test/{app_with_schema → fixtures/app_with_schema}/_schema/2026-01-02-foo.rb +0 -0
  113. /data/test/{app_with_schema → fixtures/app_with_schema}/_schema/2026-05-30-bar.rb +0 -0
  114. /data/test/{schema → fixtures/schema}/2026-01-02-foo.rb +0 -0
  115. /data/test/{schema → fixtures/schema}/2026-05-30-bar.rb +0 -0
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: syntropy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.33.0
4
+ version: 0.34.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sharon Rosner
@@ -204,15 +204,22 @@ files:
204
204
  - examples/basic/favicon.ico
205
205
  - examples/basic/index.md
206
206
  - examples/basic/templates.rb
207
+ - examples/blog/.gitignore
207
208
  - examples/blog/app/_layout/default.rb
208
- - examples/blog/app/_lib/post_store.rb
209
+ - examples/blog/app/_lib/database.rb
210
+ - examples/blog/app/_lib/posts.rb
209
211
  - examples/blog/app/_schema/2026-01-01-initial.rb
210
- - examples/blog/app/_setup.rb
212
+ - examples/blog/app/assets/style.css
211
213
  - examples/blog/app/index.rb
212
214
  - examples/blog/app/posts/[id]/edit.rb
213
215
  - examples/blog/app/posts/[id]/index.rb
214
216
  - examples/blog/app/posts/index.rb
215
217
  - examples/blog/app/posts/new.rb
218
+ - examples/blog/app/test.rb
219
+ - examples/blog/config/development.rb
220
+ - examples/blog/config/production.rb
221
+ - examples/blog/config/test.rb
222
+ - examples/blog/test/test_posts.rb
216
223
  - examples/mcp-oauth/.ruby-version
217
224
  - examples/mcp-oauth/Gemfile
218
225
  - examples/mcp-oauth/README.md
@@ -228,6 +235,18 @@ files:
228
235
  - examples/mcp-oauth/app/signin.rb
229
236
  - examples/mcp-oauth/test/test_app.rb
230
237
  - examples/mcp-oauth/test/test_oauth.rb
238
+ - examples/template/.gitignore
239
+ - examples/template/Gemfile
240
+ - examples/template/app/_layout/default.rb
241
+ - examples/template/app/_lib/database.rb
242
+ - examples/template/app/_schema/2026-01-01-initial.rb
243
+ - examples/template/app/assets/style.css
244
+ - examples/template/app/index.rb
245
+ - examples/template/app/test.rb
246
+ - examples/template/config/development.rb
247
+ - examples/template/config/production.rb
248
+ - examples/template/config/test.rb
249
+ - examples/template/test/test_app.rb
231
250
  - lib/syntropy.rb
232
251
  - lib/syntropy/app.rb
233
252
  - lib/syntropy/applets/builtin/auto_refresh/watch.js
@@ -261,56 +280,60 @@ files:
261
280
  - lib/syntropy/request/mock_adapter.rb
262
281
  - lib/syntropy/request/request_info.rb
263
282
  - lib/syntropy/request/response.rb
264
- - lib/syntropy/request/session.rb
265
283
  - lib/syntropy/request/validation.rb
266
284
  - lib/syntropy/routing_tree.rb
285
+ - lib/syntropy/session.rb
267
286
  - lib/syntropy/side_run.rb
268
287
  - lib/syntropy/test.rb
269
288
  - lib/syntropy/utils.rb
270
289
  - lib/syntropy/version.rb
271
290
  - syntropy.gemspec
272
- - test/app/.well-known/foo.rb
273
- - test/app/_hook.rb
274
- - test/app/_layout/default.rb
275
- - test/app/_lib/callable.rb
276
- - test/app/_lib/dep.rb
277
- - test/app/_lib/env.rb
278
- - test/app/_lib/klass.rb
279
- - test/app/_lib/missing-export.rb
280
- - test/app/_lib/self.rb
281
- - test/app/about/_error.rb
282
- - test/app/about/foo.md
283
- - test/app/about/index.rb
284
- - test/app/about/raise.rb
285
- - test/app/api+.rb
286
- - test/app/assets/style.css
287
- - test/app/bad_mod.rb
288
- - test/app/bar.rb
289
- - test/app/baz.rb
290
- - test/app/by_method.rb
291
- - test/app/deps.rb
292
- - test/app/index.html
293
- - test/app/mod/bar/index+.rb
294
- - test/app/mod/foo/index.rb
295
- - test/app/mod/path/a.rb
296
- - test/app/mod/path/b.rb
297
- - test/app/params/[foo].rb
298
- - test/app/rss.rb
299
- - test/app/tmp.rb
300
- - test/app_custom/_site.rb
301
- - test/app_multi_site/_site.rb
302
- - test/app_multi_site/bar.baz/index.html
303
- - test/app_multi_site/foo.bar/index.html
304
- - test/app_setup/_setup.rb
305
- - test/app_setup/index.rb
306
- - test/app_with_schema/_schema/2026-01-02-foo.rb
307
- - test/app_with_schema/_schema/2026-05-30-bar.rb
308
291
  - test/bm_router_proc.rb
309
292
  - test/bm_server.rb
293
+ - test/fixtures/app/.well-known/foo.rb
294
+ - test/fixtures/app/_hook.rb
295
+ - test/fixtures/app/_layout/default.rb
296
+ - test/fixtures/app/_lib/callable.rb
297
+ - test/fixtures/app/_lib/dep.rb
298
+ - test/fixtures/app/_lib/env.rb
299
+ - test/fixtures/app/_lib/klass.rb
300
+ - test/fixtures/app/_lib/missing-export.rb
301
+ - test/fixtures/app/_lib/self.rb
302
+ - test/fixtures/app/about/_error.rb
303
+ - test/fixtures/app/about/foo.md
304
+ - test/fixtures/app/about/index.rb
305
+ - test/fixtures/app/about/raise.rb
306
+ - test/fixtures/app/api+.rb
307
+ - test/fixtures/app/assets/style.css
308
+ - test/fixtures/app/bad_mod.rb
309
+ - test/fixtures/app/bar.rb
310
+ - test/fixtures/app/baz.rb
311
+ - test/fixtures/app/by_method.rb
312
+ - test/fixtures/app/class_instance.rb
313
+ - test/fixtures/app/deps.rb
314
+ - test/fixtures/app/http.rb
315
+ - test/fixtures/app/index.html
316
+ - test/fixtures/app/mod/bar/index+.rb
317
+ - test/fixtures/app/mod/foo/index.rb
318
+ - test/fixtures/app/mod/path/a.rb
319
+ - test/fixtures/app/mod/path/b.rb
320
+ - test/fixtures/app/params/[foo].rb
321
+ - test/fixtures/app/post_ct.rb
322
+ - test/fixtures/app/rss.rb
323
+ - test/fixtures/app/singleton.rb
324
+ - test/fixtures/app/tmp.rb
325
+ - test/fixtures/app_custom/_site.rb
326
+ - test/fixtures/app_multi_site/_site.rb
327
+ - test/fixtures/app_multi_site/bar.baz/index.html
328
+ - test/fixtures/app_multi_site/foo.bar/index.html
329
+ - test/fixtures/app_setup/_setup.rb
330
+ - test/fixtures/app_setup/index.rb
331
+ - test/fixtures/app_with_schema/_schema/2026-01-02-foo.rb
332
+ - test/fixtures/app_with_schema/_schema/2026-05-30-bar.rb
333
+ - test/fixtures/schema/2026-01-02-foo.rb
334
+ - test/fixtures/schema/2026-05-30-bar.rb
310
335
  - test/helper.rb
311
336
  - test/run.rb
312
- - test/schema/2026-01-02-foo.rb
313
- - test/schema/2026-05-30-bar.rb
314
337
  - test/test_app.rb
315
338
  - test/test_caching.rb
316
339
  - test/test_db_connection_pool.rb
@@ -330,6 +353,7 @@ files:
330
353
  - test/test_routing_tree.rb
331
354
  - test/test_server.rb
332
355
  - test/test_side_run.rb
356
+ - test/test_test.rb
333
357
  homepage: https://github.com/digital-fabric/syntropy
334
358
  licenses:
335
359
  - MIT
@@ -1,4 +0,0 @@
1
- @app.setup_db(
2
- db_path: File.join(@app.root_dir, '../blog.db'),
3
- schema_root: '_schema'
4
- )
@@ -1,113 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'base64'
4
- require 'json'
5
- require 'securerandom'
6
-
7
- module Syntropy
8
- class Session
9
- def initialize(request)
10
- @request = request
11
- @data = nil
12
- end
13
-
14
- def [](key)
15
- @data ||= load
16
- @data[key]
17
- end
18
-
19
- def []=(key, value)
20
- @data ||= load
21
- @data[key] = value
22
- save(@data)
23
- end
24
-
25
- def delete(key)
26
- @data ||= load
27
- @data.delete(key)
28
- save(@data.empty? ? nil : @data)
29
- end
30
-
31
- def discard
32
- save(nil)
33
- end
34
-
35
- def flash
36
- @data ||= load
37
- @flash ||= Flash.new(self)
38
- end
39
-
40
- private
41
-
42
- class NowFlash
43
- def initialize
44
- @data = {}
45
- end
46
-
47
- def [](key)
48
- @data[key.to_s]
49
- end
50
-
51
- def []=(key, value)
52
- @data[key.to_s] = value
53
- end
54
-
55
- def each(&block)
56
- @data.each { |k, v| block.(k.to_sym, v) }
57
- end
58
- end
59
-
60
- class Flash
61
- def initialize(session)
62
- @session = session
63
- @current_flash_data = @session['_flash']
64
- @session.delete('_flash') if @current_flash_data
65
- @current_flash_data ||= {}
66
- @future_flash_data = {}
67
- @now_flash_data = NowFlash.new
68
- end
69
-
70
- def [](key)
71
- key = key.to_s
72
- @now_flash_data[key] || @current_flash_data[key]
73
- end
74
-
75
- def []=(key, value)
76
- key = key.to_s
77
- @future_flash_data[key] = value
78
- @session['_flash'] = @future_flash_data
79
- end
80
-
81
- def each(&block)
82
- @now_flash_data.each { |k, v| block.(k.to_sym, v) }
83
- @current_flash_data.each_pair { |k, v| block.(k.to_sym, v) }
84
- end
85
-
86
- def keep
87
- @future_flash_data = @current_flash_data.merge!(@future_flash_data)
88
- @session['_flash'] = @future_flash_data
89
- end
90
-
91
- def now
92
- @now_flash_data
93
- end
94
- end
95
-
96
- # Loads session data from
97
- def load
98
- data = @request.cookies['__syntropy_session__']
99
- return {} if !data
100
-
101
- JSON.parse(Base64.decode64(data))
102
- rescue JSON::ParserError
103
- {}
104
- ensure
105
- @loaded = true
106
- end
107
-
108
- def save(data)
109
- cookie = data ? "#{Base64.strict_encode64(JSON.dump(data))}; Path=/; HttpOnly" : nil
110
- @request.set_cookie('__syntropy_session__', cookie)
111
- end
112
- end
113
- end
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes