ping 0.0.8 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 53bcca036a31b4ffcaeab4ea6ac4c1a645dba51b
4
- data.tar.gz: ae2324d2655747a23f261fa733f91a79651f9611
2
+ SHA256:
3
+ metadata.gz: 4b72814d428ea3a2db8f4c7aafd0df25d4be72402bb4f1345da8f24635d07a17
4
+ data.tar.gz: 200b1aed0640d89e91730c7d29b7356e42ab19074c06f9d8c3b855814a4915c9
5
5
  SHA512:
6
- metadata.gz: c20cdfbb8bc258e14d51213f0fedb1bdf357e72b4ae3f36a44d8efadc8d26bb1957c42c7f00e825971529906767e4101e7f27978ce781e25954459e64a509217
7
- data.tar.gz: 05464ba9e01249d5c89d90360c7f2413f369a7bd8f4a5b4483d7f11e63fbeb125d6f0c26cd16eb0a39347230da6b02916f681a0417174da23dcc1e3522aa8522
6
+ metadata.gz: b5a1a8053177c0ee4395ddd325c7acad96a7500f3190069dc50c54a95d00ee8fe339a94b2482ecf2d1cf523f5517156d7059454e81bb8a066d0add270c0e074b
7
+ data.tar.gz: d6d88258ce8b7e886eafad4888db0cf1906585fbf56375f87495127f3a13a0bd8dce9b21a5255f82e248ed65256481900241c0a46024d0d34eb04a4365314458
@@ -0,0 +1,76 @@
1
+ version: 2.1
2
+
3
+ environment: &environment
4
+ LOG_LEVEL: WARN
5
+
6
+ jobs:
7
+ functional_tests:
8
+ working_directory: ~/repos/ping
9
+
10
+ docker:
11
+ - image: circleci/ruby:2.6.4-buster-node
12
+ environment:
13
+ <<: *environment
14
+
15
+ steps:
16
+ - checkout
17
+
18
+ - run:
19
+ name: check dependencies
20
+ command: |
21
+ bundle -v
22
+ bundle exec ruby -v
23
+
24
+ - restore_cache:
25
+ keys:
26
+ - ping-bundle-v2-{{ checksum "ping.gemspec" }}
27
+ - ping-bundle-v2-
28
+
29
+ - run:
30
+ name: install gems
31
+ command: bundle install && bundle clean
32
+
33
+ - save_cache:
34
+ key: ping-bundle-v2-{{ checksum "ping.gemspec" }}
35
+ paths:
36
+ - vendor/bundle
37
+
38
+ - run:
39
+ name: run functional tests
40
+ command: bundle exec rake test
41
+
42
+ - store_test_results:
43
+ path: test_results
44
+
45
+ publish_to_rubygems:
46
+ working_directory: ~/repos/ping
47
+
48
+ docker:
49
+ - image: circleci/ruby:2.6.4-buster-node
50
+ environment:
51
+ <<: *environment
52
+
53
+ steps:
54
+ - checkout
55
+
56
+ - run:
57
+ name: setup Rubygems
58
+ command: bash .circleci/setup-rubygems.sh
59
+
60
+ - run:
61
+ name: publish to Rubygems
62
+ command: |
63
+ gem build ping.gemspec
64
+ gem push "ping-$(git describe --abbrev=0 --tags | cut -c 2-).gem"
65
+
66
+ workflows:
67
+ version: 2
68
+ build_and_test:
69
+ jobs:
70
+ - functional_tests
71
+ - publish_to_rubygems:
72
+ filters:
73
+ tags:
74
+ only: /.*/
75
+ branches:
76
+ ignore: /.*/
@@ -0,0 +1,3 @@
1
+ mkdir ~/.gem
2
+ echo -e "---\r\n:rubygems_api_key: $RUBYGEMS_API_KEY" > ~/.gem/credentials
3
+ chmod 0600 /home/circleci/.gem/credentials
data/.gitignore CHANGED
@@ -3,9 +3,9 @@
3
3
  .bundle
4
4
  .config
5
5
  .yardoc
6
- Gemfile.lock
7
6
  InstalledFiles
8
7
  _yardoc
8
+ Gemfile.lock
9
9
  coverage
10
10
  doc/
11
11
  lib/bundler/man
@@ -2,3 +2,10 @@ inherit_from: .rubocop_todo.yml
2
2
 
