files 0.0.4 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +3 -3
- data/files.gemspec +1 -1
- data/lib/files.rb +5 -6
- data/lib/files/version.rb +1 -1
- data/test/files_test.rb +10 -0
- metadata +4 -4
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Files
|
2
2
|
|
3
|
-
*a simple DSL for creating files and directories*
|
3
|
+
*a simple DSL for creating temporary files and directories*
|
4
4
|
|
5
5
|
## Usage
|
6
6
|
|
@@ -28,12 +28,12 @@ see `test/files_test.rb` for more examples
|
|
28
28
|
|
29
29
|
## TODO
|
30
30
|
|
31
|
-
* :path option -- specifying the
|
31
|
+
* :path option -- specifying the parent of the temporary dir (default: Dir.tmpdir)
|
32
32
|
* take a hash
|
33
33
|
* take a YAML file or string
|
34
34
|
* emit a hash
|
35
35
|
* emit a YAML file or string
|
36
|
-
* symlinks (?)
|
36
|
+
* support symlinks (?)
|
37
37
|
* specify file mode
|
38
38
|
* copy an entire data dir
|
39
39
|
* play nice with FakeFS (possibly with a :fake option)
|
data/files.gemspec
CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |s|
|
|
8
8
|
s.authors = ["Alex Chaffee"]
|
9
9
|
s.email = ["alex@stinky.com"]
|
10
10
|
s.homepage = ""
|
11
|
-
s.summary = %q{a simple DSL for creating files and directories}
|
11
|
+
s.summary = %q{a simple DSL for creating temporary files and directories}
|
12
12
|
s.description = %q{Sometimes you want to create a whole bunch of files at once, like when you're testing a tool that processes a whole bunch of files. The Files gem lets you cleanly specify those files and their contents inside your test code, instead of making you create a fixture directory and check it in to your repo. It puts them in a temporary directory and cleans up when your test is done.}
|
13
13
|
|
14
14
|
s.rubyforge_project = "files"
|
data/lib/files.rb
CHANGED
@@ -29,19 +29,18 @@ module Files
|
|
29
29
|
|
30
30
|
def initialize path, block, options
|
31
31
|
@root = path
|
32
|
-
@dirs = [
|
33
|
-
|
34
|
-
Dir.mkdir(path)
|
32
|
+
@dirs = []
|
33
|
+
dir path, &block
|
35
34
|
at_exit {FileUtils.rm_rf(path) if File.exists?(path)} if options[:remove]
|
36
|
-
|
37
|
-
instance_eval &block if block
|
38
35
|
end
|
39
36
|
|
40
37
|
def dir name, &block
|
41
38
|
path = "#{current}/#{name}"
|
42
39
|
Dir.mkdir path
|
43
40
|
@dirs << name
|
44
|
-
|
41
|
+
Dir.chdir(path) do
|
42
|
+
instance_eval &block if block
|
43
|
+
end
|
45
44
|
@dirs.pop
|
46
45
|
path
|
47
46
|
end
|
data/lib/files/version.rb
CHANGED
data/test/files_test.rb
CHANGED
@@ -85,3 +85,13 @@ end
|
|
85
85
|
assert { stuff == "#{dir}/stuff" }
|
86
86
|
assert { hello == "#{dir}/stuff/hello.txt" }
|
87
87
|
|
88
|
+
dir_inside_do_block = nil
|
89
|
+
dir = Files do
|
90
|
+
dir_inside_do_block = Dir.pwd
|
91
|
+
dir "xyzzy" do
|
92
|
+
assert("sets the current directory inside the dir block") { File.basename(Dir.pwd) == "xyzzy" }
|
93
|
+
end
|
94
|
+
end
|
95
|
+
assert("sets the current directory inside the Files block") { File.basename(dir_inside_do_block) == File.basename(dir) }
|
96
|
+
# note that we can't just compare the full paths because some OS's hard link their temp dir to different base paths
|
97
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: files
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -45,7 +45,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
45
45
|
version: '0'
|
46
46
|
segments:
|
47
47
|
- 0
|
48
|
-
hash: -
|
48
|
+
hash: -255388511158483173
|
49
49
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
@@ -54,13 +54,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
54
54
|
version: '0'
|
55
55
|
segments:
|
56
56
|
- 0
|
57
|
-
hash: -
|
57
|
+
hash: -255388511158483173
|
58
58
|
requirements: []
|
59
59
|
rubyforge_project: files
|
60
60
|
rubygems_version: 1.8.6
|
61
61
|
signing_key:
|
62
62
|
specification_version: 3
|
63
|
-
summary: a simple DSL for creating files and directories
|
63
|
+
summary: a simple DSL for creating temporary files and directories
|
64
64
|
test_files:
|
65
65
|
- test/data/cheez_doing_it_wrong.jpg
|
66
66
|
- test/files_test.rb
|