googletastic 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.textile +47 -0
- data/Rakefile +103 -0
- data/lib/googletastic/access_rule.rb +45 -0
- data/lib/googletastic/album.rb +22 -0
- data/lib/googletastic/app_engine.rb +103 -0
- data/lib/googletastic/attendee.rb +7 -0
- data/lib/googletastic/base.rb +46 -0
- data/lib/googletastic/calendar.rb +60 -0
- data/lib/googletastic/comment.rb +3 -0
- data/lib/googletastic/document.rb +219 -0
- data/lib/googletastic/event.rb +149 -0
- data/lib/googletastic/ext/file.rb +219 -0
- data/lib/googletastic/ext/pretty_print.xsl +47 -0
- data/lib/googletastic/ext/xml.rb +10 -0
- data/lib/googletastic/ext.rb +1 -0
- data/lib/googletastic/form.rb +131 -0
- data/lib/googletastic/group.rb +44 -0
- data/lib/googletastic/helpers/document.rb +70 -0
- data/lib/googletastic/helpers/event.rb +26 -0
- data/lib/googletastic/helpers/form.rb +102 -0
- data/lib/googletastic/helpers.rb +18 -0
- data/lib/googletastic/image.rb +121 -0
- data/lib/googletastic/mixins/actions.rb +113 -0
- data/lib/googletastic/mixins/attributes.rb +27 -0
- data/lib/googletastic/mixins/finders.rb +78 -0
- data/lib/googletastic/mixins/namespaces.rb +42 -0
- data/lib/googletastic/mixins/parsing.rb +68 -0
- data/lib/googletastic/mixins/requesting.rb +84 -0
- data/lib/googletastic/mixins.rb +5 -0
- data/lib/googletastic/person.rb +41 -0
- data/lib/googletastic/spreadsheet.rb +35 -0
- data/lib/googletastic/sync/document.rb +120 -0
- data/lib/googletastic/sync/form.rb +106 -0
- data/lib/googletastic/sync.rb +46 -0
- data/lib/googletastic/thumbnail.rb +7 -0
- data/lib/googletastic/youtube.rb +25 -0
- data/lib/googletastic.rb +115 -0
- data/spec/benchmarks/document_benchmark.rb +40 -0
- data/spec/config.yml +6 -0
- data/spec/fixtures/data/Doing business in the eMarketPlace.doc +0 -0
- data/spec/fixtures/data/basic.txt +1 -0
- data/spec/fixtures/data/calendar.list.xml +64 -0
- data/spec/fixtures/data/doc_as_html.html +3097 -0
- data/spec/fixtures/data/doc_as_html_html.html +0 -0
- data/spec/fixtures/data/doclist.xml +76 -0
- data/spec/fixtures/data/document.single.xml +30 -0
- data/spec/fixtures/data/end.xml +446 -0
- data/spec/fixtures/data/event.list.xml +62 -0
- data/spec/fixtures/data/form.html +66 -0
- data/spec/fixtures/data/group.list.xml +58 -0
- data/spec/fixtures/data/person.list.xml +53 -0
- data/spec/fixtures/data/photo.list.xml +111 -0
- data/spec/fixtures/data/sample_upload.mp4 +0 -0
- data/spec/fixtures/data/spreadsheet.list.xml +43 -0
- data/spec/fixtures/models/document.rb +7 -0
- data/spec/fixtures/models/event.rb +3 -0
- data/spec/fixtures/models/form.rb +6 -0
- data/spec/fixtures/models/test_model.rb +3 -0
- data/spec/fixtures/results/test.txt +185 -0
- data/spec/googletastic/access_rule_spec.rb +13 -0
- data/spec/googletastic/album_spec.rb +9 -0
- data/spec/googletastic/app_engine_spec.rb +12 -0
- data/spec/googletastic/base_spec.rb +49 -0
- data/spec/googletastic/calendar_spec.rb +11 -0
- data/spec/googletastic/document_spec.rb +163 -0
- data/spec/googletastic/event_spec.rb +34 -0
- data/spec/googletastic/form_spec.rb +43 -0
- data/spec/googletastic/group_spec.rb +9 -0
- data/spec/googletastic/image_spec.rb +9 -0
- data/spec/googletastic/person_spec.rb +9 -0
- data/spec/googletastic/post_spec.rb +46 -0
- data/spec/googletastic/spreadsheet_spec.rb +9 -0
- data/spec/googletastic/youtube_spec.rb +58 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +25 -0
- metadata +187 -0
| @@ -0,0 +1,49 @@ | |
| 1 | 
            +
            require File.expand_path("./spec/spec_helper")
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe Googletastic::Base do
         | 
| 4 | 
            +
              
         | 
| 5 | 
            +
              # URL
         | 
| 6 | 
            +
              describe "url parsing" do
         | 
| 7 | 
            +
                it "should convert a hash of params into url parameters" do
         | 
| 8 | 
            +
                  pending
         | 
| 9 | 
            +
                end
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                it "should only convert 'valid_params' into url parameters" do
         | 
| 12 | 
            +
                  pending
         | 
| 13 | 
            +
                end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                it "should throw an error if no url is specified in the params" do
         | 
| 16 | 
            +
                  pending
         | 
| 17 | 
            +
                end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                it "should format the url properly with params" do
         | 
| 20 | 
            +
                  options = {:offset => 10, :with => "LANCE", :reader => "JOHN", :url => "http://docs.google.com/"}
         | 
| 21 | 
            +
                  # base
         | 
| 22 | 
            +
                  url = Googletastic::Base.build_url(options)
         | 
