ztk 1.15.0 → 1.15.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/README.md +18 -2
- data/lib/ztk/background.rb +1 -3
- data/lib/ztk/base.rb +23 -29
- data/lib/ztk/benchmark.rb +2 -3
- data/lib/ztk/command.rb +1 -3
- data/lib/ztk/parallel.rb +1 -2
- data/lib/ztk/report.rb +1 -4
- data/lib/ztk/rescue_retry.rb +1 -2
- data/lib/ztk/spinner.rb +1 -2
- data/lib/ztk/ssh.rb +1 -3
- data/lib/ztk/tcp_socket_check.rb +1 -2
- data/lib/ztk/version.rb +1 -1
- data/ztk.gemspec +21 -2
- metadata +61 -4
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NzNiOWIzNTcwMDQ2NTgyN2JkM2JkNDFmZmE3OTUwZWIzMzExYWM1MQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YzllMGFkNmZlMTQyZTc3YzEyMTdiYTcwZGJmNzAwNTEwZDY5NjgzOQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZGRhZTJkMGU3M2JkOTYwZWIzODgyYzFmNTQ3MTY0MDQ2OGY0MmFjNGFjOGEz
|
10
|
+
ODZlMTYwNTZmOTdmMDRhZWFhN2MxNTlhMWI5MTA3ZjdhZjQ2YzFhYTIyOGMw
|
11
|
+
ZTE0ZjY5YmM3NTM3MTM4ODE1MDBjZWIyYmVjMjc2Mzc5NWZkYzU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NGYwNDRjNWVjNThmYjcyNDQyMmQyZDc2OWEzOWRkNmJhZGYwNmZkNzk3YjMy
|
14
|
+
YjQxZTBiOTRhZWE0OTJlNWYwZTI1OGI0NTA0MDdkMThhMTZjNDFjMjE5YjAz
|
15
|
+
MzdhZTE4YzVjODI2MjBjYTk5OWY0MDEzZWExZDc5ZDI5NWM2ZmI=
|
data/README.md
CHANGED
@@ -6,7 +6,23 @@
|
|
6
6
|
|
7
7
|
# ZTK
|
8
8
|
|
9
|
-
Zachary's
|
9
|
+
Zachary's Tool Kit is a general purpose utility gem, featuring a collection of classes meant to simplify development of complex systems in Ruby.
|
10
|
+
|
11
|
+
- **ZTK::Background**
|
12
|
+
|
13
|
+
Easily turn most iterative tasks into a parallel processes and easily leverage multiple cores to speed up processing large sets of data.
|
14
|
+
|
15
|
+
- **ZTK::DSL**
|
16
|
+
|
17
|
+
Create your own DSL in seconds by inheriting this DSL class. Featuring ActiveRecord style associations where DSL objects can `belong_to` or `has_many` other DSL objects.
|
18
|
+
|
19
|
+
- **ZTK::Logger**
|
20
|
+
|
21
|
+
Based off the core Ruby logger, this is meant to be a drop in replacement. Features added logging information, including PID, uSec time resolution, method and line numbers of logging statements (i.e. the caller). One can seamlessly chain Ruby loggers using ZTK:Logger, for example to output logs to both STDOUT and a log file on disk at the same time; all while maintaining compatibility with the core Ruby logger.
|
22
|
+
|
23
|
+
- **ZTK::SSH**
|
24
|
+
|
25
|
+
An SSH class that nicely wraps up all of the SSH gems into a nice uniform interface, complete with transfer progress callbacks. It is meant to function as a drop in replacement, but I admit this has not been heavily tested like in the case of the ZTK::Logger class. It provides the ability to switch between SCP and SFTP for file transfers seamlessly. Full SSH proxy support as well, plus methods to spawn up interactive SSH consoles via `Kernel.exec`.
|
10
26
|
|
11
27
|
# RUBIES TESTED AGAINST
|
12
28
|
|
@@ -36,7 +52,7 @@ Issues:
|
|
36
52
|
|
37
53
|
# LICENSE
|
38
54
|
|
39
|
-
ZTK - Zachary's
|
55
|
+
ZTK - Zachary's Tool Kit
|
40
56
|
|
41
57
|
* Author: Zachary Patten <zachary AT jovelabs DOT com> [![endorse](http://api.coderwall.com/zpatten/endorsecount.png)](http://coderwall.com/zpatten)
|
42
58
|
* Copyright: Copyright (c) Zachary Patten
|
data/lib/ztk/background.rb
CHANGED
@@ -89,9 +89,7 @@ module ZTK
|
|
89
89
|
# @param [Hash] configuration Configuration options hash.
|
90
90
|
#
|
91
91
|
def initialize(configuration={})
|
92
|
-
super(
|
93
|
-
}.merge(configuration))
|
94
|
-
config.ui.logger.debug { "config=#{config.send(:table).inspect}" }
|
92
|
+
super(configuration)
|
95
93
|
|
96
94
|
@result = nil
|
97
95
|
GC.respond_to?(:copy_on_write_friendly=) and GC.copy_on_write_friendly = true
|
data/lib/ztk/base.rb
CHANGED
@@ -21,37 +21,34 @@ module ZTK
|
|
21
21
|
|
22
22
|
class << self
|
23
23
|
|
24
|
-
#
|
24
|
+
# Builds Configuration Object
|
25
|
+
#
|
26
|
+
# Builds an OpenStruct backed configuration object.
|
27
|
+
#
|
28
|
+
# @param [Hash] config Configuration options hash.
|
25
29
|
# @option config [ZTK::UI] :ui Instance of ZTK:UI to be used for
|
26
30
|
# console IO and logging.
|
27
|
-
|
28
|
-
|
29
|
-
configuration = configuration.send(:table)
|
30
|
-
end
|
31
|
-
|
32
|
-
# FIXME: this needs to be refactored into the UI class
|
31
|
+
# @param [Hash] override Override configuration hash.
|
32
|
+
def build_config(config={}, override={})
|
33
33
|
config = OpenStruct.new({
|
34
34
|
:ui => ::ZTK::UI.new
|
35
|
-
}.merge(
|
35
|
+
}.merge(hash_config(config)).merge(hash_config(override)))
|
36
|
+
|
37
|
+
config.ui.logger.debug { "config=#{config.send(:table).inspect}" }
|
36
38
|
|
37
39
|
config
|
38
40
|
end
|
39
41
|
|
40
|
-
#
|
41
|
-
# into classes they are not meant for.
|
42
|
+
# Hash Configuration
|
42
43
|
#
|
43
|
-
#
|
44
|
-
#
|
45
|
-
def
|
46
|
-
if
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
config = configuration.reject do |key,value|
|
51
|
-
!(%w(stdout stderr stdin logger).map(&:to_sym).include?(key))
|
44
|
+
# Ensure a configuration is of object type Hash. Since we use OpenStructs
|
45
|
+
# we need to convert back to hash from time to time.
|
46
|
+
def hash_config(config={})
|
47
|
+
if config.is_a?(OpenStruct)
|
48
|
+
config.send(:table)
|
49
|
+
else
|
50
|
+
config
|
52
51
|
end
|
53
|
-
|
54
|
-
config
|
55
52
|
end
|
56
53
|
|
57
54
|
# Logs an exception and then raises it.
|
@@ -73,13 +70,10 @@ module ZTK
|
|
73
70
|
|
74
71
|
end
|
75
72
|
|
76
|
-
# @param [Hash] config
|
77
|
-
# @
|
78
|
-
|
79
|
-
|
80
|
-
# @option config [Logger] :logger Instance of Logger to be used for logging.
|
81
|
-
def initialize(config={})
|
82
|
-
@config = Base.build_config(config)
|
73
|
+
# @param [Hash] config Initial configuration hash.
|
74
|
+
# @param [Hash] override Override configuration hash.
|
75
|
+
def initialize(config={}, override={})
|
76
|
+
@config = Base.build_config(config, override)
|
83
77
|
end
|
84
78
|
|
85
79
|
# Configuration OpenStruct accessor method.
|
@@ -127,7 +121,7 @@ module ZTK
|
|
127
121
|
|
128
122
|
if !block_given?
|
129
123
|
log_and_raise(BaseError, "You must supply a block to the log method!")
|
130
|
-
elsif (@config.ui.logger.level <=
|
124
|
+
elsif (@config.ui.logger.level <= ::Logger.const_get(log_level.to_s.upcase))
|
131
125
|
@config.ui.logger << ZTK::ANSI.uncolor(yield)
|
132
126
|
end
|
133
127
|
end
|
data/lib/ztk/benchmark.rb
CHANGED
@@ -72,8 +72,7 @@ module ZTK
|
|
72
72
|
def bench(options={}, &block)
|
73
73
|
options = Base.build_config({
|
74
74
|
:use_spinner => true
|
75
|
-
}
|
76
|
-
options.ui.logger.debug { "options=#{options.send(:table).inspect}" }
|
75
|
+
}, options)
|
77
76
|
|
78
77
|
!block_given? and Base.log_and_raise(options.ui.logger, BenchmarkError, "You must supply a block!")
|
79
78
|
|
@@ -84,7 +83,7 @@ module ZTK
|
|
84
83
|
benchmark = ::Benchmark.realtime do
|
85
84
|
if (options.message && options.mark)
|
86
85
|
if options.use_spinner
|
87
|
-
ZTK::Spinner.spin(
|
86
|
+
ZTK::Spinner.spin(options) do
|
88
87
|
yield
|
89
88
|
end
|
90
89
|
else
|
data/lib/ztk/command.rb
CHANGED
data/lib/ztk/parallel.rb
CHANGED
@@ -122,8 +122,7 @@ module ZTK
|
|
122
122
|
def initialize(configuration={})
|
123
123
|
super({
|
124
124
|
:max_forks => MAX_FORKS
|
125
|
-
}
|
126
|
-
config.ui.logger.debug { "config=#{config.send(:table).inspect}" }
|
125
|
+
}, configuration)
|
127
126
|
|
128
127
|
(config.max_forks < 1) and log_and_raise(ParallelError, "max_forks must be equal to or greater than one!")
|
129
128
|
|
data/lib/ztk/report.rb
CHANGED
@@ -28,10 +28,7 @@ module ZTK
|
|
28
28
|
|
29
29
|
# @param [Hash] configuration Configuration options hash.
|
30
30
|
def initialize(configuration={})
|
31
|
-
super(
|
32
|
-
}.merge(configuration))
|
33
|
-
|
34
|
-
config.ui.logger.debug { "config=#{config.send(:table).inspect}" }
|
31
|
+
super(configuration)
|
35
32
|
end
|
36
33
|
|
37
34
|
|
data/lib/ztk/rescue_retry.rb
CHANGED
@@ -109,8 +109,7 @@ module ZTK
|
|
109
109
|
:on => Exception,
|
110
110
|
:delay => 1,
|
111
111
|
:raise => nil
|
112
|
-
}
|
113
|
-
options.ui.logger.debug { "options=#{options.send(:table).inspect}" }
|
112
|
+
}, options)
|
114
113
|
|
115
114
|
!block_given? and Base.log_and_raise(options.ui.logger, RescueRetryError, "You must supply a block!")
|
116
115
|
|
data/lib/ztk/spinner.rb
CHANGED
@@ -40,8 +40,7 @@ module ZTK
|
|
40
40
|
def spin(options={}, &block)
|
41
41
|
options = Base.build_config({
|
42
42
|
:step => 0.1
|
43
|
-
}
|
44
|
-
options.ui.logger.debug { "options(#{options.send(:table).inspect})" }
|
43
|
+
}, options)
|
45
44
|
|
46
45
|
!block_given? and Base.log_and_raise(options.ui.logger, SpinnerError, "You must supply a block!")
|
47
46
|
|
data/lib/ztk/ssh.rb
CHANGED
data/lib/ztk/tcp_socket_check.rb
CHANGED
data/lib/ztk/version.rb
CHANGED
data/ztk.gemspec
CHANGED
@@ -26,8 +26,26 @@ Gem::Specification.new do |spec|
|
|
26
26
|
spec.version = ZTK::VERSION
|
27
27
|
spec.authors = ["Zachary Patten"]
|
28
28
|
spec.email = ["zachary AT jovelabs DOT com"]
|
29
|
-
spec.description =
|
30
|
-
|
29
|
+
spec.description = <<-EOTEXT
|
30
|
+
Zachary's Tool Kit is a general purpose utility gem, featuring a collection of classes meant to simplify development of complex systems in Ruby.
|
31
|
+
|
32
|
+
ZTK::Background
|
33
|
+
===============
|
34
|
+
Easily turn most iterative tasks into a parallel processes and easily leverage multiple cores to speed up processing large sets of data.
|
35
|
+
|
36
|
+
ZTK::DSL
|
37
|
+
========
|
38
|
+
Create your own DSL in seconds by inheriting this DSL class. Featuring ActiveRecord style associations where DSL objects can `belong_to` or `has_many` other DSL objects.
|
39
|
+
|
40
|
+
ZTK::Logger
|
41
|
+
===========
|
42
|
+
Based off the core Ruby logger, this is meant to be a drop in replacement. Features added logging information, including PID, uSec time resolution, method and line numbers of logging statements (i.e. the caller). One can seamlessly chain Ruby loggers using ZTK:Logger, for example to output logs to both STDOUT and a log file on disk at the same time; all while maintaining compatibility with the core Ruby logger.
|
43
|
+
|
44
|
+
ZTK::SSH
|
45
|
+
========
|
46
|
+
An SSH class that nicely wraps up all of the SSH gems into a nice uniform interface, complete with transfer progress callbacks. It is meant to function as a drop in replacement, but I admit this has not been heavily tested like in the case of the ZTK::Logger class. It provides the ability to switch between SCP and SFTP for file transfers seamlessly. Full SSH proxy support as well, plus methods to spawn up interactive SSH consoles via `Kernel.exec`.
|
47
|
+
EOTEXT
|
48
|
+
spec.summary = %q{Zachary's Tool Kit}
|
31
49
|
spec.homepage = "https://github.com/zpatten/ztk"
|
32
50
|
spec.license = "Apache 2.0"
|
33
51
|
|
@@ -49,4 +67,5 @@ Gem::Specification.new do |spec|
|
|
49
67
|
spec.add_development_dependency("yard")
|
50
68
|
spec.add_development_dependency("redcarpet")
|
51
69
|
spec.add_development_dependency("coveralls")
|
70
|
+
spec.add_development_dependency("travis")
|
52
71
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ztk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.15.
|
4
|
+
version: 1.15.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zachary Patten
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -178,7 +178,64 @@ dependencies:
|
|
178
178
|
- - ! '>='
|
179
179
|
- !ruby/object:Gem::Version
|
180
180
|
version: '0'
|
181
|
-
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: travis
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - ! '>='
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '0'
|
188
|
+
type: :development
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - ! '>='
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '0'
|
195
|
+
description: ! 'Zachary''s Tool Kit is a general purpose utility gem, featuring a
|
196
|
+
collection of classes meant to simplify development of complex systems in Ruby.
|
197
|
+
|
198
|
+
|
199
|
+
ZTK::Background
|
200
|
+
|
201
|
+
===============
|
202
|
+
|
203
|
+
Easily turn most iterative tasks into a parallel processes and easily leverage multiple
|
204
|
+
cores to speed up processing large sets of data.
|
205
|
+
|
206
|
+
|
207
|
+
ZTK::DSL
|
208
|
+
|
209
|
+
========
|
210
|
+
|
211
|
+
Create your own DSL in seconds by inheriting this DSL class. Featuring ActiveRecord
|
212
|
+
style associations where DSL objects can `belong_to` or `has_many` other DSL objects.
|
213
|
+
|
214
|
+
|
215
|
+
ZTK::Logger
|
216
|
+
|
217
|
+
===========
|
218
|
+
|
219
|
+
Based off the core Ruby logger, this is meant to be a drop in replacement. Features
|
220
|
+
added logging information, including PID, uSec time resolution, method and line
|
221
|
+
numbers of logging statements (i.e. the caller). One can seamlessly chain Ruby
|
222
|
+
loggers using ZTK:Logger, for example to output logs to both STDOUT and a log file
|
223
|
+
on disk at the same time; all while maintaining compatibility with the core Ruby
|
224
|
+
logger.
|
225
|
+
|
226
|
+
|
227
|
+
ZTK::SSH
|
228
|
+
|
229
|
+
========
|
230
|
+
|
231
|
+
An SSH class that nicely wraps up all of the SSH gems into a nice uniform interface,
|
232
|
+
complete with transfer progress callbacks. It is meant to function as a drop in
|
233
|
+
replacement, but I admit this has not been heavily tested like in the case of the
|
234
|
+
ZTK::Logger class. It provides the ability to switch between SCP and SFTP for file
|
235
|
+
transfers seamlessly. Full SSH proxy support as well, plus methods to spawn up
|
236
|
+
interactive SSH consoles via `Kernel.exec`.
|
237
|
+
|
238
|
+
'
|
182
239
|
email:
|
183
240
|
- zachary AT jovelabs DOT com
|
184
241
|
executables:
|
@@ -291,7 +348,7 @@ rubyforge_project:
|
|
291
348
|
rubygems_version: 2.1.11
|
292
349
|
signing_key:
|
293
350
|
specification_version: 4
|
294
|
-
summary: Zachary's
|
351
|
+
summary: Zachary's Tool Kit
|
295
352
|
test_files:
|
296
353
|
- spec/spec_helper.rb
|
297
354
|
- spec/support/before_install.sh
|