mkdtemp 1.2 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/ext/mkdtemp.c +40 -29
- data/lib/mkdtemp/version.rb +1 -24
- metadata +57 -11
data/ext/mkdtemp.c
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
// Copyright 2007-
|
1
|
+
// Copyright 2007-2011 Wincent Colaiuta. All rights reserved.
|
2
2
|
//
|
3
3
|
// Redistribution and use in source and binary forms, with or without
|
4
4
|
// modification, are permitted provided that the following conditions are met:
|
@@ -39,32 +39,43 @@ VALUE yield_block(VALUE ignored, VALUE block)
|
|
39
39
|
return rb_funcall(block, rb_intern("call"), 0);
|
40
40
|
}
|
41
41
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
42
|
+
/*
|
43
|
+
* @overload mkdtemp(template)
|
44
|
+
* Securely create a temporary directory.
|
45
|
+
*
|
46
|
+
* This method securely creates temporary directories. It is a wrapper for the
|
47
|
+
* <code>mkdtemp()</code> function in the standard C library.
|
48
|
+
*
|
49
|
+
* If supplied a block, performs a <code>Dir.chdir</code> into the created
|
50
|
+
* directory and yields to the block:
|
51
|
+
*
|
52
|
+
* @example
|
53
|
+
* # this: # is a shorthand for:
|
54
|
+
* Dir.mkdtemp do # dir = Dir.mkdtemp
|
55
|
+
* puts Dir.pwd # Dir.chdir dir do
|
56
|
+
* end # puts Dir.pwd
|
57
|
+
* # end
|
58
|
+
*
|
59
|
+
* @yield an optional block to perform operations inside the created directory.
|
60
|
+
* @param [String, nil] template a template describing the desired form of the
|
61
|
+
* directory name. If no template is supplied then "/tmp/temp.XXXXXX" is used
|
62
|
+
* as a default.
|
63
|
+
* @return [String] the path to the created directory
|
64
|
+
* @raise [TypeError] if <code>template</code> is not a String or cannot be
|
65
|
+
* converted into one
|
66
|
+
* @raise [SecurityError] if <code>template</code> is tainted and
|
67
|
+
* <code>$SAFE</code> is > 0
|
68
|
+
* @raise [NoMemoryError] if temporary storage for the template could not be
|
69
|
+
* allocated
|
70
|
+
* @raise [SystemCallError] if the call to <code>mkdtemp()</code> fails
|
71
|
+
*
|
72
|
+
* @note
|
73
|
+
* Note that the exact implementation of <code>mkdtemp()</code> may vary
|
74
|
+
* depending on the target system. For example, on Mac OS X at the time of
|
75
|
+
* writing, the man page states that the template may contain "some number" of
|
76
|
+
* "Xs" on the end of the string, whereas on Red Hat Enterprise Linux it states
|
77
|
+
* that the template suffix "must be XXXXXX".
|
78
|
+
*/
|
68
79
|
static VALUE dir_mkdtemp_m(int argc, VALUE *argv, VALUE self)
|
69
80
|
{
|
70
81
|
VALUE template, block;
|
@@ -95,7 +106,7 @@ static VALUE dir_mkdtemp_m(int argc, VALUE *argv, VALUE self)
|
|
95
106
|
rb_raise(rb_eSystemCallError, "mkdtemp failed (error #%d: %s)", errno, strerror(errno));
|
96
107
|
|
97
108
|
// yield to block if given, inside Dir.chdir
|
98
|
-
if (rb_block_given_p()
|
109
|
+
if (rb_block_given_p())
|
99
110
|
rb_iterate(call_chdir, template, yield_block, block);
|
100
111
|
return template;
|
101
112
|
}
|
@@ -103,7 +114,7 @@ static VALUE dir_mkdtemp_m(int argc, VALUE *argv, VALUE self)
|
|
103
114
|
void Init_mkdtemp()
|
104
115
|
{
|
105
116
|
#if 0
|
106
|
-
// for
|
117
|
+
// for YARD, need to fake this here
|
107
118
|
VALUE rb_cDir = rb_define_class("Dir", rb_cObject);
|
108
119
|
#endif
|
109
120
|
rb_define_singleton_method(rb_cDir, "mkdtemp", dir_mkdtemp_m, -1);
|
data/lib/mkdtemp/version.rb
CHANGED
@@ -1,28 +1,5 @@
|
|
1
|
-
# Copyright 2008-2010 Wincent Colaiuta. All rights reserved.
|
2
|
-
#
|
3
|
-
# Redistribution and use in source and binary forms, with or without
|
4
|
-
# modification, are permitted provided that the following conditions are met:
|
5
|
-
#
|
6
|
-
# 1. Redistributions of source code must retain the above copyright notice,
|
7
|
-
# this list of conditions and the following disclaimer.
|
8
|
-
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
9
|
-
# this list of conditions and the following disclaimer in the documentation
|
10
|
-
# and/or other materials provided with the distribution.
|
11
|
-
#
|
12
|
-
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
13
|
-
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
14
|
-
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
15
|
-
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
|
16
|
-
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
17
|
-
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
18
|
-
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
19
|
-
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
20
|
-
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
21
|
-
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
22
|
-
# POSSIBILITY OF SUCH DAMAGE.
|
23
|
-
|
24
1
|
class Dir
|
25
2
|
module Mkdtemp
|
26
|
-
VERSION = '1.2'
|
3
|
+
VERSION = '1.2.1'
|
27
4
|
end # module Mkdtemp
|
28
5
|
end # class Dir
|
metadata
CHANGED
@@ -1,11 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mkdtemp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 29
|
5
|
+
prerelease:
|
5
6
|
segments:
|
6
7
|
- 1
|
7
8
|
- 2
|
8
|
-
|
9
|
+
- 1
|
10
|
+
version: 1.2.1
|
9
11
|
platform: ruby
|
10
12
|
authors:
|
11
13
|
- Wincent Colaiuta
|
@@ -13,24 +15,65 @@ autorequire:
|
|
13
15
|
bindir: bin
|
14
16
|
cert_chain: []
|
15
17
|
|
16
|
-
date:
|
17
|
-
default_executable:
|
18
|
+
date: 2011-09-05 00:00:00 Z
|
18
19
|
dependencies:
|
19
20
|
- !ruby/object:Gem::Dependency
|
20
|
-
|
21
|
+
type: :development
|
21
22
|
prerelease: false
|
22
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
23
25
|
requirements:
|
24
26
|
- - ">="
|
25
27
|
- !ruby/object:Gem::Version
|
28
|
+
hash: 3
|
26
29
|
segments:
|
27
|
-
- 2
|
28
30
|
- 0
|
31
|
+
version: "0"
|
32
|
+
version_requirements: *id001
|
33
|
+
name: rake
|
34
|
+
- !ruby/object:Gem::Dependency
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
38
|
+
none: false
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
hash: 3
|
43
|
+
segments:
|
29
44
|
- 0
|
30
|
-
|
31
|
-
|
45
|
+
version: "0"
|
46
|
+
version_requirements: *id002
|
47
|
+
name: rcov
|
48
|
+
- !ruby/object:Gem::Dependency
|
32
49
|
type: :development
|
33
|
-
|
50
|
+
prerelease: false
|
51
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ~>
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
hash: 3
|
57
|
+
segments:
|
58
|
+
- 2
|
59
|
+
- 0
|
60
|
+
version: "2.0"
|
61
|
+
version_requirements: *id003
|
62
|
+
name: rspec
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
type: :development
|
65
|
+
prerelease: false
|
66
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
67
|
+
none: false
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
hash: 3
|
72
|
+
segments:
|
73
|
+
- 0
|
74
|
+
version: "0"
|
75
|
+
version_requirements: *id004
|
76
|
+
name: yard
|
34
77
|
description: " mkdtemp is a C extension that wraps the Standard C Library function\n of the same name to make secure creation of temporary directories\n easily available from within Ruby.\n"
|
35
78
|
email: win@wincent.com
|
36
79
|
executables: []
|
@@ -45,7 +88,6 @@ files:
|
|
45
88
|
- ext/ruby_compat.h
|
46
89
|
- ext/extconf.rb
|
47
90
|
- ext/depend
|
48
|
-
has_rdoc: false
|
49
91
|
homepage: https://wincent.com/products/mkdtemp
|
50
92
|
licenses: []
|
51
93
|
|
@@ -56,23 +98,27 @@ require_paths:
|
|
56
98
|
- ext
|
57
99
|
- lib
|
58
100
|
required_ruby_version: !ruby/object:Gem::Requirement
|
101
|
+
none: false
|
59
102
|
requirements:
|
60
103
|
- - ">="
|
61
104
|
- !ruby/object:Gem::Version
|
105
|
+
hash: 3
|
62
106
|
segments:
|
63
107
|
- 0
|
64
108
|
version: "0"
|
65
109
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
|
+
none: false
|
66
111
|
requirements:
|
67
112
|
- - ">="
|
68
113
|
- !ruby/object:Gem::Version
|
114
|
+
hash: 3
|
69
115
|
segments:
|
70
116
|
- 0
|
71
117
|
version: "0"
|
72
118
|
requirements: []
|
73
119
|
|
74
120
|
rubyforge_project: mkdtemp
|
75
|
-
rubygems_version: 1.
|
121
|
+
rubygems_version: 1.8.10
|
76
122
|
signing_key:
|
77
123
|
specification_version: 3
|
78
124
|
summary: Secure creation of temporary directories
|