ztk 0.0.7 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -14,6 +14,10 @@ Issues:
14
14
 
15
15
  * https://github.com/jovelabs/ztk/issues
16
16
 
17
+ Documentation:
18
+
19
+ * http://rubydoc.info/gems/ztk
20
+
17
21
  Wiki:
18
22
 
19
23
  * https://github.com/jovelabs/ztk/wiki
@@ -22,7 +26,7 @@ Wiki:
22
26
 
23
27
  ZTK - Zachary's Tool Kit
24
28
 
25
- * Author: Zachary Patten <zachary@jovelabs.com>
29
+ * Author: Zachary Patten <zachary@jovelabs.net>
26
30
  * Copyright: Copyright (c) Jove Labs
27
31
  * License: Apache License, Version 2.0
28
32
 
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
1
  ################################################################################
2
2
  #
3
- # Author: Zachary Patten <zachary@jovelabs.com>
3
+ # Author: Zachary Patten <zachary@jovelabs.net>
4
4
  # Copyright: Copyright (c) Jove Labs
5
5
  # License: Apache License, Version 2.0
6
6
  #
data/lib/ztk/base.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  ################################################################################
2
2
  #
3
- # Author: Zachary Patten <zachary@jovelabs.com>
3
+ # Author: Zachary Patten <zachary@jovelabs.net>
4
4
  # Copyright: Copyright (c) Jove Labs
5
5
  # License: Apache License, Version 2.0
6
6
  #
@@ -25,6 +25,8 @@ module ZTK
25
25
  # ZTK::Base error class
26
26
  class BaseError < Error; end
27
27
 
28
+ # ZTK Base Class
29
+ #
28
30
  # This is the base class inherited by most of the other classes in this
29
31
  # library. It provides a standard set of features to control STDOUT, STDERR
30
32
  # and STDIN, a configuration mechanism and logging mechanism.
data/lib/ztk/command.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  ################################################################################
2
2
  #
3
- # Author: Zachary Patten <zachary@jovelabs.com>
3
+ # Author: Zachary Patten <zachary@jovelabs.net>
4
4
  # Copyright: Copyright (c) Jove Labs
5
5
  # License: Apache License, Version 2.0
6
6
  #
@@ -23,21 +23,41 @@ require "ostruct"
23
23
  module ZTK
24
24
 
25
25
  # ZTK::Command error class
26
- # @author Zachary Patten <zachary@jovelabs.com>
26
+ #
27
+ # @author Zachary Patten <zachary@jovelabs.net>
27
28
  class CommandError < Error; end
28
29
 
29
- ################################################################################
30
-
30
+ # Command Execution Class
31
+ #
32
+ # We can get a new instance of Command like so:
33
+ #
34
+ # cmd = ZTK::Command.new
35
+ #
36
+ # If we wanted to redirect STDOUT and STDERR to a StringIO we can do this:
37
+ #
38
+ # std_combo = StringIO.new
39
+ # cmd = ZTK::Command.new(:stdout => std_combo, :stderr => std_combo)
40
+ #
41
+ # @author Zachary Patten <zachary@jovelabs.net>
31
42
  class Command < ZTK::Base
32
43
 
33
- ################################################################################
34
-
35
44
  def initialize(config={})
36
45
  super(config)
37
46
  end
38
47
 
39
- ################################################################################
40
-
48
+ # Executes a local command.
49
+ #
50
+ # @param [String] command The command to execute.
51
+ # @param [Hash] options The options hash for executing the command.
52
+ #
53
+ # @return [OpenStruct#output] The output of the command, both STDOUT and
54
+ # STDERR.
55
+ # @return [OpenStruct#exit] The exit status (i.e. $?).
56
+ #
57
+ # @example Execute a command:
58
+ #
59
+ # cmd = ZTK::Command.new
60
+ # puts cmd.exec("hostname -f").inspect
41
61
  def exec(command, options={})
42
62
  options = OpenStruct.new({ :exit_code => 0, :silence => false }.merge(options))
43
63
  log(:debug) { "config(#{@config.inspect})" }
@@ -65,8 +85,12 @@ module ZTK
65
85
 
66
86
  Process.waitpid(pid)
67
87
 
