syntropy 0.27 → 0.27.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: b84251781cfce3688f58c6f25a754b0699d97fe4a7c51f390b63635b45007960
4
- data.tar.gz: 69e85137dcee6b399d3198303f9de4227b5276521a6c964eca5ac4954a9fb10f
3
+ metadata.gz: e80e6b84e9a27a66ceea390152e0a5f78e1e9f09faa2e05f2cf3d3633524d859
4
+ data.tar.gz: 6df75f9834f47adb3cbb2d72d7c725c3630f7d2d90deef7d4667e108a812b572
5
5
  SHA512:
6
- metadata.gz: dd871276c35cd2a9c216f37ec1361794e34f489af71580a1da5cebef244830daf0e2bc4e418abe28623607e8da5693ead8074dd1f397ba9ea61afb0e4bcf7d96
7
- data.tar.gz: 2b3ae1c3c4691d247357a8ec3d9f7e3da778c0fcdd7a94de84b2d83c94ffe75c7beb7ec7883976c2ca09b5c45225391b9322e28a32be9cc3a55acfc6d8c5ac9e
6
+ metadata.gz: 7b244f6672e0cb10456c7723a7f991566a7d31de4ea3072fe498a13901eebaab558dd7914e12de85f0262e08080a51959c742ef1b7149be7f13d75be56259555
7
+ data.tar.gz: 64824cf03670ab6ff06e12c639011dfe67a3b0d0e32d18daad5aa23df24e8dfaafb2d01e2dced957f7493fdf6dc6fbb0f040959d3ab6c2bc2abea55a0bf0fd7d
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ # 0.27.2 2025-10-21
2
+
3
+ - Add `Module#collection_module!` method
4
+
5
+ # 0.27.1 2025-10-21
6
+
7
+ - Fix error instantiation and error testing
8
+
1
9
  # 0.27 2025-10-21
2
10
 
3
11
  - Use accept header (instead of user-agent) for rendering error page
@@ -56,7 +56,7 @@ module Syntropy
56
56
  # ValidationError is raised when a validation has failed.
57
57
  class ValidationError < Error
58
58
  def initialize(msg)
59
- super(Qeweney::Status::BAD_REQUEST, msg)
59
+ super(msg, Qeweney::Status::BAD_REQUEST)
60
60
  end
61
61
  end
62
62
  end
@@ -53,9 +53,8 @@ module Syntropy
53
53
  # @return [void]
54
54
  def invalidate_fn(fn)
55
55
  ref = @fn_map[fn]
56
- return if !ref
57
-
58
- invalidate_ref(ref)
56
+ invalidate_ref(ref) if ref
57
+ invalidate_collection_modules
59
58
  end
60
59
 
61
60
  private
@@ -75,6 +74,14 @@ module Syntropy
75
74
  entry[:reverse_deps].each { invalidate_ref(it) }
76
75
  end
77
76
 
77
+ def invalidate_collection_modules
78
+ refs = []
79
+ @modules.each do |ref, entry|
80
+ refs << ref if entry[:module].is_collection_module?
81
+ end
82
+ refs.each { invalidate_ref(it) }
83
+ end
84
+
78
85
  # Registers reverse dependencies for the given module reference.
79
86
  #
80
87
  # @param ref [String] module reference
@@ -102,12 +109,13 @@ module Syntropy
102
109
  @fn_map[fn] = ref
103
110
  code = IO.read(fn)
104
111
  env = @env.merge(module_loader: self, ref: clean_ref(ref))
105
- m = Syntropy::Module.load(env, code, fn)
106
- add_dependencies(ref, m.__dependencies__)
107
- export_value = transform_module_export_value(m.__export_value__)
112
+ mod = Syntropy::Module.load(env, code, fn)
113
+ add_dependencies(ref, mod.__dependencies__)
114
+ export_value = transform_module_export_value(mod.__export_value__)
108
115
 
109
116
  {
110
117
  fn: fn,
118
+ module: mod,
111
119
  export_value: export_value,
112
120
  reverse_deps: []
113
121
  }
@@ -195,6 +203,14 @@ module Syntropy
195
203
  Syntropy.page_list(@env, ref)
196
204
  end
197
205
 
206
+ # Returns true if the module is a collection module. See also
207
+ # #collection_module!
208
+ #
209
+ # @return [bool]
210
+ def is_collection_module?
211
+ @collection_module_p
212
+ end
213
+
198
214
  private
199
215
 
200
216
  # Exports the given value. This value will be used as the module's
@@ -217,6 +233,16 @@ module Syntropy
217
233
  @module_loader.load(ref).tap { __dependencies__ << ref }
218
234
  end
219
235
 
