lita-jira-issues 0.2.2 → 0.2.3

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
2
  SHA1:
3
- metadata.gz: 41460e79444d88c618386fb02fbe9057ccb36736
4
- data.tar.gz: ff8facb4607f63e1c04ba7911afdc515a207b550
3
+ metadata.gz: 35aac2c646137a72b605110012083c2d97750f3f
4
+ data.tar.gz: fe01278b2923c44cd638ae6d3ded73fc3a1a087b
5
5
  SHA512:
6
- metadata.gz: b68cbc5e9d3e15b90b494e5462ba183d452d321bee94edc5d852f046d5064606dee4810e657a214ee760eb85b19595beddde5ac7e79289f63633250a66ce79ca
7
- data.tar.gz: e3d58d93cec5707754a9ece3177c4cceb648cda08e8eae2d08ccfcf68fdc839e945527c8bf5e137613c243417731cfa34b9530f833d68aff1b4c403378ab338a
6
+ metadata.gz: 1f0496574cadd911e313cd13eb77a053ebfdb0092faa3644b933654353eacf2861c6e71231c386cbfd2042157456474ca961b51f59adc39669081f4fc9becc9b
7
+ data.tar.gz: 7c057167cd2cbaaec896e6f9990187685405af33cbf867bd88aa986e50ef9feea9e4f2b5918aa17706b59083426c88d4d6e8c86fc699cec74f117d061b2743d5
data/CHANGELOG.md CHANGED
@@ -4,6 +4,11 @@ This project adheres to [Semantic Versioning](http://semver.org/).
4
4
 
5
5
  ## [Unreleased][unreleased]
6
6
 
7
+ ## [0.2.3] - 2015-04-29
8
+ ### Added
9
+ - Optional TTL feature for silencing the same JIRA for a period of time. Thanks
10
+ to @johntdyer for the contribution.
11
+
7
12
  ## [0.2.2] - 2015-04-11
8
13
  ### Added
9
14
  - A mechanism to ignore a list of users. Thanks to @jlambert121 for contributing.
@@ -24,7 +29,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
24
29
  https://github.com/github/hubot-scripts/blob/master/src/scripts/jira-issues.coffee)
25
30
 
26
31
 
27
- [unreleased]: https://github.com/amaltson/lita-jira-issues/compare/v0.2.2...HEAD
32
+ [unreleased]: https://github.com/amaltson/lita-jira-issues/compare/v0.2.3...HEAD
33
+ [0.2.3]: https://github.com/amaltson/lita-jira-issues/compare/v0.2.2...v0.2.3
28
34
  [0.2.2]: https://github.com/amaltson/lita-jira-issues/compare/v0.2.1...v0.2.2
29
35
  [0.2.1]: https://github.com/amaltson/lita-jira-issues/compare/v0.2.0...v0.2.1
30
36
  [0.2.0]: https://github.com/amaltson/lita-jira-issues/compare/v0.1.0...v0.2.0
data/README.md CHANGED
@@ -30,6 +30,7 @@ the following configurations to your `lita_config.rb`.
30
30
  config.handlers.jira_issues.url = 'http://jira.local'
31
31
  config.handlers.jira_issues.username = ENV['JIRA_USER'] || 'user'
32
32
  config.handlers.jira_issues.password = ENV['JIRA_PASSWORD'] || 'password'
33
+ config.handlers.jira_issues.issue_ttl = 0 #optional
33
34
  ```
34
35
 
35
36
  As in the example above, you can always use environment variables for sensitive
@@ -42,6 +43,14 @@ configuration parameter
42
43
  config.handlers.jira_issues.ignore = [ 'Jira', 'Github' ]
43
44
  ```
44
45
 
46
+ Optionally you can set a timer for how long to sleep prior to posting an issue to chat again. This is accomplished by setting an expiring key in Redis. That timeout is governed by the following config
47
+
48
+ ```ruby
49
+ config.handlers.jira_issues.issue_ttl = 120
50
+ ```
51
+
52
+ The default for this config is 0 which serves to disables the feature entirely.
53
+
45
54
  ## Usage
46
55
 
47
56
  Simply mention any JIRA valid key in upper or lower case, eg. JIRA-123, proj-8,
@@ -9,6 +9,7 @@ module Lita
9
9
  config :username, required: true, type: String
10
10
  config :password, required: true, type: String
11
11
  config :ignore, default: [], type: Array
12
+ config :issue_ttl, default: 0, type: Integer
12
13
 
13
14
  route /[a-zA-Z]+-\d+/, :jira_message, help: {
14
15
  "KEY-123" => "Replies with information about the given JIRA key"
@@ -25,6 +26,7 @@ module Lita
25
26
  def handle_key(response, key)
26
27
  data = @jira.data_for_issue(key)
27
28
  return if data.empty?
29
+ return if silenced?(key)
28
30
  issue = issue_details(data)
29
31
  response.reply issue
30
32
  end
@@ -80,6 +82,26 @@ module Lita
80
82
  def issue_link(key)
81
83
  "\n#{config.url}/browse/#{key}"
82
84
  end
85
+
86
+ def silenced?(key)
87
+
88
+ if config.issue_ttl == 0
89
+ log.debug("JiraIssues: issue_ttl is set to 0, will post every matched issue to chat")
90
+ return false
91
+ end
92
+
93
+ current_ttl = redis.ttl(key).to_i
94
+
95
+ if current_ttl > 0
96
+ log.debug("JiraIssues: Key expiration not met for #{key}, will not reprompt for #{current_ttl} seconds")
97
+ true
98
+ else
99
+ redis.setex(key, config.issue_ttl, key)
100
+ log.debug("JiraIssues: Setting expiring key in redis for JIRA issue: #{key}. Key is configured to expire in #{config.issue_ttl} seconds")
101
+ false
102
+ end
103
+ end
104
+
83
105
  end
84
106
 
85
107
  Lita.register_handler(JiraIssues)
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "lita-jira-issues"
3
- spec.version = "0.2.2"
3
+ spec.version = "0.2.3"
4
4
  spec.authors = ["Arthur Maltson"]
5
5
  spec.email = ["arthur@maltson.com"]
6
6
  spec.description = "Lita handler to show JIRA issue details"
@@ -22,4 +22,5 @@ Gem::Specification.new do |spec|
22
22
  spec.add_development_dependency "rspec", ">= 3.0.0"
23
23
  spec.add_development_dependency "simplecov"
24
24
  spec.add_development_dependency "coveralls"
25
+ spec.add_development_dependency "fakeredis"
25
26
  end
@@ -1,4 +1,4 @@
1
- require "spec_helper"
1
+ require 'spec_helper'
2
2
 
3
3
  describe Lita::Handlers::JiraIssues, lita_handler: true do
4
4
 
@@ -7,7 +7,33 @@ describe Lita::Handlers::JiraIssues, lita_handler: true do
7
7
 
8
8
  describe 'Looking up keys' do
9
9
 
10
+ context 'Test silenced handler' do
11
+
12
+ let(:redis) { Redis::Namespace }
13
+
14
+ it 'should return false when issue ttl is set to 0, which is default' do
15
+ Lita.config.handlers.jira_issues.issue_ttl = 0
16
+ expect(Lita::Handlers::JiraIssues.new.silenced?('KEY-123')).to eql false
17
+ end
18
+
19
+ context 'configured ttl of 10 seconds' do
20
+ before(:each) { Lita.config.handlers.jira_issues.issue_ttl = 10 }
21
+
22
+ it 'should return true with redis ttl is 10' do
23
+ allow_any_instance_of(redis).to receive(:ttl).with('KEY-424').and_return('10')
24
+ expect(Lita::Handlers::JiraIssues.new.silenced?('KEY-424')).to eql true
25
+ end
26
+
27
+ it 'should return true for silenced when redis ttl is -2' do
28
+ allow_any_instance_of(redis).to receive(:ttl).with('KEY-424').and_return('-2')
29
+ expect(Lita::Handlers::JiraIssues.new.silenced?('KEY-424')).to eql false
30
+ end
31
+ end
32
+
33
+ end
34
+
10
35
  before(:each) do
36
+ Lita.test_mode = true
11
37
  Lita.config.handlers.jira_issues.url = 'http://jira.local'
12
38
  Lita.config.handlers.jira_issues.username = 'user'
13
39
  Lita.config.handlers.jira_issues.password = 'pass'
@@ -87,8 +113,8 @@ http://jira.local/browse/PROJ-9872
87
113
  }
88
114
  })
89
115
 
90
- bob = Lita::User.create(123, name: "Bob Smith")
91
- fred = Lita::User.create(123, name: "Fred Smith")
116
+ bob = Lita::User.create(123, name: 'Bob Smith')
117
+ fred = Lita::User.create(123, name: 'Fred Smith')
92
118
 
93
119
  send_message('Some message KEY-424 more text', as: bob)
94
120
  expect(replies.last).not_to match('KEY-424')
data/spec/spec_helper.rb CHANGED
@@ -8,5 +8,5 @@ SimpleCov.start { add_filter "/spec/" }
8
8
 
9
9
  require "lita-jira-issues"
10
10
  require "lita/rspec"
11
-
11
+ require "fakeredis/rspec"
12
12
  Lita.version_3_compatibility_mode = false
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lita-jira-issues
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arthur Maltson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-11 00:00:00.000000000 Z
11
+ date: 2015-04-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lita
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: fakeredis
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
97
111
  description: Lita handler to show JIRA issue details
98
112
  email:
99
113
  - arthur@maltson.com