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 +4 -4
- data/changelog.md +6 -0
- data/lib/fog/core/collection.rb +1 -1
- data/lib/fog/core/connection.rb +25 -3
- data/lib/fog/core/version.rb +1 -1
- data/spec/connection_spec.rb +6 -11
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 92d66fd0343833e7c90dcb8fce05e3104ce86996
|
4
|
+
data.tar.gz: 713e785d1cb64e82f913387ff68137f9e26ba569
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 678c115c28500fb036b3cef826cfad6667136dbd165526e8e6ce85511deffd6ef23d5a312439d341f02b8fa281c013bc7a2d724da88f9ec8916c4ee9fa9d0538
|
7
|
+
data.tar.gz: ba7626703891e1a952570dd9dfce2ebe1123d0028ed5ecbae060f8266e630ae503d20323dc80d46eb30cdf32bf1af19080dfb34586e2541f1a28add73e65999c
|
data/changelog.md
CHANGED
data/lib/fog/core/collection.rb
CHANGED
data/lib/fog/core/connection.rb
CHANGED
@@ -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
|
|
data/lib/fog/core/version.rb
CHANGED
data/spec/connection_spec.rb
CHANGED
@@ -14,20 +14,15 @@ describe Fog::Core::Connection do
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
it "
|
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
|
-
|
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.
|
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-
|
12
|
+
date: 2015-02-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: builder
|