Permalink
Browse files

adding new PeerIndex call: profile/show

  • Loading branch information...
1 parent 1ef1565 commit 1dc74a69ef860a6fea000dccf214dcbff0bfcc75 @spier spier committed Feb 25, 2012
Showing with 1,045 additions and 7 deletions.
  1. +64 −0 Rakefile
  2. +954 −0 alltables_forked.env
  3. +4 −4 peerindex/README.md
  4. +3 −3 peerindex/peerindex.profile.xml
  5. +20 −0 peerindex/peerindex.show.xml
View
64 Rakefile
@@ -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
View
954 alltables_forked.env
954 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
8 peerindex/README.md
@@ -10,17 +10,17 @@ When you are using the full set of [YQL community tables][yql_community_tables]
## Query one twitter user
- USE "https://github.com/spier/yql-tables/raw/peerindex/peerindex/peerindex.profile.xml";
+ USE "https://github.com/spier/yql-tables/raw/peerindex/peerindex/peerindex.show.xml";
SET api_key="YOUR_API_KEY_HERE" ON peerindex;
- SELECT * FROM peerindex.profile WHERE id="PeerIndex"
+ SELECT * FROM peerindex.show WHERE id="PeerIndex"
## Query multiple twitter users
- USE "https://github.com/spier/yql-tables/raw/peerindex/peerindex/peerindex.profile.xml";
+ USE "https://github.com/spier/yql-tables/raw/peerindex/peerindex/peerindex.show.xml";
SET api_key="YOUR_API_KEY_HERE" ON peerindex;
- SELECT * FROM peerindex.profile WHERE id="davewiner" OR id="kaykas"
+ SELECT * FROM peerindex.show WHERE id="davewiner" OR id="kaykas"
## Advanced: Use twitter search API to find users that are mentioning @peerindex frequently. Then identify the peerindex for these users.
View
6 peerindex/peerindex.profile.xml
@@ -2,14 +2,14 @@
<table xmlns="http://query.yahooapis.com/v1/schema/table.xsd">
<meta>
<author>Sebastian Spier (http://twitter.com/#!/sebastianspier/)</author>
- <description>Lookup of PeerIndex profile data (API key required) V1</description>
- <documentationURL>http://dev.peerindex.net/docs/profile/show</documentationURL>
+ <description>Currently not a very useful API. use peerindex.show instead.</description>
+ <documentationURL>http://dev.peerindex.com/docs/profile/profile</documentationURL>
<sampleQuery>SELECT * FROM {table} WHERE id='twitterUserGoesHere' AND api_key='yourKeyGoesHere'</sampleQuery>
</meta>
<bindings>
<select itemPath="json" produces="JSON">
<urls>
- <url>http://api.peerindex.net/1/profile/show.json</url>
+ <url>http://api.peerindex.net/1/profile/profile.json</url>
</urls>
<inputs>
<key id="id" type="xs:string" paramType="query" required="true"/>
View
20 peerindex/peerindex.show.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<table xmlns="http://query.yahooapis.com/v1/schema/table.xsd">
+ <meta>
+ <author>Sebastian Spier (http://twitter.com/#!/sebastianspier/)</author>
+ <description>Returns the extended PeerIndex profile including the interest graph of a screenname or a twitter id (V1)</description>
+ <documentationURL>http://dev.peerindex.com/docs/profile/show</documentationURL>
+ <sampleQuery>SELECT * FROM {table} WHERE id='twitterScreenname' AND api_key='yourApiKey'</sampleQuery>
+ </meta>
+ <bindings>
+ <select itemPath="json" produces="JSON">
+ <urls>
+ <url>http://api.peerindex.net/v2/profile/show.json</url>
+ </urls>
+ <inputs>
+ <key id="id" type="xs:string" paramType="query" required="true"/>
+ <key id="api_key" type="xs:string" paramType="query" required="true"/>
+ </inputs>
+ </select>
+ </bindings>
+</table>

0 comments on commit 1dc74a6

Please sign in to comment.