ztk 1.4.4 → 1.4.5

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.
Files changed (59) hide show
  1. data/README.md +1 -1
  2. data/Rakefile +1 -1
  3. data/lib/ztk.rb +3 -23
  4. data/lib/ztk/ansi.rb +94 -33
  5. data/lib/ztk/background.rb +4 -23
  6. data/lib/ztk/base.rb +5 -24
  7. data/lib/ztk/benchmark.rb +4 -23
  8. data/lib/ztk/command.rb +49 -40
  9. data/lib/ztk/config.rb +3 -22
  10. data/lib/ztk/dsl.rb +3 -22
  11. data/lib/ztk/dsl/base.rb +14 -22
  12. data/lib/ztk/dsl/core.rb +4 -24
  13. data/lib/ztk/dsl/core/actions.rb +1 -21
  14. data/lib/ztk/dsl/core/actions/find.rb +2 -22
  15. data/lib/ztk/dsl/core/actions/timestamps.rb +2 -22
  16. data/lib/ztk/dsl/core/attributes.rb +2 -22
  17. data/lib/ztk/dsl/core/dataset.rb +2 -22
  18. data/lib/ztk/dsl/core/io.rb +2 -22
  19. data/lib/ztk/dsl/core/relations.rb +2 -22
  20. data/lib/ztk/dsl/core/relations/belongs_to.rb +2 -22
  21. data/lib/ztk/dsl/core/relations/has_many.rb +2 -22
  22. data/lib/ztk/locator.rb +3 -22
  23. data/lib/ztk/logger.rb +2 -21
  24. data/lib/ztk/parallel.rb +4 -23
  25. data/lib/ztk/pty.rb +8 -23
  26. data/lib/ztk/report.rb +4 -23
  27. data/lib/ztk/rescue_retry.rb +4 -24
  28. data/lib/ztk/spinner.rb +6 -25
  29. data/lib/ztk/ssh.rb +20 -27
  30. data/lib/ztk/ssh/bootstrap.rb +17 -19
  31. data/lib/ztk/ssh/command.rb +1 -19
  32. data/lib/ztk/ssh/download.rb +1 -19
  33. data/lib/ztk/ssh/exec.rb +14 -24
  34. data/lib/ztk/ssh/file.rb +1 -19
  35. data/lib/ztk/ssh/upload.rb +5 -22
  36. data/lib/ztk/tcp_socket_check.rb +3 -22
  37. data/lib/ztk/template.rb +4 -23
  38. data/lib/ztk/ui.rb +5 -25
  39. data/lib/ztk/version.rb +1 -21
  40. data/spec/spec_helper.rb +1 -1
  41. data/spec/ztk/background_spec.rb +1 -1
  42. data/spec/ztk/base_spec.rb +1 -1
  43. data/spec/ztk/benchmark_spec.rb +1 -1
  44. data/spec/ztk/command_spec.rb +1 -1
  45. data/spec/ztk/config_spec.rb +1 -1
  46. data/spec/ztk/dsl_spec.rb +1 -1
  47. data/spec/ztk/locator_spec.rb +1 -1
  48. data/spec/ztk/logger_spec.rb +1 -1
  49. data/spec/ztk/parallel_spec.rb +1 -1
  50. data/spec/ztk/pty_spec.rb +1 -1
  51. data/spec/ztk/rescue_retry_spec.rb +1 -1
  52. data/spec/ztk/spinner_spec.rb +1 -1
  53. data/spec/ztk/ssh_spec.rb +1 -1
  54. data/spec/ztk/tcp_socket_check_spec.rb +1 -1
  55. data/spec/ztk/template_spec.rb +1 -1
  56. data/spec/ztk/ui_spec.rb +1 -1
  57. data/spec/ztk/version_spec.rb +1 -1
  58. data/ztk.gemspec +2 -2
  59. metadata +4 -4
@@ -1,25 +1,7 @@
1
- ################################################################################
2
- #
3
- # Author: Zachary Patten <zachary@jovelabs.net>
4
- # Copyright: Copyright (c) Zachary Patten
5
- # License: Apache License, Version 2.0
6
- #
7
- # Licensed under the Apache License, Version 2.0 (the "License");
8
- # you may not use this file except in compliance with the License.
9
- # You may obtain a copy of the License at
10
- #
11
- # http://www.apache.org/licenses/LICENSE-2.0
12
- #
13
- # Unless required by applicable law or agreed to in writing, software
14
- # distributed under the License is distributed on an "AS IS" BASIS,
15
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- # See the License for the specific language governing permissions and
17
- # limitations under the License.
18
- #
19
- ################################################################################
20
1
  module ZTK
