ztk 1.0.0.rc.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -21,7 +21,7 @@ require "base64"
21
21
 
22
22
  module ZTK
23
23
 
24
- # ZTK::Background Error Class
24
+ # ZTK::Background General Error Class
25
25
  #
26
26
  # @author Zachary Patten <zachary@jovelabs.net>
27
27
  class BackgroundError < Error; end
@@ -106,6 +106,7 @@ module ZTK
106
106
  attr_accessor :pid, :result
107
107
 
108
108
  # @param [Hash] configuration Configuration options hash.
109
+ #
109
110
  def initialize(configuration={})
110
111
  super({
111
112
  }.merge(configuration))
@@ -121,6 +122,7 @@ module ZTK
121
122
  # @yieldreturn [Object] Block can return any object to be marshalled back to
122
123
  # the parent processes.
123
124
  # @return [Integer] Returns the pid of the child process forked.
125
+ #
124
126
  def process(&block)
125
127
  !block_given? and log_and_raise(BackgroundError, "You must supply a block to the process method!")
126
128
 
@@ -167,6 +169,7 @@ module ZTK
167
169
  # @return [Array<pid, status, data>] An array containing the pid,
168
170
  # status and data returned from the process block. If wait2() fails nil
169
171
  # is returned.
172
+ #
170
173
  def wait
171
174
  config.ui.logger.debug { "wait" }
172
175
  pid, status = (Process.wait2(@pid) rescue nil)
data/lib/ztk/base.rb CHANGED
@@ -21,7 +21,7 @@ require "ostruct"
21
21
 
22
22
  module ZTK
23
23
 
24
- # ZTK::Base Error Class
24
+ # ZTK::Base General Error Class
25
25
  #
26
26
  # @author Zachary Patten <zachary@jovelabs.net>
27
27
  class BaseError < Error; end
data/lib/ztk/benchmark.rb CHANGED
@@ -21,7 +21,7 @@ require 'benchmark'
21
21
 
22
22
  module ZTK
23
23
 
24
- # ZTK::Benchmark Error Class
24
+ # ZTK::Benchmark General Error Class
25
25
  #
26
26
  # @author Zachary Patten <zachary@jovelabs.net>
27
27
  class BenchmarkError < Error; end
@@ -87,6 +87,7 @@ module ZTK
87
87
  # @yield Block should execute the tasks to be benchmarked.
88
88
  # @yieldreturn [Object] The return value of the block is ignored.
89
89
  # @return [Float] The benchmark time.
90
+ #
90
91
  def bench(options={}, &block)
