awesome_bot 1.3.3 → 1.4.0

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: 8f4eaebd0ceb7d910abbfcc44a70d69e31490ca9
4
- data.tar.gz: 5b4e45aa0a884b43cf75f0ee173a0e90cc6db5b6
3
+ metadata.gz: 0c2ad393dacd395f168e5dcec9d326cf721aa840
4
+ data.tar.gz: 4f91280d25a56aac470f1277e6871ee143a3e7fb
5
5
  SHA512:
6
- metadata.gz: ea6709ee56f65e61e8e15f3151c1301be3a19157c91d76e600dc25343c85adcda8153e14963bf873521be1ac4cb2a2392fd38828e408b4c352ccbadf5cacde64
7
- data.tar.gz: 743870bb7619c31f7615717c89d5b7b9c5345a020748f8ba742ed04a74a5da92356acd0af952a368ed9917ae09ee281e88ed155741118c2d60d7b7a11ffd3f65
6
+ metadata.gz: f7527e8cdef9febad7a1150d7661225ddf424564ca370170dd7979f0b647dcea372042c5e64d74cb26c698c5fe98a4f60b786d37ce59d9a2c12457ac0cc13872
7
+ data.tar.gz: 0ef28356259469480e62deb04ec970ca3fdb8904cf11d65da8c446acc8df5bc1e5b137238cac3c4f265a058bf0459ea91269b5c9079ee6b4f9e632b820090924
@@ -7,5 +7,8 @@ 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
11
  - awesome_bot bin/assets/test-dupe --allow-dupe
12
+ - awesome_bot bin/assets/test-timeout --allow-timeout --set-timeout 1
13
+ - awesome_bot bin/assets/test-timeout-and-redirect --allow-timeout --set-timeout 1 --allow-redirect
11
14
  - awesome_bot README.md --allow-dupe --white-list gph.is,bot.svg,codeload,badge,rubydoc
@@ -50,6 +50,10 @@
50
50
 
51
51
  - [gemspec] remove uri dependency
52
52
 
53
+ # 1.4.0
54
+
55
+ - add `--allow-timeout` and `--set-timeout` options
56
+
53
57
  ## Contact
54
58
 
