url-status 1.0.2 → 1.0.5

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: 282caf40c639207e50080ad363f4b67391bccb37
4
- data.tar.gz: 9d6eeabcf22037c22c34c2a54f91a5933f470e2b
3
+ metadata.gz: 464dd6bff417b902058f071064a0c16a15c9a537
4
+ data.tar.gz: d3188a0b1a175ff6b78626434bef465adf8f282d
5
5
  SHA512:
6
- metadata.gz: 6a811b2e5a8fecbab90329a7963da84ddaeb52d7725c2abae21f83f80f574325558328390008b173be1b2362131444da8a7e98b1d868226938ff16d4c02095f1
7
- data.tar.gz: 9af417813d4ec27ad440a4da7fac7b14eacfa446449ec6287d62f2e706852890baae9ee64f49c16076ffa0b7d7aee8b87db001737afe8caed9215832d0b2359a
6
+ metadata.gz: 15433535e360fe36159845fb9e4e2ff8d93d86b0862d6da589a25e92e891b54576f6190419c7a668f6a8e454cf7208c1cd241683762b00b9a84ddd2349a395d3
7
+ data.tar.gz: 3c7b3ba72b743e95644c09a28bc718788af310fe2597d40276193a8ac1ed619004241494936d45cfc4c209f2c27b484da0c2c2f5487523037b6998aae2fe0d81
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- url_status (0.1.0)
4
+ url-status (1.0.2)
5
5
  colorize
6
6
  rest-client (~> 1.8)
7
7
  trollop
@@ -32,7 +32,7 @@ PLATFORMS
32
32
  DEPENDENCIES
33
33
  bundler (~> 1.12)
34
34
  rake (~> 10.0)
35
- url_status!
35
+ url-status!
36
36
 
37
37
  BUNDLED WITH
38
38
  1.12.5
@@ -14,18 +14,33 @@ module UrlStatus
14
14
 
15
15
  class App
16
16
  def main
17
+ # we want to disable the text coloring if we are printing to a
18
+ # file, or on a platform (like windows) that likely doesn't support
19
+ # the colors
20
+ String.disable_colorization = !$stdout.isatty
21
+
22
+ success = true
17
23
  url_list.each do |url|
18
24
  begin
19
25
  response = get_response(url)
26
+ success = success && response.ok?
20
27
  code = response.ok? ? response.code.to_s.green : response.code.to_s.red
21
28
  final_url = response.request.url
29
+
22
30
  text = "[#{code}] #{final_url}"
23
31
  text += " (requested #{url})".yellow unless final_url.include?(url)
24
- puts text
32
+ puts text
25
33
  rescue StandardError => e
34
+ success = false
26
35
  puts "[#{"---".red}] #{url} (#{e.to_s.red})"
27
36
  end
37
+
38
+ $stdout.flush
28
39
  end
40
+
41
+ # unless *every* request completed properly, return an error code
42
+ #, then we can do something else, like send an email
43
+ exit(false) unless success
29
44
  end
30
45
 
31
46
  def url_list
@@ -54,6 +69,7 @@ module UrlStatus
54
69
  begin
55
70
  return RestClient.get(url)
56
71
  rescue RestClient::ExceptionWithResponse => e
72
+ raise e if e.response.nil?
57
73
  return e.response
58
74
  end
59
75
  end
@@ -1,3 +1,3 @@
1
1
  module UrlStatus
2
- VERSION = "1.0.2"
2
+ VERSION = "1.0.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: url-status
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Reed
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-10-30 00:00:00.000000000 Z
11
+ date: 2016-11-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client