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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c316008c4924a7b1c9244f77e9aecc7513202c459662611f2add7d073e081e82
4
- data.tar.gz: 977cb2570077e82539f2f9bf7172ef529f637e50b433f0aff10fbd44a05e5add
3
+ metadata.gz: 702d6e7c443504b12de28619254711077de0e6b605fef65ca364e0760c731a4c
4
+ data.tar.gz: 79621b6046182ee868d8bb146f2160f63de15961e791eb10b94cf4a91892cc5e
5
5
  SHA512:
6
- metadata.gz: b5212f508e3b12511041a8ad1b2aa6d3cc67982dbe2ff5c62ea4fcfaa1102387deba1904b052ecaf7a71ec3cbae9a19667e057771ed0da2374c422ae227397f3
7
- data.tar.gz: 7005d1365496e88053488b1900310176c53808a2e8948cb24cc6417885d5ffa7afc724b56300ece5c777b135e8efce26789189be99dfeb746e9b066c654ac61e
6
+ metadata.gz: f480fbd7c4f807e65ba8f50d18c3f1657f68ec2dc6cab86ed523afbec17dec20e3a2eed031c069ac1323542fd992ff937dffd35c64b98a6c5f745a96cf6d6e4f
7
+ data.tar.gz: 89aff18188238280e14e49af9074fa23a021330c165eece63eadf144d699c81f9d45ab7e9431b64e7491c632192ffe1caf3c6e919fbfe1f9d19678025e2281fd
@@ -1,5 +1,6 @@
1
1
  AllCops:
2
2
  NewCops: enable
3
+ TargetRubyVersion: '2.5'
3
4
 
4
5
  Metrics:
5
6
  Enabled: false
@@ -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
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rack-capture (0.2.0)
4
+ rack-capture (0.3.0)
5
5
  rack
6
6
 
7
7
  GEM
@@ -7,23 +7,21 @@ require 'rack/capture/version'
7
7
  module Rack
8
8
  class Capture
9
9
  class << self
10
- # @param [#call] app Rack application.
11
- # @param [String] url
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 << element
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#{uri.path}")
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' => uri.path,
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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Rack
4
4
  class Capture
5
- VERSION = '0.2.0'
5
+ VERSION = '0.3.0'
6
6
  end
7
7
  end
@@ -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.4.0')
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.2.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.4.0
64
+ version: 2.5.0
66
65
  required_rubygems_version: !ruby/object:Gem::Requirement
67
66
  requirements:
68
67
  - - ">="
@@ -1,6 +0,0 @@
1
- ---
2
- language: ruby
3
- cache: bundler
4
- rvm:
5
- - 2.7.1
6
- before_install: gem install bundler -v 2.1.4