paperclip_database 1.0.4 → 1.0.5

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/.travis.yml ADDED
@@ -0,0 +1,16 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.2
4
+ - 1.9.3
5
+ gemfile:
6
+ - gemfiles/rails2_legacy.gemfile
7
+ - gemfiles/rails2_paperclip27.gemfile
8
+ - gemfiles/rails30_paperclip25.gemfile
9
+ - gemfiles/rails30_paperclip27.gemfile
10
+ - gemfiles/rails30_paperclip31.gemfile
11
+ - gemfiles/rails31_paperclip25.gemfile
12
+ - gemfiles/rails31_paperclip27.gemfile
13
+ - gemfiles/rails31_paperclip31.gemfile
14
+ - gemfiles/rails32_paperclip25.gemfile
15
+ - gemfiles/rails32_paperclip27.gemfile
16
+ - gemfiles/rails32_paperclip31.gemfile
data/Appraisals CHANGED
@@ -56,6 +56,12 @@ appraise "rails30_paperclip31" do
56
56
  gem "paperclip_database", :path => "../"
57
57
  end
58
58
 
59
+ appraise "rails30_paperclip32" do
60
+ gem "rails", "~> 3.0.0"
61
+ gem "paperclip", "~> 3.2.0"
62
+ gem "paperclip_database", :path => "../"
63
+ end
64
+
59
65
 
60
66
  ## Rails 3.1
61
67
 
@@ -89,6 +95,12 @@ appraise "rails31_paperclip31" do
89
95
  gem "paperclip_database", :path => "../"
90
96
  end
91
97
 
98
+ appraise "rails31_paperclip32" do
99
+ gem "rails", "~> 3.1.0"
100
+ gem "paperclip", "~> 3.2.0"
101
+ gem "paperclip_database", :path => "../"
102
+ end
103
+
92
104
 
93
105
  ## Rails 3.2
94
106
 
@@ -122,4 +134,10 @@ appraise "rails32_paperclip31" do
122
134
  gem "paperclip_database", :path => "../"
123
135
  end
124
136
 
137
+ appraise "rails32_paperclip32" do
138
+ gem "rails", "~> 3.2.0"
139
+ gem "paperclip", "~> 3.2.0"
140
+ gem "paperclip_database", :path => "../"
141
+ end
142
+
125
143
 
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  Paperclip Database Storage
2
2
  ==========================
3
3
 
