rack-blank 0.1.0 → 0.1.1

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
  SHA1:
3
- metadata.gz: f61d1cdca998620a42191974d555e9a4c595c41d
4
- data.tar.gz: 028ce79383715a0665ae97c4e97dc1e0628d2e78
3
+ metadata.gz: 172dfe177707cf62db69c0d8045b527d451c8102
4
+ data.tar.gz: 3c19a4d4824ccb936efaf2636c71a56e56e53251
5
5
  SHA512:
6
- metadata.gz: e5b8bcc7a5f0a2adf432b53932bb34ad13d39bcefb5c7bb5f255781cfc5283b9cc277dd1059a018b039c6bc429f2760386f4c0bc3ae7f1d2093af1ea35875072
7
- data.tar.gz: cbab45224d3bc001f1ceb8cf73614b9b7fc42260871bb973251563ba213bc97d8a00d84514072d584ca7beb4ece8162f7d3754d2f1dc381504ff199d2453956b
6
+ metadata.gz: 0c9a62bb818b9bc9dbd2e73506ba11502a5d4cca8dad3cf1deac2028d9d4479c3745a232532ba84723d2698ea47f0307e673629bfaa1619c6d529771d74fc41e
7
+ data.tar.gz: 738ca7911934c769d1283db5b82de1d57c9961bfa785787e2c168892fa1637b7495200adbca667a388ee50cbd70577f193cdf4152fa35af97b9be11231087b60
@@ -1,5 +1,5 @@
1
1
  module Rack
2
2
  class Blank
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
5
5
  end
data/lib/rack/blank.rb CHANGED
@@ -10,21 +10,22 @@ module Rack
10
10
  end
11
11
 
12
12
  def call(env)
13
- if @path && env['PATH_INFO'] == @path
14
- body = if env['CONTENT_TYPE'] == 'application/json'
15
- JSON.generate({})
16
- else
17
- ''
13
+ request_path = "#{::File.dirname(env['PATH_INFO'])}/#{::File.basename(env['PATH_INFO'], '.*')}"
14
+ request_ext = ::File.extname(env['PATH_INFO'])
15
+ if request_path == @path
16
+ body = ''
17
+ content_type = 'text/plain'
18
+ if env['CONTENT_TYPE'] == 'application/json' || request_ext == '.json'
19
+ body = JSON.generate({})
20
+ content_type = 'application/json'
18
21
  end
19
22
  headers = {
20
23
  "Content-Length" => body.bytesize.to_s,
21
- "Content-Type" => env['CONTENT_TYPE'] || ''
24
+ "Content-Type" => content_type
22
25
  }
23
- res = [200, headers, [body]]
24
- return res
26
+ return [200, headers, [body]]
25
27
  end
26
- res = @app.call(env)
27
- return res
28
+ return @app.call(env)
28
29
  end
29
30
 
30
31
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-blank
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - haruyama-makoto