lx 1.1 → 1.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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/lx.rb +9 -7
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '0129287631d7874f63195026285a321e29b8beb2ed2959a02d6ed59a7edda3ba'
4
- data.tar.gz: 3b2ce691ff835795825aae039084bfa68a908b275028d3d4ec5a58b37d26c16b
3
+ metadata.gz: d8b2a5569804633e4f09068a5c1384c144c441cd27f6c06fb4ff013cc1c72ca2
4
+ data.tar.gz: 2d869403ffb6026c80b433f7ec3145bd3980015f0ceb697d7524ba3c5738bd50
5
5
  SHA512:
6
- metadata.gz: e5b6723a4103a00ba8769c6a60d696481d3048e5359b7448ab3afa5d35d5ded07f6d271b214a67eead90ce9c62718245b48d851b4f49d47a31ead16175bf1bcc
7
- data.tar.gz: e06b0f7724126c604993825f5640f5fcd18cbbbf7526282a17f745e82a912c68602f052f4d3aca2d8998ef62538e1b416830b73e5a6540f1ceb17857adcc4ca5
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. For now, it only contains the randstr method.
6
+ # class.
7
7
  module LX
8
8
  # version
9
- VERSION = '1.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
- # $tm.hrm
462
- temp_path do |path_tmp|
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`
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lx
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.1'
4
+ version: '1.2'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike O'Sullivan