backports 1.8.1 → 1.8.2

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.
@@ -1,5 +1,20 @@
1
1
  = Packable --- History
2
2
 
3
+ == Version 1.8.2 - September 3rd, 2009
4
+
5
+ Added Dir.mktmpdir for older version of 1.8.6
6
+
7
+ == Version 1.8.1 - September 1st, 2009
8
+
9
+ Added the alias String#lines (Ruby 1.8.7)
10
+
11
+ == Version 1.8 - August 30, 2009
12
+
13
+ Backports can be required selectively:
14
+ * backports/1.8.7
15
+ * backports/1.9 (which include 1.8.7)
16
+ * rails
17
+
3
18
  == Version 1.8 - August 30, 2009
4
19
 
5
20
  Backports can be required selectively:
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 1
3
3
  :minor: 8
4
- :patch: 1
4
+ :patch: 2
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{backports}
8
- s.version = "1.8.1"
8
+ s.version = "1.8.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Marc-Andr\303\251 Lafortune"]
12
- s.date = %q{2009-09-01}
12
+ s.date = %q{2009-09-03}
13
13
  s.description = %q{ Essential backports that enable some of the really nice features of ruby 1.8.7, ruby 1.9 and rails from ruby 1.8.6 and earlier.
14
14
  }
15
15
  s.email = %q{github@marc-andre.ca}
@@ -2,6 +2,48 @@ class Dir
2
2
  Backports.make_block_optional self, :each, :test_on => Dir.new(".")
3
3
  class << self
4
4
  Backports.make_block_optional self, :foreach, :test_on => Dir, :arg => "."
5
+
6
+ def mktmpdir(prefix_suffix=nil, tmpdir=nil)
7
+ raise NoMethodError, "undefined method `mktmpdir' for Dir:Class; you must require 'tmpdir'" unless Dir.method_defined? :tmpdir
8
+
9
+ case prefix_suffix
10
+ when nil
11
+ prefix = "d"
12
+ suffix = ""
13
+ when String
14
+ prefix = prefix_suffix
15
+ suffix = ""
16
+ when Array
17
+ prefix = prefix_suffix[0]
18
+ suffix = prefix_suffix[1]
19
+ else
20
+ raise ArgumentError, "unexpected prefix_suffix: #{prefix_suffix.inspect}"
21
+ end
22
+ tmpdir ||= Dir.tmpdir
23
+ t = Time.now.strftime("%Y%m%d")
24
+ n = nil
25
+ begin
26
+ path = "#{tmpdir}/#{prefix}#{t}-#{$$}-#{rand(0x100000000).to_s(36)}"
27
+ path << "-#{n}" if n
28
+ path << suffix
29
+ Dir.mkdir(path, 0700)
30
+ rescue Errno::EEXIST
31
+ n ||= 0
32
+ n += 1
33
+ retry
34
+ end
35
+
36
+ if block_given?
37
+ begin
38
+ yield path
39
+ ensure
40
+ FileUtils.remove_entry_secure path
41
+ end
42
+ else
43
+ path
44
+ end
45
+ end unless method_defined? :mktmpdir
46
+
5
47
  end
6
48
  end
7
49
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: backports
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.1
4
+ version: 1.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - "Marc-Andr\xC3\xA9 Lafortune"
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-09-01 00:00:00 -04:00
12
+ date: 2009-09-03 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies: []
15
15