jellyfish 1.2.2 → 1.3.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 +4 -4
- data/CHANGES.md +13 -0
- data/jellyfish.gemspec +4 -4
- data/lib/jellyfish/builder.rb +6 -5
- data/lib/jellyfish/chunked_body.rb +1 -0
- data/lib/jellyfish/json.rb +1 -0
- data/lib/jellyfish/normalized_params.rb +1 -1
- data/lib/jellyfish/normalized_path.rb +1 -1
- data/lib/jellyfish/rewrite.rb +15 -2
- data/lib/jellyfish/test.rb +1 -0
- data/lib/jellyfish/urlmap.rb +4 -2
- data/lib/jellyfish/version.rb +2 -1
- data/lib/jellyfish/websocket.rb +1 -0
- data/test/test_rewrite.rb +16 -12
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f9e1adde462fe63f752d02b74395426c74022f9e8fb920ecf089a4b3bb20624
|
4
|
+
data.tar.gz: 2c4fea5a52568b9bd153c95f67c02a722634ad32177733be4c7941686eb9bfed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 428fb54496fb53eb2efc363f37d0ad2b7b889edb23c3a40a22cd1acc52f20348015b8193a8d92967a9f8da1716903b68ff672ff581e4e68411d8b017b6a6a3ca
|
7
|
+
data.tar.gz: 20db48c00b68b9cb4bb3499e3a0bf8bee223f71f0f48312c16a1eeb21481cb5cb2865a2ec2331412ffcf4e88e9bfa4da4a5bc81e6a2ca206b6df4d8b211b61be
|
data/CHANGES.md
CHANGED
@@ -1,5 +1,18 @@
|
|
1
1
|
# CHANGES
|
2
2
|
|
3
|
+
## Jellyfish 1.3.0 -- 2018-11-11
|
4
|
+
|
5
|
+
### Incompatible changes
|
6
|
+
|
7
|
+
* Interface for `Builder.app`, and `Builder#to_app`, and `Rewrite.new`
|
8
|
+
slightly changed due to fixing the bug in `Rewrite`. You shouldn't use
|
9
|
+
those directly though.
|
10
|
+
* Now all strings allocated from Jellyfish are frozen.
|
11
|
+
|
12
|
+
### Bugs fixed
|
13
|
+
|
14
|
+
* Fixed `Jellyfish::Rewrite`. Should properly handle SCRIPT_NAME.
|
15
|
+
|
3
16
|
## Jellyfish 1.2.2 -- 2018-09-23
|
4
17
|
|
5
18
|
### Bugs fixed
|
data/jellyfish.gemspec
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: jellyfish 1.
|
2
|
+
# stub: jellyfish 1.3.0 ruby lib
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "jellyfish".freeze
|
6
|
-
s.version = "1.
|
6
|
+
s.version = "1.3.0"
|
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 = "2018-
|
11
|
+
s.date = "2018-11-11"
|
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 = [
|
@@ -56,7 +56,7 @@ Gem::Specification.new do |s|
|
|
56
56
|
"test/test_websocket.rb".freeze]
|
57
57
|
s.homepage = "https://github.com/godfat/jellyfish".freeze
|
58
58
|
s.licenses = ["Apache-2.0".freeze]
|
59
|
-
s.rubygems_version = "2.7.
|
59
|
+
s.rubygems_version = "2.7.8".freeze
|
60
60
|
s.summary = "Pico web framework for building API-centric web applications.".freeze
|
61
61
|
s.test_files = [
|
62
62
|
"test/rack/test_builder.rb".freeze,
|
data/lib/jellyfish/builder.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
|
2
3
|
require 'jellyfish/urlmap'
|
3
4
|
|
4
5
|
module Jellyfish
|
5
6
|
class Builder
|
6
|
-
def self.app app=nil, to=nil, &block
|
7
|
-
new(app, &block).to_app(to)
|
7
|
+
def self.app app=nil, from=nil, to=nil, &block
|
8
|
+
new(app, &block).to_app(from, to)
|
8
9
|
end
|
9
10
|
|
10
11
|
def initialize app=nil, &block
|
@@ -43,11 +44,11 @@ module Jellyfish
|
|
43
44
|
end
|
44
45
|
end
|
45
46
|
|
46
|
-
def to_app to=nil
|
47
|
+
def to_app from=nil, to=nil
|
47
48
|
run = if @map then generate_map(@map, @run) else @run end
|
48
49
|
fail 'missing run or map statement' unless run
|
49
50
|
app = @use.inject(run){ |a, m| m.call(a) }
|
50
|
-
result = if to then Rewrite.new(app, to) else app end
|
51
|
+
result = if to then Rewrite.new(app, from, to) else app end
|
51
52
|
@warmup.call(result) if @warmup
|
52
53
|
result
|
53
54
|
end
|
@@ -56,7 +57,7 @@ module Jellyfish
|
|
56
57
|
def generate_map current_map, app
|
57
58
|
mapped = if app then {'' => app} else {} end
|
58
59
|
current_map.each do |path, (block, to)|
|
59
|
-
mapped[path] = self.class.app(app, to, &block)
|
60
|
+
mapped[path] = self.class.app(app, path, to, &block)
|
60
61
|
end
|
61
62
|
URLMap.new(mapped)
|
62
63
|
end
|
data/lib/jellyfish/json.rb
CHANGED
data/lib/jellyfish/rewrite.rb
CHANGED
@@ -1,8 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
|
2
3
|
module Jellyfish
|
3
|
-
class Rewrite < Struct.new(:app, :to)
|
4
|
+
class Rewrite < Struct.new(:app, :from, :to)
|
4
5
|
def call env
|
5
|
-
app.call(env.merge(
|
6
|
+
app.call(env.merge(
|
7
|
+
'SCRIPT_NAME' => delete_suffix(env['SCRIPT_NAME'], from),
|
8
|
+
'PATH_INFO' => "#{to}#{env['PATH_INFO']}"))
|
9
|
+
end
|
10
|
+
|
11
|
+
if ''.respond_to?(:delete_suffix)
|
12
|
+
def delete_suffix str, suffix
|
13
|
+
str.delete_suffix(suffix)
|
14
|
+
end
|
15
|
+
else
|
16
|
+
def delete_suffix str, suffix
|
17
|
+
str.sub(/#{Regexp.escape(suffix)}\z/, '')
|
18
|
+
end
|
6
19
|
end
|
7
20
|
end
|
8
21
|
end
|
data/lib/jellyfish/test.rb
CHANGED
data/lib/jellyfish/urlmap.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
|
2
3
|
require 'uri'
|
3
4
|
|
@@ -46,8 +47,9 @@ module Jellyfish
|
|
46
47
|
end
|
47
48
|
|
48
49
|
if app = @mapped[key]
|
49
|
-
app.call(env.merge(
|
50
|
-
|
50
|
+
app.call(env.merge(
|
51
|
+
'SCRIPT_NAME' => env['SCRIPT_NAME'] + script_name,
|
52
|
+
'PATH_INFO' => path_info[cut_path.size..-1]))
|
51
53
|
else
|
52
54
|
[404, {}, []]
|
53
55
|
end
|
data/lib/jellyfish/version.rb
CHANGED
data/lib/jellyfish/websocket.rb
CHANGED
data/test/test_rewrite.rb
CHANGED
@@ -5,7 +5,9 @@ require 'jellyfish/urlmap'
|
|
5
5
|
describe Jellyfish::Rewrite do
|
6
6
|
paste :jellyfish
|
7
7
|
|
8
|
-
lam = lambda
|
8
|
+
lam = lambda do |env|
|
9
|
+
[200, {}, ["#{env['SCRIPT_NAME']}!#{env['PATH_INFO']}"]]
|
10
|
+
end
|
9
11
|
|
10
12
|
def call app, path
|
11
13
|
get(path, app).dig(-1, 0)
|
@@ -18,23 +20,25 @@ describe Jellyfish::Rewrite do
|
|
18
20
|
end
|
19
21
|
end
|
20
22
|
|
21
|
-
expect(call(app, '/from/here')).eq '
|
23
|
+
expect(call(app, '/from/here')).eq '!/to/here'
|
22
24
|
end
|
23
25
|
|
24
26
|
would 'rewrite and fallback' do
|
25
27
|
app = Jellyfish::Builder.app do
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
28
|
+
map '/top' do
|
29
|
+
rewrite '/from/inner' => '/to/inner',
|
30
|
+
'/from/outer' => '/to/outer' do
|
31
|
+
run lam
|
32
|
+
end
|
33
|
+
|
34
|
+
map '/from' do
|
35
|
+
run lam
|
36
|
+
end
|
33
37
|
end
|
34
38
|
end
|
35
39
|
|
36
|
-
expect(call(app, '/from'
|
37
|
-
expect(call(app, '/from/inner')).eq '/to/inner'
|
38
|
-
expect(call(app, '/from/outer')).eq '/to/outer'
|
40
|
+
expect(call(app, '/top/from/other')).eq '/top/from!/other'
|
41
|
+
expect(call(app, '/top/from/inner')).eq '/top!/to/inner'
|
42
|
+
expect(call(app, '/top/from/outer')).eq '/top!/to/outer'
|
39
43
|
end
|
40
44
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jellyfish
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lin Jen-Shin (godfat)
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-11-11 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |-
|
14
14
|
Pico web framework for building API-centric web applications.
|
@@ -85,7 +85,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
85
85
|
version: '0'
|
86
86
|
requirements: []
|
87
87
|
rubyforge_project:
|
88
|
-
rubygems_version: 2.7.
|
88
|
+
rubygems_version: 2.7.8
|
89
89
|
signing_key:
|
90
90
|
specification_version: 4
|
91
91
|
summary: Pico web framework for building API-centric web applications.
|