sla 0.0.5 → 0.0.6

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: 50ec41399fd977f97a9987ff148f9846f1aecae2
4
- data.tar.gz: 93d2d55e73f5f812a5615a324af9b41031a183cd
3
+ metadata.gz: 1aef2c99c5add4cd1609324877dc739ae125b7ea
4
+ data.tar.gz: 65feca5ae91b4dfff63599188b666c21fa44b94c
5
5
  SHA512:
6
- metadata.gz: eb27195220e441b517b7eac34466479117c1a4e4f195f39fe753abb1348b9270833c00278834921b80f1af92cf17cf70da51330516e339d53b28ce11d30d72a1
7
- data.tar.gz: 465e9965dddb77655299f70d04f79694746ca81af7333052fa43f2748a3e4e397c5a9f869f5bdd6f802c278bc0662b8e37655f87c7bad58ea6e140aa3e995433
6
+ metadata.gz: e1249956cd581a42d4e7ffe7c8af8ad8097fd77c84efa7679518b09d5e9451e470c5857cc71d6799b2ebf51c9a2727d36b2faf21de03c4e3579cd56bfe3d9c01
7
+ data.tar.gz: 820a50215cc6b9ec3eb6cc2701eb3a6f62a69a9bf53a0420418691d543fbf0a44b3725b5cb59825c0b1126666b431fc46d3542b00bf65e3cd9152a43adcc77e2
data/README.md CHANGED
@@ -74,6 +74,9 @@ Options:
74
74
  --cache-dir DIR
75
75
  Set the cache directory
76
76
 
77
+ --external
78
+ Also check external links
79
+
77
80
  --no-color
78
81
  Disable colors in output
79
82
 
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
 
@@ -25,11 +25,12 @@ module SLA
25
25
 
26
26
  def check_domain(args)
27
27
  checker = Checker.new
28
- checker.max_depth = args['--depth'].to_i
29
- Cache.settings.life = args['--cache'].to_i
30
- Cache.settings.dir = args['--cache-dir'] if args['--cache-dir']
31
- logfile = args['--log']
32
- start_url = args['DOMAIN']
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
@@ -18,6 +18,9 @@ Options:
18
18
  --cache-dir DIR
19
19
  Set the cache directory
20
20
 
21
+ --external
22
+ Also check external links
23
+
21
24
  --no-color
22
25
  Disable colors in output
23
26
 
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.interesting?
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 interesting?
81
- !external? && full_uri.scheme =~ /^http/
80
+ def relevant?
81
+ full_uri.scheme =~ /^http/
82
82
  end
83
83
  end
84
84
  end
data/lib/sla/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module SLA
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sla
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Danny Ben Shitrit