typhoeus 0.7.3 → 0.8.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: 258c4fa9fa36f07af4d6b3b5aff63ff005927660
4
- data.tar.gz: b6258b32116ff79087392c2e3003ad809a9d5c50
3
+ metadata.gz: d6141d4a4fce3468605180e9fa209f44dcadb297
4
+ data.tar.gz: f44b3f1fc22744bee6e552bad735bbeed1acca25
5
5
  SHA512:
6
- metadata.gz: 482769a76a20585b3c02aa42b356c4316a10e6765c542a777f51ba5d8e0b7723d7657fb2b9a8ba961feea9cf53f36644afcd35d0ff459af46a908e41e71656f7
7
- data.tar.gz: 53adcad9bb067d2a10be8ddfb19342924887b02bc140b508ba061d1608b085946d9521f681d5766554fa3dbb3602bd0c312536709854ee64593ccbfc426f3d88
6
+ metadata.gz: 22303b457d981211f37f0da3f056d9a78e97be9c907878b9ab3ae497db3f09c0975c1d0b305f30ffd75c308d5fa08ce3aee22314591b0e056cebabd402529195
7
+ data.tar.gz: 35ca8ddee5fe6122677ea2823b1c9db407e848e2070dc59f78780d88c56fe5d8cf7d6386fe6e0e8d1f5dde624bfec704aa9dad4d34afd95dde922c8f10a863f5
data/README.md CHANGED
@@ -506,6 +506,15 @@ Typhoeus::Config.verbose = true
506
506
  Just remember that libcurl prints it’s debug output to the console (to
507
507
  STDERR), so you’ll need to run your scripts from the console to see it.
508
508
 
509
+ ### Default User Agent Header
510
+
511
+ In many cases, all HTTP requests made by an application require the same User-Agent header set. Instead of supplying it on a per-request basis by supplying a custom header, it is possible to override it for all requests using:
512
+
513
+
514
+ ```ruby
515
+ Typhoeus::Config.user_agent = "custom user agent"
516
+ ```
517
+
509
518
  ### Running the specs
510
519
 
511
520
  Running the specs should be as easy as:
@@ -514,6 +523,9 @@ Running the specs should be as easy as:
514
523
  bundle install
515
524
  bundle exec rake
516
525
  ```
526
+ ## Semantic Versioning
527
+
528
+ This project conforms to [semver](http://semver.org/).
517
529
 
518
530
  ## LICENSE
519
531
 
@@ -545,4 +557,3 @@ OTHER DEALINGS IN THE SOFTWARE.
545
557
 
546
558
 
547
559
  [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/typhoeus/typhoeus/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
548
-
@@ -51,5 +51,12 @@ module Typhoeus
51
51
  # @see Typhoeus::Hydra::Cacheable
52
52
  # @see Typhoeus::Request::Cacheable
53
53
  attr_accessor :cache
54
+
55
+ # Defines whether to use a default user agent.
56
+ #
57
+ # @return [ String ]
58
+ #
59
+ # @see Typhoeus::Request#set_defaults
60
+ attr_accessor :user_agent
54
61
  end
55
62
  end
@@ -209,10 +209,12 @@ module Typhoeus
209
209
 
210
210
  # Sets default header and verbose when turned on.
211
211
  def set_defaults
212
+ default_user_agent = Config.user_agent || Typhoeus::USER_AGENT
213
+
212
214
  if @options[:headers]
213
- @options[:headers] = {'User-Agent' => Typhoeus::USER_AGENT}.merge(options[:headers])
215
+ @options[:headers] = {'User-Agent' => default_user_agent}.merge(options[:headers])
214
216
  else
215
- @options[:headers] = {'User-Agent' => Typhoeus::USER_AGENT}
217
+ @options[:headers] = {'User-Agent' => default_user_agent}
216
218
  end
217
219
  @options[:verbose] = Typhoeus::Config.verbose if @options[:verbose].nil? && !Typhoeus::Config.verbose.nil?
218
220
  @options[:maxredirs] ||= 50
@@ -1,5 +1,5 @@
1
1
  module Typhoeus
2
2
 
3
3
  # The current Typhoeus version.
4
- VERSION = '0.7.3'
4
+ VERSION = '0.8.0'
5
5
  end
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe Typhoeus::Config do
4
4
  let(:config) { Typhoeus::Config }
5
5
 
6
- [:block_connection, :memoize, :verbose, :cache].each do |name|
6
+ [:block_connection, :memoize, :verbose, :cache, :user_agent].each do |name|
7
7
  it "responds to #{name}" do
8
8
  expect(config).to respond_to(name)
9
9
  end
@@ -65,6 +65,27 @@ describe Typhoeus::Request do
65
65
  end
66
66
  end
67
67
 
68
+ context "when Config.user_agent set" do
69
+ before { Typhoeus.configure { |config| config.user_agent = "Default" } }
70
+ after { Typhoeus.configure { |config| config.user_agent = nil } }
71
+
72
+ context "with headers" do
73
+ let(:options) { {:headers => { "User-Agent" => "Fubar" } } }
74
+
75
+ it "uses the request options' user agent" do
76
+ expect(request.options[:headers]["User-Agent"]).to eq("Fubar")
77
+ end
78
+ end
79
+
80
+ context "without headers" do
81
+ let(:options) { {:headers => {} } }
82
+
83
+ it "uses the global options' user agent" do
84
+ expect(request.options[:headers]["User-Agent"]).to eq("Default")
85
+ end
86
+ end
87
+ end
88
+
68
89
  context "when Config.verbose set" do
69
90
  before { Typhoeus.configure { |config| config.verbose = true} }
70
91
  after { Typhoeus.configure { |config| config.verbose = false} }
@@ -17,7 +17,7 @@ Gem::Specification.new do |s|
17
17
  s.required_rubygems_version = ">= 1.3.6"
18
18
  s.license = 'MIT'
19
19
 
20
- s.add_dependency('ethon', [">= 0.7.4"])
20
+ s.add_dependency('ethon', [">= 0.8.0"])
21
21
 
22
22
  s.files = `git ls-files`.split("\n")
23
23
  s.test_files = `git ls-files -- spec/*`.split("\n")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: typhoeus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.3
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Balatero
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-08-08 00:00:00.000000000 Z
13
+ date: 2015-09-17 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: ethon
@@ -18,14 +18,14 @@ dependencies:
18
18
  requirements:
19
19
  - - ">="
20
20
  - !ruby/object:Gem::Version
21
- version: 0.7.4
21
+ version: 0.8.0
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
26
  - - ">="
27
27
  - !ruby/object:Gem::Version
28
- version: 0.7.4
28
+ version: 0.8.0
29
29
  description: Like a modern code version of the mythical beast with 100 serpent heads,
30
30
  Typhoeus runs HTTP requests in parallel while cleanly encapsulating handling logic.
31
31
  email: