rack-capture 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -0
- data/CHANGELOG.md +14 -0
- data/Gemfile.lock +1 -1
- data/lib/rack/capture.rb +15 -12
- data/lib/rack/capture/version.rb +1 -1
- data/rack-capture.gemspec +1 -1
- metadata +2 -3
- data/.travis.yml +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 702d6e7c443504b12de28619254711077de0e6b605fef65ca364e0760c731a4c
|
4
|
+
data.tar.gz: 79621b6046182ee868d8bb146f2160f63de15961e791eb10b94cf4a91892cc5e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f480fbd7c4f807e65ba8f50d18c3f1657f68ec2dc6cab86ed523afbec17dec20e3a2eed031c069ac1323542fd992ff937dffd35c64b98a6c5f745a96cf6d6e4f
|
7
|
+
data.tar.gz: 89aff18188238280e14e49af9074fa23a021330c165eece63eadf144d699c81f9d45ab7e9431b64e7491c632192ffe1caf3c6e919fbfe1f9d19678025e2281fd
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -7,6 +7,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
7
7
|
|
8
8
|
## Unreleased
|
9
9
|
|
10
|
+
## 0.3.0 - 2020-11-06
|
11
|
+
|
12
|
+
### Added
|
13
|
+
|
14
|
+
- Add `:script_name` option.
|
15
|
+
|
16
|
+
### Changed
|
17
|
+
|
18
|
+
- Change least require ruby version from 2.4.0 to 2.5.0.
|
19
|
+
|
20
|
+
### Fixed
|
21
|
+
|
22
|
+
- Fix frozen bug when a frozen body is passsed.
|
23
|
+
|
10
24
|
## 0.2.0 - 2020-11-06
|
11
25
|
|
12
26
|
### Changed
|
data/Gemfile.lock
CHANGED
data/lib/rack/capture.rb
CHANGED
@@ -7,23 +7,21 @@ require 'rack/capture/version'
|
|
7
7
|
module Rack
|
8
8
|
class Capture
|
9
9
|
class << self
|
10
|
-
|
11
|
-
|
12
|
-
def call(
|
13
|
-
app:,
|
14
|
-
url:
|
15
|
-
)
|
16
|
-
new(app: app, url: url).call
|
10
|
+
def call(**args)
|
11
|
+
new(**args).call
|
17
12
|
end
|
18
13
|
end
|
19
14
|
|
20
15
|
# @param [#call] app Rack application.
|
16
|
+
# @param [String] script_name
|
21
17
|
# @param [String] url
|
22
18
|
def initialize(
|
23
19
|
app:,
|
24
|
-
url
|
20
|
+
url:,
|
21
|
+
script_name: ''
|
25
22
|
)
|
26
23
|
@app = app
|
24
|
+
@script_name = script_name
|
27
25
|
@url = url
|
28
26
|
end
|
29
27
|
|
@@ -33,7 +31,7 @@ module Rack
|
|
33
31
|
destination.parent.mkpath
|
34
32
|
content = ''
|
35
33
|
response.body.each do |element|
|
36
|
-
content
|
34
|
+
content += element
|
37
35
|
end
|
38
36
|
destination.write(content)
|
39
37
|
end
|
@@ -42,7 +40,7 @@ module Rack
|
|
42
40
|
|
43
41
|
# @param [Rack::Response] response
|
44
42
|
def calculate_destination(response:)
|
45
|
-
destination = ::Pathname.new("dist#{
|
43
|
+
destination = ::Pathname.new("dist#{path_info}")
|
46
44
|
if response.content_type&.include?('text/html')
|
47
45
|
destination += 'index' if uri.path == '/'
|
48
46
|
destination = destination.sub_ext('.html')
|
@@ -56,15 +54,20 @@ module Rack
|
|
56
54
|
::Rack::Response.new(body, status, headers)
|
57
55
|
end
|
58
56
|
|
57
|
+
# @return [String]
|
58
|
+
def path_info
|
59
|
+
uri.path.delete_prefix(@script_name)
|
60
|
+
end
|
61
|
+
|
59
62
|
# @return [Hash]
|
60
63
|
def rack_env
|
61
64
|
{
|
62
65
|
'HTTP_HOST' => @host,
|
63
|
-
'PATH_INFO' =>
|
66
|
+
'PATH_INFO' => path_info,
|
64
67
|
'QUERY_STRING' => uri.query || '',
|
65
68
|
'rack.url_scheme' => rack_url_scheme,
|
66
69
|
'REQUEST_METHOD' => 'GET',
|
67
|
-
'SCRIPT_NAME' =>
|
70
|
+
'SCRIPT_NAME' => @script_name,
|
68
71
|
'SERVER_NAME' => uri.host
|
69
72
|
}
|
70
73
|
end
|
data/lib/rack/capture/version.rb
CHANGED
data/rack-capture.gemspec
CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
|
|
11
11
|
spec.summary = 'Generate static files from Rack application and URLs.'
|
12
12
|
spec.homepage = 'https://github.com/r7kamura/rack-capture'
|
13
13
|
spec.license = 'MIT'
|
14
|
-
spec.required_ruby_version = Gem::Requirement.new('>= 2.
|
14
|
+
spec.required_ruby_version = Gem::Requirement.new('>= 2.5.0')
|
15
15
|
|
16
16
|
spec.metadata['homepage_uri'] = spec.homepage
|
17
17
|
spec.metadata['source_code_uri'] = spec.homepage
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-capture
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryo Nakamura
|
@@ -35,7 +35,6 @@ files:
|
|
35
35
|
- ".gitignore"
|
36
36
|
- ".rspec"
|
37
37
|
- ".rubocop.yml"
|
38
|
-
- ".travis.yml"
|
39
38
|
- CHANGELOG.md
|
40
39
|
- Gemfile
|
41
40
|
- Gemfile.lock
|
@@ -62,7 +61,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
62
61
|
requirements:
|
63
62
|
- - ">="
|
64
63
|
- !ruby/object:Gem::Version
|
65
|
-
version: 2.
|
64
|
+
version: 2.5.0
|
66
65
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
67
66
|
requirements:
|
68
67
|
- - ">="
|