puppet_forge 2.2.3 → 2.2.4

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: 9d3ac1386618a86886bcc242c9cf8899241b7480
4
- data.tar.gz: 9042c6e51d0fcfeb1ff492fb125dc35a4a19702c
3
+ metadata.gz: 052203624976cb87f491f5f75bdc25b1c0d2b4e3
4
+ data.tar.gz: 9c0fcd86efb6afd798b47391738af47f99837f8e
5
5
  SHA512:
6
- metadata.gz: 755007e1ac00c2209976755d3891ee18c8c2e63a2e2f0aa4bdbe22f64a18bf9c847f288aab30c418dfb61432df5e03b5bc76a32111df1908f98e38cf45ccde37
7
- data.tar.gz: 8557b39ff685e758b9550df9a5c55c01a707079cc7a1e345df6786a099bcc5fd17ed980a3b210b0a42f93d9f14b30205acaa071f21e3037eca548e8fccab42fc
6
+ metadata.gz: af53aa35169471736552e69d98c4d84dbb17d5710f46af80301e2f062c181b509343f0d73ca15ee41002882edb35b415e5ab923cd6930fe581c88ce70f7d9472
7
+ data.tar.gz: 5ec3843bfa58d02ce337c20d1510e0f198cf4e0062166f56eb45eaf2460368894b40e1963f7ad74a58f260e2b61268a78314c92b080993ace956dfe24468c652
@@ -3,6 +3,13 @@
3
3
  Starting with v2.0.0, all notable changes to this project will be documented in this file.
4
4
  This project adheres to [Semantic Versioning](http://semver.org/).
5
5
 
6
+ ## v2.2.4 - 2017-04-17
7
+
8
+ ### Added
9
+
10
+ * PuppetForge::Connection now has .accept\_language and .accept\_language= class methods providing a way to set the
11
+ 'Accept-Language' header for outbound requests.
12
+
6
13
  ## v2.2.3 - 2017-01-17
7
14
 
8
15
  ### Changed
@@ -51,6 +51,15 @@ module PuppetForge
51
51
  @proxy
52
52
  end
53
53
 
54
+ def self.accept_language=(lang)
55
+ lang = nil if lang.respond_to?(:empty?) && lang.empty?
56
+ @accept_language = lang
57
+ end
58
+
59
+ def self.accept_language
60
+ @accept_language
61
+ end
62
+
54
63
  # @param reset_connection [Boolean] flag to create a new connection every time this is called
55
64
  # @param opts [Hash] Hash of connection options for Faraday
56
65
  # @return [Faraday::Connection] An existing Faraday connection if one was
@@ -58,8 +67,9 @@ module PuppetForge
58
67
  def conn(reset_connection = nil, opts = {})
59
68
  new_auth = @conn && @conn.headers['Authorization'] != PuppetForge::Connection.authorization
60
69
  new_proxy = @conn && ((@conn.proxy.nil? && PuppetForge::Connection.proxy) || (@conn.proxy && @conn.proxy.uri.to_s != PuppetForge::Connection.proxy))
70
+ new_lang = @conn && @conn.headers['Accept-Language'] != PuppetForge::Connection.accept_language
61
71
 
62
- if new_auth || new_proxy || reset_connection
72
+ if reset_connection || new_auth || new_proxy || new_lang
63
73
  default_connection(opts)
64
74
  else
65
75
  @conn ||= default_connection(opts)
@@ -95,6 +105,10 @@ module PuppetForge
95
105
  options[:headers][:authorization] = token
96
106
  end
97
107
 
108
+ if lang = PuppetForge::Connection.accept_language
109
+ options[:headers]['Accept-Language'] = lang
110
+ end
111
+
98
112
  if proxy = PuppetForge::Connection.proxy
99
113
  options[:proxy] = proxy
100
114
  end
@@ -1,3 +1,3 @@
1
1
  module PuppetForge
2
- VERSION = '2.2.3' # Library version
2
+ VERSION = '2.2.4' # Library version
3
3
  end
@@ -38,6 +38,33 @@ describe PuppetForge::Connection do
38
38
  expect(subject.instance_variable_get(:@proxy)).to be_nil
39
39
  end
40
40
  end
41
+
42
+ describe '#accept_language=' do
43
+ after(:each) do
44
+ subject.accept_language = nil
45
+ end
46
+
47
+ it "sets @accept_language to value when passed non-empty string" do
48
+ lang = "ja-JP"
49
+
50
+ subject.accept_language = lang
51
+
52
+ expect(subject.instance_variable_get(:@accept_language)).to eq lang
53
+ end
54
+
55
+ it "sets @accept_language to nil when passed an empty string" do
56
+ subject.accept_language = ''
57
+
58
+ expect(subject.instance_variable_get(:@accept_language)).to be_nil
59
+ end
60
+
61
+ it "replaces existing @accept_language value with nil when set to empty string" do
62
+ subject.instance_variable_set(:@accept_language, 'value')
63
+ subject.accept_language = ''
64
+
65
+ expect(subject.instance_variable_get(:@accept_language)).to be_nil
66
+ end
67
+ end
41
68
  end
42
69
 
43
70
  describe 'creating a new connection' do
@@ -73,6 +100,16 @@ describe PuppetForge::Connection do
73
100
  expect(subject.headers).to include(:authorization => "auth-test value")
74
101
  end
75
102
  end
103
+
104
+ context 'when an accept language value is provided' do
105
+ before(:each) do
106
+ allow(described_class).to receive(:accept_language).and_return("ja-JP")
107
+ end
108
+
109
+ it 'sets accept-language header on requests' do
110
+ expect(subject.headers).to include('Accept-Language' => "ja-JP")
111
+ end
112
+ end
76
113
  end
77
114
 
78
115
  describe 'creating a default connection' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppet_forge
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.3
4
+ version: 2.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppet Labs
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-17 00:00:00.000000000 Z
11
+ date: 2017-04-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday