open_uri_redirections 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -29,7 +29,7 @@ module OpenURI
29
29
  #
30
30
  # The original open_uri takes *args but then doesn't do anything with them.
31
31
  # Assume we can only handle a hash.
32
- def self.open_uri(name, options = {})
32
+ def self.open_uri(name, options = {}, &block)
33
33
  allow_redirections = options.delete :allow_redirections
34
34
 
35
35
  case allow_redirections
@@ -50,6 +50,6 @@ module OpenURI
50
50
  end
51
51
  end
52
52
 
53
- self.open_uri_original name, options
53
+ self.open_uri_original name, options, &block
54
54
  end
55
55
  end
@@ -1,3 +1,3 @@
1
1
  module OpenUriRedirections
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -16,7 +16,7 @@ Gem::Specification.new do |gem|
16
16
  gem.test_files = gem.files.grep(%r{^(spec)/})
17
17
  gem.require_paths = ["lib"]
18
18
 
19
- gem.add_development_dependency 'rspec', '~> 2.12.0'
19
+ gem.add_development_dependency 'rspec', '~> 2.13.0'
20
20
  gem.add_development_dependency 'fakeweb', '~> 1.3.0'
21
21
  gem.add_development_dependency 'rake', '~> 10.0.3'
22
22
  end
@@ -34,6 +34,12 @@ describe "OpenURI" do
34
34
  it "should follow safe redirections" do
35
35
  open("http://safe.com", :allow_redirections => :safe).read.should == "Hello, this is Safe."
36
36
  end
37
+
38
+ it "should follow safe redirections with block" do
39
+ expect { |b|
40
+ open("http://safe.com", :allow_redirections => :safe, &b)
41
+ }.to yield_control
42
+ end
37
43
  end
38
44
 
39
45
  describe ":allow_redirections => :all" do
@@ -56,6 +62,18 @@ describe "OpenURI" do
56
62
  it "should follow unsafe redirections" do
57
63
  open("https://unsafe.com", :allow_redirections => :all).read.should == "Hello, this is Unsafe."
58
64
  end
65
+
66
+ it "should follow safe redirections with block" do
67
+ expect { |b|
68
+ open("http://safe.com", :allow_redirections => :all, &b)
69
+ }.to yield_control
70
+ end
71
+
72
+ it "should follow unsafe redirections with block" do
73
+ expect { |b|
74
+ open("https://unsafe.com", :allow_redirections => :all, &b)
75
+ }.to yield_control
76
+ end
59
77
  end
60
78
  end
61
79
  end
metadata CHANGED
@@ -1,81 +1,72 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: open_uri_redirections
3
- version: !ruby/object:Gem::Version
4
- hash: 27
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 1
9
- - 0
10
- version: 0.1.0
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Jaime Iniesta
14
9
  - Gabriel Cebrian
15
10
  autorequire:
16
11
  bindir: bin
17
12
  cert_chain: []
18
-
19
- date: 2013-01-19 00:00:00 Z
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
13
+ date: 2013-03-11 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
22
16
  name: rspec
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
17
+ requirement: !ruby/object:Gem::Requirement
25
18
  none: false
26
- requirements:
19
+ requirements:
27
20
  - - ~>
28
- - !ruby/object:Gem::Version
29
- hash: 63
30
- segments:
31
- - 2
32
- - 12
33
- - 0
34
- version: 2.12.0
21
+ - !ruby/object:Gem::Version
22
+ version: 2.13.0
35
23
  type: :development
36
- version_requirements: *id001
37
- - !ruby/object:Gem::Dependency
38
- name: fakeweb
39
24
  prerelease: false
40
- requirement: &id002 !ruby/object:Gem::Requirement
25
+ version_requirements: !ruby/object:Gem::Requirement
41
26
  none: false
42
- requirements:
27
+ requirements:
43
28
  - - ~>
44
- - !ruby/object:Gem::Version
45
- hash: 27
46
- segments:
47
- - 1
48
- - 3
49
- - 0
29
+ - !ruby/object:Gem::Version
30
+ version: 2.13.0
31
+ - !ruby/object:Gem::Dependency
32
+ name: fakeweb
33
+ requirement: !ruby/object:Gem::Requirement
34
+ none: false
35
+ requirements:
36
+ - - ~>
37
+ - !ruby/object:Gem::Version
50
38
  version: 1.3.0
51
39
  type: :development
52
- version_requirements: *id002
53
- - !ruby/object:Gem::Dependency
54
- name: rake
55
40
  prerelease: false
56
- requirement: &id003 !ruby/object:Gem::Requirement
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ~>
45
+ - !ruby/object:Gem::Version
46
+ version: 1.3.0
47
+ - !ruby/object:Gem::Dependency
48
+ name: rake
49
+ requirement: !ruby/object:Gem::Requirement
57
50
  none: false
58
- requirements:
51
+ requirements:
59
52
  - - ~>
60
- - !ruby/object:Gem::Version
61
- hash: 73
62
- segments:
63
- - 10
64
- - 0
65
- - 3
53
+ - !ruby/object:Gem::Version
66
54
  version: 10.0.3
67
55
  type: :development
68
- version_requirements: *id003
56
+ prerelease: false
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ~>
61
+ - !ruby/object:Gem::Version
62
+ version: 10.0.3
69
63
  description: OpenURI patch to allow redirections between HTTP and HTTPS
70
- email:
64
+ email:
71
65
  - jaimeiniesta@gmail.com
72
66
  executables: []
73
-
74
67
  extensions: []
75
-
76
68
  extra_rdoc_files: []
77
-
78
- files:
69
+ files:
79
70
  - .gitignore
80
71
  - .travis.yml
81
72
  - Gemfile
@@ -94,38 +85,35 @@ files:
94
85
  - spec/spec_helper.rb
95
86
  homepage: https://github.com/jaimeiniesta/open_uri_redirections
96
87
  licenses: []
97
-
98
88
  post_install_message:
99
89
  rdoc_options: []
100
-
101
- require_paths:
90
+ require_paths:
102
91
  - lib
103
- required_ruby_version: !ruby/object:Gem::Requirement
92
+ required_ruby_version: !ruby/object:Gem::Requirement
104
93
  none: false
105
- requirements:
106
- - - ">="
107
- - !ruby/object:Gem::Version
108
- hash: 3
109
- segments:
94
+ requirements:
95
+ - - ! '>='
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ segments:
110
99
  - 0
111
- version: "0"
112
- required_rubygems_version: !ruby/object:Gem::Requirement
100
+ hash: 2413654041070005087
101
+ required_rubygems_version: !ruby/object:Gem::Requirement
113
102
  none: false
114
- requirements:
115
- - - ">="
116
- - !ruby/object:Gem::Version
117
- hash: 3
118
- segments:
103
+ requirements:
104
+ - - ! '>='
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ segments:
119
108
  - 0
120
- version: "0"
109
+ hash: 2413654041070005087
121
110
  requirements: []
122
-
123
111
  rubyforge_project:
124
- rubygems_version: 1.8.24
112
+ rubygems_version: 1.8.25
125
113
  signing_key:
126
114
  specification_version: 3
127
115
  summary: OpenURI patch to allow redirections between HTTP and HTTPS
128
- test_files:
116
+ test_files:
129
117
  - spec/redirections_spec.rb
130
118
  - spec/samples/http_safe.response
131
119
  - spec/samples/http_unsafe.response