| 23 | 
            +
                  url.should == "http://docs.google.com/?q=LANCE&start-index=10"
         | 
| 24 | 
            +
                end
         | 
| 25 | 
            +
              end
         | 
| 26 | 
            +
              
         | 
| 27 | 
            +
              # AUTHENTICATION
         | 
| 28 | 
            +
              describe "authentication" do
         | 
| 29 | 
            +
                it "should find the configuration file" do
         | 
| 30 | 
            +
                  pending
         | 
| 31 | 
            +
                end
         | 
| 32 | 
            +
             | 
| 33 | 
            +
                it "should successfully authenticate" do
         | 
| 34 | 
            +
                  pending
         | 
| 35 | 
            +
                end
         | 
| 36 | 
            +
                
         | 
| 37 | 
            +
              end
         | 
| 38 | 
            +
              
         | 
| 39 | 
            +
              # http://code.google.com/apis/gdata/articles/gdata_on_rails.html#AuthSub
         | 
| 40 | 
            +
              it "should login via 'AuthSub'" do
         | 
| 41 | 
            +
                client = GData::Client::DocList.new
         | 
| 42 | 
            +
                next_url = 'http://accd.org'
         | 
| 43 | 
            +
                secure = false  # set secure = true for signed AuthSub requests
         | 
| 44 | 
            +
                sess = true
         | 
| 45 | 
            +
                domain = nil#'accd.org'  # force users to login to a Google Apps hosted domain
         | 
| 46 | 
            +
                authsub_link = client.authsub_url(next_url, secure, sess, domain)
         | 
| 47 | 
            +
              end
         | 
| 48 | 
            +
              
         | 
| 49 | 
            +
            end
         | 
| @@ -0,0 +1,163 @@ | |
| 1 | 
            +
            require File.expand_path("./spec/spec_helper")
         | 
| 2 | 
            +
            # spec ./spec/googletastic/document_spec.rb
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            describe Googletastic::Document do
         | 
| 5 | 
            +
              
         | 
| 6 | 
            +
              before(:all) do
         | 
| 7 | 
            +
                @doc = Document.new
         | 
| 8 | 
            +
                @id = "0AT1-fvkm5vJPZGN2NzR3bmJfMGZiMnh3N2R0"
         | 
| 9 | 
            +
              end
         | 
| 10 | 
            +
              
         | 
| 11 | 
            +
              # FIND METHODS
         | 
| 12 | 
            +
              describe "find methods" do
         | 
| 13 | 
            +
                it "should find first document from google docs" do
         | 
| 14 | 
            +
                  doc = Googletastic::Document.first
         | 
| 15 | 
            +
                  doc.should_not == nil
         | 
| 16 | 
            +
                  doc.title.should_not be_empty
         | 
| 17 | 
            +
                end
         | 
| 18 | 
            +
                
         | 
| 19 | 
            +
                it "should find all documents from google docs, and they should be an array" do
         | 
| 20 | 
            +
                  docs = Googletastic::Document.all
         | 
| 21 | 
            +
                  docs.should_not == nil
         | 
| 22 | 
            +
                  docs.class.to_s.should == "Array"
         | 
| 23 | 
            +
                end
         | 
| 24 | 
            +
                
         | 
| 25 | 
            +
                it "should find single document by id from google docs" do
         | 
| 26 | 
            +
                  doc = Googletastic::Document.find(@id)
         | 
| 27 | 
            +
                  doc.should_not == nil
         | 
| 28 | 
            +
                  doc.id.should == @id
         | 
| 29 | 
            +
                end
         | 
| 30 | 
            +
                
         | 
| 31 | 
            +
                it "should find single document by id from google docs, with ACL via ':include => [:acl]'" do
         | 
| 32 | 
            +
                  pending
         | 
| 33 | 
            +
                end
         | 
| 34 | 
            +
              
         | 
| 35 | 
            +
                it "should retrieve ACL for document when called" do
         | 
| 36 | 
            +
                  doc = Googletastic::Document.first
         | 
| 37 | 
            +
                  doc.acl.should_not == nil
         | 
| 38 | 
            +
                end
         | 
| 39 | 
            +
             | 
| 40 | 
            +
                it "should retrieve only the specified fields from the xml" do
         | 
| 41 | 
            +
            #      result = Googletastic::Document.all(:fields => "title,id", :raw => true)
         | 
| 42 | 
            +
            #      puts Nokogiri::XML(result.body).to_xml
         | 
| 43 | 
            +
                  pending
         | 
| 44 | 
            +
                end
         | 
| 45 | 
            +
                
         | 
| 46 | 
            +
                it "should get document by 'kind' of 'spreadsheet'" do
         | 
| 47 | 
            +
            #      Googletastic::Document.first(:kind => "spreadsheet")
         | 
| 48 | 
            +
                  pending
         | 
| 49 | 
            +
                end
         | 
| 50 | 
            +
                
         | 
| 51 | 
            +
                describe "errors" do
         | 
| 52 | 
            +
                  it "should throw an error if you don't pass 'find' any parameters" do
         | 
| 53 | 
            +
            #        Googletastic::Document.find.should raise_error
         | 
| 54 | 
            +
                  end
         | 
| 55 | 
            +
                end
         | 
| 56 | 
            +
              end
         | 
| 57 | 
            +
              
         | 
| 58 | 
            +
              describe "document properties" do
         | 
| 59 | 
            +
                before(:all) do
         | 
| 60 | 
            +
                  @doc = Googletastic::Document.first
         | 
| 61 | 
            +
                end
         | 
| 62 | 
            +
                
         | 
| 63 | 
            +
                it "should have a valid 'kind'" do
         | 
