sla 0.0.2 → 0.0.3

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: 01f60c128b7038b32831ed7011616cabe8192e7d
4
- data.tar.gz: d3e011da78e545c9612060339ec8a4bd150e8f38
3
+ metadata.gz: 7c4f0612c8ccebbc1c29a22eee3ad61cd7610563
4
+ data.tar.gz: 1e6ed70e361c653b2c780e4be344ecd624529efc
5
5
  SHA512:
6
- metadata.gz: 8f86a06953f843f733e0b6be1816e65a0170a06e1fb8d13f84b7a813bf5fb2ba5319e58516d2cee551abc3c80b2eca7a2ac7848fa7b29b32cec17bbec84b8a4b
7
- data.tar.gz: 125008c1d368a3ee447e203644c39bad83405ad65de09acadfa5c402f7d429c0b9b3ad8dab6b228438f9767340209aba6823aa265519a77c3a669db5a0786b34
6
+ metadata.gz: b2c1eb8bc98e1c0139e7e7155744cba9266364c6edc1f5bd254af233643f4eee50693171fc247f3555b31e1d1a6191df90bcb763dac825935253274805bee1ba
7
+ data.tar.gz: 216a0aa3ca464ad342826f60c1f1e73dbde5b5f0d17aadafe24551d658f52e665d7ae3513b5b086039e66b5f9800d27f447caa54c5ffd9cec58e341bbb9205d0
data/README.md CHANGED
@@ -2,6 +2,7 @@ Site Link Analyzer
2
2
  ==================================================
3
3
 
