Skip to content

Instantly share code, notes, and snippets.

@omphe
Created December 22, 2011 14:25
Show Gist options
  • Save omphe/1510469 to your computer and use it in GitHub Desktop.
Save omphe/1510469 to your computer and use it in GitHub Desktop.
CDW-Plus Sinatra
# XML Transformation Prototype
# Branden Faulls <branden.faulls@clockworkrobot.co.uk
# http://www.clockworkrobot.co.uk
require 'rubygems'
require 'sinatra'
require_relative 'cdw_document.rb'
helpers do
def display_doc(doc)
if(doc.errors?)
'Error'
else
content_type :json
doc.to_json
end
end
end
get '/' do
doc = CDWDocument.new('http://localhost:4567/rexml')
display_doc(doc)
end
get '/converted' do
doc = CDWInventoryDocument.new('http://localhost:4567/rexml')
display_doc(doc)
end
get '/rexml' do
file = File.new('rexml.xml')
content_type :xml
file.read
end
get '/standings' do
doc = CDWStandingsDocument.new('http://cd.uefa.com/competitions/euro/standings/allgroups.html')
display_doc(doc)
end
get '/matches' do
doc = CDWMatchesDocument.new('http://cd.uefa.com/competitions/euro/Matches/allMatches.html')
display_doc(doc)
end
get '/competition' do
doc = CDWAggregateDocument.new()
display_doc(doc)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment