ztk 3.2.0 → 3.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/README.md +25 -1
- data/lib/ztk/dsl/base.rb +1 -54
- data/lib/ztk/parallel.rb +2 -3
- data/lib/ztk/version.rb +1 -1
- data/spec/spec_helper.rb +10 -12
- data/ztk.gemspec +19 -19
- metadata +16 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e082c8f8eb50ec7a075755f019c3ba11c09b55f1
|
4
|
+
data.tar.gz: 8ed941fc634889a8eea5fb745cf8e37a00f7987c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2fe1079bcf4128bfd605cfe56e4d67cbd1f6e322179cf6ef5457a137a6fa92cd9a43854a5d830b84908721ce49d9d9e329f19d9a2f9ca4979f1d0510584cfb9c
|
7
|
+
data.tar.gz: 654d085829e7fa7ffa5b0c408311cf80dcbb0302538b286f5aee0d64ea027edee65d3f213951948c5c805f70ad9ebf946961699f2cd3fa33326cbd8c7acf08e5
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
[![Gem Version](https://badge.fury.io/rb/ztk.png)](http://badge.fury.io/rb/ztk)
|
2
2
|
[![Build Status](https://secure.travis-ci.org/zpatten/ztk.png)](http://travis-ci.org/zpatten/ztk)
|
3
|
-
[![Coverage Status](https://coveralls.io/repos/zpatten/ztk/badge.png?branch=master)](https://coveralls.io/
|
3
|
+
[![Coverage Status](https://coveralls.io/repos/github/zpatten/ztk/badge.png?branch=master)](https://coveralls.io/github/zpatten/ztk?branch=master)
|
4
4
|
[![Dependency Status](https://gemnasium.com/zpatten/ztk.png)](https://gemnasium.com/zpatten/ztk)
|
5
5
|
[![Code Climate](https://codeclimate.com/github/zpatten/ztk.png)](https://codeclimate.com/github/zpatten/ztk)
|
6
6
|
|
@@ -8,6 +8,26 @@
|
|
8
8
|
|
9
9
|
Zachary's Tool Kit contains a collection of reusable classes meant to simplify development of complex systems in Ruby. These classes provide functionality I often find myself needing from project to project. Instead of reinventing the wheel each time, I've started building a collection of reusable classes. Easy-bake DSLs, parallel processing, complex logging, templating and many other useful design patterns, for example are all contained in simple, reusable classes with a common interface and configuration style.
|
10
10
|
|
11
|
+
## INSTALLATION
|
12
|
+
|
13
|
+
Add this line to your application's Gemfile:
|
14
|
+
|
15
|
+
gem 'ztk'
|
16
|
+
|
17
|
+
And then execute:
|
18
|
+
|
19
|
+
$ bundle
|
20
|
+
|
21
|
+
Or install it yourself as:
|
22
|
+
|
23
|
+
$ gem install ztk
|
24
|
+
|
25
|
+
Then run the pry console to play with it:
|
26
|
+
|
27
|
+
$ bundle exec ztk
|
28
|
+
|
29
|
+
## USAGE
|
30
|
+
|
11
31
|
- **ZTK::ANSI**
|
12
32
|
|
13
33
|
This mixin module gives you the ability to easily add ANSI colors to strings. It also has a method for stripping all ANSI codes out of a string. Read more at the [ZTK::ANSI](http://zpatten.github.io/ztk/ZTK/ANSI.html) documentation.
|
@@ -76,6 +96,10 @@ Zachary's Tool Kit contains a collection of reusable classes meant to simplify d
|
|
76
96
|
|
77
97
|
UI management; this class encapsulates STDOUT, STDERR, STDIN and a Ruby logger; as well as some other helpful flags. This allows you to easily present a unified UI interface and allows for easy redirection of that interface (really helpful when using StringIO's with rspec to test program output for example). Read more at the [ZTK::UI](http://zpatten.github.io/ztk/ZTK/UI.html) documentation.
|
78
98
|
|
99
|
+
## CONTRIBUTING
|
100
|
+
|
101
|
+
I await your pull request.
|
102
|
+
|
79
103
|
# RUBIES TESTED AGAINST
|
80
104
|
|
81
105
|
* Ruby 2.0.0
|
data/lib/ztk/dsl/base.rb
CHANGED
@@ -29,7 +29,7 @@ module ZTK::DSL
|
|
29
29
|
# You can also instantiate classes separately and associate them after the
|
30
30
|
# fact. That is not shown in this example.
|
31
31
|
#
|
32
|
-
#
|
32
|
+
# @example Building infrastructure DSL objects
|
33
33
|
#
|
34
34
|
# class Network < ZTK::DSL::Base
|
35
35
|
# has_many :servers
|
@@ -75,59 +75,6 @@ module ZTK::DSL
|
|
75
75
|
# Server.all
|
76
76
|
# Server.find(:my_server)
|
77
77
|
#
|
78
|
-
# *pry output*:
|
79
|
-
#
|
80
|
-
# [1] pry(main)> class Network < ZTK::DSL::Base
|
81
|
-
# [1] pry(main)* has_many :servers
|
82
|
-
# [1] pry(main)*
|
83
|
-
# [1] pry(main)* attribute :name
|
84
|
-
# [1] pry(main)* attribute :gw
|
85
|
-
# [1] pry(main)* attribute :network
|
86
|
-
# [1] pry(main)* attribute :netmask
|
87
|
-
# [1] pry(main)* end
|
88
|
-
# => #<Proc:0x0000000121f498@/home/zpatten/Dropbox/code/chef-repo/vendor/checkouts/ztk/lib/ztk/dsl/core/attributes.rb:45 (lambda)>
|
89
|
-
# [2] pry(main)> class Server < ZTK::DSL::Base
|
90
|
-
# [2] pry(main)* belongs_to :network
|
91
|
-
# [2] pry(main)*
|
92
|
-
# [2] pry(main)* attribute :name
|
93
|
-
# [2] pry(main)* end
|
94
|
-
# => #<Proc:0x00000001983108@/home/zpatten/Dropbox/code/chef-repo/vendor/checkouts/ztk/lib/ztk/dsl/core/attributes.rb:45 (lambda)>
|
95
|
-
# [3] pry(main)> Network.new do
|
96
|
-
# [3] pry(main)* id :leet_net
|
97
|
-
# [3] pry(main)* name "leet-net"
|
98
|
-
# [3] pry(main)* gw "7.3.3.1"
|
99
|
-
# [3] pry(main)* network "7.3.3.0"
|
100
|
-
# [3] pry(main)* netmask "255.255.255.0"
|
101
|
-
# [3] pry(main)*
|
102
|
-
# [3] pry(main)* server do
|
103
|
-
# [3] pry(main)* name "leet-server"
|
104
|
-
# [3] pry(main)* end
|
105
|
-
# [3] pry(main)*
|
106
|
-
# [3] pry(main)* server do
|
107
|
-
# [3] pry(main)* id :my_server
|
108
|
-
# [3] pry(main)* name "my-server"
|
109
|
-
# [3] pry(main)* end
|
110
|
-
# [3] pry(main)*
|
111
|
-
# [3] pry(main)* server do
|
112
|
-
# [3] pry(main)* name "dev-server"
|
113
|
-
# [3] pry(main)* end
|
114
|
-
# [3] pry(main)* end
|
115
|
-
# => #<Network id=:leet_net attributes={:id=>:leet_net, :name=>"leet-net", :gw=>"7.3.3.1", :network=>"7.3.3.0", :netmask=>"255.255.255.0"}, has_many_references=1>
|
116
|
-
# [4] pry(main)> Network.count
|
117
|
-
# => 1
|
118
|
-
# [5] pry(main)> Network.all
|
119
|
-
# => [#<Network id=:leet_net attributes={:id=>:leet_net, :name=>"leet-net", :gw=>"7.3.3.1", :network=>"7.3.3.0", :netmask=>"255.255.255.0"}, has_many_references=1>]
|
120
|
-
# [6] pry(main)> Network.find(:leet_net)
|
121
|
-
# => [#<Network id=:leet_net attributes={:id=>:leet_net, :name=>"leet-net", :gw=>"7.3.3.1", :network=>"7.3.3.0", :netmask=>"255.255.255.0"}, has_many_references=1>]
|
122
|
-
# [7] pry(main)> Server.count
|
123
|
-
# => 3
|
124
|
-
# [8] pry(main)> Server.all
|
125
|
-
# => [#<Server id=2 attributes={:id=>2, :name=>"leet-server", :network_id=>:leet_net}, belongs_to_references=1>,
|
126
|
-
# #<Server id=:my_server attributes={:id=>:my_server, :name=>"my-server", :network_id=>:leet_net}, belongs_to_references=1>,
|
127
|
-
# #<Server id=4 attributes={:id=>4, :name=>"dev-server", :network_id=>:leet_net}, belongs_to_references=1>]
|
128
|
-
# [9] pry(main)> Server.find(:my_server)
|
129
|
-
# => [#<Server id=:my_server attributes={:id=>:my_server, :name=>"my-server", :network_id=>:leet_net}, belongs_to_references=1>]
|
130
|
-
#
|
131
78
|
# @author Zachary Patten <zpatten AT jovelabs DOT io>
|
132
79
|
class Base
|
133
80
|
include(ZTK::DSL::Core)
|
data/lib/ztk/parallel.rb
CHANGED
@@ -63,9 +63,9 @@ module ZTK
|
|
63
63
|
# Default Maximum Number of Forks
|
64
64
|
MAX_FORKS = case RUBY_PLATFORM
|
65
65
|
when /darwin/ then
|
66
|
-
%x( sysctl hw.ncpu ).strip.split(':').last.strip.to_i
|
66
|
+
(%x( sysctl hw.ncpu ).strip.split(':').last.strip.to_i - 1)
|
67
67
|
when /linux/ then
|
68
|
-
%x( grep -c processor /proc/cpuinfo ).strip.strip.to_i
|
68
|
+
(%x( grep -c processor /proc/cpuinfo ).strip.strip.to_i - 1)
|
69
69
|
end
|
70
70
|
|
71
71
|
# Platforms memory capacity in bytes
|
@@ -103,7 +103,6 @@ module ZTK
|
|
103
103
|
$stderr.puts("SIG#{signal} received by PID##{Process.pid}; signaling child processes...")
|
104
104
|
|
105
105
|
signal_all(signal)
|
106
|
-
exit!(1)
|
107
106
|
end
|
108
107
|
end
|
109
108
|
end
|
data/lib/ztk/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -17,26 +17,24 @@
|
|
17
17
|
# limitations under the License.
|
18
18
|
#
|
19
19
|
################################################################################
|
20
|
+
|
21
|
+
require 'codeclimate-test-reporter'
|
22
|
+
require 'coveralls'
|
20
23
|
require 'simplecov'
|
21
24
|
require 'simplecov-rcov'
|
22
|
-
|
23
|
-
|
24
|
-
require "codeclimate-test-reporter"
|
25
|
-
CodeClimate::TestReporter.start
|
26
|
-
################################################################################
|
27
|
-
require 'coveralls'
|
28
|
-
Coveralls.wear!
|
29
|
-
################################################################################
|
25
|
+
require 'yarjuf'
|
26
|
+
|
30
27
|
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new(
|
31
28
|
[
|
29
|
+
CodeClimate::TestReporter::Formatter,
|
30
|
+
Coveralls::SimpleCov::Formatter,
|
32
31
|
SimpleCov::Formatter::HTMLFormatter,
|
33
|
-
SimpleCov::Formatter::RcovFormatter
|
34
|
-
Coveralls::SimpleCov::Formatter
|
32
|
+
SimpleCov::Formatter::RcovFormatter
|
35
33
|
]
|
36
34
|
)
|
35
|
+
|
37
36
|
SimpleCov.start
|
38
|
-
|
39
|
-
require 'yarjuf'
|
37
|
+
|
40
38
|
################################################################################
|
41
39
|
|
42
40
|
require 'tempfile'
|
data/ztk.gemspec
CHANGED
@@ -22,38 +22,38 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
22
22
|
require 'ztk/version'
|
23
23
|
|
24
24
|
Gem::Specification.new do |spec|
|
25
|
-
spec.name
|
26
|
-
spec.version
|
27
|
-
spec.authors
|
28
|
-
spec.email
|
29
|
-
spec.description
|
30
|
-
spec.summary
|
31
|
-
spec.homepage
|
32
|
-
spec.license
|
25
|
+
spec.name = "ztk"
|
26
|
+
spec.version = ZTK::VERSION
|
27
|
+
spec.authors = %(Zachary Patten)
|
28
|
+
spec.email = [ %(zpatten AT jovelabs DOT io) ]
|
29
|
+
spec.description = %(Zachary's Tool Kit contains a collection of reusable classes meant to simplify development of complex systems in Ruby. These classes provide functionality I often find myself needing from project to project. Instead of reinventing the wheel each time, I've started building a collection of reusable classes. Easy-bake DSLs, parallel processing, complex logging, templating and many other useful design patterns, for example are all contained in simple, reusable classes with a common interface and configuration style.)
|
30
|
+
spec.summary = %(Zachary's Tool Kit contains a collection of reusable classes meant to simplify development of complex systems in Ruby.)
|
31
|
+
spec.homepage = "https://github.com/zpatten/ztk"
|
32
|
+
spec.license = "Apache 2.0"
|
33
33
|
|
34
|
-
spec.files
|
35
|
-
spec.executables
|
36
|
-
spec.test_files
|
37
|
-
spec.require_paths
|
34
|
+
spec.files = `git ls-files`.split($\)
|
35
|
+
spec.executables = spec.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
36
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
37
|
+
spec.require_paths = ["lib"]
|
38
38
|
|
39
39
|
spec.required_ruby_version = '>= 2.0.0'
|
40
40
|
|
41
41
|
spec.add_dependency("activesupport")
|
42
42
|
spec.add_dependency("erubis")
|
43
|
+
spec.add_dependency("net-scp")
|
44
|
+
spec.add_dependency("net-sftp")
|
43
45
|
spec.add_dependency("net-ssh")
|
44
46
|
spec.add_dependency("net-ssh-gateway")
|
45
|
-
spec.add_dependency("net-sftp")
|
46
|
-
spec.add_dependency("net-scp")
|
47
47
|
|
48
|
+
spec.add_development_dependency("codeclimate-test-reporter")
|
49
|
+
spec.add_development_dependency("coveralls")
|
48
50
|
spec.add_development_dependency("pry")
|
49
51
|
spec.add_development_dependency("rake")
|
50
|
-
spec.add_development_dependency("rspec")
|
51
|
-
spec.add_development_dependency("yard")
|
52
52
|
spec.add_development_dependency("redcarpet")
|
53
|
-
spec.add_development_dependency("
|
54
|
-
spec.add_development_dependency("coveralls")
|
55
|
-
spec.add_development_dependency("yarjuf")
|
53
|
+
spec.add_development_dependency("rspec")
|
56
54
|
spec.add_development_dependency("simplecov-rcov")
|
57
55
|
spec.add_development_dependency("travis")
|
58
56
|
spec.add_development_dependency("websocket-native")
|
57
|
+
spec.add_development_dependency("yard")
|
58
|
+
spec.add_development_dependency("yarjuf")
|
59
59
|
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: 3.2.
|
4
|
+
version: 3.2.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: 2016-
|
11
|
+
date: 2016-12-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name: net-
|
42
|
+
name: net-scp
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
@@ -53,7 +53,7 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name: net-
|
56
|
+
name: net-sftp
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
@@ -67,7 +67,7 @@ dependencies:
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name: net-
|
70
|
+
name: net-ssh
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - ">="
|
@@ -81,7 +81,7 @@ dependencies:
|
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name: net-
|
84
|
+
name: net-ssh-gateway
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - ">="
|
@@ -95,7 +95,7 @@ dependencies:
|
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
98
|
+
name: codeclimate-test-reporter
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - ">="
|
@@ -109,7 +109,7 @@ dependencies:
|
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
112
|
+
name: coveralls
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
115
|
- - ">="
|
@@ -123,7 +123,7 @@ dependencies:
|
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
|
-
name:
|
126
|
+
name: pry
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
129
|
- - ">="
|
@@ -137,7 +137,7 @@ dependencies:
|
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '0'
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
|
-
name:
|
140
|
+
name: rake
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
142
142
|
requirements:
|
143
143
|
- - ">="
|
@@ -165,7 +165,7 @@ dependencies:
|
|
165
165
|
- !ruby/object:Gem::Version
|
166
166
|
version: '0'
|
167
167
|
- !ruby/object:Gem::Dependency
|
168
|
-
name:
|
168
|
+
name: rspec
|
169
169
|
requirement: !ruby/object:Gem::Requirement
|
170
170
|
requirements:
|
171
171
|
- - ">="
|
@@ -179,7 +179,7 @@ dependencies:
|
|
179
179
|
- !ruby/object:Gem::Version
|
180
180
|
version: '0'
|
181
181
|
- !ruby/object:Gem::Dependency
|
182
|
-
name:
|
182
|
+
name: simplecov-rcov
|
183
183
|
requirement: !ruby/object:Gem::Requirement
|
184
184
|
requirements:
|
185
185
|
- - ">="
|
@@ -193,7 +193,7 @@ dependencies:
|
|
193
193
|
- !ruby/object:Gem::Version
|
194
194
|
version: '0'
|
195
195
|
- !ruby/object:Gem::Dependency
|
196
|
-
name:
|
196
|
+
name: travis
|
197
197
|
requirement: !ruby/object:Gem::Requirement
|
198
198
|
requirements:
|
199
199
|
- - ">="
|
@@ -207,7 +207,7 @@ dependencies:
|
|
207
207
|
- !ruby/object:Gem::Version
|
208
208
|
version: '0'
|
209
209
|
- !ruby/object:Gem::Dependency
|
210
|
-
name:
|
210
|
+
name: websocket-native
|
211
211
|
requirement: !ruby/object:Gem::Requirement
|
212
212
|
requirements:
|
213
213
|
- - ">="
|
@@ -221,7 +221,7 @@ dependencies:
|
|
221
221
|
- !ruby/object:Gem::Version
|
222
222
|
version: '0'
|
223
223
|
- !ruby/object:Gem::Dependency
|
224
|
-
name:
|
224
|
+
name: yard
|
225
225
|
requirement: !ruby/object:Gem::Requirement
|
226
226
|
requirements:
|
227
227
|
- - ">="
|
@@ -235,7 +235,7 @@ dependencies:
|
|
235
235
|
- !ruby/object:Gem::Version
|
236
236
|
version: '0'
|
237
237
|
- !ruby/object:Gem::Dependency
|
238
|
-
name:
|
238
|
+
name: yarjuf
|
239
239
|
requirement: !ruby/object:Gem::Requirement
|
240
240
|
requirements:
|
241
241
|
- - ">="
|