awesome_bot 1.5.0 → 1.5.1

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: 19d8dfe764c84b4cf654c29ba4d6bd9e953a1b9c
4
- data.tar.gz: 2811c9cdbae2178e934979da5f2885ffd5ba6968
3
+ metadata.gz: 86f47522c8abd6392f288ac1b07c0ad82304a593
4
+ data.tar.gz: 91e754b597dbf52696bf580c482097a01d59b9bf
5
5
  SHA512:
6
- metadata.gz: c566f671dae5922252856621d86052914e8c9f154c0ac31b30e70df1455ad9d0475ca1210ea84f9983e2edcf00b9dc9ef66448bdcdcdf9bd45c23afaee53f50f
7
- data.tar.gz: 3bcd9be66cf3a23fc0373f61fbe8ee7cde059bd0e5261df82fdb5b86ac5b571a6da5cd019010a9b240116ab066f957b2f055a22c8d960ed8a75372a9f667141a
6
+ metadata.gz: 43b2abdd184fce42b28121d65171720deafd55db92d4b6c75093acb0a526ca83309af7564da7efa26d06a656b2501ab579f56d169f049ede2843c3cc87ea1255
7
+ data.tar.gz: 987906144e1c1534d905433bc0ee44a616358197b4a589aabbaf2f3bf0b73e276fa802f4d03e0a9ab90ece70b19585bf6cb586db71384973125c77bd5d22437e
@@ -7,7 +7,7 @@ script:
7
7
  - awesome_bot
8
8
  - awesome_bot bin/assets/test-no-issues
9
9
  - awesome_bot bin/assets/test-no-links
10
- - awesome_bot bin/assets/test-parse
10
+ - awesome_bot bin/assets/test-parse --white-list coveralls,travis-ci
11
11
  - awesome_bot bin/assets/test-dupe --allow-dupe
12
12
  - awesome_bot bin/assets/test-timeout --allow-timeout --set-timeout 1
13
13
  - awesome_bot bin/assets/test-timeout-and-redirect --allow-timeout --set-timeout 1 --allow-redirect
@@ -56,14 +56,20 @@
56
56
 
57
57
  # 1.5.0
58
58
 
