-
Notifications
You must be signed in to change notification settings - Fork 416
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding new PeerIndex call: profile/show
- Loading branch information
Showing
5 changed files
with
1,045 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# | ||
# A couple of rake tasks to make the creation of YQL tables easier. | ||
# This caters specifically to my setup, as I am hosting my YQL tables at github.com | ||
# | ||
# Author: Sebastian Spier (http://twitter.com/#!/sebastianspier/) | ||
# | ||
|
||
require 'rubygems' | ||
require 'rake' | ||
require 'nokogiri' | ||
require 'open-uri' | ||
|
||
YQL_XSD_ONLINE = "http://query.yahooapis.com/v1/schema/table.xsd" | ||
YQL_XSD_LOCAL = "table.xsd" | ||
GITHUB_USER = "spier" | ||
ENV_FILENAME = "alltables_forked.env" | ||
|
||
|
||
task :default => :create_env_file | ||
|
||
|
||
desc "Create new .env file for use with github" | ||
task :create_env_file do | ||
# determine from git, what the current branch is | ||
# see: http://stackoverflow.com/questions/1593051/how-to-programmatically-determine-the-current-checked-out-git-branch | ||
branch = `git name-rev --name-only HEAD` | ||
branch.strip! | ||
|
||
# parameters to this rake tasks could also be provided from the outside: | ||
# http://www.viget.com/extend/protip-passing-parameters-to-your-rake-tasks/ | ||
|
||
# alternatively one could also ask for the branch name | ||
# puts "Which branch?" | ||
# branch = STDIN.gets.chomp | ||
|
||
# github user and repository name are hardcoded | ||
base_path = "https://raw.github.com/#{GITHUB_USER}/yql-tables/#{branch}/" | ||
env_fh = File.open(ENV_FILENAME,"w") | ||
|
||
# write one entry for each .xml files to the .env file | ||
xml_files = Dir.glob("**/*.xml") | ||
xml_files.each do |filename| | ||
table_name = File.basename(filename,".xml") | ||
absolute_url = File.join(base_path,filename) | ||
use_statement = "USE '#{absolute_url}' AS #{table_name};" | ||
env_fh.puts use_statement | ||
end | ||
|
||
env_fh.close() | ||
puts "Wrote new file #{ENV_FILENAME}. Total of #{xml_files.size} YQL open data tables." | ||
end | ||
|
||
|
||
desc "Check a YQL table against the YQL XSD, call with 'rake check file=abc'" | ||
task :check do | ||
filename = ENV['file'] | ||
xsd = Nokogiri::XML::Schema(open(YQL_XSD_LOCAL).read) | ||
doc = Nokogiri::XML(open(filename).read) | ||
puts "Is the YQL definition '#{filename}' valid? => #{xsd.valid?(doc)}" | ||
|
||
xsd.validate(doc).each do |error| | ||
puts error.message | ||
end | ||
end |
Oops, something went wrong.