devver-construct 1.0.0 → 1.1.0

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.
@@ -0,0 +1,18 @@
1
+ # Your API key authenticates you to Devver.
2
+ # Be careful to keep it secret. For instance,
3
+ # ensure that you do not check it into source
4
+ # control.
5
+
6
+ # You can retrieve your API key by logging in to
7
+ # http://devver.net
8
+
9
+ API_KEY: 'f148006f8d6379dbe96f7e5d817c303c7a30bb69f531b5ca875150714fa3654e'
10
+
11
+ # set REPORT_FAST to true to print error details as they occur during a run
12
+
13
+ REPORT_FAST: 'false'
14
+
15
+ # set DISPLAY_OUTPUT to false to hide the stdout and the stderr
16
+
17
+ DISPLAY_OUTPUT: true
18
+
@@ -0,0 +1,11 @@
1
+ #!/bin/sh
2
+
3
+ ################################################################################
4
+ # build
5
+ #
6
+ # This hook is responsible for running a full "build" of the project for the
7
+ # purpose of Continuus Integration
8
+ #
9
+ ################################################################################
10
+
11
+ rake
@@ -0,0 +1,3 @@
1
+ #!/bin/sh
2
+
3
+ geminstaller
@@ -0,0 +1,50 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ ################################################################################
4
+ # notify
5
+ #
6
+ # This hook is reponsible for notifying the user of the results of a task, such
7
+ # as a Continuous Integration build.
8
+ #
9
+ # PARAMETERS:
10
+ #
11
+ # This hook will be called with the form:
12
+ #
13
+ # .devver/hooks/notify TASK EXIT_STATUS
14
+ #
15
+ # * TASK is the name of the task that triggered the notification
16
+ # * EXIT_STATUS is the numeric exit status of the task. 0 indicates success.
17
+ #
18
+ # INPUT:
19
+ #
20
+ # This hook will be provided with a transcript of the triggering task's output.
21
+ # Both STDOUT and STDERR output will be included in the transcript.
22
+ #
23
+ # OUTPUT:
24
+ #
25
+ # This task should exit with a 0 status if the notification was successful, and
26
+ # a nonzero status if the notification failed.
27
+ #
28
+ ################################################################################
29
+ require 'net/smtp'
30
+ require 'time'
31
+ to = "devs@devver.net"
32
+
33
+ success = ARGV[0].to_i == 0
34
+ recipient = ENV.fetch('NOTIFY_RECIPIENT'){to}
35
+ message = <<"EOF"
36
+ From: support@devver.net
37
+ To: #{recipient}
38
+ Subject: Build #{success ? 'succeeded' : 'failed'}
39
+ Date: #{Time.now.rfc2822}
40
+
41
+ The task "#{ARGV[1]}" #{success ? 'succeeded' : 'failed'}.
42
+
43
+ Output:
44
+
45
+ #{$stdin.read}
46
+ EOF
47
+
48
+ Net::SMTP.start('localhost', 25) do |smtp|
49
+ smtp.send_message(message, 'application@devver.net', recipient)
50
+ end
@@ -0,0 +1 @@
1
+ #!/bin/sh
@@ -2,17 +2,17 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{construct}
5
- s.version = "1.0.0"
5
+ s.version = "1.1.0"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Ben Brinckerhoff (ben@devver.net) and Avdi Grimm (avdi@devver.net)"]
9
- s.date = %q{2009-08-18}
9
+ s.date = %q{2009-09-09}
10
10
  s.default_executable = %q{construct}
11
11
  s.description = %q{}
12
12
  s.email = %q{ben@devver.net, avdi@devver.net}
13
13
  s.executables = ["construct"]
14
14
  s.extra_rdoc_files = ["History.txt", "bin/construct"]
