eac_ruby_utils 0.29.0 → 0.30.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cfb2a1fd2c1122f700f061be368854e35b9c47218bb558d6b5491eff3e0291fe
4
- data.tar.gz: e966b104345dd201267c09e719180e08b3c5f8c532a2b7819cd0fc733373a2a1
3
+ metadata.gz: 1680d184052f77a08665a26ef0516cf8d277be629bf77e2bb7f80aa567b15d78
4
+ data.tar.gz: e188807dabbcbebb5e8540769c568a9d3c67f77ac518710fc05aa9b97f63cbe7
5
5
  SHA512:
6
- metadata.gz: 0ac76c77d50a91fb42e22e9b8203e904483526f34be079a0011750664619a23cc488cc7750b1831aeef4dbc5f1b2a2f8597796d7cff3162c6cac86076e22b9b3
7
- data.tar.gz: 382fc3f33de11d79e4fd8e8ea9b03e2144f2be130c420a2a5d84ad347cfce0437cfc8db5f6fdb48acac4d21ecc7d41abf70517297351b9115f555bd51b2fdfe6
6
+ metadata.gz: c3f8f24fca00cca9810b832e1ba44b9c53c27e61dfea24e0ecdcc7e52bcf8978ab7ba8150e251931ed6bda483dcb5ba2f38c14afb8c03ac10eaeb84fba25921d
7
+ data.tar.gz: c0c5a84961622516f85d03120dd4be14d866977c148f0da7b28985b3e8e36274d298ad7c73770aaf11e27f0c9ff35af2840c1dd9411f8f9934fd2edd2db75efa
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'pathname'
4
+ require 'tempfile'
5
+
6
+ module EacRubyUtils
7
+ module Fs
8
+ # Utilities for temporary files.
9
+ module Temp
10
+ class << self
11
+ # @return [Pathname]
12
+ def file(*tempfile_args)
13
+ file = Tempfile.new(*tempfile_args)
14
+ r = ::Pathname.new(file.path)
15
+ file.close
16
+ file.unlink
17
+ r
18
+ end
19
+
20
+ # Run a block while a temporary file pathname is providade. The file is deleted when block
21
+ # is finished.
22
+ def on_file(*tempfile_args)
23
+ pathname = file(*tempfile_args)
24
+ begin
25
+ yield(pathname)
26
+ ensure
27
+ pathname.unlink if pathname.exist?
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_support/core_ext/object/blank'
4
+ require 'pathname'
5
+
6
+ class Object
7
+ # Convert +self+ to String and then to Pathname. Return nil if +self+ is +blank?+.
8
+ #
9
+ # @return [Pathname]
10
+ def to_pathname
11
+ return self if is_a?(::Pathname)
12
+
13
+ to_s.blank? ? nil : ::Pathname.new(to_s)
14
+ end
15
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRubyUtils
4
- VERSION = '0.29.0'
4
+ VERSION = '0.30.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eac_ruby_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.29.0
4
+ version: 0.30.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esquilo Azul Company
@@ -134,6 +134,7 @@ files:
134
134
  - lib/eac_ruby_utils/envs/ssh_env.rb
135
135
  - lib/eac_ruby_utils/filesystem_cache.rb
136
136
  - lib/eac_ruby_utils/fs.rb
137
+ - lib/eac_ruby_utils/fs/temp.rb
137
138
  - lib/eac_ruby_utils/fs/traversable.rb
138
139
  - lib/eac_ruby_utils/fs/traverser.rb
139
140
  - lib/eac_ruby_utils/fs_cache.rb
@@ -164,6 +165,7 @@ files:
164
165
  - lib/eac_ruby_utils/patches/object/asserts.rb
165
166
  - lib/eac_ruby_utils/patches/object/if_present.rb
166
167
  - lib/eac_ruby_utils/patches/object/template.rb
168
+ - lib/eac_ruby_utils/patches/object/to_pathname.rb
167
169
  - lib/eac_ruby_utils/patches/pathname.rb
168
170
  - lib/eac_ruby_utils/patches/pathname/basename_sub.rb
169
171
  - lib/eac_ruby_utils/paths_hash.rb