Permalink
Browse files

Remove Yql::Client#version and modify #initialize to set

the default version on object creation.
  • Loading branch information...
1 parent 5683205 commit 9219de05540fbfc9acee392a7878702e8573b723 nas committed Jun 22, 2010
Showing with 20 additions and 14 deletions.
  1. +6 −5 README.rdoc
  2. +5 −8 lib/yql/client.rb
  3. +9 −1 spec/yql/client_spec.rb
View
11 README.rdoc
@@ -11,8 +11,8 @@ Most of the people during science hack day were using YQL to fetch or post their
1. Add Unit Tests
2. Add oauth
-3. Add table creation
-4. Add update / insert / delete operations
+3. Add YQL table creation
+4. Add YQL update / insert / delete operations
==INSTALLATION
@@ -27,13 +27,14 @@ require 'rubygems'
require 'yql'
-===Building Query
+===Building Query and connecting to YQL
-
-====Finders
+====Initialize Client
yql = Yql::Client.new
+====Finders
+
* Query builder takes table as mandatory parameter.
query = Yql::QueryBuilder.new 'yelp.review.search'
View
13 lib/yql/client.rb
@@ -8,22 +8,19 @@ class Client
YQL_ENV = 'http://datatables.org/alltables.env'
attr_accessor :query, :diagnostics, :format
+ attr_reader :version
def initialize(args={})
- @diagnostics = args[:diagnostics] #true or false
- @version = args[:version]
- @query = args[:query]
- @format = args[:format] || 'xml'
+ @diagnostics = args[:diagnostics] || false
+ @version = args[:version] || VERSION
+ @format = args[:format] || 'xml'
+ @query = args[:query]
end
def query
@query.kind_of?(Yql::QueryBuilder) ? @query.to_s : @query
end
- def version
- @version ||= VERSION
- end
-
def path_without_domain
"/#{version}/#{URL_SUFFIX}"
end
View
10 spec/yql/client_spec.rb
@@ -17,13 +17,17 @@
it "should have the api version set to 'v1' by default" do
@yql_client.version.should eql('v1')
end
+
+ it "should have the diagnostics turned off" do
+ @yql_client.diagnostics.should be_false
+ end
end
context "when arguments provided" do
before(:each) do
- @yql_client = Yql::Client.new(:format => 'json', :version => 'v2')
+ @yql_client = Yql::Client.new(:format => 'json', :version => 'v2', :diagnostics => true)
end
it "should set the format" do
@@ -33,6 +37,10 @@
it "should set the api version" do
@yql_client.version.should eql('v2')
end
+
+ it "should have the diagnostics turned on" do
+ @yql_client.diagnostics.should be_true
+ end
end

0 comments on commit 9219de0

Please sign in to comment.