hiiro 0.1.169 → 0.1.170
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 +4 -6
- data/lib/hiiro/git.rb +1 -1
- data/lib/hiiro/paths.rb +30 -7
- 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: 72a0ad30e0ada0bea531d4a2d9f0724b1e82f2f3f785c44dda3fbad2d28abb61
|
|
4
|
+
data.tar.gz: 3f2e11e363408038c0910b1f66d5d7240c15510c85d04599fc973a2c4a9ae203
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d7da2d57be1be7c956e9221ed3f16e96cad9e6793eba5f7f2aadaffb097c2678c13f02f3346de33ac287daaff8436733328d4babe55fb566fda76133a961c28f
|
|
7
|
+
data.tar.gz: c5f99d312ed8baed31c2540182389b0cd59ff33cd0da0534473aa0e3d22a5ac6b3d06170f85f8523705e97fa0abdc6a5f9b4cbf144a719c771e49f83d69cfa3b
|
data/bin/h-misc
CHANGED
|
@@ -6,11 +6,10 @@ require 'awesome_print'
|
|
|
6
6
|
Hiiro.run {
|
|
7
7
|
add_subcmd(:symlink_destinations) do |*args|
|
|
8
8
|
opts = Hiiro::Options.parse(args) do
|
|
9
|
-
option(:root, short: :r, desc: 'root path')
|
|
9
|
+
option(:root, short: :r, default: `git rev-parse --show-toplevel 2>/dev/null`.strip, desc: 'root path')
|
|
10
10
|
end
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
pwd = Hiiro::Paths.new(Dir.pwd)
|
|
12
|
+
pwd = Hiiro::Paths.new(Dir.pwd, hiiro: this)
|
|
14
13
|
outside = Hash.new { |h,k| h[k] = [] }
|
|
15
14
|
|
|
16
15
|
opts.args.each_with_object(outside) do |basedir,h|
|
|
@@ -21,10 +20,9 @@ Hiiro.run {
|
|
|
21
20
|
|
|
22
21
|
outside.each do |base, links|
|
|
23
22
|
puts "# symlinks outside of => #{base}"
|
|
24
|
-
dest_width = links.map{|l| l.
|
|
23
|
+
dest_width = links.map{|l| l.dest_from_root.to_s.length }.max
|
|
25
24
|
links.each do |link|
|
|
26
|
-
|
|
27
|
-
printf("%-*s # => %s\n", dest_width, rel_dest, link.path)
|
|
25
|
+
printf("%-*s # => %s\n", dest_width, link.dest_from_root, link.path)
|
|
28
26
|
end
|
|
29
27
|
end
|
|
30
28
|
end
|
data/lib/hiiro/git.rb
CHANGED
data/lib/hiiro/paths.rb
CHANGED
|
@@ -5,10 +5,11 @@ require "delegate"
|
|
|
5
5
|
|
|
6
6
|
class Hiiro
|
|
7
7
|
class Paths
|
|
8
|
-
attr_reader :base
|
|
8
|
+
attr_reader :base, :hiiro
|
|
9
9
|
|
|
10
|
-
def initialize(base=Dir.pwd)
|
|
10
|
+
def initialize(base=Dir.pwd, hiiro: nil)
|
|
11
11
|
@base = Pathname.new base
|
|
12
|
+
@hiiro = hiiro
|
|
12
13
|
end
|
|
13
14
|
|
|
14
15
|
def from_base(file)
|
|
@@ -17,14 +18,21 @@ class Hiiro
|
|
|
17
18
|
end
|
|
18
19
|
|
|
19
20
|
def symlinks_in(path)
|
|
20
|
-
subdir = Pathname.new(path)
|
|
21
|
+
subdir = Pathname.new(path).expand_path
|
|
21
22
|
|
|
22
23
|
subdir.find
|
|
23
24
|
.select(&:symlink?)
|
|
24
|
-
.map { |link| Symlink.new(link) }
|
|
25
|
+
.map { |link| Symlink.new(link, hiiro) }
|
|
25
26
|
end
|
|
26
27
|
|
|
27
28
|
class Symlink < SimpleDelegator
|
|
29
|
+
attr_reader :hiiro
|
|
30
|
+
|
|
31
|
+
def initialize(path, hiiro=nil)
|
|
32
|
+
@hiiro = hiiro
|
|
33
|
+
super(path)
|
|
34
|
+
end
|
|
35
|
+
|
|
28
36
|
def path
|
|
29
37
|
@path ||= Pathname.new(__getobj__)
|
|
30
38
|
end
|
|
@@ -33,9 +41,24 @@ class Hiiro
|
|
|
33
41
|
path.readlink
|
|
34
42
|
end
|
|
35
43
|
|
|
36
|
-
def
|
|
37
|
-
|
|
38
|
-
|
|
44
|
+
def root
|
|
45
|
+
@root ||= hiiro&.git&.root || `git rev-parse --show-toplevel 2>/dev/null`.chomp
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def root_path
|
|
49
|
+
Pathname.new root
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def abs_dest
|
|
53
|
+
(path.dirname + dest).cleanpath
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def dest_from_root
|
|
57
|
+
abs_dest.relative_path_from(root_path)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def dest_relative_to(base_dir)
|
|
61
|
+
abs_dest.relative_path_from(Pathname.new(base_dir))
|
|
39
62
|
end
|
|
40
63
|
|
|
41
64
|
def dest_dir
|
data/lib/hiiro/version.rb
CHANGED