ztk 0.1.0 → 0.1.1

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/lib/ztk/base.rb CHANGED
@@ -89,6 +89,16 @@ module ZTK
89
89
  end
90
90
  end
91
91
 
92
+ def direct_log(log_level, &blocK)
93
+ @config.logger.nil? and raise BaseError, "You must supply a logger for direct logging support!"
94
+
95
+ if !block_given?
96
+ raise BaseError, "You must supply a block to the log method!"
97
+ elsif (@config.logger.level == ZTK::Logger.const_get(log_level.to_s.upcase))
98
+ @config.logger and @config.logger.instance_variable_get(:@logdev).instance_variable_get(:@dev).write(yield)
99
+ end
100
+ end
101
+
92
102
  end
93
103
 
94
104
  end
data/lib/ztk/ssh.rb CHANGED
@@ -109,6 +109,12 @@ module ZTK
109
109
  }.merge(config))
110
110
  end
111
111
 
112
+ def inspect
113
+ user_host = "#{@config.user}@#{@config.host_name}"
114
+ port = (@config.port ? ":#{@config.port}" : nil)
115
+ [user_host, port].compact.join
116
+ end
117
+
112
118
  # Starts an SSH session. Can also be used to get the Net::SSH object.
113
119
  #
114
120
  # Primarily used internally.
@@ -182,13 +188,13 @@ module ZTK
182
188
  raise SSHError, "Could not execute '#{command}'." unless success
183
189
 
184
190
  ch.on_data do |c, data|
185
- log(:debug) { data.chomp.strip }
191
+ direct_log(:debug) { "[#{self.inspect}] #{data}" }
186
192
  @config.stdout.print(data) unless options.silence
187
193
  output += data.chomp.strip
188
194
  end
189
195
 
190
196
  ch.on_extended_data do |c, type, data|
191
- log(:debug) { data.chomp.strip }
197
+ direct_log(:debug) { "[#{self.inspect}] #{data}" }
192
198
  @config.stderr.print(data) unless options.silence
193
199
  output += data.chomp.strip
194
200
  end
data/lib/ztk/version.rb CHANGED
@@ -19,5 +19,5 @@
19
19
  ################################################################################
20
20
 
21
21
  module ZTK
22
- VERSION = "0.1.0" unless const_defined?(:VERSION)
22
+ VERSION = "0.1.1" unless const_defined?(:VERSION)
23
23
  end
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.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -207,12 +207,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
207
207
  - - ! '>='
208
208
  - !ruby/object:Gem::Version
209
209
  version: '0'
210
+ segments:
211
+ - 0
212
+ hash: -4401933246613250209
210
213
  required_rubygems_version: !ruby/object:Gem::Requirement
211
214
  none: false
212
215
  requirements:
213
216
  - - ! '>='
214
217
  - !ruby/object:Gem::Version
215
218
  version: '0'
219
+ segments:
220
+ - 0
221
+ hash: -4401933246613250209
216
222
  requirements: []
217
223
  rubyforge_project:
218
224
  rubygems_version: 1.8.24
@@ -230,3 +236,4 @@ test_files:
230
236
  - spec/ztk/ssh_spec.rb
231
237
  - spec/ztk/tcp_socket_check_spec.rb
232
238
  - spec/ztk/template_spec.rb
239
+ has_rdoc: