redirect_follow_get 0.0.1 → 0.0.2

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: 489244bf6ae720127fe31bc306bec70d7580095f
4
- data.tar.gz: be122af4d3842e63e9004d5f06feb32f3911b7be
3
+ metadata.gz: 97c056312496571885d638b57f696c8dc8b7a26c
4
+ data.tar.gz: ce3792d988d3a3e60d7b4e644c15e66ff54ad4a9
5
5
  SHA512:
6
- metadata.gz: d193140c589a4396dbaa36a99b471d57f24b9964418c402767458e6c537b2d6288acc2f5c5e125a3305a2f5b8f7537bf4fd9b64f3e8b7dab4a388fc849b7601d
7
- data.tar.gz: 1cdecb99bbd4afb29508432c2adc6dd86b860bc3028747d0f454e28f941e058c0354d7a4332a87822df4bc5fbc8f37f9fd272534d89bcb72a1ccc065cf963fae
6
+ metadata.gz: 4f84a8c3e58c4e6347dad6e078e34079e48b121e1ff77441f9e14bdfec1f2d6fb05840dca9c4d313ad092b3f7aa7514dadfc3fd40cbbbaf0118cb78ba0f00dbe
7
+ data.tar.gz: 052c5c1bf3ee2a68292fbcf3c643cb404c00585ccb693ade47f030cd135591c9ab2c705719f2e261fffc216cc1b4aef023ef31326099e8725dfa8590a85996cc
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # redirect_follow_get
2
2
 
3
- `redirect_follow_get` is simple http get method which follows http redirect. It wraps `net/http` library.
3
+ `redirect_follow_get` is simple http get method following redirect. It wraps `net/http` library.
4
4
 
5
5
  ## Installation
6
6
 
@@ -20,28 +20,25 @@ Or install it yourself as:
20
20
 
21
21
  ## Usage
22
22
 
23
- TODO: Write usage instructions here
23
+ `redirect_follow_get` returns `Net::HTTPOK` when the request gets 200 response.
24
24
 
25
25
  ```rb
26
26
  response = redirect_follow_get('http://google.com/')
27
27
  # => #<Net::HTTPOK 200 OK readbody=true>
28
+ ```
28
29
 
29
- puts response.code
30
- # 200
31
-
32
- puts response.uri
33
- # http://www.google.co.jp/?gfe_rd=...
30
+ ```rb
31
+ response.code
32
+ # => "200"
34
33
 
35
- puts response.body
36
- # <!DOCTYPE html>
37
- # <html>
38
- # <head>
39
- # <meta charset="utf-8">
40
- # ...
34
+ response.uri
35
+ # => #<URI::HTTP http://www.google.co.jp/?gfe_rd=...>
41
36
 
37
+ response.body
38
+ # => "<!doctype html><html ...
42
39
  ```
43
40
 
44
- ### Redirects limit
41
+ ### Redirection limit
45
42
 
46
43
  You can limit the number of redirects with `limit:` option. **Default redirects limit is 10.**
47
44
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'redirect_follow_get/version'
2
3
  require 'net/http'
3
4
 
@@ -8,7 +9,8 @@ end
8
9
  def redirect_follow_get(url, limit: 10)
9
10
  raise RedirectFollowGet::TooManyRedirects, 'too many HTTP redirects' if limit.zero?
10
11
 
11
- case response = Net::HTTP.get_response(URI(url))
12
+ uri = URI(URI.escape(url))
13
+ case response = Net::HTTP.get_response(uri)
12
14
  when Net::HTTPSuccess
13
15
  response
14
16
  when Net::HTTPRedirection
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module RedirectFollowGet
2
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
3
4
  end
@@ -9,8 +9,8 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ["Toshimaru"]
10
10
  spec.email = ["me@toshimaru.net"]
11
11
 
12
- spec.summary = %q{redirect_follow_get is simple http get method which follows http redirect.}
13
- spec.description = %q{redirect_follow_get is simple http get method which follows http redirect.}
12
+ spec.summary = %q{redirect_follow_get is simple http get method following redirect.}
13
+ spec.description = %q{redirect_follow_get is simple http get method following redirect.}
14
14
  spec.homepage = "https://github.com/toshimaru/redirect_follow_get"
15
15
  spec.license = "MIT"
16
16
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redirect_follow_get
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Toshimaru
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-12-26 00:00:00.000000000 Z
11
+ date: 2016-12-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,7 +66,7 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
- description: redirect_follow_get is simple http get method which follows http redirect.
69
+ description: redirect_follow_get is simple http get method following redirect.
70
70
  email:
71
71
  - me@toshimaru.net
72
72
  executables: []
@@ -107,5 +107,5 @@ rubyforge_project:
107
107
  rubygems_version: 2.5.1
108
108
  signing_key:
109
109
  specification_version: 4
110
- summary: redirect_follow_get is simple http get method which follows http redirect.
110
+ summary: redirect_follow_get is simple http get method following redirect.
111
111
  test_files: []