Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

the default version on object creation.
  • Loading branch information...
commit 9219de05540fbfc9acee392a7878702e8573b723 1 parent 5683205
authored June 22, 2010
11  README.rdoc
Source Rendered
@@ -11,8 +11,8 @@ Most of the people during science hack day were using YQL to fetch or post their
11 11
 
12 12
 1. Add Unit Tests
13 13
 2. Add oauth
14  
-3. Add table creation
15  
-4. Add update / insert / delete operations
  14
+3. Add YQL table creation
  15
+4. Add YQL update / insert / delete operations
16 16
 
17 17
 ==INSTALLATION
18 18
 
@@ -27,13 +27,14 @@ require 'rubygems'
27 27
 
28 28
 require 'yql'
29 29
 
30  
-===Building Query
  30
+===Building Query and connecting to YQL
31 31
 
32  
-
33  
-====Finders
  32
+====Initialize Client
34 33
 
35 34
 yql = Yql::Client.new
36 35
 
  36
+====Finders
  37
+
37 38
 * Query builder takes table as mandatory parameter.
38 39
 
39 40
 query = Yql::QueryBuilder.new 'yelp.review.search'
13  lib/yql/client.rb
@@ -8,22 +8,19 @@ class Client
8 8
     YQL_ENV    = 'http://datatables.org/alltables.env'
9 9
     
10 10
     attr_accessor :query, :diagnostics, :format
  11
+    attr_reader   :version
11 12
     
12 13
     def initialize(args={})
13  
-      @diagnostics = args[:diagnostics] #true or false
14  
-      @version = args[:version]
15  
-      @query = args[:query]
16  
-      @format = args[:format] || 'xml'
  14
+      @diagnostics = args[:diagnostics] || false
  15
+      @version     = args[:version]     || VERSION
  16
+      @format      = args[:format]      || 'xml'
  17
+      @query       = args[:query]
17 18
     end
18 19
     
19 20
     def query
20 21
       @query.kind_of?(Yql::QueryBuilder) ? @query.to_s : @query
21 22
     end
22 23
     
23  
-    def version
24  
-      @version ||= VERSION
25  
-    end
26  
-    
27 24
     def path_without_domain
28 25
       "/#{version}/#{URL_SUFFIX}"
29 26
     end
10  spec/yql/client_spec.rb
@@ -17,13 +17,17 @@
17 17
       it "should have the api version set to 'v1' by default" do
18 18
         @yql_client.version.should eql('v1')
19 19
       end
  20
+      
  21
+      it "should have the diagnostics turned off" do
  22
+        @yql_client.diagnostics.should be_false
  23
+      end
20 24
 
21 25
     end
22 26
 
23 27
     context "when arguments provided" do
24 28
 
25 29
       before(:each) do
26  
-        @yql_client = Yql::Client.new(:format => 'json', :version => 'v2')
  30
+        @yql_client = Yql::Client.new(:format => 'json', :version => 'v2', :diagnostics => true)
27 31
       end
28 32
 
29 33
       it "should set the format" do
@@ -33,6 +37,10 @@
33 37
       it "should set the api version" do
34 38
         @yql_client.version.should eql('v2')
35 39
       end
  40
+      
  41
+      it "should have the diagnostics turned on" do
  42
+        @yql_client.diagnostics.should be_true
  43
+      end
36 44
 
37 45
     end
38 46
 

0 notes on commit 9219de0

Please sign in to comment.
Something went wrong with that request. Please try again.