| 64 | 
            +
                  @doc.kind.should_not == nil
         | 
| 65 | 
            +
                  Googletastic::Document.valid_category?(@doc.kind).should == true
         | 
| 66 | 
            +
                end
         | 
| 67 | 
            +
                
         | 
| 68 | 
            +
                it "should have an array of categories" do
         | 
| 69 | 
            +
                  @doc.categories.should be_an_instance_of(Array)
         | 
| 70 | 
            +
                end
         | 
| 71 | 
            +
              end
         | 
| 72 | 
            +
              
         | 
| 73 | 
            +
              # URL PARSING
         | 
| 74 | 
            +
              describe "url parsing" do
         | 
| 75 | 
            +
                it "should format the url properly with params" do
         | 
| 76 | 
            +
                  options = {:offset => 10, :with => "LANCE", :reader => "JOHN", :url => "http://docs.google.com/"}
         | 
| 77 | 
            +
                  # document
         | 
| 78 | 
            +
                  url = Googletastic::Document.build_url(options)
         | 
| 79 | 
            +
                  url.should == "http://docs.google.com/?reader=JOHN&q=LANCE&start-index=10"
         | 
| 80 | 
            +
                
         | 
| 81 | 
            +
                  options = {:include => [:acl], :url => Googletastic::Document::FEED}
         | 
| 82 | 
            +
                  url = Googletastic::Document.build_url(options)
         | 
| 83 | 
            +
                  url.should =~ /#{Googletastic::Document::FEED.gsub(/full$/, "expandAcl")}/
         | 
| 84 | 
            +
                end
         | 
| 85 | 
            +
              end
         | 
| 86 | 
            +
              
         | 
| 87 | 
            +
              describe "marshalling" do
         | 
| 88 | 
            +
                before(:all) do
         | 
| 89 | 
            +
                  @doc = Googletastic::Document.first
         | 
| 90 | 
            +
                  @xml = @doc.to_xml
         | 
| 91 | 
            +
                end
         | 
| 92 | 
            +
                
         | 
| 93 | 
            +
                it "should marshall the document into an entry feed with at least a 'title' and 'id'" do
         | 
| 94 | 
            +
                  xml = Nokogiri::XML(@xml)
         | 
| 95 | 
            +
                  xml.xpath("//atom:id", {"atom" => NS['atom']}).first.text.should == "#{@doc.index_url.gsub('http', 'https').gsub('documents', 'default')}/#{@doc.resource_id}"
         | 
| 96 | 
            +
                  xml.xpath("//atom:title", {"atom" => NS['atom']}).first.text.should == @doc.title
         | 
| 97 | 
            +
                end
         | 
| 98 | 
            +
              end
         | 
| 99 | 
            +
              
         | 
| 100 | 
            +
              describe "viewing" do
         | 
| 101 | 
            +
                it "should pull the raw html content of the document down" do
         | 
| 102 | 
            +
                  doc = Googletastic::Document.find(@id)
         | 
| 103 | 
            +
                  view = doc.view
         | 
| 104 | 
            +
                  liquid = Liquid::Template.parse(view.to_xml.to_xml)
         | 
| 105 | 
            +
                  result = liquid.render("company_name" => "My Company")
         | 
| 106 | 
            +
                end
         | 
| 107 | 
            +
                
         | 
| 108 | 
            +
                it "should return a 'Content Not Modified' response" do
         | 
| 109 | 
            +
                  client = Googletastic::Document.client
         | 
| 110 | 
            +
                  since = '2010-03-28T22:51:51.488Z'
         | 
| 111 | 
            +
                  good = '2009-11-04T10:57:00-08:00'
         | 
| 112 | 
            +
                  # AkQFRnw7fCp7ImA9WxBaGEw.
         | 
| 113 | 
            +
                  client.headers["If-Modified-Since"] = since
         | 
| 114 | 
            +
                  url = Googletastic::Document.index_url + "?updated-max=#{good}"
         | 
| 115 | 
            +
                end
         | 
| 116 | 
            +
              end
         | 
| 117 | 
            +
              
         | 
| 118 | 
            +
              describe "uploading" do
         | 
| 119 | 
            +
                it "should post a document's content to google docs" do
         | 
| 120 | 
            +
            #      response = Googletastic::Document.upload(File.join(FIXTURES_DIR, "data/basic.txt"))
         | 
| 121 | 
            +
            #      response.should_not == nil # better assertion :p, but it works
         | 
| 122 | 
            +
                end
         | 
| 123 | 
            +
                
         | 
| 124 | 
            +
                it "should upload the document's content and add a custom title" do
         | 
| 125 | 
            +
                  
         | 
| 126 | 
            +
                end
         | 
| 127 | 
            +
              end
         | 
| 128 | 
            +
              
         | 
| 129 | 
            +
              # DOWNLOADING
         | 
| 130 | 
            +
              describe "downloading" do
         | 
| 131 | 
            +
                it "should download a document as plain text" do
         | 
| 132 | 
            +
                  doc = Googletastic::Document.find(@id)
         | 
| 133 | 
            +
                  result = doc.download("txt")
         | 
| 134 | 
            +
                  liquid = Liquid::Template.parse(result.body)
         | 
| 135 | 
            +
                  result = liquid.render("company_name" => "My Company")
         | 
| 136 | 
            +
                  File.write(File.join(FIXTURES_DIR, "results/test.txt"), result)
         | 
| 137 | 
            +
                  result.should_not == nil
         | 
| 138 | 
            +
                end
         | 
| 139 | 
            +
                
         | 
| 140 | 
            +
                it "should get a '.doc' file from google docs and return it as html" do
         | 
