html-pipeline-issue_references 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +4 -0
- data/.rubocop.yml +22 -0
- data/CONTRIBUTING.md +11 -0
- data/Gemfile +2 -0
- data/Guardfile +27 -0
- data/README.md +7 -6
- data/Rakefile +10 -4
- data/html-pipeline-issue_references.gemspec +16 -9
- data/lib/html/pipeline/issue_reference_filter.rb +18 -13
- data/lib/html/pipeline/issue_references/version.rb +3 -1
- metadata +76 -13
- data/bin/console +0 -14
- data/bin/setup +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 256c8ae3f5a32e2cef21323584e59dea27bbf687c1e52db839e68ed2903208c9
|
4
|
+
data.tar.gz: fcac21ffce366794345af4e3a4878a502caff068e3896267630934308eb4882b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 369778576f6c031fecec86c6c363212c71bb137fe037c0503cb3bf915503caaa818db0e8faa58c84c8f0160c94aae429ca8147d5fa9c28357106c03f7b04a6be
|
7
|
+
data.tar.gz: 54b84770620d327944fed9cdfba381ccd0a04552472d6dea23bfca9156b0fdcb74e7ccfd0702bdf852c1225d7f5ba309dcd3b7237b47bff240757fe5fcbda633
|
data/.circleci/config.yml
CHANGED
data/.rubocop.yml
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 2.4
|
3
|
+
Exclude:
|
4
|
+
- 'bin/**/*'
|
5
|
+
- 'vendor/**/*'
|
6
|
+
- 'config.ru'
|
7
|
+
|
8
|
+
Style/HashEachMethods:
|
9
|
+
Enabled: true
|
10
|
+
|
11
|
+
Style/HashTransformKeys:
|
12
|
+
Enabled: true
|
13
|
+
|
14
|
+
Style/HashTransformValues:
|
15
|
+
Enabled: true
|
16
|
+
|
17
|
+
Layout/LineLength:
|
18
|
+
Max: 100
|
19
|
+
|
20
|
+
Style/ClassAndModuleChildren:
|
21
|
+
Exclude:
|
22
|
+
- 'test/**/*.rb'
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
# Contributions Welcome!
|
2
|
+
|
3
|
+
Hi there! We're thrilled that you'd like to contribute to this project. Before you do, would you mind reading [this license agreement](LICENSE.txt)? If you open a PR, we'll assume you agree to it. If you have any hesitation or disagreement, please do open a PR still, but note your concerns as well.
|
4
|
+
|
5
|
+
Once done, follow these steps:
|
6
|
+
|
7
|
+
1. Fork this repository
|
8
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
9
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
10
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
11
|
+
5. Create a Pull Request
|
data/Gemfile
CHANGED
data/Guardfile
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# rspec configuration
|
4
|
+
minitest_opts = {
|
5
|
+
cmd: 'rake test',
|
6
|
+
autorun: false,
|
7
|
+
all_on_start: true
|
8
|
+
}
|
9
|
+
|
10
|
+
rubocop_opts = {
|
11
|
+
all_on_start: true,
|
12
|
+
cli: ['--display-cop-names']
|
13
|
+
}
|
14
|
+
|
15
|
+
group :rails, halt_on_fail: true do
|
16
|
+
guard :minitest, minitest_opts do
|
17
|
+
directories %w[test lib]
|
18
|
+
watch %r{^test/(.+)_test\.rb$}
|
19
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "test/#{m[1]}_test.rb" }
|
20
|
+
end
|
21
|
+
|
22
|
+
guard :rubocop, rubocop_opts do
|
23
|
+
directories %w[test lib]
|
24
|
+
watch(%r{^test/.+\.rb$})
|
25
|
+
watch(%r{^lib/(.+)\.rb$})
|
26
|
+
end
|
27
|
+
end
|
data/README.md
CHANGED
@@ -52,10 +52,15 @@ Fixes <a href='https://github.com/rails/rails/issues/123' class='issue-reference
|
|
52
52
|
```
|
53
53
|
|
54
54
|
## Development
|
55
|
+
After checking out the repo, run `bundle install` to install dependencies.
|
55
56
|
|
56
|
-
|
57
|
+
To install this gem onto your local machine, run `bundle exec rake install`.
|
57
58
|
|
58
|
-
To
|
59
|
+
To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
60
|
+
|
61
|
+
## Testing
|
62
|
+
Before beginning testing, be sure to run `bundle install && npm install`
|
63
|
+
Ruby unit tests can be run with `bundle exec rake test`.
|
59
64
|
|
60
65
|
## Contributing
|
61
66
|
|
@@ -65,7 +70,3 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
65
70
|
4. Push to the branch (`git push origin my-new-feature`)
|
66
71
|
5. Create a new Pull Request
|
67
72
|
|
68
|
-
## Updating RubyGems
|
69
|
-
1. Ensure you have the desired branch `git checkout master && git fetch origin && git pull`
|
70
|
-
2. Create an annotated tag `git tag -a v1.0.1 -m "msg with the tag"`
|
71
|
-
3. Push tag to Github `github push --tags`
|
data/Rakefile
CHANGED
@@ -1,10 +1,16 @@
|
|
1
|
-
|
2
|
-
require "rake/testtask"
|
1
|
+
# frozen_string_literal: true
|
3
2
|
|
3
|
+
require 'bundler/gem_tasks'
|
4
|
+
require 'rake/testtask'
|
5
|
+
require 'rubocop/rake_task'
|
6
|
+
|
7
|
+
task default: :test
|
4
8
|
Rake::TestTask.new do |t|
|
5
|
-
t.libs <<
|
9
|
+
t.libs << 'test'
|
6
10
|
t.test_files = FileList['test/**/*_test.rb']
|
7
11
|
t.verbose = true
|
8
12
|
end
|
9
13
|
|
10
|
-
|
14
|
+
RuboCop::RakeTask.new
|
15
|
+
|
16
|
+
Rake::Task['test'].enhance ['rubocop']
|
@@ -1,5 +1,6 @@
|
|
1
|
-
#
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
3
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
5
|
require 'html/pipeline/issue_references/version'
|
5
6
|
|
@@ -8,17 +9,23 @@ Gem::Specification.new do |spec|
|
|
8
9
|
spec.version = HTML::Pipeline::IssueReferences::VERSION
|
9
10
|
spec.authors = ['Codetree', 'Derrick Reimer']
|
10
11
|
spec.email = ['support@codetree.com', 'derrickreimer@gmail.com']
|
11
|
-
spec.summary =
|
12
|
+
spec.summary = 'An HTML::Pipeline filter for auto-linking GitHub issue references'
|
12
13
|
spec.description = spec.summary
|
13
14
|
spec.homepage = 'https://github.com/codetree/html-pipeline-issue_references'
|
14
15
|
spec.license = 'MIT'
|
15
|
-
|
16
|
-
spec.
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
|
17
19
|
spec.require_paths = ['lib']
|
20
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
21
|
|
19
|
-
spec.add_dependency 'html-pipeline', '~> 2.
|
22
|
+
spec.add_dependency 'html-pipeline', '~> 2.12'
|
20
23
|
|
21
|
-
spec.add_development_dependency 'bundler', '~> 1.
|
22
|
-
spec.add_development_dependency '
|
23
|
-
spec.add_development_dependency 'minitest', '~>
|
24
|
+
spec.add_development_dependency 'bundler', '~> 2.1', '>= 2.1.4'
|
25
|
+
spec.add_development_dependency 'guard', '~> 2.16'
|
26
|
+
spec.add_development_dependency 'guard-minitest', '~> 2.4'
|
27
|
+
spec.add_development_dependency 'guard-rubocop', '~> 1.3'
|
28
|
+
spec.add_development_dependency 'minitest', '~> 5.14'
|
29
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
30
|
+
spec.add_development_dependency 'rubocop', '~> 0.80.1'
|
24
31
|
end
|
@@ -1,10 +1,13 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'html/pipeline'
|
4
|
+
require 'set'
|
3
5
|
|
4
6
|
module HTML
|
5
7
|
class Pipeline
|
8
|
+
# identify github issue references using a customizable filter pattern
|
6
9
|
class IssueReferenceFilter < Filter
|
7
|
-
REPOSITORY_NAME =
|
10
|
+
REPOSITORY_NAME = %r{[a-z0-9][a-z0-9\-]*/[a-z0-9][a-z0-9\-_]*}ix.freeze
|
8
11
|
|
9
12
|
# Match references of the form:
|
10
13
|
#
|
@@ -25,17 +28,17 @@ module HTML
|
|
25
28
|
[^0-9a-zA-Z_.]| # non-word character except dot
|
26
29
|
$ # end of line
|
27
30
|
)
|
28
|
-
/ix
|
31
|
+
/ix.freeze
|
29
32
|
|
30
33
|
# Match references of the form:
|
31
34
|
#
|
32
35
|
# - https://github.com/codetree/feedback/issues/123
|
33
36
|
# - https://github.com/codetree/feedback/pulls/123
|
34
|
-
URL_PATTERN =
|
37
|
+
URL_PATTERN = %r{
|
35
38
|
(?:^|\W) # beginning of string or non-word char
|
36
|
-
https
|
39
|
+
https://github.com/
|
37
40
|
(#{REPOSITORY_NAME}) # repository name
|
38
|
-
|
41
|
+
/(?:issues|pulls)/
|
39
42
|
(\d+) # issue number
|
40
43
|
(?=
|
41
44
|
\.+[ \t\W]| # dots followed by space or non-word character
|
@@ -43,15 +46,15 @@ module HTML
|
|
43
46
|
[^0-9a-zA-Z_.]| # non-word character except dot
|
44
47
|
$ # end of line
|
45
48
|
)
|
46
|
-
|
49
|
+
}ix.freeze
|
47
50
|
|
48
51
|
# Don't look for mentions in text nodes that are children of these elements
|
49
|
-
IGNORE_PARENTS = %w
|
52
|
+
IGNORE_PARENTS = %w[pre code a style].to_set
|
50
53
|
|
51
54
|
def self.issue_references_in(text)
|
52
55
|
text.gsub SHORT_PATTERN do |match|
|
53
|
-
repository =
|
54
|
-
number =
|
56
|
+
repository = Regexp.last_match(2)
|
57
|
+
number = Regexp.last_match(3)
|
55
58
|
yield match, repository, number
|
56
59
|
end
|
57
60
|
end
|
@@ -64,15 +67,17 @@ module HTML
|
|
64
67
|
doc.search('.//text()').each do |node|
|
65
68
|
content = node.to_html
|
66
69
|
next if has_ancestor?(node, IGNORE_PARENTS)
|
70
|
+
|
67
71
|
html = issue_reference_filter(content, base_url, default_repo)
|
68
72
|
next if html == content
|
73
|
+
|
69
74
|
node.replace(html)
|
70
75
|
end
|
71
76
|
|
72
77
|
doc
|
73
78
|
end
|
74
79
|
|
75
|
-
def issue_reference_filter(text,
|
80
|
+
def issue_reference_filter(text, _base_url = '/', default_repo = nil)
|
76
81
|
self.class.issue_references_in(text) do |match, referenced_repo, number|
|
77
82
|
repo = referenced_repo || default_repo
|
78
83
|
repo ? link_to_issue(repo, number, default_repo) : match
|
@@ -84,7 +89,7 @@ module HTML
|
|
84
89
|
content = "#{repo}#{content}" if repo != default_repo
|
85
90
|
|
86
91
|
url = base_url.dup
|
87
|
-
url <<
|
92
|
+
url << '/' unless url =~ %r{[/~]\z}
|
88
93
|
url << "#{repo}/issues/#{number}"
|
89
94
|
|
90
95
|
"<a href='#{url}' class='issue-reference'>#{content}</a>"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: html-pipeline-issue_references
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Codetree
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-
|
12
|
+
date: 2020-04-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: html-pipeline
|
@@ -17,56 +17,118 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: '2.
|
20
|
+
version: '2.12'
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: '2.
|
27
|
+
version: '2.12'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: bundler
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
32
|
- - "~>"
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: '1
|
34
|
+
version: '2.1'
|
35
|
+
- - ">="
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 2.1.4
|
35
38
|
type: :development
|
36
39
|
prerelease: false
|
37
40
|
version_requirements: !ruby/object:Gem::Requirement
|
38
41
|
requirements:
|
39
42
|
- - "~>"
|
40
43
|
- !ruby/object:Gem::Version
|
41
|
-
version: '1
|
44
|
+
version: '2.1'
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 2.1.4
|
42
48
|
- !ruby/object:Gem::Dependency
|
43
|
-
name:
|
49
|
+
name: guard
|
50
|
+
requirement: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.16'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2.16'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: guard-minitest
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '2.4'
|
69
|
+
type: :development
|
70
|
+
prerelease: false
|
71
|
+
version_requirements: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '2.4'
|
76
|
+
- !ruby/object:Gem::Dependency
|
77
|
+
name: guard-rubocop
|
44
78
|
requirement: !ruby/object:Gem::Requirement
|
45
79
|
requirements:
|
46
80
|
- - "~>"
|
47
81
|
- !ruby/object:Gem::Version
|
48
|
-
version: '
|
82
|
+
version: '1.3'
|
49
83
|
type: :development
|
50
84
|
prerelease: false
|
51
85
|
version_requirements: !ruby/object:Gem::Requirement
|
52
86
|
requirements:
|
53
87
|
- - "~>"
|
54
88
|
- !ruby/object:Gem::Version
|
55
|
-
version: '
|
89
|
+
version: '1.3'
|
56
90
|
- !ruby/object:Gem::Dependency
|
57
91
|
name: minitest
|
58
92
|
requirement: !ruby/object:Gem::Requirement
|
59
93
|
requirements:
|
60
94
|
- - "~>"
|
61
95
|
- !ruby/object:Gem::Version
|
62
|
-
version: '5.
|
96
|
+
version: '5.14'
|
97
|
+
type: :development
|
98
|
+
prerelease: false
|
99
|
+
version_requirements: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '5.14'
|
104
|
+
- !ruby/object:Gem::Dependency
|
105
|
+
name: rake
|
106
|
+
requirement: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '13.0'
|
111
|
+
type: :development
|
112
|
+
prerelease: false
|
113
|
+
version_requirements: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '13.0'
|
118
|
+
- !ruby/object:Gem::Dependency
|
119
|
+
name: rubocop
|
120
|
+
requirement: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 0.80.1
|
63
125
|
type: :development
|
64
126
|
prerelease: false
|
65
127
|
version_requirements: !ruby/object:Gem::Requirement
|
66
128
|
requirements:
|
67
129
|
- - "~>"
|
68
130
|
- !ruby/object:Gem::Version
|
69
|
-
version:
|
131
|
+
version: 0.80.1
|
70
132
|
description: An HTML::Pipeline filter for auto-linking GitHub issue references
|
71
133
|
email:
|
72
134
|
- support@codetree.com
|
@@ -78,13 +140,14 @@ files:
|
|
78
140
|
- ".circleci/config.yml"
|
79
141
|
- ".circleci/setup-rubygems.sh"
|
80
142
|
- ".gitignore"
|
143
|
+
- ".rubocop.yml"
|
81
144
|
- ".travis.yml"
|
145
|
+
- CONTRIBUTING.md
|
82
146
|
- Gemfile
|
147
|
+
- Guardfile
|
83
148
|
- LICENSE.txt
|
84
149
|
- README.md
|
85
150
|
- Rakefile
|
86
|
-
- bin/console
|
87
|
-
- bin/setup
|
88
151
|
- html-pipeline-issue_references.gemspec
|
89
152
|
- lib/html/pipeline/issue_reference_filter.rb
|
90
153
|
- lib/html/pipeline/issue_references/version.rb
|
data/bin/console
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require "bundler/setup"
|
4
|
-
require "html/pipeline/issue_references"
|
5
|
-
|
6
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
-
# with your gem easier. You can also use a different console, if you like.
|
8
|
-
|
9
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
# require "pry"
|
11
|
-
# Pry.start
|
12
|
-
|
13
|
-
require "irb"
|
14
|
-
IRB.start
|