3
3
  Style/RegexpLiteral:
4
4
  AllowInnerSlashes: true
5
+
6
+ AllCops:
7
+ Exclude:
8
+ - 'test/ping/*'
9
+ - 'ping.gemspec'
10
+ - 'lib/ping/version.rb'
11
+ - 'vendor/**/*'
data/Gemfile CHANGED
@@ -2,3 +2,5 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in ping.gemspec
4
4
  gemspec
5
+
6
+ gem 'rake', '13.0.1'
@@ -1,4 +1,4 @@
1
- Copyright (c) 2014 Derrick Reimer
1
+ Copyright (c) 2014-2016 Derrick Reimer
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Ping
1
+ # Ping [![Circle CI](https://circleci.com/gh/codetree/ping.svg?style=svg)](https://circleci.com/gh/codetree/ping)
2
2
 
3
3
  A little library for extracting GitHub @mentions and issue references.
4
4
 
@@ -16,9 +16,47 @@ Or install it yourself as:
16
16
 
17
17
  $ gem install ping
18
18
 
19
- ## Usage
19
+ ## Basic Usage
20
20
 
21
- TODO: Write usage instructions here
21
+ Simply load a new parser object and extract issue references and mentions. Here are examples.
22
+
23
+ #### issue references
24
+
25
+ ``` ruby
26
+ parser = Ping::Parser.new('closed codetree/ping#25')
27
+ parser.issue_references # => [#<Ping::IssueReference:0x000056099c3cf400 @number="25", @qualifier="closed", @repository='codetree/ping'>]
28
+ ```
29
+
30
+ #### mentions
31
+
32
+ ``` ruby
33
+ parser = Ping::Mention.new('Hey @djreimer, please look into the bug.')
34
+ parser.mentions # => [#<Ping::Mention:0x000055ad151f43d0 @username="djreimer">]
35
+ ```
36
+
37
+ ## Configuration
38
+
39
+ gem provided some default qualifiers to extract issue references
40
+
41
+ ``` ruby
42
+ DEFAULT_QUALIFIERS = [
43
+ 'close', 'closes', 'closed', 'fix', 'fixes', 'fixed', 'need', 'needs', 'needed',
44
+ 'require', 'requires', 'required', 'resolve', 'resolves', 'resolved'
45
+ ]
46
+ ```
47
+
48
+ but you can also define your own qualifiers along with default qualifiers
49
+
50
+ ``` ruby
51
+ ## config/initializers/ping.rb
52
+
53
+ require 'ping'
54
+
55
+ Ping.configure do |config|
56
+ config.qualifiers = Ping::DEFAULT_QUALIFIERS.push(*['epic' 'needed-by'])
57
+ end
58
+ ```
59
+ ** Note: qualifiers must be an array of qualifier words
22
60
 
23
61
  ## Contributing
24
62
 
@@ -27,3 +65,7 @@ TODO: Write usage instructions here
27
65
  3. Commit your changes (`git commit -am 'Add some feature'`)
28
66
  4. Push to the branch (`git push origin my-new-feature`)
29
67
  5. Create a new Pull Request
68
+
69
+ ## Updating RubyGems
70
+ 1. Create an annotated tag `git tag -a v0.1.0 -m "msg with the tag`
71
+ 2. Push tag to Github `github push --tags`
@@ -0,0 +1,33 @@
1
+ module Ping
2
+ class << self
3
+ attr_accessor :config
4
+
5
+ def configure
6
+ yield config
7
+ end
8
+
9
+ def config
10
+ @config ||= Config.new
11
+ end
12
+
13
+ # Here we are implementing a reset method because
14
+ # for global values like this, it’s best to clean up before/after
15
+ # each spec to ensure the system is back to a default state.
16
+ def reset
17
+ @config = Config.new
18
+ end
19
+ end
20
+
21
+ class Config
22
+ attr_accessor :qualifiers
23
+
24
+ DEFAULT_QUALIFIERS = [
25
+ 'close', 'closes', 'closed', 'fix', 'fixes', 'fixed', 'need', 'needs', 'needed',
26
+ 'require', 'requires', 'required', 'resolve', 'resolves', 'resolved'
27
+ ]
28
+
29
+ def initialize
30
+ @qualifiers = DEFAULT_QUALIFIERS
31
+ end
32
+ end
33
+ end
@@ -2,92 +2,97 @@ module Ping
2
2
  class IssueReference
