cuba 4.0.0 → 4.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7d1132f58ee467460030f12c618ab68ec947bb83d8b20df22588475d37e95994
4
- data.tar.gz: 7e73fb3214fa781d9a5564d780d3a0a4e6e32ba1833ce55e286ab62b75002b04
3
+ metadata.gz: fdca6a9e01b7f7981cd430ed976c9d0822739895340549150e4d719196e059c0
4
+ data.tar.gz: 206b7ea5088509c073f6d69f9c72e07c066b0b043483d1ecd2b292e5a9dd9f2e
5
5
  SHA512:
6
- metadata.gz: 046baecf8b875441123af6279840efa324757e9579324e5accc5f39b5d5f1df01be38c07af2e08c164f2a55e611c7653282239bbc3fd558feb6290a658c46eb1
7
- data.tar.gz: b2812bc154953daa7e84972d1380aaaf68612e3f7162389315932404614e625a0a002ab21ba13c76c77727694a6b4696810206927a7798c600cce0aff70fa3c2
6
+ metadata.gz: 36cd6bcfa37d6ab1c50b4235243143117be5de74cfa3d7a065c4434c2c4fd1bd064fd46df2f13d4578427d61c6ceda769566bd26152214787a7357779780f6f5
7
+ data.tar.gz: 64e6ce940c7f8004b88535cb6b8c938da8e0be6ccce33e544843fd97029bccb7763f9ded60860d2299c5632bc825cd7d688585ad37e7449bf42183cbc232f183
data/.gems CHANGED
@@ -1,5 +1,5 @@
1
1
  cutest -v 1.2.3
2
- tilt -v 2.0.10
3
- rack -v 3.0.2
2
+ tilt -v 2.1.0
3
+ rack -v 3.0.4.1
4
4
  rack-test -v 2.0.2
5
- rack-session -v 0.3.0
5
+ rack-session -v 2.0.0
data/CHANGELOG CHANGED
@@ -1,10 +1,14 @@
1
+ 4.0.3
2
+
3
+ * Change secure headers to lowercase.
4
+
1
5
  3.9.0
2
6
 
3
- * Cache regular expressions
7
+ * Cache regular expressions.
4
8
 
5
9
  3.8.1
6
10
 
7
- * Remove requirement on Time
11
+ * Remove requirement on Time.
8
12
 
9
13
  3.8.0
10
14
 
@@ -64,4 +68,4 @@
64
68
  * Remove Cuba::VERSION.
65
69
  * Rename _call to call! (inspired from Sinatra).
66
70
  * Fix a memory leak with the caching used in Tilt.
67
- * Adding syntax highlighting to the README Code blocks
71
+ * Adding syntax highlighting to the README Code blocks.
data/cuba.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "cuba"
3
- s.version = "4.0.0"
3
+ s.version = "4.0.3"
4
4
  s.summary = "Microframework for web applications."
5
5
  s.description = "Cuba is a microframework for web applications."
6
6
  s.authors = ["Michel Martens"]
@@ -11,6 +11,7 @@ Gem::Specification.new do |s|
11
11
  s.files = `git ls-files`.split("\n")
12
12
 
13
13
  s.add_dependency "rack", ">= 3.0.0"
14
+ s.add_dependency "rack-session", ">= 2.0.0"
14
15
  s.add_development_dependency "cutest"
15
16
  s.add_development_dependency "rack-test"
16
17
  s.add_development_dependency "tilt"
data/lib/cuba/render.rb CHANGED
@@ -13,7 +13,7 @@ class Cuba
13
13
  end
14
14
 
15
15
  def render(template, locals = {}, layout = settings[:render][:layout])
16
- res.headers["Content-Type"] ||= "text/html; charset=utf-8"
16
+ res.headers[Rack::CONTENT_TYPE] ||= "text/html; charset=utf-8"
17
17
  res.write(view(template, locals, layout))
18
18
  end
19
19
 
@@ -10,6 +10,8 @@
10
10
  # - X-Download-Options [6].
11
11
  # - X-Permitted-Cross-Domain-Policies [7].
12
12
  #
13
+ # Due to HTTP/2 specifications and Rack specifications, field names are applied in all lowercase.
14
+ #
13
15
  # == References
14
16
  #
15
17
  # [1]: https://github.com/twitter/secureheaders
