Exporting redmine wiki pages

I wanted to export all wiki pages of a redmine project as plain text (the original textile code) with a small yaml header:

~/redmine $ RAILS_ENV=production ./script/console -s
Loading production environment in sandbox (Rails 2.3.11)
Any modifications you make will be rolled back on exit
NOTE: SourceIndex.new(hash) is deprecated; From /usr/lib/ruby/gems/1.8/gems/rails-2.3.11/lib/rails/vendor_gem_source_index.rb:100:in `new'.
>> def export_text(p)
>>   c = p.content_for_version(nil)
>>   "---\ntitle: #{p.title}\nupdated_on: #{c.updated_on}\n---\n\n#{c.text}"
>> end
=> nil
>> def export_wiki(dir, wiki)
>>   dir = dir + "/" + wiki.project.identifier
>>   Dir.mkdir(dir)
>>   wiki.pages.each { |p|File.open(dir + "/" + p.title + ".textile", "w") { |f| f.write(export_text(p)) } }
>>   true
>> end
=> nil
>> Project.all
=> [#<Project id: 2, name: "Debian Server", ... , identifier: "debianserver", ...
>> export_wiki("/tmp", Project.find(2).wiki)
=> true

Now /tmp/debianserver/ contains all the wiki pages.

The ruby functions without irb shell:

def export_text(p)
  c = p.content_for_version(nil)
  "---\ntitle: #{p.title}\nupdated_on: #{c.updated_on}\n---\n\n#{c.text}"
end

def export_wiki(dir, wiki)
  dir = dir + "/" + wiki.project.identifier
  Dir.mkdir(dir)
  wiki.pages.each { |p|File.open(dir + "/" + p.title + ".textile", "w") { |f| f.write(export_text(p)) } }
  true
end