cache_cache 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/cache_cache.rb +106 -0
- metadata +45 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 2212d8d62c207a2ecb08200a5522d388f4269acb
|
4
|
+
data.tar.gz: 50a84cb1f102d2f733ed2a5004e38fe37c179aa4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1714a2a60833bc4235bedfed36a9b94f3a0118bb5a44a110c1a6de1d3c19611443cc690c1566216f8cd760d80833ae31e5e5103695a8767767dfb9b5d995e8fc
|
7
|
+
data.tar.gz: e706767f50a658db1ea0ec3bc6823362cc6668eb4b11a6c9eff3b872b992d10435e07cb8e54027ddd470a8dc8f85c61114c1e8bcf4740a94a34532d6fb1b8cc0
|
data/lib/cache_cache.rb
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
module Rails
|
2
|
+
|
3
|
+
# CacheCache allow you to manage dynamically multiple group of HTML5 manifest.
|
4
|
+
# CacheCache use rails cache to store generated manifests.
|
5
|
+
#
|
6
|
+
class CacheCache
|
7
|
+
|
8
|
+
# Constructor
|
9
|
+
#
|
10
|
+
def initialize(options = {}, &block)
|
11
|
+
@memory_store = options.fetch(:memory_store, ActiveSupport::Cache::MemoryStore.new)
|
12
|
+
@group = options.fetch(:group, :default)
|
13
|
+
|
14
|
+
@cache = { }
|
15
|
+
@network = { }
|
16
|
+
@fallback = { }
|
17
|
+
|
18
|
+
instance_eval(&block) if block_given?
|
19
|
+
end
|
20
|
+
|
21
|
+
# Get / Set an entry into the cache section of the manifest
|
22
|
+
#
|
23
|
+
def cache(entry = nil)
|
24
|
+
unless entry.nil?
|
25
|
+
@cache[@group] ||= []
|
26
|
+
@cache[@group] << entry
|
27
|
+
end
|
28
|
+
|
29
|
+
@cache[@group]
|
30
|
+
end
|
31
|
+
|
32
|
+
# Get / Set an entry into the network section of the manifest
|
33
|
+
#
|
34
|
+
def network(entry = nil)
|
35
|
+
unless entry.nil?
|
36
|
+
@network[@group] ||= []
|
37
|
+
@network[@group] << entry
|
38
|
+
end
|
39
|
+
|
40
|
+
@network[@group]
|
41
|
+
end
|
42
|
+
|
43
|
+
# Get / Set an entry into the fallback section of the manifest
|
44
|
+
#
|
45
|
+
def fallback(entry = nil)
|
46
|
+
unless entry.nil?
|
47
|
+
@fallback[@group] ||= []
|
48
|
+
@fallback[@group] << entry
|
49
|
+
end
|
50
|
+
|
51
|
+
@fallback[@group]
|
52
|
+
end
|
53
|
+
|
54
|
+
# Save the current manifest
|
55
|
+
#
|
56
|
+
def save
|
57
|
+
@memory_store.write(self.label, self.manifest)
|
58
|
+
end
|
59
|
+
|
60
|
+
# Get the manifest
|
61
|
+
#
|
62
|
+
def manifest
|
63
|
+
return (@memory_store.read(self.label) or self.generate)
|
64
|
+
end
|
65
|
+
|
66
|
+
# Generate the manifest
|
67
|
+
#
|
68
|
+
def generate
|
69
|
+
[
|
70
|
+
'CACHE MANIFEST' ,
|
71
|
+
self.spoor ,
|
72
|
+
'CACHE:' ,
|
73
|
+
self.cache ,
|
74
|
+
'NETWORK:' ,
|
75
|
+
self.network ,
|
76
|
+
'FALLBACK:' ,
|
77
|
+
self.fallback ,
|
78
|
+
].join("\n")
|
79
|
+
end
|
80
|
+
|
81
|
+
# Get / Set the current group
|
82
|
+
#
|
83
|
+
def group(group_name = nil)
|
84
|
+
@group = group_name unless group_name.nil?
|
85
|
+
@group
|
86
|
+
end
|
87
|
+
|
88
|
+
# Get the spoor of the manifest
|
89
|
+
#
|
90
|
+
def spoor
|
91
|
+
"# generated by cache_cache"
|
92
|
+
end
|
93
|
+
|
94
|
+
# Get label
|
95
|
+
#
|
96
|
+
def label
|
97
|
+
"cache_cache_#{@group}"
|
98
|
+
end
|
99
|
+
|
100
|
+
# Get the manifest
|
101
|
+
#
|
102
|
+
def to_s
|
103
|
+
self.manifest
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
metadata
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cache_cache
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Clement Bruchon
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-12-17 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: CacheCache allow you to manage dynamically multiple group of HTML5 manifest
|
14
|
+
using rails cache.
|
15
|
+
email: clement.bruchon@gmail.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- lib/cache_cache.rb
|
21
|
+
homepage: https://github.com/Oxyless/cache_cache
|
22
|
+
licenses:
|
23
|
+
- MIT
|
24
|
+
metadata: {}
|
25
|
+
post_install_message:
|
26
|
+
rdoc_options: []
|
27
|
+
require_paths:
|
28
|
+
- lib
|
29
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
requirements: []
|
40
|
+
rubyforge_project:
|
41
|
+
rubygems_version: 2.0.2
|
42
|
+
signing_key:
|
43
|
+
specification_version: 4
|
44
|
+
summary: Dynamic HTML5 manifest generator
|
45
|
+
test_files: []
|