21
2
  class SSH
22
3
 
4
+ # SSH Console Command Helpers
23
5
  module Command
24
6
 
25
7
  # Builds our SSH console command.
@@ -1,25 +1,7 @@
1
- ################################################################################
2
- #
3
- # Author: Zachary Patten <zachary@jovelabs.net>
4
- # Copyright: Copyright (c) Zachary Patten
5
- # License: Apache License, Version 2.0
6
- #
7
- # Licensed under the Apache License, Version 2.0 (the "License");
8
- # you may not use this file except in compliance with the License.
9
- # You may obtain a copy of the License at
10
- #
11
- # http://www.apache.org/licenses/LICENSE-2.0
12
- #
13
- # Unless required by applicable law or agreed to in writing, software
14
- # distributed under the License is distributed on an "AS IS" BASIS,
15
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- # See the License for the specific language governing permissions and
17
- # limitations under the License.
18
- #
19
- ################################################################################
20
1
  module ZTK
21
2
  class SSH
22
3
 
4
+ # SSH Download Functionality
23
5
  module Download
24
6
 
25
7
  # Downloads a remote file to the local host.
data/lib/ztk/ssh/exec.rb CHANGED
@@ -1,35 +1,25 @@
1
- ################################################################################
2
- #
3
- # Author: Zachary Patten <zachary@jovelabs.net>
4
- # Copyright: Copyright (c) Zachary Patten
5
- # License: Apache License, Version 2.0
6
- #
7
- # Licensed under the Apache License, Version 2.0 (the "License");
8
- # you may not use this file except in compliance with the License.
9
- # You may obtain a copy of the License at
10
- #
11
- # http://www.apache.org/licenses/LICENSE-2.0
12
- #
13
- # Unless required by applicable law or agreed to in writing, software
14
- # distributed under the License is distributed on an "AS IS" BASIS,
15
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- # See the License for the specific language governing permissions and
17
- # limitations under the License.
18
- #
19
- ################################################################################
20
1
  module ZTK
21
2
  class SSH
22
3
 
4
+ # SSH Command Execution Functionality
23
5
  module Exec
24
6
 
25
7
  # Executes a command on the remote host.
26
8
  #
27
9
  # @param [String] command The command to execute.
28
10
  # @param [Hash] options The options hash for executing the command.
29
- # @option options [Boolean] :silence Squelch output to STDOUT and STDERR.
30
- # If the log level is :debug, STDOUT and STDERR will go to the log file
31
- # regardless of this setting. STDOUT and STDERR are always returned in
32
- # the output return value regardless of this setting.
11
+ # @option options [Integer] :timeout (600) How long in seconds before
12
+ # the command will timeout.
13
+ # @option options [Boolean] :ignore_exit_status (false) Whether or not
14
+ # we should ignore the exit status of the the process we spawn. By
15
+ # default we do not ignore the exit status and throw an exception if it is
16
+ # non-zero.
17
+ # @option options [Integer] :exit_code (0) The exit code we expect the
18
+ # process to return. This is ignore if *ignore_exit_status* is true.
19
+ # @option options [Boolean] :silence (false) Whether or not we should
20
+ # squelch the output of the process. The output will always go to the
21
+ # logging device supplied in the ZTK::UI object. The output is always
22
+ # available in the return value from the method additionally.
33
23
  #
34
24
  # @return [OpenStruct#output] The output of the command, both STDOUT and
35
25
  # STDERR.
@@ -44,7 +34,7 @@ module ZTK
44
34
  # end
45
35
  # puts ssh.exec("hostname").inspect
46
36
  def exec(command, options={})
47
- options = OpenStruct.new({ :exit_code => 0, :silence => false }.merge(config.send(:table)).merge(options))
37
+ options = OpenStruct.new(config.send(:table).merge(options))
48
38
 
49
39
  options.ui.logger.debug { "config=#{options.send(:table).inspect}" }
50
40
  options.ui.logger.debug { "options=#{options.send(:table).inspect}" }
data/lib/ztk/ssh/file.rb CHANGED
@@ -1,25 +1,7 @@
1
- ################################################################################
2
- #
3
- # Author: Zachary Patten <zachary@jovelabs.net>
4
- # Copyright: Copyright (c) Zachary Patten
5
- # License: Apache License, Version 2.0
6
- #
7
- # Licensed under the Apache License, Version 2.0 (the "License");
8
- # you may not use this file except in compliance with the License.
9
- # You may obtain a copy of the License at
10
- #
11
- # http://www.apache.org/licenses/LICENSE-2.0
12
- #
13
- # Unless required by applicable law or agreed to in writing, software
14
- # distributed under the License is distributed on an "AS IS" BASIS,
15
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- # See the License for the specific language governing permissions and
17
- # limitations under the License.
18
- #
19
- ################################################################################
20
1
  module ZTK
21
2
  class SSH
22
3
 
4
+ # SSH Remote File Functionality
23
5
  module File
24
6
  require 'tempfile'
25
7
 
@@ -1,32 +1,11 @@
1
- ################################################################################
2
- #
3
- # Author: Zachary Patten <zachary@jovelabs.net>
4
- # Copyright: Copyright (c) Zachary Patten
5
- # License: Apache License, Version 2.0
6
- #
7
- # Licensed under the Apache License, Version 2.0 (the "License");
8
- # you may not use this file except in compliance with the License.
9
- # You may obtain a copy of the License at
10
- #
11
- # http://www.apache.org/licenses/LICENSE-2.0
12
- #
13
- # Unless required by applicable law or agreed to in writing, software
14
- # distributed under the License is distributed on an "AS IS" BASIS,
15
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- # See the License for the specific language governing permissions and
17
- # limitations under the License.
18
- #
19
- ################################################################################
20
1
  module ZTK
21
2
  class SSH
22
3
 
4
+ # SSH Upload Functionality
23
5
  module Upload
24
6
 
25
7
  # Uploads a local file to a remote host.
26
8
  #
27
- # @param [String] local The local file/path you wish to upload from.
28
- # @param [String] remote The remote file/path you with to upload to.
29
- #
30
9
  # @example Upload a file:
31
10
  # $logger = ZTK::Logger.new(STDOUT)
32
11
  # ssh = ZTK::SSH.new
@@ -37,6 +16,10 @@ module ZTK
37
16
  # local = File.expand_path(File.join(ENV["HOME"], ".ssh", "id_rsa.pub"))
38
17
  # remote = File.expand_path(File.join("/tmp", "id_rsa.pub"))
39
18
  # ssh.upload(local, remote)
19
+ #
20
+ # @param [String] local The local file/path you wish to upload from.
21
+ # @param [String] remote The remote file/path you with to upload to.
22
+ # @return [Boolean] True if successful.
40
23
  def upload(local, remote)
41
24
  config.ui.logger.debug { "config=#{config.send(:table).inspect}" }
42
25
  config.ui.logger.info { "upload(#{local.inspect}, #{remote.inspect})" }
@@ -1,30 +1,11 @@
1
- ################################################################################
2
- #
3
- # Author: Zachary Patten <zachary@jovelabs.net>
4
- # Copyright: Copyright (c) Zachary Patten
5
- # License: Apache License, Version 2.0
6
- #
7
- # Licensed under the Apache License, Version 2.0 (the "License");
8
- # you may not use this file except in compliance with the License.
9
- # You may obtain a copy of the License at
10
- #
11
- # http://www.apache.org/licenses/LICENSE-2.0
12
- #
13
- # Unless required by applicable law or agreed to in writing, software
14
- # distributed under the License is distributed on an "AS IS" BASIS,
15
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- # See the License for the specific language governing permissions and
17
- # limitations under the License.
18
- #
19
- ################################################################################
20
1
  require 'socket'
21
2
  require 'timeout'
22
3
 
23
4
  module ZTK
24
5
 
25
- # ZTK::TCPSocketCheck Error Class
6
+ # TCPSocketCheck Error Class
26
7
  #
27
- # @author Zachary Patten <zachary@jovelabs.net>
8
+ # @author Zachary Patten <zachary AT jovelabs DOT com>
28
9
  class TCPSocketCheckError < Error; end
29
10
 
30
11
  # TCP Socket Checking Class
@@ -79,7 +60,7 @@ module ZTK
79
60
  #
80
61
  # The wait methods timeout is bound to the configuration option *wait*.
