eac_ruby_utils 0.32.1 → 0.33.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: c3b4252e76ab06f5b59322d5fda1ef5449a96902fc2fd1dd0d8351b9b158d82e
4
- data.tar.gz: 9d75843b64980304d25951adda38219e9b0ef7d8053af3cbd5b2d36bc4fefa86
3
+ metadata.gz: 3a1862278458f2d12656dde6da578afba1edacaa582971511f39ecf04d30f080
4
+ data.tar.gz: 9b1d192e277da7a4fd5f740223161a08b98076498fe849291dfd8ef6a35c4d99
5
5
  SHA512:
6
- metadata.gz: 23b52276403c3eef53b6239b1095e1e58eec87fb9d00c3c8fa8b0ea06b12e1292951dab3b58ad4068922c7f6020309c73ec8b9f00d2ae678847f37b8fc959669
7
- data.tar.gz: 8e352a0818a7c7aa7392e8b8333db4dfabcd7d31f9a4a06e19177c3d44405f6cdc4e4ccda099d28407942cd1f0c18f033c07163e99bfc5492eb392ad885c1041
6
+ metadata.gz: 5a6b73a58b94e8e7670dffb850d66e1453b51ecf21dee4dbff6181506f4cbdeebc31af724dc60e7fc1495db5a5cf77756edc32823f5b058cd53a61dd6e936c2b
7
+ data.tar.gz: 1845a0dd4dea2c126781bd197b61d28fc44ac8a9b873a355453433c56b495862663d6e5ee7d8fbfbd553bf2a03520f9fd03349deb6e5a7640617741b2e626e72
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EacRubyUtils
4
+ module Fs
5
+ class << self
6
+ # A [File.extname] which find multiple extensions (Ex.: .tar.gz).
7
+ def extname(path, limit = -1)
8
+ recursive_extension(::File.basename(path), limit)
9
+ end
10
+
11
+ # Shortcut to +extname(2)+.
12
+ def extname2(path)
13
+ extname(path, 2)
14
+ end
15
+
16
+ private
17
+
18
+ def recursive_extension(basename, limit)
19
+ return '' if limit.zero?
20
+
21
+ m = /\A(.+)(\.[a-z][a-z0-9]*)\z/i.match(basename)
22
+ if m
23
+ "#{recursive_extension(m[1], limit - 1)}#{m[2]}"
24
+ else
25
+ ''
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRubyUtils
4
- VERSION = '0.32.1'
4
+ VERSION = '0.33.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eac_ruby_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.32.1
4
+ version: 0.33.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esquilo Azul Company
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-12 00:00:00.000000000 Z
11
+ date: 2020-05-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -140,6 +140,7 @@ files:
140
140
  - lib/eac_ruby_utils/envs/ssh_env.rb
141
141
  - lib/eac_ruby_utils/filesystem_cache.rb
142
142
  - lib/eac_ruby_utils/fs.rb
143
+ - lib/eac_ruby_utils/fs/extname.rb
143
144
  - lib/eac_ruby_utils/fs/temp.rb
144
145
  - lib/eac_ruby_utils/fs/temp/directory.rb
145
146
  - lib/eac_ruby_utils/fs/temp/file.rb