quintype 0.0.10 → 0.0.11

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: '0287b1b423facb37184a57dba69a5d6d55ab51cf'
4
- data.tar.gz: ecab515fafee3dd23ba15b0b24cc36acc8efbabd
3
+ metadata.gz: 24fc217ce09f1cb4bdefb0799585ef30f769c9ba
4
+ data.tar.gz: 5c3941c16e5b841dd1571a75511d6b237b74c299
5
5
  SHA512:
6
- metadata.gz: 17e34a6cd0641bef5cbb90ba1c8922400dcc1c0ecfed3d375daec1c050384e7c036bedd0e56610f9fcfdbb8943ad2018724c41ce42b21bde11b480e5ee53106e
7
- data.tar.gz: be0da5cc89a320bc48cf11b2d72804a797c3370552ca289125da5bb5408f395f3dafa1dc23efb7b6da13907daf04eae04f12e175a97aabee02bf92d448f09be7
6
+ metadata.gz: c1ea1563227cf39ba704d99b17fa0d7ae852fab8f76c38782d29f69a290f5bfcbeed217000aeb11c59c116570cc220dba3b36b1ceab6451e6b18b1204529526b
7
+ data.tar.gz: 824c94d1f7eb35547e84f235d5a5e3529b6e55aa1ece322ebc6d2fb5540e55faebb0ae05cf79eced3e7ed7a01ddac9e1e1716fd239e187e63d7ba4f0ec89137b
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- quintype (0.0.10)
4
+ quintype (0.0.11)
5
5
  activesupport (~> 4.2)
6
6
  faraday (~> 0.9)
7
7
 
@@ -25,18 +25,26 @@ class API
25
25
  end
26
26
 
27
27
  def bulk_cached(params)
28
+ response_body = nil # Used in case of manticore auto following redirect. Ugly side effect
29
+
28
30
  location = @@bulk_cache.fetch(params) do |params|
29
31
  response = @@conn.post(@@api_base + "bulk-request", params) do |request|
30
32
  request.headers['Content-Type'] = 'application/json'
31
33
  request.body = params.to_json
32
34
  end
35
+
33
36
  if response.status == 303 && response.headers["Location"]
34
37
  response.headers["Location"]
38
+ elsif response.status == 200 && response.headers["Content-Location"]
39
+ response_body = keywordize(JSON.parse(response.body))
40
+ log_warning("The faraday adapter is configured to follow redirects by default. Using the Content-Location header")
41
+ response.headers["Content-Location"]
35
42
  else
36
43
  raise "Did not recieve a location header, status #{response.status}"
37
44
  end
38
45
  end
39
- _get(location.sub(/^\/api\//, ""))
46
+
47
+ response_body || _get(location.sub(/^\/api\//, ""))
40
48
  end
41
49
 
42
50
  def config
@@ -265,5 +273,10 @@ class API
265
273
  def make_fields(arr)
266
274
  arr.join(',') if arr.present?
267
275
  end
276
+
277
+ def log_warning(*args)
278
+ return unless defined?(Rails)
279
+ Rails.logger.warn(*args)
280
+ end
268
281
  end
269
282
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'quintype'
3
- s.version = '0.0.10'
3
+ s.version = '0.0.11'
4
4
  s.date = '2016-02-19'
5
5
  s.summary = "quintype!"
6
6
  s.platform = Gem::Platform::RUBY
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quintype
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - ''