ztk 1.4.4 → 1.4.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. data/README.md +1 -1
  2. data/Rakefile +1 -1
  3. data/lib/ztk.rb +3 -23
  4. data/lib/ztk/ansi.rb +94 -33
  5. data/lib/ztk/background.rb +4 -23
  6. data/lib/ztk/base.rb +5 -24
  7. data/lib/ztk/benchmark.rb +4 -23
  8. data/lib/ztk/command.rb +49 -40
  9. data/lib/ztk/config.rb +3 -22
  10. data/lib/ztk/dsl.rb +3 -22
  11. data/lib/ztk/dsl/base.rb +14 -22
  12. data/lib/ztk/dsl/core.rb +4 -24
  13. data/lib/ztk/dsl/core/actions.rb +1 -21
  14. data/lib/ztk/dsl/core/actions/find.rb +2 -22
  15. data/lib/ztk/dsl/core/actions/timestamps.rb +2 -22
  16. data/lib/ztk/dsl/core/attributes.rb +2 -22
  17. data/lib/ztk/dsl/core/dataset.rb +2 -22
  18. data/lib/ztk/dsl/core/io.rb +2 -22
  19. data/lib/ztk/dsl/core/relations.rb +2 -22
  20. data/lib/ztk/dsl/core/relations/belongs_to.rb +2 -22
  21. data/lib/ztk/dsl/core/relations/has_many.rb +2 -22
  22. data/lib/ztk/locator.rb +3 -22
  23. data/lib/ztk/logger.rb +2 -21
  24. data/lib/ztk/parallel.rb +4 -23
  25. data/lib/ztk/pty.rb +8 -23
  26. data/lib/ztk/report.rb +4 -23
  27. data/lib/ztk/rescue_retry.rb +4 -24
  28. data/lib/ztk/spinner.rb +6 -25
  29. data/lib/ztk/ssh.rb +20 -27
  30. data/lib/ztk/ssh/bootstrap.rb +17 -19
  31. data/lib/ztk/ssh/command.rb +1 -19
  32. data/lib/ztk/ssh/download.rb +1 -19
  33. data/lib/ztk/ssh/exec.rb +14 -24
  34. data/lib/ztk/ssh/file.rb +1 -19
  35. data/lib/ztk/ssh/upload.rb +5 -22
  36. data/lib/ztk/tcp_socket_check.rb +3 -22
  37. data/lib/ztk/template.rb +4 -23
  38. data/lib/ztk/ui.rb +5 -25
  39. data/lib/ztk/version.rb +1 -21
  40. data/spec/spec_helper.rb +1 -1
  41. data/spec/ztk/background_spec.rb +1 -1
  42. data/spec/ztk/base_spec.rb +1 -1
  43. data/spec/ztk/benchmark_spec.rb +1 -1
  44. data/spec/ztk/command_spec.rb +1 -1
  45. data/spec/ztk/config_spec.rb +1 -1
  46. data/spec/ztk/dsl_spec.rb +1 -1
  47. data/spec/ztk/locator_spec.rb +1 -1
  48. data/spec/ztk/logger_spec.rb +1 -1
  49. data/spec/ztk/parallel_spec.rb +1 -1
  50. data/spec/ztk/pty_spec.rb +1 -1
  51. data/spec/ztk/rescue_retry_spec.rb +1 -1
  52. data/spec/ztk/spinner_spec.rb +1 -1
  53. data/spec/ztk/ssh_spec.rb +1 -1
  54. data/spec/ztk/tcp_socket_check_spec.rb +1 -1
  55. data/spec/ztk/template_spec.rb +1 -1
  56. data/spec/ztk/ui_spec.rb +1 -1
  57. data/spec/ztk/version_spec.rb +1 -1
  58. data/ztk.gemspec +2 -2
  59. metadata +4 -4
data/lib/ztk/config.rb CHANGED
@@ -1,29 +1,10 @@
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
1
  require 'ostruct'
21
2
 
22
3
  module ZTK
23
4
 
24
- # ZTK::Config General Error Class
5
+ # Config Error Class
25
6
  #
26
- # @author Zachary Patten <zachary@jovelabs.net>
7
+ # @author Zachary Patten <zachary AT jovelabs DOT com>
27
8
  class ConfigError < Error; end
28
9
 
29
10
  # Configuration Module
@@ -62,7 +43,7 @@ module ZTK
62
43
  #
63
44
  # puts C.message
64
45
  #
65
- # @author Zachary Patten <zachary@jovelabs.net>
46
+ # @author Zachary Patten <zachary AT jovelabs DOT com>
66
47
  module Config
67
48
 
68
49
  # Extend base class with this module.
