Jemand kann in der Syntax meiner Rakefile aussehen?
-
03-07-2019 - |
Frage
Ich versuche, einen Import Rakefile für Redmine zu schreiben. Es nutzt Ruby on Rails. Ich bin kein Schienen-Entwickler, aber wir haben wie redmine für Projekt- und Issues Management mit.
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
Als ich es lief ich diesen Fehler:
(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
Ich habe sah sich um und ich sehe andere Benutzer mit diesem Problem, aber keine Lösung gefunden wird. Dies soll eine schnelle Skript sein, ein paar hundert Bugs und Features in redmine zu importieren.
Ich habe meine Rakefile aktualisiert. Neuer Fehler. Ich denke, es könnte die Textmuster sein, die ich suche. Ich bin mir nicht sicher, ob Ruby eine „enthält“ Methoden hat einen String nach Stichwort zu suchen.
Lösung
Sie vermissen die
end
erforderlich, um den Namensraum zu schließen.
Um dies zu beheben, eine zusätzliche put
end
am Ende der Datei