Skip to content

Commit 1cd24eb

Browse files
author
Ben Brinckerhoff
committed
Cleaned up the README.markdown and closed the bug
1 parent 80b23d9 commit 1cd24eb

File tree

2 files changed

+54
-45
lines changed

2 files changed

+54
-45
lines changed

README.markdown

+48-43
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ USAGE
3333

3434
To use Construct, you need to include the Construct module in your class like so:
3535

36-
include Construct
36+
include Construct::Helpers
3737

3838
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.
3939

@@ -44,76 +44,81 @@ Creating files
4444

4545
The most basic use of Construct is creating an empty file with the:
4646

47-
within_construct do |construct|
48-
construct.file('foo.txt')
49-
end
47+
within_construct do |construct|
48+
construct.file('foo.txt')
49+
end
5050

5151
Note that the working directory is, by default, automatically change to the temporary directory created by Construct, so the following assertion will pass:
5252

53-
within_construct do |construct|
54-
construct.file('foo.txt')
55-
assert File.exist?('foo.txt')
56-
end
53+
within_construct do |construct|
54+
construct.file('foo.txt')
55+
assert File.exist?('foo.txt')
56+
end
5757

5858
You can also provide content for the file, either with an optional argument or using the return value of a supplied block:
5959

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
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
6868

6969
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:
7070

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
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
7777

7878
Finally, you can provide the entire path to a file and the parent directories will be created automatically:
7979

80-
within_construct do |construct|
81-
construct.file('foo/bar/baz.txt')
82-
end
80+
within_construct do |construct|
81+
construct.file('foo/bar/baz.txt')
82+
end
8383

8484
Creating directories
8585
--------------
8686

8787
It is easy to create a directory:
8888

89-
within_construct do |construct|
90-
construct.directory('foo')
91-
end
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).
9294

93-
You can also provide a block. The object passed to the block can be used to create nested files and directories. Again, note that the working directory is automatically changed while in the block:
95+
Again, note that the working directory is automatically changed while in the block:
9496

95-
within_construct do |construct|
96-
construct.directory('foo') do |dir|
97-
dir.file('bar.txt')
98-
assert File.exist?('bar.txt') # This assertion will pass
99-
end
100-
end
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
101103

102104
Again, you can provide paths and the necessary directories will be automatically created:
103105

104-
within_construct do |construct|
105-
construct.directory('foo/bar/') do |dir|
106-
dir.directory('baz')
107-
dir.directory('bazz')
108-
end
109-
end
106+
within_construct do |construct|
107+
construct.directory('foo/bar/') do |dir|
108+
dir.directory('baz')
109+
dir.directory('bazz')
110+
end
111+
end
110112

113+
Please read test/construct_test.rb for more examples.
111114

112-
== INSTALL:
115+
INSTALL
116+
=======
113117

114118
gem install devver-construct --source http://gems.github.com
115119

116-
== LICENSE:
120+
LICENSE
121+
=======
117122

118123
(The MIT License)
119124

bugs/issue-881ae950569b6ca718fae0060f2751710b972fd2.yaml

+6-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ type: :task
55
component: construct
66
release: neo
77
reporter: Benjamin Brinckerhoff <[email protected]>
8-
status: :unstarted
9-
disposition:
8+
status: :closed
9+
disposition: :fixed
1010
creation_time: 2009-08-18 17:19:03.766097 Z
1111
references: []
1212

@@ -16,3 +16,7 @@ log_events:
1616
- Benjamin Brinckerhoff <[email protected]>
1717
- created
1818
- ""
19+
- - 2009-08-18 20:15:40.057331 Z
20+
- Benjamin Brinckerhoff <[email protected]>
21+
- closed with disposition fixed
22+
- ""

0 commit comments

Comments
 (0)