igp 0.0.2 → 1.1.0

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
+ SHA256:
3
+ metadata.gz: dea3cd46567b9578ee580171eefef7ef44de44cd62acb3e809ba5644db1bdf8b
4
+ data.tar.gz: 1a2d1f5b44a460bf2b68d797b1d5c24b87f2130522db6d3e73ff2ecd451d210d
5
+ SHA512:
6
+ metadata.gz: 0cbf84188e9ee2d1f7d50ac9e36b8d7d80260f134fd595de7032191821aae37b6b500f7ca5e5320d0c091d7be6e4c58ca9ba3629c1961e7366974890e87d15ce
7
+ data.tar.gz: 76c1fe528924bb24918cc721e1ee9b9aba476f577858356eff0f35442c1f38b1ef2e3cc017ae12136564a30dd0949f92081525b824bfdda179b4b806e6f89584
@@ -0,0 +1,36 @@
1
+ # This workflow uses actions that are not certified by GitHub.
2
+ # They are provided by a third-party and are governed by
3
+ # separate terms of service, privacy policy, and support
4
+ # documentation.
5
+ # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6
+ # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7
+
8
+ name: Ruby
9
+
10
+ on:
11
+ push:
12
+ branches: [ '*' ]
13
+ pull_request:
14
+ branches: [ main ]
15
+
16
+ jobs:
17
+ test:
18
+
19
+ runs-on: ubuntu-latest
20
+ strategy:
21
+ matrix:
22
+ ruby-version: ['2.7', '3.0']
23
+
24
+ steps:
25
+ - uses: actions/checkout@v2
26
+ - name: Set up Ruby
27
+ uses: ruby/setup-ruby@473e4d8fe5dd94ee328fdfca9f8c9c7afc9dae5e
28
+ with:
29
+ ruby-version: ${{ matrix.ruby-version }}
30
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
31
+ - name: Install dependencies
32
+ run: bundle install
33
+ - name: Check Style
34
+ run: bundle exec rubocop
35
+ - name: Run tests
36
+ run: bundle exec rake
data/.gitignore ADDED
@@ -0,0 +1,55 @@
1
+ ## Documentation cache and generated files:
2
+ /.yardoc/
3
+ /_yardoc/
4
+ /doc/
5
+ /rdoc/
6
+
7
+ ## Environment normalization:
8
+ /.bundle/
9
+ /vendor/bundle
10
+ /lib/bundler/man/
11
+
12
+ # for a library or gem, you might want to ignore these files since the code is
13
+ # intended to run in multiple environments; otherwise, check them in:
14
+ Gemfile.lock
15
+ .ruby-version
16
+ .ruby-gemset
17
+ *.gem
18
+ pkg
19
+
20
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
21
+ .rvmrc
22
+
23
+ # rcov generated
24
+ coverage
25
+
26
+ # logs
27
+ log
28
+ *.log
29
+
30
+ # Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
31
+ #
32
+ # * Create a file at ~/.gitignore
33
+ # * Include files you want ignored
34
+ # * Run: git config --global core.excludesfile ~/.gitignore
35
+ #
36
+ # After doing this, these files will be ignored in all your git projects,
37
+ # saving you from having to 'pollute' every project you touch with them
38
+ #
39
+ # Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
40
+ #
41
+ # For MacOS:
42
+ #
43
+ #.DS_Store
44
+ #
45
+ # For TextMate
46
+ #*.tmproj
47
+ #tmtags
48
+ #
49
+ # For emacs:
50
+ #*~
51
+ #\#*
52
+ #.\#*
53
+ #
54
+ # For vim:
55
+ #*.swp
data/.rubocop.yml ADDED
@@ -0,0 +1,35 @@
1
+ inherit_from: .rubocop_todo.yml
2
+
3
+ AllCops:
4
+ NewCops: enable
5
+
6
+ Layout/CommentIndentation:
7
+ Exclude:
8
+ - 'lib/igp/base.rb'
9
+
10
+ # Offense count: 1
11
+ # Configuration parameters: CheckForMethodsWithNoSideEffects.
12
+ Lint/Void:
13
+ Exclude:
14
+ - 'lib/igp/shell.rb'
15
+
16
+ # Offense count: 3
17
+ # Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
18
+ Metrics/AbcSize:
19
+ Max: 29
20
+
21
+ # Offense count: 5
22
+ # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
23
+ # IgnoredMethods: refine
24
+ Metrics/BlockLength:
25
+ Max: 148
26
+
27
+ # Offense count: 1
28
+ # Configuration parameters: IgnoredMethods.
29
+ Metrics/CyclomaticComplexity:
30
+ Max: 8
31
+
32
+ # Offense count: 3
33
+ # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
34
+ Metrics/MethodLength:
35
+ Max: 16
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,89 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2022-03-01 12:54:50 UTC using RuboCop version 1.25.1.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 1
10
+ # Configuration parameters: Include.
11
+ # Include: **/*.gemspec
12
+ Gemspec/RequiredRubyVersion:
13
+ Exclude:
14
+ - 'igp.gemspec'
15
+
16
+ # Offense count: 1
17
+ Lint/RescueException:
18
+ Exclude:
19
+ - 'bin/igp'
20
+
21
+ # Offense count: 1
22
+ # Configuration parameters: ForbiddenDelimiters.
23
+ # ForbiddenDelimiters: (?-mix:(^|\s)(EO[A-Z]{1}|END)(\s|$))
24
+ Naming/HeredocDelimiterNaming:
25
+ Exclude:
26
+ - 'lib/igp/shell.rb'
27
+
28
+ # Offense count: 2
29
+ Security/Eval:
30
+ Exclude:
31
+ - 'spec/spec_helper.rb'
32
+
33
+ # Offense count: 2
34
+ # Cop supports --auto-correct.
35
+ # Configuration parameters: EnforcedStyle.
36
+ # SupportedStyles: nested, compact
37
+ Style/ClassAndModuleChildren:
38
+ Exclude:
39
+ - 'lib/igp/base.rb'
40
+ - 'lib/igp/shell.rb'
41
+ - 'lib/net/ping/ldap.rb'
42
+
43
+ # Offense count: 1
44
+ # Cop supports --auto-correct.
45
+ Style/Encoding:
46
+ Exclude:
47
+ - 'igp.gemspec'
48
+
49
+ # Offense count: 2
50
+ # Cop supports --auto-correct.
51
+ Style/EvalWithLocation:
52
+ Exclude:
53
+ - 'spec/spec_helper.rb'
54
+
55
+ # Offense count: 1
56
+ # Cop supports --auto-correct.
57
+ Style/ExpandPathArguments:
58
+ Exclude:
59
+ - 'igp.gemspec'
60
+
61
+ # Offense count: 13
62
+ # Cop supports --auto-correct.
63
+ # Configuration parameters: EnforcedStyle.
64
+ # SupportedStyles: always, always_true, never
65
+ Style/FrozenStringLiteralComment:
66
+ Exclude:
67
+ - 'Gemfile'
68
+ - 'Guardfile'
69
+ - 'Rakefile'
70
+ - 'bin/igp'
71
+ - 'igp.gemspec'
72
+ - 'lib/igp.rb'
73
+ - 'lib/igp/base.rb'
74
+ - 'lib/igp/shell.rb'
75
+ - 'lib/igp/version.rb'
76
+ - 'lib/net/ping/ldap.rb'
77
+ - 'spec/base_spec.rb'
78
+ - 'spec/format_spec.rb'
79
+ - 'spec/net/ping/ldap_spec.rb'
80
+ - 'spec/shell_spec.rb'
81
+ - 'spec/spec_helper.rb'
82
+
83
+ # Offense count: 4
84
+ # Cop supports --auto-correct.
85
+ Style/StderrPuts:
86
+ Exclude:
87
+ - 'bin/igp'
88
+ - 'lib/igp/base.rb'
89
+ - 'lib/igp/shell.rb'
data/CHANGELOG CHANGED
@@ -1,3 +1,21 @@
1
+ Version 1.1.0 Release: 2022-03-01
2
+ ==================================================
3
+
4
+ * added back LDAP ping functionality (built-in for now)
5
+
6
+ Version 1.0.0 Release: 2022-03-01
7
+ ==================================================
8
+
9
+ * updated to ruby 2.7+ and net-ping 2.0.8+
10
+ * LDAP functionality removed (since dropped from net-ping)
11
+
12
+ Version 0.0.3 Release: 7th May 2011
13
+ ==================================================
14
+ * more ruby 1.8.7 compatibility fixes:
15
+ - suppress net-ping error on ^C
16
+ - requires rubygems (allows bin/igp to run when not already installed as a gem)
17
+ - don't lazy-evaluate GetOptions hash values
18
+
1
19
  Version 0.0.2 Release: 7th May 2011
