Sha256: f90ddba9f63e23c14ea122f2bf836ced52d556b66d27532694581691ff801802

Contents?: true

Size: 1.52 KB

Versions: 9

Compression:

Stored size: 1.52 KB

Contents

#!/usr/bin/env ruby
require_relative './../spec/spec_helper'
require 'sqlite3'
require 'active_record'

ActiveRecord::Base.establish_connection(
  :adapter  => 'sqlite3',
  :database => ':memory:'
)

class Waypoint < ActiveRecord::Base
  include ROXML

  belongs_to :route

  xml_attr :isLeg
  xml_attr :lonlatx
  xml_attr :lonlaty
  xml_attr :gridReference
  xml_attr :ascent
  xml_attr :descent
  xml_attr :distance
  xml_attr :bearing
  xml_attr :timemins
end

class Route < ActiveRecord::Base
  include ROXML

  has_many :waypoints

  xml_attr :title
  xml_attr :totalDist
  xml_attr :totalMins
  xml_attr :totalHg
  xml_attr :lonlatx
  xml_attr :lonlaty
  xml_attr :grcenter

  xml_attr :waypoints, :as => [Waypoint], :in => "waypoints"
end

# do a quick pseudo migration.  This should only get executed on the first run
if !Waypoint.table_exists?
  ActiveRecord::Base.connection.create_table(:waypoints) do |t|
    t.column :route_id, :integer
    t.column :isLeg, :string
    t.column :lonlatx, :string
    t.column :lonlaty, :string
    t.column :gridReference, :string
    t.column :ascent, :string
    t.column :descent, :string
    t.column :distance, :string
    t.column :bearing, :string
    t.column :timeMins, :string
  end
end

if !Route.table_exists?
  ActiveRecord::Base.connection.create_table(:routes) do |t|
    t.column :title, :string
    t.column :totalDist, :string
    t.column :totalMins, :string
    t.column :totalHg, :string
    t.column :lonlatx, :string
    t.column :lonlaty, :string
    t.column :grcenter, :string
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
roxml-4.2.0 examples/rails.rb
roxml-4.1.1 examples/rails.rb
roxml-4.1.0 examples/rails.rb
roxml-4.0.0 examples/rails.rb
roxml-3.3.1 examples/rails.rb
roxml-3.3.0 examples/rails.rb
roxml-3.2.2 examples/rails.rb
roxml-3.2.1 examples/rails.rb
roxml-3.2.0 examples/rails.rb