lib/sup/util.rb in sup-0.14.1.1 vs lib/sup/util.rb in sup-0.15.0
- old
+ new
@@ -6,10 +6,11 @@
require 'pathname'
require 'set'
require 'enumerator'
require 'benchmark'
require 'unicode'
+require 'fileutils'
## time for some monkeypatching!
class Symbol
unless method_defined? :to_proc
def to_proc
@@ -43,10 +44,21 @@
end
def touch_yourself; touch path end
end
+class File
+ # platform safe file.link which attempts a copy if hard-linking fails
+ def self.safe_link src, dest
+ begin
+ File.link src, dest
+ rescue
+ FileUtils.copy src, dest
+ end
+ end
+end
+
class Pathname
def human_size
s =
begin
size
@@ -117,11 +129,9 @@
class Header
# Convert to ASCII before trying to match with regexp
class Field
-
- EXTRACT_FIELD_NAME_RE = /\A([^\x00-\x1f\x7f-\xff :]+):\s*/no
class << self
def parse(field)
field = field.dup.to_s
field = field.fix_encoding!.ascii