jellyfish 1.4.0 → 1.5.0

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: a2ac4c1c5b9beff9266516aa120e637e7c1b3d09010e0f0cf0df7b8728e26646
4
- data.tar.gz: 8cd5fff611eea7b8fc454aa8a4d2a844225cf2904d6fcf46dacfc118f9090d84
3
+ metadata.gz: 628990b1c7e58bef69d30e9d58c735546643875b3e56c3c9bb3c6d3938bac6d5
4
+ data.tar.gz: 5e50afb6c489da13a22225b87c6e3a20f1215c4fda43150e5447845159649223
5
5
  SHA512:
6
- metadata.gz: 87587d0f02f1896aa15fb8b72daf2e1cd22b129a89f277680f56ada903778ff2d23c86765273a6199e97c85563e458225a8079bd97e660b4085103b548d99a78
7
- data.tar.gz: 35071bfc020d030e952c2023a3bfb7c8cdcf9723194bb8f70212e4cb01b0dc74105a9ccfd93e4c7921f94b37c10049e74e42322cc0532447b87c8e90ceacfd38
6
+ metadata.gz: 4ec7d867538663a72c11f796ff44e64aea12966a81d8b52ef992dfeb51cb79a30882145be143aef69762725cf98d3233337fe54ff6aa27fea00e6d2cb0417a0e
7
+ data.tar.gz: b9b09ec0ca7070536515eee34e6635183eb6909da7abdcf2e76450650476d11093b475303bda708e4f2059ce5298c012a157a2774c94ddb817ef2871a847a67a
data/.gitlab-ci.yml CHANGED
@@ -4,7 +4,7 @@ stages:
4
4
 
5
5
  .test:
6
6
  stage: test
7
- image: ruby:${RUBY_VERSION}-bullseye
7
+ image: ruby:${RUBY_VERSION}-trixie
8
8
  variables:
9
9
  GIT_DEPTH: "1"
10
10
  GIT_SUBMODULE_STRATEGY: recursive
@@ -17,23 +17,17 @@ stages:
17
17
  script:
18
18
  - ruby -vr bundler/setup -S rake test
19
19
 
20
- ruby:3.0:
20
+ ruby:3.4:
21
21
  extends:
22
22
  - .test
23
23
  variables:
24
- RUBY_VERSION: '3.0'
24
+ RUBY_VERSION: '3.4'
25
25
 
26
- ruby:3.1:
26
+ ruby:4.0:
27
27
  extends:
28
28
  - .test
29
29
  variables:
30
- RUBY_VERSION: '3.1'
31
-
32
- ruby:3.2:
33
- extends:
34
- - .test
35
- variables:
36
- RUBY_VERSION: '3.2'
30
+ RUBY_VERSION: '4.0'
37
31
 
38
32
  jruby:latest:
39
33
  extends:
data/CHANGES.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # CHANGES
2
2
 
3
+ ## Jellyfish 1.5.0 -- 2026-11-22
4
+
5
+ ### Incompatible changes
6
+
7
+ * Removed `redirect` which is an alias of `found`
8
+ * Response from `found` with HTTP 302 no longer adds any response body
9
+
10
+ ### Enhancements
11
+
12
+ * Added `moved` helper for HTTP 301
13
+ * Static responses are now memorized to avoid I/O
14
+
3
15
  ## Jellyfish 1.4.0 -- 2023-02-22
4
16
 
5
17
  ### Incompatible changes
data/Gemfile CHANGED
@@ -3,11 +3,15 @@ source 'https://rubygems.org'
3
3
 
4
4
  gemspec
5
5
 
6
+ gem 'base64' # stdlib
7
+
6
8
  gem 'rake'
7
9
  gem 'rack'
8
10
  gem 'pork'
9
11
  gem 'muack'
10
12
  gem 'websocket_parser'
11
13
 
12
- gem 'simplecov', :require => false if ENV['COV']
13
- gem 'coveralls', :require => false if ENV['CI']
14
+ platform :ruby do
15
+ gem 'simplecov', :require => false if ENV['COV']
16
+ gem 'coveralls', :require => false if ENV['CI']
17
+ end
data/README.md CHANGED
@@ -166,6 +166,8 @@ POST /
166
166
 
167
167
  ### Redirect helper
168
168
 
