Permalink
Browse files

Merge branch 'master' of github.com:scribd/rscribd

  • Loading branch information...
2 parents ebb5cff + 7e858d6 commit a4257fbb482f641edffca7930b7479b13198d6c3 Tim Morgan committed May 11, 2010
Showing with 110 additions and 15 deletions.
  1. +0 −1 .gitignore
  2. +8 −0 History.txt
  3. +2 −2 README.txt
  4. +5 −0 Rakefile
  5. +1 −1 VERSION
  6. +54 −7 lib/scribddoc.rb
  7. +2 −2 lib/scribduser.rb
  8. +38 −2 spec/document_spec.rb
View
@@ -1,5 +1,4 @@
doc
-*.gemspec
pkg
.idea
.DS_Store
View
@@ -1,3 +1,11 @@
+=== 1.1.0 / 2010-3-16
+
+* Switched from Hoe to Jeweler.
+* Added support for docs.browse and docs.featured.
+* Added support for docs.getStats call to fetch document read count.
+* Fixed bug where access parameter wasn't sent in docs.changeSettings call.
+* Fixed Windows binary file upload issue.
+
=== 1.0.4 / 2009-7-24
* Offset and limit parameters can now be used when fetching user documents.
View
@@ -1,6 +1,6 @@
= rscribd
-* 1.0.3 (July 13, 2009)
+* 1.1.0 (March 16, 2010)
== DESCRIPTION:
@@ -25,7 +25,7 @@ storage system to store your documents in accessible manner. Scribd's ad system
will help you monetize your documents easily.
First, you'll need to get a Scribd API account. Visit
-http://www.scribd.com/publisher/api to apply for a platform account.
+http://www.scribd.com/developers/api to apply for a platform account.
On the Platform site you will be given an API key and secret. The API object
will need these to authenticate you:
View
@@ -10,10 +10,15 @@ begin
gemspec.email = "api@scribd.com"
gemspec.homepage = "http://www.scribd.com/developers"
gemspec.authors = [ "Tim Morgan", "Jared Friedman", "Mike Watts" ]
+ gemspec.rubyforge_project = "rscribd"
gemspec.add_dependency 'mime-types'
gemspec.add_development_dependency "rspec"
end
+ Jeweler::RubyforgeTasks.new do |rubyforge|
+ rubyforge.doc_task = "rdoc"
+ end
+ Jeweler::GemcutterTasks.new
rescue LoadError
puts "Jeweler not available. Install it with: gem install jeweler"
end
View
@@ -1 +1 @@
-1.0.4
+1.1.0
View
@@ -26,7 +26,7 @@ module Scribd
# Aside from these two attributes, you can set other attributes that affect
# how the file is displayed on Scribd. See the API documentation online for a
# list of attributes, at
- # http://www.scribd.com/publisher/api?method_name=docs.search (consult the
+ # http://www.scribd.com/developers/api?method_name=docs.search (consult the
# "Result explanation" section).
#
# These attributes can be accessed or changed directly
@@ -177,7 +177,7 @@ def self.update_all(docs, options)
# their content. You must at a minimum supply a +query+ option, with a
# string that will become the full-text search query. For a list of other
# supported options, please see the online API documentation at
- # http://www.scribd.com/publisher/api?method_name=docs.search
+ # http://www.scribd.com/developers/api?method_name=docs.search
#
# The scope can be any value given for the +scope+ parameter in the above
# website, or <tt>:first</tt> to return the first result only (not an array
@@ -195,7 +195,7 @@ def self.update_all(docs, options)
#
# Passing in simply a numerical ID loads the document with that ID. You can
# pass additional options as defined at
- # httphttp://www.scribd.com/publisher/api?method_name=docs.getSettings
+ # httphttp://www.scribd.com/developers/api?method_name=docs.getSettings
#
# Scribd::Document.find(108196)
#
@@ -222,19 +222,66 @@ def self.find(scope, options={})
return scope == :first ? documents.first : documents
end
end
-
+
+ # === Featured docs
+ #
+ # This method is called with a scope and a hash of options. For a list of
+ # supported options, please see the online API documentation at
+ # http://www.scribd.com/developers/api?method_name=docs.featured
+ #
+ # The scope can be either <tt>:first</tt> to return the first result only (not an array
+ # of results) or <tt>:all</tt> to return an array. Include a +scope+ option
+ # to control the parameter described in the API documentation.
+ #
+ # Scribd::Document.featured(:all, :scope => 'hot', :limit => 10)
+ #
+ # Documents returned from this method will have their +owner+ attributes set
+ # to nil.
+
+ def self.featured(scope, options = {})
+ response = API.instance.send_request('docs.featured', options)
+ documents = []
+ response.elements['/rsp/result_set'].elements.each do |doc|
+ documents << Document.new(:xml => doc)
+ end
+ scope == :first ? documents.first : documents
+ end
+
+ # === Browse docs
+ #
+ # This method is called with a scope and a hash of options. For a list of
+ # supported options, please see the online API documentation at
+ # http://www.scribd.com/developers/api?method_name=docs.browse
+ #
+ # The scope can be either <tt>:first</tt> to return the first result only (not an array
+ # of results) or <tt>:all</tt> to return an array.
+ #
+ # Scribd::Document.browse(:all, :sort => 'views', :category_id => 1, :limit => 10)
+ #
+ # Documents returned from this method will have their +owner+ attributes set
+ # to nil.
+
+ def self.browse(scope, options = {})
+ response = API.instance.send_request('docs.browse', options)
+ documents = []
+ response.elements['/rsp/result_set'].elements.each do |doc|
+ documents << Document.new(:xml => doc)
+ end
+ scope == :first ? documents.first : documents
+ end
+
class << self
alias_method :upload, :create
end
-
+
# Returns the conversion status of this document. When a document is
# uploaded it must be converted before it can be used. The conversion is
# non-blocking; you can query this method to determine whether the document
# is ready to be displayed.
#
# The conversion status is returned as a string. For a full list of
# conversion statuses, see the online API documentation at
- # http://www.scribd.com/publisher/api?method_name=docs.getConversionStatus
+ # http://www.scribd.com/developers/api?method_name=docs.getConversionStatus
#
# Unlike other properties of a document, this is retrieved from the server
# every time it's queried.
@@ -277,7 +324,7 @@ def owner=(newuser) #:nodoc:
# Retrieves a document's download URL. You can provide a format for the
# download. Valid formats are listed at
- # http://www.scribd.com/publisher/api?method_name=docs.getDownloadUrl
+ # http://www.scribd.com/developers/api?method_name=docs.getDownloadUrl
#
# If you do not provide a format, the link will be for the document's
# original format.
View
@@ -18,7 +18,7 @@ module Scribd
# user = Scribd::API.instance.user
#
# For information on a user's attributes, please consult the online API
- # documentation at http://www.scribd.com/publisher/api?method_name=user.login
+ # documentation at http://www.scribd.com/developers/api?method_name=user.login
#
# You can create a new account with the signup (a.k.a. create) method:
#
@@ -71,7 +71,7 @@ def save
# Scribd::Document instances returned through this method have more
# attributes than those returned by the Scribd::Document.find method. The
# additional attributes are documented online at
- # http://www.scribd.com/publisher/api?method_name=docs.getSettings
+ # http://www.scribd.com/developers/api?method_name=docs.getSettings
def documents(options = {})
response = API.instance.send_request('docs.getList', options.merge(:session_key => @attributes[:session_key]))
View
@@ -442,9 +442,45 @@
end
end
end
-
+
+ describe ".featured" do
+ before :each do
+ @xml = REXML::Document.new("<rsp stat='ok'><result_set><result><access_key>abc123</access_key></result><result><access_key>abc321</access_key></result></result_set></rsp>")
+ end
+
+ it "should set the scope field according the options" do
+ Scribd::API.instance.should_receive(:send_request).with('docs.featured', hash_including(:scope => 'hot')).and_return(@xml)
+ Scribd::Document.featured(:all, :scope => 'hot', :limit => 10)
+ end
+
+ it "should return first result if :first is provided" do
+ Scribd::API.instance.should_receive(:send_request).with('docs.featured', {}).and_return(@xml)
+ docs = Scribd::Document.featured(:first)
+ docs.should be_kind_of(Scribd::Document)
+ docs.access_key.should eql('abc123')
+ end
+ end
+
+ describe ".browse" do
+ before :each do
+ @xml = REXML::Document.new("<rsp stat='ok'><result_set><result><access_key>abc123</access_key></result><result><access_key>abc321</access_key></result></result_set></rsp>")
+ end
+
+ it "should not pass the scope parameter in the options" do
+ Scribd::API.instance.should_receive(:send_request).with('docs.browse', hash_including(:sort => 'views', :category_id => 1, :limit => 10)).and_return(@xml)
+ Scribd::Document.browse(:all, :sort => 'views', :category_id => 1, :limit => 10)
+ end
+
+ it "should return first result if :first is provided" do
+ Scribd::API.instance.should_receive(:send_request).with('docs.browse', {}).and_return(@xml)
+ docs = Scribd::Document.browse(:first)
+ docs.should be_kind_of(Scribd::Document)
+ docs.access_key.should eql('abc123')
+ end
+ end
+
it "should have an upload synonym for the create method"
-
+
describe ".conversion_status" do
before :each do
@document = Scribd::Document.new(:xml => REXML::Document.new("<doc_id type='integer'>123</doc_id>"))

0 comments on commit a4257fb

Please sign in to comment.