loquor 1.5.0 → 1.6.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 +13 -5
- data/CHANGELOG.md +4 -0
- data/lib/loquor.rb +4 -0
- data/lib/loquor/api_call.rb +1 -0
- data/lib/loquor/api_calls/destroy.rb +13 -0
- data/lib/loquor/api_calls/index.rb +2 -2
- data/lib/loquor/client.rb +5 -0
- data/lib/loquor/http_action.rb +1 -0
- data/lib/loquor/http_actions/delete.rb +31 -0
- data/lib/loquor/resource.rb +4 -0
- data/lib/loquor/version.rb +1 -1
- data/test/api_calls/destroy_test.rb +15 -0
- data/test/api_calls/index_test.rb +15 -0
- data/test/client_test.rb +7 -0
- data/test/http_actions/delete_test.rb +27 -0
- data/test/resource_test.rb +6 -0
- metadata +14 -9
checksums.yaml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
Nzc1YzA3OTlhOGVlZWQ1YTMzYzkwNjVjN2QzZjcyOGJjYzExNDFmYw==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NWYwNTc3MTRlOTBjZTU5MWMzNzE2YjI0OGMzZTUzZTFlZDViNjc1Yw==
|
5
7
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
ZmQxODJlYTdmZTNkOTU5ZTE0ZDY1YmVhNjA0MDVhMTMyOTFmZTRjOWE1M2I5
|
10
|
+
ZDQxY2JmNDZlOThkYWExYWZjNzk2ZTBiODZkNGI2YzgxNjNjYjU2OTU5NWU1
|
11
|
+
NmE0MzI5YmNlMzYwYzgxZjY2NjhiMjFkY2FmMTUxZWVhN2JiMGQ=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
OGFlZmEwMjY2YmVkZmIxMjIzY2RhYWMwZjYxYzkwNGE0NjNhNTJhOTA0YjFi
|
14
|
+
Yzg3Yzk1ODU2ZDAzNGUyYmVjZGE1MjU2NTE4ZGVmZjBhZGM1OTFkZjBhN2Yz
|
15
|
+
NDAzZWRiN2JjMTllNTcyODY5M2Y5ZTVkNDY3N2FhZDAzMTNjM2Y=
|
data/CHANGELOG.md
CHANGED
data/lib/loquor.rb
CHANGED
data/lib/loquor/api_call.rb
CHANGED
@@ -73,7 +73,7 @@ module Loquor
|
|
73
73
|
query_string << "#{key}=#{URI.encode(substitute_value)}"
|
74
74
|
else
|
75
75
|
case value
|
76
|
-
when String, Symbol, Numeric
|
76
|
+
when String, Symbol, Numeric, Date, Time, DateTime
|
77
77
|
query_string << "#{key}=#{URI.encode(value.to_s)}"
|
78
78
|
when Array
|
79
79
|
value.each do |v|
|
@@ -84,7 +84,7 @@ module Loquor
|
|
84
84
|
query_string << "#{key}[#{k}]=#{URI.encode(v.to_s)}"
|
85
85
|
end
|
86
86
|
else
|
87
|
-
raise LoquorError.new("Filter values must be strings, arrays or single-depth hashes.")
|
87
|
+
raise LoquorError.new("Filter values must be strings, arrays, date, time, datetime or single-depth hashes.")
|
88
88
|
end
|
89
89
|
end
|
90
90
|
end
|
data/lib/loquor/client.rb
CHANGED
data/lib/loquor/http_action.rb
CHANGED
@@ -0,0 +1,31 @@
|
|
1
|
+
module Loquor
|
2
|
+
class HttpAction::Delete < HttpAction
|
3
|
+
def self.delete(url, deps)
|
4
|
+
new(url, deps).delete
|
5
|
+
end
|
6
|
+
|
7
|
+
def initialize(url, deps)
|
8
|
+
super(url, deps)
|
9
|
+
end
|
10
|
+
|
11
|
+
def delete
|
12
|
+
@config.logger.info "Making DELETE request to: #{full_url}"
|
13
|
+
response = JSON.parse(signed_request.execute)
|
14
|
+
@config.logger.info "Signed request executed. Response: #{response}"
|
15
|
+
response
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def request
|
21
|
+
RestClient::Request.new(url: full_url,
|
22
|
+
accept: :json,
|
23
|
+
headers: {'Content-type' => 'application/json'},
|
24
|
+
method: :delete)
|
25
|
+
end
|
26
|
+
|
27
|
+
def full_url
|
28
|
+
"#{@config.endpoint}#{@url}"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/loquor/resource.rb
CHANGED
data/lib/loquor/version.rb
CHANGED
@@ -0,0 +1,15 @@
|
|
1
|
+
require File.expand_path('../../test_helper', __FILE__)
|
2
|
+
|
3
|
+
module Loquor
|
4
|
+
class ApiCall::DestroyTest < Minitest::Test
|
5
|
+
def test_delete_is_called_correctly
|
6
|
+
klass = mock
|
7
|
+
klass.stubs(new: nil)
|
8
|
+
klass.stubs(path: "/foobar")
|
9
|
+
id = 5
|
10
|
+
Loquor.expects(:delete).with("#{klass.path}/#{id}")
|
11
|
+
ApiCall::Destroy.new(klass, id).execute
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
@@ -55,6 +55,21 @@ module Loquor
|
|
55
55
|
assert searcher.send(:generate_url).include? "?name=star"
|
56
56
|
end
|
57
57
|
|
58
|
+
def test_where_gets_correct_url_with_date
|
59
|
+
searcher = ApiCall::Index.new(resource).where(name: Date.new(1969,5,10))
|
60
|
+
assert searcher.send(:generate_url).include? "?name=1969-05-10"
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_where_gets_correct_url_with_time
|
64
|
+
searcher = ApiCall::Index.new(resource).where(name: Time.new(1969,5,10,13,10))
|
65
|
+
assert searcher.send(:generate_url).include? "?name=1969-05-10%2013:10:00"
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_where_gets_correct_url_with_date_time
|
69
|
+
searcher = ApiCall::Index.new(resource).where(name: DateTime.new(1969,5,10,13,10))
|
70
|
+
assert searcher.send(:generate_url).include? "?name=1969-05-10T13:10:00"
|
71
|
+
end
|
72
|
+
|
58
73
|
def test_where_gets_correct_url_with_number
|
59
74
|
searcher = ApiCall::Index.new(resource).where(name: 1)
|
60
75
|
assert searcher.send(:generate_url).include? "?name=1"
|
data/test/client_test.rb
CHANGED
@@ -36,6 +36,13 @@ module Loquor
|
|
36
36
|
client.post(url, payload)
|
37
37
|
end
|
38
38
|
|
39
|
+
def test_delete_calls_deletes
|
40
|
+
url = "foobar"
|
41
|
+
client = Client.new
|
42
|
+
deps = {config: client.config}
|
43
|
+
HttpAction::Delete.expects(:delete).with(url, deps)
|
44
|
+
client.delete(url)
|
45
|
+
end
|
39
46
|
|
40
47
|
def test_get_calls_gets_with_cache_flag
|
41
48
|
url = "foobar"
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require File.expand_path('../../test_helper', __FILE__)
|
2
|
+
|
3
|
+
module Loquor
|
4
|
+
class HttpAction::DeleteTest < HttpAction::Test
|
5
|
+
def test_delete_should_call_new
|
6
|
+
url = "foobar"
|
7
|
+
deps = {x: true}
|
8
|
+
HttpAction::Delete.expects(:new).with(url, deps).returns(mock(delete: nil))
|
9
|
+
HttpAction::Delete.delete(url, deps)
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_delete_should_call_put
|
13
|
+
HttpAction::Delete.any_instance.expects(:delete)
|
14
|
+
HttpAction::Delete.delete("foobar", {})
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_request_is_signed_correctly
|
18
|
+
puts = HttpAction::Delete.new("", deps)
|
19
|
+
request = RestClient::Request.new(url: "http://localhost:3000", method: :delete)
|
20
|
+
puts.expects(request: request)
|
21
|
+
ApiAuth.expects(:sign!).with(request, @access_id, @secret_key)
|
22
|
+
puts.send(:signed_request)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
|
data/test/resource_test.rb
CHANGED
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.6.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-
|
11
|
+
date: 2014-03-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: filum
|
@@ -84,28 +84,28 @@ dependencies:
|
|
84
84
|
name: mocha
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - '>='
|
87
|
+
- - ! '>='
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - '>='
|
94
|
+
- - ! '>='
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: rake
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- - '>='
|
101
|
+
- - ! '>='
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '0'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- - '>='
|
108
|
+
- - ! '>='
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
description: An API dispatcher for Meducation
|
@@ -125,12 +125,14 @@ files:
|
|
125
125
|
- lib/loquor.rb
|
126
126
|
- lib/loquor/api_call.rb
|
127
127
|
- lib/loquor/api_calls/create.rb
|
128
|
+
- lib/loquor/api_calls/destroy.rb
|
128
129
|
- lib/loquor/api_calls/index.rb
|
129
130
|
- lib/loquor/api_calls/show.rb
|
130
131
|
- lib/loquor/api_calls/update.rb
|
131
132
|
- lib/loquor/client.rb
|
132
133
|
- lib/loquor/configuration.rb
|
133
134
|
- lib/loquor/http_action.rb
|
135
|
+
- lib/loquor/http_actions/delete.rb
|
134
136
|
- lib/loquor/http_actions/get.rb
|
135
137
|
- lib/loquor/http_actions/post.rb
|
136
138
|
- lib/loquor/http_actions/put.rb
|
@@ -140,12 +142,14 @@ files:
|
|
140
142
|
- lib/loquor/resource_mock.rb
|
141
143
|
- lib/loquor/version.rb
|
142
144
|
- loquor.gemspec
|
145
|
+
- test/api_calls/destroy_test.rb
|
143
146
|
- test/api_calls/index_test.rb
|
144
147
|
- test/api_calls/show_test.rb
|
145
148
|
- test/api_calls/update_test.rb
|
146
149
|
- test/client_test.rb
|
147
150
|
- test/configuration_test.rb
|
148
151
|
- test/http_action_test.rb
|
152
|
+
- test/http_actions/delete_test.rb
|
149
153
|
- test/http_actions/get_test.rb
|
150
154
|
- test/http_actions/post_test.rb
|
151
155
|
- test/http_actions/put_test.rb
|
@@ -164,12 +168,12 @@ require_paths:
|
|
164
168
|
- lib
|
165
169
|
required_ruby_version: !ruby/object:Gem::Requirement
|
166
170
|
requirements:
|
167
|
-
- - '>='
|
171
|
+
- - ! '>='
|
168
172
|
- !ruby/object:Gem::Version
|
169
173
|
version: '0'
|
170
174
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
171
175
|
requirements:
|
172
|
-
- - '>='
|
176
|
+
- - ! '>='
|
173
177
|
- !ruby/object:Gem::Version
|
174
178
|
version: '0'
|
175
179
|
requirements: []
|
@@ -179,12 +183,14 @@ signing_key:
|
|
179
183
|
specification_version: 4
|
180
184
|
summary: This library dispatches requests to Meducation
|
181
185
|
test_files:
|
186
|
+
- test/api_calls/destroy_test.rb
|
182
187
|
- test/api_calls/index_test.rb
|
183
188
|
- test/api_calls/show_test.rb
|
184
189
|
- test/api_calls/update_test.rb
|
185
190
|
- test/client_test.rb
|
186
191
|
- test/configuration_test.rb
|
187
192
|
- test/http_action_test.rb
|
193
|
+
- test/http_actions/delete_test.rb
|
188
194
|
- test/http_actions/get_test.rb
|
189
195
|
- test/http_actions/post_test.rb
|
190
196
|
- test/http_actions/put_test.rb
|
@@ -193,4 +199,3 @@ test_files:
|
|
193
199
|
- test/resource_mock_test.rb
|
194
200
|
- test/resource_test.rb
|
195
201
|
- test/test_helper.rb
|
196
|
-
has_rdoc:
|