ztk 1.3.3 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -10,6 +10,10 @@ Zachary's (DevOp) Tool Kit is a general purpose utility gem, featuring a collect
10
10
 
11
11
  # RESOURCES
12
12
 
13
+ IRC:
14
+
15
+ * #jovelabs on irc.freenode.net
16
+
13
17
  Documentation:
14
18
 
15
19
  * http://zpatten.github.io/ztk/
data/lib/ztk.rb CHANGED
@@ -37,6 +37,7 @@ module ZTK
37
37
  autoload :Base, "ztk/base"
38
38
  autoload :DSL, "ztk/dsl"
39
39
 
40
+ autoload :ANSI, "ztk/ansi"
40
41
  autoload :Background, "ztk/background"
41
42
  autoload :Benchmark, "ztk/benchmark"
42
43
  autoload :Command, "ztk/command"
@@ -0,0 +1,85 @@
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
+ module ZTK
21
+
22
+ # ANSI Error Class
23
+ # @author Zachary Patten <zachary@jovelabs.net>
24
+ class ANSIError < Error; end
25
+
26
+ # ANSI Mixin Module
27
+ #
28
+ # Include this module to enable easy ANSI coloring methods like:
29
+ #
30
+ # "bold red".red.bold
31
+ #
32
+ # Or
33
+ #
34
+ # "green".green
35
+ #
36
+ # Standard use is to mix this module into String.
37
+ #
38
+ # @author Zachary Patten <zachary@jovelabs.net>
39
+ module ANSI
40
+
41
+ COLOR_MATRIX = {
42
+ :black => 30,
43
+ :red => 31,
44
+ :green => 32,
45
+ :yellow => 33,
46
+ :blue => 34,
47
+ :magenta => 35,
48
+ :cyan => 36,
49
+ :white => 37
50
+ }
51
+
52
+ ATTRIBUTE_MATRIX = {
53
+ :normal => 0,
54
+ :bold => 1
55
+ }
56
+
57
+ def self.build_ansi_methods(hash)
58
+ hash.each do |key, value|
59
+ define_method(key) do |string=nil, &block|
60
+ result = Array.new
61
+ result << %(\e[#{value}m)
62
+ if block_given?
63
+ result << yield
64
+ elsif string.respond_to?(:to_str)
65
+ result << string.to_str
66
+ elsif respond_to?(:to_str)
67
+ result << to_str
68
+ else
69
+ return result
70
+ end
71
+ result << %(\e[0m)
72
+
73
+ result.join
74
+ end
75
+ end
76
+ end
77
+
78
+ build_ansi_methods(COLOR_MATRIX)
79
+ build_ansi_methods(ATTRIBUTE_MATRIX)
80
+
81
+ extend self
82
+
83
+ end
84
+
85
+ end
@@ -42,7 +42,6 @@ module ZTK
42
42
  config.ui.logger.info { "download(#{remote.inspect}, #{local.inspect})" }
43
43
 
44
44
  ZTK::RescueRetry.try(:tries => 3, :on => EOFError) do
45
- @sftp = Net::SFTP.start(config.host_name, config.user, ssh_options)
46
45
  sftp.download!(remote.to_s, local.to_s) do |event, downloader, *args|
47
46
  case event
48
47
  when :open
@@ -42,7 +42,6 @@ module ZTK
42
42
  config.ui.logger.info { "upload(#{local.inspect}, #{remote.inspect})" }
43
43
 
44
44
  ZTK::RescueRetry.try(:tries => 3, :on => EOFError) do
45
- @sftp = Net::SFTP.start(config.host_name, config.user, ssh_options)
46
45
  sftp.upload!(local.to_s, remote.to_s) do |event, uploader, *args|
47
46
  case event
48
47
  when :open
@@ -21,6 +21,6 @@
21
21
  module ZTK
22
22
 
23
23
  # ZTK Version String
24
- VERSION = "1.3.3"
24
+ VERSION = "1.4.0"
25
25
 
26
26
  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: 1.3.3
4
+ version: 1.4.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-28 00:00:00.000000000 Z
12
+ date: 2013-04-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: erubis
@@ -175,6 +175,7 @@ files:
175
175
  - Rakefile
176
176
  - bin/ztk
177
177
  - lib/ztk.rb
178
+ - lib/ztk/ansi.rb
178
179
  - lib/ztk/background.rb
179
180
  - lib/ztk/base.rb
180
181
  - lib/ztk/benchmark.rb
@@ -246,7 +247,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
246
247
  version: '0'
247
248
  segments:
248
249
  - 0
249
- hash: -566135137334067410
250
+ hash: 1701561932137543849
250
251
  required_rubygems_version: !ruby/object:Gem::Requirement
251
252
  none: false
252
253
  requirements:
@@ -255,7 +256,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
255
256
  version: '0'
256
257
  segments:
257
258
  - 0
258
- hash: -566135137334067410
259
+ hash: 1701561932137543849
259
260
  requirements: []
260
261
  rubyforge_project:
261
262
  rubygems_version: 1.8.25