paperclip_heroku 0.2.1
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/README.md +6 -0
- data/lib/paperclip/heroku.rb +80 -0
- data/lib/paperclip/heroku/version.rb +15 -0
- data/lib/paperclip_heroku.rb +1 -0
- metadata +128 -0
data/README.md
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
require 'paperclip'
|
2
|
+
require 'active_support/core_ext/module/aliasing'
|
3
|
+
|
4
|
+
module Paperclip
|
5
|
+
module Heroku
|
6
|
+
module ClassMethods
|
7
|
+
# Default filesystem path at which to save attachments.
|
8
|
+
DEFAULT_PATH = Paperclip::Attachment.default_options[:path]
|
9
|
+
|
10
|
+
# Default endpoint for S3 requests
|
11
|
+
DEFAULT_S3_HOST_NAME = 's3.amazonaws.com'
|
12
|
+
|
13
|
+
# Adds a :heroku option to Paperclip's +has_attached_file+ method.
|
14
|
+
#
|
15
|
+
# class User
|
16
|
+
# has_attached_file :avatar, heroku: true
|
17
|
+
# end
|
18
|
+
#
|
19
|
+
# Using +heroku: true+ configures Paperclip to use Amazon S3 on Heroku
|
20
|
+
# and the filesystem in development/testing.
|
21
|
+
#
|
22
|
+
# == Configuration
|
23
|
+
#
|
24
|
+
# S3 storage config can be set on the command line using +heroku config:add+, like this:
|
25
|
+
#
|
26
|
+
# $ heroku config:add S3_BUCKET=my_bucket_name
|
27
|
+
# $ heroku config:add S3_KEY=my_s3_access_key_id
|
28
|
+
# $ heroku config:add S3_SECRET=my_s3_secret_access_key
|
29
|
+
#
|
30
|
+
# You can also optionally set a S3_HOST_NAME to specify an endpoint for S3
|
31
|
+
# requests: for example, if your S3 bucket is in the US West (Oregon) region,
|
32
|
+
# you should set S3_HOST_NAME to 's3-us-west-2.amazonaws.com'. If not set,
|
33
|
+
# this will default to s3.amazonaws.com.
|
34
|
+
#
|
35
|
+
# == Note
|
36
|
+
#
|
37
|
+
# Paperclip::Heroku assumes that Heroku is configured to run your
|
38
|
+
# Rails app in the production environment.
|
39
|
+
#
|
40
|
+
def has_attached_file_with_heroku(name, options = {})
|
41
|
+
if options[:heroku] == true
|
42
|
+
# Set per-environment options for Heroku/development
|
43
|
+
#
|
44
|
+
# :storage is a given. Other options are only set
|
45
|
+
# if the user hasn't provided values for them.
|
46
|
+
#
|
47
|
+
options[:storage] = environment_storage
|
48
|
+
options[:path] ||= environment_path
|
49
|
+
options[:url] ||= environment_url
|
50
|
+
options[:bucket] ||= ENV['S3_BUCKET']
|
51
|
+
options[:s3_host_name] ||= ENV['S3_HOST_NAME'] || DEFAULT_S3_HOST_NAME
|
52
|
+
options[:s3_credentials] ||= {
|
53
|
+
:access_key_id => ENV['S3_KEY'],
|
54
|
+
:secret_access_key => ENV['S3_SECRET']
|
55
|
+
}
|
56
|
+
end
|
57
|
+
|
58
|
+
has_attached_file_without_heroku(name, options)
|
59
|
+
end
|
60
|
+
|
61
|
+
private
|
62
|
+
def environment_storage
|
63
|
+
Rails.env.production? ? :s3 : :filesystem
|
64
|
+
end
|
65
|
+
|
66
|
+
def environment_path
|
67
|
+
Rails.env.production? ? DEFAULT_PATH : ['public', DEFAULT_PATH].join
|
68
|
+
end
|
69
|
+
|
70
|
+
def environment_url
|
71
|
+
Rails.env.production? ? ':s3_domain_url' : DEFAULT_PATH
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
module ClassMethods
|
77
|
+
include Paperclip::Heroku::ClassMethods
|
78
|
+
alias_method_chain :has_attached_file, :heroku
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'paperclip/heroku'
|
metadata
ADDED
@@ -0,0 +1,128 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: paperclip_heroku
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- James Wilding
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-05-17 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: paperclip
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 3.4.1
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 3.4.1
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: aws-sdk
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 1.10.0
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 1.10.0
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rake
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rspec
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: autotest
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
description: Easy Paperclip attachments using Heroku and Amazon S3.
|
95
|
+
email: office@jameswilding.net
|
96
|
+
executables: []
|
97
|
+
extensions: []
|
98
|
+
extra_rdoc_files: []
|
99
|
+
files:
|
100
|
+
- lib/paperclip/heroku/version.rb
|
101
|
+
- lib/paperclip/heroku.rb
|
102
|
+
- lib/paperclip_heroku.rb
|
103
|
+
- README.md
|
104
|
+
homepage: http://github.com/jameswilding/paperclip_heroku
|
105
|
+
licenses: []
|
106
|
+
post_install_message:
|
107
|
+
rdoc_options: []
|
108
|
+
require_paths:
|
109
|
+
- lib
|
110
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
111
|
+
none: false
|
112
|
+
requirements:
|
113
|
+
- - ! '>='
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '0'
|
116
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
|
+
none: false
|
118
|
+
requirements:
|
119
|
+
- - ! '>='
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: '0'
|
122
|
+
requirements: []
|
123
|
+
rubyforge_project:
|
124
|
+
rubygems_version: 1.8.25
|
125
|
+
signing_key:
|
126
|
+
specification_version: 3
|
127
|
+
summary: Paperclip + Heroku + Amazon S3
|
128
|
+
test_files: []
|