loquor 1.2.1 → 1.3.0
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/CHANGELOG.md +3 -0
- data/lib/loquor/api_calls/index.rb +18 -4
- data/lib/loquor/http_actions/get.rb +2 -2
- data/lib/loquor/version.rb +1 -1
- data/test/api_calls/index_test.rb +12 -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: 0ad76c89016157ae20f02505acbda23ca0cc3617
|
4
|
+
data.tar.gz: 277e5922c2a7b41053fececa763bf96fd1001e21
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 87967e954097c11795e7cc931b77f955974b08a24a7c31fdf32069a6378ff2597f7ddb3339522f34903de510e6488f59b1f8254bfa157bfe671669b26bfa168c
|
7
|
+
data.tar.gz: 497f582435455dd8eabe8e3f2262872a3e53a77186a86684b5ff80f17931fba86ab7ba87f036c9b1edc97f58fa93af5f9728f42fa2dbe9337d3a167c99dde456
|
data/CHANGELOG.md
CHANGED
@@ -1,16 +1,22 @@
|
|
1
1
|
module Loquor
|
2
2
|
class ApiCall::Index < ApiCall
|
3
3
|
|
4
|
-
attr_reader :criteria
|
4
|
+
attr_reader :criteria, :clauses
|
5
5
|
|
6
6
|
def initialize(klass)
|
7
7
|
super(klass)
|
8
8
|
@criteria = {}
|
9
|
+
@clauses = []
|
9
10
|
end
|
10
11
|
|
11
|
-
def where(
|
12
|
-
|
13
|
-
|
12
|
+
def where(data)
|
13
|
+
case data
|
14
|
+
when String
|
15
|
+
@clauses << data
|
16
|
+
else
|
17
|
+
data.each do |key, value|
|
18
|
+
@criteria[key] = value
|
19
|
+
end
|
14
20
|
end
|
15
21
|
self
|
16
22
|
end
|
@@ -54,6 +60,10 @@ module Loquor
|
|
54
60
|
@criteria.each do |key,value|
|
55
61
|
add_criteria(query_string, key, value)
|
56
62
|
end
|
63
|
+
@clauses.each do |clause|
|
64
|
+
add_clause(query_string, clause)
|
65
|
+
end
|
66
|
+
|
57
67
|
"#{klass.path}?#{query_string.join("&")}"
|
58
68
|
end
|
59
69
|
|
@@ -78,5 +88,9 @@ module Loquor
|
|
78
88
|
end
|
79
89
|
end
|
80
90
|
end
|
91
|
+
|
92
|
+
def add_clause(query_string, clause)
|
93
|
+
query_string << "clauses[]=#{URI.encode(clause.to_s)}"
|
94
|
+
end
|
81
95
|
end
|
82
96
|
end
|
@@ -14,7 +14,7 @@ module Loquor
|
|
14
14
|
@config.logger.info "Response: #{response}"
|
15
15
|
response
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
def execute_against_cache
|
19
19
|
cache = @config.cache
|
20
20
|
if cache
|
@@ -26,7 +26,7 @@ module Loquor
|
|
26
26
|
val
|
27
27
|
else
|
28
28
|
execute
|
29
|
-
end
|
29
|
+
end
|
30
30
|
end
|
31
31
|
|
32
32
|
private
|
data/lib/loquor/version.rb
CHANGED
@@ -14,6 +14,12 @@ module Loquor
|
|
14
14
|
assert_equal({fields: fields}, searcher.criteria)
|
15
15
|
end
|
16
16
|
|
17
|
+
def test_where_sets_clauses
|
18
|
+
clause = "WHERE 1 = 1"
|
19
|
+
searcher = ApiCall::Index.new(resource).where(clause)
|
20
|
+
assert_equal([clause], searcher.clauses)
|
21
|
+
end
|
22
|
+
|
17
23
|
def test_where_sets_criteria
|
18
24
|
criteria = {genre: 'Animation'}
|
19
25
|
searcher = ApiCall::Index.new(resource).where(criteria)
|
@@ -34,7 +40,12 @@ module Loquor
|
|
34
40
|
assert_equal({genre: "Action"}, searcher.criteria)
|
35
41
|
end
|
36
42
|
|
37
|
-
def
|
43
|
+
def test_where_gets_correct_url_with_clauses
|
44
|
+
searcher = ApiCall::Index.new(resource).where("WHERE 1=1")
|
45
|
+
assert searcher.send(:generate_url).include? "?clauses[]=WHERE%201=1"
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_where_gets_correct_url_with_crtieria
|
38
49
|
searcher = ApiCall::Index.new(resource).where(name: 'Star Wars')
|
39
50
|
assert searcher.send(:generate_url).include? "?name=Star%20Wars"
|
40
51
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: loquor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Walker
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: filum
|