@@ -19,17 +21,18 @@
19
21
  # [5]: http://msdn.microsoft.com/en-us/library/ie/gg622941(v=vs.85).aspx
20
22
  # [6]: http://msdn.microsoft.com/en-us/library/ie/jj542450(v=vs.85).aspx
21
23
  # [7]: https://www.adobe.com/devnet/adobe-media-server/articles/cross-domain-xml-for-streaming.html
24
+ # [8]: https://datatracker.ietf.org/doc/html/rfc9113#name-http-fields
22
25
  #
23
26
  class Cuba
24
27
  module Safe
25
28
  module SecureHeaders
26
29
  HEADERS = {
27
- "X-Content-Type-Options" => "nosniff",
28
- "X-Download-Options" => "noopen",
29
- "X-Frame-Options" => "SAMEORIGIN",
30
- "X-Permitted-Cross-Domain-Policies" => "none",
31
- "X-XSS-Protection" => "1; mode=block",
32
- "Strict-Transport-Security" => "max-age=2628000"
30
+ "x-content-type-options" => "nosniff",
31
+ "x-download-options" => "noopen",
32
+ "x-frame-options" => "SAMEORIGIN",
33
+ "x-permitted-cross-domain-policies" => "none",
34
+ "x-xss-protection" => "1; mode=block",
35
+ "strict-transport-security" => "max-age=2628000"
33
36
  }
34
37
 
35
38
  def self.setup(app)
data/lib/cuba.rb CHANGED
@@ -10,7 +10,7 @@ class Cuba
10
10
  REGEXES = Hash.new { |h, pattern| h[pattern] = /\A\/(#{pattern})(\/|\z)/ }
11
11
 
12
12
  class Response
13
- LOCATION = "Location".freeze
13
+ LOCATION = "location".freeze
14
14
 
15
15
  module ContentType
16
16
  HTML = "text/html".freeze # :nodoc:
@@ -91,8 +91,8 @@ class Cuba
91
91
  @app ||= Rack::Builder.new
92
92
  end
93
93
 
94
- def self.use(middleware, *args, &block)
95
- app.use(middleware, *args, &block)
94
+ def self.use(middleware, *args, **kwargs, &block)
95
+ app.use(middleware, *args, **kwargs, &block)
96
96
  end
97
97
 
98
98
  def self.define(&block)
data/test/middleware.rb CHANGED
@@ -1,8 +1,9 @@
1
1
  require File.expand_path("helper", File.dirname(__FILE__))
2
2
 
3
3
  class Shrimp
4
- def initialize(app)
4
+ def initialize(app, foo:)
5
5
  @app = app
6
+ @foo = foo
6
7
  end
7
8
 
8
9
  def call(env)
@@ -17,7 +18,7 @@ end
17
18
 
18
19
  test do
19
20
  class API < Cuba
20
- use Shrimp
21
+ use Shrimp, foo: 'bar'
21
22
 
22
23
  define do
23
24
  on "v1/test" do
data/test/redirect.rb CHANGED
@@ -16,6 +16,6 @@ test "redirect" do
16
16
  status, headers, body = Cuba.call(env)
17
17
 
18
18
  assert_equal status, 302
19
- assert_equal headers, { "Location" => "/hello" }
19
+ assert_equal headers, { "location" => "/hello" }
20
20
  assert_response body, []
21
21
  end
data/test/render.rb CHANGED
@@ -124,5 +124,5 @@ test "ensures content-type header is set" do
124
124
 
125
125
  _, headers, _ = Cuba.call({})
126
126
 
127
- assert_equal("text/html; charset=utf-8", headers["Content-Type"])
127
+ assert_equal("text/html; charset=utf-8", headers["content-type"])
128
128
  end
data/test/run.rb CHANGED
@@ -17,7 +17,7 @@ test "redirect canonical example" do
17
17
 
18
18
  status, headers, resp = Cuba.call(env)
19
19
 
20
- assert_equal "/login", headers["Location"]
20
+ assert_equal "/login", headers["location"]
21
21
  assert_equal 307, status
22
22
  assert_response resp, []
23
23
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cuba
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0
4
+ version: 4.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michel Martens
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-02-16 00:00:00.000000000 Z
11
+ date: 2024-01-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 3.0.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: rack-session
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 2.0.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 2.0.0
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: cutest
29
43
  requirement: !ruby/object:Gem::Requirement