scribd_fu 2.0.6 → 2.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/scribd_fu/paperclip.rb +3 -1
- data/scribd_fu.gemspec +4 -4
- data/spec/scribd_fu_spec.rb +28 -15
- metadata +17 -5
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.0.
|
1
|
+
2.0.7
|
data/lib/scribd_fu/paperclip.rb
CHANGED
@@ -28,7 +28,9 @@ module ScribdFu
|
|
28
28
|
# stored on S3, this is a full S3 URI, while it is a full path to the
|
29
29
|
# local file if the file is stored locally.
|
30
30
|
def file_path
|
31
|
-
attached_file.url =~ ScribdFu::S3 ? attached_file.url : attached_file.path
|
31
|
+
path = (attached_file.url =~ ScribdFu::S3) ? attached_file.url : attached_file.path
|
32
|
+
pos = path.rindex('?')
|
33
|
+
(pos) ? path[0, pos] : path
|
32
34
|
end
|
33
35
|
|
34
36
|
|
data/scribd_fu.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{scribd_fu}
|
8
|
-
s.version = "2.0.
|
8
|
+
s.version = "2.0.7"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Matt Darby"]
|
12
|
-
s.date = %q{
|
12
|
+
s.date = %q{2010-06-30}
|
13
13
|
s.description = %q{A Rails gem that streamlines interactions with the Scribd service}
|
14
14
|
s.email = %q{matt@matt-darby.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -38,7 +38,7 @@ Gem::Specification.new do |s|
|
|
38
38
|
s.homepage = %q{http://github.com/mdarby/scribd_fu}
|
39
39
|
s.rdoc_options = ["--charset=UTF-8"]
|
40
40
|
s.require_paths = ["lib"]
|
41
|
-
s.rubygems_version = %q{1.3.
|
41
|
+
s.rubygems_version = %q{1.3.7}
|
42
42
|
s.summary = %q{A Rails gem that streamlines interactions with the Scribd service}
|
43
43
|
s.test_files = [
|
44
44
|
"spec/scribd_fu_spec.rb",
|
@@ -49,7 +49,7 @@ Gem::Specification.new do |s|
|
|
49
49
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
50
50
|
s.specification_version = 3
|
51
51
|
|
52
|
-
if Gem::Version.new(Gem::
|
52
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
53
53
|
else
|
54
54
|
end
|
55
55
|
else
|
data/spec/scribd_fu_spec.rb
CHANGED
@@ -66,7 +66,7 @@ describe "An AttachmentFu model" do
|
|
66
66
|
@scribd_user.should_receive(:upload).with(:file => "some%20filename%20with%20spaces", :access => 'access').and_return(res)
|
67
67
|
ScribdFu::upload(@document, "some filename with spaces")
|
68
68
|
end
|
69
|
-
|
69
|
+
|
70
70
|
end
|
71
71
|
|
72
72
|
describe "and uploading to Scribd succeeded" do
|
@@ -187,13 +187,23 @@ describe "A Paperclip model" do
|
|
187
187
|
@attached_file.stub!(:path => "/path/to/somewhere with spaces.pdf")
|
188
188
|
@attachment.stub!(:update_attributes)
|
189
189
|
end
|
190
|
-
|
190
|
+
|
191
191
|
it "should sanitize the file path" do
|
192
192
|
res = mock('response', :doc_id => 1, :access_key => "ASDF")
|
193
193
|
@scribd_user.should_receive(:upload).with(:file => "/path/to/somewhere%20with%20spaces.pdf", :access => 'access').and_return(res)
|
194
194
|
ScribdFu::upload(@attachment, "/path/to/somewhere with spaces.pdf")
|
195
195
|
end
|
196
|
-
|
196
|
+
|
197
|
+
end
|
198
|
+
|
199
|
+
context "and it was uploaded to S3" do
|
200
|
+
before do
|
201
|
+
@attached_file.stub!(:url => "http://s3.amazonaws.com/path/to/somewhere.pdf?0000000000")
|
202
|
+
end
|
203
|
+
|
204
|
+
it "should strip the trailing cache string before sending to Scribd" do
|
205
|
+
@attachment.file_path.should == "http://s3.amazonaws.com/path/to/somewhere.pdf"
|
206
|
+
end
|
197
207
|
end
|
198
208
|
|
199
209
|
describe "and uploading to Scribd succeeded" do
|
@@ -203,7 +213,10 @@ describe "A Paperclip model" do
|
|
203
213
|
end
|
204
214
|
|
205
215
|
it "should update the Scribd-centric attributes" do
|
206
|
-
@attachment.should_receive(:update_attributes).with({
|
216
|
+
@attachment.should_receive(:update_attributes).with({
|
217
|
+
:ipaper_id => 'doc_id',
|
218
|
+
:ipaper_access_key => 'access_key'
|
219
|
+
})
|
207
220
|
@attachment.save
|
208
221
|
end
|
209
222
|
|
@@ -270,39 +283,39 @@ end
|
|
270
283
|
describe "Viewing an iPaper document" do
|
271
284
|
before do
|
272
285
|
rebuild_model
|
273
|
-
|
286
|
+
|
274
287
|
config = YAML.load_file("spec/scribd_fu.yml")
|
275
288
|
File.stub!(:file?).with(ScribdFu::ConfigPath).and_return(true)
|
276
289
|
YAML.stub!(:load_file).and_return(config)
|
277
|
-
|
290
|
+
|
278
291
|
Document.class_eval do
|
279
292
|
has_ipaper_and_uses 'AttachmentFu'
|
280
293
|
end
|
281
|
-
|
294
|
+
|
282
295
|
@document = Document.new
|
283
296
|
@document.attributes = {:ipaper_id => 'doc_id', :ipaper_access_key => 'access_key'}
|
284
297
|
end
|
285
|
-
|
298
|
+
|
286
299
|
it "should return this HTML by default" do
|
287
300
|
@document.display_ipaper.gsub(/\s{2,}/, "").should == "<script type=\"text/javascript\" src=\"http://www.scribd.com/javascripts/view.js\"></script><div id=\"embedded_flash\"></div><script type=\"text/javascript\">var scribd_doc = scribd.Document.getDoc(doc_id, 'access_key');scribd_doc.write(\"embedded_flash\");</script>\n"
|
288
301
|
end
|
289
|
-
|
302
|
+
|
290
303
|
it "should allow custom alt text" do
|
291
304
|
@document.display_ipaper(:alt => "something").should =~ /.*<div id="embedded_flash">something<\/div>.*/
|
292
305
|
end
|
293
|
-
|
306
|
+
|
294
307
|
it "should allow custom Javascript params" do
|
295
308
|
options = {:height => 100, :width => 100}
|
296
|
-
|
309
|
+
|
297
310
|
@document.display_ipaper(options).should =~ /.*scribd_doc\.addParam\('height', '100'\);.*/
|
298
311
|
@document.display_ipaper(options).should =~ /.*scribd_doc\.addParam\('width', '100'\);.*/
|
299
312
|
end
|
300
|
-
|
313
|
+
|
301
314
|
it "should allow not allow crazy custom Javascript params" do
|
302
315
|
options = {:some_dumb_setting => 100, :width => 100}
|
303
|
-
|
316
|
+
|
304
317
|
@document.display_ipaper(options).should =~ /.*scribd_doc\.addParam\('width', '100'\);.*/
|
305
318
|
@document.display_ipaper(options).should_not =~ /.*scribd_doc\.addParam\('some_dumb_setting', '100'\);.*/
|
306
319
|
end
|
307
|
-
|
308
|
-
end
|
320
|
+
|
321
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scribd_fu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 1
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 2
|
8
|
+
- 0
|
9
|
+
- 7
|
10
|
+
version: 2.0.7
|
5
11
|
platform: ruby
|
6
12
|
authors:
|
7
13
|
- Matt Darby
|
@@ -9,7 +15,7 @@ autorequire:
|
|
9
15
|
bindir: bin
|
10
16
|
cert_chain: []
|
11
17
|
|
12
|
-
date:
|
18
|
+
date: 2010-06-30 00:00:00 -04:00
|
13
19
|
default_executable:
|
14
20
|
dependencies: []
|
15
21
|
|
@@ -50,21 +56,27 @@ rdoc_options:
|
|
50
56
|
require_paths:
|
51
57
|
- lib
|
52
58
|
required_ruby_version: !ruby/object:Gem::Requirement
|
59
|
+
none: false
|
53
60
|
requirements:
|
54
61
|
- - ">="
|
55
62
|
- !ruby/object:Gem::Version
|
63
|
+
hash: 3
|
64
|
+
segments:
|
65
|
+
- 0
|
56
66
|
version: "0"
|
57
|
-
version:
|
58
67
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
|
+
none: false
|
59
69
|
requirements:
|
60
70
|
- - ">="
|
61
71
|
- !ruby/object:Gem::Version
|
72
|
+
hash: 3
|
73
|
+
segments:
|
74
|
+
- 0
|
62
75
|
version: "0"
|
63
|
-
version:
|
64
76
|
requirements: []
|
65
77
|
|
66
78
|
rubyforge_project:
|
67
|
-
rubygems_version: 1.3.
|
79
|
+
rubygems_version: 1.3.7
|
68
80
|
signing_key:
|
69
81
|
specification_version: 3
|
70
82
|
summary: A Rails gem that streamlines interactions with the Scribd service
|