ztk 1.4.5 → 1.4.6

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.
@@ -1,16 +1,16 @@
1
1
  language: ruby
2
2
 
3
3
  rvm:
4
+ - ree
4
5
  - 1.9.2
5
6
  - 1.9.3
6
7
  - 2.0.0
7
8
 
8
- before_install:
9
- - sudo apt-get -qq --force-yes update
10
-
11
- bundler_args: --binstubs
12
-
13
- script: "rake test"
9
+ before_install: ./spec/support/before_install.sh
14
10
 
15
11
  notifications:
16
12
  irc: "irc.freenode.net#jovelabs"
13
+
14
+ matrix:
15
+ allow_failures:
16
+ - rvm: ree
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
+ gem "json" if (RUBY_VERSION == "1.8.7")
4
+
3
5
  gemspec
@@ -52,8 +52,10 @@ module ZTK
52
52
 
53
53
  notice << char
54
54
  notice << "#{char} WARNING: AUTOMATICALLY GENERATED FILE; DO NOT EDIT!"
55
- notice << char
56
- notice << "#{char} #{message}" if !message.nil?
55
+ if !message.nil?
56
+ notice << char
57
+ notice << "#{char} #{message}"
58
+ end
57
59
  notice << char
58
60
  notice << "#{char} Generated @ #{Time.now.utc}"
59
61
  notice << char
@@ -1,6 +1,6 @@
1
1
  module ZTK
2
2
 
3
3
  # ZTK Version String
4
- VERSION = "1.4.5"
4
+ VERSION = "1.4.6"
5
5
 
6
6
  end
@@ -0,0 +1,41 @@
1
+ ################################################################################
2
+ #
3
+ # Author: Zachary Patten <zachary AT jovelabs DOT com>
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
+ #!/bin/bash
21
+ set -x
22
+
23
+ sudo apt-get -qq update
24
+
25
+ ssh -V
26
+ cat /etc/ssh/sshd_config
27
+ ls -la $HOME
28
+
29
+ eval `ssh-agent -s`
30
+ ssh-add -L
31
+
32
+ mkdir -p $HOME/.ssh
33
+ ssh-keygen -N '' -f $HOME/.ssh/id_rsa
34
+
35
+ ls -la $HOME/.ssh
36
+
37
+ cat $HOME/.ssh/id_rsa.pub | tee $HOME/.ssh/authorized_keys
38
+ cat $HOME/.ssh/id_rsa.pub | tee $HOME/.ssh/authorized_keys2
39
+
40
+ ssh-add $HOME/.ssh/id_rsa
41
+ ssh-add -L
@@ -32,42 +32,81 @@ describe ZTK::Parallel do
32
32
 
33
33
  end
34
34
 
35
- describe "behaviour" do
35
+ describe "methods" do
36
36
 
37
- it "should throw an exception if the process method is called without a block" do
38
- lambda{ subject.process }.should raise_error ZTK::ParallelError, "You must supply a block to the process method!"
39
- end
40
37
 
41
- it "should spawn multiple processes to handle each iteration" do
42
- 3.times do |x|
43
- subject.process do
44
- Process.pid
38
+ describe "#process" do
39
+
40
+ it "should throw an exception if the process method is called without a block" do
41
+ lambda{ subject.process }.should raise_error ZTK::ParallelError, "You must supply a block to the process method!"
42
+ end
43
+
44
+ it "should spawn multiple processes to handle each iteration" do
45
+ 3.times do |x|
46
+ subject.process do
47
+ Process.pid
48
+ end
45
49
  end
50
+
51
+ subject.waitall
52
+
53
+ subject.results.all?{ |r| r.should be_kind_of Integer }
54
+ subject.results.all?{ |r| r.should > 0 }
55
+ subject.results.uniq.count.should == 3
56
+ subject.results.include?(Process.pid).should be false
46
57
  end
47
58
 
