lx 1.1 → 1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lx.rb +9 -7
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d8b2a5569804633e4f09068a5c1384c144c441cd27f6c06fb4ff013cc1c72ca2
|
4
|
+
data.tar.gz: 2d869403ffb6026c80b433f7ec3145bd3980015f0ceb697d7524ba3c5738bd50
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1298853bbfca20fcd6ed0252a4a3eece73c023bbfecdc6cf8bda2ec3236614c8c3264c34a53b280b91a066dde7a30734a908a4a5b70f536d43d94020fb95e7b3
|
7
|
+
data.tar.gz: 2c14dbdec8137432b50ee8c0ebb8c6300e03f8b18dde67e897d0c529845c1ca953a11f9441ecd42c0bf9ab95bdd9c08ef2b36084a3fcca57d34ff0d67dec556e
|
data/lib/lx.rb
CHANGED
@@ -3,10 +3,10 @@
|
|
3
3
|
#
|
4
4
|
|
5
5
|
# The LX module is the home for utilities that don't particularly fit in one
|
6
|
-
# class.
|
6
|
+
# class.
|
7
7
|
module LX
|
8
8
|
# version
|
9
|
-
VERSION = '1.
|
9
|
+
VERSION = '1.2'
|
10
10
|
|
11
11
|
#---------------------------------------------------------------------------
|
12
12
|
# verbose
|
@@ -396,7 +396,7 @@ class LX::String
|
|
396
396
|
if @str.match(rx)
|
397
397
|
tmp = @str.dup.untaint
|
398
398
|
else
|
399
|
-
raise 'string-does-not-match-untaint-pattern'
|
399
|
+
raise 'string-does-not-match-untaint-pattern: ' + rx.to_s
|
400
400
|
end
|
401
401
|
end
|
402
402
|
|
@@ -458,13 +458,15 @@ class LX::File::Class
|
|
458
458
|
# Atomically writes content to the given path. Does so by creating a temp
|
459
459
|
# file, writing to it, then renaming the temp file to the final destination.
|
460
460
|
def atomic_write(path_final, content)
|
461
|
-
|
462
|
-
|
461
|
+
begin
|
462
|
+
path_tmp = path_final + '.' + rand.to_s.sub(/\A.*\./mu, '')
|
463
463
|
File.write path_tmp, content
|
464
464
|
File.rename path_tmp, path_final
|
465
|
+
ensure
|
466
|
+
if File.exist?(path_tmp)
|
467
|
+
File.delete path_tmp
|
468
|
+
end
|
465
469
|
end
|
466
|
-
|
467
|
-
# path_tmp = path_final + '.' + rand.to_s.sub(/\A.*\./mu, '')
|
468
470
|
end
|
469
471
|
|
470
472
|
# Creates a temporary path. Does *not* create a file. If, after the `do`
|