rscribd 1.0.4 → 1.1.0
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/.gitignore +0 -1
- data/History.txt +8 -0
- data/README.txt +2 -2
- data/Rakefile +1 -0
- data/VERSION +1 -1
- data/lib/scribddoc.rb +55 -8
- data/lib/scribduser.rb +2 -2
- data/spec/document_spec.rb +38 -2
- metadata +24 -14
- data/Manifest.txt +0 -14
data/History.txt
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
=== 1.1.0 / 2010-3-16
|
2
|
+
|
3
|
+
* Switched from Hoe to Jeweler.
|
4
|
+
* Added support for docs.browse and docs.featured.
|
5
|
+
* Added support for docs.getStats call to fetch document read count.
|
6
|
+
* Fixed bug where access parameter wasn't sent in docs.changeSettings call.
|
7
|
+
* Fixed Windows binary file upload issue.
|
8
|
+
|
1
9
|
=== 1.0.4 / 2009-7-24
|
2
10
|
|
3
11
|
* Offset and limit parameters can now be used when fetching user documents.
|
data/README.txt
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
= rscribd
|
2
2
|
|
3
|
-
* 1.0
|
3
|
+
* 1.1.0 (March 16, 2010)
|
4
4
|
|
5
5
|
== DESCRIPTION:
|
6
6
|
|
@@ -25,7 +25,7 @@ storage system to store your documents in accessible manner. Scribd's ad system
|
|
25
25
|
will help you monetize your documents easily.
|
26
26
|
|
27
27
|
First, you'll need to get a Scribd API account. Visit
|
28
|
-
http://www.scribd.com/
|
28
|
+
http://www.scribd.com/developers/api to apply for a platform account.
|
29
29
|
|
30
30
|
On the Platform site you will be given an API key and secret. The API object
|
31
31
|
will need these to authenticate you:
|
data/Rakefile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0
|
1
|
+
1.1.0
|
data/lib/scribddoc.rb
CHANGED
@@ -26,7 +26,7 @@ module Scribd
|
|
26
26
|
# Aside from these two attributes, you can set other attributes that affect
|
27
27
|
# how the file is displayed on Scribd. See the API documentation online for a
|
28
28
|
# list of attributes, at
|
29
|
-
# http://www.scribd.com/
|
29
|
+
# http://www.scribd.com/developers/api?method_name=docs.search (consult the
|
30
30
|
# "Result explanation" section).
|
31
31
|
#
|
32
32
|
# These attributes can be accessed or changed directly
|
@@ -121,7 +121,7 @@ module Scribd
|
|
121
121
|
fields[:url] = @attributes[:file]
|
122
122
|
response = API.instance.send_request 'docs.uploadFromUrl', fields
|
123
123
|
elsif uri.kind_of? URI::Generic or uri.nil? then
|
124
|
-
file_obj = is_file_object ? file : File.open(file, '
|
124
|
+
file_obj = is_file_object ? file : File.open(file, 'rb')
|
125
125
|
fields[:file] = file_obj
|
126
126
|
response = API.instance.send_request 'docs.upload', fields
|
127
127
|
file_obj.close unless is_file_object
|
@@ -177,7 +177,7 @@ module Scribd
|
|
177
177
|
# their content. You must at a minimum supply a +query+ option, with a
|
178
178
|
# string that will become the full-text search query. For a list of other
|
179
179
|
# supported options, please see the online API documentation at
|
180
|
-
# http://www.scribd.com/
|
180
|
+
# http://www.scribd.com/developers/api?method_name=docs.search
|
181
181
|
#
|
182
182
|
# The scope can be any value given for the +scope+ parameter in the above
|
183
183
|
# website, or <tt>:first</tt> to return the first result only (not an array
|
@@ -195,7 +195,7 @@ module Scribd
|
|
195
195
|
#
|
196
196
|
# Passing in simply a numerical ID loads the document with that ID. You can
|
197
197
|
# pass additional options as defined at
|
198
|
-
# httphttp://www.scribd.com/
|
198
|
+
# httphttp://www.scribd.com/developers/api?method_name=docs.getSettings
|
199
199
|
#
|
200
200
|
# Scribd::Document.find(108196)
|
201
201
|
#
|
@@ -222,11 +222,58 @@ module Scribd
|
|
222
222
|
return scope == :first ? documents.first : documents
|
223
223
|
end
|
224
224
|
end
|
225
|
-
|
225
|
+
|
226
|
+
# === Featured docs
|
227
|
+
#
|
228
|
+
# This method is called with a scope and a hash of options. For a list of
|
229
|
+
# supported options, please see the online API documentation at
|
230
|
+
# http://www.scribd.com/developers/api?method_name=docs.featured
|
231
|
+
#
|
232
|
+
# The scope can be either <tt>:first</tt> to return the first result only (not an array
|
233
|
+
# of results) or <tt>:all</tt> to return an array. Include a +scope+ option
|
234
|
+
# to control the parameter described in the API documentation.
|
235
|
+
#
|
236
|
+
# Scribd::Document.featured(:all, :scope => 'hot', :limit => 10)
|
237
|
+
#
|
238
|
+
# Documents returned from this method will have their +owner+ attributes set
|
239
|
+
# to nil.
|
240
|
+
|
241
|
+
def self.featured(scope, options = {})
|
242
|
+
response = API.instance.send_request('docs.featured', options)
|
243
|
+
documents = []
|
244
|
+
response.elements['/rsp/result_set'].elements.each do |doc|
|
245
|
+
documents << Document.new(:xml => doc)
|
246
|
+
end
|
247
|
+
scope == :first ? documents.first : documents
|
248
|
+
end
|
249
|
+
|
250
|
+
# === Browse docs
|
251
|
+
#
|
252
|
+
# This method is called with a scope and a hash of options. For a list of
|
253
|
+
# supported options, please see the online API documentation at
|
254
|
+
# http://www.scribd.com/developers/api?method_name=docs.browse
|
255
|
+
#
|
256
|
+
# The scope can be either <tt>:first</tt> to return the first result only (not an array
|
257
|
+
# of results) or <tt>:all</tt> to return an array.
|
258
|
+
#
|
259
|
+
# Scribd::Document.browse(:all, :sort => 'views', :category_id => 1, :limit => 10)
|
260
|
+
#
|
261
|
+
# Documents returned from this method will have their +owner+ attributes set
|
262
|
+
# to nil.
|
263
|
+
|
264
|
+
def self.browse(scope, options = {})
|
265
|
+
response = API.instance.send_request('docs.browse', options)
|
266
|
+
documents = []
|
267
|
+
response.elements['/rsp/result_set'].elements.each do |doc|
|
268
|
+
documents << Document.new(:xml => doc)
|
269
|
+
end
|
270
|
+
scope == :first ? documents.first : documents
|
271
|
+
end
|
272
|
+
|
226
273
|
class << self
|
227
274
|
alias_method :upload, :create
|
228
275
|
end
|
229
|
-
|
276
|
+
|
230
277
|
# Returns the conversion status of this document. When a document is
|
231
278
|
# uploaded it must be converted before it can be used. The conversion is
|
232
279
|
# non-blocking; you can query this method to determine whether the document
|
@@ -234,7 +281,7 @@ module Scribd
|
|
234
281
|
#
|
235
282
|
# The conversion status is returned as a string. For a full list of
|
236
283
|
# conversion statuses, see the online API documentation at
|
237
|
-
# http://www.scribd.com/
|
284
|
+
# http://www.scribd.com/developers/api?method_name=docs.getConversionStatus
|
238
285
|
#
|
239
286
|
# Unlike other properties of a document, this is retrieved from the server
|
240
287
|
# every time it's queried.
|
@@ -277,7 +324,7 @@ module Scribd
|
|
277
324
|
|
278
325
|
# Retrieves a document's download URL. You can provide a format for the
|
279
326
|
# download. Valid formats are listed at
|
280
|
-
# http://www.scribd.com/
|
327
|
+
# http://www.scribd.com/developers/api?method_name=docs.getDownloadUrl
|
281
328
|
#
|
282
329
|
# If you do not provide a format, the link will be for the document's
|
283
330
|
# original format.
|
data/lib/scribduser.rb
CHANGED
@@ -18,7 +18,7 @@ module Scribd
|
|
18
18
|
# user = Scribd::API.instance.user
|
19
19
|
#
|
20
20
|
# For information on a user's attributes, please consult the online API
|
21
|
-
# documentation at http://www.scribd.com/
|
21
|
+
# documentation at http://www.scribd.com/developers/api?method_name=user.login
|
22
22
|
#
|
23
23
|
# You can create a new account with the signup (a.k.a. create) method:
|
24
24
|
#
|
@@ -71,7 +71,7 @@ module Scribd
|
|
71
71
|
# Scribd::Document instances returned through this method have more
|
72
72
|
# attributes than those returned by the Scribd::Document.find method. The
|
73
73
|
# additional attributes are documented online at
|
74
|
-
# http://www.scribd.com/
|
74
|
+
# http://www.scribd.com/developers/api?method_name=docs.getSettings
|
75
75
|
|
76
76
|
def documents(options = {})
|
77
77
|
response = API.instance.send_request('docs.getList', options.merge(:session_key => @attributes[:session_key]))
|
data/spec/document_spec.rb
CHANGED
@@ -442,9 +442,45 @@ describe Scribd::Document do
|
|
442
442
|
end
|
443
443
|
end
|
444
444
|
end
|
445
|
-
|
445
|
+
|
446
|
+
describe ".featured" do
|
447
|
+
before :each do
|
448
|
+
@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>")
|
449
|
+
end
|
450
|
+
|
451
|
+
it "should set the scope field according the options" do
|
452
|
+
Scribd::API.instance.should_receive(:send_request).with('docs.featured', hash_including(:scope => 'hot')).and_return(@xml)
|
453
|
+
Scribd::Document.featured(:all, :scope => 'hot', :limit => 10)
|
454
|
+
end
|
455
|
+
|
456
|
+
it "should return first result if :first is provided" do
|
457
|
+
Scribd::API.instance.should_receive(:send_request).with('docs.featured', {}).and_return(@xml)
|
458
|
+
docs = Scribd::Document.featured(:first)
|
459
|
+
docs.should be_kind_of(Scribd::Document)
|
460
|
+
docs.access_key.should eql('abc123')
|
461
|
+
end
|
462
|
+
end
|
463
|
+
|
464
|
+
describe ".browse" do
|
465
|
+
before :each do
|
466
|
+
@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>")
|
467
|
+
end
|
468
|
+
|
469
|
+
it "should not pass the scope parameter in the options" do
|
470
|
+
Scribd::API.instance.should_receive(:send_request).with('docs.browse', hash_including(:sort => 'views', :category_id => 1, :limit => 10)).and_return(@xml)
|
471
|
+
Scribd::Document.browse(:all, :sort => 'views', :category_id => 1, :limit => 10)
|
472
|
+
end
|
473
|
+
|
474
|
+
it "should return first result if :first is provided" do
|
475
|
+
Scribd::API.instance.should_receive(:send_request).with('docs.browse', {}).and_return(@xml)
|
476
|
+
docs = Scribd::Document.browse(:first)
|
477
|
+
docs.should be_kind_of(Scribd::Document)
|
478
|
+
docs.access_key.should eql('abc123')
|
479
|
+
end
|
480
|
+
end
|
481
|
+
|
446
482
|
it "should have an upload synonym for the create method"
|
447
|
-
|
483
|
+
|
448
484
|
describe ".conversion_status" do
|
449
485
|
before :each do
|
450
486
|
@document = Scribd::Document.new(:xml => REXML::Document.new("<doc_id type='integer'>123</doc_id>"))
|
metadata
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rscribd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 1
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
version: 1.1.0
|
5
10
|
platform: ruby
|
6
11
|
authors:
|
7
12
|
- Tim Morgan
|
@@ -11,29 +16,33 @@ autorequire:
|
|
11
16
|
bindir: bin
|
12
17
|
cert_chain: []
|
13
18
|
|
14
|
-
date: 2010-
|
19
|
+
date: 2010-03-16 00:00:00 -07:00
|
15
20
|
default_executable:
|
16
21
|
dependencies:
|
17
22
|
- !ruby/object:Gem::Dependency
|
18
23
|
name: mime-types
|
19
|
-
|
20
|
-
|
21
|
-
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
prerelease: false
|
25
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
22
26
|
requirements:
|
23
27
|
- - ">="
|
24
28
|
- !ruby/object:Gem::Version
|
29
|
+
segments:
|
30
|
+
- 0
|
25
31
|
version: "0"
|
26
|
-
|
32
|
+
type: :runtime
|
33
|
+
version_requirements: *id001
|
27
34
|
- !ruby/object:Gem::Dependency
|
28
35
|
name: rspec
|
29
|
-
|
30
|
-
|
31
|
-
version_requirements: !ruby/object:Gem::Requirement
|
36
|
+
prerelease: false
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
32
38
|
requirements:
|
33
39
|
- - ">="
|
34
40
|
- !ruby/object:Gem::Version
|
41
|
+
segments:
|
42
|
+
- 0
|
35
43
|
version: "0"
|
36
|
-
|
44
|
+
type: :development
|
45
|
+
version_requirements: *id002
|
37
46
|
description: The official Ruby gem for the Scribd API. Scribd is a document-sharing website allowing people to upload and view documents online.
|
38
47
|
email: api@scribd.com
|
39
48
|
executables: []
|
@@ -45,7 +54,6 @@ extra_rdoc_files:
|
|
45
54
|
files:
|
46
55
|
- .gitignore
|
47
56
|
- History.txt
|
48
|
-
- Manifest.txt
|
49
57
|
- README.txt
|
50
58
|
- Rakefile
|
51
59
|
- VERSION
|
@@ -78,18 +86,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
78
86
|
requirements:
|
79
87
|
- - ">="
|
80
88
|
- !ruby/object:Gem::Version
|
89
|
+
segments:
|
90
|
+
- 0
|
81
91
|
version: "0"
|
82
|
-
version:
|
83
92
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
84
93
|
requirements:
|
85
94
|
- - ">="
|
86
95
|
- !ruby/object:Gem::Version
|
96
|
+
segments:
|
97
|
+
- 0
|
87
98
|
version: "0"
|
88
|
-
version:
|
89
99
|
requirements: []
|
90
100
|
|
91
101
|
rubyforge_project:
|
92
|
-
rubygems_version: 1.3.
|
102
|
+
rubygems_version: 1.3.6
|
93
103
|
signing_key:
|
94
104
|
specification_version: 3
|
95
105
|
summary: Ruby client library for the Scribd API
|
data/Manifest.txt
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
History.txt
|
2
|
-
Manifest.txt
|
3
|
-
README.txt
|
4
|
-
Rakefile
|
5
|
-
lib/scribdapi.rb
|
6
|
-
lib/scribddoc.rb
|
7
|
-
lib/scribderrors.rb
|
8
|
-
lib/scribdmultiparthack.rb
|
9
|
-
lib/scribdresource.rb
|
10
|
-
lib/rscribd.rb
|
11
|
-
lib/scribduser.rb
|
12
|
-
sample/01_upload.rb
|
13
|
-
sample/02_user.rb
|
14
|
-
sample/test.txt
|