68
- @config.stdout.write(parent_stdout_reader.read) unless options.silence
69
- @config.stderr.write(parent_stderr_reader.read) unless options.silence
88
+ stdout = parent_stdout_reader.read
89
+ stderr = parent_stderr_reader.read
90
+ output = (stdout || '') + (stderr || '')
91
+
92
+ @config.stdout.write(stdout) unless options.silence
93
+ @config.stderr.write(stderr) unless options.silence
70
94
 
71
95
  parent_stdout_reader.close
72
96
  parent_stderr_reader.close
@@ -79,7 +103,7 @@ module ZTK
79
103
  raise CommandError, message
80
104
  end
81
105
 
82
- $?
106
+ OpenStruct.new(:output => output, :exit => $?)
83
107
  end
84
108
 
85
109
  def upload(*args)
@@ -90,12 +114,6 @@ module ZTK
90
114
  raise CommandError, "Not Implemented"
91
115
  end
92
116
 
93
- ################################################################################
94
-
95
117
  end
96
118
 
97
- ################################################################################
98
-
99
119
  end
100
-
101
- ################################################################################
data/lib/ztk/logger.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  ################################################################################
2
2
  #
3
- # Author: Zachary Patten <zachary@jovelabs.com>
3
+ # Author: Zachary Patten <zachary@jovelabs.net>
4
4
  # Copyright: Copyright (c) Jove Labs
5
5
  # License: Apache License, Version 2.0
6
6
  #
@@ -22,7 +22,27 @@ require "logger"
22
22
 
23
23
  module ZTK
24
24
 
25
- # @author Zachary Patten <zachary@jovelabs.com>
25
+ # Standard Logging Class
26
+ #
27
+ # Supplies loggers the same as the base ruby logger class, except adds some
28
+ # extra spice to your log messages. This includes uSec timestamping, PIDs and
29
+ # caller tree details.
30
+ #
31
+ # One can override the logging level on the command line with programs that
32
+ # use this library like so:
33
+ # LOG_LEVEL=DEBUG bin/cucumber-chef ssh
34
+ #
35
+ # = Typical usage:
36
+ #
37
+ # $logger = ZTK::Logger.new("/dev/null")
38
+ #
39
+ # $logger.debug { "This is a debug message!" }
40
+ # $logger.info { "This is a info message!" }
41
+ # $logger.warn { "This is a warn message!" }
42
+ # $logger.error { "This is a error message!" }
43
+ # $logger.fatal { "This is a fatal message!" }
44
+ #
45
+ # @author Zachary Patten <zachary@jovelabs.net>
26
46
  class Logger < ::Logger
27
47
 
28
48
  SEVERITIES = Severity.constants.inject([]) {|arr,c| arr[Severity.const_get(c)] = c; arr}
data/lib/ztk/parallel.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  ################################################################################
2
2
  #
3
- # Author: Zachary Patten <zachary@jovelabs.com>
3
+ # Author: Zachary Patten <zachary@jovelabs.net>
4
4
  # Copyright: Copyright (c) Jove Labs
5
5
  # License: Apache License, VersIOn 2.0
6
6
  #
@@ -20,29 +20,58 @@
20
20
 
21
21
  require "base64"
22
22
 
23
- ################################################################################
24
-
25
23
  module ZTK
26
24
 
27
- ################################################################################
28
-
25
+ # ZTK::Parallel error class
26
+ #
27
+ # @author Zachary Patten <zachary@jovelabs.net>
29
28
  class ParallelError < Error; end
30
29
 
31
- ################################################################################
32
-
30
+ # Parallel Processing Class
31
+ #
32
+ # This class can be used to easily run iterative and linear processes in a parallel manner.
33
+ #
34
+ # a_callback = Proc.new do |pid|
35
+ # puts "Hello from After Callback - PID #{pid}"
36
+ # end
37
+ #
38
+ # b_callback = Proc.new do |pid|
39
+ # puts "Hello from Before Callback - PID #{pid}"
40
+ # end
41
+ #
42
+ # parallel = ZTK::Parallel.new
43
+ # parallel.config do |config|
44
+ # config.before_fork = b_callback
45
+ # config.after_fork = a_callback
46
+ # end
47
+ #
48
+ # 3.times do |x|
49
+ # parallel.process do
50
+ # x
51
+ # end
52
+ # end
53
+ #
54
+ # parallel.waitall
55
+ # parallel.results
56
+ #
57
+ # The before fork callback is called once in the parent process.
58
+ #
59
+ # The after fork callback is called twice, once in the parent process and once
60
+ # in the child process.
61
+ #
62
+ # @author Zachary Patten <zachary@jovelabs.net>
33
63
  class Parallel < ZTK::Base
