lita-pivotal-tracker 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 21c227938ec96ad605c67ba5afe7370638f37796
4
+ data.tar.gz: 1b496766a009dfbca94acfb678378931585200d4
5
+ SHA512:
6
+ metadata.gz: fe4f8a483ca31161e2898957ade5de9a49084f4a492d55c767d46f2cc21ba3091d990e4f66be087d0f3b787f1436fa5ec0a6ef8300af3b3962e0f1d1cefdd5cd
7
+ data.tar.gz: 9524f8695f5fb33b853ac1691949581a8b6fce333f729aa7d0c152ee2e7a24b97d2a6aa0775ef1d3894ee7411e502923cea1221ce1ed9373ccbfbbbf957289de
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .DS_Store
4
+ .bundle
5
+ .config
6
+ .yardoc
7
+ Gemfile.lock
8
+ InstalledFiles
9
+ _yardoc
10
+ coverage
11
+ doc/
12
+ lib/bundler/man
13
+ pkg
14
+ rdoc
15
+ spec/reports
16
+ test/tmp
17
+ test/version_tmp
18
+ tmp
data/.travis.yml ADDED
@@ -0,0 +1,8 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ script: bundle exec rake
5
+ before_install:
6
+ - gem update --system
7
+ services:
8
+ - redis-server
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2014 Marty Trzpit
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,33 @@
1
+ # lita-pivotal-tracker
2
+
3
+ [![Build Status](https://travis-ci.org/martytrzpit/lita-pivotal-tracker.png?branch=master)](https://travis-ci.org/martytrzpit/lita-pivotal-tracker)
4
+ [![Code Climate](https://codeclimate.com/github/martytrzpit/lita-pivotal-tracker.png)](https://codeclimate.com/github/martytrzpit/lita-pivotal-tracker)
5
+ [![Coverage Status](https://coveralls.io/repos/martytrzpit/lita-pivotal-tracker/badge.png)](https://coveralls.io/r/martytrzpit/lita-pivotal-tracker)
6
+
7
+ **lita-pivotal-tracker** is a handler plugin for [Lita](https://www.lita.io/) that manages [Pivotal Tracker](https://www.pivotaltracker.com/) stories.
8
+
9
+ ## Installation
10
+
11
+ Add lita-pivotal-tracker to your Lita instance's Gemfile:
12
+
13
+ ``` ruby
14
+ gem "lita-pivotal-tracker"
15
+ ```
16
+
17
+ ## Configuration
18
+
19
+ config.handlers.pivotal_tracker.token = `YOUR_PIVOTAL_TRACKER_TOKEN`
20
+
21
+ ## Usage
22
+
23
+ `(pt|pivotaltracker) add [feature (default) | bug | chore] <name> to <project>`
24
+
25
+ ### Examples
26
+
27
+ `lita pt add Exhaust ports are ray shielded to Death Star` will add a __Feature__ named _Exhaust ports are ray shielded_ to the _Death Star_ project.
28
+
29
+ `lita pt add bug Explosive chain reaction in exhaust ports to Death Star` will add a __Bug__ named _Explosive chain reaction in exhaust ports_ to the _Death Star_ project.
30
+
31
+ ## License
32
+
33
+ [MIT](http://opensource.org/licenses/MIT)
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
@@ -0,0 +1,79 @@
1
+ require "lita"
2
+
3
+ module Lita
4
+ module Handlers
5
+ class PivotalTracker < Handler
6
+ route(
7
+ /^(?:pivotaltracker|pt)\s(?:add)(?:\s?(feature|bug|chore)?(.*)\s(?:to)\s(.*))*$/i,
8
+ :pt_add,
9
+ command: true,
10
+ help: {
11
+ t('help.add.syntax') => t('help.add.desc')
12
+ }
13
+ )
14
+
15
+ def self.default_config(config)
16
+ config.token = nil
17
+ end
18
+
19
+ def pt_add(response)
20
+ response.reply("USAGE: #{t('help.add.syntax')}") and return if response.matches[0][1].nil? || response.matches[0][2].nil?
21
+
22
+ project_id, project_name = id_and_name_for_project_name(response.matches[0][2])
23
+ response.reply("Couldn't find project with name containing '#{project_name}'") and return unless project_id
24
+
25
+ pt_params = {}
26
+
27
+ pt_params[:story_type] = response.matches[0][0] if response.matches[0][0]
28
+ pt_params[:name] = response.matches[0][1]
29
+
30
+ result = api_request('post', "projects/#{project_id}/stories", pt_params)
31
+
32
+ response.reply("BAM! Added #{result['story_type'].capitalize} '#{result['name']}' to '#{project_name}' #{result['url']}")
33
+ end
34
+
35
+ private
36
+
37
+ def api_request(method, path, args = {})
38
+ if Lita.config.handlers.pivotal_tracker.token.nil?
39
+ Lita.logger.error('Missing Pivotal Tracker token')
40
+ fail 'Missing token'
41
+ end
42
+
43
+ url = "https://www.pivotaltracker.com/services/v5/#{path}"
44
+
45
+ http_response = http.send(method) do |req|
46
+ req.url url, args
47
+ req.headers['X-TrackerToken'] = Lita.config.handlers.pivotal_tracker.token
48
+ end
49
+
50
+ if http_response.status == 200 || http_response.status == 201
51
+ MultiJson.load(http_response.body)
52
+ else
53
+ Lita.logger.error("HTTP #{method} for #{url} with #{args} " \
54
+ "returned #{http_response.status}")
55
+ Lita.logger.error(http_response.body)
56
+ nil
57
+ end
58
+ end
59
+
60
+ def id_and_name_for_project_name(project_name)
61
+ result = api_request('get', "projects")
62
+
63
+ project_id = nil
64
+ full_project_name = project_name
65
+ result.each do |p|
66
+ if p['name'].include? project_name
67
+ project_id = p['id']
68
+ full_project_name = p['name']
69
+ break
70
+ end
71
+ end
72
+
73
+ return project_id, full_project_name
74
+ end
75
+ end
76
+
77
+ Lita.register_handler(PivotalTracker)
78
+ end
79
+ end
@@ -0,0 +1,7 @@
1
+ require "lita"
2
+
3
+ Lita.load_locales Dir[File.expand_path(
4
+ File.join("..", "..", "locales", "*.yml"), __FILE__
5
+ )]
6
+
7
+ require "lita/handlers/pivotal_tracker"
@@ -0,0 +1,24 @@
1
+ Gem::Specification.new do |spec|
2
+ spec.name = "lita-pivotal-tracker"
3
+ spec.version = "0.1.0"
4
+ spec.authors = ["Marty Trzpit"]
5
+ spec.email = ["mtrizzy@gmail.com"]
6
+ spec.description = %q(Lita handler for adding stories to Pivotal Tracker.)
7
+ spec.summary = %q(Lita handler for adding stories to Pivotal Tracker.)
8
+ spec.homepage = "https://github.com/martytrzpit/lita-pivotal-tracker"
9
+ spec.license = "MIT"
10
+ spec.metadata = { "lita_plugin_type" => "handler" }
11
+
12
+ spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
13
+ spec.executables = spec.files.grep(/^bin\//) { |f| File.basename(f) }
14
+ spec.test_files = spec.files.grep(/^(test|spec|features)\//)
15
+ spec.require_paths = ["lib"]
16
+
17
+ spec.add_runtime_dependency "lita", ">= 3.2"
18
+
19
+ spec.add_development_dependency "bundler", "~> 1.3"
20
+ spec.add_development_dependency "rake"
21
+ spec.add_development_dependency "rspec", ">= 3.0.0.beta2"
22
+ spec.add_development_dependency "simplecov"
23
+ spec.add_development_dependency "coveralls"
24
+ end
data/locales/en.yml ADDED
@@ -0,0 +1,8 @@
1
+ en:
2
+ lita:
3
+ handlers:
4
+ pivotal_tracker:
5
+ help:
6
+ add:
7
+ syntax: (pt|pivotaltracker) add [feature | bug | chore] <name> to <project>
8
+ desc: Add a feature (default), bug, or chore to Pivotal Tracker with the <name> specified to <project>.
@@ -0,0 +1,18 @@
1
+ {
2
+ "created_at": "2014-05-13T12:00:05Z",
3
+ "current_state": "unscheduled",
4
+ "id": 2300,
5
+ "kind": "story",
6
+ "labels":
7
+ [
8
+ ],
9
+ "name": "Explosive chain reaction in exhaust ports",
10
+ "owner_ids":
11
+ [
12
+ ],
13
+ "project_id": 99,
14
+ "requested_by_id": 101,
15
+ "story_type": "bug",
16
+ "updated_at": "2014-05-13T12:00:05Z",
17
+ "url": "http://localhost/story/show/806"
18
+ }
@@ -0,0 +1,34 @@
1
+ {
2
+ "created_at": "2014-05-13T12:00:05Z",
3
+ "current_state": "unscheduled",
4
+ "id": 2300,
5
+ "kind": "story",
6
+ "labels":
7
+ [
8
+ {
9
+ "kind": "label",
10
+ "id": 5100,
11
+ "project_id": 99,
12
+ "name": "newnew",
13
+ "created_at": "2014-05-13T12:00:05Z",
14
+ "updated_at": "2014-05-13T12:00:05Z"
15
+ },
16
+ {
17
+ "kind": "label",
18
+ "id": 2007,
19
+ "project_id": 99,
20
+ "name": "rebel bases",
21
+ "created_at": "2014-05-13T12:00:00Z",
22
+ "updated_at": "2014-05-13T12:00:00Z"
23
+ }
24
+ ],
25
+ "name": "Exhaust ports are ray shielded",
26
+ "owner_ids":
27
+ [
28
+ ],
29
+ "project_id": 99,
30
+ "requested_by_id": 101,
31
+ "story_type": "feature",
32
+ "updated_at": "2014-05-13T12:00:05Z",
33
+ "url": "http://localhost/story/show/2300"
34
+ }
@@ -0,0 +1,69 @@
1
+ [
2
+ {
3
+ "id": 98,
4
+ "kind": "project",
5
+ "name": "Learn About the Force",
6
+ "version": 2,
7
+ "iteration_length": 1,
8
+ "week_start_day": "Monday",
9
+ "point_scale": "0,1,2,3",
10
+ "point_scale_is_custom": false,
11
+ "bugs_and_chores_are_estimatable": false,
12
+ "enable_planned_mode": false,
13
+ "enable_tasks": true,
14
+ "time_zone":
15
+ {
16
+ "kind": "time_zone",
17
+ "olson_name": "America/Los_Angeles",
18
+ "offset": "-07:00"
19
+ },
20
+ "velocity_averaged_over": 3,
21
+ "number_of_done_iterations_to_show": 12,
22
+ "has_google_domain": false,
23
+ "enable_incoming_emails": true,
24
+ "initial_velocity": 10,
25
+ "public": false,
26
+ "atom_enabled": true,
27
+ "start_time": "2014-05-13T12:00:05Z",
28
+ "created_at": "2014-05-13T12:00:10Z",
29
+ "updated_at": "2014-05-13T12:00:15Z",
30
+ "account_id": 100,
31
+ "current_iteration_number": 1,
32
+ "enable_following": true
33
+ },
34
+ {
35
+ "id": 99,
36
+ "kind": "project",
37
+ "name": "Death Star",
38
+ "version": 62,
39
+ "iteration_length": 1,
40
+ "week_start_day": "Monday",
41
+ "point_scale": "0,1,2,3",
42
+ "point_scale_is_custom": false,
43
+ "bugs_and_chores_are_estimatable": false,
44
+ "enable_planned_mode": false,
45
+ "enable_tasks": true,
46
+ "time_zone":
47
+ {
48
+ "kind": "time_zone",
49
+ "olson_name": "America/Los_Angeles",
50
+ "offset": "-07:00"
51
+ },
52
+ "velocity_averaged_over": 3,
53
+ "number_of_done_iterations_to_show": 12,
54
+ "has_google_domain": false,
55
+ "description": "Expeditionary Battle Planetoid",
56
+ "profile_content": "This is a machine of war such as the universe has never known. It's colossal, the size of a class-four moon. And it possesses firepower unequaled in the history of warfare.",
57
+ "enable_incoming_emails": true,
58
+ "initial_velocity": 10,
59
+ "public": false,
60
+ "atom_enabled": true,
61
+ "start_date": "2014-01-27",
62
+ "start_time": "2014-05-13T12:00:15Z",
63
+ "created_at": "2014-05-13T12:00:10Z",
64
+ "updated_at": "2014-05-13T12:00:15Z",
65
+ "account_id": 100,
66
+ "current_iteration_number": 15,
67
+ "enable_following": true
68
+ }
69
+ ]
@@ -0,0 +1,67 @@
1
+ require 'spec_helper'
2
+
3
+ describe Lita::Handlers::PivotalTracker, lita_handler: true do
4
+
5
+ let(:projects) do
6
+ File.read('spec/files/projects.json')
7
+ end
8
+
9
+ let(:feature) do
10
+ File.read('spec/files/feature.json')
11
+ end
12
+
13
+ let(:bug) do
14
+ File.read('spec/files/bug.json')
15
+ end
16
+
17
+ it { routes_command('pt add').to(:pt_add) }
18
+
19
+ before do
20
+ Lita.config.handlers.pivotal_tracker = Lita::Config.new
21
+ Lita.config.handlers.pivotal_tracker.tap do |config|
22
+ config.token = "TOKEN"
23
+ end
24
+ end
25
+
26
+ def grab_request(method, status, body)
27
+ response = double('Faraday::Response', status: status, body: body)
28
+ expect_any_instance_of(Faraday::Connection).to \
29
+ receive(method.to_sym).and_return(response)
30
+ end
31
+
32
+ describe 'missing config' do
33
+ before { Lita.config.handlers.pivotal_tracker.token = nil }
34
+ it 'should raise an error' do
35
+ expect { send_command('pt add some feature to some project') }.to raise_error('Missing token')
36
+ end
37
+ end
38
+
39
+ describe '#pt_add' do
40
+ it 'adds a bug' do
41
+ grab_request('get', 200, projects)
42
+ grab_request('post', 200, bug)
43
+ send_command("pt add bug Explosive chain reaction in exhaust ports to Death Star")
44
+ expect(replies.last).to eq("BAM! Added Bug 'Explosive chain reaction in exhaust ports' to 'Death Star' http://localhost/story/show/806")
45
+ end
46
+
47
+ it 'defaults to feature' do
48
+ grab_request('get', 200, projects)
49
+ grab_request('post', 200, feature)
50
+ send_command("pt add Exhaust ports are ray shielded to Death Star")
51
+ expect(replies.last).to eq("BAM! Added Feature 'Exhaust ports are ray shielded' to 'Death Star' http://localhost/story/show/2300")
52
+ end
53
+
54
+ it 'responds with the help info if called incorrectly' do
55
+ send_command("pt add")
56
+ expect(replies.last).to eq("USAGE: (pt|pivotaltracker) add [feature | bug | chore] <name> to <project>")
57
+ end
58
+
59
+ context 'project not found' do
60
+ it 'responds with an error' do
61
+ grab_request('get', 200, projects)
62
+ send_command("pt add Some story to a project that does not exist")
63
+ expect(replies.last).to eq("Couldn't find project with name containing 'a project that does not exist'")
64
+ end
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,10 @@
1
+ require 'simplecov'
2
+ require 'coveralls'
3
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
4
+ SimpleCov::Formatter::HTMLFormatter,
5
+ Coveralls::SimpleCov::Formatter
6
+ ]
7
+ SimpleCov.start { add_filter '/spec/' }
8
+
9
+ require 'lita-pivotal-tracker'
10
+ require 'lita/rspec'
metadata ADDED
@@ -0,0 +1,149 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lita-pivotal-tracker
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Marty Trzpit
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-05-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: lita
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '3.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '3.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: 3.0.0.beta2
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: 3.0.0.beta2
69
+ - !ruby/object:Gem::Dependency
70
+ name: simplecov
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: coveralls
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: Lita handler for adding stories to Pivotal Tracker.
98
+ email:
99
+ - mtrizzy@gmail.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - .gitignore
105
+ - .travis.yml
106
+ - Gemfile
107
+ - LICENSE
108
+ - README.md
109
+ - Rakefile
110
+ - lib/lita-pivotal-tracker.rb
111
+ - lib/lita/handlers/pivotal_tracker.rb
112
+ - lita-pivotal-tracker.gemspec
113
+ - locales/en.yml
114
+ - spec/files/bug.json
115
+ - spec/files/feature.json
116
+ - spec/files/projects.json
117
+ - spec/lita/handlers/pivotal-tracker_spec.rb
118
+ - spec/spec_helper.rb
119
+ homepage: https://github.com/martytrzpit/lita-pivotal-tracker
120
+ licenses:
121
+ - MIT
122
+ metadata:
123
+ lita_plugin_type: handler
124
+ post_install_message:
125
+ rdoc_options: []
126
+ require_paths:
127
+ - lib
128
+ required_ruby_version: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - '>='
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ required_rubygems_version: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - '>='
136
+ - !ruby/object:Gem::Version
137
+ version: '0'
138
+ requirements: []
139
+ rubyforge_project:
140
+ rubygems_version: 2.2.2
141
+ signing_key:
142
+ specification_version: 4
143
+ summary: Lita handler for adding stories to Pivotal Tracker.
144
+ test_files:
145
+ - spec/files/bug.json
146
+ - spec/files/feature.json
147
+ - spec/files/projects.json
148
+ - spec/lita/handlers/pivotal-tracker_spec.rb
149
+ - spec/spec_helper.rb