data/lib/ztk/dsl.rb CHANGED
@@ -1,33 +1,14 @@
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
- require "active_support/inflector"
1
+ require 'active_support/inflector'
21
2
 
22
3
  module ZTK
23
4
 
24
5
  # Generic Domain-specific Language Interface
25
6
  #
26
7
  # @see ZTK::DSL::Base
27
- # @author Zachary Patten <zachary@jovelabs.net>
8
+ # @author Zachary Patten <zachary AT jovelabs DOT com>
28
9
  module DSL
29
10
 
30
- # @author Zachary Patten <zachary@jovelabs.net>
11
+ # @author Zachary Patten <zachary AT jovelabs DOT com>
31
12
  class DSLError < Error; end
32
13
 
33
14
  autoload :Base, "ztk/dsl/base"
data/lib/ztk/dsl/base.rb CHANGED
@@ -1,23 +1,3 @@
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
-
21
1
  module ZTK::DSL
22
2
 
23
3
  # Generic Domain-specific Language Interface
@@ -148,7 +128,7 @@ module ZTK::DSL
148
128
  # [9] pry(main)> Server.find(:my_server)
149
129
  # => [#<Server id=:my_server attributes={:id=>:my_server, :name=>"my-server", :network_id=>:leet_net}, belongs_to_references=1>]
150
130
  #
151
- # @author Zachary Patten <zachary@jovelabs.net>
131
+ # @author Zachary Patten <zachary AT jovelabs DOT com>
152
132
  class Base
153
133
  include(ZTK::DSL::Core)
154
134
 
@@ -184,6 +164,12 @@ module ZTK::DSL
184
164
  raise StandardError, "Primary key '#{self.id}' already exists!" if (primary_key_count > 1)
185
165
  end
186
166
 
167
+ # Instance Inspect
168
+ #
169
+ # Inspect the DSL object's instance, returning a concise string
170
+ # representation of the instance.
171
+ #
172
+ # @return [String] A concise string representation of the instance.
187
173
  def inspect
188
174
  details = Array.new
189
175
  details << "attributes=#{attributes.inspect}" if attributes.count > 0
@@ -192,9 +178,15 @@ module ZTK::DSL
192
178
  "#<#{self.class.to_s} id=#{self.id.inspect} #{details.join(', ')}>"
193
179
  end
194
180
 
195
- # @author Zachary Patten <zachary@jovelabs.net>
181
+ # @author Zachary Patten <zachary AT jovelabs DOT com>
196
182
  module ClassMethods
197
183
 
184
+ # Class Inspect
185
+ #
186
+ # Inspect the DSL object's class, returning a concise string
187
+ # representation of the class.
188
+ #
189
+ # @return [String] A concise string representation of the class.
198
190
  def inspect
199
191
  details = Array.new
200
192
  details << "count=#{self.all.count}" if self.all.count > 0
data/lib/ztk/dsl/core.rb CHANGED
@@ -1,28 +1,8 @@
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
-
21
1
  module ZTK::DSL
22
2
 
23
- # ZTK::DSL Core
3
+ # DSL Core
24
4
  #
25
- # @author Zachary Patten <zachary@jovelabs.net>
5
+ # @author Zachary Patten <zachary AT jovelabs DOT com>
26
6
  # @api private
27
7
  module Core
28
8
  autoload :Attributes, "ztk/dsl/core/attributes"
@@ -46,7 +26,7 @@ module ZTK::DSL
46
26
  end
47
27
  end
48
28
 
49
- # @author Zachary Patten <zachary@jovelabs.net>
29
+ # @author Zachary Patten <zachary AT jovelabs DOT com>
50
30
  # module DualMethods
51
31
 
52
32
  # def logger
@@ -61,7 +41,7 @@ module ZTK::DSL
61
41
 
62
42
  # end
63
43
 
64
- # @author Zachary Patten <zachary@jovelabs.net>
44
+ # @author Zachary Patten <zachary AT jovelabs DOT com>
65
45
  module ClassMethods
66
46
 
67
47
  def cattr_accessor(*args)
@@ -1,26 +1,6 @@
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
-
21
1
  module ZTK::DSL::Core
22
2
 
23
- # @author Zachary Patten <zachary@jovelabs.net>
3
+ # @author Zachary Patten <zachary AT jovelabs DOT com>
24
4
  # @api private
25
5
  module Actions
26
6
  autoload :Find, "ztk/dsl/core/actions/find"
@@ -1,26 +1,6 @@
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
-
21
1
  module ZTK::DSL::Core::Actions
22
2
 
23
- # @author Zachary Patten <zachary@jovelabs.net>
3
+ # @author Zachary Patten <zachary AT jovelabs DOT com>
24
4
  # @api private
