isitup 0.1.0 → 1.0.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
  SHA256:
3
- metadata.gz: b1d2783abd53f3192afd3fad7c919ba6c5335cb9ee6a34eaebbbb6d1a49027f8
4
- data.tar.gz: f82782421075d5ef0d01c3a9220914d213edd26303479ce8c14c55ae9a72e36d
3
+ metadata.gz: 3591027c9e48d3f3206b893f3b749d9921496cfaccf1a1f5c00523d0806b4917
4
+ data.tar.gz: b95216e8367b36c668e8829e19a3f8545cc5419e22c10b038888b5c0013caf4d
5
5
  SHA512:
6
- metadata.gz: 46850421f535d0a16c1dfe2bc7e8434935d50e42123ed0b8b5b82709fae155f8d3661f02970663c127977f71ba722b5c979a8da9d550e210a84629069db5bb77
7
- data.tar.gz: b5819d263c93c793223ee6a2b01c963118c615c7384ae908495255483161a0ac1602ebcbd64289e52125d5e8e99ba4f7456f6f7d4e8bc5ce6069efd34f0f6183
6
+ metadata.gz: 0aabbbd5011ae54339d3d84534828a356d397faa43e033fa4fe13d8a153a591a30506747f6496037bc20b9c3dec0baa0467203ea96df671cdb987109e14d3412
7
+ data.tar.gz: cb1b603b3582abaf45121d4ae2f51bba53b66a86c7e505f8da8b042ba367050f84d7db1a16717cddfae6999a32ed4adb470fb71525b38a76876493c9a77f1de5
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ /Gemfile.lock
10
+
11
+ *.gem
12
+
13
+ # rspec failure tracking
14
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,33 @@
1
+ Layout/IndentationWidth:
2
+ Width: 4
3
+
4
+ Metrics/AbcSize:
5
+ Max: 50
6
+
7
+ Metrics/LineLength:
8
+ Enabled: false
9
+
10
+ Metrics/BlockLength:
11
+ Max: 40
12
+
13
+ Metrics/CyclomaticComplexity:
14
+ Max: 20
15
+
16
+ Metrics/MethodLength:
17
+ Max: 60
18
+
19
+ Metrics/PerceivedComplexity:
20
+ Max: 20
21
+
22
+ Style/GlobalVars:
23
+ Enabled: false
24
+
25
+ Style/RaiseArgs:
26
+ EnforcedStyle: compact
27
+
28
+ Style/RedundantBegin:
29
+ Enabled: false
30
+
31
+ Style/WordArray:
32
+ EnforcedStyle: brackets
33
+
@@ -0,0 +1,66 @@
1
+ matrix:
2
+ include:
3
+ - language: ruby
4
+ name: "Bundler (rvm 2.4.4 & bundler 1.17.3)"
5
+ rvm: 2.4.4
6
+ before_install:
7
+ - gem install bundler -v 1.17.3
8
+ - language: ruby
9
+ name: "Bundler (rvm 2.4.4 & bundler 2.0.1)"
10
+ rvm: 2.4.4
11
+ before_install:
12
+ - gem install bundler -v 2.0.1
13
+ - language: ruby
14
+ name: "Bundler (rvm 2.5.3 & bundler 2.0.1)"
15
+ rvm: 2.5.3
16
+ before_install:
17
+ - gem install bundler -v 2.0.1
18
+ - language: ruby
19
+ name: "Bundler (rvm 2.6.1 & bundler 2.0.1)"
20
+ rvm: 2.6.1
21
+ before_install:
22
+ - gem install bundler -v 2.0.1
23
+ - language: ruby
24
+ name: "Rubocop (rvm 2.4.4)"
25
+ env: SKIP_INTERPRETER=true
26
+ rvm: 2.4.4
27
+ before_install:
28
+ - git clone https://github.com/TravisToolbox/rubocop-travis.git
29
+ install:
30
+ - ./rubocop-travis/install.sh
31
+ script:
32
+ - ./rubocop-travis/scan.sh
33
+ - language: ruby
34
+ name: "Rubocop (rvm 2.5.3)"
35
+ env: SKIP_INTERPRETER=true
36
+ rvm: 2.5.3
37
+ before_install:
38
+ - git clone https://github.com/TravisToolbox/rubocop-travis.git
39
+ install:
40
+ - ./rubocop-travis/install.sh
41
+ script:
42
+ - ./rubocop-travis/scan.sh
43
+ - language: ruby
44
+ name: "Rubocop (rvm 2.6.1)"
45
+ env: SKIP_INTERPRETER=true
46
+ rvm: 2.6.1
47
+ before_install:
48
+ - git clone https://github.com/TravisToolbox/rubocop-travis.git
49
+ install:
50
+ - ./rubocop-travis/install.sh
51
+ script:
52
+ - ./rubocop-travis/scan.sh
53
+ - language: ruby
54
+ name: "Link Checker (rvm 2.6.1)"
55
+ rvm: 2.6.1
56
+ before_install:
57
+ - mkdir travis
58
+ - git clone https://github.com/TravisToolbox/awesomebot-travis.git travis/awesomebot
59
+ install:
60
+ - ./travis/awesomebot/install.sh
61
+ script:
62
+ - ./travis/awesomebot/scan.sh
63
+ notifications:
64
+ email: false
65
+ slack:
66
+ secure: T4f9HMHNwKjgyweCGboxO1YW1d23HV/tEumHAlsvgFAWcnbe3z/BdUWUxXg9ztYNQUdaTkbx9PuGH4RyYRPkSsrt1S8OLg7wT7Xjetsu41iqQb1VT0Jw9MH1SOBpFNzmW8GHrkwz9dTvsDISIossJ1WcyMLnnrA91MPRuUm0UUdvjUaGb03h9rFnoUZ0c00KzEXGB3xgHuvYKOPpErQDi7MWxBjx6PoRDARQe+MGjC/r6z+7TwVhyU+3bqz53adU1bPUfFrHlU8wBzFstzzn7yWI5pbOXXPfy92c5Wj9uwdvx62fi9mOE5bQ54Py/qkKaa+BtGznRGRU/j2ql5JxbyJOq8WaXEn93hj5gfORU/+lIWsKqFkdJcNpExhDCvZFVlLhMs3qEuccy0siujTc8XAIAaNsB77rW/4ZdFz3R402LHajGPGLcFGyQNAQNqPQiTeVS2BQqb7GWKGLHH5JnNSJIF+GheMXVCWiBDpZV/pg6foRNk4nfXYdL7ds8q9zYwqC0M0vZ1fx0uhQWrbMNFsYj1YdI7D3J9RTTrS1iM5ROkKmXGYXlgUNcEO1W/zRhGNV2dbnCE6p3tSHzQ7QFANJKtZT0pL+gZJ5KRhFF6n5GNCwgZALf4QSYCQG9vjiffIF4qhsSPjboQYv8aydqXXye1qXm2O28FiRplnDJYA=
@@ -0,0 +1,5 @@
1
+ ## 1.0.0 (June 28, 2019)
2
+
3
+ * Initial Release ([@TGWolf][])
4
+
5
+ [@TGWolf]: https://github.com/TGWolf
@@ -0,0 +1,7 @@
1
+ # The codeowners file:
2
+ #
3
+ # For more information please read: https://help.github.com/articles/about-codeowners/
4
+
5
+ # These owners will be the default owners for everything in
6
+ # the repo. Unless a later match takes precedence,
7
+ * @AntiPhotonltd/reviewers
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at tim.gurney@timgurney.net. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in isitup.gemspec
6
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Tim Gurney aka Wolf
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.
@@ -0,0 +1,55 @@
1
+ [![Build Status](https://img.shields.io/travis/AntiPhotonltd/isitup/master.svg)](https://travis-ci.org/AntiPhotonltd/isitup)
2
+ [![Software License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE.md)
3
+ [![Release](https://img.shields.io/github/release/AntiPhotonltd/isitup.svg)](https://github.com/AntiPhotonltd/isitup/releases/latest)
4
+ [![Gem Version](https://badge.fury.io/rb/isitup.svg)](https://badge.fury.io/rb/isitup)
5
+ [![Github commits (since latest release)](https://img.shields.io/github/commits-since/AntiPhotonltd/isitup/latest.svg)](https://github.com/AntiPhotonltd/isitup/commits)
6
+ [![GitHub repo size in bytes](https://img.shields.io/github/repo-size/AntiPhotonltd/isitup.svg)](https://github.com/AntiPhotonltd/isitup)
7
+ [![GitHub contributors](https://img.shields.io/github/contributors/AntiPhotonltd/isitup.svg)](https://github.com/AntiPhotonltd/isitup)
8
+
9
+ # isitup?
10
+
11
+ This is a simple little gem for checking is a site is up or not.
12
+
13
+ ## Installation
14
+
15
+ Add this line to your application's Gemfile:
16
+
17
+ ```ruby
18
+ gem 'isitup'
19
+ ```
20
+
21
+ And then execute:
22
+
23
+ $ bundle
24
+
25
+ Or install it yourself as:
26
+
27
+ $ gem install isitup
28
+
29
+ ## Usage
30
+
31
+ ```ruby
32
+ Isitup.check("www.antiphoton.com")
33
+ ```
34
+
35
+ ## Development
36
+
37
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
38
+
39
+ 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).
40
+
41
+ ## Testing
42
+
43
+ For local testing make sure that you run `bundle exec rspec spec` and then `rake install` to install the gem locally.
44
+
45
+ ## Contributing
46
+
47
+ Bug reports and pull requests are welcome on GitHub at https://github.com/AntiPhotonltd/isitup. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
48
+
49
+ ## License
50
+
51
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
52
+
53
+ ## Code of Conduct
54
+
55
+ Everyone interacting in the SSLInfo project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/AntiPhotonltd/isitup/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "isitup"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,65 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'optparse'
4
+ require 'isitup'
5
+
6
+ # -------------------------------------------------------------------------------- #
7
+ # Process Arguments #
8
+ # -------------------------------------------------------------------------------- #
9
+ # This function will process the input from the command line and work out what it #
10
+ # is that the user wants to see. #
11
+ # #
12
+ # This is the main processing function where all the processing logic is handled. #
13
+ # -------------------------------------------------------------------------------- #
14
+
15
+ def process_arguments
16
+ options = {}
17
+ # Enforce the presence of
18
+ mandatory = %I[domain]
19
+
20
+ optparse = OptionParser.new do |opts|
21
+ opts.banner = "Usage: #{$PROGRAM_NAME}"
22
+
23
+ opts.on('-h', '--help', 'Display this screen') do
24
+ puts opts
25
+ exit(1)
26
+ end
27
+ opts.on('-c', '--use-color', 'Use colour when outputting the results') do |_digits|
28
+ options[:color] = true
29
+ end
30
+ opts.on('-d', '--domain string', 'The domain name to check') do |domain|
31
+ options[:domain] = domain
32
+ end
33
+ end
34
+
35
+ begin
36
+ optparse.parse!
37
+ options[:message] = ARGF.read unless STDIN.tty? # override message parameter if data is piped in
38
+ missing = mandatory.select { |param| options[param].nil? }
39
+ raise OptionParser::MissingArgument.new(missing.join(', ')) unless missing.empty?
40
+ rescue OptionParser::InvalidOption, OptionParser::MissingArgument => e
41
+ puts e.to_s
42
+ puts optparse
43
+ exit
44
+ end
45
+
46
+ puts Isitup.check(options[:domain], options)
47
+ end
48
+
49
+ # -------------------------------------------------------------------------------- #
50
+ # Main() #
51
+ # -------------------------------------------------------------------------------- #
52
+ # The main function where all of the heavy lifting and script config is done. #
53
+ # -------------------------------------------------------------------------------- #
54
+
55
+ def main
56
+ process_arguments
57
+ end
58
+
59
+ main
60
+
61
+ # -------------------------------------------------------------------------------- #
62
+ # End of Script #
63
+ # -------------------------------------------------------------------------------- #
64
+ # This is the end - nothing more to see here. #
65
+ # -------------------------------------------------------------------------------- #
@@ -0,0 +1,35 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "isitup/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "isitup"
8
+ spec.version = Isitup::VERSION
9
+ spec.authors = ['Tim Gurney aka Wolf']
10
+ spec.email = ['wolf@tgwolf.com']
11
+
12
+ spec.summary = %q{A simple gem to check if a site is up or not.}
13
+ spec.description = %q{A simple gem to check if a site is up or not.}
14
+ spec.homepage = "https://github.com/AntiPhotonltd/isitup"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.required_ruby_version = '>= 2.3.0'
25
+
26
+ spec.add_development_dependency "bundler", ">= 1.17", "< 3.0"
27
+ spec.add_development_dependency "rake", "~> 10.0"
28
+ spec.add_development_dependency "rspec", "~> 3.0"
29
+
30
+ spec.add_development_dependency "colorize", "~> 0.8.1"
31
+ spec.add_development_dependency "rest-client", "~> 2.0.2"
32
+
33
+ spec.add_runtime_dependency "colorize", "~> 0.8.1"
34
+ spec.add_runtime_dependency "rest-client", "~> 2.0.2"
35
+ end
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'isitup/version'
4
+
5
+ require 'colorize'
6
+ require 'json'
7
+ require 'ostruct'
8
+ require 'rest-client'
9
+
10
+ #
11
+ # Docs to follow
12
+ #
13
+ module Isitup
14
+ def self.check(domain, options = {})
15
+ data = query_api(domain)
16
+ process_data(data, options)
17
+ end
18
+
19
+ def self.query_api(domain)
20
+ url = "http://isitup.org/#{domain}.json"
21
+ response = RestClient.get(url)
22
+ data = JSON.parse(response)
23
+
24
+ OpenStruct.new(
25
+ domain: data['domain'],
26
+ status: data['status_code'],
27
+ time: data['response_time']
28
+ )
29
+ rescue RestClient::Exception => e
30
+ e.response
31
+ nil
32
+ end
33
+
34
+ def self.process_data(data, options)
35
+ case data.status
36
+ when 1
37
+ if options[:color]
38
+ "The domain: #{data.domain} is up! Response time: #{data.time}".green
39
+ else
40
+ "The domain: #{data.domain} is up! Response time: #{data.time}"
41
+ end
42
+ when 2
43
+ if options[:color]
44
+ "The domain: #{data.domain} is down".red
45
+ else
46
+ "The domain: #{data.domain} is down"
47
+ end
48
+ else
49
+ if options[:color]
50
+ "#{data.domain} is not a valid domain!".blue
51
+ else
52
+ "#{data.domain} is not a valid domain!"
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Isitup
4
+ VERSION = '1.0.0'
5
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: isitup
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Gurney aka Wolf
@@ -117,10 +117,28 @@ dependencies:
117
117
  description: A simple gem to check if a site is up or not.
118
118
  email:
119
119
  - wolf@tgwolf.com
120
- executables: []
120
+ executables:
121
+ - isitup
121
122
  extensions: []
122
123
  extra_rdoc_files: []
123
- files: []
124
+ files:
125
+ - ".gitignore"
126
+ - ".rspec"
127
+ - ".rubocop.yml"
128
+ - ".travis.yml"
129
+ - CHANGELOG.md
130
+ - CODEOWNERS
131
+ - CODE_OF_CONDUCT.md
132
+ - Gemfile
133
+ - LICENSE.txt
134
+ - README.md
135
+ - Rakefile
136
+ - bin/console
137
+ - bin/setup
138
+ - exe/isitup
139
+ - isitup.gemspec
140
+ - lib/isitup.rb
141
+ - lib/isitup/version.rb
124
142
  homepage: https://github.com/AntiPhotonltd/isitup
125
143
  licenses:
126
144
  - MIT
@@ -133,7 +151,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
133
151
  requirements:
134
152
  - - ">="
135
153
  - !ruby/object:Gem::Version
136
- version: '0'
154
+ version: 2.3.0
137
155
  required_rubygems_version: !ruby/object:Gem::Requirement
138
156
  requirements:
139
157
  - - ">="