link-checker 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +10 -4
- data/VERSION +1 -1
- data/bin/check-links +1 -1
- data/lib/link_checker.rb +4 -2
- data/link-checker.gemspec +1 -1
- metadata +20 -20
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
-
#
|
1
|
+
# Link Checker
|
2
2
|
|
3
|
-
This Ruby gem
|
3
|
+
This Ruby gem enables you to easily check the links in your web site. It will scan each ```.html``` or ```.htm``` file and then check each external link within each file.
|
4
|
+
|
5
|
+
It will print the file path in green if all of the external links check out, and red if there are any problems. If there are any problems then it will list each problem URL. It will display yellow warnings for URLs that redirect to other URLs that are good, or red errors if the redirect does not lead to a good URL.
|
4
6
|
|
5
7
|
## Installation
|
6
8
|
|
@@ -12,12 +14,16 @@ Then ```bundle install``` to install the gem.
|
|
12
14
|
|
13
15
|
## Usage
|
14
16
|
|
15
|
-
You can use the ```check-links``` command to specify any directory to scan for HTML files.
|
17
|
+
You can use the ```check-links``` command to specify any directory to scan for HTML files.
|
16
18
|
|
17
|
-
For example, to check the links for
|
19
|
+
For example, to check the links for an Octopress site:
|
18
20
|
|
19
21
|
check-links 'public'
|
20
22
|
|
23
|
+
To check the links for a Jekyll site:
|
24
|
+
|
25
|
+
check-links
|
26
|
+
|
21
27
|
## Testing
|
22
28
|
|
23
29
|
The ```link-checker``` gem uses [RSpec](http://rspec.info) for testing and has 100% test coverage, verified using [simplecov](https://github.com/colszowka/simplecov).
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/bin/check-links
CHANGED
data/lib/link_checker.rb
CHANGED
@@ -19,7 +19,10 @@ class LinkChecker
|
|
19
19
|
|
20
20
|
def self.find_external_links(file_path)
|
21
21
|
Nokogiri::HTML(open(file_path)).css('a').
|
22
|
-
select
|
22
|
+
select do |link|
|
23
|
+
!link.attribute('href').nil? &&
|
24
|
+
link.attribute('href').value =~ /^https?\:\/\//
|
25
|
+
end
|
23
26
|
end
|
24
27
|
|
25
28
|
def self.check_link(uri, redirected=false)
|
@@ -49,7 +52,6 @@ class LinkChecker
|
|
49
52
|
find_html_files.each do |file|
|
50
53
|
bad_checks = []
|
51
54
|
warnings = []
|
52
|
-
|
53
55
|
self.class.find_external_links(file).each do |link|
|
54
56
|
uri = link.attribute('href').value
|
55
57
|
begin
|
data/link-checker.gemspec
CHANGED
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.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-10-04 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|
16
|
-
requirement: &
|
16
|
+
requirement: &70123915371780 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 1.5.5
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70123915371780
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: colorize
|
27
|
-
requirement: &
|
27
|
+
requirement: &70123915371000 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 0.5.8
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70123915371000
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rspec
|
38
|
-
requirement: &
|
38
|
+
requirement: &70123915370260 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 2.11.0
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70123915370260
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: jeweler
|
49
|
-
requirement: &
|
49
|
+
requirement: &70123915386020 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 1.8.4
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70123915386020
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: simplecov
|
60
|
-
requirement: &
|
60
|
+
requirement: &70123915385300 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: 0.6.4
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70123915385300
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: fakeweb
|
71
|
-
requirement: &
|
71
|
+
requirement: &70123915384680 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ~>
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: 1.3.0
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70123915384680
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: yard
|
82
|
-
requirement: &
|
82
|
+
requirement: &70123915384020 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ~>
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: 0.8.2.1
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *70123915384020
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: redcarpet
|
93
|
-
requirement: &
|
93
|
+
requirement: &70123915383280 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ~>
|
@@ -98,10 +98,10 @@ dependencies:
|
|
98
98
|
version: 2.1.1
|
99
99
|
type: :development
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *70123915383280
|
102
102
|
- !ruby/object:Gem::Dependency
|
103
103
|
name: debugger
|
104
|
-
requirement: &
|
104
|
+
requirement: &70123915382660 !ruby/object:Gem::Requirement
|
105
105
|
none: false
|
106
106
|
requirements:
|
107
107
|
- - ! '>='
|
@@ -109,7 +109,7 @@ dependencies:
|
|
109
109
|
version: '0'
|
110
110
|
type: :development
|
111
111
|
prerelease: false
|
112
|
-
version_requirements: *
|
112
|
+
version_requirements: *70123915382660
|
113
113
|
description: Check the links in a web site before deploying, using Nokogiri.
|
114
114
|
email:
|
115
115
|
executables:
|
@@ -481,7 +481,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
481
481
|
version: '0'
|
482
482
|
segments:
|
483
483
|
- 0
|
484
|
-
hash:
|
484
|
+
hash: 4067428474501451879
|
485
485
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
486
486
|
none: false
|
487
487
|
requirements:
|