url-status 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 282caf40c639207e50080ad363f4b67391bccb37
4
+ data.tar.gz: 9d6eeabcf22037c22c34c2a54f91a5933f470e2b
5
+ SHA512:
6
+ metadata.gz: 6a811b2e5a8fecbab90329a7963da84ddaeb52d7725c2abae21f83f80f574325558328390008b173be1b2362131444da8a7e98b1d868226938ff16d4c02095f1
7
+ data.tar.gz: 9af417813d4ec27ad440a4da7fac7b14eacfa446449ec6287d62f2e706852890baae9ee64f49c16076ffa0b7d7aee8b87db001737afe8caed9215832d0b2359a
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ pkg
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in url_status.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,38 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ url_status (0.1.0)
5
+ colorize
6
+ rest-client (~> 1.8)
7
+ trollop
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ colorize (0.8.1)
13
+ domain_name (0.5.20161021)
14
+ unf (>= 0.0.5, < 1.0.0)
15
+ http-cookie (1.0.3)
16
+ domain_name (~> 0.5)
17
+ mime-types (2.99.3)
18
+ netrc (0.11.0)
19
+ rake (10.4.2)
20
+ rest-client (1.8.0)
21
+ http-cookie (>= 1.0.2, < 2.0)
22
+ mime-types (>= 1.16, < 3.0)
23
+ netrc (~> 0.7)
24
+ trollop (2.1.2)
25
+ unf (0.1.4)
26
+ unf_ext
27
+ unf_ext (0.0.7.2)
28
+
29
+ PLATFORMS
30
+ ruby
31
+
32
+ DEPENDENCIES
33
+ bundler (~> 1.12)
34
+ rake (~> 10.0)
35
+ url_status!
36
+
37
+ BUNDLED WITH
38
+ 1.12.5
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Nathan Reed
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # UrlStatus
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/url_status`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'url_status'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install url_status
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake true` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/url_status.
36
+
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
+
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/install.sh ADDED
@@ -0,0 +1,6 @@
1
+ #!/bin/sh
2
+
3
+ DIR=`pwd`
4
+ chmod 711 url-status.sh
5
+ cd ~/bin
6
+ ln -s $DIR/url-status.sh url-status-dev
data/bin/url-status.sh ADDED
@@ -0,0 +1,5 @@
1
+ #!/bin/bash
2
+
3
+ DIR="$(dirname "$(readlink "$0")")"
4
+ DIR=$DIR/..
5
+ /usr/bin/env ruby $DIR/app.rb "$@"
data/exe/url-status ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require 'url_status'
3
+ UrlStatus::App.new.main
data/lib/url_status.rb ADDED
@@ -0,0 +1,62 @@
1
+ require "url_status/version"
2
+ require 'rest-client'
3
+ require 'colorize'
4
+ require 'yaml'
5
+ require 'trollop'
6
+
7
+ module RestClient::Response
8
+ def ok?
9
+ code == 200
10
+ end
11
+ end
12
+
13
+ module UrlStatus
14
+
15
+ class App
16
+ def main
17
+ url_list.each do |url|
18
+ begin
19
+ response = get_response(url)
20
+ code = response.ok? ? response.code.to_s.green : response.code.to_s.red
21
+ final_url = response.request.url
22
+ text = "[#{code}] #{final_url}"
23
+ text += " (requested #{url})".yellow unless final_url.include?(url)
24
+ puts text
25
+ rescue StandardError => e
26
+ puts "[#{"---".red}] #{url} (#{e.to_s.red})"
27
+ end
28
+ end
29
+ end
30
+
31
+ def url_list
32
+ opts = Trollop::options do
33
+ version "url-status (c) 2016 @reednj (reednj@gmail.com)"
34
+ opt :config, "YAML config file containing array of urls", :type => :string
35
+ end
36
+
37
+ if ARGV.empty?
38
+ begin
39
+ data_file_name = opts[:config] || "#{ENV['HOME']}/sites.yaml"
40
+ YAML.load_file(data_file_name)
41
+ rescue => e
42
+ puts "Could not open '#{data_file_name}' (#{e})"
43
+ exit(false)
44
+ end
45
+ else
46
+ ARGV.clone
47
+ end
48
+
49
+ end
50
+
51
+ def get_response(url)
52
+ url = 'http://' + url unless url.start_with? 'http'
53
+
54
+ begin
55
+ return RestClient.get(url)
56
+ rescue RestClient::ExceptionWithResponse => e
57
+ return e.response
58
+ end
59
+ end
60
+ end
61
+
62
+ end
@@ -0,0 +1,3 @@
1
+ module UrlStatus
2
+ VERSION = "1.0.2"
3
+ end
data/sites.test.yaml ADDED
@@ -0,0 +1,13 @@
1
+ ---
2
+ # list of urls to check if they are working
3
+ - http://reddit-stream.com
4
+ - http://reddit-stream.com/comments/59ruau/
5
+ #- https://reddit-stream.com/comments/59ruau/
6
+ - so.reednj.com/xxx
7
+ - so.reednj.com:441/xxx
8
+ - ssrs.reednj.com
9
+ - paint.reednj.com
10
+ - triangle-wars.com
11
+ - popacular.com
12
+ - gigatweeter.com
13
+ - hhjutfiytf.com
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'url_status/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "url-status"
8
+ spec.version = UrlStatus::VERSION
9
+ spec.authors = ["Nathan Reed"]
10
+ spec.email = ["reednj@gmail.com"]
11
+
12
+ spec.summary = "command line gem to check the http status of a list of urls"
13
+ spec.homepage = "http://github.com/reednj/url-status"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = "exe"
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.required_ruby_version = '>=1.9.3'
22
+ spec.add_dependency 'rest-client', '~>1.8'
23
+ spec.add_dependency 'colorize'
24
+ spec.add_dependency 'trollop'
25
+
26
+ spec.add_development_dependency "bundler", "~> 1.12"
27
+ spec.add_development_dependency "rake", "~> 10.0"
28
+ end
metadata ADDED
@@ -0,0 +1,128 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: url-status
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Nathan Reed
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-10-30 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rest-client
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.8'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.8'
27
+ - !ruby/object:Gem::Dependency
28
+ name: colorize
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: trollop
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.12'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.12'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '10.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '10.0'
83
+ description:
84
+ email:
85
+ - reednj@gmail.com
86
+ executables:
87
+ - url-status
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - ".gitignore"
92
+ - Gemfile
93
+ - Gemfile.lock
94
+ - LICENSE.txt
95
+ - README.md
96
+ - Rakefile
97
+ - bin/install.sh
98
+ - bin/url-status.sh
99
+ - exe/url-status
100
+ - lib/url_status.rb
101
+ - lib/url_status/version.rb
102
+ - sites.test.yaml
103
+ - url_status.gemspec
104
+ homepage: http://github.com/reednj/url-status
105
+ licenses:
106
+ - MIT
107
+ metadata: {}
108
+ post_install_message:
109
+ rdoc_options: []
110
+ require_paths:
111
+ - lib
112
+ required_ruby_version: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: 1.9.3
117
+ required_rubygems_version: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - ">="
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
122
+ requirements: []
123
+ rubyforge_project:
124
+ rubygems_version: 2.6.6
125
+ signing_key:
126
+ specification_version: 4
127
+ summary: command line gem to check the http status of a list of urls
128
+ test_files: []