| 141 | 
            +
                  pending
         | 
| 142 | 
            +
                end
         | 
| 143 | 
            +
                
         | 
| 144 | 
            +
                it "should download all documents as a zip file" do
         | 
| 145 | 
            +
                  
         | 
| 146 | 
            +
                end
         | 
| 147 | 
            +
              end
         | 
| 148 | 
            +
              
         | 
| 149 | 
            +
              describe "active record wrapper" do
         | 
| 150 | 
            +
                it "should have the dynamic method 'find_with_google_doc'" do
         | 
| 151 | 
            +
                  Document.respond_to?(:find_with_google_doc).should == true
         | 
| 152 | 
            +
                end
         | 
| 153 | 
            +
                
         | 
| 154 | 
            +
                it "should find and save all new documents" do
         | 
| 155 | 
            +
                  # Document.find_with_google_doc.should_not == nil
         | 
| 156 | 
            +
                end
         | 
| 157 | 
            +
                
         | 
| 158 | 
            +
                it "should be able to compare previous updated time with current updated time" do
         | 
| 159 | 
            +
                  doc = Googletastic::Document.first
         | 
| 160 | 
            +
                  puts doc.inspect
         | 
| 161 | 
            +
                end
         | 
| 162 | 
            +
              end
         | 
| 163 | 
            +
            end
         | 
| @@ -0,0 +1,34 @@ | |
| 1 | 
            +
            require File.expand_path("./spec/spec_helper")
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe Googletastic::Event do
         | 
| 4 | 
            +
              
         | 
| 5 | 
            +
              describe "finding" do
         | 
| 6 | 
            +
                it "should retrieve a list of events from google calendar" do
         | 
| 7 | 
            +
                  Googletastic::Event.all.should_not == nil
         | 
| 8 | 
            +
                end
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                it "should get a 'content not modified' response from google" do
         | 
| 11 | 
            +
                  pending
         | 
| 12 | 
            +
                end
         | 
| 13 | 
            +
              end
         | 
| 14 | 
            +
              
         | 
| 15 | 
            +
              describe "posting" do
         | 
| 16 | 
            +
                it "should post an event on google calendar" do
         | 
| 17 | 
            +
                  @event = Googletastic::Event.new
         | 
| 18 | 
            +
                  @event.title = "Event with DESCRIPTION"
         | 
| 19 | 
            +
                  @event.start_time = Time.now.xmlschema
         | 
| 20 | 
            +
                  @event.end_time = 2.days.from_now.xmlschema
         | 
| 21 | 
            +
                  @event.description = "You know, i hope this works!"
         | 
| 22 | 
            +
              #    @event.save
         | 
| 23 | 
            +
                end
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                it "should update (put) an even on google calendar" do
         | 
| 26 | 
            +
                  @event = Googletastic::Event.first
         | 
| 27 | 
            +
                  @event.title = "I CHANGED MY TITLE"
         | 
| 28 | 
            +
                  @event.description = "Now I have a description?"
         | 
| 29 | 
            +
                  @event.where = "Berkeley"
         | 
| 30 | 
            +
              #    @event.save
         | 
| 31 | 
            +
                end
         | 
| 32 | 
            +
              end
         | 
| 33 | 
            +
              
         | 
| 34 | 
            +
            end
         | 
| @@ -0,0 +1,43 @@ | |
| 1 | 
            +
            require File.expand_path("./spec/spec_helper")
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe Googletastic::Form do
         | 
| 4 | 
            +
              
         | 
| 5 | 
            +
              before(:all) do
         | 
| 6 | 
            +
                @form = Form.new
         | 
| 7 | 
            +
              end
         | 
| 8 | 
            +
              
         | 
| 9 | 
            +
              describe "find" do
         | 
| 10 | 
            +
                it "should list all spreadsheets as forms" do
         | 
| 11 | 
            +
                  
         | 
| 12 | 
            +
                end
         | 
| 13 | 
            +
              end
         | 
| 14 | 
            +
              
         | 
| 15 | 
            +
              describe "dynamic helper methods" do
         | 
| 16 | 
            +
                it "should add dynamic methods to form model based on googletastic :form options" do
         | 
| 17 | 
            +
                  @form.respond_to?(:google_form).should == true
         | 
| 18 | 
            +
                end
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                it "should respond_to?(:find_with_google_form) dynamic class methods" do
         | 
| 21 | 
            +
                  Form.respond_to?(:find_with_google_form).should == true
         | 
| 22 | 
            +
                  pending
         | 
| 23 | 
            +
                end
         | 
| 24 | 
            +
              end
         | 
| 25 | 
            +
              
         | 
| 26 | 
            +
              describe "unmarshalling" do
         | 
| 27 | 
            +
                it "should strip the html page down to a form (unmarshall)" do
         | 
| 28 | 
            +
                  @html = Nokogiri::HTML(IO.read(File.join(FIXTURES_DIR, "data/form.html")))
         | 
| 29 | 
            +
                  form = Googletastic::Form.unmarshall(@html)
         | 
| 30 | 
            +
                  form.redirect = "/forms/my-custom-id"
         | 
| 31 | 
            +
                end
         | 
| 32 | 
            +
              end
         | 
| 33 | 
            +
              
         | 
| 34 | 
            +
              describe "redirecting" do
         | 
| 35 | 
            +
                it "should add generic redirect" do
         | 
| 36 | 
            +
                  Googletastic::Form.redirect_to = "/my-generic-redirect"
         | 
| 37 | 
            +
                  @html = Nokogiri::HTML(IO.read(File.join(FIXTURES_DIR, "data/form.html")))
         | 
