pathutil 0.8.0 → 0.9.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 +4 -4
- data/lib/pathutil.rb +31 -19
- data/lib/pathutil/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c10b81a9cf17f0652212fefb3a9b82467716c295
|
4
|
+
data.tar.gz: 3f336ad870a92910d1dc28fd4131b07366cd7581
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a9b1db57f38d02fb924c98aa1061dd5a8045aa9f3599b9e4be3896904d8cd0e9135ebb1ada4960dde3eb4c599825321d499b146f3b22e3414c73baeee0e94f9
|
7
|
+
data.tar.gz: 5c7c52a0373b8a7807d89ecdd7bafeba72a29ef3c9ac888832a29a4744e7273e266b7c88d6806562624c2d0243056fc181aa246890da485860f9843a6e3d172b
|
data/lib/pathutil.rb
CHANGED
@@ -413,16 +413,17 @@ class Pathutil
|
|
413
413
|
# --------------------------------------------------------------------------
|
414
414
|
# Copy a directory, allowing symlinks if the link falls inside of the root.
|
415
415
|
# This is indented for people who wish some safety to their copies.
|
416
|
+
# NOTE: Ignore is ignored on safe_copy file because it's explicit.
|
416
417
|
# --------------------------------------------------------------------------
|
417
418
|
|
418
|
-
def safe_copy(to, root: nil)
|
419
|
+
def safe_copy(to, root: nil, ignore: [])
|
419
420
|
raise ArgumentError, "must give a root" unless root
|
420
421
|
root = self.class.new(root)
|
421
422
|
to = self.class.new(to)
|
422
423
|
|
423
424
|
if directory?
|
424
425
|
safe_copy_directory(to, {
|
425
|
-
:root => root
|
426
|
+
:root => root, :ignore => ignore
|
426
427
|
})
|
427
428
|
|
428
429
|
else
|
@@ -552,6 +553,14 @@ class Pathutil
|
|
552
553
|
end
|
553
554
|
end
|
554
555
|
|
556
|
+
# --------------------------------------------------------------------------
|
557
|
+
|
558
|
+
def to_regexp(guard: true)
|
559
|
+
Regexp.new((guard ? "\\A" : "") + Regexp.escape(
|
560
|
+
self
|
561
|
+
))
|
562
|
+
end
|
563
|
+
|
555
564
|
# --------------------------------------------------------------------------
|
556
565
|
# Expand the paths and return.
|
557
566
|
# --------------------------------------------------------------------------
|
@@ -578,7 +587,9 @@ class Pathutil
|
|
578
587
|
# --------------------------------------------------------------------------
|
579
588
|
|
580
589
|
private
|
581
|
-
def safe_copy_directory(to, root: nil)
|
590
|
+
def safe_copy_directory(to, root: nil, ignore: [])
|
591
|
+
ignore = [ignore].flatten.uniq
|
592
|
+
|
582
593
|
if !in_path?(root)
|
583
594
|
raise Errno::EPERM, "#{self} not in #{
|
584
595
|
root
|
@@ -587,21 +598,23 @@ class Pathutil
|
|
587
598
|
else
|
588
599
|
to.mkdir_p unless to.exist?
|
589
600
|
children do |file|
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
601
|
+
unless ignore.any? { |path| file.in_path?(path) }
|
602
|
+
if !file.in_path?(root)
|
603
|
+
raise Errno::EPERM, "#{file} not in #{
|
604
|
+
root
|
605
|
+
}"
|
606
|
+
|
607
|
+
elsif file.file?
|
608
|
+
FileUtils.cp(file, to, {
|
609
|
+
:preserve => true
|
610
|
+
})
|
611
|
+
|
612
|
+
else
|
613
|
+
path = file.realpath
|
614
|
+
path.safe_copy(to.join(file.basename), {
|
615
|
+
:root => root, :ignore => ignore
|
616
|
+
})
|
617
|
+
end
|
605
618
|
end
|
606
619
|
end
|
607
620
|
end
|
@@ -773,7 +786,6 @@ class Pathutil
|
|
773
786
|
rb_delegate :opendir, :to => :Dir, :alias_of => :open
|
774
787
|
rb_delegate :relative?, :to => :self, :alias_of => :absolute?, :bool => :reverse
|
775
788
|
rb_delegate :regexp_escape, :to => :Regexp, :args => :@path, :alias_of => :escape
|
776
|
-
rb_delegate :to_regexp, :to => :Regexp, :args => :@path, :alias_of => :new
|
777
789
|
rb_delegate :shellescape, :to => :Shellwords, :args => :@path
|
778
790
|
rb_delegate :mkdir, :to => :Dir, :args => :@path
|
779
791
|
|
data/lib/pathutil/version.rb
CHANGED
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
|
+
version: 0.9.0
|
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-04-
|
11
|
+
date: 2016-04-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: forwardable-extended
|