attune 0.0.4 → 0.0.5
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/attune/client.rb +8 -3
- data/lib/attune/default.rb +1 -5
- data/lib/attune/version.rb +1 -1
- data/spec/attune/client_spec.rb +1 -2
- metadata +2 -3
- data/lib/attune/param_flattener.rb +0 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 45c59186f1dcdeca6c980301341d727d19de096a
|
4
|
+
data.tar.gz: ea00f9ff82b7b97f16b47eaebf4da9c0d02312fb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce5686a15ec87759aec89f089bed2f5b928411436b277c70d686e007476738a0c05231092650d2e1e2358e9d3729389b84df6f0fbd1e01f066fabe24a8074123
|
7
|
+
data.tar.gz: c8522c490bfb68816751ced0bb971568baf5975f9653f16b4d7c21af7fe745e64e15aba851f9b0bdecd3d52013519fb8b42fc2caf1ce680107a0c85514ad9f81
|
data/lib/attune/client.rb
CHANGED
@@ -239,9 +239,14 @@ module Attune
|
|
239
239
|
|
240
240
|
def adapter
|
241
241
|
raise DisabledException if disabled?
|
242
|
-
|
243
|
-
|
244
|
-
|
242
|
+
Faraday.new(url: endpoint, builder: middleware) do |connection|
|
243
|
+
connection.options.timeout = timeout
|
244
|
+
|
245
|
+
# Needed for encoding of BATCH GET requests
|
246
|
+
connection.options.params_encoder = Faraday::FlatParamsEncoder
|
247
|
+
|
248
|
+
connection.authorization :Bearer, auth_token unless !auth_token
|
249
|
+
end
|
245
250
|
end
|
246
251
|
end
|
247
252
|
end
|
data/lib/attune/default.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'attune/param_flattener'
|
2
1
|
require "attune/call_dropping"
|
3
2
|
require "attune/json_logger"
|
4
3
|
|
@@ -9,10 +8,7 @@ module Attune
|
|
9
8
|
|
10
9
|
ENDPOINT = "http://localhost/".freeze
|
11
10
|
|
12
|
-
MIDDLEWARE = Faraday::
|
13
|
-
# Needed for encoding of BATCH GET requests
|
14
|
-
builder.use Attune::ParamFlattener
|
15
|
-
|
11
|
+
MIDDLEWARE = Faraday::RackBuilder.new do |builder|
|
16
12
|
# Log all requests
|
17
13
|
builder.use Attune::CallDropping
|
18
14
|
|
data/lib/attune/version.rb
CHANGED
data/spec/attune/client_spec.rb
CHANGED
@@ -18,8 +18,7 @@ describe Attune::Client do
|
|
18
18
|
let(:options){ {endpoint: 'http://example.com:8080/', middleware: middleware} }
|
19
19
|
let(:stubs) { Faraday::Adapter::Test::Stubs.new }
|
20
20
|
let(:middleware) do
|
21
|
-
Faraday::
|
22
|
-
builder.use Attune::ParamFlattener
|
21
|
+
Faraday::RackBuilder.new do |builder|
|
23
22
|
builder.adapter :test, stubs
|
24
23
|
end
|
25
24
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: attune
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Hawthorn
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -130,7 +130,6 @@ files:
|
|
130
130
|
- lib/attune/configurable.rb
|
131
131
|
- lib/attune/default.rb
|
132
132
|
- lib/attune/json_logger.rb
|
133
|
-
- lib/attune/param_flattener.rb
|
134
133
|
- lib/attune/version.rb
|
135
134
|
- spec/attune/call_dropping_spec.rb
|
136
135
|
- spec/attune/client_spec.rb
|
@@ -1,17 +0,0 @@
|
|
1
|
-
module Attune
|
2
|
-
# Faraday 0.8 can't make resuests like /?ids=123&ids=456 and forces the form
|
3
|
-
# /?ids[]=123&ids[]=456 (this is fixed in faraday 0.9)
|
4
|
-
#
|
5
|
-
# Fortunately faraday's middleware is quite powerful. This just strips the
|
6
|
-
# array syntax from the request.
|
7
|
-
class ParamFlattener < Faraday::Middleware
|
8
|
-
def call(env)
|
9
|
-
url = env[:url]
|
10
|
-
|
11
|
-
# replaces ?foo[]=123 with ?foo=123
|
12
|
-
url.query = url.query.gsub('%5B%5D', '') if url.query
|
13
|
-
|
14
|
-
@app.call(env)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|