2
20
  ==================================================
3
21
  * properly handle time format in 1.8 and 1.9 ruby
data/Gemfile CHANGED
@@ -1,11 +1,3 @@
1
- source "http://rubygems.org"
1
+ source 'https://rubygems.org'
2
2
 
3
- gem 'net-ping', '~> 1.5.0'
4
- gem 'getoptions', '~> 0.3'
5
-
6
- group :development do
7
- gem 'rspec', '> 2.3.0', :require => 'spec'
8
- gem 'bundler', '~> 1.0.0'
9
- gem 'jeweler', '~> 1.5.2'
10
- gem 'rcov', '>= 0'
11
- end
3
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,16 @@
1
+ guard :rspec, cmd: 'bundle exec rspec' do
2
+ require 'guard/rspec/dsl'
3
+ dsl = Guard::RSpec::Dsl.new(self)
4
+
5
+ # Feel free to open issues for suggestions and improvements
6
+
7
+ # RSpec files
8
+ rspec = dsl.rspec
9
+ watch(rspec.spec_helper) { rspec.spec_dir }
10
+ watch(rspec.spec_support) { rspec.spec_dir }
11
+ watch(rspec.spec_files)
12
+
13
+ # Ruby files
14
+ ruby = dsl.ruby
15
+ dsl.watch_spec_files_for(ruby.lib_files)
16
+ end
data/Rakefile CHANGED
@@ -1,49 +1,18 @@
1
- require 'rubygems'
2
- require 'bundler'
3
- begin
4
- Bundler.setup(:default, :development)
5
- rescue Bundler::BundlerError => e
6
- $stderr.puts e.message
7
- $stderr.puts "Run `bundle install` to install missing gems"
8
- exit e.status_code
9
- end
10
- require 'rake'
11
- $LOAD_PATH << './lib'
12
- require 'igp'
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
13
3
 