59
- - [output] display url redirect location, by [Colby M. White](https://github.com/colbywhite)
59
+ - [output] display url redirect location, by [Colby M. White][]
60
60
  - [output] update logic for number of unique links
61
61
  - [output] standardize indent
62
- - rename `Result` `rejected` to `links_white_listed`
62
+ - rename `Result` `rejected` to `links_white_listed`
63
+
64
+ # 1.5.1
65
+
66
+ - [fix] link parsing error with markdown badge
67
+ - improve code, suggested by [Colby M. White][]
63
68
 
64
69
  ## Contact
65
70
 
66
71
  - [github.com/dkhamsing](https://github.com/dkhamsing)
67
72
  - [twitter.com/dkhamsing](https://twitter.com/dkhamsing)
68
73
 
74
+ [Colby M. White]:https://github.com/colbywhite
69
75
  [R.I. Pienaar]:https://github.com/ripienaar
@@ -1,2 +1,4 @@
1
1
  [Eddystone](https://en.wikipedia.org/wiki/Eddystone_(Google))
2
2
  her [dockerfiles](https://github.com/jfrazelle/dockerfiles))
3
+
4
+ # ng-flow [![Build Status](https://travis-ci.org/flowjs/ng-flow.svg)](https://travis-ci.org/flowjs/ng-flow) [![Coverage Status](https://coveralls.io/repos/flowjs/ng-flow/badge.svg?branch=master&service=github)](https://coveralls.io/github/flowjs/ng-flow?branch=master)
@@ -9,9 +9,17 @@ module AwesomeBot
9
9
 
10
10
  STATUS_OK = '✓'
11
11
  STATUS_OTHER = 'x'
12
- STATUS_REDIRECT = '→'
12
+ STATUS_REDIRECT = '→'
13
13
 
14
14
  class << self
15
+ def log_status(s, log)
16
+ if status_is_redirected? s
17
+ log.addp STATUS_REDIRECT
18
+ else
19
+ log.addp(s == 200 ? STATUS_OK : STATUS_OTHER)
20
+ end
21
+ end
22
+
15
23
  def check(content, white_listed = nil, skip_dupe = false, log = Log.new)
16
24
  log.add '> Will allow duplicate links' if skip_dupe
17
25
 
@@ -34,11 +42,7 @@ module AwesomeBot
34
42
  log.addp 'Checking URLs: ' if r.links.count > 0
35
43
  r.status =
36
44
  statuses(r.links.uniq, NUMBER_OF_THREADS) do |s|
37
- if (s > 299) && (s < 400)
38
- log.addp STATUS_REDIRECT
39
- else
40
- log.addp(s == 200 ? STATUS_OK : STATUS_OTHER)
41
- end
45
+ log_status s, log
42
46
  end
43
47
  log.add ''
44
48
 
@@ -47,11 +51,7 @@ module AwesomeBot
47
51
  log.addp 'Checking white listed URLs: '
48
52
  r.white_listed =
49
53
  statuses(r.links_white_listed.uniq, NUMBER_OF_THREADS, true) do |s|
50
- if (s > 299) && (s < 400)
51
- log.addp STATUS_REDIRECT
52
- else
53
- log.addp(s == 200 ? STATUS_OK : STATUS_OTHER)
54
- end
54
+ log_status s, log
55
55
  end
56
56
  log.add ''
57
57
 
@@ -1,6 +1,7 @@
1
1
  require 'awesome_bot/check'
2
2
  require 'awesome_bot/log'
3
3
  require 'awesome_bot/result'
4
+ require 'awesome_bot/statuses'
4
5
  require 'awesome_bot/version'
5
6
 
6
7
  # Command line interface
@@ -24,7 +25,7 @@ module AwesomeBot
24
25
  print "#{s} " unless s == STATUS_ERROR
25
26
  print "#{x['url']}"
26
27
  print " #{x['error']}" if s == STATUS_ERROR
27
- print " #{STATUS_REDIRECT} #{x['headers']['location']}" if s > 299 && s <400
28
+ print " #{STATUS_REDIRECT} #{x['headers']['location']}" if status_is_redirected? s
28
29
  puts ''
29
30
  end
30
31
 
@@ -9,7 +9,9 @@ module AwesomeBot
9
9
  x.gsub(/'.*/, '').gsub(/,.*/, '').gsub('/:', '/')
10
10
  end
11
11
  .map do |x|
12
- if (x.scan(')').count == 2) && (x.scan('(').count == 1)
12
+ if x.include? ')]'
13
+ x.gsub /\)\].*/, ''
14
+ elsif (x.scan(')').count == 2) && (x.scan('(').count == 1)
13
15
  x.gsub(/\)\).*/, ')')
14
16
  elsif x.scan(')').count > 0
15
17
  x.gsub(/\).*/, '')
@@ -1,7 +1,8 @@
1
- require 'awesome_bot/white_list'
2
-
3
1
  # Result
4
2
  module AwesomeBot
3
+ require 'awesome_bot/statuses'
4
+ require 'awesome_bot/white_list'
5
+
5
6
  # Result
6
7
  class Result
7
8
  attr_accessor :dupes
@@ -23,7 +24,7 @@ module AwesomeBot
23
24
 
24
25
  def statuses_issues(allow_redirects = false, allow_timeouts = false)
25
26
  s = status.select { |x| x['status'] != 200 }
26
- r = s.reject { |x| (x['status'] > 299) && (x['status'] < 400) }
27
+ r = s.reject { |x| AwesomeBot.status_is_redirected? x['status'] }
27
28
  t = s.reject do |x|
28
29
  (x['status'] == -1) && ((x['error'].message == 'Net::ReadTimeout') || (x['error'].message == 'execution expired'))
29
30
  end
@@ -18,6 +18,10 @@ module AwesomeBot
18
18
  head ? net_head_status(url) : net_get_status(url)
19
19
  end
20
20
 
21
+ def status_is_redirected?(status)
22
+ (status > 299) && (status < 400)
23
+ end
24
+
21
25
  def statuses(links, threads, head = false)
22
26
  statuses = []
23
27
  Parallel.each(links, in_threads: threads) do |u|
@@ -25,6 +29,7 @@ module AwesomeBot
25
29
  response = net_status u, head
26
30
  status = response.status
27
31
  headers = response.headers
32
+ error = nil # nil (success)
28
33
  rescue => e
29
34
  status = STATUS_ERROR
30
35
  headers = {}
@@ -5,5 +5,5 @@ module AwesomeBot
5
5
  'Great for "awesome" projects.'
6
6
  PROJECT_URL = 'https://github.com/dkhamsing/awesome_bot'
7
7
 
8
- VERSION = '1.5.0'
8
+ VERSION = '1.5.1'
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: awesome_bot
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Khamsing
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-04 00:00:00.000000000 Z
11
+ date: 2016-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday