Skip to content

Commit

Permalink
initial version
Browse files Browse the repository at this point in the history
  • Loading branch information
jkraemer committed Feb 13, 2010
0 parents commit 3335314
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 0 deletions.
19 changes: 19 additions & 0 deletions README
@@ -0,0 +1,19 @@
Redmine to Lighthouse ticket importer
=====================================


Author: Jens Krämer <jk@jkraemer.net>


USAGE
-----

install the lighthouse-api gem and place this file into
your redmine application directory, and edit the marked
variables to match your setup.

Then run via script runner:

RAILS_ENV=production script/runner rm2lighthouse.rb


92 changes: 92 additions & 0 deletions rm2lighthouse.rb
@@ -0,0 +1,92 @@
# Redmine to Lighthouse ticket importer
# Author: Jens Krämer <jk@jkraemer.net>
#

# usage:
# place this file into your redmine applicatiojn directory and run via script runner:
#
# RAILS_ENV=production script/runner rm2lighthouse.rb


# Copyright (c) 2010 Jens Krämer
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without
# restriction, including without limitation the rights to use,
# copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following
# conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.


require 'rubygems'
gem 'lighthouse-api'

require 'lighthouse'

############
### Lighthouse configuration
###

# Lighthouse Account Name -- NOT your username!
Lighthouse.account = 'j-k'
# Lighthouse API token
Lighthouse.token = 'c3cf54610c4a780afc52128931c674e99e888abc'


# redmine project identifier => lighthouse project id
PROJECTS = {
'aaf' => 45560
}

class RmTicketImporter

STATE_MAP = {
'New' => 'new',
'Assigned' => 'open',
'Resolved' => 'resolved',
'Feedback' => 'open',
'Closed' => 'resolved',
'Rejected' => 'invalid'
}

def initialize(project_mapping)
@projects = project_mapping
end

def import
@projects.each_pair do |rm_proj, lh_proj|
issues_for_project(rm_proj).each { |issue| create_ticket(issue, lh_proj) }
end
end

def issues_for_project(proj)
Project.find_by_identifier(proj).issues
end

def create_ticket(rm_issue, proj)
ticket = Lighthouse::Ticket.new(:project_id => proj)
ticket.title = rm_issue.subject
ticket.body = rm_issue.description
ticket.state = STATE_MAP[rm_issue.status.name]
# ticket.tags = tag_prep(trac_ticket[:tags] + status_tags)
# ticket.milestone_id = Config[:milestones][trac_ticket[:milestone]]
ticket.save
end

end

RmTicketImporter.new(PROJECTS).import

0 comments on commit 3335314

Please sign in to comment.