14
- begin
15
- require 'jeweler'
16
- Jeweler::Tasks.new do |gem|
17
- # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
18
- gem.name = "igp"
19
- gem.version = Igp::VERSION
20
- gem.homepage = "http://github.com/tardate/igp"
21
- gem.license = "MIT"
22
- gem.summary = %Q{It goes PING!}
23
- gem.description = %Q{It goes PING! .. simple command-line server monitoring with a range of protocols: ICMP, TCP, UDP, HTTP/S, LDAP/S}
24
- gem.email = "gallagher.paul@gmail.com"
25
- gem.authors = ["Paul Gallagher"]
26
- end
27
- Jeweler::RubygemsDotOrgTasks.new
28
- rescue LoadError
29
- puts "Jeweler not available. Install it with: sudo gem install jeweler"
30
- end
4
+ RSpec::Core::RakeTask.new(:spec)
31
5
 
6
+ task default: :spec
32
7
 
33
- require 'rspec'
34
- require 'rspec/core/rake_task'
35
- RSpec::Core::RakeTask.new do |t|
36
- t.rspec_opts = ["-c", "-f progress"]
37
- t.pattern = 'spec/**/*_spec.rb'
8
+ desc 'Open an irb session preloaded with this library'
9
+ task :console do
10
+ sh 'irb -rubygems -I lib -r cancannible.rb'
38
11
  end
39
12
 
13
+ require 'rdoc/task'
40
14
 
41
- task :default => :spec
42
-
43
- require 'rake/rdoctask'
44
- Rake::RDocTask.new do |rdoc|
45
- rdoc.rdoc_dir = 'rdoc'
46
- rdoc.title = "igp #{Igp::VERSION}"
47
- rdoc.rdoc_files.include('README*')
48
- rdoc.rdoc_files.include('lib/**/*.rb')
15
+ RDoc::Task.new do |rdoc|
16
+ rdoc.main = 'README.rdoc'
17
+ rdoc.rdoc_files.include('README.rdoc', 'lib /*.rb')
49
18
  end
data/bin/igp CHANGED
@@ -6,11 +6,10 @@ require 'getoptions'
6
6
 
7
7
  begin
8
8
  options = GetOptions.new(Igp::Shell::OPTIONS)
9
- Igp::Shell.new(options,ARGV).run
10
- rescue Interrupt
11
- $stderr.puts ""
9
+ Igp::Shell.new(options, ARGV).run
10
+ rescue Interrupt, NoMethodError
11
+ $stderr.puts ''
12
12
  rescue Exception => e
