Class: Itinerary::CreateTool
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Tool
find_tool, inherited, #initialize, tools
Constructor Details
This class inherits a constructor from Itinerary::Tool
Class Method Details
.name ⇒ Object
4 5 6 |
# File 'lib/itinerary/tools/create.rb', line 4 def self.name 'create' end |
Instance Method Details
#run ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/itinerary/tools/create.rb', line 8 def run tmp = Pathname.new('/tmp/new-entry') unless tmp.exist? rec = Record.new( :path => tmp, :person => 'FIXME', :organization => 'FIXME', :address => 'FIXME', :email => 'FIXME', :phone => 'FIXME', :uri => 'FIXME', :description => 'FIXME', :ref => 'FIXME', ) rec.save! rec.edit(:wait => true) end rec = Record.load(tmp) rec.geocode or begin warn "Failed to geocode #{rec.address.inspect} (entry left in #{tmp})" exit(1) end rec.path = rec.make_path(@itinerary.entries_path) rec.save! warn "Saved to #{rec.path}" tmp.unlink @itinerary.import_entry(rec.path) end |