15
- s.files = ["History.txt", "README.markdown", "Rakefile", "bin/construct", "bugs/issue-0127c8c6ba1d31b5488f4551f8d869e57d53956d.yaml", "bugs/issue-404e5da7b128e5b34e7a33fbcd56603618010d92.yaml", "bugs/issue-50798912193be32b1dc610d949a557b3860d96fd.yaml", "bugs/issue-5a10ec7298127df3c62255ea59e01dcf831ff1d3.yaml", "bugs/issue-67f704f8b7190ccc1157eec007c3d584779dc805.yaml", "bugs/issue-881ae950569b6ca718fae0060f2751710b972fd2.yaml", "bugs/issue-bc8dfdf3834bb84b1d942ab2a90ac8c82b4389fb.yaml", "bugs/issue-d05e9a907202348d47c4bf92062c1f4673dcae68.yaml", "bugs/issue-f30a3db19d917f8e72ca8689e099ef0cb2681fd3.yaml", "bugs/project.yaml", "construct.gemspec", "geminstaller.yml", "lib/construct.rb", "lib/construct/helpers.rb", "lib/construct/path_extensions.rb", "tasks/ann.rake", "tasks/bones.rake", "tasks/gem.rake", "tasks/git.rake", "tasks/notes.rake", "tasks/post_load.rake", "tasks/rdoc.rake", "tasks/rubyforge.rake", "tasks/setup.rb", "tasks/spec.rake", "tasks/svn.rake", "tasks/test.rake", "tasks/zentest.rake", "test/construct_test.rb", "test/test_helper.rb"]
15
+ s.files = [".devver/devver_opts.yml", ".devver/hooks/build", ".devver/hooks/install_dependencies", ".devver/hooks/notify", ".devver/hooks/prepare_database", "History.txt", "README.markdown", "Rakefile", "bin/construct", "bugs/issue-0127c8c6ba1d31b5488f4551f8d869e57d53956d.yaml", "bugs/issue-404e5da7b128e5b34e7a33fbcd56603618010d92.yaml", "bugs/issue-50798912193be32b1dc610d949a557b3860d96fd.yaml", "bugs/issue-5a10ec7298127df3c62255ea59e01dcf831ff1d3.yaml", "bugs/issue-67f704f8b7190ccc1157eec007c3d584779dc805.yaml", "bugs/issue-881ae950569b6ca718fae0060f2751710b972fd2.yaml", "bugs/issue-bc8dfdf3834bb84b1d942ab2a90ac8c82b4389fb.yaml", "bugs/issue-d05e9a907202348d47c4bf92062c1f4673dcae68.yaml", "bugs/issue-f30a3db19d917f8e72ca8689e099ef0cb2681fd3.yaml", "bugs/project.yaml", "construct.gemspec", "geminstaller.yml", "lib/construct.rb", "lib/construct/helpers.rb", "lib/construct/path_extensions.rb", "tasks/ann.rake", "tasks/bones.rake", "tasks/gem.rake", "tasks/git.rake", "tasks/notes.rake", "tasks/post_load.rake", "tasks/rdoc.rake", "tasks/rubyforge.rake", "tasks/setup.rb", "tasks/spec.rake", "tasks/svn.rake", "tasks/test.rake", "tasks/zentest.rake", "test/construct_test.rb", "test/test_helper.rb"]
16
16
  s.has_rdoc = true