25
5
  module Find
26
6
 
@@ -30,7 +10,7 @@ module ZTK::DSL::Core::Actions
30
10
  end
31
11
  end
32
12
 
33
- # @author Zachary Patten <zachary@jovelabs.net>
13
+ # @author Zachary Patten <zachary AT jovelabs DOT com>
34
14
  module ClassMethods
35
15
 
36
16
  def all
@@ -1,26 +1,6 @@
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
-
21
1
  module ZTK::DSL::Core::Actions
22
2
 
23
- # @author Zachary Patten <zachary@jovelabs.net>
3
+ # @author Zachary Patten <zachary AT jovelabs DOT com>
24
4
  # @api private
25
5
  module Timestamps
26
6
 
@@ -34,7 +14,7 @@ module ZTK::DSL::Core::Actions
34
14
  end
35
15
  end
36
16
 
37
- # @author Zachary Patten <zachary@jovelabs.net>
17
+ # @author Zachary Patten <zachary AT jovelabs DOT com>
38
18
  module ClassMethods
39
19
 
40
20
  def updated_at_timestamp
@@ -1,26 +1,6 @@
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
-
21
1
  module ZTK::DSL::Core
22
2
 
23
- # @author Zachary Patten <zachary@jovelabs.net>
3
+ # @author Zachary Patten <zachary AT jovelabs DOT com>
24
4
  # @api private
25
5
  module Attributes
26
6
 
@@ -34,7 +14,7 @@ module ZTK::DSL::Core
34
14
  @attributes ||= {}
35
15
  end
36
16
 
37
- # @author Zachary Patten <zachary@jovelabs.net>
17
+ # @author Zachary Patten <zachary AT jovelabs DOT com>
38
18
  module ClassMethods
39
19
 
40
20
  def attribute(key, options={})
@@ -1,26 +1,6 @@
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
-
21
1
  module ZTK::DSL::Core
22
2
 
23
- # @author Zachary Patten <zachary@jovelabs.net>
3
+ # @author Zachary Patten <zachary AT jovelabs DOT com>
24
4
  # @api private
25
5
  module Dataset
26
6
 
@@ -30,7 +10,7 @@ module ZTK::DSL::Core
30
10
  end
31
11
  end
32
12
 
33
- # @author Zachary Patten <zachary@jovelabs.net>
13
+ # @author Zachary Patten <zachary AT jovelabs DOT com>
34
14
  module ClassMethods
35
15
 
36
16
  def dataset
@@ -1,26 +1,6 @@
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
-
21
1
  module ZTK::DSL::Core
22
2
 
23
- # @author Zachary Patten <zachary@jovelabs.net>
3
+ # @author Zachary Patten <zachary AT jovelabs DOT com>
24
4
  # @api private
25
5
  module IO
26
6
 
@@ -30,7 +10,7 @@ module ZTK::DSL::Core
30
10
  end
31
11
  end
32
12
 
33
- # @author Zachary Patten <zachary@jovelabs.net>
13
+ # @author Zachary Patten <zachary AT jovelabs DOT com>
34
14
  module ClassMethods
35
15
 
36
16
  def load(rb_file)
@@ -1,26 +1,6 @@
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
-
21
1
  module ZTK::DSL::Core
22
2
 
23
- # @author Zachary Patten <zachary@jovelabs.net>
3
+ # @author Zachary Patten <zachary AT jovelabs DOT com>
24
4
  # @api private
25
5
  module Relations
26
6
  autoload :BelongsTo, "ztk/dsl/core/relations/belongs_to"
@@ -34,7 +14,7 @@ module ZTK::DSL::Core
34
14
  end
35
15
  end
36
16
 
37
- # @author Zachary Patten <zachary@jovelabs.net>
17
+ # @author Zachary Patten <zachary AT jovelabs DOT com>
38
18
  module ClassMethods
39
19
 
40
20
  def add_relation(key)
@@ -1,26 +1,6 @@
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
-
21
1
  module ZTK::DSL::Core::Relations
22
2
 
23
- # @author Zachary Patten <zachary@jovelabs.net>
3
+ # @author Zachary Patten <zachary AT jovelabs DOT com>
24
4
  # @api private
25
5
  module BelongsTo
26
6
 
@@ -64,7 +44,7 @@ module ZTK::DSL::Core::Relations
64
44
  end
65
45
  end
66
46
 
67
- # @author Zachary Patten <zachary@jovelabs.net>
47
+ # @author Zachary Patten <zachary AT jovelabs DOT com>
68
48
  module ClassMethods
69
49
 
70
50
  def belongs_to(key, options={})