34
64
 
35
- ################################################################################
36
-
65
+ # Result Set
37
66
  attr_accessor :results
38
67
 
39
- ################################################################################
40
-
68
+ # @param [Hash] config Configuration options hash.
69
+ # @option config [Integer] :max_forks Maximum number of forks to use.
70
+ # @option config [Proc] :before_fork (nil) Proc to call before forking.
71
+ # @option config [Proc] :after_fork (nil) Proc to call after forking.
41
72
  def initialize(config={})
42
73
  super({
43
74
  :max_forks => %x( grep -c processor /proc/cpuinfo ).chomp.to_i,
44
- :before_fork => nil,
45
- :after_fork => nil
46
75
  }.merge(config))
47
76
 
48
77
  @forks = Array.new
@@ -50,8 +79,12 @@ module ZTK
50
79
  GC.respond_to?(:copy_on_write_friendly=) and GC.copy_on_write_friendly = true
51
80
  end
52
81
 
53
- ################################################################################
54
-
82
+ # Process in parallel.
83
+ #
84
+ # @yield Block should execute tasks to be performed in parallel.
85
+ # @yieldreturn [Object] Block can return any object to be marshalled back to
86
+ # the parent processes result set.
87
+ # @return [Integer] Returns the pid of the child process forked.
55
88
  def process(&block)
56
89
  raise ParallelError, "You must supply a block to the process method!" if !block_given?
57
90
 
@@ -91,9 +124,16 @@ module ZTK
91
124
  pid
92
125
  end
93
126
 
94
- ################################################################################
95
-
127
+ # Wait for a single fork to finish.
128
+ #
129
+ # If a fork successfully finishes, it's return value from the *process*
130
+ # block is stored into the main result set.
131
+ #
132
+ # @return [Array<pid, status, data>] An array containing the pid,
133
+ # status and data returned from the process block. If wait2() fails nil
134
+ # is returned.
96
135
  def wait
136
+ log(:debug) { "wait" }
97
137
  log(:debug) { "forks(#{@forks.inspect})" }
98
138
  pid, status = (Process.wait2(-1) rescue nil)
99
139
  if !pid.nil? && !status.nil? && !(fork = @forks.select{ |f| f[:pid] == pid }.first).nil?
@@ -109,30 +149,25 @@ module ZTK
109
149
  nil
110
150
  end
111
151
 
112
- ################################################################################
113
-
152
+ # Waits for all forks to finish.
153
+ #
154
+ # @return [Array<Object>] The results from all of the *process* blocks.
114
155
  def waitall
115
- data = Array.new
156
+ log(:debug) { "waitall" }
116
157
  while @forks.count > 0
117
- result = self.wait
118
- result and data << result
158
+ self.wait
119
159
  end
120
- data
160
+ @results
121
161
  end
122
162
 
123
- ################################################################################
124
-
163
+ # Count of active forks.
164
+ #
165
+ # @return [Integer] Current number of active forks.
125
166
  def count
126
167
  log(:debug) { "count(#{@forks.count})" }
127
168
  @forks.count
128
169
  end
129
170
 
130
- ################################################################################
131
-
132
171
  end
133
172
 
134
- ################################################################################
135
-
136
173
  end
137
-
138
- ################################################################################
data/lib/ztk/spinner.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  ################################################################################
2
2
  #
3
- # Author: Zachary Patten <zachary@jovelabs.com>
3
+ # Author: Zachary Patten <zachary@jovelabs.net>
4
4
  # Copyright: Copyright (c) Jove Labs
5
5
  # License: Apache License, Version 2.0
6
6
  #
@@ -24,10 +24,13 @@ module ZTK
24
24
 
25
25
  # ZTK::Spinner error class
26
26
  #
27
- # @author Zachary Patten <zachary@jovelabs.com>
27
+ # @author Zachary Patten <zachary@jovelabs.net>
28
+ # @author Stephen Nelson-Smith <stephen@atalanta-systems.com>
28
29
  class SpinnerError < Error; end
29
30
 
30
- # @author Zachary Patten <zachary@jovelabs.com>
31
+ # Spinner Class
32
+ # @author Zachary Patten <zachary@jovelabs.net>
33
+ # @author Stephen Nelson-Smith <stephen@atalanta-systems.com>
31
34
  class Spinner
