pathutil 0.11.0 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pathutil.rb +11 -4
- data/lib/pathutil/helpers.rb +2 -2
- data/lib/pathutil/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7adeba9b30c364e3ee44b710c116d6b8f5c1618e
|
4
|
+
data.tar.gz: c411f1581b9aa43bb8950b8152996214b0f3d439
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f4098b97bc4f98a84a09dbc229c7ebe0e79577d5606fbc31ca2870268d8ecd905793bfe07d40e2a40ccb3d2cfbef1e2616029e61e4e2d1bf97cae9be8424577c
|
7
|
+
data.tar.gz: b906af65d158da1a5cf5178330d3e2cd899e1b74c640c9e59f7372a2b099203d4a677c3b200c11c8a7408f095937c92fdb4e52deccdd4b74a2c079acaa34e602
|
data/lib/pathutil.rb
CHANGED
@@ -107,7 +107,7 @@ class Pathutil
|
|
107
107
|
# --
|
108
108
|
def split_path
|
109
109
|
@path.split(
|
110
|
-
|
110
|
+
%r!\\+|/+!
|
111
111
|
)
|
112
112
|
end
|
113
113
|
|
@@ -258,7 +258,7 @@ class Pathutil
|
|
258
258
|
# @return true|false
|
259
259
|
# --
|
260
260
|
def root?
|
261
|
-
!!(self =~
|
261
|
+
!!(self =~ %r!\A(?:[A-Za-z]:)?(?:\\+|/+)\z!)
|
262
262
|
end
|
263
263
|
|
264
264
|
# --
|
@@ -577,6 +577,10 @@ class Pathutil
|
|
577
577
|
))
|
578
578
|
end
|
579
579
|
|
580
|
+
# --
|
581
|
+
# rubocop:disable Metrics/AbcSize
|
582
|
+
# rubocop:disable Metrics/CyclomaticComplexity
|
583
|
+
# rubocop:disable Metrics/PerceivedComplexity
|
580
584
|
# --
|
581
585
|
|
582
586
|
def aggressive_cleanpath
|
@@ -604,7 +608,7 @@ class Pathutil
|
|
604
608
|
# --
|
605
609
|
|
606
610
|
def conservative_cleanpath
|
607
|
-
_out =
|
611
|
+
_out = split_path.each_with_object([]) do |part, out|
|
608
612
|
next if part == "." || (part == ".." && out.last == "")
|
609
613
|
out.push(
|
610
614
|
part
|
@@ -621,11 +625,14 @@ class Pathutil
|
|
621
625
|
|
622
626
|
return self.class.new("/") if _out == [""].freeze
|
623
627
|
return self.class.new(".") if _out.empty? && (end_with?(".") || relative?)
|
624
|
-
return self.class.new(_out.join("/")).join("") if @path =~
|
628
|
+
return self.class.new(_out.join("/")).join("") if @path =~ %r!/\z! && _out.last != "." && _out.last != ".."
|
625
629
|
self.class.new(_out.join("/"))
|
626
630
|
end
|
627
631
|
|
628
632
|
# --
|
633
|
+
# rubocop:enable Metrics/AbcSize
|
634
|
+
# rubocop:enable Metrics/CyclomaticComplexity
|
635
|
+
# rubocop:enable Metrics/PerceivedComplexity
|
629
636
|
# Expand the paths and return.
|
630
637
|
# --
|
631
638
|
private
|
data/lib/pathutil/helpers.rb
CHANGED
@@ -20,8 +20,8 @@ class Pathutil
|
|
20
20
|
# @note We default aliases to yes so we can detect if you explicit true.
|
21
21
|
# @return Hash
|
22
22
|
# --
|
23
|
-
def load_yaml(data, safe: true, whitelist_classes:
|
24
|
-
whitelist_symbols:
|
23
|
+
def load_yaml(data, safe: true, whitelist_classes: allowed[:yaml][:classes], \
|
24
|
+
whitelist_symbols: allowed[:yaml][:symbols], aliases: :yes)
|
25
25
|
|
26
26
|
require "yaml"
|
27
27
|
unless safe
|
data/lib/pathutil/version.rb
CHANGED