| 38 | 
            +
                  form = Googletastic::Form.unmarshall(@html)
         | 
| 39 | 
            +
                  Nokogiri::HTML(form.body).xpath("//form").first["action"].should == "/my-generic-redirect"
         | 
| 40 | 
            +
                end
         | 
| 41 | 
            +
              end
         | 
| 42 | 
            +
              
         | 
| 43 | 
            +
            end
         | 
| @@ -0,0 +1,46 @@ | |
| 1 | 
            +
            require File.expand_path("./spec/spec_helper")
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe Googletastic do
         | 
| 4 | 
            +
              
         | 
| 5 | 
            +
            =begin
         | 
| 6 | 
            +
              before(:all) do
         | 
| 7 | 
            +
                @email = "flexinstyle@gmail.com"
         | 
| 8 | 
            +
                @password = "flexyflexy"
         | 
| 9 | 
            +
                @blog_id = 178484585982103126
         | 
| 10 | 
            +
                @path = "http://www.blogger.com/feeds/#{@blog_id}/posts/full"
         | 
| 11 | 
            +
              end
         | 
| 12 | 
            +
              
         | 
| 13 | 
            +
              it "should get a list of blog posts from viatropos.blogspot.com" do
         | 
| 14 | 
            +
                client = GData::Client::Blogger.new
         | 
| 15 | 
            +
                client.clientlogin(@email, @password)
         | 
| 16 | 
            +
                #puts client.get(@path).to_xml()
         | 
| 17 | 
            +
                #puts Thing::Google::Document.view(nil, nil).to_xml
         | 
| 18 | 
            +
              end
         | 
| 19 | 
            +
              
         | 
| 20 | 
            +
              it "should post a post to blogger" do
         | 
| 21 | 
            +
                client = GData::Client::Blogger.new
         | 
| 22 | 
            +
                client.clientlogin(@email, @password)
         | 
| 23 | 
            +
                post = <<-eof
         | 
| 24 | 
            +
                <entry xmlns='http://www.w3.org/2005/Atom'>
         | 
| 25 | 
            +
                  <title type='text'>Marriage!</title>
         | 
| 26 | 
            +
                  <content type='xhtml'>
         | 
| 27 | 
            +
                    <div xmlns="http://www.w3.org/1999/xhtml">
         | 
| 28 | 
            +
                      <p>Mr. Darcy has <em>proposed marriage</em> to me!</p>
         | 
| 29 | 
            +
                      <p>He is the last man on earth I would ever desire to marry.</p>
         | 
| 30 | 
            +
                      <p>Whatever shall I do?</p>
         | 
| 31 | 
            +
                    </div>
         | 
| 32 | 
            +
                  </content>
         | 
| 33 | 
            +
                  <category scheme="http://www.blogger.com/atom/ns#" term="marriage" />
         | 
| 34 | 
            +
                  <category scheme="http://www.blogger.com/atom/ns#" term="Mr. Darcy" />
         | 
| 35 | 
            +
                </entry>
         | 
| 36 | 
            +
                eof
         | 
| 37 | 
            +
                #post = client.post(@path, post)
         | 
| 38 | 
            +
                #post = client.get(@path).to_xml.xpath("//atom:entry", {'atom' => ATOM_NS}).first
         | 
| 39 | 
            +
                #puts post.to_xml
         | 
| 40 | 
            +
              end
         | 
| 41 | 
            +
            =end  
         | 
| 42 | 
            +
              after(:each) do
         | 
| 43 | 
            +
             | 
| 44 | 
            +
              end
         | 
| 45 | 
            +
              
         | 
| 46 | 
            +
            end
         | 
| @@ -0,0 +1,58 @@ | |
| 1 | 
            +
            require File.expand_path("./spec/spec_helper")
         | 
| 2 | 
            +
            =begin
         | 
| 3 | 
            +
            describe Thing::Google::YouTube do
         | 
| 4 | 
            +
              
         | 
| 5 | 
            +
              VIDEOS = "http://gdata.youtube.com/feeds/api/videos" unless defined?(VIDEOS)
         | 
| 6 | 
            +
              
         | 
| 7 | 
            +
              before(:each) do
         | 
| 8 | 
            +
                @yt = GData::Client::YouTube.new
         | 
| 9 | 
            +
                @keys = Thing::Google.credentials
         | 
| 10 | 
            +
                @yt.developer_key = @keys[:youtube_dev_key]
         | 
| 11 | 
            +
                @yt.clientlogin(@keys[:youtube_login], @keys[:password])
         | 
| 12 | 
            +
              end
         | 
| 13 | 
            +
              
         | 
| 14 | 
            +
              def metadata
         | 
| 15 | 
            +
                data = <<EOF
         | 
| 16 | 
            +
            <?xml version="1.0"?>
         | 
| 17 | 
            +
            <entry xmlns="http://www.w3.org/2005/Atom"
         | 
| 18 | 
            +
              xmlns:media="http://search.yahoo.com/mrss/"
         | 
| 19 | 
            +
              xmlns:yt="http://gdata.youtube.com/schemas/2007">
         | 
| 20 | 
            +
              <media:group>
         | 
| 21 | 
            +
                <media:title type="plain">Bad Wedding Toast</media:title>
         | 
| 22 | 
            +
                <media:description type="plain">
         | 
| 23 | 
            +
                  I gave a bad toast at my friend's wedding.
         | 
| 24 | 
            +
                </media:description>
         | 
| 25 | 
            +
                <media:category scheme="http://gdata.youtube.com/schemas/2007/categories.cat">People</media:category>
         | 