55
59
  - [github.com/dkhamsing](https://github.com/dkhamsing)
data/README.md CHANGED
@@ -43,7 +43,13 @@ More information at [rubydoc](http://www.rubydoc.info/gems/awesome_bot).
43
43
 
44
44
  ### Command Line
45
45
 
46
- awesome_bot <file> [--allow-dupe] [--allow-redirect] [--white-list item1,item2,..]
46
+ awesome_bot <file> [--allow-dupe] [--allow-redirect] [--allow-timeout] [--set-timeout d] [--white-list item1,item2,..]
47
+ file Path to file
48
+ --allow-dupe Duplicates URLs are allowed URLs
49
+ --allow-redirect Redirected URLs are allowed
50
+ --allow-timeout URLs that time out are allowed
51
+ --set-timeout Set connection timeout (seconds)
52
+ --white-list Comma separated URLs to white list
47
53
 
48
54
  ```shell
49
55
  $ awesome_bot README.md
@@ -138,19 +144,27 @@ script:
138
144
  - https://github.com/matteocrippa/awesome-swift
139
145
  - https://github.com/iCHAIT/awesome-osx
140
146
  - https://github.com/ellisonleao/magictools
147
+ - https://github.com/JStumpp/awesome-android
141
148
  - https://github.com/chentsulin/awesome-graphql
149
+ - https://github.com/fasouto/awesome-dataviz
142
150
  - https://github.com/RichardLitt/awesome-conferences
143
151
  - https://github.com/stefanbuck/awesome-browser-extensions-for-github
144
152
  - https://github.com/afonsopacifer/awesome-flexbox
145
153
  - https://github.com/HQarroum/awesome-iot
154
+ - https://github.com/filipelinhares/awesome-slack
155
+ - https://github.com/notthetup/awesome-webaudio
146
156
  - https://github.com/ipfs/awesome-ipfs
147
- - https://github.com/christian-bromann/awesome-selenium
157
+ - https://github.com/brunopulis/awesome-a11y
148
158
  - https://github.com/ramitsurana/awesome-kubernetes
159
+ - https://github.com/benoitjadinon/awesome-xamarin
160
+ - https://github.com/christian-bromann/awesome-selenium
149
161
  - https://github.com/vinkla/awesome-fuse
150
162
  - https://github.com/wfhio/awesome-job-boards
151
163
  - https://github.com/sotayamashita/awesome-css
152
164
  - https://github.com/MakinGiants/awesome-mobile-dev
153
165
  - https://github.com/unixorn/awesome-zsh-plugins
166
+ - https://github.com/vredniy/awesome-newsletters
167
+ - https://github.com/unixorn/git-extra-commands
154
168
 
155
169
  ## Credits
156
170
 
@@ -0,0 +1,2 @@
1
+ [Eddystone](https://en.wikipedia.org/wiki/Eddystone_(Google))
2
+ her [dockerfiles](https://github.com/jfrazelle/dockerfiles))
@@ -0,0 +1,2 @@
1
+ http://platipy.org
2
+ https://github.com
@@ -0,0 +1,4 @@
1
+ http://platipy.org
2
+ https://github.com
3
+
4
+ https://github.com/supermarin/Alcatraz
@@ -7,11 +7,17 @@ require 'awesome_bot/version'
7
7
  module AwesomeBot
8
8
  OPTION_DUPE = 'allow-dupe'
9
9
  OPTION_REDIRECT = 'allow-redirect'
10
+ OPTION_TIMEOUT_ALLOW = 'allow-timeout'
11
+ OPTION_TIMEOUT_SET = 'set-timeout'
10
12
  OPTION_WHITE_LIST = 'white-list'
11
13
 
12
14
  USAGE = "\t"
13
15
 
14
16
  class << self
17
+ def make_option(o)
18
+ "--#{o}"
19
+ end
20
+
15
21
  def output(x, k)
16
22
  s = x['status']
17
23
  print "#{k + 1}. "
@@ -22,16 +28,21 @@ module AwesomeBot
22
28
  end
23
29
 
24
30
  def cli
25
- option_d = "--#{OPTION_DUPE}"
26
- option_r = "--#{OPTION_REDIRECT}"
27
- option_w = "--#{OPTION_WHITE_LIST}"
31
+ option_d = make_option OPTION_DUPE
32
+ option_r = make_option OPTION_REDIRECT
33
+ option_t = make_option OPTION_TIMEOUT_SET
34
+ option_t_a = make_option OPTION_TIMEOUT_ALLOW
35
+ option_w = make_option OPTION_WHITE_LIST
28
36
 
29
37
  if ARGV.count == 0
30
38
  puts "Usage: #{PROJECT} <file> [#{option_d}] [#{option_r}] "\
39
+ "[#{option_t_a}] [#{option_t} d] "\
31
40
  "[#{option_w} item1,item2,..]\n"\
32
- "#{USAGE} file \t\t Path to file \n"\
41
+ "#{USAGE} file \t\t Path to file \n"\
33
42
  "#{USAGE} #{option_d} \t Duplicates URLs are allowed URLs \n"\
34
43
  "#{USAGE} #{option_r} Redirected URLs are allowed \n"\
44
+ "#{USAGE} #{option_t_a} URLs that time out are allowed \n"\
45
+ "#{USAGE} #{option_t} \t Set connection timeout (seconds) \n"\
35
46
  "#{USAGE} #{option_w} \t Comma separated URLs to white list \n"\
36
47
  "\nVersion #{VERSION}, see #{PROJECT_URL} for more information"
37
48
  exit
@@ -48,12 +59,22 @@ module AwesomeBot
48
59
  allow_redirects = options.include? option_r
49
60
  puts '> Will allow redirects' if allow_redirects == true
50
61
 
62
+ allow_timeouts = options.include? option_t_a
63
+ puts '> Will allow network timeouts' if allow_timeouts == true
64
+
51
65
  if options.include? option_w
52
66
  i = options.find_index(option_w) + 1
53
67
  white_listed = options[i].split ','
54
68
  end
69
+
70
+ if options.include? option_t
71
+ i = options.find_index(option_t) + 1
72
+ timeout = options[i].to_i
73
+ puts "> Connection timeout = #{timeout}s"
74
+ end
55
75
  else
56
76
  allow_redirects = false
77
+ allow_timeouts = false
57
78
  end
58
79
 
59
80
  begin
@@ -63,6 +84,7 @@ module AwesomeBot
63
84
  exit 1
64
85
  end
65
86
 
87
+ Faraday.options.timeout = timeout unless timeout.nil?
66
88
 
67
89
  log = Log.new(true)
68
90
  r = check(content, white_listed, skip_dupe, log)
@@ -74,18 +96,19 @@ module AwesomeBot
74
96
  end
75
97
  end
76
98
 
77
- if r.success(allow_redirects) == true
99
+ if r.success(allow_redirects, allow_timeouts) == true
78
100
  puts 'No issues :-)'
79
101
  # exit ?
80
102
  else
81
103
  puts "\nIssues :-("
82
104
 
83
105
  print "> Links \n"
84
- if r.success_links(allow_redirects)
106
+ if r.success_links(allow_redirects, allow_timeouts)
85
107
  puts " All OK #{STATUS_OK}"
86
108
  else
87
- r.statuses_issues(allow_redirects).each_with_index do |x, k|
88
- output x, k
109
+ r.statuses_issues(allow_redirects, allow_timeouts)
110
+ .each_with_index do |x, k|
111
+ output x, k
89
112
  end
90
113
  end
91
114
 
@@ -20,15 +20,28 @@ module AwesomeBot
20
20
  @rejected, @links = links.partition { |u| AwesomeBot.white_list @w, u }
21
21
  end
22
22
 
23
- def statuses_issues(allow_redirects = false)
23
+ def statuses_issues(allow_redirects = false, allow_timeouts = false)
24
24
  s = status.select { |x| x['status'] != 200 }
25
- return s if allow_redirects == false
26
-
27
- s.reject { |x| (x['status'] > 299) && (x['status'] < 400) }
25
+ r = s.reject { |x| (x['status'] > 299) && (x['status'] < 400) }
26
+ t = s.reject do |x|
27
+ (x['status'] == -1) && ((x['error'].message == 'Net::ReadTimeout') || (x['error'].message == 'execution expired'))
28
+ end
29
+
30
+ if (allow_redirects == false) && (allow_timeouts == false)
31
+ return s
32
+ elsif (allow_redirects == true) && (allow_timeouts == false)
33
+ return r
34
+ elsif (allow_redirects == false) && (allow_timeouts == true)
35
+ return t
36
+ else
37
+ return r.reject do |x|
38
+ (x['status'] == -1) && ((x['error'].message == 'Net::ReadTimeout') || (x['error'].message == 'execution expired'))
39
+ end
40
+ end
28
41
  end
29
42
 
30
- def success(allow_redirects = false)
31
- success_dupe && success_links(allow_redirects)
43
+ def success(allow_redirects = false, allow_timeouts = false)
44
+ success_dupe && success_links(allow_redirects, allow_timeouts)
32
45
  end
33
46
 
34
47
  def success_dupe
@@ -36,8 +49,8 @@ module AwesomeBot
36
49
  links.uniq.count == links.count
37
50
  end
38
51
 
39
- def success_links(allow_redirects = false)
40
- statuses_issues(allow_redirects).count == 0
52
+ def success_links(allow_redirects = false, allow_timeouts = false)
53
+ statuses_issues(allow_redirects, allow_timeouts).count == 0
41
54
  end
42
55
 
43
56
  def white_listing
@@ -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.3.3'
8
+ VERSION = '1.4.0'
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.3.3
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Khamsing
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-21 00:00:00.000000000 Z
11
+ date: 2015-12-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -74,6 +74,9 @@ files:
74
74
  - bin/assets/test-no-dupes
75
75
  - bin/assets/test-no-issues
76
76
  - bin/assets/test-no-links
77
+ - bin/assets/test-parse
78
+ - bin/assets/test-timeout
79
+ - bin/assets/test-timeout-and-redirect
77
80
  - bin/awesome_bot
78
81
  - bin/console
79
82
  - bin/setup