32
35
 
33
36
  class << self
data/lib/ztk/ssh.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  ################################################################################
2
2
  #
3
- # Author: Zachary Patten <zachary@jovelabs.com>
3
+ # Author: Zachary Patten <zachary@jovelabs.net>
4
4
  # Copyright: Copyright (c) Jove Labs
5
5
  # License: Apache License, Version 2.0
6
6
  #
@@ -27,23 +27,29 @@ module ZTK
27
27
 
28
28
  # ZTK::SSH error class
29
29
  #
30
- # @author Zachary Patten <zachary@jovelabs.com>
30
+ # @author Zachary Patten <zachary@jovelabs.net>
31
31
  class SSHError < Error; end
32
32
 
33
+ # SSH Multi-function Class
34
+ #
33
35
  # We can get a new instance of SSH like so:
36
+ #
34
37
  # ssh = ZTK::SSH.new
35
38
  #
36
39
  # If we wanted to redirect STDOUT and STDERR to a StringIO we can do this:
40
+ #
37
41
  # std_combo = StringIO.new
38
42
  # ssh = ZTK::SSH.new(:stdout => std_combo, :stderr => std_combo)
39
43
  #
40
44
  # If you want to specify SSH options you can:
45
+ #
41
46
  # keys = File.expand_path(File.join(ENV['HOME'], '.ssh', 'id_rsa'))
42
47
  # ssh = ZTK::SSH.new(:host_name => '127.0.0.1', :user => ENV['USER'], :keys => keys)
43
48
  #
44
49
  # = Configuration Examples:
45
50
  #
46
51
  # To proxy through another host, for example SSH to 192.168.1.1 through 192.168.0.1:
52
+ #
47
53
  # ssh.config do |config|
48
54
  # config.user = ENV['USER']
49
55
  # config.host_name = '192.168.1.1'
@@ -52,27 +58,31 @@ module ZTK
52
58
  # end
53
59
  #
54
60
  # Specify an identity file:
61
+ #
55
62
  # ssh.config do |config|
56
63
  # config.keys = File.expand_path(File.join(ENV['HOME'], '.ssh', 'id_rsa'))
57
64
  # config.proxy_keys = File.expand_path(File.join(ENV['HOME'], '.ssh', 'id_rsa'))
58
65
  # end
59
66
  #
60
67
  # Specify a timeout:
68
+ #
61
69
  # ssh.config do |config|
62
70
  # config.timeout = 30
63
71
  # end
64
72
  #
65
73
  # Specify a password:
74
+ #
66
75
  # ssh.config do |config|
67
76
  # config.password = 'p@$$w0rd'
68
77
  # end
69
78
  #
70
79
  # Check host keys, the default is false (off):
80
+ #
71
81
  # ssh.config do |config|
72
82
  # config.host_key_verify = true
73
83
  # end
74
84
  #
75
- # @author Zachary Patten <zachary@jovelabs.com>
85
+ # @author Zachary Patten <zachary@jovelabs.net>
76
86
  class SSH < ZTK::Base
77
87
 
78
88
  # @param [Hash] config Configuration options hash.
@@ -131,13 +141,13 @@ module ZTK
131
141
  # @return [OpenStruct#exit] The exit status (i.e. $?).
132
142
  #
133
143
  # @example Execute a command:
134
- # $logger = ZTK::Logger.new(STDOUT)
144
+ #
135
145
  # ssh = ZTK::SSH.new
136
146
  # ssh.config do |config|
137
147
  # config.user = ENV["USER"]
138
148
  # config.host_name = "127.0.0.1"
139
149
  # end
140
- # puts ssh.exec("hostname -f").output
150
+ # puts ssh.exec("hostname -f").inspect
141
151
  def exec(command, options={})
142
152
  log(:debug) { "exec(#{command.inspect}, #{options.inspect})" }
143
153
  log(:debug) { "config(#{@config.inspect})" }
@@ -1,6 +1,6 @@
1
1
  ################################################################################
2
2
  #
3
- # Author: Zachary Patten <zachary@jovelabs.com>
3
+ # Author: Zachary Patten <zachary@jovelabs.net>
4
4
  # Copyright: Copyright (c) Jove Labs
5
5
  # License: Apache License, Version 2.0
6
6
  #