236
+ # Marks module as a collection module. This will cause the module to be
237
+ # invalidated on every file change in dev mode, regardless if it is a
238
+ # dependency.
239
+ #
240
+ # @return [self]
241
+ def collection_module!
242
+ @collection_module_p = true
243
+ self
244
+ end
245
+
220
246
  def normalize_import_ref(ref)
221
247
  base = @ref == '' ? '/' : @ref
222
248
  if ref =~ /^\//
@@ -177,12 +177,12 @@ module Syntropy
177
177
  def get_form_data
178
178
  body = read
179
179
  if !body || body.empty?
180
- raise Syntropy::Error.new(Qeweney::Status::BAD_REQUEST, 'Missing form data')
180
+ raise Syntropy::Error.new('Missing form data', Qeweney::Status::BAD_REQUEST)
181
181
  end
182
182
 
183
183
  Qeweney::Request.parse_form_data(body, headers)
184
184
  rescue Qeweney::BadRequestError
185
- raise Syntropy::Error.new(Qeweney::Status::BAD_REQUEST, 'Invalid form data')
185
+ raise Syntropy::Error.new('Invalid form data', Qeweney::Status::BAD_REQUEST)
186
186
  end
187
187
 
188
188
  def html_response(html, **headers)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Syntropy
4
- VERSION = '0.27'
4
+ VERSION = '0.27.2'
5
5
  end
data/test/app/api+.rb CHANGED
@@ -10,7 +10,7 @@ class API < Syntropy::JSONAPI
10
10
 
11
11
  def incr!(req)
12
12
  if req.path != '/test/api'
13
- raise Syntropy::Error.new(Qeweney::Status::TEAPOT, 'Teapot')
13
+ raise Syntropy::Error.new('Teapot', Qeweney::Status::TEAPOT)
14
14
  end
15
15
 
16
16
  @count += 1
data/test/test_app.rb CHANGED
@@ -50,7 +50,7 @@ class AppTest < Minitest::Test
50
50
 
51
51
  req = make_request(':method' => 'POST', ':path' => '/test')
52
52
  assert_equal Status::METHOD_NOT_ALLOWED, req.response_status
53
- assert_nil req.response_body
53
+ assert_equal "Method not allowed", req.response_body
54
54
 
55
55
  req = make_request(':method' => 'GET', ':path' => '/test/assets/style.css')
56
56
  assert_equal '* { color: beige }', req.response_body
@@ -64,7 +64,7 @@ class AppTest < Minitest::Test
64
64
 
65
65
  req = make_request(':method' => 'POST', ':path' => '/test/api?q=get')
66
66
  assert_equal Status::METHOD_NOT_ALLOWED, req.response_status
67
- assert_equal({ status: 'Error', message: '' }, req.response_json)
67
+ assert_equal({ status: 'Error', message: 'Method not allowed' }, req.response_json)
68
68
 
69
69
  req = make_request(':method' => 'GET', ':path' => '/test/api/foo?q=get')
70
70
  assert_equal({ status: 'OK', response: 0 }, req.response_json)
@@ -74,7 +74,7 @@ class AppTest < Minitest::Test
74
74
 
75
75
  req = make_request(':method' => 'GET', ':path' => '/test/api?q=incr')
76
76
  assert_equal Status::METHOD_NOT_ALLOWED, req.response_status
77
- assert_equal({ status: 'Error', message: '' }, req.response_json)
77
+ assert_equal({ status: 'Error', message: 'Method not allowed' }, req.response_json)
78
78
 
79
79
  req = make_request(':method' => 'POST', ':path' => '/test/api/foo?q=incr')
80
80
  assert_equal({ status: 'Error', message: 'Teapot' }, req.response_json)
@@ -97,7 +97,7 @@ class AppTest < Minitest::Test
97
97
  assert_equal Status::OK, req.response_status
98
98
 
99
99
  req = make_request(':method' => 'POST', ':path' => '/test/baz')
100
- assert_nil req.response_body
100
+ assert_equal 'Method not allowed', req.response_body
101
101
  assert_equal Status::METHOD_NOT_ALLOWED, req.response_status
102
102
 
103
103
  req = make_request(':method' => 'GET', ':path' => '/test/about')
data/test/test_errors.rb CHANGED
@@ -12,7 +12,7 @@ class ErrorsTest < Minitest::Test
12
12
  e = Syntropy::Error.new
13
13
  assert_equal ISE, Syntropy::Error.http_status(e)
14
14
 
15
- e = Syntropy::Error.new(Qeweney::Status::UNAUTHORIZED)
15
+ e = Syntropy::Error.new("", Qeweney::Status::UNAUTHORIZED)
16
16
  assert_equal Qeweney::Status::UNAUTHORIZED, Syntropy::Error.http_status(e)
17
17
  end
18
18
 
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.27'
4
+ version: 0.27.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sharon Rosner