wire-framework 0.1.4.1 → 0.1.4.2
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 +4 -4
- data/lib/app.rb +1 -0
- data/lib/app/cache.rb +64 -0
- data/lib/wire.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8fb0cb127428e965623ad670dfcdf591c54dcb84
|
4
|
+
data.tar.gz: 9bffa2b55ea5271e0dfdc87a5f5b5a916af48f73
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 28e3e80dd115e2e217e69bd6faf5033232569ae3f4584c7151cab5a26fada4067665d91dd03068922ef6c07100ab4fec8a0434e00c610eccd028356de541548d
|
7
|
+
data.tar.gz: 319d6e21f2f09a68b57a12a4732a74b4974b2031dc519b98e2da0b8868cdaa1fe6ae0d502d4190d974f46d5648584373fd3ec6aff27e4b67a53706ce67a43233
|
data/lib/app.rb
CHANGED
data/lib/app/cache.rb
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
require_relative '../app'
|
2
|
+
require_relative '../closet/resource'
|
3
|
+
require_relative '../app/render'
|
4
|
+
|
5
|
+
module Cache
|
6
|
+
module Memory
|
7
|
+
include Wire::App
|
8
|
+
include Wire::Resource
|
9
|
+
extend Render
|
10
|
+
|
11
|
+
$cache = {}
|
12
|
+
|
13
|
+
def self.write_aware
|
14
|
+
$current_resource[:write_aware] = true
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.update_cache(context)
|
18
|
+
action = (context.uri.length == 3) ? :readAll : :read
|
19
|
+
content = forward(action,context)
|
20
|
+
temp = context.uri.dup
|
21
|
+
temp.shift
|
22
|
+
target = $cache
|
23
|
+
until temp.empty?
|
24
|
+
current = temp.shift
|
25
|
+
unless target[current]
|
26
|
+
target[current] = {}
|
27
|
+
end
|
28
|
+
target = target[current]
|
29
|
+
end
|
30
|
+
target = (context.uri.length == 3) ? target[:all] : target
|
31
|
+
target = content
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.get_cached(context)
|
35
|
+
temp = context.uri.dup
|
36
|
+
temp.shift
|
37
|
+
result = $cache
|
38
|
+
until temp.empty?
|
39
|
+
result = result[temp.shift]
|
40
|
+
end
|
41
|
+
if context.uri.length == 3
|
42
|
+
result = result[:all]
|
43
|
+
end
|
44
|
+
result
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.invoke(actions,context)
|
48
|
+
case context.action
|
49
|
+
when :create,:update,:delete
|
50
|
+
result = forward(context.action,context)
|
51
|
+
if context.resource[:write_aware]
|
52
|
+
update_cache(context)
|
53
|
+
end
|
54
|
+
result
|
55
|
+
when :read
|
56
|
+
cached = get_cached(context)
|
57
|
+
unless cached
|
58
|
+
cached = update_cache(context)
|
59
|
+
end
|
60
|
+
cached
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
data/lib/wire.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wire-framework
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.4.
|
4
|
+
version: 0.1.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bryan T. Meyers
|
@@ -160,6 +160,7 @@ files:
|
|
160
160
|
- LICENSE
|
161
161
|
- README.md
|
162
162
|
- lib/app.rb
|
163
|
+
- lib/app/cache.rb
|
163
164
|
- lib/app/db.rb
|
164
165
|
- lib/app/file.rb
|
165
166
|
- lib/app/history.rb
|