attune 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aa77fa0fcbd44e02a0b3a26e722a76f3e7fabbff
4
- data.tar.gz: bc15acc01376c94db3192f81a90d114aa6040e91
3
+ metadata.gz: 45c59186f1dcdeca6c980301341d727d19de096a
4
+ data.tar.gz: ea00f9ff82b7b97f16b47eaebf4da9c0d02312fb
5
5
  SHA512:
6
- metadata.gz: 04272c55ef9a1f7095a2e77beaf008451aa73bf115fc5f99cf791f34e76e1dad2ffda8c3f1fde06b40203530fd6643822c563bd389772430b1f3ec9dbcb04b34
7
- data.tar.gz: b95899dd52c6d526944569c775bfae2e942bfda23766b346792bfb68f28a0c6bc1103055ae9f5e86f1199842b788719348ef24f49d6fb888b2ba4585ce0600e6
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
- conn = Faraday.new(url: endpoint, builder: middleware, request: {timeout: timeout})
243
- conn.authorization :Bearer, auth_token unless !auth_token
244
- conn
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
@@ -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::Builder.new do |builder|
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
 
@@ -1,3 +1,3 @@
1
1
  module Attune
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -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::Builder.new do |builder|
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
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-18 00:00:00.000000000 Z
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