169
+ This uses HTTP 302
170
+
169
171
  ``` ruby
170
172
  require 'jellyfish'
171
173
  class Tank
@@ -181,13 +183,35 @@ run Tank.new
181
183
 
182
184
  <!---
183
185
  GET /lookup host
184
- body = File.read("#{File.dirname(
185
- File.expand_path(__FILE__))}/../lib/jellyfish/public/302.html").
186
- gsub('VAR_URL', 'http://host/')
187
186
  [302,
188
- {'content-length' => body.bytesize.to_s, 'content-type' => 'text/html',
187
+ {'content-length' => '0', 'content-type' => 'text/html',
189
188
  'location' => 'http://host/'},
190
- [body]]
189
+ []]
190
+ -->
191
+
192
+ ### Moved permanently
193
+
194
+ This uses HTTP 301
195
+
196
+ ``` ruby
197
+ require 'jellyfish'
198
+ class Tank
199
+ include Jellyfish
200
+ get '/lookup' do
201
+ moved "#{env['rack.url_scheme']}://#{env['HTTP_HOST']}/"
202
+ end
203
+ end
204
+ use Rack::ContentLength
205
+ use Rack::ContentType, 'text/plain'
206
+ run Tank.new
207
+ ```
208
+
209
+ <!---
210
+ GET /lookup host
211
+ [301,
212
+ {'content-length' => '0', 'content-type' => 'text/html',
213
+ 'location' => 'http://host/'},
214
+ []]
191
215
  -->
192
216
 
193
217
  ### Crash-proof
@@ -222,7 +246,7 @@ class Tank
222
246
  include Jellyfish
223
247
  handle NameError do |e|
224
248
  status 403
225
- "No one hears you: #{e.backtrace.first}\n"
249
+ "No one hears you: #{e.name}\n"
226
250
  end
227
251
  get '/yell' do
228
252
  yell
@@ -235,14 +259,7 @@ run Tank.new
235
259
 
236
260
  <!---
237
261
  GET /yell
238
- body = case RUBY_ENGINE
239
- when 'jruby'
240
- "No one hears you: (eval):9:in `block in Tank'\n"
241
- when 'rbx'
242
- "No one hears you: core/zed.rb:1370:in `yell (method_missing)'\n"
243
- else
244
- "No one hears you: (eval):9:in `block in <class:Tank>'\n"
245
- end
262
+ body = "No one hears you: yell\n"
246
263
  [403,
247
264
  {'content-length' => body.bytesize.to_s, 'content-type' => 'text/plain'},
248
265
  [body]]
@@ -1240,7 +1257,7 @@ HTTP
1240
1257
 
1241
1258
  Apache License 2.0 (Apache-2.0)
1242
1259
 
1243
- Copyright (c) 2012-2023, Lin Jen-Shin (godfat)
1260
+ Copyright (c) 2012-2026, Lin Jen-Shin (godfat)
1244
1261
 
1245
1262
  Licensed under the Apache License, Version 2.0 (the "License");
1246
1263
  you may not use this file except in compliance with the License.
data/jellyfish.gemspec CHANGED
@@ -1,14 +1,14 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: jellyfish 1.4.0 ruby lib
2
+ # stub: jellyfish 1.5.0 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "jellyfish".freeze
6
- s.version = "1.4.0"
6
+ s.version = "1.5.0".freeze
7
7
 
8
8
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
9
9
  s.require_paths = ["lib".freeze]
10
10
  s.authors = ["Lin Jen-Shin (godfat)".freeze]
11
- s.date = "2023-02-22"
11
+ s.date = "2026-11-22"
12
12
  s.description = "Pico web framework for building API-centric web applications.\nFor Rack applications or Rack middleware. Around 250 lines of code.\n\nCheck [jellyfish-contrib][] for extra extensions.\n\n[jellyfish-contrib]: https://github.com/godfat/jellyfish-contrib".freeze
13
13
  s.email = ["godfat (XD) godfat.org".freeze]
14
14
  s.files = [
@@ -30,7 +30,6 @@ Gem::Specification.new do |s|
30
30
  "lib/jellyfish/json.rb".freeze,
31
31
  "lib/jellyfish/normalized_params.rb".freeze,
32
32
  "lib/jellyfish/normalized_path.rb".freeze,
33
- "lib/jellyfish/public/302.html".freeze,
34
33
  "lib/jellyfish/public/404.html".freeze,
35
34
  "lib/jellyfish/public/500.html".freeze,
36
35
  "lib/jellyfish/rewrite.rb".freeze,
@@ -56,7 +55,7 @@ Gem::Specification.new do |s|
56
55
  "test/test_websocket.rb".freeze]
57
56
  s.homepage = "https://github.com/godfat/jellyfish".freeze
58
57
  s.licenses = ["Apache-2.0".freeze]
59
- s.rubygems_version = "3.4.3".freeze
58
+ s.rubygems_version = "4.1.0".freeze
60
59
  s.summary = "Pico web framework for building API-centric web applications.".freeze
