devver-construct 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,4 @@
1
+ == 1.0.0 / 2009-08-18
2
+
3
+ * 1 major enhancement
4
+ * Birthday!
@@ -0,0 +1,144 @@
1
+ Construct
2
+ =========
3
+ by Ben Brinckerhoff and Avdi Grimm
4
+ http://github.com/devver/construct
5
+
6
+ DESCRIPTION:
7
+ ============
8
+
9
+ "This is the construct. It's our loading program. We can load anything, from clothing to equipment, weapons, and training simulations, anything we need" -- Morpheus
10
+
11
+ Construct is a DSL for creating temporary files and directories during testing.
12
+
13
+ SYNOPSIS:
14
+ ========
15
+
16
+ class ExampleTest < Test::Unit::TestCase
17
+ include Construct::Helpers
18
+
19
+ def test_example
20
+ within_construct do |c|
21
+ c.directory 'alice/rabbithole' do |d|
22
+ d.file 'white_rabbit.txt', "I'm late!"
23
+
24
+ assert_equal "I'm late!", File.read('white_rabbit.txt')
25
+ end
26
+ end
27
+ end
28
+
29
+ end
30
+
31
+ USAGE
32
+ =====
33
+
34
+ To use Construct, you need to include the Construct module in your class like so:
35
+
36
+ include Construct::Helpers
37
+
38
+ Using construct is as simple as calling `within_construct` and providing a block. All files and directories that are created within that block are created within a temporary directory. The temporary directory is always deleted before `within_construct` finishes.
39
+
40
+ There is nothing special about the files and directories created with Construct, so you can use plain old Ruby IO methods to interact with them.
41
+
42
+ Creating files
43
+ --------------
44
+
45
+ The most basic use of Construct is creating an empty file with the:
46
+
47
+ within_construct do |construct|
48
+ construct.file('foo.txt')
49
+ end
50
+
51
+ Note that the working directory is, by default, automatically change to the temporary directory created by Construct, so the following assertion will pass:
52
+
53
+ within_construct do |construct|
54
+ construct.file('foo.txt')
55
+ assert File.exist?('foo.txt')
56
+ end
57
+
58
+ You can also provide content for the file, either with an optional argument or using the return value of a supplied block:
59
+
60
+ within_construct do |construct|
61
+ construct.file('foo.txt','Here is some content')
62
+ construct.file('bar.txt') do
63
+ <<-EOS
64
+ The block will return this string, which will be used as the content.
65
+ EOS
66
+ end
67
+ end
68
+
69
+ If you provide block that accepts a parameter, construct will pass you the IO object. In this case, you are responsible for writing content to the file yourself - the return value of the block will not be used:
70
+
71
+ within_construct do |construct|
72
+ construct.file('foo.txt') do |file|
73
+ file << "Some content\n"
74
+ file << "Some more content"
75
+ end
76
+ end
77
+
78
+ Finally, you can provide the entire path to a file and the parent directories will be created automatically:
79
+
80
+ within_construct do |construct|
81
+ construct.file('foo/bar/baz.txt')
82
+ end
83
+
84
+ Creating directories
85
+ --------------
86
+
87
+ It is easy to create a directory:
88
+
89
+ within_construct do |construct|
90
+ construct.directory('foo')
91
+ end
92
+
93
+ You can also provide a block. The object passed to the block can be used to create nested files and directories (it's just a [Pathname](http://www.ruby-doc.org/stdlib/libdoc/pathname/rdoc/index.html) instance with some extra functionality, so you can use it to get the path of the current directory).
94
+
95
+ Again, note that the working directory is automatically changed while in the block:
96
+
97
+ within_construct do |construct|
98
+ construct.directory('foo') do |dir|
99
+ dir.file('bar.txt')
100
+ assert File.exist?('bar.txt') # This assertion will pass
101
+ end
102
+ end
103
+
104
+ Again, you can provide paths and the necessary directories will be automatically created:
105
+
106
+ within_construct do |construct|
107
+ construct.directory('foo/bar/') do |dir|
108
+ dir.directory('baz')
109
+ dir.directory('bazz')
110
+ end
111
+ end
112
+
113
+ Please read test/construct_test.rb for more examples.
114
+
115
+ INSTALL
116
+ =======
117
+
118
+ gem install devver-construct --source http://gems.github.com
119
+
120
+ LICENSE
121
+ =======
122
+
123
+ (The MIT License)
124
+
125
+ Copyright (c) 2009
126
+
127
+ Permission is hereby granted, free of charge, to any person obtaining
128
+ a copy of this software and associated documentation files (the
129
+ 'Software'), to deal in the Software without restriction, including
130
+ without limitation the rights to use, copy, modify, merge, publish,
131
+ distribute, sublicense, and/or sell copies of the Software, and to
132
+ permit persons to whom the Software is furnished to do so, subject to
133
+ the following conditions:
134
+
135
+ The above copyright notice and this permission notice shall be
136
+ included in all copies or substantial portions of the Software.
137
+
138
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
139
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
140
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
141
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
142
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
143
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
144
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,36 @@
1
+ # Look in the tasks/setup.rb file for the various options that can be
2
+ # configured in this Rakefile. The .rake files in the tasks directory
3
+ # are where the options are used.
4
+
5
+ begin
6
+ require 'bones'
7
+ Bones.setup
8
+ rescue LoadError
9
+ begin
10
+ load 'tasks/setup.rb'
11
+ rescue LoadError
12
+ raise RuntimeError, '### please install the "bones" gem ###'
13
+ end
14
+ end
15
+
16
+ ensure_in_path 'lib'
17
+ require 'construct'
18
+
19
+ task :default => 'test'
20
+
21
+ PROJ.name = 'construct'
22
+
23
+ PROJ.authors = 'Ben Brinckerhoff (ben@devver.net) and Avdi Grimm (avdi@devver.net)'
24
+ PROJ.email = 'ben@devver.net, avdi@devver.net'
25
+ PROJ.url = 'http://github.com/devver/construct'
26
+ PROJ.version = Construct::VERSION
27
+ PROJ.rubyforge.name = 'construct'
28
+ PROJ.test.files = FileList['test/**/*_test.rb']
29
+ PROJ.ruby_opts = []
30
+ PROJ.readme_file = "README.markdown"
31
+ PROJ.summary = "Construct is a DSL for creating temporary files and directories during testing."
32
+ PROJ.ignore_file = ".gitignore"
33
+
34
+ PROJ.gem.development_dependencies << ["jeremymcanally-pending", "~> 0.1"]
35
+
36
+ # EOF
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require File.expand_path(
4
+ File.join(File.dirname(__FILE__), %w[.. lib construct]))
5
+
6
+ # Put your code here
7
+
8
+ # EOF
@@ -0,0 +1,29 @@
1
+ --- !ditz.rubyforge.org,2008-03-06/issue
2
+ title: Fix Construct::VERSION to not conflict with other VERSION constants when Constuct is included
3
+ desc: |-
4
+ We have two options:
5
+ 1. We could move the includable module to a submodule on Construct, so VERSION would not be added
6
+ 2. We could change VERSION to CONSTRUCT_VERSION or something
7
+ type: :feature
8
+ component: construct
9
+ release: neo
10
+ reporter: Benjamin Brinckerhoff <ben@devver.net>
11
+ status: :closed
12
+ disposition: :fixed
13
+ creation_time: 2009-08-18 17:16:31.006045 Z
14
+ references: []
15
+
16
+ id: 0127c8c6ba1d31b5488f4551f8d869e57d53956d
17
+ log_events:
18
+ - - 2009-08-18 17:16:33.750549 Z
19
+ - Benjamin Brinckerhoff <ben@devver.net>
20
+ - created
21
+ - ""
22
+ - - 2009-08-18 18:23:37.187486 Z
23
+ - Avdi Grimm <avdi@avdi.org>
24
+ - changed status from unstarted to in_progress
25
+ - ""
26
+ - - 2009-08-18 19:23:37.387572 Z
27
+ - Avdi Grimm <avdi@avdi.org>
28
+ - closed with disposition fixed
29
+ - Moved test helpers to Construct::Helpers
@@ -0,0 +1,22 @@
1
+ --- !ditz.rubyforge.org,2008-03-06/issue
2
+ title: Make it possible to use Construct without including the module
3
+ desc: E.g. Construct.within_construct do ... end
4
+ type: :feature
5
+ component: construct
6
+ release: neo
7
+ reporter: Avdi Grimm <avdi@avdi.org>
8
+ status: :closed
9
+ disposition: :fixed
10
+ creation_time: 2009-08-18 18:08:34.555757 Z
11
+ references: []
12
+
13
+ id: 404e5da7b128e5b34e7a33fbcd56603618010d92
14
+ log_events:
15
+ - - 2009-08-18 18:08:37.083969 Z
16
+ - Avdi Grimm <avdi@avdi.org>
17
+ - created
18
+ - ""
19
+ - - 2009-08-18 20:06:07.792831 Z
20
+ - Benjamin Brinckerhoff <ben@devver.net>
21
+ - closed with disposition fixed
22
+ - ""
@@ -0,0 +1,23 @@
1
+ --- !ditz.rubyforge.org,2008-03-06/issue
2
+ title: Add gemspec file
3
+ desc: We'll need to be sure to include all our dependencies. Note that some dependencies (like Mocha) are only necessary if the user wants to run our tests.
4
+ type: :task
5
+ component: construct
6
+ release: neo
7
+ reporter: Benjamin Brinckerhoff <ben@devver.net>
8
+ status: :closed
9
+ disposition: :fixed
10
+ creation_time: 2009-08-18 17:18:22.309778 Z
11
+ references: []
12
+
13
+ id: 50798912193be32b1dc610d949a557b3860d96fd
14
+ log_events:
15
+ - - 2009-08-18 17:18:23.566713 Z
16
+ - Benjamin Brinckerhoff <ben@devver.net>
17
+ - created
18
+ - ""
19
+ - - 2009-08-18 19:37:27.228428 Z
20
+ - Avdi Grimm <avdi@devver.net>
21
+ - closed with disposition fixed
22
+ - This was closed by adding Bones-ifying the project
23
+ git_branch:
@@ -0,0 +1,22 @@
1
+ --- !ditz.rubyforge.org,2008-03-06/issue
2
+ title: Block form of file creation yields file IO object
3
+ desc: ""
4
+ type: :feature
5
+ component: construct
6
+ release: neo
7
+ reporter: Avdi Grimm <avdi@avdi.org>
8
+ status: :closed
9
+ disposition: :fixed
10
+ creation_time: 2009-08-18 15:17:32.937884 Z
11
+ references: []
12
+
13
+ id: 5a10ec7298127df3c62255ea59e01dcf831ff1d3
14
+ log_events:
15
+ - - 2009-08-18 15:17:37.603386 Z
16
+ - Avdi Grimm <avdi@avdi.org>
17
+ - created
18
+ - ""
19
+ - - 2009-08-18 15:26:09.385442 Z
20
+ - Benjamin Brinckerhoff <ben@devver.net>
21
+ - closed with disposition fixed
22
+ - ""
@@ -0,0 +1,18 @@
1
+ --- !ditz.rubyforge.org,2008-03-06/issue
2
+ title: Switch to development/release branch structure
3
+ desc: ""
4
+ type: :task
5
+ component: construct
6
+ release: neo
7
+ reporter: Avdi Grimm <avdi@avdi.org>
8
+ status: :unstarted
9
+ disposition:
10
+ creation_time: 2009-08-18 18:22:21.091404 Z
11
+ references: []
12
+
13
+ id: 67f704f8b7190ccc1157eec007c3d584779dc805
14
+ log_events:
15
+ - - 2009-08-18 18:22:23.004080 Z
16
+ - Avdi Grimm <avdi@avdi.org>
17
+ - created
18
+ - ""
@@ -0,0 +1,22 @@
1
+ --- !ditz.rubyforge.org,2008-03-06/issue
2
+ title: Write synoposis with examples
3
+ desc: We need to give the basic usage for construct.
4
+ type: :task
5
+ component: construct
6
+ release: neo
7
+ reporter: Benjamin Brinckerhoff <ben@devver.net>
8
+ status: :closed
9
+ disposition: :fixed
10
+ creation_time: 2009-08-18 17:19:03.766097 Z
11
+ references: []
12
+
13
+ id: 881ae950569b6ca718fae0060f2751710b972fd2
14
+ log_events:
15
+ - - 2009-08-18 17:19:04.502056 Z
16
+ - Benjamin Brinckerhoff <ben@devver.net>
17
+ - created
18
+ - ""
19
+ - - 2009-08-18 20:15:40.057331 Z
20
+ - Benjamin Brinckerhoff <ben@devver.net>
21
+ - closed with disposition fixed
22
+ - ""
@@ -0,0 +1,22 @@
1
+ --- !ditz.rubyforge.org,2008-03-06/issue
2
+ title: Add files to make construct a proper gem
3
+ desc: We'll need a Rakefile, a license.txt, an authors file, and will want to move tests to their own directory. Also, we'll need a gemspec file
4
+ type: :task
5
+ component: construct
6
+ release: neo
7
+ reporter: Benjamin Brinckerhoff <ben@devver.net>
8
+ status: :closed
9
+ disposition: :fixed
10
+ creation_time: 2009-08-18 15:31:45.185804 Z
11
+ references: []
12
+
13
+ id: bc8dfdf3834bb84b1d942ab2a90ac8c82b4389fb
14
+ log_events:
15
+ - - 2009-08-18 15:31:49.976522 Z
16
+ - Benjamin Brinckerhoff <ben@devver.net>
17
+ - created
18
+ - ""
19
+ - - 2009-08-18 20:19:55.937027 Z
20
+ - Benjamin Brinckerhoff <ben@devver.net>
21
+ - closed with disposition fixed
22
+ - ""
@@ -0,0 +1,18 @@
1
+ --- !ditz.rubyforge.org,2008-03-06/issue
2
+ title: Make Dir.chdir play nicely with ruby-debug
3
+ desc: ""
4
+ type: :bugfix
5
+ component: construct
6
+ release: neo
7
+ reporter: Avdi Grimm <avdi@avdi.org>
8
+ status: :unstarted
9
+ disposition:
10
+ creation_time: 2009-08-18 15:21:33.793706 Z
11
+ references: []
12
+
13
+ id: d05e9a907202348d47c4bf92062c1f4673dcae68
14
+ log_events:
15
+ - - 2009-08-18 15:21:37.449671 Z
16
+ - Avdi Grimm <avdi@avdi.org>
17
+ - created
18
+ - ""
@@ -0,0 +1,20 @@
1
+ --- !ditz.rubyforge.org,2008-03-06/issue
2
+ title: replace rand with counter
3
+ desc: |-
4
+ Use a counter instead of a random number for container naming
5
+ Should be process-wide (and probably threadsafe).
6
+ type: :feature
7
+ component: construct
8
+ release: neo
9
+ reporter: Avdi Grimm <avdi@avdi.org>
10
+ status: :unstarted
11
+ disposition:
12
+ creation_time: 2009-08-18 15:20:57.785823 Z
13
+ references: []
14
+
15
+ id: f30a3db19d917f8e72ca8689e099ef0cb2681fd3
16
+ log_events:
17
+ - - 2009-08-18 15:21:00.057673 Z
18
+ - Avdi Grimm <avdi@avdi.org>
19
+ - created
20
+ - ""
@@ -0,0 +1,16 @@
1
+ --- !ditz.rubyforge.org,2008-03-06/project
2
+ name: construct
3
+ version: "0.5"
4
+ components:
5
+ - !ditz.rubyforge.org,2008-03-06/component
6
+ name: construct
7
+ releases:
8
+ - !ditz.rubyforge.org,2008-03-06/release
9
+ name: neo
10
+ status: :unreleased
11
+ release_time:
12
+ log_events:
13
+ - - 2009-08-18 14:58:47.209904 Z
14
+ - Avdi Grimm <avdi@avdi.org>
15
+ - created
16
+ - Initial release
@@ -0,0 +1,40 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{construct}
5
+ s.version = "1.0.0"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Ben Brinckerhoff (ben@devver.net) and Avdi Grimm (avdi@devver.net)"]
9
+ s.date = %q{2009-08-18}
10
+ s.default_executable = %q{construct}
11
+ s.description = %q{}
12
+ s.email = %q{ben@devver.net, avdi@devver.net}
13
+ s.executables = ["construct"]
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"]
16
+ s.has_rdoc = true
17
+ s.homepage = %q{http://github.com/devver/construct}
18
+ s.rdoc_options = ["--main", "README.markdown"]
19
+ s.require_paths = ["lib"]
20
+ s.rubyforge_project = %q{construct}
21
+ s.rubygems_version = %q{1.3.1}
22
+ s.summary = %q{Construct is a DSL for creating temporary files and directories during testing.}
23
+ s.test_files = ["test/construct_test.rb"]
24
+
25
+ if s.respond_to? :specification_version then
26
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
27
+ s.specification_version = 2
28
+
29
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
30
+ s.add_development_dependency(%q<bones>, [">= 2.5.1"])
31
+ s.add_development_dependency(%q<jeremymcanally-pending>, ["~> 0.1"])
32
+ else
33
+ s.add_dependency(%q<bones>, [">= 2.5.1"])
34
+ s.add_dependency(%q<jeremymcanally-pending>, ["~> 0.1"])
35
+ end
36
+ else
37
+ s.add_dependency(%q<bones>, [">= 2.5.1"])
38
+ s.add_dependency(%q<jeremymcanally-pending>, ["~> 0.1"])
39
+ end
40
+ end