fog-core 1.28.0 → 1.29.0

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: c3adfecc06e8a5e94b89b4734caca15a4b650984
4
- data.tar.gz: 18cad321f56ecf4f8031d220dc8c1bf292b7479a
3
+ metadata.gz: 92d66fd0343833e7c90dcb8fce05e3104ce86996
4
+ data.tar.gz: 713e785d1cb64e82f913387ff68137f9e26ba569
5
5
  SHA512:
6
- metadata.gz: 5f06f19bda33e2a1ec1316f6fcb50e2bbbc940217d9a9f8e6c97304b088a4ae02fcfd81ef8dbb3356b40f2f04f510f44052f99db9918f98388c08c186e679f3b
7
- data.tar.gz: 92c242001650b228e5ae34426836f014235d128263c66f96a1d3970135985e7e5f4cf38448e50f53866fc1dbc4e0ba205600f6bf99eae2b40f3c96c4284616c6
6
+ metadata.gz: 678c115c28500fb036b3cef826cfad6667136dbd165526e8e6ce85511deffd6ef23d5a312439d341f02b8fa281c013bc7a2d724da88f9ec8916c4ee9fa9d0538
7
+ data.tar.gz: ba7626703891e1a952570dd9dfce2ebe1123d0028ed5ecbae060f8266e630ae503d20323dc80d46eb30cdf32bf1af19080dfb34586e2541f1a28add73e65999c
@@ -1,3 +1,9 @@
1
+ 1.29.0 02/19/2015
2
+ ==========================================================
3
+
4
+ minor refactoring
5
+ add ability to add additional user agent info to requests
6
+
1
7
  1.28.0 01/30/2015
2
8
  ==========================================================
3
9
 
@@ -43,7 +43,7 @@ module Fog
43
43
  end
44
44
 
45
45
  def clear
46
- @loaded = true && super
46
+ @loaded = super
47
47
  end
48
48
 
49
49
  def create(attributes = {})
@@ -6,6 +6,26 @@ module Fog
6
6
  # modifications such as authentication or response object.
7
7
  #
8
8
  class Connection
9
+
10
+ class << self
11
+ @@user_agents = []
12
+
13
+ def add_user_agent(str)
14
+ if /\S+\/[\d|.]+/.match(str)
15
+ @@user_agents << str
16
+ else
17
+ raise "User Agent must be in <app name>/<app version> notation."
18
+ end
19
+ end
20
+
21
+ def user_agents
22
+ agents = @@user_agents.dup
23
+ agents << "fog/#{Fog::VERSION}" if defined?(Fog::VERSION)
24
+ agents << "fog-core/#{Fog::Core::VERSION}"
25
+ agents.uniq.compact.join(" ")
26
+ end
27
+ end
28
+
9
29
  # Prepares the connection and sets defaults for any future requests.
10
30
  #
11
31
  # @param [String] url The destination URL
@@ -34,10 +54,8 @@ module Fog
34
54
 
35
55
  params[:debug_response] = true unless params.key?(:debug_response)
36
56
  params[:headers] ||= {}
37
- user_agent = "fog-core/#{Fog::Core::VERSION}"
38
- user_agent = "fog/#{Fog::VERSION} #{user_agent}" if defined?(Fog::VERSION)
39
- params[:headers]["User-Agent"] ||= user_agent
40
57
  params.merge!(:persistent => params.fetch(:persistent, persistent))
58
+ params[:headers]["User-Agent"] ||= user_agent
41
59
  @excon = Excon.new(url, params)
42
60
  end
43
61
 
@@ -77,6 +95,10 @@ module Fog
77
95
 
78
96
  private
79
97
 
98
+ def user_agent
99
+ self.class.user_agents
100
+ end
101
+
80
102
  def handle_path_prefix_for(params)
81
103
  return params unless @path_prefix
82
104
 
@@ -1,5 +1,5 @@
1
1
  module Fog
2
2
  module Core
3
- VERSION = "1.28.0"
3
+ VERSION = "1.29.0"
4
4
  end
5
5
  end
@@ -14,20 +14,15 @@ describe Fog::Core::Connection do
14
14
  end
15
15
  end
16
16
 
17
- it "writes the Fog::Core::VERSION to the User-Agent header" do
17
+ it "adds custom user-agents to Fog requests" do
18
+ Fog::VERSION = 'Version'
19
+ Fog::Core::Connection.add_user_agent("my-app/1.2")
20
+
18
21
  connection = Fog::Core::Connection.new("http://example.com")
19
- assert_equal "fog-core/#{Fog::Core::VERSION}",
22
+ assert_equal "my-app/1.2 fog/Version fog-core/#{Fog::Core::VERSION}",
20
23
  connection.instance_variable_get(:@excon).data[:headers]["User-Agent"]
21
- end
22
24
 
23
- describe "when Fog is installed" do
24
- it "writes the Fog::VERSION to the User-Agent header" do
25
- Fog::VERSION = 'Version'
26
- connection = Fog::Core::Connection.new("http://example.com")
27
- assert_equal "fog/Version fog-core/#{Fog::Core::VERSION}",
28
- connection.instance_variable_get(:@excon).data[:headers]["User-Agent"]
29
- Fog.send(:remove_const, :VERSION)
30
- end
25
+ Fog.send(:remove_const, :VERSION)
31
26
  end
32
27
 
33
28
  it "doesn't error when persistence is enabled" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fog-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.28.0
4
+ version: 1.29.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evan Light
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-01-30 00:00:00.000000000 Z
12
+ date: 2015-02-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: builder