61
60
  s.test_files = [
62
61
  "test/rack/test_builder.rb".freeze,
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Jellyfish
4
- VERSION = '1.4.0'
4
+ VERSION = '1.5.0'
5
5
  end
data/lib/jellyfish.rb CHANGED
@@ -11,16 +11,22 @@ module Jellyfish
11
11
  autoload :ChunkedBody, 'jellyfish/chunked_body'
12
12
  autoload :WebSocket , 'jellyfish/websocket'
13
13
 
14
- Cascade = Object.new
15
- GetValue = Object.new
14
+ Cascade = Object.new.freeze
15
+ GetValue = Object.new.freeze
16
16
 
17
17
  class Response < RuntimeError
18
+ def self.contents status
19
+ (@contents ||= Hash.new do |hash, key|
20
+ hash[key] = File.read("#{Jellyfish.public_root}/#{status}.html")
21
+ end)[status]
22
+ end
23
+
18
24
  def headers
19
25
  @headers ||= {'content-type' => 'text/html'}
20
26
  end
21
27
 
22
28
  def body
23
- @body ||= [File.read("#{Jellyfish.public_root}/#{status}.html")]
29
+ @body ||= [self.class.contents(status)]
24
30
  end
25
31
  end
26
32
 
@@ -31,8 +37,9 @@ module Jellyfish
31
37
  def initialize url; @url = url ; end
32
38
  def status ; 302 ; end
33
39
  def headers ; super.merge('location' => url) ; end
34
- def body ; super.map{ |b| b.gsub('VAR_URL', url) }; end
40
+ def body ; [] ; end
35
41
  end
42
+ class Moved < Found ; def status; 301; end; end
36
43
 
37
44
  # -----------------------------------------------------------------
38
45
 
@@ -63,7 +70,7 @@ module Jellyfish
63
70
  def cascade ; halt(Jellyfish::Cascade) ; end
64
71
  def not_found ; halt(Jellyfish::NotFound.new) ; end
65
72
  def found url; halt(Jellyfish:: Found.new(url)); end
66
- alias_method :redirect, :found
73
+ def moved url; halt(Jellyfish:: Moved.new(url)); end
67
74
 
68
75
  def path_info ; env['PATH_INFO'] || '/' ; end
69
76
  def request_method; env['REQUEST_METHOD'] || 'GET'; end
data/test/test_log.rb CHANGED
@@ -12,8 +12,9 @@ describe Jellyfish do
12
12
  include Jellyfish
13
13
  get('/log') { log('hi') }
14
14
  get('/log_error'){
15
- log_error(
16
- Muack::API.stub(RuntimeError.new).backtrace{ ['backtrace'] }.object)
15
+ error = RuntimeError.new
16
+ error.set_backtrace(['backtrace'])
17
+ log_error(error)
17
18
  }
18
19
  def self.name
19
20
  'Name'
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jellyfish
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
- - Lin Jen-Shin (godfat)
8
- autorequire:
7
+ - Lin Jen-Shin (godfat)
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2023-02-22 00:00:00.000000000 Z
10
+ date: 2026-11-22 00:00:00.000000000 Z
12
11
  dependencies: []
13
12
  description: |-
14
13
  Pico web framework for building API-centric web applications.
@@ -18,88 +17,87 @@ description: |-
18
17
 
19
18
  [jellyfish-contrib]: https://github.com/godfat/jellyfish-contrib
20
19
  email:
21
- - godfat (XD) godfat.org
20
+ - godfat (XD) godfat.org
22
21
  executables: []
23
22
  extensions: []
24
23
  extra_rdoc_files: []
25
24
  files:
26
- - ".gitignore"
27
- - ".gitlab-ci.yml"
28
- - ".gitmodules"
29
- - CHANGES.md
30
- - Gemfile
31
- - LICENSE
32
- - README.md
33
- - Rakefile
34
- - TODO.md
35
- - bench/bench_builder.rb
36
- - config.ru
37
- - jellyfish.gemspec
38
- - lib/jellyfish.rb
39
- - lib/jellyfish/builder.rb
40
- - lib/jellyfish/chunked_body.rb
41
- - lib/jellyfish/json.rb
42
- - lib/jellyfish/normalized_params.rb
43
- - lib/jellyfish/normalized_path.rb
44
- - lib/jellyfish/public/302.html
45
- - lib/jellyfish/public/404.html
46
- - lib/jellyfish/public/500.html
47
- - lib/jellyfish/rewrite.rb
48
- - lib/jellyfish/test.rb
49
- - lib/jellyfish/urlmap.rb
50
- - lib/jellyfish/version.rb
51
- - lib/jellyfish/websocket.rb
52
- - task/README.md
53
- - task/gemgem.rb
54
- - test/rack/test_builder.rb
55
- - test/rack/test_urlmap.rb
56
- - test/sinatra/test_base.rb
57
- - test/sinatra/test_chunked_body.rb
58
- - test/sinatra/test_error.rb
59
- - test/sinatra/test_routing.rb
60
- - test/test_from_readme.rb
61
- - test/test_inheritance.rb
62
- - test/test_listen.rb
63
- - test/test_log.rb
64
- - test/test_misc.rb
65
- - test/test_rewrite.rb
66
- - test/test_threads.rb
67
- - test/test_websocket.rb
68
- homepage: https://github.com/godfat/jellyfish
25
+ - .gitignore
26
+ - .gitlab-ci.yml
27
+ - .gitmodules
28
+ - CHANGES.md
29
+ - Gemfile
30
+ - LICENSE
31
+ - README.md
32
+ - Rakefile
33
+ - TODO.md
34
+ - bench/bench_builder.rb
35
+ - config.ru
36
+ - jellyfish.gemspec
37
+ - lib/jellyfish.rb
38
+ - lib/jellyfish/builder.rb
39
+ - lib/jellyfish/chunked_body.rb
40
+ - lib/jellyfish/json.rb
41
+ - lib/jellyfish/normalized_params.rb
42
+ - lib/jellyfish/normalized_path.rb
43
+ - lib/jellyfish/public/404.html
44
+ - lib/jellyfish/public/500.html
45
+ - lib/jellyfish/rewrite.rb
46
+ - lib/jellyfish/test.rb
47
+ - lib/jellyfish/urlmap.rb
48
+ - lib/jellyfish/version.rb
49
+ - lib/jellyfish/websocket.rb
50
+ - task/README.md
51
+ - task/gemgem.rb
52
+ - test/rack/test_builder.rb
53
+ - test/rack/test_urlmap.rb
54
+ - test/sinatra/test_base.rb
55
+ - test/sinatra/test_chunked_body.rb
56
+ - test/sinatra/test_error.rb
57
+ - test/sinatra/test_routing.rb
58
+ - test/test_from_readme.rb
59
+ - test/test_inheritance.rb
60
+ - test/test_listen.rb
61
+ - test/test_log.rb
62
+ - test/test_misc.rb
63
+ - test/test_rewrite.rb
64
+ - test/test_threads.rb
65
+ - test/test_websocket.rb
66
+ homepage: "https://github.com/godfat/jellyfish"
69
67
  licenses:
70
- - Apache-2.0
68
+ - Apache-2.0
71
69
  metadata: {}
72
- post_install_message:
73
70
  rdoc_options: []
74
71
  require_paths:
75
- - lib
72
+ - lib
76
73
  required_ruby_version: !ruby/object:Gem::Requirement
77
74
  requirements:
78
- - - ">="
79
- - !ruby/object:Gem::Version
80
- version: '0'
75
+ -
76
+ - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: "0"
81
79
  required_rubygems_version: !ruby/object:Gem::Requirement
82
80
  requirements:
83
- - - ">="
84
- - !ruby/object:Gem::Version
85
- version: '0'
81
+ -
82
+ - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: "0"
86
85
  requirements: []
87
- rubygems_version: 3.4.3
88
- signing_key:
86
+ rubygems_version: 4.1.0
89
87
  specification_version: 4
90
88
  summary: Pico web framework for building API-centric web applications.
91
89
  test_files:
92
- - test/rack/test_builder.rb
93
- - test/rack/test_urlmap.rb
94
- - test/sinatra/test_base.rb
95
- - test/sinatra/test_chunked_body.rb
96
- - test/sinatra/test_error.rb
97
- - test/sinatra/test_routing.rb
98
- - test/test_from_readme.rb
99
- - test/test_inheritance.rb
100
- - test/test_listen.rb
101
- - test/test_log.rb
102
- - test/test_misc.rb
103
- - test/test_rewrite.rb
104
- - test/test_threads.rb
105
- - test/test_websocket.rb
90
+ - test/rack/test_builder.rb
91
+ - test/rack/test_urlmap.rb
92
+ - test/sinatra/test_base.rb
93
+ - test/sinatra/test_chunked_body.rb
94
+ - test/sinatra/test_error.rb
95
+ - test/sinatra/test_routing.rb
96
+ - test/test_from_readme.rb
97
+ - test/test_inheritance.rb
98
+ - test/test_listen.rb
99
+ - test/test_log.rb
100
+ - test/test_misc.rb
101
+ - test/test_rewrite.rb
102
+ - test/test_threads.rb
103
+ - test/test_websocket.rb
@@ -1,10 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5
- <meta http-equiv="refresh" content="0;URL='VAR_URL'">
6
- </head>
7
- <body>
8
- <h1>Jellyfish found: VAR_URL</h1>
9
- </body>
10
- </html>