link_checker 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -18,7 +18,7 @@ Or install it yourself as:
18
18
 
19
19
  ## Usage
20
20
 
21
- LinkChecker.new('http://example.com').valid?
21
+ LinkChecker.new('http://example.com').accessible?
22
22
 
23
23
  ## Contributing
24
24
 
@@ -3,14 +3,14 @@ require 'net/http'
3
3
 
4
4
  # Checks whether URL is accessible, following up to 10 redirects.
5
5
  # Example:
6
- # LinkChecker.new('http://example.com').valid?
6
+ # LinkChecker.new('http://example.com').accessible?
7
7
  class LinkChecker
8
8
  def initialize(uri_str, limit = 10)
9
9
  @uri_str, @limit = uri_str, limit
10
10
  @uri_str = "http://#{@uri_str}" unless @uri_str.include?('://')
11
11
  end
12
12
 
13
- def valid?
13
+ def accessible?
14
14
  return false if @limit == 0
15
15
  uri = URI(@uri_str)
16
16
  Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https', :verify_mode => OpenSSL::SSL::VERIFY_NONE) do |http|
@@ -25,7 +25,7 @@ class LinkChecker
25
25
  host_with_protocol = @uri_str[/^[^\:]+\:\/\/[^\/]+/, 0]
26
26
  location = host_with_protocol + location
27
27
  end
28
- self.class.new(location, @limit - 1).valid?
28
+ self.class.new(location, @limit - 1).accessible?
29
29
  else
30
30
  false
31
31
  end
@@ -1,3 +1,3 @@
1
1
  class LinkChecker
2
- VERSION = "0.0.1"
2
+ VERSION = "0.1.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: link_checker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: