redmine_kayako_integration 0.0.1

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.
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source "https://rubygems.org"
2
+ gem 'KayakoClient', '~>1.1.0'
3
+ gem 'activeresource', '~>3.2.12'
4
+ gem 'logger'
5
+
6
+ # Testing
7
+ gem 'rspec', :require => 'spec'
@@ -0,0 +1,35 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ KayakoClient (1.1.0)
5
+ activemodel (3.2.12)
6
+ activesupport (= 3.2.12)
7
+ builder (~> 3.0.0)
8
+ activeresource (3.2.12)
9
+ activemodel (= 3.2.12)
10
+ activesupport (= 3.2.12)
11
+ activesupport (3.2.12)
12
+ i18n (~> 0.6)
13
+ multi_json (~> 1.0)
14
+ builder (3.0.4)
15
+ diff-lcs (1.2.1)
16
+ i18n (0.6.4)
17
+ logger (1.2.8)
18
+ multi_json (1.6.1)
19
+ rspec (2.13.0)
20
+ rspec-core (~> 2.13.0)
21
+ rspec-expectations (~> 2.13.0)
22
+ rspec-mocks (~> 2.13.0)
23
+ rspec-core (2.13.0)
24
+ rspec-expectations (2.13.0)
25
+ diff-lcs (>= 1.1.3, < 2.0)
26
+ rspec-mocks (2.13.0)
27
+
28
+ PLATFORMS
29
+ ruby
30
+
31
+ DEPENDENCIES
32
+ KayakoClient (~> 1.1.0)
33
+ activeresource (~> 3.2.12)
34
+ logger
35
+ rspec
data/LICENSE ADDED
File without changes
@@ -0,0 +1,16 @@
1
+ This program will provide redmine issue status updates to the Kayako helpdesk. Kayako tickets are related to redmine issues when a Kayako user adds redmine issue numbers to the custom field in a ticket designated for redmine issue numbers.
2
+
3
+ The scipt is designed to run every 3,5,15 minutes? a which time it will get redmine issue numbers from Kayako, check redmine for status updates, and finally re-write the Kayako custom fields with new redmine statuses. The custom field in Kayako contains both the redmine issue and status in the following format: #3452|open|#4329|closed|
4
+
5
+
6
+
7
+
8
+
9
+
10
+ if fields && !fields.empty?
11
+
12
+ ##update recent update time in kayako only ofter red update, not after every cron
13
+ #$_SWIFT_TicketObject->UpdatePool('lastactivity', DATENOW);
14
+
15
+ ##Kayako tickets reference MANY redmine issues from 'Public' project and 'Private'
16
+
@@ -0,0 +1,52 @@
1
+ require "rubygems"
2
+ require "bundler/setup"
3
+
4
+ require "kayako_client"
5
+ require "active_resource"
6
+ require "logger"
7
+
8
+ class RedmineIssue < ActiveResource::Base # Redmine API configuration and Issue model
9
+ end
10
+
11
+ class RedmineKayako #Redmine Kayako status updater class
12
+ attr_accessor :kayako_department
13
+ attr_accessor :kayako_issue_field_identifier
14
+
15
+ def setup
16
+ # Kayako setup
17
+ self.kayako_department = 3
18
+ self.kayako_issue_field_identifier = '2azuubvzms0b'
19
+ KayakoClient::Base.configure do |config| # Kayako API Configuration uses kayako_client gem
20
+ config.api_url = "" kayako_url
21
+ config.api_key = ""# kayako_key
22
+ config.secret_key = ""# kayako_secret
23
+ end
24
+
25
+ # Redmine setup
26
+ #class RedmineIssue < ActiveResource::Base # Redmine API configuration and Issue model
27
+ # redmine info here
28
+ RedmineIssue.site = ""# redmine_url
29
+ RedmineIssue.user = ""# redmine_user
30
+ RedmineIssue.password = ""# redmine_password
31
+ RedmineIssue.format = :xml
32
+ #end
33
+
34
+ # Logger
35
+ KayakoClient::Base.configure do |config| #logger config
36
+ config.logger = Logger.new(STDOUT)
37
+ end
38
+ end
39
+
40
+ def update_kayako
41
+ KayakoClient::Ticket.all(self.kayako_department).each do |ticket|
42
+ # Get kayako custom field contents
43
+ kayako_custom_fields = KayakoClient::TicketCustomField.get(ticket.id)
44
+ # extract redmine ids
45
+ redmine_issue_ids = kayako_custom_fields[self.kayako_issue_field_identifier].scan(/\#(\d+)/).flatten.map(&:to_i)
46
+ # assemble a string of redmine ids and statuses, e.g. "#123|open| #957|closed|"
47
+ kayako_custom_fields[self.kayako_issue_field_identifier] = redmine_issue_ids.map{|id| RedmineIssue.exists?(id)? "##{id}|#{RedmineIssue.find(id).status.name}|" : "##{id}|NA|" }.join(" ")
48
+ # post updated kayako custom field string
49
+ kayako_custom_fields.post
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,15 @@
1
+ # -*- encoding: utf-8 -*-
2
+ Gem::Specification.new do |s|
3
+ s.name = 'redmine_kayako_integration'
4
+ s.version = '0.0.1'
5
+ s.authors = ['Randy Janzen']
6
+ s.email = ['randy.janzen@gmail.com']
7
+ s.homepage = 'https://github.com/rjanzen821/redmine_kayako_integration'
8
+ s.summary = 'Redmine Kayako Issue Status Sync'
9
+ s.description = 'This gem will parse custom fields in Kayako, extract redmine issue numbers
10
+ and send status and target version back to Kayako'
11
+
12
+ s.files = `git ls-files`.split("\n")
13
+ s.test_files = `git ls-files -- {spec}/*`.split("\n")
14
+ s.require_paths = ['lib']
15
+ end
@@ -0,0 +1,41 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe RedmineKayako do
4
+ let(:worker){ RedmineKayako.new}
5
+ it "has a default department" do
6
+ worker.setup
7
+ worker.kayako_department.should == 3
8
+ end
9
+ it "has a default redmine issue identifier" do
10
+ worker.setup
11
+ worker.kayako_issue_field_identifier.should == '2azuubvzms0b'
12
+ end
13
+ it "can access kayako api" do
14
+ KayakoClient::Base.configure do |config| # Kayako API Configuration uses kayako_client gem
15
+ config.api_url = ""# kayako_url
16
+ config.api_key = ""# kayako_key
17
+ config.secret_key = ""# kayako_secret
18
+ end
19
+ end
20
+ it "can access redmine api" do
21
+ RedmineIssue.site = ""# redmine_url
22
+ RedmineIssue.user = ""# redmine_user
23
+ RedmineIssue.password = ""# redmine_password
24
+ RedmineIssue.format = :xml
25
+ end
26
+
27
+ it "can get all custom fields from each kayako ticket" do
28
+ worker.update_kayako
29
+ worker.kayako_custom_fields.should = KayakoClient::TicketCustomField.get(ticket.id)
30
+ end
31
+ it "can extract redmine ids from kayako custom field" do
32
+ worker.update_kayako
33
+ worker.redmine_issue_ids.should = kayako_custom_fields[self.kayako_issue_field_identifier].scan(/\#(\d+)/).flatten.map(&:to_i)
34
+ end
35
+ it "can assemble a string of redmine ids and statuses" do
36
+ kayako_custom_fields[self.kayako_issue_field_identifier] = redmine_issue_ids.map{|id| RedmineIssue.exists?(id)? "##{id}|#{RedmineIssue.find(id).status.name}|" : "##{id}|NA|" }.join(" ")
37
+ end
38
+ it "can post updated kayako custom field string to kayako" do
39
+ kayako_custom_fields.post
40
+ end
41
+ end
@@ -0,0 +1,19 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # Require this file using `require "spec_helper"` to ensure that it is only
4
+ # loaded once.
5
+ #
6
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
+ require File.expand_path(File.dirname(__FILE__) + '/../redmine_kayako_status_updater')
8
+
9
+ RSpec.configure do |config|
10
+ config.treat_symbols_as_metadata_keys_with_true_values = true
11
+ config.run_all_when_everything_filtered = true
12
+ config.filter_run :focus
13
+
14
+ # Run specs in random order to surface order dependencies. If you find an
15
+ # order dependency and want to debug it, you can fix the order by providing
16
+ # the seed, which is printed after each run.
17
+ # --seed 1234
18
+ config.order = 'random'
19
+ end
metadata ADDED
@@ -0,0 +1,55 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: redmine_kayako_integration
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Randy Janzen
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-05-01 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: ! "This gem will parse custom fields in Kayako, extract redmine issue
15
+ numbers\n and send status and target version back to Kayako"
16
+ email:
17
+ - randy.janzen@gmail.com
18
+ executables: []
19
+ extensions: []
20
+ extra_rdoc_files: []
21
+ files:
22
+ - .rspec
23
+ - Gemfile
24
+ - Gemfile.lock
25
+ - LICENSE
26
+ - README.md
27
+ - lib/redmine_kayako_status_updater.rb
28
+ - redmine_kayako_integration.gemspec
29
+ - spec/redmine_kayako_status_updater_spec.rb
30
+ - spec/spec_helper.rb
31
+ homepage: https://github.com/rjanzen821/redmine_kayako_integration
32
+ licenses: []
33
+ post_install_message:
34
+ rdoc_options: []
35
+ require_paths:
36
+ - lib
37
+ required_ruby_version: !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - ! '>='
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
43
+ required_rubygems_version: !ruby/object:Gem::Requirement
44
+ none: false
45
+ requirements:
46
+ - - ! '>='
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ requirements: []
50
+ rubyforge_project:
51
+ rubygems_version: 1.8.24
52
+ signing_key:
53
+ specification_version: 3
54
+ summary: Redmine Kayako Issue Status Sync
55
+ test_files: []