| 26 | 
            +
                <media:keywords>toast, wedding</media:keywords>
         | 
| 27 | 
            +
              </media:group>
         | 
| 28 | 
            +
            </entry>
         | 
| 29 | 
            +
            EOF
         | 
| 30 | 
            +
              end
         | 
| 31 | 
            +
              
         | 
| 32 | 
            +
              it "should get a list of videos from youtube" do
         | 
| 33 | 
            +
                pending
         | 
| 34 | 
            +
                response = @yt.get(Thing.paramify_url(VIDEOS, {:q => "dan tocchini"}))
         | 
| 35 | 
            +
                response = response.to_xml.xpath("//atom:entry", {'atom' => ATOM_NS}).first.to_xml
         | 
| 36 | 
            +
                puts "response! " + response.inspect    
         | 
| 37 | 
            +
              end
         | 
| 38 | 
            +
              
         | 
| 39 | 
            +
              it "should upload video metadata to youtube" do
         | 
| 40 | 
            +
                url = File.join(Thing::Google::YouTube::API, Thing::Google::YouTube::GET_UPLOAD_TOKEN)
         | 
| 41 | 
            +
                #response = @yt.post(url, metadata).to_xml
         | 
| 42 | 
            +
                #puts response.to_xml
         | 
| 43 | 
            +
              end
         | 
| 44 | 
            +
              
         | 
| 45 | 
            +
              it "should upload the actual video to youtube" do
         | 
| 46 | 
            +
                url = File.join(Thing::Google::YouTube::UPLOAD, @keys[:youtube_login], "uploads")
         | 
| 47 | 
            +
                puts url
         | 
| 48 | 
            +
                mime_type = Thing::Google::YouTube::MULTIPART
         | 
| 49 | 
            +
                response = @yt.post_file(url, File.join(FIXTURES_DIR, "sample_upload.mp4"), mime_type).to_xml
         | 
| 50 | 
            +
                puts response.to_xml
         | 
| 51 | 
            +
              end
         | 
| 52 | 
            +
              
         | 
| 53 | 
            +
              after(:each) do
         | 
| 54 | 
            +
                
         | 
| 55 | 
            +
              end
         | 
| 56 | 
            +
              
         | 
| 57 | 
            +
            end
         | 
| 58 | 
            +
            =end    
         | 
    
        data/spec/spec.opts
    ADDED
    
    | @@ -0,0 +1 @@ | |
| 1 | 
            +
            --colour
         | 
    
        data/spec/spec_helper.rb
    ADDED
    
    | @@ -0,0 +1,25 @@ | |
| 1 | 
            +
            begin
         | 
| 2 | 
            +
              require 'spec'
         | 
| 3 | 
            +
            rescue LoadError
         | 
| 4 | 
            +
              require 'rubygems' unless ENV['NO_RUBYGEMS']
         | 
| 5 | 
            +
              gem 'rspec'
         | 
| 6 | 
            +
              require 'spec'
         | 
| 7 | 
            +
            end
         | 
| 8 | 
            +
            require 'benchmark'
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            $:.unshift(File.dirname(__FILE__) + '/../lib')
         | 
| 11 | 
            +
            require 'googletastic'
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            FIXTURES_DIR    = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures')) unless defined?(FIXTURES_DIR)
         | 
| 14 | 
            +
            MODELS_DIR      = File.join(FIXTURES_DIR, "models") unless defined?(MODELS_DIR)
         | 
| 15 | 
            +
            DATA_DIR        = File.join(FIXTURES_DIR, "data") unless defined?(DATA_DIR)
         | 
| 16 | 
            +
             | 
| 17 | 
            +
            $:.unshift(MODELS_DIR)
         | 
| 18 | 
            +
            require 'test_model'
         | 
| 19 | 
            +
             | 
| 20 | 
            +
            Googletastic::TestModel.send(:include, Googletastic::Helpers)
         | 
| 21 | 
            +
            Dir.glob("#{MODELS_DIR}/*") {|file| require file}
         | 
| 22 | 
            +
             | 
| 23 | 
            +
            Googletastic.keys = YAML.load_file("spec/config.yml").symbolize_keys
         | 
| 24 | 
            +
             | 
| 25 | 
            +
            NS              = Googletastic::Mixins::Namespaces::NAMESPACES
         | 
    
        metadata
    ADDED
    
    | @@ -0,0 +1,187 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification 
         | 
| 2 | 
            +
            name: googletastic
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version 
         | 
| 4 | 
            +
              prerelease: false
         | 
| 5 | 
            +
              segments: 
         | 
| 6 | 
            +
              - 0
         | 
| 7 | 
            +
              - 0
         | 
| 8 | 
            +
              - 1
         | 
| 9 | 
            +
              version: 0.0.1
         | 
| 10 | 
            +
            platform: ruby
         | 
| 11 | 
            +
            authors: 
         | 
| 12 | 
            +
            - Lance Pollard
         | 
| 13 | 
            +
            autorequire: 
         | 
| 14 | 
            +
            bindir: bin
         | 
| 15 | 
            +
            cert_chain: []
         | 
| 16 | 
            +
             | 
| 17 | 
            +
            date: 2010-03-22 00:00:00 -07:00
         | 
| 18 | 
            +
            default_executable: 
         | 
| 19 | 
            +
            dependencies: 
         | 
| 20 | 
            +
            - !ruby/object:Gem::Dependency 
         | 
| 21 | 
            +
              name: nokogiri
         | 
| 22 | 
            +
              prerelease: false
         | 
| 23 | 
            +
              requirement: &id001 !ruby/object:Gem::Requirement 
         | 
