waittcp 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/bin/waittcp +39 -4
  4. data/waittcp.gemspec +1 -1
  5. metadata +10 -10
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ff3b73c8ba15a926a5e4bd8874d3ceaa2f3a90a0
4
- data.tar.gz: 4b59607c2969cc715c986a8a9973fbc861fc6b51
3
+ metadata.gz: 154f23ea6c80204f8fd998ca35d0f112cb63a612
4
+ data.tar.gz: 06595e472dfd10b5f8862ac8d2efa78f00d39e3f
5
5
  SHA512:
6
- metadata.gz: 4f8528d621891b852269a1558437b43779adbd22873171deee70c14cea85171b4285fb78345aad88d4b5baf73fd5b833eaae133f461ebfb42e8ce5290d0dbc2f
7
- data.tar.gz: 2ca942344ea486c239ffc025d940eed8a9f85e9b7eb1f07470f5ea41d36eee47af7b0efed232c69cbb0e7e42cd497ee3d6f6e26353c1f0f365f007ced863f4dd
6
+ metadata.gz: a2f2fd6b04c108f9bb7151da3cfda35c378e6689f77b068db7357e16cd304cf3ac44551cd26d0a7ee761a9e7dafcca975d4578f55e5b392232131119a8685e01
7
+ data.tar.gz: 83eb0669d71df692d448577fef8d30288d823da7b27f5f631ce4a495ee16e0dd15f7b5bc512362d4a23bf7b251dfb91dfa134cfaa5e668b6e8f11fb5b361e1dc
data/.gitignore CHANGED
@@ -12,3 +12,4 @@
12
12
  *.o
13
13
  *.a
14
14
  mkmf.log
15
+ *.gem
data/bin/waittcp CHANGED
@@ -1,17 +1,52 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'socket'
4
+ require 'timeout'
5
+ require 'getoptlong'
4
6
 
5
- host = ARGV[0] || 'localhost'
6
- port = ARGV[1] || '22'
7
+ opts = GetoptLong.new(
8
+ [ '--port', '-p', GetoptLong::OPTIONAL_ARGUMENT ],
9
+ [ '--wait', '-w', GetoptLong::OPTIONAL_ARGUMENT ],
10
+ [ '--ssh', '-x', GetoptLong::NO_ARGUMENT ],
11
+ [ '--help', '-h', GetoptLong::NO_ARGUMENT ]
12
+ )
13
+
14
+ def help
15
+ puts "Usage: waittcp [--port 22|-p 22] [--wait 2|-w 2] [--ssh|-x] [--help|-h] [localhost]"
16
+ exit 1
17
+ end
18
+
19
+ host = 'localhost'
20
+ port = '22'
21
+ wait = 2
22
+ ssh = false
23
+
24
+ begin
25
+ opts.each do |opt, arg|
26
+ case opt
27
+ when '--port'
28
+ port = arg
29
+ when '--ssh'
30
+ ssh = true
31
+ when '--wait'
32
+ wait = arg.to_i
33
+ end
34
+ end
35
+ rescue
36
+ help
37
+ end
38
+
39
+ host = ARGV[0] if ARGV.size > 0
7
40
 
8
41
  while true do
9
42
  begin
10
- s = TCPSocket.new host, port
43
+ Timeout::timeout(wait) { TCPSocket.new(host, port) }
11
44
  puts '>'
12
45
  break
13
46
  rescue
14
47
  $stdout.write '.'
15
- sleep(3)
48
+ sleep(wait)
16
49
  end
17
50
  end
51
+
52
+ exec("ssh -p #{port} #{host}") if ssh
data/waittcp.gemspec CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "waittcp"
7
- spec.version = "0.1.0"
7
+ spec.version = "0.2.0"
8
8
  spec.authors = ["Sascha Spreitzer"]
9
9
  spec.email = ["sascha@spreitzer.ch"]
10
10
  spec.summary = "waittcp blocks until a tcp can connect"
metadata CHANGED
@@ -1,41 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: waittcp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sascha Spreitzer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-11 00:00:00.000000000 Z
11
+ date: 2016-06-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.7'
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: '1.7'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '10.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10.0'
41
41
  description: wait for a tcp connection
@@ -46,7 +46,7 @@ executables:
46
46
  extensions: []
47
47
  extra_rdoc_files: []
48
48
  files:
49
- - .gitignore
49
+ - ".gitignore"
50
50
  - Gemfile
51
51
  - LICENSE.txt
52
52
  - README.md
@@ -63,17 +63,17 @@ require_paths:
63
63
  - lib
64
64
  required_ruby_version: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  required_rubygems_version: !ruby/object:Gem::Requirement
70
70
  requirements:
71
- - - '>='
71
+ - - ">="
72
72
  - !ruby/object:Gem::Version
73
73
  version: '0'
74
74
  requirements: []
75
75
  rubyforge_project:
76
- rubygems_version: 2.0.14
76
+ rubygems_version: 2.4.8
77
77
  signing_key:
78
78
  specification_version: 4
79
79
  summary: waittcp blocks until a tcp can connect