hiiro 0.1.129 → 0.1.130
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/bin/h-misc +12 -17
- data/lib/hiiro/paths.rb +22 -15
- data/lib/hiiro/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9ee15221ef5fd0d6dd334387e083049fc53cec41df755c270451f1329e63804a
|
|
4
|
+
data.tar.gz: 89df78fc18b86391dced6ec9e7f1dbb597f6f6549a3c627cc5b2898c2dd23b94
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6e043a980f853c53b429500047fc872092e21488a45ad9bfd1cdf64b4fab56d1513423cfe7af061988c468cb10272935cca9ceadad059d972c03c1ba51c152d0
|
|
7
|
+
data.tar.gz: 3abc9a1acfd9ff38060b6d8c01accae3efa5cea58113b8f0b1378b1270054b0e95543797400b9c89a5ed941c40679ab51299b447e86ccdf676189f561fb8dae6
|
data/bin/h-misc
CHANGED
|
@@ -9,24 +9,19 @@ Hiiro.run {
|
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
pwd = Hiiro::Paths.new(Dir.pwd)
|
|
12
|
-
outside_basedir = opts.args.inject({}) do |basedir
|
|
13
|
-
|
|
14
|
-
symlinks = pwd.symlinks_in(real_base)
|
|
12
|
+
outside_basedir = opts.args.inject({}) do |h,basedir|
|
|
13
|
+
symlinks = pwd.symlinks_in(basedir)
|
|
15
14
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
puts "LINK: #{link}"
|
|
27
|
-
puts "DEST: #{dest}"
|
|
28
|
-
puts "is outside => #{real_base}"
|
|
29
|
-
end
|
|
15
|
+
outside_dir = symlinks
|
|
16
|
+
.reject{|l| l.dest_in_dir?(basedir) }
|
|
17
|
+
.tap do |outside|
|
|
18
|
+
outside.each do |link,dest|
|
|
19
|
+
puts
|
|
20
|
+
puts "LINK: #{link}"
|
|
21
|
+
puts "DEST: #{dest}"
|
|
22
|
+
puts "is outside => #{real_base}"
|
|
23
|
+
end
|
|
24
|
+
end
|
|
30
25
|
end
|
|
31
26
|
end
|
|
32
27
|
}
|
data/lib/hiiro/paths.rb
CHANGED
|
@@ -1,37 +1,44 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
2
|
|
|
3
3
|
require "hiiro"
|
|
4
|
+
require "delegate"
|
|
4
5
|
|
|
5
6
|
class Hiiro
|
|
6
7
|
class Paths
|
|
7
8
|
attr_reader :base
|
|
8
9
|
|
|
9
|
-
def initialize(base)
|
|
10
|
+
def initialize(base=Dir.pwd)
|
|
10
11
|
@base = Pathname.new base
|
|
11
12
|
end
|
|
12
13
|
|
|
13
|
-
def
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
else
|
|
17
|
-
base.join path
|
|
18
|
-
end
|
|
14
|
+
def from_base(file)
|
|
15
|
+
path = Pathname.new(file)
|
|
16
|
+
path.relative_path_from(base)
|
|
19
17
|
end
|
|
20
18
|
|
|
21
19
|
def symlinks_in(path)
|
|
22
|
-
subdir =
|
|
20
|
+
subdir = Pathname.new(path)
|
|
23
21
|
|
|
24
|
-
subdir.find
|
|
22
|
+
subdir.find
|
|
23
|
+
.select(&:symlink?)
|
|
24
|
+
.map { |link| Symlink.new(link) }
|
|
25
25
|
end
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
class Symlink < SimpleDelegator
|
|
28
|
+
def path
|
|
29
|
+
@path ||= Pathname.new(__getobj__)
|
|
30
|
+
end
|
|
30
31
|
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
def dest
|
|
33
|
+
path.readlink
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def dest_in_dir?(dir)
|
|
37
|
+
dir = Pathname.new(dir)
|
|
33
38
|
|
|
34
|
-
|
|
39
|
+
relpath = dest.relative_path_from(dir)
|
|
40
|
+
relpath.descend.first.to_s != '..'
|
|
41
|
+
end
|
|
35
42
|
end
|
|
36
43
|
end
|
|
37
44
|
end
|
data/lib/hiiro/version.rb
CHANGED