@@ -25,15 +25,38 @@ module ZTK
25
25
 
26
26
  # ZTK::TCPSocketCheck error class
27
27
  #
28
- # @author Zachary Patten <zachary@jovelabs.com>
28
+ # @author Zachary Patten <zachary@jovelabs.net>
29
29
  class TCPSocketCheckError < Error; end
30
30
 
31
31
  # TCP Socket Checking Class
32
32
  #
33
+ # This class has two basic modes of operation:
34
+ #
35
+ # * Read Test
36
+ #
37
+ # By default we will perform a read test against the host and port specified.
38
+ # In this mode we will attempt to connect to the host and port supplied and if
39
+ # we can read any amount of data, regardless of the content we view this as
40
+ # success.
41
+ #
42
+ # * Write Test
43
+ #
44
+ # If data is supplied via the configuration, this will change the mode of
45
+ # operation to a write test. Certain services, such as HTTP don't send any
46
+ # data unless you send something first. In this mode we will attempt to
47
+ # connect to the host and port supplied, once connected we will write the
48
+ # supplied data to the socket and then attempt to read from the socket. If we
49
+ # can read any amount of data, reagardless of the conent we view this as
50
+ # success.
51
+ #
52
+ # = Typical usage:
53
+ #
33
54
  # Given a host and port we want to check, we can do something like this:
55
+ #
34
56
  # sc = ZTK::TCPSocketCheck.new(:host => "www.github.com", :port => 22)
35
57
  #
36
58
  # Then if we want to check if this host is responding on the specified port:
59
+ #
37
60
  # sc.ready? and puts("They are there!")
38
61
  #
39
62
  # This works well for protocols that spew forth some data right away for use
@@ -42,17 +65,22 @@ module ZTK
42
65
  #
43
66
  # Given we want to check a host and port that requires some giving before we
44
67
  # can take:
68
+ #
45
69
  # sc = ZTK::TCPSocketCheck.new(:host => "www.google.com", :port => 80, :data => "GET")
46
70
  #
47
71
  # Then if we want to check if this host is responding on the specified port:
72
+ #
48
73
  # sc.ready? and puts("They are there!")
74
+ #
49
75
  # The ready? methods timeout is bound to the configuration option *timeout*.
50
76
  #
51
77
  # If we are waiting for a service to come online, we can do this:
78
+ #
52
79
  # sc.wait and puts("They are there!")
80
+ #
53
81
  # The wait methods timeout is bound to the configuration option *wait*.
54
82
  #
55
- # @author Zachary Patten <zachary@jovelabs.com>
83
+ # @author Zachary Patten <zachary@jovelabs.net>
56
84
  class TCPSocketCheck < ZTK::Base
57
85
 
58
86
  # @param [Hash] config Configuration options hash.
data/lib/ztk/template.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  ################################################################################
2
2
  #
3
- # Author: Zachary Patten <zachary@jovelabs.com>
3
+ # Author: Zachary Patten <zachary@jovelabs.net>
4
4
  # Copyright: Copyright (c) Jove Labs
5
5
  # License: Apache License, Version 2.0
6
6
  #
@@ -24,23 +24,26 @@ module ZTK
24
24
 
25
25
  # ZTK::Template error class
26
26
  #
27
- # @author Zachary Patten <zachary@jovelabs.com>
27
+ # @author Zachary Patten <zachary@jovelabs.net>
28
28
  class TemplateError < Error; end
29
29
 
30
30
  # Erubis Templating Class
31
31
  #
32
32
  # Given a template like this (i.e. "template.erb"):
33
+ #
33
34
  # This is a test template!
34
35
  # <%= @variable %>
35
36
  #
36
37
  # We can do this:
38
+ #
37
39
  # ZTK::Template.render("template.erb", { :variable => "Hello World" })
38
40
  #
39
41
  # And get:
42
+ #
40
43
  # This is a test template!
41
44
  # Hello World
42
45
  #
43
- # @author Zachary Patten <zachary@jovelabs.com>
46
+ # @author Zachary Patten <zachary@jovelabs.net>
44
47
  class Template
45
48
 
46
49
  class << self
data/lib/ztk/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  ################################################################################
2
2
  #
3
- # Author: Zachary Patten <zachary@jovelabs.com>
3
+ # Author: Zachary Patten <zachary@jovelabs.net>
4
4
  # Copyright: Copyright (c) Jove Labs
