mdarby-scribd_fu 2.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +64 -0
- data/generators/scribd_fu/scribd_fu_generator.rb +7 -0
- data/generators/scribd_fu/templates/scribd_fu.yml +7 -0
- data/lib/scribd_fu.rb +1 -0
- data/lib/scribd_fu/attachment_fu.rb +36 -0
- data/lib/scribd_fu/paperclip.rb +62 -0
- data/scribd_fu.gemspec +21 -9
- data/spec/database.yml +3 -0
- data/spec/scribd_fu.yml +7 -0
- data/spec/scribd_fu_spec.rb +274 -0
- data/spec/spec_helper.rb +42 -0
- metadata +15 -13
data/README.textile
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
h1. Scribd_fu
|
2
|
+
|
3
|
+
A Ruby on Rails plugin that streamlines interaction with Scribd.com's iPaper service, and works along side of either Attachment_fu or Paperclip
|
4
|
+
|
5
|
+
h1. Big Changes! v2.0 OMGZ!
|
6
|
+
|
7
|
+
Please make sure to read below if you're using an older version of ScribdFu. Pretty much everything has changed. Don't fret, it's now easier and cleaner. ScribdFu has been taken out into the backyard and given a thorough scrubbing. It's now lean, mean, fully tested, and works beautifully with Attachment_fu, Paperclip, and Amazon's S3 service.
|
8
|
+
|
9
|
+
h2. What it does
|
10
|
+
|
11
|
+
Scribd_fu hides out in the shadows like a document converting ninja, just waiting to process your data into a convenient Flash format (like YouTube) with the help of the black majick of Scribd.com. Imagine embedding documents inline with your web UI — no downloading, no required programs on the client side (except for Flash) to view your data. It's pretty damned cool, and free to boot!
|
12
|
+
|
13
|
+
h2. Requirements
|
14
|
+
|
15
|
+
Scribd_fu requires the rscribd gem via @sudo gem install rscribd@ (along with either the Attachment_fu plugin or the Paperclip gem)
|
16
|
+
|
17
|
+
h2. How to Install
|
18
|
+
|
19
|
+
h3. ScribdFu requires a base plugin
|
20
|
+
|
21
|
+
ScribdFu is awesome, but it needs help from either "Attachment_fu":http://github.com/technoweenie/attachment_fu/tree/master or "Paperclip":http://github.com/thoughtbot/paperclip/tree/master
|
22
|
+
|
23
|
+
h3. Install ScribdFu
|
24
|
+
|
25
|
+
<pre>sudo gem install mdarby-scribd_fu --source 'http://gems.github.com'</pre>
|
26
|
+
|
27
|
+
h3. Add ScribdFu to your environment.rb
|
28
|
+
|
29
|
+
<pre>config.gem 'mdarby-scribd_fu', :lib => 'scribd_fu', :source => 'http://gems.github.com'</pre>
|
30
|
+
|
31
|
+
h2. How to Use
|
32
|
+
|
33
|
+
* Sign up for "Scribd.com's API access":http://www.scribd.com/developers/signup_api (it's totally free)
|
34
|
+
|
35
|
+
* Run @./script/generate scribd_fu_config@ and fill out @config/scribd_fu.yml@ file with your Scribd account info.
|
36
|
+
|
37
|
+
* If you're using AttachmentFu, add @has_ipaper_and_uses 'AttachmentFu'@ to your model that uses ScribdFu
|
38
|
+
|
39
|
+
* If you're using Paperclip, add @has_ipaper_and_uses 'Paperclip'@ to your model that uses ScribdFu
|
40
|
+
|
41
|
+
* Add the following fields into a new migration for the target model:
|
42
|
+
|
43
|
+
<pre>
|
44
|
+
t.integer :ipaper_id
|
45
|
+
t.string :ipaper_access_key
|
46
|
+
</pre>
|
47
|
+
|
48
|
+
Scribd_fu will use these to track Scribd-related information.
|
49
|
+
|
50
|
+
Now, when you upload a file to that model, Scribd_fu will automatically handle the Scribd side of things for you. Files are uploaded to Scribd after the model is saved. No muss, no fuss. Scribd's conversion of your document is usally quite fast, but if you want a contingency plan, the @conversion_processing?@, @conversion_complete?@, @conversion_successful?@, and @conversion_error?@ instance methods can be used to determine the conversion status of the document.
|
51
|
+
|
52
|
+
h2. Viewing the iPaper Document
|
53
|
+
|
54
|
+
Just add @<%= document.display_ipaper %>@ into your view (where @document@ is an object of your ScribdFu model). That's it!
|
55
|
+
|
56
|
+
h2. Access
|
57
|
+
|
58
|
+
You can set the access level on all documents by setting the @access@ key in the scribd_fu.yml file to either 'private' or 'public'. ScribdFu assumes that you'd like to keep your documents private.
|
59
|
+
|
60
|
+
h2. About the Author
|
61
|
+
|
62
|
+
My name is "Matt Darby.":http://blog.matt-darby.com I’m an IT Manager and pro-web-dev at for "Dynamix Engineering":http://dynamix-ltd.com and hold a Master’s Degree in Computer Science from "Franklin University":http://www.franklin.edu in sunny "Columbus, OH.":http://en.wikipedia.org/wiki/Columbus,_Ohio
|
63
|
+
|
64
|
+
Feel free to check out my "blog":http://blog.matt-darby.com or "recommend me":http://www.workingwithrails.com/person/10908-matt-darby
|
data/lib/scribd_fu.rb
CHANGED
@@ -0,0 +1,36 @@
|
|
1
|
+
module ScribdFu
|
2
|
+
module AttachmentFu
|
3
|
+
|
4
|
+
module ClassMethods
|
5
|
+
end
|
6
|
+
|
7
|
+
module InstanceMethods
|
8
|
+
|
9
|
+
def self.included(base)
|
10
|
+
base.extend ClassMethods
|
11
|
+
end
|
12
|
+
|
13
|
+
# Returns a URL for a thumbnail for this model's attachment.
|
14
|
+
#
|
15
|
+
# If Scribd does not provide a thumbnail URL, then Attachment_fu's
|
16
|
+
# thumbnail is fallen back on by returning the value of
|
17
|
+
# <tt>public_filename(:thumb)</tt>.
|
18
|
+
#
|
19
|
+
# Sample use in a view:
|
20
|
+
# <%= image_tag(@attachment.thumbnail_url, :alt => @attachment.name) %>
|
21
|
+
def thumbnail_url
|
22
|
+
(ipaper_document && ipaper_document.thumbnail_url) || public_filename(:thumb)
|
23
|
+
end
|
24
|
+
|
25
|
+
def get_content_type
|
26
|
+
self.content_type
|
27
|
+
end
|
28
|
+
|
29
|
+
# Yields the correct path to the file, either the local filename or the S3 URL.
|
30
|
+
def file_path
|
31
|
+
public_filename
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module ScribdFu
|
2
|
+
module Paperclip
|
3
|
+
|
4
|
+
module ClassMethods
|
5
|
+
end
|
6
|
+
|
7
|
+
module InstanceMethods
|
8
|
+
|
9
|
+
def self.included(base)
|
10
|
+
base.extend ClassMethods
|
11
|
+
end
|
12
|
+
|
13
|
+
# Find the content type of the associated file
|
14
|
+
def get_content_type
|
15
|
+
self.send("#{prefix}_content_type")
|
16
|
+
end
|
17
|
+
|
18
|
+
# Returns a URL for a thumbnail for the specified +attribute+ attachment.
|
19
|
+
#
|
20
|
+
# If Scribd does not provide a thumbnail URL, then Paperclip's thumbnail
|
21
|
+
# is fallen back on by returning the value of
|
22
|
+
# <tt>attribute.url(:thumb)</tt>.
|
23
|
+
#
|
24
|
+
# Sample use in a view:
|
25
|
+
# <%= image_tag(@attachment.thumbnail_url, :alt => @attachment.name) %>
|
26
|
+
def thumbnail_url
|
27
|
+
begin
|
28
|
+
(ipaper_document && ipaper_document.thumbnail_url) || attached_file.url(:thumb)
|
29
|
+
rescue
|
30
|
+
raise ScribdFu::ScribdFuError, "The thumbnail doesn't exist."
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# Returns the full filename for the given attribute. If the file is
|
35
|
+
# stored on S3, this is a full S3 URI, while it is a full path to the
|
36
|
+
# local file if the file is stored locally.
|
37
|
+
def file_path
|
38
|
+
if attached_file.url =~ /^https{0,1}:\/\/s3.amazonaws.com$/
|
39
|
+
attached_file.url
|
40
|
+
else
|
41
|
+
attached_file.path
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
# Figure out what Paperclip is calling the attached file object
|
49
|
+
# ie. has_attached_file :attachment => "attachment"
|
50
|
+
def prefix
|
51
|
+
@prefix ||= self.class.column_names.detect{|c| c.ends_with?("_file_name")}.gsub("_file_name", '')
|
52
|
+
end
|
53
|
+
|
54
|
+
# Return the attached file object
|
55
|
+
def attached_file
|
56
|
+
@file ||= self.send(prefix)
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
data/scribd_fu.gemspec
CHANGED
@@ -1,18 +1,30 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "scribd_fu"
|
3
|
-
s.version = "2.0"
|
4
|
-
s.date = "2009-03-
|
3
|
+
s.version = "2.0.1"
|
4
|
+
s.date = "2009-03-30"
|
5
5
|
s.summary = "Quick and easy interactions with Scribd's iPaper service"
|
6
6
|
s.email = "matt@matt-darby.com"
|
7
7
|
s.homepage = "http://github.com/mdarby/scribd_fu/tree/master"
|
8
8
|
s.description = "A Rails plugin that streamlines interactions with the Scribd service"
|
9
9
|
s.has_rdoc = false
|
10
10
|
s.authors = ["Matt Darby"]
|
11
|
-
s.files = [
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
11
|
+
s.files = [
|
12
|
+
'MIT-LICENSE',
|
13
|
+
'README.textile',
|
14
|
+
'generators/scribd_fu',
|
15
|
+
'generators/scribd_fu/scribd_fu_generator.rb',
|
16
|
+
'generators/scribd_fu/templates',
|
17
|
+
'generators/scribd_fu/templates/scribd_fu.yml',
|
18
|
+
'init.rb',
|
19
|
+
'lib/scribd_fu',
|
20
|
+
'lib/scribd_fu/attachment_fu.rb',
|
21
|
+
'lib/scribd_fu/paperclip.rb',
|
22
|
+
'lib/scribd_fu.rb',
|
23
|
+
'scribd_fu.gemspec',
|
24
|
+
'spec/database.yml',
|
25
|
+
'spec/scribd_fu.yml',
|
26
|
+
'spec/scribd_fu_spec.rb',
|
27
|
+
'spec/spec_helper.rb'
|
28
|
+
]
|
17
29
|
s.add_dependency 'rscribd'
|
18
|
-
end
|
30
|
+
end
|
data/spec/database.yml
ADDED
data/spec/scribd_fu.yml
ADDED
@@ -0,0 +1,274 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), %w[spec_helper])
|
2
|
+
|
3
|
+
describe "ScribdFu" do
|
4
|
+
|
5
|
+
describe "with incorrect Scribd credentials" do
|
6
|
+
before do
|
7
|
+
Scribd::User.stub!(:login).and_raise(Scribd::ResponseError)
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should throw an error" do
|
11
|
+
lambda { ScribdFu::scribd_user }.should raise_error(ScribdFu::ScribdFuError)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "that is missing a config file" do
|
16
|
+
before do
|
17
|
+
File.should_receive(:file?).with("#{RAILS_ROOT}/config/scribd_fu.yml").and_return(false)
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should raise an error" do
|
21
|
+
lambda { ScribdFu::config }.should raise_error(ScribdFu::ScribdFuError)
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "An AttachmentFu model" do
|
29
|
+
before do
|
30
|
+
rebuild_model
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "that is configured for ScribdFu" do
|
34
|
+
before do
|
35
|
+
config = YAML.load_file("spec/scribd_fu.yml")
|
36
|
+
File.stub!(:file?).with(ScribdFu::ConfigPath).and_return(true)
|
37
|
+
YAML.stub!(:load_file).and_return(config)
|
38
|
+
|
39
|
+
Document.class_eval do
|
40
|
+
has_ipaper_and_uses 'AttachmentFu'
|
41
|
+
end
|
42
|
+
|
43
|
+
@document = Document.new
|
44
|
+
end
|
45
|
+
|
46
|
+
describe "with correct credentials" do
|
47
|
+
before do
|
48
|
+
@scribd_user = mock("scribd_user")
|
49
|
+
Scribd::User.stub!(:login).and_return(@scribd_user)
|
50
|
+
end
|
51
|
+
|
52
|
+
describe "that was just created" do
|
53
|
+
before do
|
54
|
+
@document.attributes = {:ipaper_id => nil, :ipaper_access_key => nil, :content_type => "application/pdf"}
|
55
|
+
@document.stub!(:public_filename => "/path/to/somewhere")
|
56
|
+
end
|
57
|
+
|
58
|
+
describe "and is scribdable?" do
|
59
|
+
before do
|
60
|
+
@document.stub!(:scribdable? => true)
|
61
|
+
end
|
62
|
+
|
63
|
+
describe "and uploading to Scribd succeeded" do
|
64
|
+
before do
|
65
|
+
@scribd_response = mock('scribd_response', :doc_id => "doc_id", :access_key => "access_key")
|
66
|
+
@scribd_user.should_receive(:upload).and_return(@scribd_response)
|
67
|
+
end
|
68
|
+
|
69
|
+
it "should update the Scribd-centric attributes" do
|
70
|
+
@document.should_receive(:update_attributes).with({:ipaper_id => 'doc_id', :ipaper_access_key => 'access_key'})
|
71
|
+
@document.save
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
|
76
|
+
describe "and uploading to Scribd failed" do
|
77
|
+
before do
|
78
|
+
@scribd_user.stub!(:upload).and_raise(StandardError)
|
79
|
+
end
|
80
|
+
|
81
|
+
it "should throw an error" do
|
82
|
+
lambda { ScribdFu::upload(@document, 'private') }.should raise_error(ScribdFu::ScribdFuUploadError)
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
|
89
|
+
describe "and is not scribdable?" do
|
90
|
+
before do
|
91
|
+
@document.stub!(:scribdable? => false)
|
92
|
+
end
|
93
|
+
|
94
|
+
it "should not upload to Scribd" do
|
95
|
+
ScribdFu.should_not_receive(:upload)
|
96
|
+
@document.save
|
97
|
+
end
|
98
|
+
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
102
|
+
|
103
|
+
describe "that was just updated" do
|
104
|
+
before do
|
105
|
+
@document.stub!(:ipaper_id => 'doc_id')
|
106
|
+
end
|
107
|
+
|
108
|
+
it "should not reupload to Scribd" do
|
109
|
+
@scribd_user.should_not_receive(:upload)
|
110
|
+
@document.save
|
111
|
+
end
|
112
|
+
|
113
|
+
end
|
114
|
+
|
115
|
+
describe "that is about to be destroyed" do
|
116
|
+
before do
|
117
|
+
@ipaper_document = mock("ipaper_document")
|
118
|
+
ScribdFu.stub!(:load_ipaper_document).and_return(@ipaper_document)
|
119
|
+
end
|
120
|
+
|
121
|
+
it "should destroy the ipaper document" do
|
122
|
+
ScribdFu.should_receive(:destroy).with(@ipaper_document)
|
123
|
+
@document.destroy
|
124
|
+
end
|
125
|
+
|
126
|
+
end
|
127
|
+
|
128
|
+
end
|
129
|
+
|
130
|
+
end
|
131
|
+
|
132
|
+
end
|
133
|
+
|
134
|
+
describe "A Paperclip model" do
|
135
|
+
before do
|
136
|
+
rebuild_model
|
137
|
+
end
|
138
|
+
|
139
|
+
describe "that is configured for ScribdFu" do
|
140
|
+
before do
|
141
|
+
config = YAML.load_file("spec/scribd_fu.yml")
|
142
|
+
File.stub!(:file?).with(ScribdFu::ConfigPath).and_return(true)
|
143
|
+
YAML.stub!(:load_file).and_return(config)
|
144
|
+
|
145
|
+
Attachment.class_eval do
|
146
|
+
has_ipaper_and_uses 'Paperclip'
|
147
|
+
end
|
148
|
+
|
149
|
+
@attached_file = mock("attached_file", :url => "http://test.com/path/to/somewhere", :path => "/path/to/somewhere")
|
150
|
+
|
151
|
+
@attachment = Attachment.new
|
152
|
+
@attachment.stub!(:prefix).and_return("attachment")
|
153
|
+
@attachment.stub!(:attached_file).and_return(@attached_file)
|
154
|
+
end
|
155
|
+
|
156
|
+
describe "with correct credentials" do
|
157
|
+
before do
|
158
|
+
@scribd_user = mock("scribd_user")
|
159
|
+
Scribd::User.stub!(:login).and_return(@scribd_user)
|
160
|
+
end
|
161
|
+
|
162
|
+
describe "that was just created" do
|
163
|
+
before do
|
164
|
+
@attachment.attributes = {:ipaper_id => nil, :ipaper_access_key => nil, :attachment_content_type => "application/pdf"}
|
165
|
+
@attachment.stub!(:file_path => "/path/to/somewhere")
|
166
|
+
end
|
167
|
+
|
168
|
+
describe "and is scribdable?" do
|
169
|
+
before do
|
170
|
+
@attachment.stub!(:scribdable? => true)
|
171
|
+
end
|
172
|
+
|
173
|
+
describe "and uploading to Scribd succeeded" do
|
174
|
+
before do
|
175
|
+
@scribd_response = mock('scribd_response', :doc_id => "doc_id", :access_key => "access_key")
|
176
|
+
@scribd_user.should_receive(:upload).and_return(@scribd_response)
|
177
|
+
end
|
178
|
+
|
179
|
+
it "should update the Scribd-centric attributes" do
|
180
|
+
@attachment.should_receive(:update_attributes).with({:ipaper_id => 'doc_id', :ipaper_access_key => 'access_key'})
|
181
|
+
@attachment.save
|
182
|
+
end
|
183
|
+
|
184
|
+
end
|
185
|
+
|
186
|
+
describe "and uploading to Scribd failed" do
|
187
|
+
before do
|
188
|
+
@scribd_user.stub!(:upload).and_raise(StandardError)
|
189
|
+
end
|
190
|
+
|
191
|
+
it "should throw an error" do
|
192
|
+
lambda { ScribdFu::upload(@attachment, 'private') }.should raise_error(ScribdFu::ScribdFuUploadError)
|
193
|
+
end
|
194
|
+
|
195
|
+
end
|
196
|
+
|
197
|
+
end
|
198
|
+
|
199
|
+
describe "and is not scribdable?" do
|
200
|
+
before do
|
201
|
+
@attachment.stub!(:scribdable? => false)
|
202
|
+
end
|
203
|
+
|
204
|
+
it "should not upload to Scribd" do
|
205
|
+
ScribdFu.should_not_receive(:upload)
|
206
|
+
@attachment.save
|
207
|
+
end
|
208
|
+
|
209
|
+
end
|
210
|
+
|
211
|
+
end
|
212
|
+
|
213
|
+
describe "that was just updated" do
|
214
|
+
before do
|
215
|
+
@attachment.stub!(:ipaper_id => 'doc_id')
|
216
|
+
end
|
217
|
+
|
218
|
+
it "should not reupload to Scribd" do
|
219
|
+
@scribd_user.should_not_receive(:upload)
|
220
|
+
@attachment.save
|
221
|
+
end
|
222
|
+
|
223
|
+
end
|
224
|
+
|
225
|
+
describe "that is about to be destroyed" do
|
226
|
+
before do
|
227
|
+
@ipaper_document = mock("ipaper_document")
|
228
|
+
ScribdFu.stub!(:load_ipaper_document).and_return(@ipaper_document)
|
229
|
+
end
|
230
|
+
|
231
|
+
it "should destroy the ipaper document" do
|
232
|
+
ScribdFu.should_receive(:destroy).with(@ipaper_document)
|
233
|
+
@attachment.destroy
|
234
|
+
end
|
235
|
+
|
236
|
+
end
|
237
|
+
|
238
|
+
end
|
239
|
+
|
240
|
+
end
|
241
|
+
|
242
|
+
end
|
243
|
+
|
244
|
+
describe "Viewing an iPaper document" do
|
245
|
+
before do
|
246
|
+
rebuild_model
|
247
|
+
|
248
|
+
config = YAML.load_file("spec/scribd_fu.yml")
|
249
|
+
File.stub!(:file?).with(ScribdFu::ConfigPath).and_return(true)
|
250
|
+
YAML.stub!(:load_file).and_return(config)
|
251
|
+
|
252
|
+
Document.class_eval do
|
253
|
+
has_ipaper_and_uses 'AttachmentFu'
|
254
|
+
end
|
255
|
+
|
256
|
+
@document = Document.new
|
257
|
+
@document.attributes = {:ipaper_id => 'doc_id', :ipaper_access_key => 'access_key'}
|
258
|
+
end
|
259
|
+
|
260
|
+
it "should return this HTML by default" do
|
261
|
+
@document.display_ipaper.should == " <script type=\"text/javascript\" src=\"http://www.scribd.com/javascripts/view.js\"></script>\n <div id=\"embedded_flash\"></div>\n <script type=\"text/javascript\">\n var scribd_doc = scribd.Document.getDoc(doc_id, 'access_key');\n \n scribd_doc.write(\"embedded_flash\");\n </script>\n"
|
262
|
+
end
|
263
|
+
|
264
|
+
it "should allow custom Javascript params" do
|
265
|
+
options = {:height => 100, :width => 100}
|
266
|
+
@document.display_ipaper(options).should == " <script type=\"text/javascript\" src=\"http://www.scribd.com/javascripts/view.js\"></script>\n <div id=\"embedded_flash\"></div>\n <script type=\"text/javascript\">\n var scribd_doc = scribd.Document.getDoc(doc_id, 'access_key');\n scribd_doc.addParam('width', '100');\nscribd_doc.addParam('height', '100');\n scribd_doc.write(\"embedded_flash\");\n </script>\n"
|
267
|
+
end
|
268
|
+
|
269
|
+
it "should allow not allow crazy custom Javascript params" do
|
270
|
+
options = {:some_dumb_setting => 100, :width => 100}
|
271
|
+
@document.display_ipaper(options).should == " <script type=\"text/javascript\" src=\"http://www.scribd.com/javascripts/view.js\"></script>\n <div id=\"embedded_flash\"></div>\n <script type=\"text/javascript\">\n var scribd_doc = scribd.Document.getDoc(doc_id, 'access_key');\n scribd_doc.addParam('width', '100');\n scribd_doc.write(\"embedded_flash\");\n </script>\n"
|
272
|
+
end
|
273
|
+
|
274
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'active_record'
|
3
|
+
require 'rscribd'
|
4
|
+
|
5
|
+
ROOT = File.join(File.dirname(__FILE__), '..')
|
6
|
+
RAILS_ROOT = ROOT
|
7
|
+
|
8
|
+
$LOAD_PATH << File.join(ROOT, 'lib')
|
9
|
+
$LOAD_PATH << File.join(ROOT, 'lib', 'scribd_fu')
|
10
|
+
|
11
|
+
require File.join(ROOT, 'lib', 'scribd_fu.rb')
|
12
|
+
|
13
|
+
ENV['RAILS_ENV'] ||= 'test'
|
14
|
+
|
15
|
+
config = YAML::load(IO.read(File.dirname(__FILE__) + '/database.yml'))
|
16
|
+
ActiveRecord::Base.establish_connection(config[ENV['RAILS_ENV'] || 'test'])
|
17
|
+
|
18
|
+
def rebuild_model options = {}
|
19
|
+
ActiveRecord::Base.connection.create_table :documents, :force => true do |table|
|
20
|
+
table.column :ipaper_id, :string
|
21
|
+
table.column :ipaper_access_key, :string
|
22
|
+
table.column :content_type, :string
|
23
|
+
end
|
24
|
+
|
25
|
+
ActiveRecord::Base.connection.create_table :attachments, :force => true do |table|
|
26
|
+
table.column :ipaper_id, :string
|
27
|
+
table.column :ipaper_access_key, :string
|
28
|
+
table.column :attachment_content_type, :string
|
29
|
+
end
|
30
|
+
|
31
|
+
Object.send(:remove_const, "Document") rescue nil
|
32
|
+
Object.const_set("Document", Class.new(ActiveRecord::Base))
|
33
|
+
|
34
|
+
Object.send(:remove_const, "Attachment") rescue nil
|
35
|
+
Object.const_set("Attachment", Class.new(ActiveRecord::Base))
|
36
|
+
end
|
37
|
+
|
38
|
+
Spec::Runner.configure do |config|
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
# EOF
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mdarby-scribd_fu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Darby
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-03-
|
12
|
+
date: 2009-03-30 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -31,20 +31,22 @@ extensions: []
|
|
31
31
|
extra_rdoc_files: []
|
32
32
|
|
33
33
|
files:
|
34
|
-
- init.rb
|
35
|
-
- install.rb
|
36
|
-
- uninstall.rb
|
37
34
|
- MIT-LICENSE
|
38
|
-
-
|
39
|
-
-
|
35
|
+
- README.textile
|
36
|
+
- generators/scribd_fu
|
37
|
+
- generators/scribd_fu/scribd_fu_generator.rb
|
38
|
+
- generators/scribd_fu/templates
|
39
|
+
- generators/scribd_fu/templates/scribd_fu.yml
|
40
|
+
- init.rb
|
41
|
+
- lib/scribd_fu
|
42
|
+
- lib/scribd_fu/attachment_fu.rb
|
43
|
+
- lib/scribd_fu/paperclip.rb
|
40
44
|
- lib/scribd_fu.rb
|
41
|
-
- lib/scribd_fu_helper.rb
|
42
|
-
- lib/attachment_fu/methods.rb
|
43
|
-
- lib/paperclip/methods.rb
|
44
|
-
- rails/init.rb
|
45
45
|
- scribd_fu.gemspec
|
46
|
-
-
|
47
|
-
-
|
46
|
+
- spec/database.yml
|
47
|
+
- spec/scribd_fu.yml
|
48
|
+
- spec/scribd_fu_spec.rb
|
49
|
+
- spec/spec_helper.rb
|
48
50
|
has_rdoc: false
|
49
51
|
homepage: http://github.com/mdarby/scribd_fu/tree/master
|
50
52
|
post_install_message:
|