deadlink 0.2.0 → 0.3.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/.travis.yml +2 -1
- data/README.md +22 -0
- data/exe/deadlink +1 -2
- data/lib/deadlink/decorator.rb +11 -0
- data/lib/deadlink/path.rb +22 -12
- data/lib/deadlink/paths.rb +5 -10
- data/lib/deadlink/version.rb +1 -1
- data/lib/deadlink.rb +9 -2
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f42e427eaed4d72f32f1792483e63ada02693bee
|
|
4
|
+
data.tar.gz: 9bce889bdc0bf45a1c9f801e5a38fa828d32d501
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4d390237db254c21ca8ad04326dc0984d08fa0f65fbd2d7c6b7007e375fef371d567b5b12f8ac59f242ca4ec75141462fbaae728339203523d54d784760d2ec0
|
|
7
|
+
data.tar.gz: bad4ecfdcb120bedd548d9774bbd422ceff9430fe66f6d87595bb8a4b718840aba1af271e93ed22294d33e0df1a43c599149c1f7b1b630e7c99fa19bca89d0ed
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
# Deadlink
|
|
2
2
|
|
|
3
3
|
[](https://travis-ci.org/yutakakinjyo/deadlink)
|
|
4
|
+
[](https://codeclimate.com/github/yutakakinjyo/deadlink)
|
|
5
|
+
[](https://gemnasium.com/yutakakinjyo/deadlink)
|
|
6
|
+
[](https://badge.fury.io/rb/deadlink)
|
|
4
7
|
|
|
5
8
|
Check **deadlink** of markdown files in your git repository.
|
|
6
9
|
|
|
@@ -68,6 +71,25 @@ if you not specify `<dir>` path, deadlink scan top directory of current git repo
|
|
|
68
71
|
$ deadlink
|
|
69
72
|
```
|
|
70
73
|
|
|
74
|
+
### Option
|
|
75
|
+
|
|
76
|
+
`-p` option output for editor. In this repository case
|
|
77
|
+
|
|
78
|
+
`$ deadlink -p deadlink/`
|
|
79
|
+
|
|
80
|
+
```
|
|
81
|
+
+46 ./README.md
|
|
82
|
+
+90 ./README.md
|
|
83
|
+
+2 ./test/files/dir1/nest_file1.md
|
|
84
|
+
+3 ./test/files/top.md
|
|
85
|
+
+5 ./test/files/top.md
|
|
86
|
+
+8 ./test/files/top.md
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Forexample you can jump deadlink line easily, like following command.
|
|
90
|
+
|
|
91
|
+
`$ vi $(deadlink -p deadlink/ | peco)`
|
|
92
|
+
|
|
71
93
|
## Development
|
|
72
94
|
|
|
73
95
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/exe/deadlink
CHANGED
data/lib/deadlink/path.rb
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
module Deadlink
|
|
2
2
|
class Path
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
|
|
4
|
+
attr_reader :link, :cur_file_path, :index
|
|
5
|
+
|
|
6
|
+
def initialize(cur_file_path, link, index, repo_root)
|
|
5
7
|
@link = link
|
|
8
|
+
@cur_file_path = cur_file_path
|
|
6
9
|
@index = index
|
|
7
|
-
@repo_root = repo_root
|
|
8
|
-
end
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
@repo_root = repo_root
|
|
12
|
+
|
|
13
|
+
hash = split_link(link)
|
|
14
|
+
@link_file_path = hash[:filepath]
|
|
15
|
+
@anchor = hash[:anchor]
|
|
12
16
|
end
|
|
13
17
|
|
|
14
18
|
def deadlink?
|
|
@@ -28,17 +32,23 @@ module Deadlink
|
|
|
28
32
|
def url?
|
|
29
33
|
@link =~ /https?:\/\/[\S]+/
|
|
30
34
|
end
|
|
31
|
-
|
|
35
|
+
|
|
32
36
|
def link_path
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
if cap[:filelink][0] == "/"
|
|
36
|
-
return File.join(@repo_root, cap[:filelink])
|
|
37
|
+
if absolute_path?(@link_file_path)
|
|
38
|
+
return File.join(@repo_root, @link_file_path)
|
|
37
39
|
end
|
|
38
40
|
|
|
39
|
-
File.expand_path(
|
|
41
|
+
File.expand_path(@link_file_path, File.dirname(@cur_file_path))
|
|
40
42
|
end
|
|
41
43
|
|
|
44
|
+
def split_link(link)
|
|
45
|
+
# split <filenpath>#<title>
|
|
46
|
+
hash = link.match(/(?<filepath>[^#]*)#*(?<anchor>.*)/)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def absolute_path?(path)
|
|
50
|
+
path[0] == "/"
|
|
51
|
+
end
|
|
42
52
|
|
|
43
53
|
end
|
|
44
54
|
end
|
data/lib/deadlink/paths.rb
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
module Deadlink
|
|
2
2
|
class Paths
|
|
3
|
+
|
|
4
|
+
attr_reader :deadlinks
|
|
5
|
+
|
|
3
6
|
def initialize(paths)
|
|
4
7
|
@paths = paths
|
|
5
8
|
@deadlinks = paths.select { |path| path.deadlink? }
|
|
@@ -9,21 +12,13 @@ module Deadlink
|
|
|
9
12
|
@deadlinks.any?
|
|
10
13
|
end
|
|
11
14
|
|
|
12
|
-
def
|
|
13
|
-
@deadlinks
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def print_deadlinks
|
|
17
|
-
@paths.each { |path| path.deadlink }
|
|
15
|
+
def print_deadlinks(opts)
|
|
16
|
+
@deadlinks.each { |path| Decorator.print_info(path,opts) }
|
|
18
17
|
end
|
|
19
18
|
|
|
20
19
|
def count
|
|
21
20
|
@paths.count
|
|
22
21
|
end
|
|
23
22
|
|
|
24
|
-
def [](i)
|
|
25
|
-
@paths[i]
|
|
26
|
-
end
|
|
27
|
-
|
|
28
23
|
end
|
|
29
24
|
end
|
data/lib/deadlink/version.rb
CHANGED
data/lib/deadlink.rb
CHANGED
|
@@ -2,12 +2,19 @@ require "deadlink/version"
|
|
|
2
2
|
require 'deadlink/scanner'
|
|
3
3
|
require 'deadlink/path'
|
|
4
4
|
require 'deadlink/paths'
|
|
5
|
+
require 'deadlink/decorator'
|
|
6
|
+
require 'optparse'
|
|
5
7
|
|
|
6
8
|
module Deadlink
|
|
7
|
-
def self.scan(
|
|
9
|
+
def self.scan()
|
|
10
|
+
|
|
11
|
+
opts = ARGV.getopts('','p')
|
|
12
|
+
target_dir = ARGV[0]
|
|
13
|
+
|
|
14
|
+
|
|
8
15
|
scanner = Scanner.new(target_dir)
|
|
9
16
|
files = scanner.md_files
|
|
10
17
|
paths = scanner.paths(files)
|
|
11
|
-
paths.print_deadlinks
|
|
18
|
+
paths.print_deadlinks(opts)
|
|
12
19
|
end
|
|
13
20
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: deadlink
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- yutakakinjyo
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2015-11-
|
|
11
|
+
date: 2015-11-14 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -86,6 +86,7 @@ files:
|
|
|
86
86
|
- deadlink.gemspec
|
|
87
87
|
- exe/deadlink
|
|
88
88
|
- lib/deadlink.rb
|
|
89
|
+
- lib/deadlink/decorator.rb
|
|
89
90
|
- lib/deadlink/path.rb
|
|
90
91
|
- lib/deadlink/paths.rb
|
|
91
92
|
- lib/deadlink/scanner.rb
|