open_uri_w_redirect_to_https 0.1.2 → 0.1.3

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: 1b2bb63fccc1c47099ac402f2d81ba9eb69347ab
4
- data.tar.gz: c75767253880fc3778bb4a19c82d00acc8f86d86
3
+ metadata.gz: e8d9aab07af1e96065042f7cad95e54c8e558a0c
4
+ data.tar.gz: 09669f227446ee7eb16bbc0e7656adbb93200875
5
5
  SHA512:
6
- metadata.gz: a054859ed05cc2744f5a1374341d3ca37ce449167066a9dd37b97191a2003b4246a3060d687d36d342c1efd2fbd78844f8b512ab77968a0719c9e8614e50faba
7
- data.tar.gz: a52297318348f13cba1ef8e9feee1c8eabae2ffb00dcd0711341869cde61f47af5b6b3c116ba61d6244dc8475b099c98677e6be4b176c8eadaea8a6f9bb6d51f
6
+ metadata.gz: 41b6976010fbdf9275278991c59ebb2f7013217467ddf6dfcbb768f272080be3f20d4d902a71aa4a955f046602a766b2d46fbd84c4e5c1ec7c058ef512764ad6
7
+ data.tar.gz: 688ad496a23ce3246822fc10d0641d18af188f3530ece46f8222f54e2cfb066943138d8bd11a09afb9ef5329d50d26fcbdbfc7d30037b49f25caccfcba6f4adc
data/README.md CHANGED
@@ -2,14 +2,15 @@
2
2
 
3
3
  File : README.md
4
4
  Maintainer : Felix C. Stegerman <flx@obfusk.net>
5
- Date : 2014-11-23
5
+ Date : 2014-11-26
6
6
 
7
7
  Copyright : Copyright (C) 2014 Felix C. Stegerman
8
- Version : v0.1.2
8
+ Version : v0.1.3
9
9
 
10
10
  []: }}}1
11
11
 
12
12
  [![Gem Version](https://badge.fury.io/rb/open_uri_w_redirect_to_https.png)](https://rubygems.org/gems/open_uri_w_redirect_to_https)
13
+ [![Build Status](https://travis-ci.org/obfusk/open_uri_w_redirect_to_https.png)](https://travis-ci.org/obfusk/open_uri_w_redirect_to_https)
13
14
 
14
15
  ## Description
15
16
 
@@ -77,11 +78,13 @@ gem install open_uri_w_redirect_to_https
77
78
  Monkey-patching is not a very robust way to fix bugs. Use at your
78
79
  own risk.
79
80
 
80
- Q: why should I prefer this gem to [open_uri_redirections]
81
+ Q: Why should I prefer this gem to [open_uri_redirections]
81
82
  (https://github.com/jaimeiniesta/open_uri_redirections)?
82
83
  <br/>
83
- A: because this one is thread-safe (I hope); other than that, feel
84
- free to choose either
84
+ A: Now that open_uri_redirections (>= 0.2.0) is thread-safe, feel
85
+ free to choose either based on your needs. This gem supports global
86
+ and dynamic defaults, wherease open_uri_redirections supports HTTPS
87
+ to HTTP (unsafe) redirects.
85
88
 
86
89
  NB: this gem internally uses thread-local variables like
87
90
  `Thread.current[:__open_uri_w_redirect_to_https__]`.
@@ -97,6 +100,7 @@ rake docs
97
100
  ## TODO
98
101
 
99
102
  * specs: (can we) test `redirect_to_https=true` w/ threads?
103
+ * thread-safe spec: (can we) make it no longer brittle?
100
104
 
101
105
  ## License
102
106
 
data/Rakefile CHANGED
@@ -47,7 +47,7 @@ end
47
47
 
48
48
  desc 'Cleanup'
49
49
  task :clean do
50
- sh 'rm -rf .yardoc/ coverage/ doc/ *.gem'
50
+ sh 'rm -rf .yardoc/ coverage/ doc/ *.gem Gemfile.lock'
51
51
  end
52
52
 
53
53
  desc 'Build SNAPSHOT gem'
@@ -2,7 +2,7 @@
2
2
  #
3
3
  # File : open_uri_w_redirect_to_https.rb
4
4
  # Maintainer : Felix C. Stegerman <flx@obfusk.net>
5
- # Date : 2014-11-23
5
+ # Date : 2014-11-26
6
6
  #
7
7
  # Copyright : Copyright (C) 2014 Felix C. Stegerman
8
8
  # Licence : MIT
@@ -60,8 +60,6 @@ module OpenURI
60
60
  def redirectable?(uri1, uri2)
61
61
  if redirect_to_https? == :always ||
62
62
  Thread.current[:__open_uri_w_redirect_to_https__]
63
- # clear to prevent leaking (e.g. to block)
64
- Thread.current[:__open_uri_w_redirect_to_https__] = nil
65
63
  redirectable_w_redirect_to_https? uri1, uri2
66
64
  else
67
65
  redirectable_orig? uri1, uri2
@@ -82,10 +80,12 @@ module OpenURI
82
80
  r = (o = rest.find { |x| Hash === x }) && o.delete(:redirect_to_https)
83
81
  Thread.current[:__open_uri_w_redirect_to_https__] = \
84
82
  r.nil? ? redirect_to_https? : r
83
+ b2 = -> io {
84
+ Thread.current[:__open_uri_w_redirect_to_https__] = nil; b[io]
85
+ }
85
86
  begin
86
- open_uri_orig name, *rest, &b
87
+ open_uri_orig name, *rest, &(b ? b2 : nil)
87
88
  ensure
88
- # clear (redirectable? might not be called due to an exception)
89
89
  Thread.current[:__open_uri_w_redirect_to_https__] = nil
90
90
  end
91
91
  end
@@ -1,4 +1,4 @@
1
1
  module OpenURIWithRedirectToHttps
2
- VERSION = '0.1.2'
3
- DATE = '2014-11-23'
2
+ VERSION = '0.1.3'
3
+ DATE = '2014-11-26'
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: open_uri_w_redirect_to_https
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Felix C. Stegerman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-23 00:00:00.000000000 Z
11
+ date: 2014-11-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fakeweb