81
62
  #
82
- # @author Zachary Patten <zachary@jovelabs.net>
63
+ # @author Zachary Patten <zachary AT jovelabs DOT com>
83
64
  class TCPSocketCheck < ZTK::Base
84
65
 
85
66
  # @param [Hash] configuration Configuration options hash.
data/lib/ztk/template.rb CHANGED
@@ -1,29 +1,10 @@
1
- ################################################################################
2
- #
3
- # Author: Zachary Patten <zachary@jovelabs.net>
4
- # Copyright: Copyright (c) Zachary Patten
5
- # License: Apache License, Version 2.0
6
- #
7
- # Licensed under the Apache License, Version 2.0 (the "License");
8
- # you may not use this file except in compliance with the License.
9
- # You may obtain a copy of the License at
10
- #
11
- # http://www.apache.org/licenses/LICENSE-2.0
12
- #
13
- # Unless required by applicable law or agreed to in writing, software
14
- # distributed under the License is distributed on an "AS IS" BASIS,
15
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- # See the License for the specific language governing permissions and
17
- # limitations under the License.
18
- #
19
- ################################################################################
20
- require "erubis"
1
+ require 'erubis'
21
2
 
22
3
  module ZTK
23
4
 
24
- # ZTK::Template Error Class
5
+ # Template Error Class
25
6
  #
26
- # @author Zachary Patten <zachary@jovelabs.net>
7
+ # @author Zachary Patten <zachary AT jovelabs DOT com>
27
8
  class TemplateError < Error; end
28
9
 
29
10
  # Erubis Templating Class
@@ -42,7 +23,7 @@ module ZTK
42
23
  # This is a test template!
43
24
  # Hello World
44
25
  #
45
- # @author Zachary Patten <zachary@jovelabs.net>
26
+ # @author Zachary Patten <zachary AT jovelabs DOT com>
46
27
  class Template
47
28
 
48
29
  class << self
data/lib/ztk/ui.rb CHANGED
@@ -1,38 +1,18 @@
1
- ################################################################################
2
- #
3
- # Author: Zachary Patten <zachary@jovelabs.net>
4
- # Copyright: Copyright (c) Zachary Patten
5
- # License: Apache License, VersIOn 2.0
6
- #
7
- # Licensed under the Apache License, VersIOn 2.0 (the "License");
8
- # you may not use this file except in compliance with the License.
9
- # You may obtain a copy of the License at
10
- #
11
- # http://www.apache.org/licenses/LICENSE-2.0
12
- #
13
- # Unless required by applicable law or agreed to in writing, software
14
- # distributed under the License is distributed on an "AS IS" BASIS,
15
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- # See the License for the specific language governing permissIOns and
17
- # limitatIOns under the License.
18
- #
19
- ################################################################################
20
-
21
- require "base64"
1
+ require 'base64'
22
2
 
23
3
  module ZTK
24
4
 
25
- # ZTK::UI Error Class
5
+ # UI Error Class
26
6
  #
27
- # @author Zachary Patten <zachary@jovelabs.net>
7
+ # @author Zachary Patten <zachary AT jovelabs DOT com>
28
8
  class UIError < Error; end
29
9
 
30
- # ZTK UI Class
10
+ # UI Class
31
11
  #
32
12
  # This class encapsulates a STDOUT, STDERR, STDIN
33
13
  # and logging device.
34
14
  #
35
- # @author Zachary Patten <zachary@jovelabs.net>
15
+ # @author Zachary Patten <zachary AT jovelabs DOT com>
36
16
  class UI < ZTK::Base
37
17
 
38
18
  attr_accessor :stdout, :stderr, :stdin, :logger
data/lib/ztk/version.rb CHANGED
@@ -1,26 +1,6 @@
1
- ################################################################################
2
- #
3
- # Author: Zachary Patten <zachary@jovelabs.net>
4
- # Copyright: Copyright (c) Zachary Patten
5
- # License: Apache License, Version 2.0
6
- #
7
- # Licensed under the Apache License, Version 2.0 (the "License");
8
- # you may not use this file except in compliance with the License.
9
- # You may obtain a copy of the License at
10
- #
11
- # http://www.apache.org/licenses/LICENSE-2.0
12
- #
13
- # Unless required by applicable law or agreed to in writing, software
14
- # distributed under the License is distributed on an "AS IS" BASIS,
15
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- # See the License for the specific language governing permissions and
17
- # limitations under the License.
18
- #
19
- ################################################################################
20
-
21
1
  module ZTK