3
3
  attr_accessor :qualifier, :repository, :number
4
4
 
5
- QUALIFIERS = /
6
- close|closes|closed|fix|fixes|fixed|resolve|resolves|resolved|
7
- need|needs|needed|require|requires|required
8
- /ix
9
-
10
5
  REPOSITORY_NAME = /[a-z0-9][a-z0-9\-]*\/[a-z0-9][a-z0-9\-_]*/ix
11
6
 
12
- # Match references of the form:
13
- #
14
- # - #123
15
- # - codetree/feedback#123
16
- # - GH-123
17
- # - needs #123
18
- # - etc...
19
- #
20
- # See http://rubular.com/r/evB7RlvUfI
21
- SHORT_PATTERN = /
22
- (?:^|\W) # beginning of string or non-word char
23
- (?:(#{QUALIFIERS})(?:\s))? # qualifier (optional)
24
- (?:(#{REPOSITORY_NAME})? # repository name (optional)
25
- \#|(?:GH\-))(\d+) # issue number
26
- (?=
27
- \.+[ \t\W]| # dots followed by space or non-word character
28
- \.+$| # dots at end of line
29
- [^0-9a-zA-Z_.]| # non-word character except dot
30
- $ # end of line
31
- )
32
- /ix
7
+ class << self
8
+ def qualifier_regex
9
+ /#{Ping.config.qualifiers.join('|')}/ix
10
+ end
33
11
 
34
- # Match references of the form:
35
- #
36
- # - https://github.com/codetree/feedback/issues/123
37
- # - https://github.com/codetree/feedback/pulls/123
38
- # - needs https://github.com/codetree/feedback/issues/123
39
- # - etc...
40
- URL_PATTERN = /
41
- (?:^|\W) # beginning of string or non-word char
42
- (?:(#{QUALIFIERS})(?:\s))? # qualifier (optional)
43
- https:\/\/github.com\/
44
- (#{REPOSITORY_NAME}) # repository name
45
- \/(?:issues|pulls)\/
46
- (\d+) # issue number
47
- (?=
48
- \.+[ \t\W]| # dots followed by space or non-word character
49
- \.+$| # dots at end of line
50
- [^0-9a-zA-Z_.]| # non-word character except dot
51
- $ # end of line
52
- )
53
- /ix
12
+ # Match references of the form:
13
+ #
14
+ # - #123
15
+ # - codetree/feedback#123
16
+ # - GH-123
17
+ # - needs #123
18
+ # - etc...
19
+ #
20
+ # See http://rubular.com/r/evB7RlvUfI
21
+ def short_pattern
22
+ /
23
+ (?:^|\W) # beginning of string or non-word char
24
+ (?:(#{qualifier_regex})(?:\s))? # qualifier (optional)
25
+ (?:(#{REPOSITORY_NAME})? # repository name (optional)
26
+ \#|(?:GH\-))(\d+) # issue number
27
+ (?=
28
+ \.+[ \t]| # dots followed by space or non-word character
29
+ \.+$| # dots at end of line
30
+ [^0-9a-zA-Z_.]| # non-word character except dot
31
+ $ # end of line
32
+ )
33
+ /ix
34
+ end
54
35
 
55
- def initialize(qualifier, repository, number)
56
- @qualifier = qualifier
57
- @repository = repository
58
- @number = number
59
- end
36
+ # Match references of the form:
37
+ #
38
+ # - https://github.com/codetree/feedback/issues/123
39
+ # - https://github.com/codetree/feedback/pulls/123
40
+ # - needs https://github.com/codetree/feedback/issues/123
41
+ # - etc...
42
+ def url_pattern
43
+ /
44
+ (?:^|\W) # beginning of string or non-word char
45
+ (?:(#{qualifier_regex})(?:\s))? # qualifier (optional)
46
+ https:\/\/github.com\/
47
+ (#{REPOSITORY_NAME}) # repository name
48
+ \/(?:issues|pulls)\/
49
+ (\d+) # issue number
50
+ (?=
51
+ \.+[ \t]| # dots followed by space or non-word character
52
+ \.+$| # dots at end of line
53
+ [^0-9a-zA-Z_.]| # non-word character except dot
54
+ $ # end of line
55
+ )
56
+ /ix
57
+ end
60
58
 
61
- def self.extract(text)
62
- [SHORT_PATTERN, URL_PATTERN].inject([]) do |memo, pattern|
63
- memo.tap do |m|
64
- text.scan(pattern).each do |match|
65
- m << new(*match)
59
+ def extract(text)
60
+ [short_pattern, url_pattern].inject([]) do |memo, pattern|
61
+ memo.tap do |m|
62
+ text.scan(pattern).each do |match|
63
+ m << new(*match)
64
+ end
66
65
  end
67
66
  end
68
67
  end
69
- end
70
68
 
71
- def self.replace(text, &block)
72
- [SHORT_PATTERN, URL_PATTERN].each do |pattern|
73
- text = text.gsub(pattern) do |match|
74
- ref = new(*match.scan(pattern).first)
75
- replace_match(match, ref, &block)
69
+ def replace(text, &block)
70
+ [short_pattern, url_pattern].each do |pattern|
71
+ text = text.gsub(pattern) do |match|
72
+ ref = new(*match.scan(pattern).first)
73
+ replace_match(match, ref, &block)
74
+ end
76
75
  end
76
+
77
+ text
77
78
  end
78
79
 
79
- text
80
- end
80
+ def replace_match(match, ref, &_block)
81
+ replacement = yield(match, ref)
82
+ return replacement unless replacement.is_a?(IssueReference)
81
83
 
82
- def self.replace_match(match, ref, &_block)
83
- replacement = yield(match, ref)
84
- return replacement unless replacement.is_a?(IssueReference)
84
+ # Reformat the given issue reference replacement to match
85
+ new_phrase = match[0] == ' ' ? ' ' : '' # fix leading space
86
+ new_phrase << replacement.qualifier + ' ' if replacement.qualifier
87
+ new_phrase << replacement.repository.to_s
88
+ new_phrase << '#' + replacement.number.to_s
89
+ end
90
+ end
85
91
 
86
- # Reformat the given issue reference replacement to match
87
- new_phrase = match[0] == ' ' ? ' ' : '' # fix leading space
88
- new_phrase << replacement.qualifier + ' ' if replacement.qualifier
89
- new_phrase << replacement.repository.to_s
90
- new_phrase << '#' + replacement.number.to_s
92
+ def initialize(qualifier, repository, number)
93
+ @qualifier = qualifier
94
+ @repository = repository
95
+ @number = number
91
96
  end
92
97
 
93
98
  def ==(other)
@@ -7,7 +7,7 @@ module Ping
7
7
  @((?>[a-z0-9][a-z0-9-]*)) # @username
8
8
  (?!\/) # without a trailing slash
9
9
  (?=
10
- \.+[ \t\W]| # dots followed by space or non-word character
10
+ \.+[ \t]| # dots followed by space or non-word character
11
11
  \.+$| # dots at end of line
12
12
  [^0-9a-zA-Z_.]| # non-word character except dot
13
13
  $ # end of line
@@ -20,9 +20,9 @@ module Ping
20
20
 
21
21
  def self.extract(text)
22
22
  text.scan(PATTERN).flatten
23
- .map(&:downcase).uniq.map do |username|
24
- new(username)
25
- end
23
+ .map(&:downcase).uniq.map do |username|
24
+ new(username)
25
+ end
26
26
  end
27
27
 
28
28
  def ==(username)
@@ -1,3 +1,4 @@
1
+ require "ping/config"
1
2
  require 'ping/mention'
2
3
  require 'ping/issue_reference'
3
4
 
@@ -1,3 +1,3 @@
1
1
  module Ping
2
- VERSION = '0.0.8'
2
+ VERSION = '0.1.0'
3
3
  end
@@ -4,19 +4,19 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'ping/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = 'ping'
8
- spec.version = Ping::VERSION
9
- spec.authors = ['Derrick Reimer']
10
- spec.email = ['derrickreimer@gmail.com']
11
- spec.summary = 'Parse @mentions and issue references'
12
- spec.description = 'A little library for parsing GitHub @mentions and issue references'
13
- spec.homepage = 'https://github.com/codetree/ping'
14
- spec.license = 'MIT'
15
-
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)\//)
19
- spec.require_paths = ['lib']
7
+ spec.name = 'ping'
8
+ spec.version = Ping::VERSION
9
+ spec.authors = ['Codetree', 'Derrick Reimer']
10
+ spec.email = ['support@codetree.com', 'derrickreimer@gmail.com']
11
+ spec.summary = 'Parse @mentions and issue references'
12
+ spec.description = 'A little library for parsing GitHub @mentions and issue references'
13
+ spec.homepage = 'https://github.com/codetree/ping'
14
+ spec.license = 'MIT'
15
+ spec.required_ruby_version = '>= 2.2.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)\//)
19
+ spec.require_paths = ['lib']
20
20
 
21
21
  spec.add_development_dependency 'bundler', '~> 1.6'
22
22
  spec.add_development_dependency 'rake', '~> 10.0'
@@ -0,0 +1,41 @@
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,6 +1,10 @@
1
1
  require File.dirname(__FILE__) + '/../test_helper.rb'
2
2
 
3
3
  class Ping::IssueReferenceTest < MiniTest::Test
4
+ def setup
5
+ Ping.reset
6
+ end
7
+
4
8
  def extract(text)
5
9
  Ping::IssueReference.extract(text)
6
10
  end
@@ -14,8 +18,8 @@ class Ping::IssueReferenceTest < MiniTest::Test
14
18
  text = 'See #43'
15
19
  issue = extract_first(text)
16
20
 
17
- assert_equal nil, issue.qualifier
18
- assert_equal nil, issue.repository
21
+ assert_nil issue.qualifier
22
+ assert_nil issue.repository
19
23
  assert_equal '43', issue.number
20
24
  end
21
25
 
@@ -23,8 +27,8 @@ class Ping::IssueReferenceTest < MiniTest::Test
23
27
  text = 'See #43.'
24
28
  issue = extract_first(text)
25
29
 
26
- assert_equal nil, issue.qualifier
27
- assert_equal nil, issue.repository
30
+ assert_nil issue.qualifier
31
+ assert_nil issue.repository
28
32
  assert_equal '43', issue.number
29
33
  end
30
34
 
@@ -34,7 +38,7 @@ class Ping::IssueReferenceTest < MiniTest::Test
34
38
  issue = extract_first(text)
35
39
 
36
40
  assert_equal q, issue.qualifier
37
- assert_equal nil, issue.repository
41
+ assert_nil issue.repository
38
42
  assert_equal '55', issue.number
39
43
  end
40
44
  end
@@ -45,7 +49,7 @@ class Ping::IssueReferenceTest < MiniTest::Test
45
49
  issue = extract_first(text)
46
50
 
47
51
  assert_equal q, issue.qualifier
48
- assert_equal nil, issue.repository
52
+ assert_nil issue.repository
49
53
  assert_equal '123', issue.number
50
54
  end
51
55
  end
@@ -54,7 +58,7 @@ class Ping::IssueReferenceTest < MiniTest::Test
54
58
  text = 'codetree/codetree#43'
55
59
  issue = extract_first(text)
56
60
 
57
- assert_equal nil, issue.qualifier
61
+ assert_nil issue.qualifier
58
62
  assert_equal 'codetree/codetree', issue.repository
59
63
  assert_equal '43', issue.number
60
64
  end
@@ -90,8 +94,8 @@ class Ping::IssueReferenceTest < MiniTest::Test
90
94
  text = 'afixes #43'
91
95
  issue = extract_first(text)
92
96
 
93
- assert_equal nil, issue.qualifier
94
- assert_equal nil, issue.repository
97
+ assert_nil issue.qualifier
98
+ assert_nil issue.repository
95
99
  assert_equal '43', issue.number
96
100
  end
97
101
 
@@ -100,7 +104,7 @@ class Ping::IssueReferenceTest < MiniTest::Test
100
104
  issue = extract_first(text)
101
105
 
102
106
  assert_equal 'FIxEs', issue.qualifier
103
- assert_equal nil, issue.repository
107
+ assert_nil issue.repository
104
108
  assert_equal '43', issue.number
105
109
  end
106
110
 
@@ -108,8 +112,8 @@ class Ping::IssueReferenceTest < MiniTest::Test
108
112
  text = 'fixes #43'
109
113
  issue = extract_first(text)
110
114
 
111
- assert_equal nil, issue.qualifier
112
- assert_equal nil, issue.repository
115
+ assert_nil issue.qualifier
116
+ assert_nil issue.repository
113
117
  assert_equal '43', issue.number
114
118
  end
115
119
 
@@ -121,6 +125,37 @@ class Ping::IssueReferenceTest < MiniTest::Test
121
125
  assert_equal 'Liquid-Labs/rf-app-admin-web-app', issue.repository
122
126
  assert_equal '2', issue.number
123
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
124
159
  end
125
160
 
126
161
  context '.extract with GH-XXX syntax' do
@@ -128,8 +163,8 @@ class Ping::IssueReferenceTest < MiniTest::Test
128
163
  text = 'See GH-43'
129
164
  issue = extract_first(text)
130
165
 
131
- assert_equal nil, issue.qualifier
132
- assert_equal nil, issue.repository
166
+ assert_nil issue.qualifier
167
+ assert_nil issue.repository
133
168
  assert_equal '43', issue.number
134
169
  end
135
170
 
@@ -137,8 +172,8 @@ class Ping::IssueReferenceTest < MiniTest::Test
137
172
  text = 'See gh-43'
138
173
  issue = extract_first(text)
139
174
 
140
- assert_equal nil, issue.qualifier
141
- assert_equal nil, issue.repository
175
+ assert_nil issue.qualifier
176
+ assert_nil issue.repository
142
177
  assert_equal '43', issue.number
143
178
  end
144
179
 
@@ -146,8 +181,8 @@ class Ping::IssueReferenceTest < MiniTest::Test
146
181
  text = 'See GH-43.'
147
182
  issue = extract_first(text)
148
183
 
149
- assert_equal nil, issue.qualifier
150
- assert_equal nil, issue.repository
184
+ assert_nil issue.qualifier
185
+ assert_nil issue.repository
151
186
  assert_equal '43', issue.number
152
187
  end
153
188
 
@@ -157,7 +192,7 @@ class Ping::IssueReferenceTest < MiniTest::Test
157
192
  issue = extract_first(text)
158
193
 
159
194
  assert_equal q, issue.qualifier
160
- assert_equal nil, issue.repository
195
+ assert_nil issue.repository
161
196
  assert_equal '55', issue.number
162
197
  end
163
198
  end
@@ -168,7 +203,7 @@ class Ping::IssueReferenceTest < MiniTest::Test
168
203
  issue = extract_first(text)
169
204
 
170
205
  assert_equal q, issue.qualifier
171
- assert_equal nil, issue.repository
206
+ assert_nil issue.repository
172
207
  assert_equal '123', issue.number
173
208
  end
174
209
  end
@@ -187,8 +222,8 @@ class Ping::IssueReferenceTest < MiniTest::Test
187
222
  text = 'afixes GH-43'
188
223
  issue = extract_first(text)
189
224
 
190
- assert_equal nil, issue.qualifier
191
- assert_equal nil, issue.repository
225
+ assert_nil issue.qualifier
226
+ assert_nil issue.repository
192
227
  assert_equal '43', issue.number
193
228
  end
194
229
 
@@ -197,7 +232,7 @@ class Ping::IssueReferenceTest < MiniTest::Test
197
232
  issue = extract_first(text)
198
233
 
199
234
  assert_equal 'FIxEs', issue.qualifier
200
- assert_equal nil, issue.repository
235
+ assert_nil issue.repository
201
236
  assert_equal '43', issue.number
202
237
  end
203
238
 
@@ -205,8 +240,8 @@ class Ping::IssueReferenceTest < MiniTest::Test
205
240
  text = 'fixes GH-43'
206
241
  issue = extract_first(text)
207
242
 
208
- assert_equal nil, issue.qualifier
209
- assert_equal nil, issue.repository
243
+ assert_nil issue.qualifier
244
+ assert_nil issue.repository
210
245
  assert_equal '43', issue.number
211
246
  end
212
247
 
@@ -215,7 +250,7 @@ class Ping::IssueReferenceTest < MiniTest::Test
215
250
  issue = extract_first(text)
216
251
 
217
252
  assert_equal 'fixes', issue.qualifier
218
- assert_equal nil, issue.repository
253
+ assert_nil issue.repository
219
254
  assert_equal '43', issue.number
220
255
  end
221
256
  end
@@ -225,7 +260,7 @@ class Ping::IssueReferenceTest < MiniTest::Test
225
260
  text = 'See https://github.com/codetree/feedback/issues/43'
226
261
  issue = extract_first(text)
227
262
 
228
- assert_equal nil, issue.qualifier
263
+ assert_nil issue.qualifier
229
264
  assert_equal 'codetree/feedback', issue.repository
230
265
  assert_equal '43', issue.number
231
266
  end
@@ -234,7 +269,7 @@ class Ping::IssueReferenceTest < MiniTest::Test
234
269
  text = 'See https://github.com/codetree/feedback/pulls/43'
235
270
  issue = extract_first(text)
236
271
 
237
- assert_equal nil, issue.qualifier
272
+ assert_nil issue.qualifier
238
273
  assert_equal 'codetree/feedback', issue.repository
239
274
  assert_equal '43', issue.number
240
275
  end
@@ -243,7 +278,7 @@ class Ping::IssueReferenceTest < MiniTest::Test
243
278
  text = 'See https://github.com/codetree/feedback/issues/43.'
244
279
  issue = extract_first(text)
245
280
 
246
- assert_equal nil, issue.qualifier
281
+ assert_nil issue.qualifier
247
282
  assert_equal 'codetree/feedback', issue.repository
248
283
  assert_equal '43', issue.number
249
284
  end
@@ -252,7 +287,6 @@ class Ping::IssueReferenceTest < MiniTest::Test
252
287
  %w(fix fixes fixed close closes closed resolve resolves resolved).each do |q|
253
288
  text = "#{q} https://github.com/codetree/feedback/issues/55"
254
289
  issue = extract_first(text)
255
-
256
290
  assert_equal q, issue.qualifier
257
291
  assert_equal 'codetree/feedback', issue.repository
258
292
  assert_equal '55', issue.number
@@ -287,7 +321,7 @@ class Ping::IssueReferenceTest < MiniTest::Test
287
321
  text = 'afixes https://github.com/codetree/feedback/issues/43'
288
322
  issue = extract_first(text)
289
323
 
290
- assert_equal nil, issue.qualifier
324
+ assert_nil issue.qualifier
291
325
  assert_equal 'codetree/feedback', issue.repository
292
326
  assert_equal '43', issue.number
293
327
  end
@@ -305,10 +339,30 @@ class Ping::IssueReferenceTest < MiniTest::Test
305
339
  text = 'fixes https://github.com/codetree/feedback/issues/43'
306
340
  issue = extract_first(text)
307
341
 
308
- assert_equal nil, issue.qualifier
342
+ assert_nil issue.qualifier
309
343
  assert_equal 'codetree/feedback', issue.repository
310
344
  assert_equal '43', issue.number
311
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
312
366
  end
313
367
 
314
368
  context '.replace' do
@@ -3,4 +3,4 @@ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
3
3
  require 'ping'
4
4
  require 'minitest/autorun'
5
5
  require 'shoulda-context'
6
- require 'mocha/setup'
6
+ require 'mocha/api'
metadata CHANGED
@@ -1,120 +1,125 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ping
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
+ - Codetree
7
8
  - Derrick Reimer
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2015-08-01 00:00:00.000000000 Z
12
+ date: 2020-01-15 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: bundler
15
16
  requirement: !ruby/object:Gem::Requirement
16
17
  requirements:
17
- - - ~>
18
+ - - "~>"
18
19
  - !ruby/object:Gem::Version
19
20
  version: '1.6'
20
21
  type: :development
21
22
  prerelease: false
22
23
  version_requirements: !ruby/object:Gem::Requirement
23
24
  requirements:
24
- - - ~>
25
+ - - "~>"
25
26
  - !ruby/object:Gem::Version
26
27
  version: '1.6'
27
28
  - !ruby/object:Gem::Dependency
28
29
  name: rake
29
30
  requirement: !ruby/object:Gem::Requirement
30
31
  requirements:
31
- - - ~>
32
+ - - "~>"
32
33
  - !ruby/object:Gem::Version
33
34
  version: '10.0'
34
35
  type: :development
35
36
  prerelease: false
36
37
  version_requirements: !ruby/object:Gem::Requirement
37
38
  requirements:
38
- - - ~>
39
+ - - "~>"
39
40
  - !ruby/object:Gem::Version
40
41
  version: '10.0'
41
42
  - !ruby/object:Gem::Dependency
42
43
  name: minitest
43
44
  requirement: !ruby/object:Gem::Requirement
44
45
  requirements:
45
- - - ~>
46
+ - - "~>"
46
47
  - !ruby/object:Gem::Version
47
48
  version: '5.0'
48
49
  type: :development
49
50
  prerelease: false
50
51
  version_requirements: !ruby/object:Gem::Requirement
51
52
  requirements:
52
- - - ~>
53
+ - - "~>"
53
54
  - !ruby/object:Gem::Version
54
55
  version: '5.0'
55
56
  - !ruby/object:Gem::Dependency
56
57
  name: shoulda-context
57
58
  requirement: !ruby/object:Gem::Requirement
58
59
  requirements:
59
- - - ~>
60
+ - - "~>"
60
61
  - !ruby/object:Gem::Version
61
62
  version: '1.2'
62
63
  type: :development
63
64
  prerelease: false
64
65
  version_requirements: !ruby/object:Gem::Requirement
65
66
  requirements:
66
- - - ~>
67
+ - - "~>"
67
68
  - !ruby/object:Gem::Version
68
69
  version: '1.2'
69
70
  - !ruby/object:Gem::Dependency
70
71
  name: mocha
71
72
  requirement: !ruby/object:Gem::Requirement
72
73
  requirements:
73
- - - ~>
74
+ - - "~>"
74
75
  - !ruby/object:Gem::Version
75
76
  version: '1.0'
76
77
  type: :development
77
78
  prerelease: false
78
79
  version_requirements: !ruby/object:Gem::Requirement
79
80
  requirements:
80
- - - ~>
81
+ - - "~>"
81
82
  - !ruby/object:Gem::Version
82
83
  version: '1.0'
83
84
  - !ruby/object:Gem::Dependency
84
85
  name: rubocop
85
86
  requirement: !ruby/object:Gem::Requirement
86
87
  requirements:
87
- - - '>='
88
+ - - ">="
88
89
  - !ruby/object:Gem::Version
89
90
  version: '0'
90
91
  type: :development
91
92
  prerelease: false
92
93
  version_requirements: !ruby/object:Gem::Requirement
93
94
  requirements:
94
- - - '>='
95
+ - - ">="
95
96
  - !ruby/object:Gem::Version
96
97
  version: '0'
97
98
  description: A little library for parsing GitHub @mentions and issue references
98
99
  email:
100
+ - support@codetree.com
99
101
  - derrickreimer@gmail.com
100
102
  executables: []
101
103
  extensions: []
102
104
  extra_rdoc_files: []
103
105
  files:
104
- - .gitignore
105
- - .rubocop.yml
106
- - .rubocop_todo.yml
106
+ - ".circleci/config.yml"
107
+ - ".circleci/setup-rubygems.sh"
108
+ - ".gitignore"
109
+ - ".rubocop.yml"
110
+ - ".rubocop_todo.yml"
107
111
  - Gemfile
108
112
  - LICENSE.txt
109
113
  - README.md
110
114
  - Rakefile
111
- - circle.yml
112
115
  - lib/ping.rb
116
+ - lib/ping/config.rb
113
117
  - lib/ping/issue_reference.rb
114
118
  - lib/ping/mention.rb
115
119
  - lib/ping/parser.rb
116
120
  - lib/ping/version.rb
117
121
  - ping.gemspec
122
+ - test/ping/config_test.rb
118
123
  - test/ping/issue_reference_test.rb
119
124
  - test/ping/mention_test.rb
120
125
  - test/ping/parser_test.rb
@@ -129,23 +134,22 @@ require_paths:
129
134
  - lib
130
135
  required_ruby_version: !ruby/object:Gem::Requirement
131
136
  requirements:
132
- - - '>='
137
+ - - ">="
133
138
  - !ruby/object:Gem::Version
134
- version: '0'
139
+ version: 2.2.2
135
140
  required_rubygems_version: !ruby/object:Gem::Requirement
136
141
  requirements:
137
- - - '>='
142
+ - - ">="
138
143
  - !ruby/object:Gem::Version
139
144
  version: '0'
140
145
  requirements: []
141
- rubyforge_project:
142
- rubygems_version: 2.3.0
146
+ rubygems_version: 3.0.3
143
147
  signing_key:
144
148
  specification_version: 4
145
149
  summary: Parse @mentions and issue references
146
150
  test_files:
151
+ - test/ping/config_test.rb
147
152
  - test/ping/issue_reference_test.rb
148
153
  - test/ping/mention_test.rb
149
154
  - test/ping/parser_test.rb
150
155
  - test/test_helper.rb
151
- has_rdoc:
data/circle.yml DELETED
@@ -1,3 +0,0 @@
1
- test:
2
- override:
3
- - bundle exec rake