5
5
  # License: Apache License, Version 2.0
6
6
  #
@@ -19,5 +19,5 @@
19
19
  ################################################################################
20
20
 
21
21
  module ZTK
22
- VERSION = "0.0.7" unless const_defined?(:VERSION)
22
+ VERSION = "0.0.8" unless const_defined?(:VERSION)
23
23
  end
data/lib/ztk.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  ################################################################################
2
2
  #
3
- # Author: Zachary Patten <zachary@jovelabs.com>
3
+ # Author: Zachary Patten <zachary@jovelabs.net>
4
4
  # Copyright: Copyright (c) Jove Labs
5
5
  # License: Apache License, Version 2.0
6
6
  #
@@ -22,12 +22,12 @@ require "ztk/version"
22
22
 
23
23
  # Main ZTK module
24
24
  #
25
- # @author Zachary Patten <zachary@jovelabs.com>
25
+ # @author Zachary Patten <zachary@jovelabs.net>
26
26
  module ZTK
27
27
 
28
28
  # ZTK error class
29
29
  #
30
- # @author Zachary Patten <zachary@jovelabs.com>
30
+ # @author Zachary Patten <zachary@jovelabs.net>
31
31
  class Error < StandardError; end
32
32
 
33
33
  autoload :Base, "ztk/base"
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  ################################################################################
2
2
  #
3
- # Author: Zachary Patten <zachary@jovelabs.com>
3
+ # Author: Zachary Patten <zachary@jovelabs.net>
4
4
  # Copyright: Copyright (c) Jove Labs
5
5
  # License: Apache License, Version 2.0
6
6
  #
@@ -27,4 +27,6 @@ SimpleCov.start do
27
27
  add_filter '/spec/'
28
28
  end if ENV["COVERAGE"]
29
29
 
30
+ $logger = ZTK::Logger.new("test.log")
31
+
30
32
  ################################################################################
@@ -1,6 +1,6 @@
1
1
  ################################################################################
2
2
  #
3
- # Author: Zachary Patten <zachary@jovelabs.com>
3
+ # Author: Zachary Patten <zachary@jovelabs.net>
4
4
  # Copyright: Copyright (c) Jove Labs
5
5
  # License: Apache License, Version 2.0
6
6
  #
@@ -25,7 +25,6 @@ describe ZTK::Command do
25
25
  subject { ZTK::Command.new }
26
26
 
27
27
  before(:all) do
28
- $logger = ZTK::Logger.new("/dev/null")
29
28
  $stdout = File.open("/dev/null", "w")
30
29
  $stderr = File.open("/dev/null", "w")
31
30
  $stdin = File.open("/dev/null", "r")
@@ -70,7 +69,7 @@ describe ZTK::Command do
70
69
  end
71
70
  hostname = %x( hostname -f ).chomp
72
71
  status = subject.exec("hostname -f")
73
- status.exitstatus.should == 0
72
+ status.exit.exitstatus.should == 0
74
73
  stdout.rewind
75
74
  stdout.read.chomp.should == hostname
76
75
  end
@@ -1,6 +1,6 @@
1
1
  ################################################################################
2
2
  #
3
- # Author: Zachary Patten <zachary@jovelabs.com>
3
+ # Author: Zachary Patten <zachary@jovelabs.net>
4
4
  # Copyright: Copyright (c) Jove Labs
5
5
  # License: Apache License, Version 2.0
6
6
  #
@@ -1,6 +1,6 @@
1
1
  ################################################################################
2
2
  #
3
- # Author: Zachary Patten <zachary@jovelabs.com>
3
+ # Author: Zachary Patten <zachary@jovelabs.net>
4
4
  # Copyright: Copyright (c) Jove Labs
5
5
  # License: Apache License, Version 2.0
6
6
  #
@@ -25,7 +25,6 @@ describe ZTK::Parallel do
25
25
  subject { ZTK::Parallel.new }
26
26
 
27
27
  before(:all) do
28
- $logger = ZTK::Logger.new("/dev/null")
29
28
  $stdout = File.open("/dev/null", "w")
30
29
  $stderr = File.open("/dev/null", "w")
31
30
  $stdin = File.open("/dev/null", "r")
@@ -83,6 +82,22 @@ describe ZTK::Parallel do
83
82
  subject.results.include?(Process.pid).should be false
84
83
  end
85
84
 
