rack-offline 0.5.4 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/rack-offline.rb +2 -2
- data/lib/rack/offline.rb +4 -4
- data/lib/rack/offline/config.rb +10 -7
- data/lib/rack/offline/version.rb +1 -1
- metadata +4 -4
data/lib/rack-offline.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require "rack/offline"
|
2
2
|
|
3
3
|
module Rails
|
4
|
-
class Offline <
|
4
|
+
class Offline < Rack::Offline
|
5
5
|
def self.call(env)
|
6
6
|
@app ||= new
|
7
7
|
@app.call(env)
|
@@ -31,7 +31,7 @@ module Rails
|
|
31
31
|
"#{root}/stylesheets/**/*.css",
|
32
32
|
"#{root}/javascripts/**/*.js",
|
33
33
|
"#{root}/images/**"]
|
34
|
-
|
34
|
+
|
35
35
|
files.each do |file|
|
36
36
|
cache Pathname.new(file).relative_path_from(root)
|
37
37
|
end
|
data/lib/rack/offline.rb
CHANGED
@@ -20,7 +20,7 @@ module Rack
|
|
20
20
|
@root = Pathname.new(options[:root] || Dir.pwd)
|
21
21
|
|
22
22
|
if block_given?
|
23
|
-
@config = Rack::Offline::Config.new(&block)
|
23
|
+
@config = Rack::Offline::Config.new(@root, &block)
|
24
24
|
end
|
25
25
|
|
26
26
|
if @cache
|
@@ -36,7 +36,7 @@ module Rack
|
|
36
36
|
|
37
37
|
body = ["CACHE MANIFEST"]
|
38
38
|
body << "# #{key}"
|
39
|
-
@config.
|
39
|
+
@config.cache.each do |item|
|
40
40
|
body << item
|
41
41
|
end
|
42
42
|
|
@@ -62,11 +62,11 @@ module Rack
|
|
62
62
|
private
|
63
63
|
|
64
64
|
def precache_key!
|
65
|
-
hash = @config.
|
65
|
+
hash = @config.cache.map do |item|
|
66
66
|
Digest::SHA2.hexdigest(@root.join(item).read)
|
67
67
|
end
|
68
68
|
|
69
69
|
@key = Digest::SHA2.hexdigest(hash.join)
|
70
70
|
end
|
71
71
|
end
|
72
|
-
end
|
72
|
+
end
|
data/lib/rack/offline/config.rb
CHANGED
@@ -1,17 +1,16 @@
|
|
1
1
|
module Rack
|
2
2
|
class Offline
|
3
3
|
class Config
|
4
|
-
|
5
|
-
|
6
|
-
def initialize(&block)
|
7
|
-
@cached = []
|
4
|
+
def initialize(root, &block)
|
5
|
+
@cache = []
|
8
6
|
@network = []
|
9
7
|
@fallback = {}
|
8
|
+
@root = root
|
10
9
|
instance_eval(&block) if block_given?
|
11
10
|
end
|
12
11
|
|
13
12
|
def cache(*names)
|
14
|
-
@
|
13
|
+
@cache.concat(names)
|
15
14
|
end
|
16
15
|
|
17
16
|
def network(*names)
|
@@ -19,8 +18,12 @@ module Rack
|
|
19
18
|
end
|
20
19
|
|
21
20
|
def fallback(hash = {})
|
22
|
-
@fallback.merge(hash)
|
21
|
+
@fallback.merge!(hash)
|
22
|
+
end
|
23
|
+
|
24
|
+
def root
|
25
|
+
@root
|
23
26
|
end
|
24
27
|
end
|
25
28
|
end
|
26
|
-
end
|
29
|
+
end
|
data/lib/rack/offline/version.rb
CHANGED
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 0.
|
7
|
+
- 6
|
8
|
+
- 0
|
9
|
+
version: 0.6.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Yehuda Katz
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-06-02 00:00:00 +02:00
|
18
18
|
default_executable:
|
19
19
|
dependencies: []
|
20
20
|
|