/usr/share/doc/ruby-roxml/examples/rails.rb is in ruby-roxml 3.3.1-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | #!/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
|