onebox 1.8.7 → 1.8.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/onebox/helpers.rb +6 -0
- data/lib/onebox/version.rb +1 -1
- data/spec/lib/onebox/helpers_spec.rb +28 -0
- 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: 193a79cfcb0e3461c479883dd4a043c56beb92ad
|
4
|
+
data.tar.gz: 8f993f55c01ed4c72957828b08acfe22dee40200
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64b633a02255964ac679fa5a2ca15646d1917d77226a535ef6488360b1f71181ccc9d3499c55d40af1d86b15055d558e365d8d0fce2b52fea9e462b71ad96698
|
7
|
+
data.tar.gz: 45084fe78481d3177bcb06a1cbca15f795475b7b4b969af89ddab52cb1209628d81215ea0c361d673515bf95d8feeb78d8b3b32948b05fd5c81d6cbdeb24b08b
|
data/lib/onebox/helpers.rb
CHANGED
@@ -36,6 +36,12 @@ module Onebox
|
|
36
36
|
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
37
37
|
end
|
38
38
|
|
39
|
+
headers ||= {}
|
40
|
+
|
41
|
+
if Onebox.options.user_agent && !headers['User-Agent']
|
42
|
+
headers['User-Agent'] = Onebox.options.user_agent
|
43
|
+
end
|
44
|
+
|
39
45
|
request = Net::HTTP::Get.new(uri.request_uri, headers)
|
40
46
|
start_time = Time.now
|
41
47
|
|
data/lib/onebox/version.rb
CHANGED
@@ -42,4 +42,32 @@ RSpec.describe Onebox::Helpers do
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
+
describe "user_agent" do
|
46
|
+
before do
|
47
|
+
fake("http://example.com/some-resource", :body => 'test')
|
48
|
+
end
|
49
|
+
|
50
|
+
context "default" do
|
51
|
+
it "has the Ruby user agent" do
|
52
|
+
described_class.fetch_response('http://example.com/some-resource')
|
53
|
+
expect(FakeWeb.last_request.to_hash['user-agent'][0]).to eq("Ruby")
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
context "Custom option" do
|
58
|
+
after(:each) do
|
59
|
+
Onebox.options = Onebox::DEFAULTS
|
60
|
+
end
|
61
|
+
|
62
|
+
before do
|
63
|
+
Onebox.options = { user_agent: "EvilTroutBot v0.1" }
|
64
|
+
end
|
65
|
+
|
66
|
+
it "has the custom user agent" do
|
67
|
+
described_class.fetch_response('http://example.com/some-resource')
|
68
|
+
expect(FakeWeb.last_request.to_hash['user-agent'][0]).to eq("EvilTroutBot v0.1")
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
45
73
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: onebox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.8.
|
4
|
+
version: 1.8.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joanna Zeta
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2017-05-
|
13
|
+
date: 2017-05-24 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: multi_json
|