From e83b82a680bf49d191d50d29eacf7e5f02d0b40a Mon Sep 17 00:00:00 2001 From: Adrien Jarthon Date: Fri, 20 Feb 2015 10:45:03 +0100 Subject: [PATCH] Added getter for redirect_time value --- CHANGELOG.md | 7 +++++++ lib/typhoeus/response/informations.rb | 13 +++++++++++++ spec/typhoeus/response/informations_spec.rb | 8 ++++++++ typhoeus.gemspec | 2 +- 4 files changed, 29 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c4ccda3..a4216c9c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## Master + +[Full Changelog](http://github.com/typhoeus/typhoeus/compare/v0.7.1...master) + +* Added getter for `redirect_time` value. + ([Adrien Jarthon](https://github.com/jarthod)) + ## 0.7.1 [Full Changelog](http://github.com/typhoeus/typhoeus/compare/v0.7.0...v0.7.1) diff --git a/lib/typhoeus/response/informations.rb b/lib/typhoeus/response/informations.rb index e045bcdf..eaf4edba 100644 --- a/lib/typhoeus/response/informations.rb +++ b/lib/typhoeus/response/informations.rb @@ -160,6 +160,19 @@ def namelookup_time end alias :name_lookup_time :namelookup_time + # Return the time, in seconds, it took for all redirection steps + # include name lookup, connect, pretransfer and transfer before the + # final transaction was started. time_redirect shows the complete + # execution time for multiple redirections. + # + # @example Get redirect_time. + # response.redirect_time + # + # @return [ Float ] The redirect_time. + def redirect_time + options[:redirect_time] + end + # Return the last used effective url. # # @example Get effective_url. diff --git a/spec/typhoeus/response/informations_spec.rb b/spec/typhoeus/response/informations_spec.rb index a82cef6e..0382ec77 100644 --- a/spec/typhoeus/response/informations_spec.rb +++ b/spec/typhoeus/response/informations_spec.rb @@ -152,6 +152,14 @@ end end + describe "#redirect_time" do + let(:options) { { :redirect_time => 1 } } + + it "returns redirect_time from options" do + expect(response.redirect_time).to eq(1) + end + end + describe "#effective_url" do let(:options) { { :effective_url => "http://www.example.com" } } diff --git a/typhoeus.gemspec b/typhoeus.gemspec index 2f116197..f3a15419 100644 --- a/typhoeus.gemspec +++ b/typhoeus.gemspec @@ -17,7 +17,7 @@ Gem::Specification.new do |s| s.required_rubygems_version = ">= 1.3.6" s.license = 'MIT' - s.add_dependency('ethon', [">= 0.7.1"]) + s.add_dependency('ethon', [">= 0.7.2"]) s.files = `git ls-files`.split("\n") s.test_files = `git ls-files -- spec/*`.split("\n")