thecon 0.0.2 → 0.0.3

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: 190b3edb3ccf2f8fb1485a42f49f0aaebfda606f
4
- data.tar.gz: ce6b74d3d88f0135db81c327c1dd6d592d61cfbe
3
+ metadata.gz: 0720472a0014aacff5ef977690c719ef4b4791a1
4
+ data.tar.gz: a40be6cfd95c39da12b279843ba7ead1364fb495
5
5
  SHA512:
6
- metadata.gz: 0b935ddea4a3e3263ca2a26ba8a127e1eb8bc544e2d59cb1855f6c9b7f8eaf1e919c92751ec23e3c6ee68faca0d464c038fabaa7e42722ae4ebc4edef899b9e4
7
- data.tar.gz: e3e7a71ae5e1ad270dfbab0ba39de1b5f4c578b7a6052c6956e8a509ca496b00810301f57f4b7cf52d530f26d386dec1c8b47f4c9ca181e976de62402b81d17e
6
+ metadata.gz: 3d9ac106c1ec33c020a4f82c0ebfc5489b08e8724d1b59b7e1b548e6f293c6fa8562c8359569ad7fe8de046e8a782006d758fc62ea6612ea381c9e4796a03ebd
7
+ data.tar.gz: 6c2b8cf63d974ad355efdff990bd9da367d90c45ee81faee6d5c85a6c47526bb0b3a37869ca4ea04820a20fb7e1832e18bb4708a061a2f8f6fe48c85960d1fd3
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- ruby-2.0.0-p247
1
+ ruby-2.1.1
@@ -1,3 +1,3 @@
1
1
  module Thecon
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/lib/thecon.rb CHANGED
@@ -3,12 +3,16 @@ require "thecon/version"
3
3
  require 'timeout'
4
4
  require 'socket'
5
5
 
6
+ require 'logger'
7
+
6
8
  module Thecon
7
9
  # Your code goes here...
8
10
  def self.ready?(port=80, ip = "localhost", connection_timeout = 3, read_timeout = 2)
9
- result = false
10
- begin
11
- timeout( connection_timeout ) do
11
+ @log = Logger.new(STDOUT)
12
+
13
+ result = false
14
+ begin
15
+ timeout( connection_timeout ) do
12
16
  socket = Socket.new :INET, :STREAM
13
17
  sockaddr = Socket.pack_sockaddr_in port, ip
14
18
  socket.connect sockaddr
@@ -16,18 +20,18 @@ module Thecon
16
20
  timeout( read_timeout ) do
17
21
  r,w,e = select([socket], nil, nil, 1) # nil, nil, nil from inside the network
18
22
  unless r.nil? then
19
- p "socket was closed" if ( r[0].read(1).nil? ) #This means there is something there
23
+ @log.debug "socket was closed" if ( r[0].read(1).nil? ) #This means there is something there
20
24
  result = false #Something closed this
21
25
  else
22
- p "not available for read: either doesn't exist or not closed" #TRUE
26
+ @log.debug "not available for read: either doesn't exist or not closed" #TRUE
23
27
  result = true
24
28
  end
25
29
  end
26
30
  rescue StandardError => ka
27
- p "OK, standardERROR #{ka}" #If socket.read there could be errors (this shouldn't be triggered)
31
+ @log.debug "OK, standardERROR #{ka}" #If socket.read there could be errors (this shouldn't be triggered)
28
32
  result = true
29
33
  rescue Timeout::Error => e
30
- p "timedout reading" #Socket is there but there are not data to read (if socket.read)
34
+ @log.debug "timedout reading" #Socket is there but there are not data to read (if socket.read)
31
35
  result = true
32
36
  end
33
37
  end
data/thecon.gemspec CHANGED
@@ -1,22 +1,23 @@
1
- # -*- encoding: utf-8 -*-
1
+ # coding: utf-8
2
2
  lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'thecon/version'
5
5
 
6
- Gem::Specification.new do |gem|
7
- gem.name = "thecon"
8
- gem.version = Thecon::VERSION
9
- gem.authors = ["tnarik"]
10
- gem.email = ["tnarik@gmail.com"]
11
- gem.description = %q{Simple connection checker to find out if a server is available at a certain port}
12
- gem.summary = %q{Attempt a connection to a certain IP (or hostname), port}
13
- gem.homepage = ""
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "thecon"
8
+ spec.version = Thecon::VERSION
9
+ spec.authors = ["Tnarik Innael"]
10
+ spec.email = ["tnarik@lecafeautomatique.co.uk"]
11
+ spec.summary = %q{Attempt a connection to a certain IP (or hostname), port}
12
+ spec.description = %q{Simple connection checker to find out if a server is available at a certain port}
13
+ spec.homepage = "https://github.com/tnarik/thecon"
14
+ spec.license = "MIT"
14
15
 
15
- gem.files = `git ls-files`.split($/)
16
- gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
- gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
- gem.require_paths = ["lib"]
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
19
20
 
20
- # devevelopment dependencies
21
- gem.add_development_dependency "rspec"
22
- end
21
+ # development dependencies
22
+ spec.add_development_dependency "rspec"
23
+ end
metadata CHANGED
@@ -1,41 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thecon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
- - tnarik
7
+ - Tnarik Innael
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-04 00:00:00.000000000 Z
11
+ date: 2015-04-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  description: Simple connection checker to find out if a server is available at a certain
28
28
  port
29
29
  email:
30
- - tnarik@gmail.com
30
+ - tnarik@lecafeautomatique.co.uk
31
31
  executables: []
32
32
  extensions: []
33
33
  extra_rdoc_files: []
34
34
  files:
35
- - .gitignore
36
- - .rspec
37
- - .ruby-gemset
38
- - .ruby-version
35
+ - ".gitignore"
36
+ - ".rspec"
37
+ - ".ruby-gemset"
38
+ - ".ruby-version"
39
39
  - Gemfile
40
40
  - LICENSE.txt
41
41
  - README.md
@@ -45,8 +45,9 @@ files:
45
45
  - spec/spec_helper.rb
46
46
  - spec/thecon_spec.rb
47
47
  - thecon.gemspec
48
- homepage: ''
49
- licenses: []
48
+ homepage: https://github.com/tnarik/thecon
49
+ licenses:
50
+ - MIT
50
51
  metadata: {}
51
52
  post_install_message:
52
53
  rdoc_options: []
@@ -54,17 +55,17 @@ require_paths:
54
55
  - lib
55
56
  required_ruby_version: !ruby/object:Gem::Requirement
56
57
  requirements:
57
- - - '>='
58
+ - - ">="
58
59
  - !ruby/object:Gem::Version
59
60
  version: '0'
60
61
  required_rubygems_version: !ruby/object:Gem::Requirement
61
62
  requirements:
62
- - - '>='
63
+ - - ">="
63
64
  - !ruby/object:Gem::Version
64
65
  version: '0'
65
66
  requirements: []
66
67
  rubyforge_project:
67
- rubygems_version: 2.0.6
68
+ rubygems_version: 2.2.2
68
69
  signing_key:
69
70
  specification_version: 4
70
71
  summary: Attempt a connection to a certain IP (or hostname), port