syntropy 0.8.2 → 0.8.4

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: 76abcde175da96ee8d1617b13d3fc02cb87b3f825adb63a7ed272cdb03c7663a
4
- data.tar.gz: 46735e1a209c90bd1c9bcea7c81b02e93bee5b21a57502ed63032eb559d2e9d7
3
+ metadata.gz: 45abad590f75c9decf1a8b087af2e43fc78dbf1a18e9b33d364e7a215dcc7ac2
4
+ data.tar.gz: ae887f37aa7357c6a60a764bbbb651f99ecf70782628417b10816d96de6e325b
5
5
  SHA512:
6
- metadata.gz: 35ba5001a3cefc35fb50361ec781613bbe3c4c282ebcb4cccfdf3bc86053fe0d40b4effe9b87a4045a9cab80702baf861de3f32b199216a78d2d323bd30c06c8
7
- data.tar.gz: f8f5a47a1abd7adf7463121e282c51c30a7adf47c7141a0d0d72baaf225996d78a8fbb3a8597f2d0a1dc876eeb63f2857214b5a16361ce8a41da7c298ee75871
6
+ metadata.gz: 5eaad0914071bc82b5f223360fd7c40a1756c312653575571cab89fff1dd2c28fa2b695e6e3bed12eb5be640927d803da2e95c767ae4b3528b545475fab56932
7
+ data.tar.gz: 5b4d4ec5eb419e9bbe891a47f02886b98dc9d1855d4a5dba1bfe6b540a1d3e62a03ae1fa7efce454e168e0122897bd0ba472a7f12fb592e5b190693a5317748b
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## 0.8.4 2025-07-07
2
+
3
+ - Update TP2
4
+ - Fix Router#path_parent to not break on double slash
5
+
6
+ ## 0.8.3 2025-07-06
7
+
8
+ - Correctly handle HEAD requests for template modules
9
+
1
10
  ## 0.8.2 2025-07-06
2
11
 
3
12
  - Update deps
data/TODO.md CHANGED
@@ -1,3 +1,14 @@
1
+ - add support for applets
2
+
3
+ - can be implemented as separate gems
4
+ - can route requests to a different directory (i.e. inside the gem directory)
5
+ - simple way to instantiate and setup the applet
6
+ - as a first example, implement an auth/signin applet:
7
+ - session hook
8
+ - session persistence
9
+ - login page
10
+ - support for custom behaviour and custom workflows (2FA, signin using OTP etc.)
11
+
1
12
  - Some standard middleware:
2
13
 
3
14
  - request rewriter
data/lib/syntropy/app.rb CHANGED
@@ -143,10 +143,13 @@ module Syntropy
143
143
  :invalid
144
144
  end
145
145
 
146
- def wrap_template(templ)
146
+ def wrap_template(template)
147
147
  lambda { |req|
148
- body = templ.render
149
- req.respond(body, 'Content-Type' => 'text/html')
148
+ headers = { 'Content-Type' => template.mime_type }
149
+ req.respond_by_http_method(
150
+ 'head' => [nil, headers],
151
+ 'get' => -> { [template.render, headers] }
152
+ )
150
153
  }
151
154
  end
152
155
 
@@ -45,8 +45,9 @@ module Syntropy
45
45
  when nil
46
46
  raise 'No export found'
47
47
  when Symbol
48
+ o = mod_ctx.new(@env)
48
49
  # TODO: verify export_value denotes a valid method
49
- mod_ctx.new(@env)
50
+ ->(req) { o.send(export_value, req) }
50
51
  when String
51
52
  ->(req) { req.respond(export_value) }
52
53
  when Proc
@@ -84,7 +84,8 @@ module Syntropy
84
84
  def path_parent(path)
85
85
  return nil if path == '/'
86
86
 
87
- path.match(PATH_PARENT_RE)[1] || '/'
87
+ m = path.match(PATH_PARENT_RE)
88
+ m && (m[1] || '/')
88
89
  end
89
90
 
90
91
  MD_EXT_RE = /\.md$/
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Syntropy
4
- VERSION = '0.8.2'
4
+ VERSION = '0.8.4'
5
5
  end
data/syntropy.gemspec CHANGED
@@ -25,7 +25,7 @@ Gem::Specification.new do |s|
25
25
  s.add_dependency 'json', '2.12.2'
26
26
  s.add_dependency 'papercraft', '1.4'