22
2
 
23
3
  # ZTK Version String
24
- VERSION = "1.4.4"
4
+ VERSION = "1.4.5"
25
5
 
26
6
  end
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  ################################################################################
2
2
  #
3
- # Author: Zachary Patten <zachary@jovelabs.net>
3
+ # Author: Zachary Patten <zachary AT jovelabs DOT com>
4
4
  # Copyright: Copyright (c) Zachary Patten
5
5
  # License: Apache License, Version 2.0
6
6
  #
@@ -1,6 +1,6 @@
1
1
  ################################################################################
2
2
  #
3
- # Author: Zachary Patten <zachary@jovelabs.net>
3
+ # Author: Zachary Patten <zachary AT jovelabs DOT com>
4
4
  # Copyright: Copyright (c) Zachary Patten
5
5
  # License: Apache License, Version 2.0
6
6
  #
@@ -1,6 +1,6 @@
1
1
  ################################################################################
2
2
  #
3
- # Author: Zachary Patten <zachary@jovelabs.net>
3
+ # Author: Zachary Patten <zachary AT jovelabs DOT com>
4
4
  # Copyright: Copyright (c) Zachary Patten
5
5
  # License: Apache License, Version 2.0
6
6
  #
@@ -1,6 +1,6 @@
1
1
  ################################################################################
2
2
  #
3
- # Author: Zachary Patten <zachary@jovelabs.net>
3
+ # Author: Zachary Patten <zachary AT jovelabs DOT com>
4
4
  # Copyright: Copyright (c) Zachary Patten
5
5
  # License: Apache License, Version 2.0
6
6
  #
@@ -1,6 +1,6 @@
1
1
  ################################################################################
2
2
  #
3
- # Author: Zachary Patten <zachary@jovelabs.net>
3
+ # Author: Zachary Patten <zachary AT jovelabs DOT com>
4
4
  # Copyright: Copyright (c) Zachary Patten
5
5
  # License: Apache License, Version 2.0
6
6
  #
@@ -1,6 +1,6 @@
1
1
  ################################################################################
2
2
  #
3
- # Author: Zachary Patten <zachary@jovelabs.net>
3
+ # Author: Zachary Patten <zachary AT jovelabs DOT com>
4
4
  # Copyright: Copyright (c) Zachary Patten
5
5
  # License: Apache License, Version 2.0
6
6
  #
data/spec/ztk/dsl_spec.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  ################################################################################
2
2
  #
3
- # Author: Zachary Patten <zachary@jovelabs.net>
3
+ # Author: Zachary Patten <zachary AT jovelabs DOT com>
4
4
  # Copyright: Copyright (c) Zachary Patten
5
5
  # License: Apache License, Version 2.0
6
6
  #
@@ -1,6 +1,6 @@
1
1
  ################################################################################
2
2
  #
3
- # Author: Zachary Patten <zachary@jovelabs.net>
3
+ # Author: Zachary Patten <zachary AT jovelabs DOT com>
4
4
  # Copyright: Copyright (c) Zachary Patten
5
5
  # License: Apache License, Version 2.0
6
6
  #
@@ -1,6 +1,6 @@
1
1
  ################################################################################
2
2
  #
3
- # Author: Zachary Patten <zachary@jovelabs.net>
3
+ # Author: Zachary Patten <zachary AT jovelabs DOT com>
4
4
  # Copyright: Copyright (c) Zachary Patten
5
5
  # License: Apache License, Version 2.0
6
6
  #
@@ -1,6 +1,6 @@
1
1
  ################################################################################
2
2
  #
3
- # Author: Zachary Patten <zachary@jovelabs.net>
3
+ # Author: Zachary Patten <zachary AT jovelabs DOT com>
4
4
  # Copyright: Copyright (c) Zachary Patten
5
5
  # License: Apache License, Version 2.0
6
6
  #
data/spec/ztk/pty_spec.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  ################################################################################
2
2
  #
3
- # Author: Zachary Patten <zachary@jovelabs.net>
3
+ # Author: Zachary Patten <zachary AT jovelabs DOT com>
4
4
  # Copyright: Copyright (c) Zachary Patten
5
5
  # License: Apache License, Version 2.0
6
6
  #