| 24 | 
            +
                requirements: 
         | 
| 25 | 
            +
                - - ">="
         | 
| 26 | 
            +
                  - !ruby/object:Gem::Version 
         | 
| 27 | 
            +
                    segments: 
         | 
| 28 | 
            +
                    - 0
         | 
| 29 | 
            +
                    version: "0"
         | 
| 30 | 
            +
              type: :runtime
         | 
| 31 | 
            +
              version_requirements: *id001
         | 
| 32 | 
            +
            - !ruby/object:Gem::Dependency 
         | 
| 33 | 
            +
              name: activesupport
         | 
| 34 | 
            +
              prerelease: false
         | 
| 35 | 
            +
              requirement: &id002 !ruby/object:Gem::Requirement 
         | 
| 36 | 
            +
                requirements: 
         | 
| 37 | 
            +
                - - ">="
         | 
| 38 | 
            +
                  - !ruby/object:Gem::Version 
         | 
| 39 | 
            +
                    segments: 
         | 
| 40 | 
            +
                    - 2
         | 
| 41 | 
            +
                    - 3
         | 
| 42 | 
            +
                    - 5
         | 
| 43 | 
            +
                    version: 2.3.5
         | 
| 44 | 
            +
              type: :runtime
         | 
| 45 | 
            +
              version_requirements: *id002
         | 
| 46 | 
            +
            - !ruby/object:Gem::Dependency 
         | 
| 47 | 
            +
              name: activerecord
         | 
| 48 | 
            +
              prerelease: false
         | 
| 49 | 
            +
              requirement: &id003 !ruby/object:Gem::Requirement 
         | 
| 50 | 
            +
                requirements: 
         | 
| 51 | 
            +
                - - ">="
         | 
| 52 | 
            +
                  - !ruby/object:Gem::Version 
         | 
| 53 | 
            +
                    segments: 
         | 
| 54 | 
            +
                    - 2
         | 
| 55 | 
            +
                    - 3
         | 
| 56 | 
            +
                    - 5
         | 
| 57 | 
            +
                    version: 2.3.5
         | 
| 58 | 
            +
              type: :runtime
         | 
| 59 | 
            +
              version_requirements: *id003
         | 
| 60 | 
            +
            - !ruby/object:Gem::Dependency 
         | 
| 61 | 
            +
              name: gdata
         | 
| 62 | 
            +
              prerelease: false
         | 
| 63 | 
            +
              requirement: &id004 !ruby/object:Gem::Requirement 
         | 
| 64 | 
            +
                requirements: 
         | 
| 65 | 
            +
                - - ">="
         | 
| 66 | 
            +
                  - !ruby/object:Gem::Version 
         | 
| 67 | 
            +
                    segments: 
         | 
| 68 | 
            +
                    - 0
         | 
| 69 | 
            +
                    version: "0"
         | 
| 70 | 
            +
              type: :runtime
         | 
| 71 | 
            +
              version_requirements: *id004
         | 
| 72 | 
            +
            description: "Googletastic: A New Way of Googling"
         | 
| 73 | 
            +
            email: lancejpollard@gmail.com
         | 
| 74 | 
            +
            executables: []
         | 
| 75 | 
            +
             | 
| 76 | 
            +
            extensions: []
         | 
| 77 | 
            +
             | 
| 78 | 
            +
            extra_rdoc_files: 
         | 
| 79 | 
            +
            - README.textile
         | 
| 80 | 
            +
            files: 
         | 
| 81 | 
            +
            - README.textile
         | 
| 82 | 
            +
            - Rakefile
         | 
| 83 | 
            +
            - lib/googletastic/access_rule.rb
         | 
| 84 | 
            +
            - lib/googletastic/album.rb
         | 
| 85 | 
            +
            - lib/googletastic/app_engine.rb
         | 
| 86 | 
            +
            - lib/googletastic/attendee.rb
         | 
| 87 | 
            +
            - lib/googletastic/base.rb
         | 
| 88 | 
            +
            - lib/googletastic/calendar.rb
         | 
| 89 | 
            +
            - lib/googletastic/comment.rb
         | 
| 90 | 
            +
            - lib/googletastic/document.rb
         | 
| 91 | 
            +
            - lib/googletastic/event.rb
         | 
| 92 | 
            +
            - lib/googletastic/ext/file.rb
         | 
| 93 | 
            +
            - lib/googletastic/ext/pretty_print.xsl
         | 
| 94 | 
            +
            - lib/googletastic/ext/xml.rb
         | 
| 95 | 
            +
            - lib/googletastic/ext.rb
         | 
| 96 | 
            +
            - lib/googletastic/form.rb
         | 
| 97 | 
            +
            - lib/googletastic/group.rb
         | 
| 98 | 
            +
            - lib/googletastic/helpers/document.rb
         | 
| 99 | 
            +
            - lib/googletastic/helpers/event.rb
         | 
| 100 | 
            +
            - lib/googletastic/helpers/form.rb
         | 
| 101 | 
            +
            - lib/googletastic/helpers.rb
         | 
| 102 | 
            +
            - lib/googletastic/image.rb
         | 
| 103 | 
            +
            - lib/googletastic/mixins/actions.rb
         | 
| 104 | 
            +
            - lib/googletastic/mixins/attributes.rb
         | 
| 105 | 
            +
            - lib/googletastic/mixins/finders.rb
         | 
| 106 | 
            +
            - lib/googletastic/mixins/namespaces.rb
         | 
| 107 | 
            +
            - lib/googletastic/mixins/parsing.rb
         | 
| 108 | 
            +
            - lib/googletastic/mixins/requesting.rb
         | 