27
27
  s.add_dependency 'qeweney', '0.21'
28
- s.add_dependency 'tp2', '0.13.3'
28
+ s.add_dependency 'tp2', '0.13.4'
29
29
  s.add_dependency 'uringmachine', '0.16'
30
30
 
31
31
  s.add_dependency 'listen', '3.9.0'
data/test/test_app.rb CHANGED
@@ -121,6 +121,9 @@ class AppTest < Minitest::Test
121
121
  req = make_request(':method' => 'GET', ':path' => '/test/about/foo')
122
122
  assert_equal '<p>Hello from Markdown</p>', req.response_body.chomp
123
123
 
124
+ req = make_request(':method' => 'HEAD', ':path' => '/test/about/foo')
125
+ assert_nil req.response_body
126
+
124
127
  req = make_request(':method' => 'GET', ':path' => '/test/about/foo/bar')
125
128
  assert_equal Status::NOT_FOUND, req.response_status
126
129
  end
data/test/test_module.rb CHANGED
@@ -19,10 +19,9 @@ class ModuleTest < Minitest::Test
19
19
  assert_raises(RuntimeError) { @loader.load('_lib/missing-export') }
20
20
 
21
21
  mod = @loader.load('_lib/callable')
22
- assert_kind_of Syntropy::Module, mod
22
+ assert_kind_of Proc, mod
23
23
  assert_equal 'barbarbar', mod.call(3)
24
24
  assert_raises(NoMethodError) { mod.foo(2) }
25
- assert_equal 42, mod.bar
26
25
 
27
26
  mod = @loader.load('_lib/klass')
28
27
  assert_equal :bar, mod.foo
data/test/test_router.rb CHANGED
@@ -24,7 +24,7 @@ class RouterTest < Minitest::Test
24
24
  File.join(APP_ROOT, fn)
25
25
  end
26
26
 
27
- def test_find_route
27
+ def test_routing
28
28
  # entry = @router['/']
29
29
  # assert_equal :not_found, entry[:kind]
30
30
 
@@ -50,6 +50,9 @@ class RouterTest < Minitest::Test
50
50
  assert_equal :module, entry[:kind]
51
51
  assert_equal full_path('api+.rb'), entry[:fn]
52
52
 
53
+ entry = @router['/test/api//foo/bar']
54
+ assert_equal :not_found, entry[:kind]
55
+
53
56
  entry = @router['/test/api/foo/../bar']
54
57
  assert_equal :not_found, entry[:kind]
55
58
 
@@ -87,4 +90,27 @@ class RouterTest < Minitest::Test
87
90
  ensure
88
91
  IO.write(@tmp_fn, orig_body) if orig_body
89
92
  end
93
+
94
+ def test_malformed_path_routing
95
+ entry = @router['//xmlrpc.php?rsd']
96
+ assert_equal :not_found, entry[:kind]
97
+
98
+ entry = @router['/test//xmlrpc.php?rsd']
99
+ assert_equal :not_found, entry[:kind]
100
+
101
+ entry = @router['/test///xmlrpc.php?rsd']
102
+ assert_equal :not_found, entry[:kind]
103
+
104
+ entry = @router['/test///xmlrpc.php?rsd']
105
+ assert_equal :not_found, entry[:kind]
106
+
107
+ entry = @router['/test/./qsdf']
108
+ assert_equal :not_found, entry[:kind]
109
+
110
+ entry = @router['/test/../../lib/syntropy.rb']
111
+ assert_equal :not_found, entry[:kind]
112
+
113
+ entry = @router['/../../lib/syntropy.rb']
114
+ assert_equal :not_found, entry[:kind]
115
+ end
90
116
  end
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.8.2
4
+ version: 0.8.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sharon Rosner
@@ -71,14 +71,14 @@ dependencies:
71
71
  requirements:
72
72
  - - '='
73
73
  - !ruby/object:Gem::Version
74
- version: 0.13.3
74
+ version: 0.13.4
75
75
  type: :runtime
76
76
  prerelease: false
77
77
  version_requirements: !ruby/object:Gem::Requirement
78
78
  requirements:
79
79
  - - '='
80
80
  - !ruby/object:Gem::Version
81
- version: 0.13.3
81
+ version: 0.13.4
82
82
  - !ruby/object:Gem::Dependency
83
83
  name: uringmachine
84
84
  requirement: !ruby/object:Gem::Requirement