rack-manifest 0.1.3 → 0.1.4

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
  SHA1:
3
- metadata.gz: c2795a5909d3982a7fa52c2a20134d98fde8a159
4
- data.tar.gz: 9b442a844641207709a202ad38ef44d26157fea1
3
+ metadata.gz: 946a58a6c131b4701335d4bc97db43f6bbe69533
4
+ data.tar.gz: b385b24648f97c6ce2868b63aede9471d4986711
5
5
  SHA512:
6
- metadata.gz: 8d768b0be298236f7b31af6b1e9545ba3bac5f73c259df6319b8bdb3f6337bbebdb5207fd1b27aadb5f1addd929ace6d09b60eb32c63eac499feefeb449ae556
7
- data.tar.gz: 5874b0b22c9a93149434705b7a3d225b5434651f93bf042256fc2c87fc28316c535a286ff40cd714152ece9caf3ed7494167a58331171ddc849773161899abcb
6
+ metadata.gz: 8cfbf57dcf5d548b948c4b2a5d2c1158d46bc3c46f1d7881796df76b3f09f7d0260af256756960edb05558f58c238bb66affbcafd5c032ed618bca8711ad2309
7
+ data.tar.gz: c26e802ce4250ac0562caa2d6e114bfe48030b1d41bc7e70f59e519ba538cbf9220aa27a8e9e6d333d0ad7bae7a73ee8a4fa2572e9c35638623686f5397e93bf
@@ -1,7 +1,6 @@
1
1
  require 'json'
2
2
  require 'erb'
3
- require 'action_view/helpers/asset_url_helper'
4
- require 'rack/request'
3
+ require "digest/md5"
5
4
  require 'rack/manifest/version'
6
5
  require 'rack/manifest/rails' if defined?(Rails::Railtie)
7
6
  require 'rack/manifest/sprockets' if defined?(Sprockets) && defined?(Rails)
@@ -23,20 +22,17 @@ class Rack::Manifest
23
22
 
24
23
  def call(env)
25
24
  if env['PATH_INFO'] == '/manifest.json'
26
- headers = {}
27
- if env.has_key?('HTTP_IF_MODIFIED_SINCE')
28
- fetched_date = env['HTTP_IF_MODIFIED_SINCE']
29
- return [304, headers, []] if get_modified_time(FILE_PATH) == fetched_date
30
- end
31
25
  manifest = load_yaml(FILE_PATH)
32
26
  json = JSON.generate(manifest)
27
+ etag = digest(json)
28
+ return [304, {}, []] if env['HTTP_IF_NONE_MATCH'] == etag
33
29
  [
34
30
  200,
35
- headers.merge({
31
+ {
36
32
  'Content-Type' => 'application/json',
37
- 'Last-Modified' => get_modified_time(FILE_PATH),
33
+ 'Etag' => etag,
38
34
  'Content-Length' => json.length.to_s
39
- }),
35
+ },
40
36
  [json]
41
37
  ]
42
38
  else
@@ -45,9 +41,8 @@ class Rack::Manifest
45
41
  end
46
42
 
47
43
  private
48
- def get_modified_time(path)
49
- time = File.mtime(path)
50
- time.strftime('%a, %d %b %Y %H:%M:%S GMT')
44
+ def digest(str)
45
+ Digest::MD5.hexdigest(str)
51
46
  end
52
47
  end
53
48
 
@@ -1,5 +1,5 @@
1
1
  module Rack
2
2
  class Manifest
3
- VERSION = "0.1.3"
3
+ VERSION = "0.1.4"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-manifest
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - syumai