shutl_resource 1.7.2 → 1.7.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: 0ddcc271e6cf7f37215c62feb2b2815cafc589b4
4
- data.tar.gz: 5d289b691593e187a2d02dab517ab41df930edef
3
+ metadata.gz: 96b124ecad27867670f5f3df5f9d62edb1201575
4
+ data.tar.gz: 3d9f2c4b25b86d114b9d550e23dc09e4ac5bd608
5
5
  SHA512:
6
- metadata.gz: cfbf27b564aa4ab98cd4af6fe599f277c1baecea7e5e3958003c2c66e93ce8da8dbf57169cadf76529496f48895512bef9ccf32e5eb1ef7ec3be9a36977fe46e
7
- data.tar.gz: 0936ee3c35a6b740f70479d7599f2b3fdbd38240271176e5d681abf339d6f8d00acf9ed9fc0bb10ebce9bff453d68d568d207a5d3422b0bc021afb2adcf00262
6
+ metadata.gz: 272172bd6f2547034e3feef331a5d9711e93e88b0d2244c310e40c452ed26f0fa80d940a93ca963a03686436b0883290e61386f439ac0838b1b40dfcd4c1f2f5
7
+ data.tar.gz: 2adc0178107734fc3f42022d8f3babf562b5c84e01f277e9f3ecaa85709d6cec75372f43d4eaa08a69e21e38e008798454231d605bad789dddeca9a609a3b15a
@@ -28,7 +28,7 @@ module Shutl::Resource
28
28
 
29
29
  module Configuration
30
30
  class << self
31
- attr_accessor :base_uri, :logger
31
+ attr_accessor :base_uri, :logger, :proxy_uri
32
32
 
33
33
  def configure
34
34
  yield self
@@ -2,12 +2,16 @@ require 'open-uri'
2
2
  module Shutl::Resource
3
3
  module RestClassMethods
4
4
 
5
- def base_uri uri
5
+ def base_uri(uri)
6
6
  @base_uri = uri
7
7
  end
8
8
 
9
+ def set_proxy(uri)
10
+ @proxy_uri = uri
11
+ end
12
+
9
13
  def connection
10
- @connection ||= Faraday.new(:url => @base_uri || Shutl::Resource.base_uri) do |faraday|
14
+ @connection ||= Faraday.new(url: target_url, proxy: proxy_url) do |faraday|
11
15
  faraday.request :url_encoded # form-encode POST params
12
16
 
13
17
 
@@ -343,7 +347,7 @@ module Shutl::Resource
343
347
  def generate_url!(url_pattern, args, params = {})
344
348
  url = url_pattern.dup
345
349
 
346
- args, url = replace_args_from_pattern! args, url
350
+ _, url = replace_args_from_pattern! args, url
347
351
 
348
352
  url = URI.escape url
349
353
  params = params.except(:headers, :auth, :from, 'headers', 'auth', 'from')
@@ -359,6 +363,14 @@ module Shutl::Resource
359
363
  !!@order_collection_by
360
364
  end
361
365
 
366
+ def target_url
367
+ @base_uri || Shutl::Resource.base_uri
368
+ end
369
+
370
+ def proxy_url
371
+ @proxy_uri || Shutl::Resource.proxy_uri
372
+ end
373
+
362
374
  private
363
375
  def replace_args_from_pattern! args, url
364
376
  args = args.reject! do |key, value|
@@ -1,5 +1,5 @@
1
1
  module Shutl
2
2
  module Resource
3
- VERSION = '1.7.2'
3
+ VERSION = '1.7.3'
4
4
  end
5
5
  end
@@ -18,7 +18,7 @@ Faraday::Middleware.register_middleware :default_logger => :DefaultLogger
18
18
  module Shutl::Resource
19
19
  extend self
20
20
 
21
- delegate :logger, :logger=, :base_uri, :base_uri=, to: Configuration
21
+ delegate :logger, :logger=, :base_uri, :base_uri=, :proxy_uri, :proxy_uri=, to: Configuration
22
22
 
23
23
  def configure(*args, &block)
24
24
  Configuration.configure(*args, &block)
@@ -1,6 +1,13 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Shutl::Resource do
4
+ after do
5
+ Shutl::Resource.configure do |config|
6
+ config.base_uri = nil
7
+ config.proxy_uri = nil
8
+ end
9
+ end
10
+
4
11
  describe '#configure' do
5
12
  it "allows for configuration of the base uri" do
6
13
  Shutl::Resource.configure do |config|
@@ -8,11 +15,14 @@ describe Shutl::Resource do
8
15
  end
9
16
 
10
17
  Shutl::Resource.base_uri.should == 'base uri'
18
+ end
11
19
 
12
- #set it back to not corrupt other tests
20
+ it "allows for configuration of the proxy uri" do
13
21
  Shutl::Resource.configure do |config|
14
- config.base_uri = nil
22
+ config.proxy_uri = 'proxy uri'
15
23
  end
24
+
25
+ Shutl::Resource.proxy_uri.should == 'proxy uri'
16
26
  end
17
27
  end
18
28
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shutl_resource
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.2
4
+ version: 1.7.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Rouchy
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2014-11-13 00:00:00.000000000 Z
16
+ date: 2014-12-01 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: shutl_auth