attune 1.0.2 → 1.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 72c7246f1cc247ce77f93171fd082005a189ad88
4
- data.tar.gz: c8bac31b37aa6d41914d4e3bf3ddcd8df46b4bbb
3
+ metadata.gz: 3bcafd086e89663973f17106d28c4a1b198c32bf
4
+ data.tar.gz: 6321361a8d4d7b362d117810745ac2d1898959d8
5
5
  SHA512:
6
- metadata.gz: f1ed5785966bc47a9c689735e4b459e295e49d5a3eb1f038adafc87e6bc9de462c0c53bcb05b76f4ef5d7c1752500c930d0e67bd5d8636a2a4459a94da3d1e2f
7
- data.tar.gz: 79c8838e7273852fd7908cf9e5adfba6dd0706174582798fc85b2af3a7df163ed18428f13f2119436a9356b142297d8c1c3801a5384e067cee2a040e49e7a277
6
+ metadata.gz: 19d522512f5bfe0458c0f3e8abf15a130920c0d1934e40c59bd0116c380813dc17db49c79fcbd15960364c07b65b10f5092aafbdd8377c2f9284d6d078dbb109
7
+ data.tar.gz: 84564a663fd330b4d94bad07bd32410725baab5da48dfa259dc44509d6c11968911e288c21fdb7019f658006f3d5f45b33aada520e58eea3001cd58d3bd53e86
data/Gemfile CHANGED
@@ -6,3 +6,5 @@ gem 'guard-rspec'
6
6
  gem 'pry'
7
7
  gem 'pry-rescue'
8
8
  gem 'pry-stack_explorer'
9
+
10
+ gem "faraday", "~> 0.8.9"
data/attune.gemspec CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_dependency "faraday", "~> 0.9.0"
21
+ spec.add_dependency "faraday", "~> 0.8"
22
22
  spec.add_dependency "net-http-persistent"
23
23
 
24
24
  spec.add_development_dependency "bundler", "~> 1.2"
data/lib/attune/client.rb CHANGED
@@ -201,10 +201,10 @@ module Attune
201
201
  def encoded_ranking_params(options)
202
202
  params = {
203
203
  anonymous: options.fetch(:id),
204
- view: options.fetch(:view),
205
- entity_collection: options.fetch(:collection),
206
204
  entities: options.fetch(:entities).join(','),
207
- ip: options.fetch(:ip, 'none')
205
+ entity_collection: options.fetch(:collection),
206
+ ip: options.fetch(:ip, 'none'),
207
+ view: options.fetch(:view)
208
208
  }
209
209
  Faraday::Utils::ParamsHash[params].to_query
210
210
  end
@@ -253,12 +253,7 @@ module Attune
253
253
 
254
254
  def adapter
255
255
  raise DisabledException if disabled?
256
- Faraday.new(url: endpoint, builder: middleware) do |connection|
257
- connection.options.timeout = timeout
258
-
259
- # Needed for encoding of BATCH GET requests
260
- connection.options.params_encoder = Faraday::FlatParamsEncoder
261
-
256
+ Faraday.new(url: endpoint, builder: middleware, request: {timeout: timeout}) do |connection|
262
257
  connection.authorization :Bearer, auth_token unless !auth_token
263
258
  end
264
259
  end
@@ -1,3 +1,4 @@
1
+ require 'attune/param_flattener'
1
2
  require "attune/call_dropping"
2
3
  require "attune/json_logger"
3
4
  require "attune/net_http_persistent"
@@ -12,7 +13,10 @@ module Attune
12
13
  # user our version of NetHttpPersistent adapter
13
14
  Faraday::Adapter.register_middleware(attune_http_persistent: NetHttpPersistent)
14
15
 
15
- MIDDLEWARE = Faraday::RackBuilder.new do |builder|
16
+ MIDDLEWARE = Faraday::Builder.new do |builder|
17
+ # Needed for encoding of BATCH GET requests
18
+ builder.use Attune::ParamFlattener
19
+
16
20
  # Log all requests
17
21
  builder.use Attune::CallDropping
18
22
 
@@ -0,0 +1,17 @@
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
@@ -1,3 +1,3 @@
1
1
  module Attune
2
- VERSION = "1.0.2"
2
+ VERSION = "1.0.3"
3
3
  end
@@ -18,7 +18,8 @@ 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::RackBuilder.new do |builder|
21
+ Faraday::Builder.new do |builder|
22
+ builder.use Attune::ParamFlattener
22
23
  builder.adapter :test, stubs
23
24
  end
24
25
  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: 1.0.2
4
+ version: 1.0.3
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-26 00:00:00.000000000 Z
11
+ date: 2014-04-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ~>
18
18
  - !ruby/object:Gem::Version
19
- version: 0.9.0
19
+ version: '0.8'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ~>
25
25
  - !ruby/object:Gem::Version
26
- version: 0.9.0
26
+ version: '0.8'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: net-http-persistent
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -145,6 +145,7 @@ files:
145
145
  - lib/attune/default.rb
146
146
  - lib/attune/json_logger.rb
147
147
  - lib/attune/net_http_persistent.rb
148
+ - lib/attune/param_flattener.rb
148
149
  - lib/attune/version.rb
149
150
  - spec/attune/call_dropping_spec.rb
150
151
  - spec/attune/client_spec.rb