4
4
  [![Gem](https://img.shields.io/gem/v/sla.svg?style=flat-square)](https://rubygems.org/gems/sla)
5
+ [![Travis](https://img.shields.io/travis/DannyBen/sla.svg?style=flat-square)](https://travis-ci.org/DannyBen/sla)
5
6
  [![Code Climate](https://img.shields.io/codeclimate/github/DannyBen/sla.svg?style=flat-square)](https://codeclimate.com/github/DannyBen/sla)
6
7
  [![Gemnasium](https://img.shields.io/gemnasium/DannyBen/sla.svg?style=flat-square)](https://gemnasium.com/DannyBen/sla)
7
8
 
@@ -46,7 +47,13 @@ Options:
46
47
  --cache, -c LIFE
47
48
  Set cache life in seconds [default: 86400]
48
49
 
50
+ --cache-dir DIR
51
+ Set the cache directory [default: cache]
52
+
53
+ --color
54
+ Disable colors in output
55
+
49
56
  Examples:
50
57
  sla check example.com
51
58
  sla check example.com -c360 -d10
52
- ```
59
+ ```
data/lib/sla.rb CHANGED
@@ -15,6 +15,5 @@ require 'sla/cache'
15
15
  require 'sla/url_manager'
16
16
 
17
17
  # Remove before deploy
18
- require 'byebug'
19
- require 'awesome_print'
20
- require 'pp'
18
+ # require 'byebug'
19
+ # require 'pp'
@@ -5,6 +5,8 @@ module SLA
5
5
  def cache
6
6
  @cache ||= cache!
7
7
  end
8
+
9
+ private
8
10
 
9
11
  def cache!
10
12
  result = WebCache.new
@@ -30,14 +30,13 @@ module SLA
30
30
  def check_url(url, depth, &_block)
31
31
  page = Page.new url, depth: depth, base_url: base_url
32
32
  page.validate
33
+ checked_links.push url
33
34
 
34
- yield page
35
+ yield page if block_given?
35
36
  return if depth >= max_depth
36
37
 
37
38
  page.links.each do |link|
38
39
  next if checked_links.include? link.url
39
-
40
- checked_links.push link.url
41
40
  next_check.push link.url
42
41
  end
43
42
  end
@@ -13,20 +13,21 @@ module SLA
13
13
  end
14
14
  end
15
15
 
16
+ private
17
+
16
18
  def handle(args)
17
19
  if args['check']
18
- @domain = args['DOMAIN']
19
- @max_depth = args['--depth'].to_i
20
- @cache_life = args['--cache'].to_i
21
- check_domain
20
+ @no_color = args['--color']
21
+ check_domain args
22
22
  end
23
23
  end
24
24
 
25
- def check_domain
25
+ def check_domain(args)
26
26
  checker = Checker.new
27
- checker.max_depth = @max_depth
28
- checker.cache.life = @cache_life
29
- url_manager.base_url = @domain
27
+ checker.max_depth = args['--depth'].to_i
28
+ checker.cache.life = args['--cache'].to_i
29
+ checker.cache.dir = args['--cache-dir'] if args['--cache-dir']
30
+ url_manager.base_url = args['DOMAIN']
30
31
 
31
32
  File.unlink 'log.log' if File.exist? 'log.log'
32
33
 
@@ -47,6 +48,7 @@ module SLA
47
48
  end
48
49
 
49
50
  color = failed > 0 ? '!txtred!' : '!txtgrn!'
51
+ color = "" if @no_color
50
52
  say "#{color}Done with #{failed} failures"
51
53
  f.puts "Done with #{failed} failures"
52
54
  end
@@ -54,6 +56,8 @@ module SLA
54
56
  end
55
57
 
56
58
  def color_status(status)
59
+ return status if @no_color
60
+ # :nocov:
57
61
  case status
58
62
  when '200'
59
63
  '!txtgrn!200!txtrst!'
@@ -62,6 +66,7 @@ module SLA
62
66
  else
63
67
  status
64
68
  end
69
+ # :nocov:
65
70
  end
66
71
 
67
72
  end
@@ -15,6 +15,12 @@ Options:
15
15
  --cache, -c LIFE
16
16
  Set cache life in seconds [default: 86400]
17
17
 
18
+ --cache-dir DIR
19
+ Set the cache directory
20
+
21
+ --color
22
+ Disable colors in output
23
+
18
24
  Examples:
19
25
  sla check example.com
20
26
  sla check example.com -c360 -d10
@@ -11,7 +11,7 @@ module SLA
11
11
  end
12
12
 
13
13
  def valid?
14
- content
14
+ validate
15
15
  status == '200'
16
16
  end
17
17
 
@@ -1,3 +1,3 @@
1
1
  module SLA
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sla
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Danny Ben Shitrit
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-14 00:00:00.000000000 Z
11
+ date: 2016-07-15 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: runfile
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '0.8'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '0.8'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: colsole
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -137,19 +123,33 @@ dependencies:
137
123
  - !ruby/object:Gem::Version
138
124
  version: '9.0'
139
125
  - !ruby/object:Gem::Dependency
140
- name: awesome_print
126
+ name: rspec
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '3.4'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '3.4'
139
+ - !ruby/object:Gem::Dependency
140
+ name: simplecov
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
143
  - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: '1.7'
145
+ version: '0.11'
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - "~>"
151
151
  - !ruby/object:Gem::Version
152
- version: '1.7'
152
+ version: '0.11'
153
153
  description: Check for broken links on a website
154
154
  email: db@dannyben.com
155
155
  executables:
@@ -181,7 +181,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
181
181
  requirements:
182
182
  - - ">="
183
183
  - !ruby/object:Gem::Version
184
- version: 2.0.0
184
+ version: 2.2.2
185
185
  required_rubygems_version: !ruby/object:Gem::Requirement
186
186
  requirements:
187
187
  - - ">="
@@ -189,7 +189,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
189
189
  version: '0'
190
190
  requirements: []
191
191
  rubyforge_project:
192
- rubygems_version: 2.5.1
192
+ rubygems_version: 2.6.6
193
193
  signing_key:
194
194
  specification_version: 4
195
195
  summary: Site Link Analyzer