문제

나는 Redmine에 대한 Import rakefile을 쓰려고 노력하고 있습니다. Ruby on Rails를 사용합니다. 저는 Rails 개발자가 아니지만 프로젝트 및 문제 관리에 Redmine을 사용하는 것을 좋아합니다.

require 'rubygmes'
require 'fastercsv'

# csv issues import for redmine
# Will convert a csv into a issues bulkloader into redmine
# Column names
# row[0]=Nb Number,row[1]=Product,row[2]=Element,row[3]=Type,row[4]=Queue,
# row[5]=KeyWord,row[6]=Responsible,row[7]=Case Descriptions,row[8]=Days,
# row[9]=Planned Delivery,row[10]=Version
#


desc <<-END_DESC
Bulk loading of issues from a CSV file.

Available options:
  * filepath    => path to the text file.
  * project     => id or identifier of project

Example:
  rake redmine:csv_import filepath="~/import.csv" project="askiavista"
END_DESC

namespace :redmine do
    task :csv_import => :environment do
    @firstrow = true
    @count = 1

    FasterCSV.foreach(ENV['filepath']) do |row|
        if not firstrow
            @i = Issue.new
                @i.project = Project.find_by_name(ENV['project'])
                # If not a feature it's a bug
                if row[3].contains("SUG")
                    @i.tracker = Tracker.find_by_id(2)
                else
                    @i.tracker = Tracker.find_by_id(1)
                end

                if row[4].contains("TOP PRIORITY")
                    @i.priority = Enumeration.find_by_id(7)
                elseif row[4].contains("HIGH PRIORITY")
                    @i.priority = Enumeration.find_by_id(5)
                elseif row[4].contains("MEDIUM PRIORITY")
                    @i.priority = Enumeration.find_by_id(4)
                else
                    @i.priority = Enumeration.find_by_id(3)
                end

                @i.author = Users.find(5)
                @i.subject = truncate(row[4], 50)
                @i.description = row[4]
                @i.status = IssuesStatus.find_by_id(1)
            @i.save
            count += 1
        end
        firstrow = nil
    end
    end
end

내가 실행하면이 오류가 발생합니다.

    (in /var/lib/redmine-0.7-dev)
rake aborted!
Don't know how to build task 'redmine:csv_import.rake'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1634:in `[]'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1930:in `invoke_task'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1909:in `top_level'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1909:in `each'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1909:in `top_level'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1948:in `standard_exception_handling'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1903:in `top_level'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1881:in `run'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1948:in `standard_exception_handling'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1878:in `run'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.1/bin/rake:31
/usr/bin/rake:19:in `load'
/usr/bin/rake:19

나는 주위를 둘러 보았고이 문제가있는 다른 사용자를보고 해결책은 발견되지 않았습니다. 이것은 수백 개의 버그와 기능을 Redmine으로 가져 오는 빠른 스크립트로 여겨집니다.

rakefile을 업데이트했습니다. 새로운 오류. 나는 그것이 내가 찾고있는 텍스트 패턴일지도 모른다고 생각합니다. 루비에 키워드를 위해 문자열을 검색하는 "포함 된"메소드가 있는지 확실하지 않습니다.

도움이 되었습니까?

해결책

당신은 누락되었습니다

end

네임 스페이스를 닫는 데 필요합니다.

고치려면 추가를 넣으십시오

end

파일 끝에

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top