loquor 0.7.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/README.md +2 -0
- data/lib/loquor/api_calls/index.rb +10 -1
- data/lib/loquor/configuration.rb +3 -2
- data/lib/loquor/version.rb +1 -1
- data/test/api_calls/index_test.rb +9 -0
- data/test/configuration_test.rb +11 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 28dd6aeff0ac0f2ded967b9dd124469cc0762619
|
4
|
+
data.tar.gz: e23c26471f5cc34d54594273f3636b642117d99e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cdd7ab5e8e4dce7118a558add6f02621117aaad7836fb468b642ed83fec5cea250f6e85965f2665a042cc9057318cf01cddf943890e7ef785f9c511375a11d25
|
7
|
+
data.tar.gz: 9a210c1b605c2ee3c54a2c30b3c0df378c02ed40677a36e1139b90a05ffbcaf6cd2301d4f10eeb754af2a4ea43ae333546f0d584990de9a26fc1f4c22d70aa5a
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -26,6 +26,8 @@ Loquor.config do |config|
|
|
26
26
|
config.access_id = "Username"
|
27
27
|
config.secret_key = "SecretKey1929292"
|
28
28
|
config.endpoint = "http://www.meducation.net"
|
29
|
+
config.substitute_values[true] = ":__true__"
|
30
|
+
config.substitute_values[false] = ":__false__"
|
29
31
|
end
|
30
32
|
```
|
31
33
|
|
@@ -52,6 +52,16 @@ module Loquor
|
|
52
52
|
def generate_url
|
53
53
|
query_string = []
|
54
54
|
@criteria.each do |key,value|
|
55
|
+
add_criteria(query_string, key, value)
|
56
|
+
end
|
57
|
+
"#{klass.path}?#{query_string.join("&")}"
|
58
|
+
end
|
59
|
+
|
60
|
+
def add_criteria(query_string, key, value)
|
61
|
+
substitute_value = Loquor.config.substitute_values[value]
|
62
|
+
if !substitute_value.nil?
|
63
|
+
query_string << "#{key}=#{URI.encode(substitute_value)}"
|
64
|
+
else
|
55
65
|
case value
|
56
66
|
when String, Symbol, Numeric
|
57
67
|
query_string << "#{key}=#{URI.encode(value.to_s)}"
|
@@ -63,7 +73,6 @@ module Loquor
|
|
63
73
|
raise LoquorError.new("Filter values must be strings or arrays.")
|
64
74
|
end
|
65
75
|
end
|
66
|
-
"#{klass.path}?#{query_string.join("&")}"
|
67
76
|
end
|
68
77
|
end
|
69
78
|
end
|
data/lib/loquor/configuration.rb
CHANGED
@@ -7,7 +7,7 @@ module Loquor
|
|
7
7
|
class Configuration
|
8
8
|
|
9
9
|
SETTINGS = [
|
10
|
-
:logger, :access_id, :secret_key, :endpoint
|
10
|
+
:logger, :access_id, :secret_key, :endpoint, :substitute_values
|
11
11
|
]
|
12
12
|
|
13
13
|
attr_writer *SETTINGS
|
@@ -17,7 +17,8 @@ module Loquor
|
|
17
17
|
Filum.config do |config|
|
18
18
|
config.logfile = "./log/loquor.log"
|
19
19
|
end
|
20
|
-
logger = Filum.logger
|
20
|
+
self.logger = Filum.logger
|
21
|
+
self.substitute_values = {}
|
21
22
|
end
|
22
23
|
|
23
24
|
SETTINGS.each do |setting|
|
data/lib/loquor/version.rb
CHANGED
@@ -74,6 +74,15 @@ module Loquor
|
|
74
74
|
assert url.include?("thing[]=bar")
|
75
75
|
end
|
76
76
|
|
77
|
+
def test_uses_correct_replacement_strings_in_query
|
78
|
+
Loquor.config.substitute_values[true] = ":__true__"
|
79
|
+
criteria = {thing: true}
|
80
|
+
searcher = ApiCall::Index.new(resource).where(criteria)
|
81
|
+
searcher.stubs(path: "foobar")
|
82
|
+
url = searcher.send(:generate_url)
|
83
|
+
assert url.include?("thing=:__true__")
|
84
|
+
end
|
85
|
+
|
77
86
|
def test_that_iterating_calls_results
|
78
87
|
searcher = ApiCall::Index.new(resource).where(name: "star_wars")
|
79
88
|
searcher.expects(results: [])
|
data/test/configuration_test.rb
CHANGED
@@ -37,6 +37,17 @@ module Loquor
|
|
37
37
|
assert_equal endpoint, Loquor.config.endpoint
|
38
38
|
end
|
39
39
|
|
40
|
+
def test_substitute_values
|
41
|
+
substitute_values = {foo: 'bar'}
|
42
|
+
Loquor.config.substitute_values = substitute_values
|
43
|
+
assert_equal substitute_values, Loquor.config.substitute_values
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_substitute_values_writable
|
47
|
+
Loquor.config.substitute_values[:foo] = "bar"
|
48
|
+
assert_equal "bar", Loquor.config.substitute_values[:foo]
|
49
|
+
end
|
50
|
+
|
40
51
|
def test_missing_access_id_throws_exception
|
41
52
|
assert_raises(LoquorConfigurationError) do
|
42
53
|
Loquor.config.access_id
|