pathutil 0.4.1 → 0.4.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 864e32b983eecdfbc1d928d509e4ca432ae92b4e
4
- data.tar.gz: 29d984696ed37007719707369022c6f015dd3744
3
+ metadata.gz: 2f764aa49d17400ee6d3e613e2d4402dc7ff69de
4
+ data.tar.gz: d362e2e9d92234bc1bc7dd7b32ee01d69de5b99d
5
5
  SHA512:
6
- metadata.gz: 4dde75fdcebede966d9ece517593bd1e8c6db7c4ee6cd91bba57a7218b185754dde2abe8f879d01c4132d9e3bc6437f6384128f407dca659c66173fb2055989e
7
- data.tar.gz: d8d52741f92e185cc132186439e9657c2422492cd8fafbed06057b5b4a0c6a417a046acab5101fd35233aeb6aa0b24dbfb21eceb0ad678c3c156fade8703ac9c
6
+ metadata.gz: fba4041a94c1abf33246e417ad6fe5361aaf8dddcdaf44eda11468e539e35a62c8e85b4a01e5ffd9665353f4ea3f0b10576bd8ecb23ade4db3099d9c9f6e15b3
7
+ data.tar.gz: af0114a98b2b63b3dcedcb74fae2e7610b659abf57e1aac225145d951e7c6d281363bb242d3b6f6e3aa50cfc3117bf82642a421fd8631b03a6e6224283572eb9
@@ -35,25 +35,51 @@ class Pathutil
35
35
  # ------------------------------------------------------------------------
36
36
 
37
37
  def make_tmpname(prefix = "", suffix = nil, root = nil)
38
- prefix = prefix.join("-") if prefix.is_a?(Array)
39
- suffix = suffix.join("-") if suffix.is_a?(Array)
40
- suffix = suffix.gsub(/\A\-/, "") unless !suffix || suffix.empty?
41
- prefix = prefix.gsub(/\-\Z/, "") + "-" unless prefix.empty?
42
- root ||= Dir::Tmpname.tmpdir
38
+ prefix = tmpname_prefix(prefix)
39
+ suffix = tmpname_suffix(suffix)
43
40
 
41
+ root ||= Dir::Tmpname.tmpdir
44
42
  File.join(root, Dir::Tmpname.make_tmpname(
45
43
  prefix, suffix
46
44
  ))
47
45
  end
48
46
 
49
47
  # ------------------------------------------------------------------------
50
- # rubocop:disable Metrics/LineLength
48
+
49
+ def tmpname_suffix(suffix)
50
+ suffix = suffix.join("-") if suffix.is_a?(Array)
51
+ suffix = suffix.gsub(/\A\-/, "") unless !suffix || suffix.empty?
52
+ suffix
53
+ end
54
+
55
+ # ------------------------------------------------------------------------
56
+ # rubocop:disable Style/ParallelAssignment
57
+ # ------------------------------------------------------------------------
58
+
59
+ private
60
+ def tmpname_prefix(prefix)
61
+ ext, prefix = prefix, "" if !prefix.is_a?(Array) && prefix.start_with?(".")
62
+ ext = prefix.pop if prefix.is_a?(Array) && prefix[-1].start_with?(".")
63
+ prefix = prefix.join("-") if prefix.is_a?(Array)
64
+
65
+ unless prefix.empty?
66
+ prefix = prefix.gsub(/\-\Z/, "") \
67
+ + "-"
68
+ end
69
+
70
+ return [
71
+ prefix, ext || ""
72
+ ]
73
+ end
74
+
75
+ # ------------------------------------------------------------------------
76
+ # rubocop:enable Style/ParallelAssignment
51
77
  # ------------------------------------------------------------------------
52
78
 
53
79
  private
54
80
  def setup_safe_yaml(whitelist_classes, aliases)
55
- warn "#{self.class.name}:WARN: SafeYAML does not support disabling of aliases." if aliases && aliases != :yes
56
- warn "#{self.class.name}:WARN: SafeYAML will be removed when Ruby 2.0 goes EOL."
81
+ warn "WARN: SafeYAML does not support disabling of aliases." if aliases && aliases != :yes
82
+ warn "WARN: SafeYAML will be removed when Ruby 2.0 goes EOL."
57
83
  require "safe_yaml/load"
58
84
 
59
85
  SafeYAML.restore_defaults!
@@ -5,5 +5,5 @@
5
5
  # ----------------------------------------------------------------------------
6
6
 
7
7
  class Pathutil
8
- VERSION = "0.4.1"
8
+ VERSION = "0.4.2"
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pathutil
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jordon Bedwell
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-04 00:00:00.000000000 Z
11
+ date: 2016-02-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: forwardable-extended