ping 0.1.0 → 0.1.1
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 +41 -8
- data/Gemfile +2 -0
- data/Rakefile +6 -8
- data/lib/ping.rb +2 -0
- data/lib/ping/config.rb +7 -7
- data/lib/ping/issue_reference.rb +10 -9
- data/lib/ping/mention.rb +7 -5
- data/lib/ping/parser.rb +3 -1
- data/lib/ping/version.rb +3 -1
- data/ping.gemspec +11 -10
- metadata +29 -34
- data/.rubocop_todo.yml +0 -29
- data/test/ping/config_test.rb +0 -41
- data/test/ping/issue_reference_test.rb +0 -481
- data/test/ping/mention_test.rb +0 -45
- data/test/ping/parser_test.rb +0 -4
- data/test/test_helper.rb +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ac62acfe2a85d874917d0af6fbbb36f0eda901912c097f84d7900174ceccdd1d
|
4
|
+
data.tar.gz: 82c14c8e4b00b70c99dcd1dd76c4bbebffeed6732102f3d1185dd32d3332a391
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa87a0acd7bd37dc8d80a5ce8fa5d4efbe3e271f906746b8127ba4d21613446f10074e56d56a6e59d3575127dca2c1ba5648b93f70c73406587016521b3204dd
|
7
|
+
data.tar.gz: e2b424198f0672f8785c3c8a9dd8da0b8a3a0407f72fdf7a1123dd3e398495ff1a6052d9cadc8331f8c9e805af8914190e9489d0c6ea1618ff2891f8686ea0f4
|
data/.circleci/config.yml
CHANGED
data/.rubocop.yml
CHANGED
@@ -1,11 +1,44 @@
|
|
1
|
-
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 2.4
|
3
|
+
Exclude:
|
4
|
+
- 'bin/**/*'
|
5
|
+
- 'vendor/**/*'
|
6
|
+
- 'config.ru'
|
2
7
|
|
3
|
-
|
4
|
-
|
8
|
+
Layout/LineLength:
|
9
|
+
Max: 100
|
5
10
|
|
6
|
-
|
11
|
+
Metrics/AbcSize:
|
12
|
+
Max: 20
|
13
|
+
|
14
|
+
Metrics/BlockLength:
|
15
|
+
Max: 30
|
16
|
+
Exclude:
|
17
|
+
- 'test/**/*.rb'
|
18
|
+
|
19
|
+
Metrics/ClassLength:
|
20
|
+
Exclude:
|
21
|
+
- 'test/**/*.rb'
|
22
|
+
|
23
|
+
Metrics/MethodLength:
|
24
|
+
Max: 15
|
7
25
|
Exclude:
|
8
|
-
- 'test
|
9
|
-
|
10
|
-
|
11
|
-
|
26
|
+
- 'test/**/*.rb'
|
27
|
+
|
28
|
+
Style/ClassAndModuleChildren:
|
29
|
+
Exclude:
|
30
|
+
- 'test/**/*.rb'
|
31
|
+
|
32
|
+
Style/Documentation:
|
33
|
+
Enabled: false
|
34
|
+
Exclude:
|
35
|
+
- 'test/**/*'
|
36
|
+
|
37
|
+
Style/HashEachMethods:
|
38
|
+
Enabled: true
|
39
|
+
|
40
|
+
Style/HashTransformKeys:
|
41
|
+
Enabled: true
|
42
|
+
|
43
|
+
Style/HashTransformValues:
|
44
|
+
Enabled: true
|
data/Gemfile
CHANGED
data/Rakefile
CHANGED
@@ -1,20 +1,18 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'bundler/gem_tasks'
|
3
4
|
require 'rake/testtask'
|
5
|
+
require 'rubocop/rake_task'
|
4
6
|
|
7
|
+
desc 'Run tests'
|
8
|
+
task default: :test
|
5
9
|
Rake::TestTask.new do |t|
|
6
10
|
t.libs << 'lib'
|
7
11
|
t.pattern = 'test/**/*_test.rb'
|
8
12
|
t.verbose = true
|
9
13
|
end
|
10
14
|
|
11
|
-
desc 'Run tests'
|
12
|
-
task default: :test
|
13
|
-
|
14
15
|
# append to the default rake task
|
15
|
-
require 'rubocop/rake_task'
|
16
16
|
RuboCop::RakeTask.new
|
17
17
|
|
18
|
-
|
19
|
-
Rake::Task['rubocop'].invoke
|
20
|
-
end
|
18
|
+
Rake::Task['test'].enhance ['rubocop']
|
data/lib/ping.rb
CHANGED
data/lib/ping/config.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Ping
|
2
4
|
class << self
|
3
|
-
attr_accessor :config
|
4
|
-
|
5
5
|
def configure
|
6
6
|
yield config
|
7
7
|
end
|
@@ -11,7 +11,7 @@ module Ping
|
|
11
11
|
end
|
12
12
|
|
13
13
|
# Here we are implementing a reset method because
|
14
|
-
# for global values like this, it
|
14
|
+
# for global values like this, it's best to clean up before/after
|
15
15
|
# each spec to ensure the system is back to a default state.
|
16
16
|
def reset
|
17
17
|
@config = Config.new
|
@@ -21,10 +21,10 @@ module Ping
|
|
21
21
|
class Config
|
22
22
|
attr_accessor :qualifiers
|
23
23
|
|
24
|
-
DEFAULT_QUALIFIERS = [
|
25
|
-
|
26
|
-
|
27
|
-
]
|
24
|
+
DEFAULT_QUALIFIERS = %w[
|
25
|
+
close closes closed fix fixes fixed need needs needed
|
26
|
+
require requires required resolve resolves resolved
|
27
|
+
].freeze
|
28
28
|
|
29
29
|
def initialize
|
30
30
|
@qualifiers = DEFAULT_QUALIFIERS
|
data/lib/ping/issue_reference.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Ping
|
2
4
|
class IssueReference
|
3
5
|
attr_accessor :qualifier, :repository, :number
|
4
6
|
|
5
|
-
REPOSITORY_NAME =
|
7
|
+
REPOSITORY_NAME = %r{[a-z0-9][a-z0-9\-]*/[a-z0-9][a-z0-9\-_]*}ix.freeze
|
6
8
|
|
7
9
|
class << self
|
8
10
|
def qualifier_regex
|
@@ -40,12 +42,12 @@ module Ping
|
|
40
42
|
# - needs https://github.com/codetree/feedback/issues/123
|
41
43
|
# - etc...
|
42
44
|
def url_pattern
|
43
|
-
|
45
|
+
%r{
|
44
46
|
(?:^|\W) # beginning of string or non-word char
|
45
47
|
(?:(#{qualifier_regex})(?:\s))? # qualifier (optional)
|
46
|
-
https
|
48
|
+
https://github.com/
|
47
49
|
(#{REPOSITORY_NAME}) # repository name
|
48
|
-
|
50
|
+
/(?:issues|pulls)/
|
49
51
|
(\d+) # issue number
|
50
52
|
(?=
|
51
53
|
\.+[ \t]| # dots followed by space or non-word character
|
@@ -53,7 +55,7 @@ module Ping
|
|
53
55
|
[^0-9a-zA-Z_.]| # non-word character except dot
|
54
56
|
$ # end of line
|
55
57
|
)
|
56
|
-
|
58
|
+
}ix
|
57
59
|
end
|
58
60
|
|
59
61
|
def extract(text)
|
@@ -82,10 +84,9 @@ module Ping
|
|
82
84
|
return replacement unless replacement.is_a?(IssueReference)
|
83
85
|
|
84
86
|
# Reformat the given issue reference replacement to match
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
new_phrase << '#' + replacement.number.to_s
|
87
|
+
lead_in = match[0] == ' ' ? ' ' : '' # fix leading space
|
88
|
+
lead_in += replacement.qualifier + ' ' if replacement.qualifier
|
89
|
+
lead_in + replacement.repository.to_s + '#' + replacement.number.to_s
|
89
90
|
end
|
90
91
|
end
|
91
92
|
|
data/lib/ping/mention.rb
CHANGED
@@ -1,18 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Ping
|
2
4
|
class Mention
|
3
5
|
attr_accessor :username
|
4
6
|
|
5
|
-
PATTERN =
|
7
|
+
PATTERN = %r{
|
6
8
|
(?:^|\W) # beginning of string or non-word char
|
7
9
|
@((?>[a-z0-9][a-z0-9-]*)) # @username
|
8
|
-
(
|
10
|
+
(?!/) # without a trailing slash
|
9
11
|
(?=
|
10
12
|
\.+[ \t]| # dots followed by space or non-word character
|
11
13
|
\.+$| # dots at end of line
|
12
14
|
[^0-9a-zA-Z_.]| # non-word character except dot
|
13
15
|
$ # end of line
|
14
16
|
)
|
15
|
-
|
17
|
+
}ix.freeze
|
16
18
|
|
17
19
|
def initialize(username)
|
18
20
|
@username = username
|
@@ -25,8 +27,8 @@ module Ping
|
|
25
27
|
end
|
26
28
|
end
|
27
29
|
|
28
|
-
def ==(
|
29
|
-
|
30
|
+
def ==(other)
|
31
|
+
other == username
|
30
32
|
end
|
31
33
|
|
32
34
|
def to_s
|
data/lib/ping/parser.rb
CHANGED
data/lib/ping/version.rb
CHANGED
data/ping.gemspec
CHANGED
@@ -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 'ping/version'
|
5
6
|
|
@@ -12,16 +13,16 @@ Gem::Specification.new do |spec|
|
|
12
13
|
spec.description = 'A little library for parsing GitHub @mentions and issue references'
|
13
14
|
spec.homepage = 'https://github.com/codetree/ping'
|
14
15
|
spec.license = 'MIT'
|
15
|
-
spec.required_ruby_version = '>= 2.
|
16
|
-
spec.files = `git ls-files -z`.split("\x0")
|
17
|
-
spec.executables = spec.files.grep(/^bin\//) { |f| File.basename(f) }
|
18
|
-
spec.test_files = spec.files.grep(/^(test|spec|features)\//)
|
16
|
+
spec.required_ruby_version = '>= 2.4'
|
19
17
|
spec.require_paths = ['lib']
|
20
18
|
|
21
|
-
spec.
|
22
|
-
spec.
|
19
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
20
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
21
|
+
|
22
|
+
spec.add_development_dependency 'bundler', '~> 2.1', '>= 2.1.4'
|
23
23
|
spec.add_development_dependency 'minitest', '~> 5.0'
|
24
|
-
spec.add_development_dependency 'shoulda-context', '~> 1.2'
|
25
24
|
spec.add_development_dependency 'mocha', '~> 1.0'
|
26
|
-
spec.add_development_dependency '
|
25
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
26
|
+
spec.add_development_dependency 'rubocop', '~> 0.80.1'
|
27
|
+
spec.add_development_dependency 'shoulda-context', '~> 1.2'
|
27
28
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ping
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
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: bundler
|
@@ -17,84 +17,90 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: '1
|
20
|
+
version: '2.1'
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 2.1.4
|
21
24
|
type: :development
|
22
25
|
prerelease: false
|
23
26
|
version_requirements: !ruby/object:Gem::Requirement
|
24
27
|
requirements:
|
25
28
|
- - "~>"
|
26
29
|
- !ruby/object:Gem::Version
|
27
|
-
version: '1
|
30
|
+
version: '2.1'
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 2.1.4
|
28
34
|
- !ruby/object:Gem::Dependency
|
29
|
-
name:
|
35
|
+
name: minitest
|
30
36
|
requirement: !ruby/object:Gem::Requirement
|
31
37
|
requirements:
|
32
38
|
- - "~>"
|
33
39
|
- !ruby/object:Gem::Version
|
34
|
-
version: '
|
40
|
+
version: '5.0'
|
35
41
|
type: :development
|
36
42
|
prerelease: false
|
37
43
|
version_requirements: !ruby/object:Gem::Requirement
|
38
44
|
requirements:
|
39
45
|
- - "~>"
|
40
46
|
- !ruby/object:Gem::Version
|
41
|
-
version: '
|
47
|
+
version: '5.0'
|
42
48
|
- !ruby/object:Gem::Dependency
|
43
|
-
name:
|
49
|
+
name: mocha
|
44
50
|
requirement: !ruby/object:Gem::Requirement
|
45
51
|
requirements:
|
46
52
|
- - "~>"
|
47
53
|
- !ruby/object:Gem::Version
|
48
|
-
version: '
|
54
|
+
version: '1.0'
|
49
55
|
type: :development
|
50
56
|
prerelease: false
|
51
57
|
version_requirements: !ruby/object:Gem::Requirement
|
52
58
|
requirements:
|
53
59
|
- - "~>"
|
54
60
|
- !ruby/object:Gem::Version
|
55
|
-
version: '
|
61
|
+
version: '1.0'
|
56
62
|
- !ruby/object:Gem::Dependency
|
57
|
-
name:
|
63
|
+
name: rake
|
58
64
|
requirement: !ruby/object:Gem::Requirement
|
59
65
|
requirements:
|
60
66
|
- - "~>"
|
61
67
|
- !ruby/object:Gem::Version
|
62
|
-
version: '
|
68
|
+
version: '13.0'
|
63
69
|
type: :development
|
64
70
|
prerelease: false
|
65
71
|
version_requirements: !ruby/object:Gem::Requirement
|
66
72
|
requirements:
|
67
73
|
- - "~>"
|
68
74
|
- !ruby/object:Gem::Version
|
69
|
-
version: '
|
75
|
+
version: '13.0'
|
70
76
|
- !ruby/object:Gem::Dependency
|
71
|
-
name:
|
77
|
+
name: rubocop
|
72
78
|
requirement: !ruby/object:Gem::Requirement
|
73
79
|
requirements:
|
74
80
|
- - "~>"
|
75
81
|
- !ruby/object:Gem::Version
|
76
|
-
version:
|
82
|
+
version: 0.80.1
|
77
83
|
type: :development
|
78
84
|
prerelease: false
|
79
85
|
version_requirements: !ruby/object:Gem::Requirement
|
80
86
|
requirements:
|
81
87
|
- - "~>"
|
82
88
|
- !ruby/object:Gem::Version
|
83
|
-
version:
|
89
|
+
version: 0.80.1
|
84
90
|
- !ruby/object:Gem::Dependency
|
85
|
-
name:
|
91
|
+
name: shoulda-context
|
86
92
|
requirement: !ruby/object:Gem::Requirement
|
87
93
|
requirements:
|
88
|
-
- - "
|
94
|
+
- - "~>"
|
89
95
|
- !ruby/object:Gem::Version
|
90
|
-
version: '
|
96
|
+
version: '1.2'
|
91
97
|
type: :development
|
92
98
|
prerelease: false
|
93
99
|
version_requirements: !ruby/object:Gem::Requirement
|
94
100
|
requirements:
|
95
|
-
- - "
|
101
|
+
- - "~>"
|
96
102
|
- !ruby/object:Gem::Version
|
97
|
-
version: '
|
103
|
+
version: '1.2'
|
98
104
|
description: A little library for parsing GitHub @mentions and issue references
|
99
105
|
email:
|
100
106
|
- support@codetree.com
|
@@ -107,7 +113,6 @@ files:
|
|
107
113
|
- ".circleci/setup-rubygems.sh"
|
108
114
|
- ".gitignore"
|
109
115
|
- ".rubocop.yml"
|
110
|
-
- ".rubocop_todo.yml"
|
111
116
|
- Gemfile
|
112
117
|
- LICENSE.txt
|
113
118
|
- README.md
|
@@ -119,11 +124,6 @@ files:
|
|
119
124
|
- lib/ping/parser.rb
|
120
125
|
- lib/ping/version.rb
|
121
126
|
- ping.gemspec
|
122
|
-
- test/ping/config_test.rb
|
123
|
-
- test/ping/issue_reference_test.rb
|
124
|
-
- test/ping/mention_test.rb
|
125
|
-
- test/ping/parser_test.rb
|
126
|
-
- test/test_helper.rb
|
127
127
|
homepage: https://github.com/codetree/ping
|
128
128
|
licenses:
|
129
129
|
- MIT
|
@@ -136,7 +136,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
136
136
|
requirements:
|
137
137
|
- - ">="
|
138
138
|
- !ruby/object:Gem::Version
|
139
|
-
version: 2.
|
139
|
+
version: '2.4'
|
140
140
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
141
141
|
requirements:
|
142
142
|
- - ">="
|
@@ -147,9 +147,4 @@ rubygems_version: 3.0.3
|
|
147
147
|
signing_key:
|
148
148
|
specification_version: 4
|
149
149
|
summary: Parse @mentions and issue references
|
150
|
-
test_files:
|
151
|
-
- test/ping/config_test.rb
|
152
|
-
- test/ping/issue_reference_test.rb
|
153
|
-
- test/ping/mention_test.rb
|
154
|
-
- test/ping/parser_test.rb
|
155
|
-
- test/test_helper.rb
|
150
|
+
test_files: []
|
data/.rubocop_todo.yml
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
# This configuration was generated by `rubocop --auto-gen-config`
|
2
|
-
# on 2015-08-01 15:11:49 -0700 using RuboCop version 0.32.1.
|
3
|
-
# The point is for the user to remove these configuration records
|
4
|
-
# one by one as the offenses are removed from the code base.
|
5
|
-
# Note that changes in the inspected code, or installation of new
|
6
|
-
# versions of RuboCop, may require this file to be generated again.
|
7
|
-
|
8
|
-
# Offense count: 1
|
9
|
-
# Configuration parameters: CountComments.
|
10
|
-
Metrics/ClassLength:
|
11
|
-
Max: 335
|
12
|
-
|
13
|
-
# Offense count: 7
|
14
|
-
# Configuration parameters: AllowURI, URISchemes.
|
15
|
-
Metrics/LineLength:
|
16
|
-
Max: 93
|
17
|
-
|
18
|
-
# Offense count: 4
|
19
|
-
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
20
|
-
Style/ClassAndModuleChildren:
|
21
|
-
Enabled: false
|
22
|
-
|
23
|
-
# Offense count: 9
|
24
|
-
Style/Documentation:
|
25
|
-
Enabled: false
|
26
|
-
|
27
|
-
# Offense count: 1
|
28
|
-
Style/OpMethod:
|
29
|
-
Enabled: false
|
data/test/ping/config_test.rb
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../test_helper.rb'
|
2
|
-
|
3
|
-
class Ping::ConfigTest < MiniTest::Test
|
4
|
-
def setup
|
5
|
-
Ping.reset
|
6
|
-
end
|
7
|
-
|
8
|
-
context '#default qualifiers' do
|
9
|
-
should "have default qualifiers" do
|
10
|
-
default_qualifiers = Ping::Config::DEFAULT_QUALIFIERS
|
11
|
-
|
12
|
-
Ping.config.qualifiers.each do |q|
|
13
|
-
assert default_qualifiers.include?(q)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
context '#with custom configuration' do
|
19
|
-
setup do
|
20
|
-
@custom_qualifiers = %w(fix epic needed-by close)
|
21
|
-
|
22
|
-
Ping.configure do |config|
|
23
|
-
config.qualifiers = @custom_qualifiers
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
should 'include custom qualifiers' do
|
28
|
-
Ping.config.qualifiers.each do |q|
|
29
|
-
assert @custom_qualifiers.include?(q)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
should 'not include unknown qualifiers' do
|
34
|
-
unknown_qualifiers = %w(resolve require done)
|
35
|
-
|
36
|
-
unknown_qualifiers.each do |q|
|
37
|
-
assert !Ping.config.qualifiers.include?(q)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
@@ -1,481 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../test_helper.rb'
|
2
|
-
|
3
|
-
class Ping::IssueReferenceTest < MiniTest::Test
|
4
|
-
def setup
|
5
|
-
Ping.reset
|
6
|
-
end
|
7
|
-
|
8
|
-
def extract(text)
|
9
|
-
Ping::IssueReference.extract(text)
|
10
|
-
end
|
11
|
-
|
12
|
-
def extract_first(text)
|
13
|
-
Ping::IssueReference.extract(text).first
|
14
|
-
end
|
15
|
-
|
16
|
-
context '.extract with standard syntax' do
|
17
|
-
should 'extract single issue references' do
|
18
|
-
text = 'See #43'
|
19
|
-
issue = extract_first(text)
|
20
|
-
|
21
|
-
assert_nil issue.qualifier
|
22
|
-
assert_nil issue.repository
|
23
|
-
assert_equal '43', issue.number
|
24
|
-
end
|
25
|
-
|
26
|
-
should 'extract single issue references followed by a period' do
|
27
|
-
text = 'See #43.'
|
28
|
-
issue = extract_first(text)
|
29
|
-
|
30
|
-
assert_nil issue.qualifier
|
31
|
-
assert_nil issue.repository
|
32
|
-
assert_equal '43', issue.number
|
33
|
-
end
|
34
|
-
|
35
|
-
should 'extract close qualifiers' do
|
36
|
-
%w(fix fixes fixed close closes closed resolve resolves resolved).each do |q|
|
37
|
-
text = "#{q} #55"
|
38
|
-
issue = extract_first(text)
|
39
|
-
|
40
|
-
assert_equal q, issue.qualifier
|
41
|
-
assert_nil issue.repository
|
42
|
-
assert_equal '55', issue.number
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
should 'extract dependency qualifiers' do
|
47
|
-
%w(need needs needed require requires required).each do |q|
|
48
|
-
text = "#{q} #123"
|
49
|
-
issue = extract_first(text)
|
50
|
-
|
51
|
-
assert_equal q, issue.qualifier
|
52
|
-
assert_nil issue.repository
|
53
|
-
assert_equal '123', issue.number
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
should 'extract repository' do
|
58
|
-
text = 'codetree/codetree#43'
|
59
|
-
issue = extract_first(text)
|
60
|
-
|
61
|
-
assert_nil issue.qualifier
|
62
|
-
assert_equal 'codetree/codetree', issue.repository
|
63
|
-
assert_equal '43', issue.number
|
64
|
-
end
|
65
|
-
|
66
|
-
should 'extract repository with qualifier' do
|
67
|
-
text = 'Fixes codetree/codetree#43'
|
68
|
-
issue = extract_first(text)
|
69
|
-
|
70
|
-
assert_equal 'Fixes', issue.qualifier
|
71
|
-
assert_equal 'codetree/codetree', issue.repository
|
72
|
-
assert_equal '43', issue.number
|
73
|
-
end
|
74
|
-
|
75
|
-
should 'handle odd repository names' do
|
76
|
-
text = 'giant-sequoia-123/scaling_octokitten#43'
|
77
|
-
issue = extract_first(text)
|
78
|
-
|
79
|
-
assert_equal 'giant-sequoia-123/scaling_octokitten', issue.repository
|
80
|
-
assert_equal '43', issue.number
|
81
|
-
end
|
82
|
-
|
83
|
-
should 'extract multiple references' do
|
84
|
-
text = 'You should look at #2 and #4 because #5 fixes codetree/codetree#6'
|
85
|
-
refs = extract(text)
|
86
|
-
|
87
|
-
assert refs.include?(2)
|
88
|
-
assert refs.include?(4)
|
89
|
-
assert refs.include?(5)
|
90
|
-
assert refs.include?(6)
|
91
|
-
end
|
92
|
-
|
93
|
-
should 'not extract similar non-qualifiers' do
|
94
|
-
text = 'afixes #43'
|
95
|
-
issue = extract_first(text)
|
96
|
-
|
97
|
-
assert_nil issue.qualifier
|
98
|
-
assert_nil issue.repository
|
99
|
-
assert_equal '43', issue.number
|
100
|
-
end
|
101
|
-
|
102
|
-
should 'not choke on case' do
|
103
|
-
text = 'FIxEs #43'
|
104
|
-
issue = extract_first(text)
|
105
|
-
|
106
|
-
assert_equal 'FIxEs', issue.qualifier
|
107
|
-
assert_nil issue.repository
|
108
|
-
assert_equal '43', issue.number
|
109
|
-
end
|
110
|
-
|
111
|
-
should 'require one space between qualifier and issue' do
|
112
|
-
text = 'fixes #43'
|
113
|
-
issue = extract_first(text)
|
114
|
-
|
115
|
-
assert_nil issue.qualifier
|
116
|
-
assert_nil issue.repository
|
117
|
-
assert_equal '43', issue.number
|
118
|
-
end
|
119
|
-
|
120
|
-
should 'handle variable casing in repo names' do
|
121
|
-
text = 'needs Liquid-Labs/rf-app-admin-web-app#2'
|
122
|
-
issue = extract_first(text)
|
123
|
-
|
124
|
-
assert_equal 'needs', issue.qualifier
|
125
|
-
assert_equal 'Liquid-Labs/rf-app-admin-web-app', issue.repository
|
126
|
-
assert_equal '2', issue.number
|
127
|
-
end
|
128
|
-
|
129
|
-
context '#with custom configuration' do
|
130
|
-
setup do
|
131
|
-
@custom_qualifiers = %w(epic needed-by)
|
132
|
-
Ping.configure do |config|
|
133
|
-
config.qualifiers = Ping::Config::DEFAULT_QUALIFIERS.push(*@custom_qualifiers)
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
should 'extract default qualifiers' do
|
138
|
-
Ping::Config::DEFAULT_QUALIFIERS.each do |q|
|
139
|
-
text = "#{q} #123"
|
140
|
-
issue = extract_first(text)
|
141
|
-
|
142
|
-
assert_equal q, issue.qualifier
|
143
|
-
assert_nil issue.repository
|
144
|
-
assert_equal '123', issue.number
|
145
|
-
end
|
146
|
-
end
|
147
|
-
|
148
|
-
should 'extract custom qualifiers' do
|
149
|
-
@custom_qualifiers.each do |q|
|
150
|
-
text = "#{q} #123"
|
151
|
-
issue = extract_first(text)
|
152
|
-
|
153
|
-
assert_equal q, issue.qualifier
|
154
|
-
assert_nil issue.repository
|
155
|
-
assert_equal '123', issue.number
|
156
|
-
end
|
157
|
-
end
|
158
|
-
end
|
159
|
-
end
|
160
|
-
|
161
|
-
context '.extract with GH-XXX syntax' do
|
162
|
-
should 'extract single issue references' do
|
163
|
-
text = 'See GH-43'
|
164
|
-
issue = extract_first(text)
|
165
|
-
|
166
|
-
assert_nil issue.qualifier
|
167
|
-
assert_nil issue.repository
|
168
|
-
assert_equal '43', issue.number
|
169
|
-
end
|
170
|
-
|
171
|
-
should 'extract lower case issue references' do
|
172
|
-
text = 'See gh-43'
|
173
|
-
issue = extract_first(text)
|
174
|
-
|
175
|
-
assert_nil issue.qualifier
|
176
|
-
assert_nil issue.repository
|
177
|
-
assert_equal '43', issue.number
|
178
|
-
end
|
179
|
-
|
180
|
-
should 'extract single issue references followed by a period' do
|
181
|
-
text = 'See GH-43.'
|
182
|
-
issue = extract_first(text)
|
183
|
-
|
184
|
-
assert_nil issue.qualifier
|
185
|
-
assert_nil issue.repository
|
186
|
-
assert_equal '43', issue.number
|
187
|
-
end
|
188
|
-
|
189
|
-
should 'extract close qualifiers' do
|
190
|
-
%w(fix fixes fixed close closes closed resolve resolves resolved).each do |q|
|
191
|
-
text = "#{q} GH-55"
|
192
|
-
issue = extract_first(text)
|
193
|
-
|
194
|
-
assert_equal q, issue.qualifier
|
195
|
-
assert_nil issue.repository
|
196
|
-
assert_equal '55', issue.number
|
197
|
-
end
|
198
|
-
end
|
199
|
-
|
200
|
-
should 'extract dependency qualifiers' do
|
201
|
-
%w(need needs needed require requires required).each do |q|
|
202
|
-
text = "#{q} GH-123"
|
203
|
-
issue = extract_first(text)
|
204
|
-
|
205
|
-
assert_equal q, issue.qualifier
|
206
|
-
assert_nil issue.repository
|
207
|
-
assert_equal '123', issue.number
|
208
|
-
end
|
209
|
-
end
|
210
|
-
|
211
|
-
should 'extract multiple references' do
|
212
|
-
text = 'You should look at GH-2 and GH-4 because GH-5 fixes codetree/codetree#6'
|
213
|
-
refs = extract(text)
|
214
|
-
|
215
|
-
assert refs.include?(2)
|
216
|
-
assert refs.include?(4)
|
217
|
-
assert refs.include?(5)
|
218
|
-
assert refs.include?(6)
|
219
|
-
end
|
220
|
-
|
221
|
-
should 'not extract similar non-qualifiers' do
|
222
|
-
text = 'afixes GH-43'
|
223
|
-
issue = extract_first(text)
|
224
|
-
|
225
|
-
assert_nil issue.qualifier
|
226
|
-
assert_nil issue.repository
|
227
|
-
assert_equal '43', issue.number
|
228
|
-
end
|
229
|
-
|
230
|
-
should 'not choke on case' do
|
231
|
-
text = 'FIxEs GH-43'
|
232
|
-
issue = extract_first(text)
|
233
|
-
|
234
|
-
assert_equal 'FIxEs', issue.qualifier
|
235
|
-
assert_nil issue.repository
|
236
|
-
assert_equal '43', issue.number
|
237
|
-
end
|
238
|
-
|
239
|
-
should 'require only one space between qualifier and issue' do
|
240
|
-
text = 'fixes GH-43'
|
241
|
-
issue = extract_first(text)
|
242
|
-
|
243
|
-
assert_nil issue.qualifier
|
244
|
-
assert_nil issue.repository
|
245
|
-
assert_equal '43', issue.number
|
246
|
-
end
|
247
|
-
|
248
|
-
should 'require at least one space before GH' do
|
249
|
-
text = 'fixes codetree/codetreeGH-99 and fixes GH-43'
|
250
|
-
issue = extract_first(text)
|
251
|
-
|
252
|
-
assert_equal 'fixes', issue.qualifier
|
253
|
-
assert_nil issue.repository
|
254
|
-
assert_equal '43', issue.number
|
255
|
-
end
|
256
|
-
end
|
257
|
-
|
258
|
-
context '#issue_references with URL syntax' do
|
259
|
-
should 'extract single issue references' do
|
260
|
-
text = 'See https://github.com/codetree/feedback/issues/43'
|
261
|
-
issue = extract_first(text)
|
262
|
-
|
263
|
-
assert_nil issue.qualifier
|
264
|
-
assert_equal 'codetree/feedback', issue.repository
|
265
|
-
assert_equal '43', issue.number
|
266
|
-
end
|
267
|
-
|
268
|
-
should 'extract single pull requests references' do
|
269
|
-
text = 'See https://github.com/codetree/feedback/pulls/43'
|
270
|
-
issue = extract_first(text)
|
271
|
-
|
272
|
-
assert_nil issue.qualifier
|
273
|
-
assert_equal 'codetree/feedback', issue.repository
|
274
|
-
assert_equal '43', issue.number
|
275
|
-
end
|
276
|
-
|
277
|
-
should 'extract single issue references followed by a period' do
|
278
|
-
text = 'See https://github.com/codetree/feedback/issues/43.'
|
279
|
-
issue = extract_first(text)
|
280
|
-
|
281
|
-
assert_nil issue.qualifier
|
282
|
-
assert_equal 'codetree/feedback', issue.repository
|
283
|
-
assert_equal '43', issue.number
|
284
|
-
end
|
285
|
-
|
286
|
-
should 'extract close qualifiers' do
|
287
|
-
%w(fix fixes fixed close closes closed resolve resolves resolved).each do |q|
|
288
|
-
text = "#{q} https://github.com/codetree/feedback/issues/55"
|
289
|
-
issue = extract_first(text)
|
290
|
-
assert_equal q, issue.qualifier
|
291
|
-
assert_equal 'codetree/feedback', issue.repository
|
292
|
-
assert_equal '55', issue.number
|
293
|
-
end
|
294
|
-
end
|
295
|
-
|
296
|
-
should 'extract dependency qualifiers' do
|
297
|
-
%w(need needs needed require requires required).each do |q|
|
298
|
-
text = "#{q} https://github.com/codetree/feedback/issues/123"
|
299
|
-
issue = extract_first(text)
|
300
|
-
|
301
|
-
assert_equal q, issue.qualifier
|
302
|
-
assert_equal 'codetree/feedback', issue.repository
|
303
|
-
assert_equal '123', issue.number
|
304
|
-
end
|
305
|
-
end
|
306
|
-
|
307
|
-
should 'extract multiple references' do
|
308
|
-
text = 'You should look at https://github.com/codetree/feedback/issues/2 ' \
|
309
|
-
'and https://github.com/codetree/feedback/issues/4 because ' \
|
310
|
-
'https://github.com/codetree/feedback/issues/5 fixes codetree/codetree#6'
|
311
|
-
|
312
|
-
refs = extract(text)
|
313
|
-
|
314
|
-
assert refs.include?(2)
|
315
|
-
assert refs.include?(4)
|
316
|
-
assert refs.include?(5)
|
317
|
-
assert refs.include?(6)
|
318
|
-
end
|
319
|
-
|
320
|
-
should 'not extract similar non-qualifiers' do
|
321
|
-
text = 'afixes https://github.com/codetree/feedback/issues/43'
|
322
|
-
issue = extract_first(text)
|
323
|
-
|
324
|
-
assert_nil issue.qualifier
|
325
|
-
assert_equal 'codetree/feedback', issue.repository
|
326
|
-
assert_equal '43', issue.number
|
327
|
-
end
|
328
|
-
|
329
|
-
should 'not choke on case' do
|
330
|
-
text = 'FIxEs https://github.com/codetree/feedback/issues/43'
|
331
|
-
issue = extract_first(text)
|
332
|
-
|
333
|
-
assert_equal 'FIxEs', issue.qualifier
|
334
|
-
assert_equal 'codetree/feedback', issue.repository
|
335
|
-
assert_equal '43', issue.number
|
336
|
-
end
|
337
|
-
|
338
|
-
should 'require only one space between qualifier and issue' do
|
339
|
-
text = 'fixes https://github.com/codetree/feedback/issues/43'
|
340
|
-
issue = extract_first(text)
|
341
|
-
|
342
|
-
assert_nil issue.qualifier
|
343
|
-
assert_equal 'codetree/feedback', issue.repository
|
344
|
-
assert_equal '43', issue.number
|
345
|
-
end
|
346
|
-
|
347
|
-
context '#with custom configuration' do
|
348
|
-
setup do
|
349
|
-
@custom_qualifiers = %w(epic needed-by)
|
350
|
-
Ping.configure do |config|
|
351
|
-
config.qualifiers = @custom_qualifiers
|
352
|
-
end
|
353
|
-
end
|
354
|
-
|
355
|
-
should 'extract custom qualifiers' do
|
356
|
-
@custom_qualifiers.each do |q|
|
357
|
-
text = "#{q} https://github.com/codetree/feedback/issues/123"
|
358
|
-
issue = extract_first(text)
|
359
|
-
|
360
|
-
assert_equal q, issue.qualifier
|
361
|
-
assert_equal 'codetree/feedback', issue.repository
|
362
|
-
assert_equal '123', issue.number
|
363
|
-
end
|
364
|
-
end
|
365
|
-
end
|
366
|
-
end
|
367
|
-
|
368
|
-
context '.replace' do
|
369
|
-
should 'yield the phrase and parsed reference' do
|
370
|
-
text = 'Fixes codetree/codetree#123 needs codetree/feedback#456'
|
371
|
-
|
372
|
-
expected = [
|
373
|
-
'Fixes codetree/codetree#123',
|
374
|
-
' needs codetree/feedback#456'
|
375
|
-
]
|
376
|
-
|
377
|
-
Ping::IssueReference.replace(text) do |phrase, reference|
|
378
|
-
expected_phrase = expected.shift
|
379
|
-
expected_reference = Ping::IssueReference.extract(expected_phrase).first
|
380
|
-
|
381
|
-
assert_equal expected_phrase, phrase
|
382
|
-
assert_equal expected_reference, reference
|
383
|
-
end
|
384
|
-
end
|
385
|
-
|
386
|
-
context 'given a IssueReference replacement' do
|
387
|
-
should 'handle qualifier + repo + number' do
|
388
|
-
text = 'Fixes a/b#123 fixes #456'
|
389
|
-
|
390
|
-
result = Ping::IssueReference.replace(text) do |_phrase, reference|
|
391
|
-
reference.tap do |r|
|
392
|
-
r.repository = 'codetree/feedback' unless r.repository
|
393
|
-
end
|
394
|
-
end
|
395
|
-
|
396
|
-
assert_equal 'Fixes a/b#123 fixes codetree/feedback#456', result
|
397
|
-
end
|
398
|
-
|
399
|
-
should 'handle qualifier + number' do
|
400
|
-
text = 'Fixes #123 fixes #456'
|
401
|
-
|
402
|
-
result = Ping::IssueReference.replace(text) do |_phrase, reference|
|
403
|
-
reference.tap do |r|
|
404
|
-
r.qualifier = 'needs'
|
405
|
-
r.repository = 'a/b'
|
406
|
-
end
|
407
|
-
end
|
408
|
-
|
409
|
-
assert_equal 'needs a/b#123 needs a/b#456', result
|
410
|
-
end
|
411
|
-
|
412
|
-
should 'handle repo + number' do
|
413
|
-
text = 'a/b#123 b/c#456'
|
414
|
-
|
415
|
-
result = Ping::IssueReference.replace(text) do |_phrase, reference|
|
416
|
-
reference.tap do |r|
|
417
|
-
r.qualifier = 'needs'
|
418
|
-
r.repository = 'd/e'
|
419
|
-
end
|
420
|
-
end
|
421
|
-
|
422
|
-
assert_equal 'needs d/e#123 needs d/e#456', result
|
423
|
-
end
|
424
|
-
|
425
|
-
should 'handle number only' do
|
426
|
-
text = '#123 #456'
|
427
|
-
|
428
|
-
result = Ping::IssueReference.replace(text) do |_phrase, reference|
|
429
|
-
reference.tap do |r|
|
430
|
-
r.repository = 'd/e'
|
431
|
-
end
|
432
|
-
end
|
433
|
-
|
434
|
-
assert_equal 'd/e#123 d/e#456', result
|
435
|
-
end
|
436
|
-
end
|
437
|
-
|
438
|
-
context 'given a string replacement' do
|
439
|
-
should 'replace references' do
|
440
|
-
text = 'Fixes a/b#123 fixes #456'
|
441
|
-
|
442
|
-
result = Ping::IssueReference.replace(text) do |phrase, _reference|
|
443
|
-
phrase + ' bar'
|
444
|
-
end
|
445
|
-
|
446
|
-
assert_equal 'Fixes a/b#123 bar fixes #456 bar', result
|
447
|
-
end
|
448
|
-
end
|
449
|
-
end
|
450
|
-
|
451
|
-
context '#==' do
|
452
|
-
should 'compare with integers' do
|
453
|
-
issue = Ping::IssueReference.new('fixes', 'codetree/codetree', '123')
|
454
|
-
assert issue == 123
|
455
|
-
end
|
456
|
-
|
457
|
-
should 'compare with strings' do
|
458
|
-
issue = Ping::IssueReference.new('fixes', 'codetree/codetree', '123')
|
459
|
-
assert issue == '123'
|
460
|
-
end
|
461
|
-
|
462
|
-
should 'compare with issues' do
|
463
|
-
issue = Ping::IssueReference.new('fixes', 'codetree/codetree', '123')
|
464
|
-
assert issue == Ping::IssueReference.new(nil, 'codetree/codetree', '123')
|
465
|
-
end
|
466
|
-
end
|
467
|
-
|
468
|
-
context '#to_s' do
|
469
|
-
should 'return the issue number' do
|
470
|
-
issue = Ping::IssueReference.new('Fixes', 'codetree/codetree', '123')
|
471
|
-
assert_equal '123', issue.to_s
|
472
|
-
end
|
473
|
-
end
|
474
|
-
|
475
|
-
context '#to_i' do
|
476
|
-
should 'return the integer issue number' do
|
477
|
-
issue = Ping::IssueReference.new('Fixes', 'codetree/codetree', '123')
|
478
|
-
assert_equal 123, issue.to_i
|
479
|
-
end
|
480
|
-
end
|
481
|
-
end
|
data/test/ping/mention_test.rb
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../test_helper.rb'
|
2
|
-
|
3
|
-
class Ping::MentionTest < MiniTest::Test
|
4
|
-
def extract(text)
|
5
|
-
Ping::Mention.extract(text)
|
6
|
-
end
|
7
|
-
|
8
|
-
def extract_first(text)
|
9
|
-
Ping::Mention.extract(text).first
|
10
|
-
end
|
11
|
-
|
12
|
-
context '.extract' do
|
13
|
-
should 'extract @mentions' do
|
14
|
-
text = "Hey there, @djreimer. How's @defunkt?"
|
15
|
-
result = extract(text)
|
16
|
-
assert result.include?('djreimer')
|
17
|
-
assert result.include?('defunkt')
|
18
|
-
end
|
19
|
-
|
20
|
-
should 'de-dup mentions' do
|
21
|
-
text = "Hey there, @djreimer. How's @djreimer?"
|
22
|
-
result = extract(text)
|
23
|
-
assert_equal 1, result.length
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
context '#==' do
|
28
|
-
should 'compare with strings' do
|
29
|
-
mention = Ping::Mention.new('djreimer')
|
30
|
-
assert mention == 'djreimer'
|
31
|
-
end
|
32
|
-
|
33
|
-
should 'compare with mentions' do
|
34
|
-
mention = Ping::Mention.new('djreimer')
|
35
|
-
assert mention == Ping::Mention.new('djreimer')
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
context '#to_s' do
|
40
|
-
should 'return the username' do
|
41
|
-
mention = Ping::Mention.new('djreimer')
|
42
|
-
assert_equal 'djreimer', mention.to_s
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
data/test/ping/parser_test.rb
DELETED