85
+ it "should be able to incrementally wait the forks" do
86
+ 3.times do |x|
87
+ subject.process do
88
+ Process.pid
89
+ end
90
+ end
91
+ 3.times do
92
+ subject.wait
93
+ end
94
+ puts subject.results.inspect
95
+ subject.results.all?{ |r| r.should be_kind_of Integer }
96
+ subject.results.all?{ |r| r.should > 0 }
97
+ subject.results.uniq.count.should == 3
98
+ subject.results.include?(Process.pid).should be false
99
+ end
100
+
86
101
  end
87
102
 
88
103
  end
data/spec/ztk/ssh_spec.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  ################################################################################
2
2
  #
3
- # Author: Zachary Patten <zachary@jovelabs.com>
3
+ # Author: Zachary Patten <zachary@jovelabs.net>
4
4
  # Copyright: Copyright (c) Jove Labs
5
5
  # License: Apache License, Version 2.0
6
6
  #
@@ -25,7 +25,6 @@ describe ZTK::SSH do
25
25
  subject { ZTK::SSH.new }
26
26
 
27
27
  before(:all) do
28
- $logger = ZTK::Logger.new("test.log")
29
28
  $stdout = File.open("/dev/null", "w")
30
29
  $stderr = File.open("/dev/null", "w")
31
30
  $stdin = File.open("/dev/null", "r")
@@ -1,6 +1,6 @@
1
1
  ################################################################################
2
2
  #
3
- # Author: Zachary Patten <zachary@jovelabs.com>
3
+ # Author: Zachary Patten <zachary@jovelabs.net>
4
4
  # Copyright: Copyright (c) Jove Labs
5
5
  # License: Apache License, Version 2.0
6
6
  #
@@ -25,7 +25,6 @@ describe ZTK::TCPSocketCheck do
25
25
  subject { ZTK::TCPSocketCheck.new }
26
26
 
27
27
  before(:all) do
28
- $logger = ZTK::Logger.new("/dev/null")
29
28
  $stdout = File.open("/dev/null", "w")
30
29
  $stderr = File.open("/dev/null", "w")
31
30
  $stdin = File.open("/dev/null", "r")
@@ -1,6 +1,6 @@
1
1
  ################################################################################
2
2
  #
3
- # Author: Zachary Patten <zachary@jovelabs.com>
3
+ # Author: Zachary Patten <zachary@jovelabs.net>
4
4
  # Copyright: Copyright (c) Jove Labs
5
5
  # License: Apache License, Version 2.0
6
6
  #
@@ -25,7 +25,6 @@ describe ZTK::Template do
25
25
  subject { ZTK::Template }
26
26
 
27
27
  before(:all) do
28
- $logger = ZTK::Logger.new("/dev/null")
29
28
  $stdout = File.open("/dev/null", "w")
30
29
  $stderr = File.open("/dev/null", "w")
31
30
  $stdin = File.open("/dev/null", "r")
data/ztk.gemspec CHANGED
@@ -3,7 +3,7 @@ require File.expand_path('../lib/ztk/version', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |gem|
5
5
  gem.authors = ["Zachary Patten"]
6
- gem.email = ["zachary@jovelabs.com"]
6
+ gem.email = ["zachary@jovelabs.net"]
7
7
  gem.description = %q{Zachary's Tool Kit}
8
8
  gem.summary = %q{Contains various classes and utilities I find I regularly need.}
9
9
  gem.homepage = "https://github.com/jovelabs/ztk"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ztk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -157,7 +157,7 @@ dependencies:
157
157
  version: '0'
158
158
  description: Zachary's Tool Kit
159
159
  email:
160
- - zachary@jovelabs.com
160
+ - zachary@jovelabs.net
161
161
  executables:
162
162
  - ztk
163
163
  extensions: []
@@ -205,7 +205,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
205
205
  version: '0'
206
206
  segments:
207
207
  - 0
208
- hash: -971283166384197742
208
+ hash: -3183770896296440620
209
209
  required_rubygems_version: !ruby/object:Gem::Requirement
210
210
  none: false
211
211
  requirements:
@@ -214,7 +214,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
214
214
  version: '0'
215
215
  segments:
216
216
  - 0
217
- hash: -971283166384197742
217
+ hash: -3183770896296440620
218
218
  requirements: []
219
219
  rubyforge_project:
220
220
  rubygems_version: 1.8.24