eoat 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/eoat/cache/memcached_cache.rb +5 -4
- data/lib/eoat/eve_api.rb +2 -2
- data/lib/eoat/request.rb +6 -7
- data/lib/eoat/result/eve_type.rb +49 -1
- data/lib/eoat/version.rb +1 -1
- data/lib/eoat/zk_api.rb +2 -2
- data/spec/eoat/file_cache_spec.rb +4 -1
- data/spec/eoat/memcached_cache_spec.rb +4 -1
- data/spec/eoat/redis_cache_spec.rb +4 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0def34809c9e1f489c393467806f6cd4ddf98819
|
4
|
+
data.tar.gz: bbed96f4dc56a7022e83229e7cbcde434e3c773e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 167dbbe3a201fa422a098ab97614653cc761e02d40bf0e14035fbd4c3c775c742ecb3c0f65dc5aba718fcca471658fcb1193e95633f9f58ac224950771691e92
|
7
|
+
data.tar.gz: ce32beaa74de1e8ea61800ad0024bb33021de078b73d2d086747134384927c0a74ba47b0bdce321b9b768a10a079db4b47ae2fec7af380e0d4b8ca5591c4e80f
|
@@ -28,8 +28,8 @@ module EOAT
|
|
28
28
|
key = EOAT::Cache.md5hash(host + uri)
|
29
29
|
response = @backend.get(key)
|
30
30
|
if response
|
31
|
-
if EOAT::Cache.md5hash(response
|
32
|
-
return response
|
31
|
+
if EOAT::Cache.md5hash(response) == @backend.get(key + '_hash')
|
32
|
+
return YAML::load(response)
|
33
33
|
else
|
34
34
|
@backend.delete(key)
|
35
35
|
@backend.delete(key + '_hash')
|
@@ -51,14 +51,15 @@ module EOAT
|
|
51
51
|
if expire > 0
|
52
52
|
# Set key as md5 string
|
53
53
|
key = EOAT::Cache.md5hash(host + uri)
|
54
|
+
yaml = content.to_yaml
|
54
55
|
@backend.set(
|
55
56
|
key,
|
56
|
-
|
57
|
+
yaml,
|
57
58
|
:expiry => expire
|
58
59
|
)
|
59
60
|
@backend.set(
|
60
61
|
key + '_hash',
|
61
|
-
EOAT::Cache.md5hash(
|
62
|
+
EOAT::Cache.md5hash(yaml),
|
62
63
|
:expiry => expire
|
63
64
|
)
|
64
65
|
end
|
data/lib/eoat/eve_api.rb
CHANGED
@@ -28,9 +28,9 @@ module EOAT
|
|
28
28
|
# Create an request according to the method called.
|
29
29
|
# This is used to dynamically create api calls.
|
30
30
|
# @return [Object] the result class
|
31
|
-
def method_missing(method, **kwargs)
|
31
|
+
def method_missing(method, cache: true, **kwargs)
|
32
32
|
uri = create_uri(method.id2name, kwargs)
|
33
|
-
EOAT::Request.new(@host, uri, EOAT::Result::EveType::Result).get
|
33
|
+
EOAT::Request.new(@host, uri, EOAT::Result::EveType::Result).get(cache)
|
34
34
|
end
|
35
35
|
|
36
36
|
private
|
data/lib/eoat/request.rb
CHANGED
@@ -29,15 +29,14 @@ module EOAT
|
|
29
29
|
end
|
30
30
|
|
31
31
|
# Method-collector of private methods. Performs basic algorithm of output.
|
32
|
-
def get
|
33
|
-
cache = cache_get
|
32
|
+
def get(cache)
|
34
33
|
if cache
|
35
|
-
|
36
|
-
|
37
|
-
result = @result.new(http_request)
|
38
|
-
cache_save(result)
|
39
|
-
result
|
34
|
+
cache_response = cache_get
|
35
|
+
return(cache_response) if cache_response
|
40
36
|
end
|
37
|
+
response = @result.new(http_request)
|
38
|
+
cache_save(response)
|
39
|
+
response
|
41
40
|
end
|
42
41
|
|
43
42
|
private
|
data/lib/eoat/result/eve_type.rb
CHANGED
@@ -69,6 +69,22 @@ module EOAT
|
|
69
69
|
end
|
70
70
|
end
|
71
71
|
end
|
72
|
+
|
73
|
+
def method_missing(meth, *args, &block)
|
74
|
+
if instance_variable_defined?("@#{meth.to_s}")
|
75
|
+
instance_variable_get("@#{meth.to_s}")
|
76
|
+
else
|
77
|
+
super
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def respond_to?(meth)
|
82
|
+
if instance_variable_defined?("@#{meth.to_s}")
|
83
|
+
true
|
84
|
+
else
|
85
|
+
super
|
86
|
+
end
|
87
|
+
end
|
72
88
|
end
|
73
89
|
|
74
90
|
# Rowset container for xml data.
|
@@ -121,7 +137,7 @@ module EOAT
|
|
121
137
|
# Return first fount Row.
|
122
138
|
# @param [Integer, String] key the value that been search
|
123
139
|
def get(key)
|
124
|
-
index = @entries_index[key]
|
140
|
+
index = @entries_index[key.to_i]
|
125
141
|
if index
|
126
142
|
case index
|
127
143
|
when Array
|
@@ -132,6 +148,22 @@ module EOAT
|
|
132
148
|
end
|
133
149
|
nil
|
134
150
|
end
|
151
|
+
|
152
|
+
def method_missing(meth, *args, &block)
|
153
|
+
if instance_variable_defined?("@#{meth.to_s}")
|
154
|
+
instance_variable_get("@#{meth.to_s}")
|
155
|
+
else
|
156
|
+
super
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
def respond_to?(meth)
|
161
|
+
if instance_variable_defined?("@#{meth.to_s}")
|
162
|
+
true
|
163
|
+
else
|
164
|
+
super
|
165
|
+
end
|
166
|
+
end
|
135
167
|
end
|
136
168
|
|
137
169
|
# Key-values container. All methods generated automatically.
|
@@ -182,6 +214,22 @@ module EOAT
|
|
182
214
|
end
|
183
215
|
end
|
184
216
|
end
|
217
|
+
|
218
|
+
def method_missing(meth, *args, &block)
|
219
|
+
if instance_variable_defined?("@#{meth.to_s}")
|
220
|
+
instance_variable_get("@#{meth.to_s}")
|
221
|
+
else
|
222
|
+
super
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
226
|
+
def respond_to?(meth)
|
227
|
+
if instance_variable_defined?("@#{meth.to_s}")
|
228
|
+
true
|
229
|
+
else
|
230
|
+
super
|
231
|
+
end
|
232
|
+
end
|
185
233
|
end
|
186
234
|
end
|
187
235
|
end
|
data/lib/eoat/version.rb
CHANGED
data/lib/eoat/zk_api.rb
CHANGED
@@ -16,9 +16,9 @@ module EOAT
|
|
16
16
|
|
17
17
|
# Create an request according to the method called.
|
18
18
|
# This is used to dynamically create api calls.
|
19
|
-
def method_missing(method, **kwargs)
|
19
|
+
def method_missing(method, cache: true, **kwargs)
|
20
20
|
uri = create_uri(method.id2name, kwargs)
|
21
|
-
EOAT::Request.new(@host, uri, EOAT::Result::EveType::Result).get
|
21
|
+
EOAT::Request.new(@host, uri, EOAT::Result::EveType::Result).get(cache)
|
22
22
|
end
|
23
23
|
|
24
24
|
# Collect all request parameters and combine it to query string.
|
@@ -13,7 +13,10 @@ describe EOAT::Cache::FileCache do
|
|
13
13
|
EOAT.cache = EOAT::Cache::FileCache.new(
|
14
14
|
File.expand_path(File.join(File.dirname(__FILE__), '..', 'fixtures/cache'))
|
15
15
|
)
|
16
|
-
EOAT::EveApi.new.ErrorList
|
16
|
+
response = EOAT::EveApi.new.ErrorList
|
17
|
+
response.from_cache.should == true
|
18
|
+
response.errors.class.should == EOAT::Result::EveType::RowSet
|
19
|
+
response.errors.get(513).errorCode.should == '513'
|
17
20
|
end
|
18
21
|
|
19
22
|
it 'was return result again from http' do
|
@@ -9,6 +9,9 @@ describe EOAT::Cache::MemcachedCache do
|
|
9
9
|
|
10
10
|
it 'return result from cache' do
|
11
11
|
EOAT.cache = EOAT::Cache::MemcachedCache.new
|
12
|
-
EOAT::EveApi.new.ErrorList
|
12
|
+
response = EOAT::EveApi.new.ErrorList
|
13
|
+
response.from_cache.should == true
|
14
|
+
response.errors.class.should == EOAT::Result::EveType::RowSet
|
15
|
+
response.errors.get(513).errorCode.should == '513'
|
13
16
|
end
|
14
17
|
end
|
@@ -9,6 +9,9 @@ describe EOAT::Cache::RedisCache do
|
|
9
9
|
|
10
10
|
it 'return result from cache' do
|
11
11
|
EOAT.cache = EOAT::Cache::RedisCache.new
|
12
|
-
EOAT::EveApi.new.ErrorList
|
12
|
+
response = EOAT::EveApi.new.ErrorList
|
13
|
+
response.from_cache.should == true
|
14
|
+
response.errors.class.should == EOAT::Result::EveType::RowSet
|
15
|
+
response.errors.get(513).errorCode.should == '513'
|
13
16
|
end
|
14
17
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eoat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ivan Kotov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-10-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|