48
- subject.waitall
59
+ end
60
+
61
+ describe "#wait" do
62
+
63
+ it "should be able to incrementally wait the forks" do
64
+ 3.times do |x|
65
+ subject.process do
66
+ Process.pid
67
+ end
68
+ end
69
+
70
+ 3.times do
71
+ subject.wait
72
+ end
73
+
74
+ subject.results.all?{ |r| r.should be_kind_of Integer }
75
+ subject.results.all?{ |r| r.should > 0 }
76
+ subject.results.uniq.count.should == 3
77
+ subject.results.include?(Process.pid).should be false
78
+ end
49
79
 
50
- subject.results.all?{ |r| r.should be_kind_of Integer }
51
- subject.results.all?{ |r| r.should > 0 }
52
- subject.results.uniq.count.should == 3
53
- subject.results.include?(Process.pid).should be false
54
80
  end
55
81
 
56
- it "should be able to incrementally wait the forks" do
57
- 3.times do |x|
58
- subject.process do
59
- Process.pid
82
+ describe "#waitall" do
83
+
84
+ it "should be able to wait for all forks to stop" do
85
+ 3.times do |x|
86
+ subject.process do
87
+ Process.pid
88
+ end
60
89
  end
90
+
91
+ subject.waitall
92
+ subject.count.should == 0
61
93
  end
62
94
 
63
- 3.times do
64
- subject.wait
95
+ end
96
+
97
+ describe "#count" do
98
+
99
+ it "should return the number of active forked processes" do
100
+ 3.times do |x|
101
+ subject.process do
102
+ sleep(WAIT_SMALL)
103
+ end
104
+ end
105
+
106
+ subject.count.should == 3
107
+ subject.waitall
65
108
  end
66
109
 
67
- subject.results.all?{ |r| r.should be_kind_of Integer }
68
- subject.results.all?{ |r| r.should > 0 }
69
- subject.results.uniq.count.should == 3
70
- subject.results.include?(Process.pid).should be false
71
110
  end
72
111
 
73
112
  end
@@ -245,7 +245,13 @@ describe ZTK::SSH do
245
245
  File.exists?(remote_file) && File.delete(remote_file)
246
246
 
247
247
  local_file = File.join("/tmp", "ssh-upload-local")
248
- IO.write(local_file, data)
248
+ if RUBY_VERSION < "1.9.3"
249
+ File.open(local_file, 'w') do |file|
250
+ file.puts(data)
251
+ end
252
+ else
253
+ IO.write(local_file, data)
254
+ end
249
255
 
250
256
  File.exists?(remote_file).should == false
251
257
  subject.upload(local_file, remote_file)
@@ -273,7 +279,13 @@ describe ZTK::SSH do
273
279
  File.exists?(local_file) && File.delete(local_file)
274
280
 
275
281
  remote_file = File.join("/tmp", "ssh-download-remote")
276
- IO.write(remote_file, data)
282
+ if RUBY_VERSION < "1.9.3"
283
+ File.open(remote_file, 'w') do |file|
284
+ file.puts(data)
285
+ end
286
+ else
287
+ IO.write(remote_file, data)
288
+ end
277
289
 
278
290
  File.exists?(local_file).should == false
279
291
  subject.download(remote_file, local_file)
@@ -285,7 +297,7 @@ describe ZTK::SSH do
285
297
 
286
298
  end
287
299
 
288
- end if !ENV['CI'] && !ENV['TRAVIS']
300
+ end
289
301
 
290
302
  describe "proxy SSH behaviour" do
291
303
 
@@ -515,7 +527,13 @@ describe ZTK::SSH do
515
527
  File.exists?(remote_file) && File.delete(remote_file)
516
528
 
517
529
  local_file = File.join("/tmp", "ssh-upload-local")
518
- IO.write(local_file, data)
530
+ if RUBY_VERSION < "1.9.3"
531
+ File.open(local_file, 'w') do |file|
532
+ file.puts(data)
533
+ end
534
+ else
535
+ IO.write(local_file, data)
536
+ end
519
537
 
520
538
  File.exists?(remote_file).should == false
521
539
  subject.upload(local_file, remote_file)
@@ -545,7 +563,13 @@ describe ZTK::SSH do
545
563
  File.exists?(local_file) && File.delete(local_file)
546
564
 
547
565
  remote_file = File.join("/tmp", "ssh-download-remote")
548
- IO.write(remote_file, data)
566
+ if RUBY_VERSION < "1.9.3"
567
+ File.open(remote_file, 'w') do |file|
568
+ file.puts(data)
569
+ end
570
+ else
571
+ IO.write(remote_file, data)
572
+ end
549
573
 
550
574
  File.exists?(local_file).should == false
551
575
  subject.download(remote_file, local_file)
@@ -557,6 +581,6 @@ describe ZTK::SSH do
557
581
 
558
582
  end
559
583
 
560
- end if !ENV['CI'] && !ENV['TRAVIS']
584
+ end
561
585
 
562
586
  end
@@ -32,13 +32,47 @@ describe ZTK::Template do
32
32
 
33
33
  end
34
34
 
35
- describe "behaviour" do
35
+ describe "methods" do
36
+
37
+ describe "do_not_edit_notice" do
38
+
39
+ it "should render the notice with no options" do
40
+ result = subject.do_not_edit_notice
41
+ result.should =~ /WARNING: AUTOMATICALLY GENERATED FILE; DO NOT EDIT!/
42
+ result.should =~ /Generated @/
43
+ result.should =~ /#/
44
+ end
45
+
46
+ it "should render the notice with our message inside" do
47
+ message = "Hello World"
48
+ result = subject.do_not_edit_notice(:message => message)
49
+ result.should =~ /WARNING: AUTOMATICALLY GENERATED FILE; DO NOT EDIT!/
50
+ result.should =~ /Generated @/
51
+ result.should =~ /#/
52
+ result.should =~ /#{message}/
53
+ end
54
+
55
+ it "should allow us to change the comment character" do
56
+ message = "Hello World"
57
+ char = "ZZ"
58
+ result = subject.do_not_edit_notice(:message => message, :char => char)
59
+ result.should =~ /WARNING: AUTOMATICALLY GENERATED FILE; DO NOT EDIT!/
60
+ result.should =~ /Generated @/
61
+ result.should =~ /#{message}/
62
+ result.should =~ /#{char}/
63
+ end
64
+
65
+ end
66
+
67
+ describe "render" do
68
+
69
+ it "should render the template with the supplied context" do
70
+ template_file = File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "test-template.txt.erb"))
71
+ context = { :test_variable => "Hello World" }
72
+ output = subject.render(template_file, context)
73
+ output.should == "Hello World"
74
+ end
36
75
 
37
- it "should render the template with the supplied context" do
38
- template_file = File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "test-template.txt.erb"))
39
- context = { :test_variable => "Hello World" }
40
- output = subject.render(template_file, context)
41
- output.should == "Hello World"
42
76
  end
43
77
 
44
78
  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.4.5
4
+ version: 1.4.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -228,6 +228,7 @@ files:
228
228
  - lib/ztk/ui.rb
229
229
  - lib/ztk/version.rb
230
230
  - spec/spec_helper.rb
231
+ - spec/support/before_install.sh
231
232
  - spec/support/test-config.rb
232
233
  - spec/support/test-template.txt.erb
233
234
  - spec/ztk/background_spec.rb
@@ -263,7 +264,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
263
264
  version: '0'
264
265
  segments:
265
266
  - 0
266
- hash: -3687907436918424858
267
+ hash: -4478842353570464598
267
268
  required_rubygems_version: !ruby/object:Gem::Requirement
268
269
  none: false
269
270
  requirements:
@@ -272,7 +273,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
272
273
  version: '0'
273
274
  segments:
274
275
  - 0
275
- hash: -3687907436918424858
276
+ hash: -4478842353570464598
276
277
  requirements: []
277
278
  rubyforge_project:
278
279
  rubygems_version: 1.8.25
@@ -281,6 +282,7 @@ specification_version: 3
281
282
  summary: Zachary's (DevOp) Tool Kit
282
283
  test_files:
283
284
  - spec/spec_helper.rb
285
+ - spec/support/before_install.sh
284
286
  - spec/support/test-config.rb
285
287
  - spec/support/test-template.txt.erb
286
288
  - spec/ztk/background_spec.rb