91
92
  options = Base.build_config({
92
93
  :use_spinner => true
data/lib/ztk/command.rb CHANGED
@@ -23,7 +23,6 @@ require "timeout"
23
23
  module ZTK
24
24
 
25
25
  # ZTK::Command Error Class
26
- #
27
26
  # @author Zachary Patten <zachary@jovelabs.net>
28
27
  class CommandError < Error; end
29
28
 
@@ -36,7 +35,8 @@ module ZTK
36
35
  # If we wanted to redirect STDOUT and STDERR to a StringIO we can do this:
37
36
  #
38
37
  # std_combo = StringIO.new
39
- # cmd = ZTK::Command.new(:stdout => std_combo, :stderr => std_combo)
38
+ # ui = ZTK::UI.new(:stdout => std_combo, :stderr => std_combo)
39
+ # cmd = ZTK::Command.new(:ui => ui)
40
40
  #
41
41
  # @author Zachary Patten <zachary@jovelabs.net>
42
42
  class Command < ZTK::Base
@@ -62,6 +62,7 @@ module ZTK
62
62
  #
63
63
  # cmd = ZTK::Command.new
64
64
  # puts cmd.exec("hostname -f").inspect
65
+ #
65
66
  def exec(command, options={})
66
67
  options = OpenStruct.new({ :exit_code => 0, :silence => false }.merge(options))
67
68
 
@@ -175,11 +176,15 @@ module ZTK
175
176
 
176
177
  private
177
178
 
179
+ # Returns a string in the format of "user@hostname" for the current
180
+ # shell.
178
181
  def tag
179
182
  @hostname ||= %x(hostname -f).chomp
180
183
  "#{ENV['USER']}@#{@hostname}"
181
184
  end
182
185
 
186
+ # Formats a header suitable for writing to the direct logger when logging
187
+ # sessions.
183
188
  def log_header(what)
184
189
  count = 8
185
190
  sep = ("=" * count)
data/lib/ztk/config.rb CHANGED
@@ -21,7 +21,7 @@ require 'ostruct'
21
21
 
22
22
  module ZTK
23
23
 
24
- # ZTK::Config Error Class
24
+ # ZTK::Config General Error Class
25
25
  #
26
26
  # @author Zachary Patten <zachary@jovelabs.net>
27
27
  class ConfigError < Error; end
@@ -69,6 +69,7 @@ module ZTK
69
69
  #
70
70
  # This will add the *configuration* attribute to the base class and create
71
71
  # a new *OpenStruct* object assigning it to the *configuration* attribute.
72
+ #
72
73
  def self.extended(base)
73
74
  class << base
74
75
  attr_accessor :configuration
@@ -78,14 +79,16 @@ module ZTK
78
79
  end
79
80
 
80
81
  # Loads a configuration from a file.
82
+ #
81
83
  def from_file(filename)
82
- self.instance_eval(IO.read(filename), filename, 1)
84
+ self.instance_eval(IO.read(filename), filename)
83
85
  end
84
86
 
85
87
  # Yields the configuration OpenStruct object to a block.
86
88
  #
87
89
  # @yield [configuration] Pass the configuration OpenStruct object to the
88
90
  # specified block.
91
+ #
89
92
  def config(&block)
90
93
  block and block.call(self.configuration)
91
94
  end
@@ -96,6 +99,7 @@ module ZTK
96
99
  # key to return.
97
100
  #
98
101
  # @return The value currently assigned to the configuration key.
102
+ #
99
103
  def [](key)
100
104
  _get(key)
101
105
  end
@@ -108,31 +112,37 @@ module ZTK
108
112
  # key.
109
113
  #
110
114
  # @return The value assigned to the configuration key.
115
+ #
111
116
  def []=(key, value)
112
117
  _set(key, value)
113
118
  end
114
119
 
115
120
  # @see Hash#keys
121
+ #
116
122
  def keys
117
123
  self.configuration.send(:table).keys
118
124
  end
119
125
 
120
126
  # @see Hash#has_key?
127
+ #
121
128
  def has_key?(key)
122
129
  self.configuration.send(:table).has_key?(key)
123
130
  end
124
131
 
125
132
  # @see Hash#merge
133
+ #
126
134
  def merge(hash)
127
135
  self.configuration.send(:table).merge(hash)
128
136
  end
129
137
 
130
138
  # @see Hash#merge!
139
+ #
131
140
  def merge!(hash)
132
141
  self.configuration.send(:table).merge!(hash)
133
142
  end
134
143
 
135
144
  # Handles method calls for our configuration keys.
145
+ #
136
146
  def method_missing(method_symbol, *method_args)
137
147
  if method_args.length > 0
138
148
  _set(method_symbol, method_args.first)
data/lib/ztk/ssh.rb CHANGED
@@ -38,7 +38,8 @@ module ZTK
38
38
  # If we wanted to redirect STDOUT and STDERR to a StringIO we can do this:
39
39
  #
40
40
  # std_combo = StringIO.new
41
- # ssh = ZTK::SSH.new(:stdout => std_combo, :stderr => std_combo)
41
+ # ui = ZTK::UI.new(:stdout => std_combo, :stderr => std_combo)
42
+ # ssh = ZTK::SSH.new(:ui => ui)
42
43
  #
43
44
  # If you want to specify SSH options you can:
44
45
  #
data/lib/ztk/version.rb CHANGED
@@ -21,6 +21,6 @@
21
21
  module ZTK
22
22
 
23
23
  # ZTK Version String
24
- VERSION = "1.0.0.rc.1"
24
+ VERSION = "1.0.0"
25
25
 
26
26
  end
metadata CHANGED
@@ -1,8 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ztk
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.rc.1
5
- prerelease: 6
4
+ version: 1.0.0
5
+ prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - Zachary Patten
@@ -250,13 +250,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
250
250
  version: '0'
251
251
  segments:
252
252
  - 0
253
- hash: -276404012806695172
253
+ hash: 3551649041852268044
254
254
  required_rubygems_version: !ruby/object:Gem::Requirement
255
255
  none: false
256
256
  requirements:
257
- - - ! '>'
257
+ - - ! '>='
258
258
  - !ruby/object:Gem::Version
259
- version: 1.3.1
259
+ version: '0'
260
+ segments:
261
+ - 0
262
+ hash: 3551649041852268044
260
263
  requirements: []
261
264
  rubyforge_project:
262
265
  rubygems_version: 1.8.24