17
17
  s.homepage = %q{http://github.com/devver/construct}
18
18
  s.rdoc_options = ["--main", "README.markdown"]
@@ -5,7 +5,7 @@ require 'English'
5
5
  module Construct
6
6
 
7
7
  # :stopdoc:
8
- VERSION = '1.0.0'
8
+ VERSION = '1.1.0'
9
9
  LIBPATH = ::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR
10
10
  PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR
11
11
  # :startdoc:
@@ -45,6 +45,21 @@ module Construct
45
45
  Dir.glob(search_me).sort.each {|rb| require rb}
46
46
  end
47
47
 
48
+ # END Bones boilerplate
49
+
50
+ CONTAINER_PREFIX = 'construct_container'
51
+
52
+ def self.tmpdir
53
+ dir = nil
54
+ Dir.chdir Dir.tmpdir do dir = Dir.pwd end # HACK FOR OSX
55
+ dir
56
+ end
57
+
58
+ def self.destroy_all!
59
+ Pathname.glob(File.join(tmpdir, CONTAINER_PREFIX + "*")) do |container|
60
+ container.rmtree
61
+ end
62
+ end
48
63
 
49
64
  end # module Construct
50
65
 
@@ -6,23 +6,21 @@ module Construct
6
6
  extend self
7
7
 
8
8
  def within_construct(chdir=true)
9
- path = (Pathname(tmpdir)+"construct_container-#{$PROCESS_ID}-#{rand(1_000_000_000)}")
10
- begin
11
- path.mkpath
12
- path.extend(PathExtensions)
13
- path.construct__chdir_default = chdir
14
- maybe_change_dir(chdir,path) do
15
- yield(path)
16
- end
17
- ensure
18
- path.rmtree
9
+ container = create_construct(chdir)
10
+ container.maybe_change_dir(chdir) do
11
+ yield(container)
19
12
  end
13
+ ensure
14
+ container.destroy!
20
15
  end
21
16
 
22
- def tmpdir
23
- dir = nil
24
- Dir.chdir Dir.tmpdir do dir = Dir.pwd end # HACK FOR OSX
25
- dir
17
+ def create_construct(chdir=true)
18
+ path = (Pathname(Construct.tmpdir) +
19
+ "#{CONTAINER_PREFIX}-#{$PROCESS_ID}-#{rand(1_000_000_000)}")
20
+ path.mkpath
21
+ path.extend(PathExtensions)
22
+ path.construct__chdir_default = chdir
23
+ path
26
24
  end
27
25
 
28
26
  end
@@ -7,7 +7,7 @@ module Construct
7
7
  subdir = (self + path)
8
8
  subdir.mkpath
9
9
  subdir.extend(PathExtensions)
10
- maybe_change_dir(chdir,subdir) do
10
+ subdir.maybe_change_dir(chdir) do
11
11
  yield(subdir) if block_given?
12
12
  end
13
13
  subdir
@@ -30,13 +30,23 @@ module Construct
30
30
  path
31
31
  end
32
32
 
33
- def maybe_change_dir(chdir,path,&block)
33
+ def maybe_change_dir(chdir, &block)
34
34
  if(chdir)
35
- Dir.chdir(path,&block)
35
+ self.chdir(&block)
36
36
  else
37
37
  block.call
38
38
  end
39
39
  end
40
40
 
41
+ # Note: Pathname implements #chdir directly, but it is deprecated in favor
42
+ # of Dir.chdir
43
+ def chdir(&block)
44
+ Dir.chdir(self, &block)
45
+ end
46
+
47
+ def destroy!
48
+ rmtree
49
+ end
50
+
41
51
  end
42
52
  end
@@ -9,13 +9,17 @@ require 'mocha'
9
9
  class ConstructTest < Test::Unit::TestCase
10
10
  include Construct::Helpers
11
11
 
12
+ def teardown
13
+ Construct.destroy_all!
14
+ end
15
+
12
16
  testing 'using within_construct explicitly' do
13
17
 
14
18
  test 'creates construct' do
15
19
  num = rand(1_000_000_000)
16
20
  Construct.stubs(:rand).returns(num)
17
21
  Construct::within_construct do |construct|
18
- assert File.directory?(File.join(Construct::Helpers::tmpdir, "construct_container-#{$PROCESS_ID}-#{num}"))
22
+ assert File.directory?(File.join(Construct.tmpdir, "construct_container-#{$PROCESS_ID}-#{num}"))
19
23
  end
20
24
  end
21
25
 
@@ -27,7 +31,7 @@ class ConstructTest < Test::Unit::TestCase
27
31
  num = rand(1_000_000_000)
28
32
  self.stubs(:rand).returns(num)
29
33
  within_construct do |construct|
30
- assert File.directory?(File.join(Construct::Helpers::tmpdir, "construct_container-#{$PROCESS_ID}-#{num}"))
34
+ assert File.directory?(File.join(Construct.tmpdir, "construct_container-#{$PROCESS_ID}-#{num}"))
31
35
  end
32
36
  end
33
37
 
@@ -43,7 +47,7 @@ class ConstructTest < Test::Unit::TestCase
43
47
  num = rand(1_000_000_000)
44
48
  self.stubs(:rand).returns(num)
45
49
  within_construct do |container_path|
46
- expected_path = (Pathname(Construct::Helpers.tmpdir) +
50
+ expected_path = (Pathname(Construct.tmpdir) +
47
51
  "construct_container-#{$PROCESS_ID}-#{num}")
48
52
  assert_equal(expected_path, container_path)
49
53
  end
@@ -417,4 +421,42 @@ Contents
417
421
 
418
422
  end
419
423
 
424
+ testing "#create_construct" do
425
+ test "returns a working Construct" do
426
+ it = create_construct
427
+ it.directory "foo"
428
+ it.file "bar", "CONTENTS"
429
+ assert (it + "foo").directory?
430
+ assert_equal "CONTENTS", (it + "bar").read
431
+ end
432
+ end
433
+
434
+ testing "#chdir" do
435
+ test "executes its block in the context of the construct" do
436
+ it = create_construct
437
+ assert_not_equal it.to_s, Dir.pwd
438
+ sensor = :unset
439
+ it.chdir do
440
+ sensor = Dir.pwd
441
+ end
442
+ assert_equal it.to_s, sensor
443
+ end
444
+
445
+ test "leaves construct directory on block exit" do
446
+ it = create_construct
447
+ it.chdir do
448
+ # NOOP
449
+ end
450
+ assert_not_equal it.to_s, Dir.pwd
451
+ end
452
+ end
453
+
454
+ testing "#destroy!" do
455
+ test "removes the construct container" do
456
+ it = create_construct
457
+ it.destroy!
458
+ assert !File.exist?(it.to_s)
459
+ end
460
+ end
461
+
420
462
  end
@@ -1,6 +1,5 @@
1
1
  require 'rubygems'
2
2
  require 'test/unit'
3
- require 'pending'
4
3
 
5
4
  class Test::Unit::TestCase
6
5
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devver-construct
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Brinckerhoff (ben@devver.net) and Avdi Grimm (avdi@devver.net)
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-08-18 00:00:00 -07:00
12
+ date: 2009-09-09 00:00:00 -07:00
13
13
  default_executable: construct
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -42,6 +42,11 @@ extra_rdoc_files:
42
42
  - History.txt
43
43
  - bin/construct
44
44
  files:
45
+ - .devver/devver_opts.yml
46
+ - .devver/hooks/build
47
+ - .devver/hooks/install_dependencies
48
+ - .devver/hooks/notify
49
+ - .devver/hooks/prepare_database
45
50
  - History.txt
46
51
  - README.markdown
47
52
  - Rakefile
@@ -78,7 +83,6 @@ files:
78
83
  - test/test_helper.rb
79
84
  has_rdoc: true
80
85
  homepage: http://github.com/devver/construct
81
- licenses:
82
86
  post_install_message:
83
87
  rdoc_options:
84
88
  - --main
@@ -100,7 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
100
104
  requirements: []
101
105
 
102
106
  rubyforge_project: construct
103
- rubygems_version: 1.3.5
107
+ rubygems_version: 1.2.0
104
108
  signing_key:
105
109
  specification_version: 2
106
110
  summary: Construct is a DSL for creating temporary files and directories during testing.