| 109 | 
            +
            - lib/googletastic/mixins.rb
         | 
| 110 | 
            +
            - lib/googletastic/person.rb
         | 
| 111 | 
            +
            - lib/googletastic/spreadsheet.rb
         | 
| 112 | 
            +
            - lib/googletastic/sync/document.rb
         | 
| 113 | 
            +
            - lib/googletastic/sync/form.rb
         | 
| 114 | 
            +
            - lib/googletastic/sync.rb
         | 
| 115 | 
            +
            - lib/googletastic/thumbnail.rb
         | 
| 116 | 
            +
            - lib/googletastic/youtube.rb
         | 
| 117 | 
            +
            - lib/googletastic.rb
         | 
| 118 | 
            +
            - spec/benchmarks/document_benchmark.rb
         | 
| 119 | 
            +
            - spec/config.yml
         | 
| 120 | 
            +
            - spec/fixtures/data/basic.txt
         | 
| 121 | 
            +
            - spec/fixtures/data/calendar.list.xml
         | 
| 122 | 
            +
            - spec/fixtures/data/doc_as_html.html
         | 
| 123 | 
            +
            - spec/fixtures/data/doc_as_html_html.html
         | 
| 124 | 
            +
            - spec/fixtures/data/doclist.xml
         | 
| 125 | 
            +
            - spec/fixtures/data/document.single.xml
         | 
| 126 | 
            +
            - spec/fixtures/data/Doing business in the eMarketPlace.doc
         | 
| 127 | 
            +
            - spec/fixtures/data/end.xml
         | 
| 128 | 
            +
            - spec/fixtures/data/event.list.xml
         | 
| 129 | 
            +
            - spec/fixtures/data/form.html
         | 
| 130 | 
            +
            - spec/fixtures/data/group.list.xml
         | 
| 131 | 
            +
            - spec/fixtures/data/person.list.xml
         | 
| 132 | 
            +
            - spec/fixtures/data/photo.list.xml
         | 
| 133 | 
            +
            - spec/fixtures/data/sample_upload.mp4
         | 
| 134 | 
            +
            - spec/fixtures/data/spreadsheet.list.xml
         | 
| 135 | 
            +
            - spec/fixtures/models/document.rb
         | 
| 136 | 
            +
            - spec/fixtures/models/event.rb
         | 
| 137 | 
            +
            - spec/fixtures/models/form.rb
         | 
| 138 | 
            +
            - spec/fixtures/models/test_model.rb
         | 
| 139 | 
            +
            - spec/fixtures/results/test.txt
         | 
| 140 | 
            +
            - spec/googletastic/access_rule_spec.rb
         | 
| 141 | 
            +
            - spec/googletastic/album_spec.rb
         | 
| 142 | 
            +
            - spec/googletastic/app_engine_spec.rb
         | 
| 143 | 
            +
            - spec/googletastic/base_spec.rb
         | 
| 144 | 
            +
            - spec/googletastic/calendar_spec.rb
         | 
| 145 | 
            +
            - spec/googletastic/document_spec.rb
         | 
| 146 | 
            +
            - spec/googletastic/event_spec.rb
         | 
| 147 | 
            +
            - spec/googletastic/form_spec.rb
         | 
| 148 | 
            +
            - spec/googletastic/group_spec.rb
         | 
| 149 | 
            +
            - spec/googletastic/image_spec.rb
         | 
| 150 | 
            +
            - spec/googletastic/person_spec.rb
         | 
| 151 | 
            +
            - spec/googletastic/post_spec.rb
         | 
| 152 | 
            +
            - spec/googletastic/spreadsheet_spec.rb
         | 
| 153 | 
            +
            - spec/googletastic/youtube_spec.rb
         | 
| 154 | 
            +
            - spec/spec.opts
         | 
| 155 | 
            +
            - spec/spec_helper.rb
         | 
| 156 | 
            +
            has_rdoc: true
         | 
| 157 | 
            +
            homepage: http://github.com/viatropos/googletastic
         | 
| 158 | 
            +
            licenses: []
         | 
| 159 | 
            +
             | 
| 160 | 
            +
            post_install_message: 
         | 
| 161 | 
            +
            rdoc_options: []
         | 
| 162 | 
            +
             | 
| 163 | 
            +
            require_paths: 
         | 
| 164 | 
            +
            - lib
         | 
| 165 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement 
         | 
| 166 | 
            +
              requirements: 
         | 
| 167 | 
            +
              - - ">="
         | 
| 168 | 
            +
                - !ruby/object:Gem::Version 
         | 
| 169 | 
            +
                  segments: 
         | 
| 170 | 
            +
                  - 0
         | 
| 171 | 
            +
                  version: "0"
         | 
| 172 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement 
         | 
| 173 | 
            +
              requirements: 
         | 
| 174 | 
            +
              - - ">="
         | 
| 175 | 
            +
                - !ruby/object:Gem::Version 
         | 
| 176 | 
            +
                  segments: 
         | 
| 177 | 
            +
                  - 0
         | 
| 178 | 
            +
                  version: "0"
         | 
| 179 | 
            +
            requirements: []
         | 
| 180 | 
            +
             | 
| 181 | 
            +
            rubyforge_project: googletastic
         | 
| 182 | 
            +
            rubygems_version: 1.3.6
         | 
| 183 | 
            +
            signing_key: 
         | 
| 184 | 
            +
            specification_version: 3
         | 
| 185 | 
            +
            summary: More than Syncing Rails Apps with the Google Data API
         | 
| 186 | 
            +
            test_files: []
         | 
| 187 | 
            +
             |