sla 0.0.5 → 0.0.6
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 +4 -4
- data/README.md +3 -0
- data/lib/sla/checker.rb +7 -1
- data/lib/sla/command_line.rb +6 -5
- data/lib/sla/docopt.txt +3 -0
- data/lib/sla/link.rb +4 -4
- data/lib/sla/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1aef2c99c5add4cd1609324877dc739ae125b7ea
|
4
|
+
data.tar.gz: 65feca5ae91b4dfff63599188b666c21fa44b94c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e1249956cd581a42d4e7ffe7c8af8ad8097fd77c84efa7679518b09d5e9451e470c5857cc71d6799b2ebf51c9a2727d36b2faf21de03c4e3579cd56bfe3d9c01
|
7
|
+
data.tar.gz: 820a50215cc6b9ec3eb6cc2701eb3a6f62a69a9bf53a0420418691d543fbf0a44b3725b5cb59825c0b1126666b431fc46d3542b00bf65e3cd9152a43adcc77e2
|
data/README.md
CHANGED
data/lib/sla/checker.rb
CHANGED
@@ -2,11 +2,12 @@ module SLA
|
|
2
2
|
class Checker
|
3
3
|
include Colsole
|
4
4
|
|
5
|
-
attr_accessor :max_depth, :checked_links
|
5
|
+
attr_accessor :max_depth, :checked_links, :check_external
|
6
6
|
|
7
7
|
def initialize
|
8
8
|
@max_depth = 10
|
9
9
|
@checked_links = []
|
10
|
+
@check_external = false
|
10
11
|
end
|
11
12
|
|
12
13
|
def count
|
@@ -15,12 +16,17 @@ module SLA
|
|
15
16
|
|
16
17
|
def check(link, depth=1, &block)
|
17
18
|
link = Link.new link, depth: depth if link.is_a? String
|
19
|
+
|
20
|
+
return if link.external? && !@check_external
|
21
|
+
|
18
22
|
link.validate
|
19
23
|
yield link if block_given?
|
20
24
|
|
21
25
|
return if checked_links.include? link.url
|
26
|
+
|
22
27
|
checked_links.push link.url
|
23
28
|
|
29
|
+
return if link.external?
|
24
30
|
return unless link.valid?
|
25
31
|
return if depth >= max_depth
|
26
32
|
|
data/lib/sla/command_line.rb
CHANGED
@@ -25,11 +25,12 @@ module SLA
|
|
25
25
|
|
26
26
|
def check_domain(args)
|
27
27
|
checker = Checker.new
|
28
|
-
checker.max_depth
|
29
|
-
|
30
|
-
Cache.settings.
|
31
|
-
|
32
|
-
|
28
|
+
checker.max_depth = args['--depth'].to_i
|
29
|
+
checker.check_external = args['--external']
|
30
|
+
Cache.settings.life = args['--cache'].to_i
|
31
|
+
Cache.settings.dir = args['--cache-dir'] if args['--cache-dir']
|
32
|
+
logfile = args['--log']
|
33
|
+
start_url = args['DOMAIN']
|
33
34
|
|
34
35
|
start_url = "http://#{start_url}" unless start_url[0..3] == 'http'
|
35
36
|
|
data/lib/sla/docopt.txt
CHANGED
data/lib/sla/link.rb
CHANGED
@@ -31,7 +31,7 @@ module SLA
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def ident
|
34
|
-
full_uri.request_uri
|
34
|
+
external? ? full_uri.to_s : full_uri.request_uri
|
35
35
|
end
|
36
36
|
|
37
37
|
def url
|
@@ -51,7 +51,7 @@ module SLA
|
|
51
51
|
result = []
|
52
52
|
anchors.each do |a|
|
53
53
|
link = Link.new a['href'], text: a.text, parent: real_uri, depth: depth+1
|
54
|
-
result.push link if link.
|
54
|
+
result.push link if link.relevant?
|
55
55
|
end
|
56
56
|
result
|
57
57
|
end
|
@@ -77,8 +77,8 @@ module SLA
|
|
77
77
|
parent.host != full_uri.host
|
78
78
|
end
|
79
79
|
|
80
|
-
def
|
81
|
-
|
80
|
+
def relevant?
|
81
|
+
full_uri.scheme =~ /^http/
|
82
82
|
end
|
83
83
|
end
|
84
84
|
end
|
data/lib/sla/version.rb
CHANGED