bucky-core 0.10.6 → 0.10.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 95eea4889710b2e9a9c9ed0c75cb3383e9036119
4
- data.tar.gz: 92eb538f8b984f71e3f06534adbc2f7a014fea37
3
+ metadata.gz: ba4cfdfb0d88340a326b8bb17c55517e8f4e9838
4
+ data.tar.gz: d52796926a4bdd0bce45326f73aeb4b0bddd62f7
5
5
  SHA512:
6
- metadata.gz: cac44cb6d544e868a146a26ae5e38b1547557072eb1d6722e38c33a571d578fa078f574dfc6f93206d54d212edae32c0266190f2f4c2c70375f87284dca686fb
7
- data.tar.gz: 4905bbbeb5dd84b279b746d250a7cfc40a9c690f22def77666b590dfad104c58f45a05fc228e0e9762b41e3838a12b30583bae92df60370d6f0b8722c963b0d7
6
+ metadata.gz: f30e29812db9cf2b91c771e5565d4d477dd0c2f59675878a3a17c24891c2d3aea99cf650609ea60ee5b6c2665cf40d8c22a098d12773782bf211f2245659daa4
7
+ data.tar.gz: c8018498f6471c2744e8142c883853b2a9575e96b21aa2f27bdd7e1cf33a0e596de9334348201d6a089922c164343cbed4fffea7f20678d785983af8759617a2
@@ -61,7 +61,7 @@ MethodLength:
61
61
  Enabled: false
62
62
 
63
63
  ModuleLength:
64
- Max: 120
64
+ Max: 130
65
65
  Exclude:
66
66
  - 'spec/**/*.rb'
67
67
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bucky-core (0.10.5)
4
+ bucky-core (0.10.6)
5
5
  addressable (~> 2.5)
6
6
  color_echo (~> 3.1)
7
7
  json (~> 2.1)
@@ -34,7 +34,11 @@ module Bucky
34
34
  # If number of requests is over redirect limit
35
35
  return { error_message: "\n[Redirect Error] #{url} is redirected more than #{REDIRECT_LIMIT}" } if redirect_count > REDIRECT_LIMIT
36
36
 
37
- check_result = check_log_and_get_response(url, device, link_check_max_times, url_log)
37
+ begin
38
+ check_result = check_log_and_get_response(url, device, link_check_max_times, url_log)
39
+ rescue Net::ReadTimeout => e
40
+ return { error_message: "#{e.message} Please check this url: #{url}" }
41
+ end
38
42
  # If result include response continue to check, else return result
39
43
  !check_result.key?(:response) ? (return check_result) : response = check_result[:response]
40
44
 
@@ -46,13 +50,8 @@ module Bucky
46
50
  puts " #{url} ... [#{response.code}:OK]"
47
51
  { entity: response.entity }
48
52
  when /3[0-9]{2}/
49
- fqdn = url[%r{^(https?:\/\/([a-zA-Z0-9\-_.]+))}]
50
- redirect_url = response['location']
51
- # Add fqdn if location doesn't include fqdn
52
- redirect_url = fqdn << redirect_url unless redirect_url.include?('http')
53
- puts " #{url} ... redirect to #{redirect_url} [#{response.code}:RD]"
54
- http_status_check_args = { url: redirect_url, device: device, link_check_max_times: link_check_max_times, url_log: url_log, redirect_count: redirect_count + 1, redirect_url_list: redirect_url_list }
55
- http_status_check(http_status_check_args)
53
+ http_status_check_args = { url: url, device: device, link_check_max_times: link_check_max_times, url_log: url_log, redirect_count: redirect_count + 1, redirect_url_list: redirect_url_list }
54
+ redirect_and_http_status_check(response, http_status_check_args)
56
55
  when /(4|5)[0-9]{2}/
57
56
  url_log[url][:error_message] = "[Status Error] http status returned #{response.code}.\ncheck this url: #{redirect_url_list.join(' -> ')}"
58
57
  puts " #{url} ... [#{response.code}:NG]"
@@ -82,12 +81,12 @@ module Bucky
82
81
  # Check base url
83
82
  http_status_check_args = { url: url, device: device, link_check_max_times: link_check_max_times, url_log: url_log, redirect_count: 0, redirect_url_list: [] }
84
83
  base_response = http_status_check(http_status_check_args)
85
- assert_nil(base_response[:error_message], "Response of base URL is incorrect.\n#{base_response[:error_message]}")
84
+ raise Test::Unit::AssertionFailedError, "Response of base URL is incorrect.\n#{base_response[:error_message]}" unless base_response[:error_message].nil?
86
85
 
87
86
  # Collect links
88
87
  links_args = { base_url: base_url, base_fqdn: base_fqdn, url_reg: url_reg, only_same_fqdn: only_same_fqdn, entity: base_response[:entity] }
89
88
  links = make_target_links(links_args)
90
- links = exclude(links, exclude_urls) unless exclude_urls.nil?
89
+ links = exclude(links, exclude_urls)
91
90
 
92
91
  errors = []
93
92
  Parallel.each(links.uniq, in_threads: Bucky::Utils::Config.instance[:linkstatus_thread_num]) do |link|
@@ -96,7 +95,7 @@ module Bucky
96
95
  link_response = http_status_check(http_status_check_args)
97
96
  errors << link_response[:error_message] if link_response[:error_message]
98
97
  end
99
- assert_empty(errors, errors.join("\n"))
98
+ raise Test::Unit::AssertionFailedError, errors.join("\n") unless errors.empty?
100
99
  end
101
100
 
102
101
  def make_target_links(args)
@@ -128,6 +127,8 @@ module Bucky
128
127
 
129
128
  # Exclude non test target url
130
129
  def exclude(links, exclude_urls)
130
+ return links if exclude_urls.nil?
131
+
131
132
  excluded_links = links - exclude_urls
132
133
 
133
134
  # Exclude url if it has "*" in the last of it
@@ -178,6 +179,16 @@ module Bucky
178
179
  href.insert(0, '/') unless href.match(%r{^/|^#})
179
180
  base_url + href
180
181
  end
182
+
183
+ def redirect_and_http_status_check(response, http_status_check_args)
184
+ fqdn = http_status_check_args[:url][%r{^(https?:\/\/([a-zA-Z0-9\-_.]+))}]
185
+ redirect_url = response['location']
186
+ # Add fqdn if location doesn't include fqdn
187
+ redirect_url = fqdn << redirect_url unless redirect_url.include?('http')
188
+ puts " #{http_status_check_args[:url]} ... redirect to #{redirect_url} [#{response.code}:RD]"
189
+ http_status_check_args[:url] = redirect_url
190
+ http_status_check(http_status_check_args)
191
+ end
181
192
  end
182
193
  end
183
194
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Bucky
4
4
  module Version
5
- VERSION = '0.10.6'
5
+ VERSION = '0.10.7'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bucky-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.6
4
+ version: 0.10.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - NaotoKishino
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: exe
15
15
  cert_chain: []
16
- date: 2020-03-30 00:00:00.000000000 Z
16
+ date: 2020-04-27 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: awesome_print