13
13
  $stderr.puts "That wasn't meant to happen! #{e.message}"
14
14
  Igp::Shell.usage
15
15
  end
16
-
data/igp.gemspec CHANGED
@@ -1,78 +1,36 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
- # -*- encoding: utf-8 -*-
1
+ # coding: utf-8
5
2
 
6
- Gem::Specification.new do |s|
7
- s.name = %q{igp}
8
- s.version = "0.0.2"
3
+ lib = File.expand_path('../lib', __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'igp/version'
9
6
 
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Paul Gallagher"]
12
- s.date = %q{2011-05-07}
13
- s.description = %q{It goes PING! .. simple command-line server monitoring with a range of protocols: ICMP, TCP, UDP, HTTP/S, LDAP/S}
14
- s.email = %q{gallagher.paul@gmail.com}
15
- s.executables = ["igp"]
16
- s.extra_rdoc_files = [
17
- "LICENSE",
18
- "README.rdoc"
19
- ]
20
- s.files = [
21
- "CHANGELOG",
22
- "Gemfile",
23
- "Gemfile.lock",
24
- "LICENSE",
25
- "README.rdoc",
26
- "Rakefile",
27
- "bin/igp",
28
- "igp.gemspec",
29
- "init.rb",
30
- "lib/igp.rb",
31
- "lib/igp/base.rb",
32
- "lib/igp/shell.rb",
33
- "lib/igp/version.rb",
34
- "spec/base_spec.rb",
35
- "spec/format_spec.rb",
36
- "spec/shell_spec.rb",
37
- "spec/spec_helper.rb"
38
- ]
39
- s.homepage = %q{http://github.com/tardate/igp}
40
- s.licenses = ["MIT"]
41
- s.require_paths = ["lib"]
42
- s.rubygems_version = %q{1.7.2}
43
- s.summary = %q{It goes PING!}
44
- s.test_files = [
45
- "spec/base_spec.rb",
46
- "spec/format_spec.rb",
47
- "spec/shell_spec.rb",
48
- "spec/spec_helper.rb"
49
- ]
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'igp'
9
+ spec.version = Igp::VERSION
10
+ spec.authors = ['Paul Gallagher']
11
+ spec.email = ['gallagher.paul@gmail.com']
12
+ spec.summary = 'It goes PING!'
13
+ spec.description = 'Simple command-line server monitoring with a range of protocols: ICMP, TCP, UDP, HTTP/S, LDAP/S'
14
+ spec.homepage = 'https://github.com/tardate/igp'
15
+ spec.license = 'MIT'
50
16
 
51
- if s.respond_to? :specification_version then
52
- s.specification_version = 3
17
+ spec.files = `git ls-files -z`.split("\x0")
18
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
+ spec.require_paths = ['lib']
53
21
 
54
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
55
- s.add_runtime_dependency(%q<net-ping>, ["~> 1.5.0"])
56
- s.add_runtime_dependency(%q<getoptions>, ["~> 0.3"])
57
- s.add_development_dependency(%q<rspec>, ["> 2.3.0"])
58
- s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
59
- s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
60
- s.add_development_dependency(%q<rcov>, [">= 0"])
61
- else
62
- s.add_dependency(%q<net-ping>, ["~> 1.5.0"])
63
- s.add_dependency(%q<getoptions>, ["~> 0.3"])
64
- s.add_dependency(%q<rspec>, ["> 2.3.0"])
65
- s.add_dependency(%q<bundler>, ["~> 1.0.0"])
66
- s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
67
- s.add_dependency(%q<rcov>, [">= 0"])
68
- end
69
- else
70
- s.add_dependency(%q<net-ping>, ["~> 1.5.0"])
71
- s.add_dependency(%q<getoptions>, ["~> 0.3"])
72
- s.add_dependency(%q<rspec>, ["> 2.3.0"])
73
- s.add_dependency(%q<bundler>, ["~> 1.0.0"])
74
- s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
75
- s.add_dependency(%q<rcov>, [">= 0"])
76
- end
77
- end
22
+ spec.add_runtime_dependency 'getoptions', '~> 0.3'
23
+ spec.add_runtime_dependency 'net-ldap', '~> 0.16.0'
24
+ spec.add_runtime_dependency 'net-ping', '~> 2.0.8'
78
25
 
26
+ spec.add_development_dependency 'bundler'
27
+ spec.add_development_dependency 'fakeldap', '~> 0.1.1'
28
+ spec.add_development_dependency 'guard-rspec'
29
+ spec.add_development_dependency 'rake'
30
+ spec.add_development_dependency 'rb-fsevent'
31
+ spec.add_development_dependency 'rdoc'
32
+ spec.add_development_dependency 'rspec'
33
+ spec.add_development_dependency 'rubocop'
34
+ spec.add_development_dependency 'ruby-ldapserver', '~> 0.5.0'
35
+ spec.metadata['rubygems_mfa_required'] = 'true'
36
+ end
data/lib/igp/base.rb CHANGED
@@ -1,6 +1,5 @@
1
1
  # main class that runs the ping task
2
2
  class Igp::Base
3
-
4
3
  # holds the parsed options
5
4
  attr_reader :options
6
5
  # the output formatter
@@ -27,11 +26,11 @@ class Igp::Base
27
26
  @interval = options[:interval] || 5
28
27
  case options[:type]
29
28
  when :icmp
30
- @ping_handler = Net::Ping::External.new(@options[:host],@options[:port])
29
+ @ping_handler = Net::Ping::External.new(@options[:host], @options[:port])
31
30
  when :udp
32
- @ping_handler = Net::Ping::UDP.new(@options[:host],@options[:port])
31
+ @ping_handler = Net::Ping::UDP.new(@options[:host], @options[:port])
33
32
  when :tcp
34
- @ping_handler = Net::Ping::TCP.new(@options[:host],@options[:port])
33
+ @ping_handler = Net::Ping::TCP.new(@options[:host], @options[:port])
35
34
  when :http, :https
36
35
  @ping_handler = Net::Ping::HTTP.new(@options[:url])
37
36
  when :ldap, :ldaps
@@ -42,43 +41,40 @@ class Igp::Base
42
41
  # main routine to run a complete ping test
43
42
  def run
44
43
  return unless ping_handler && formatter
44
+
45
45
  formatter.header(
46
- '# It goes PING! .. testing',options[:url],
46
+ '# It goes PING! .. testing', options[:url],
47
47
  (limit ? "#{limit} times - once" : nil),
48
- 'every',interval,'seconds'
48
+ 'every', interval, 'seconds'
49
49
  )
50
- ping_count=0
51
- while (limit.nil? || ping_count < limit) do
50
+ ping_count = 0
51
+ while limit.nil? || ping_count < limit
52
52
  status = ping_handler.ping?
53
- formatter.log(status,formatter.duration(ping_handler.duration),ping_handler.exception)
53
+ formatter.log(status, formatter.duration(ping_handler.duration), ping_handler.exception)
54
54
  ping_count += 1
55
- sleep interval if (limit.nil? || ping_count < limit)
55
+ sleep interval if limit.nil? || ping_count < limit
56
56
  end
57
57
  end
58
58
 
59
59
  # handle output formating tasks
60
60
  class Format
61
-
62
- # the time format - in 1.8 strftime doesn't understand milliseconds
63
- TIME_FORMAT = (RUBY_VERSION =~ /^1\.9/) ? "%Y-%m-%dT%H:%M:%S.%LZ" : "%Y-%m-%dT%H:%M:%SZ"
61
+ TIME_FORMAT = '%Y-%m-%dT%H:%M:%S.%LZ'.freeze
64
62
 
65
63
  # prints the header structure to STDERR
66
64
  def header(*args)
67
65
  $stderr.puts(args.compact.join(' '))
68
66
  end
69
-
67
+
70
68
  # logs ping result to STDOUT
71
69
  # +args+ is an array of values to log
72
70
  def log(*args)
73
- $stdout.puts(([Time.now.utc.strftime( TIME_FORMAT )] + args).join(','))
71
+ $stdout.puts(([Time.now.utc.strftime(TIME_FORMAT)] + args).join(','))
74
72
  $stdout.flush
75
73
  end
76
-
74
+
77
75
  # formats the duration for output. nil duration remains nil
78
76
  def duration(duration)
79
- "%.6f" % duration if duration
77
+ format('%.6f', duration) if duration
80
78
  end
81
-
82
79
  end
83
-
84
- end
80
+ end
data/lib/igp/shell.rb CHANGED
@@ -2,7 +2,6 @@ require 'uri'
2
2
 
3
3
  # class that groks the igp command line options and invokes the ping task
4
4
  class Igp::Shell
5
-
6
5
  # holds the parsed options
7
6
  attr_reader :options
8
7
  # holds the URI object representing the ping target
@@ -14,12 +13,13 @@ class Igp::Shell
14
13
  #
15
14
  # +args+ is the remaining command line arguments
16
15
  #
17
- def initialize(options,args)
16
+ def initialize(options, args)
18
17
  defaults = {
19
- :interval => 1
18
+ interval: 1
20
19
  }
21
- @options = defaults.merge( (options||{}).each{|k|k} )
20
+ @options = defaults.merge((options || {}).each { |k, v| { k => v } })
22
21
  return unless args.first
22
+
23
23
  resolve_addressing args.first
24
24
  normalise_options
25
25
  end
@@ -32,7 +32,7 @@ class Igp::Shell
32
32
  unless uri.scheme
33
33
  @options[:type] = :icmp
34
34
  @options[:host] = uri.to_s
35
- @options[:url] = "#{@options[:type].to_s}://#{@options[:host]}"
35
+ @options[:url] = "#{@options[:type]}://#{@options[:host]}"
36
36
  return
37
37
  end
38
38
  @options[:url] = uri.to_s
@@ -52,7 +52,7 @@ class Igp::Shell
52
52
  # runs the ping task
53
53
  def run
54
54
  case options[:type]
55
- when :icmp,:http,:https,:tcp,:udp,:ldap,:ldaps
55
+ when :icmp, :http, :https, :tcp, :udp, :ldap, :ldaps
56
56
  Igp::Base.new(options).run
57
57
  else
58
58
  usage
@@ -60,49 +60,50 @@ class Igp::Shell
60
60
  end
61
61
 
62
62
  # defines the valid command line options
63
- OPTIONS = %w(help verbose interval=i limit=i)
63
+ OPTIONS = %w[help verbose interval=i limit=i].freeze
64
64
 
65
65
  # prints usage/help information
66
66
  def usage
67
67
  self.class.usage
68
68
  end
69
+
69
70
  # prints usage/help information
70
71
  def self.usage
71
- $stderr.puts <<-EOS
72
+ $stderr.puts <<~EOS
73
+
74
+ It goes PING! v#{Igp::VERSION}
75
+ ===================================
72
76
 
73
- It goes PING! v#{Igp::VERSION}
74
- ===================================
77
+ Usage:
78
+ igp [options] uri
75
79
 
76
- Usage:
77
- igp [options] uri
78
-
79
- Options:
80
- -h | --help :shows command help
81
- -i= | --interval=seconds (default: 1 second)
82
- -l= | --limit=number of tests (default: infinite)
80
+ Options:
81
+ -h | --help :shows command help
82
+ -i= | --interval=seconds (default: 1 second)
83
+ -l= | --limit=number of tests (default: infinite)
83
84
 
84
- The uri specifies the protocol, hostname and port.
85
- The ICMP protocol is assumed if not specified.
86
- The default well-known port is assumed if not specified.
85
+ The uri specifies the protocol, hostname and port.
86
+ The ICMP protocol is assumed if not specified.
87
+ The default well-known port is assumed if not specified.
87
88
 
88
- Examples:
89
+ Examples:
89
90
 
90
- ICMP ping:
91
- igp localhost
92
- igp icmp://localhost
91
+ ICMP ping:
92
+ igp localhost
93
+ igp icmp://localhost
93
94
 
94
- UDP/TCP ping:
95
- igp udp://localhost:123
96
- igp tcp://localhost:843
95
+ UDP/TCP ping:
96
+ igp udp://localhost:123
97
+ igp tcp://localhost:843
97
98
 
98
- HTTP/S ping:
99
- igp http://localhost:8080
100
- igp https://localhost:4443
99
+ HTTP/S ping:
100
+ igp http://localhost:8080
101
+ igp https://localhost:4443
101
102
 
102
- LDAP/S ping:
103
- igp ldap://localhost
104
- igp ldaps://localhost:6636
103
+ LDAP/S ping:
104
+ igp ldap://localhost
105
+ igp ldaps://localhost:6636
105
106
 
106
107
  EOS
107
108
  end
108
- end
109
+ end
data/lib/igp/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Igp
2
- VERSION = "0.0.2"
2
+ VERSION = '1.1.0'.freeze
3
3
  end
data/lib/igp.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'net/ping'
2
+ require 'net/ping/ldap'
2
3
  require 'igp/version'
3
4
  require 'igp/shell'
4
5
  require 'igp/base'