4
+ [![Build Status](https://secure.travis-ci.org/softace/paperclip_database.png)](http://travis-ci.org/softace/paperclip_database) [![Dependency Status](https://gemnasium.com/softace/paperclip_database.png)](https://gemnasium.com/softace/paperclip_database) [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/softace/paperclip_database)
5
+
4
6
  Paperclip Database Storage is an additional storage option for
5
7
  Paperclip. It give you the opportunity to store your paperclip binary
6
8
  file uploads in the database along with all your other data.
@@ -72,18 +74,21 @@ the extra table.
72
74
 
73
75
  On the console (rails 2):
74
76
 
75
- ./script/generate paperclip_database_migration User avatar
77
+ ./script/generate paperclip_database User avatar
76
78
 
77
79
  On the console (rails 3):
78
80
 
79
- rails generate paperclip_database_migration User avatar
80
-
81
- The generated migration should be sufficient, but yo may consider
82
- adding additional code to it such as `t.timestamps` for adding
83
- standard rails timesstamps or a referential database constraint. If
84
- you add a refferential constraint with the option `ON DELETE CASCADE`,
85
- then you need to add the option `:cascade_deletion => true` to your
86
- paperclip `has_attached_file` declaration.
81
+ bundle exec ./script/rails generate paperclip_database:migration User avatar
82
+
83
+ The generated migration should be sufficient, but you may consider
84
+ adding additional code to the migration such as `t.timestamps` for
85
+ adding standard rails timesstamps or a referential database
86
+ constraint, or an index on the foreign key id column. If you add a
87
+ refferential constraint with the option `ON DELETE CASCADE`, then you
88
+ need to add the option `:cascade_deletion => true` to your paperclip
89
+ `has_attached_file` declaration to let PaperclipDatabase know that the
90
+ Database takes care of it. Otherwise PaperclipDatabase will do the
91
+ cascade deletion.
87
92
 
88
93
  Development
89
94
  -----------
@@ -2,8 +2,8 @@ Feature: Rails integration
2
2
 
3
3
  Background:
4
4
  Given I generate a new rails application
5
- And I run a rails generator to generate a "User" scaffold with "name:string"
6
- And I run a paperclip generator to add a paperclip "attachment" to the "User" model
5
+ And I run a "scaffold" generator to generate a "User" scaffold with "name:string"
6
+ And I run a "paperclip" generator to add a paperclip "attachment" to the "User" model
7
7
  And I run a migration
8
8
  And I update my new user view to include the file upload field
9
9
  And I update my user view to include the attachment
@@ -17,7 +17,7 @@ Feature: Rails integration
17
17
  :url => '/user_attachment_views/:id?style=:style'
18
18
  attr_accessible :name, :attachment
19
19
  """
20
- And I run a rails generator to generate a "UserAttachmentView" scaffold with ""
20
+ And I run a "scaffold" generator to generate a "UserAttachmentView" scaffold with ""
21
21
  Given I add this snippet to the "user_attachment_views" controller:
22
22
  """
23
23
  def show
@@ -28,7 +28,7 @@ Feature: Rails integration
28
28
  :type => record.attachment_content_type
29
29
  end
30
30
  """
31
- And I run a paperclip_database generator to create storage for paperclip "attachment" to the "User" model
31
+ And I run a "paperclip_database:migration" generator to create storage for paperclip "attachment" to the "User" model
32
32
  And I run a migration
33
33
  And I start the rails application
34
34
  When I go to the new user page
@@ -18,16 +18,19 @@ Given /^I generate a new rails application$/ do
18
18
  }
19
19
  end
20
20
 
21
- Given /^I run a rails generator to generate a "([^"]*)" scaffold with "([^"]*)"$/ do |model_name, attributes|
22
- step %[I successfully run `bundle exec #{generator_command} scaffold #{model_name} #{attributes}`]
21
+ Given /^I run a "(.*?)" generator to generate a "(.*?)" scaffold with "(.*?)"$/ do |generator_name, model_name, attributes|
22
+ step %[I successfully run `bundle exec #{generator_command} #{generator_name} #{model_name} #{attributes}`]
23
23
  end
24
24
 
25
- Given /^I run a paperclip generator to add a paperclip "([^"]*)" to the "([^"]*)" model$/ do |attachment_name, model_name|
26
- step %[I successfully run `bundle exec #{generator_command} paperclip #{model_name} #{attachment_name}`]
25
+ Given /^I run a "(.*?)" generator to add a paperclip "(.*?)" to the "(.*?)" model$/ do |generator_name, attachment_name, model_name|
26
+ step %[I successfully run `bundle exec #{generator_command} #{generator_name} #{model_name} #{attachment_name}`]
27
27
  end
28
28
 
29
- Given /^I run a paperclip_database generator to create storage for paperclip "(.*?)" to the "(.*?)" model$/ do |attachment_name, model_name|
30
- step %[I successfully run `bundle exec #{generator_command} paperclip_database #{model_name} #{attachment_name}`]
29
+ Given /^I run a "(.*?)" generator to create storage for paperclip "(.*?)" to the "(.*?)" model$/ do |generator_name, attachment_name, model_name|
30
+ if framework_version?("2")
31
+ generator_name = rails2_generator_name(generator_name)
32
+ end
33
+ step %[I successfully run `bundle exec #{generator_command} #{generator_name} #{model_name} #{attachment_name}`]
31
34
  end
32
35
 
33
36
  Given /^I run a migration$/ do
@@ -42,6 +42,14 @@ module RailsCommandHelpers
42
42
  def runner_command
43
43
  framework_version?("3") ? "script/rails runner" : "script/runner"
44
44
  end
45
+
46
+ def rails2_generator_name(rails3_generator_name)
47
+ case rails3_generator_name
48
+ when "paperclip_database:migration" then "paperclip_database"
49
+ else rails3_generator_name
50
+ end
51
+ end
52
+
45
53
  end
46
54
 
47
55
  module PaperclipGemHelpers
@@ -0,0 +1,9 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "http://rubygems.org"
4
+
5
+ gem "rails", "~> 3.0.0"
6
+ gem "paperclip", "~> 3.2.0"
7
+ gem "paperclip_database", :path=>"../"
8
+
9
+ gemspec :path=>"../"
@@ -0,0 +1,9 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "http://rubygems.org"
4
+
5
+ gem "rails", "~> 3.1.0"
6
+ gem "paperclip", "~> 3.2.0"
7
+ gem "paperclip_database", :path=>"../"
8
+
9
+ gemspec :path=>"../"
@@ -0,0 +1,9 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "http://rubygems.org"
4
+
5
+ gem "rails", "~> 3.2.0"
6
+ gem "paperclip", "~> 3.2.0"
7
+ gem "paperclip_database", :path=>"../"
8
+
9
+ gemspec :path=>"../"
@@ -2,7 +2,7 @@ Description:
2
2
  The generator generates a database migration for the paperclip database storage
3
3
 
4
4
  Example:
5
- rails generate paperclip_database Class attachments
5
+ rails generate paperclip_database_migration User attachment
6
6
 
7
7
  This will create:
8
- what/will/it/create
8
+ db/migrations/YYYYMMDDHHmmss_create_user_attachments.rb
@@ -0,0 +1,40 @@
1
+ require 'rails/generators/active_record'
2
+
3
+ module PaperclipDatabase
4
+ module Generators
5
+ class MigrationGenerator < ActiveRecord::Generators::Base
6
+ desc "Create a migration to add database storage for the paperclip database storage." +
7
+ "The NAME argument is the name of your model, and the following " +
8
+ "arguments are the name of the attachments"
9
+
10
+ argument :attachment_names,
11
+ :required => true,
12
+ :type => :array,
13
+ :desc => "The names of the attachment(s) to add.",
14
+ :banner => "attachment_one attachment_two attachment_three ..."
15
+
16
+ def self.source_root
17
+ @source_root ||= File.expand_path('../templates', __FILE__)
18
+ end
19
+
20
+ def generate_migration
21
+ migration_template "migration.rb.erb", "db/migrate/#{migration_file_name}"
22
+ end
23
+
24
+ protected
25
+
26
+ def migration_name
27
+ "create_#{name.underscore}_#{attachment_names.map{|n| n.pluralize}.join('_and_')}"
28
+ end
29
+
30
+ def migration_file_name
31
+ "#{migration_name}.rb"
32
+ end
33
+
34
+ def migration_class_name
35
+ migration_name.camelize
36
+ end
37
+
38
+ end
39
+ end
40
+ end
@@ -1,3 +1,3 @@
1
1
  module PaperclipDatabase
2
- VERSION = "1.0.4" unless defined? PaperclipDatabase::VERSION
2
+ VERSION = "1.0.5" unless defined? PaperclipDatabase::VERSION
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paperclip_database
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-05 00:00:00.000000000 Z
12
+ date: 2012-09-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: paperclip
@@ -198,6 +198,7 @@ files:
198
198
  - .gitignore
199
199
  - .rspec
200
200
  - .rvmrc
201
+ - .travis.yml
201
202
  - Appraisals
202
203
  - Gemfile
203
204
  - LICENSE.txt
@@ -222,23 +223,26 @@ files:
222
223
  - gemfiles/rails30_paperclip27.gemfile
223
224
  - gemfiles/rails30_paperclip30.gemfile
224
225
  - gemfiles/rails30_paperclip31.gemfile
226
+ - gemfiles/rails30_paperclip32.gemfile
225
227
  - gemfiles/rails31_paperclip25.gemfile
226
228
  - gemfiles/rails31_paperclip26.gemfile
227
229
  - gemfiles/rails31_paperclip27.gemfile
228
230
  - gemfiles/rails31_paperclip30.gemfile
229
231
  - gemfiles/rails31_paperclip31.gemfile
232
+ - gemfiles/rails31_paperclip32.gemfile
230
233
  - gemfiles/rails32_paperclip25.gemfile
231
234
  - gemfiles/rails32_paperclip26.gemfile
232
235
  - gemfiles/rails32_paperclip27.gemfile
233
236
  - gemfiles/rails32_paperclip30.gemfile
234
237
  - gemfiles/rails32_paperclip31.gemfile
238
+ - gemfiles/rails32_paperclip32.gemfile
235
239
  - generators/paperclip_database/USAGE
236
240
  - generators/paperclip_database/paperclip_database_generator.rb
237
241
  - generators/paperclip_database/templates/paperclip_database_migration.rb.erb
238
242
  - generators/templates/paperclip_database_migration.rb.erb
239
- - lib/generators/paperclip_database/USAGE
240
- - lib/generators/paperclip_database/paperclip_database_generator.rb
241
- - lib/generators/paperclip_database/templates/paperclip_database_migration.rb.erb
243
+ - lib/generators/paperclip_database/migration/USAGE
244
+ - lib/generators/paperclip_database/migration/migration_generator.rb
245
+ - lib/generators/paperclip_database/migration/templates/migration.rb.erb
242
246
  - lib/paperclip/storage/database.rb
243
247
  - lib/paperclip_database.rb
244
248
  - lib/paperclip_database/version.rb
@@ -261,7 +265,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
261
265
  version: '0'
262
266
  segments:
263
267
  - 0
264
- hash: 726529476168973417
268
+ hash: -4219737218162575604
265
269
  required_rubygems_version: !ruby/object:Gem::Requirement
266
270
  none: false
267
271
  requirements:
@@ -270,7 +274,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
270
274
  version: '0'
271
275
  segments:
272
276
  - 0
273
- hash: 726529476168973417
277
+ hash: -4219737218162575604
274
278
  requirements:
275
279
  - ImageMagick
276
280
  rubyforge_project: paperclip_database
@@ -1,33 +0,0 @@
1
- require 'rails/generators/active_record'
2
-
3
- class PaperclipDatabaseGenerator < ActiveRecord::Generators::Base
4
- desc "Create a migration to add database storage for the paperclip database storage." +
5
- "The NAME argument is the name of your model, and the following " +
6
- "arguments are the name of the attachments"
7
-
8
- argument :attachment_names, :required => true, :type => :array, :desc => "The names of the attachment(s) to add.",
9
- :banner => "attachment_one attachment_two attachment_three ..."
10
-
11
- def self.source_root
12
- @source_root ||= File.expand_path('../templates', __FILE__)
13
- end
14
-
15
- def generate_migration
16
- migration_template "paperclip_database_migration.rb.erb", "db/migrate/#{migration_file_name}"
17
- end
18
-
19
- protected
20
-
21
- def migration_name
22
- "create_#{name.underscore}_#{attachment_names.map{|n| n.pluralize}.join('_and_')}"
23
- end
24
-
25
- def migration_file_name
26
- "#{migration_name}.rb"
27
- end
28
-
29
- def migration_class_name
30
- migration_name.camelize
31
- end
32
-
33
- end