bad_link_finder 0.2.2 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MWEzNmQ1MmQ4NzBkYTlkZmFlODhkNWQwNmJjZGRlMGIxNzkwOTI3Yg==
4
+ YTkzYzA3MDcwZjBkODJiN2VmZWM0OGRlODllMzFiZGJiMGQxNjc1Yg==
5
5
  data.tar.gz: !binary |-
6
- MDA5MGMwNmIyNTE3NzgzZjUzMDEzYzQwMzljMGU4NTNmMjQ5ODhmMw==
6
+ ZDNmNDg2NjYwODNmN2IwNGQyNTllZGQ3Yjc2ZTY0MjU4Y2JkMTBkMA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ODliZjFkNTg2ZWVlZjNhYjcxODRlYzI3MDY5M2I2YmUyNjg1Y2NiNzkxMjQy
10
- ZGM2ZDdmYmIxY2FjNDIyMDcxNDNiYjM3ZmFjMDAxODc0NDVhOWMxYjRkZDQ4
11
- NjhhZWEzNzJjMjAxMmY5YjE3MjVhZmQ2ZDVjODYxNWQ0MWM2Y2Y=
9
+ NWI0NGU1MTBiMzIyZDE2MTU0YmUxNTM5MWQyZTE3YTUwZjMyZThiYTcxNzA3
10
+ MjEzYWYxOWE0NTBmZjg2ZGJiYmQxZmYwMWEzNzA1NWJjNjEwM2RhMGJmZmNi
11
+ MzQ2NGU3NGMxNWI0MmFlYjdlNjYxODY5N2ExZjQ3OGQ3YThiZDk=
12
12
  data.tar.gz: !binary |-
13
- NDI0MTY2NzNjYTQ5ZjA4NWU0MWQ4MmUxNGExZjkyOTc3MWVjZmIwMjQ3OTZh
14
- MGExOTY4YjNlZDAxNGFkNmE1ZTllODk4MGY1NzUxNmRkZTZkMmZkNGRlNTlk
15
- YWFjYmYzY2JiNzBkMGQ1YmZlMDA1NmI4YzJiNWIzZGVkNTNiODQ=
13
+ NWEzMmE1NGRlNmUwOGVkNmY3ZDNmMTNkZjc3MzVkMTZlOTY1ZGRjY2M2YWM5
14
+ NDI0ZTYxNTg0MzVlYTcwZjUyNDMwNGE5OTcxYmFkMjJiMGUxOTUzZGIxODQ1
15
+ NmEzNjM5OTBhZWE1ZTk4OTgzZTBjYTU5ZmViM2Y5N2M3Y2ZlZDI=
@@ -9,6 +9,7 @@ module BadLinkFinder
9
9
  @link = link
10
10
  @url = get_url_from_link(link)
11
11
 
12
+ verify_url(@url)
12
13
  validate_with_request
13
14
 
14
15
  rescue URI::InvalidURIError => exception
@@ -60,6 +61,12 @@ module BadLinkFinder
60
61
  URI.join(@page_url, link).to_s
61
62
  end
62
63
 
64
+ def verify_url(url)
65
+ if url.start_with?('http')
66
+ raise URI::InvalidURIError.new("The URL #{url} should start with http:// or https://") unless url =~ %r{^https?://}
67
+ end
68
+ end
69
+
63
70
  def record_error(message, exception = nil)
64
71
  @error_message = message
65
72
  @exception = exception
@@ -1,3 +1,3 @@
1
1
  module BadLinkFinder
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
@@ -27,10 +27,17 @@ describe BadLinkFinder::Link do
27
27
  end
28
28
 
29
29
  it "reports malformed links without checking the internet" do
30
- link = build_link('htt[]://{an-example-path}')
30
+ hrefs = [
31
+ 'htt[]://{an-example-path}',
32
+ 'http:www.example.com'
33
+ ]
31
34
 
32
- refute link.valid?
33
- assert_equal "This link is in a bad format", link.error_message
35
+ hrefs.each do |href|
36
+ link = build_link(href)
37
+
38
+ refute link.valid?
39
+ assert_equal "This link is in a bad format", link.error_message
40
+ end
34
41
  end
35
42
 
36
43
  it "reports links returning failure status codes" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bad_link_finder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elliot Crosby-McCullough
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-03 00:00:00.000000000 Z
11
+ date: 2013-12-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mechanize