asset_sync 0.1.10 → 0.2.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/README.md +89 -43
- data/asset_sync.gemspec +3 -3
- data/lib/asset_sync/config.rb +64 -25
- data/lib/asset_sync/engine.rb +9 -3
- data/lib/asset_sync/storage.rb +2 -2
- data/lib/asset_sync/version.rb +1 -1
- data/lib/generators/asset_sync/install_generator.rb +22 -8
- data/lib/generators/asset_sync/templates/asset_sync.rb +19 -6
- data/lib/generators/asset_sync/templates/asset_sync.yml +14 -14
- data/spec/asset_sync_spec.rb +21 -15
- data/spec/{with_yml → aws_with_yml}/config/asset_sync.yml +6 -6
- data/spec/rackspace_spec.rb +83 -0
- data/spec/rackspace_with_yml/config/asset_sync.yml +20 -0
- metadata +22 -18
- data/lib/generators/asset_sync/templates/asset_sync.rake +0 -3
data/README.md
CHANGED
@@ -7,6 +7,10 @@ bucket, optionally deleting unused files and only uploading the files it needs t
|
|
7
7
|
|
8
8
|
This was initially built and is intended to work on [Heroku](http://heroku.com)
|
9
9
|
|
10
|
+
## Upgrading?
|
11
|
+
|
12
|
+
If you are upgrading from a version of asset_sync **< 0.2.0** (i.e. 0.1.x). All of the references to config variables have changed to reference those used in **Fog**. Ensure to backup your `asset\_sync.rb` or `asset\_sync.yml` files and re-run the generator. You may also then need to update your ENV configuration variables (or you can change the ones that are referenced).
|
13
|
+
|
10
14
|
## KNOWN ISSUES (IMPORTANT)
|
11
15
|
|
12
16
|
We are currently trying to talk with Heroku to iron these out.
|
@@ -26,7 +30,7 @@ This means the *RAILS_ENV* you have set via *heroku:config* is not used.
|
|
26
30
|
|
27
31
|
AssetSync.configure do |config|
|
28
32
|
...
|
29
|
-
config.
|
33
|
+
config.fog_directory = 'app-assets'
|
30
34
|
config.existing_remote_files = "keep"
|
31
35
|
end
|
32
36
|
|
@@ -37,9 +41,9 @@ Currently when heroku runs `rake assets:precompile` during deployment. It does n
|
|
37
41
|
**Workaround:** you could just hardcode your AWS credentials in the initializer or yml
|
38
42
|
|
39
43
|
AssetSync.configure do |config|
|
40
|
-
config.
|
41
|
-
config.
|
42
|
-
config.
|
44
|
+
config.aws_access_key_id_id = 'xxx'
|
45
|
+
config.aws_secret_access_key = 'xxx'
|
46
|
+
config.fog_directory = 'mybucket'
|
43
47
|
end
|
44
48
|
|
45
49
|
## Installation
|
@@ -50,7 +54,7 @@ Add the gem to your Gemfile
|
|
50
54
|
|
51
55
|
> The following steps are now optional as of version **0.1.7** there is a built-in initializer [lib/engine.rb](https://github.com/rumblelabs/asset_sync/blob/master/lib/asset_sync/engine.rb)
|
52
56
|
|
53
|
-
Generate the rake task and config
|
57
|
+
Generate the rake task and config file
|
54
58
|
|
55
59
|
rails g asset_sync:install
|
56
60
|
|
@@ -58,6 +62,11 @@ If you would like to use a YAML file for configuration instead of the default (R
|
|
58
62
|
|
59
63
|
rails g asset_sync:install --use-yml
|
60
64
|
|
65
|
+
The default *provider* is `AWS` but you can pick which one you need.
|
66
|
+
|
67
|
+
rails g asset_sync:install --provider=Rackspace
|
68
|
+
rails g asset_sync:install --provider=AWS
|
69
|
+
|
61
70
|
## Configuration
|
62
71
|
|
63
72
|
Configure __config/environments/production.rb__ to use Amazon
|
@@ -65,7 +74,7 @@ S3 as the asset host and ensure precompiling is enabled.
|
|
65
74
|
|
66
75
|
# config/environments/production.rb
|
67
76
|
config.action_controller.asset_host = Proc.new do |source, request|
|
68
|
-
request.ssl? ? "https://#{ENV['
|
77
|
+
request.ssl? ? "https://#{ENV['FOG_DIRECTORY']}.s3.amazonaws.com" : "http://#{ENV['FOG_DIRECTORY']}.s3.amazonaws.com"
|
69
78
|
end
|
70
79
|
|
71
80
|
We support two methods of configuration.
|
@@ -84,15 +93,22 @@ The recommend way to configure **asset_sync** is by using environment variables
|
|
84
93
|
The generator will create a Rails initializer at `config/initializers/asset_sync.rb`.
|
85
94
|
|
86
95
|
AssetSync.configure do |config|
|
87
|
-
config.
|
88
|
-
config.
|
89
|
-
config.
|
90
|
-
config.
|
96
|
+
config.fog_provider = 'AWS'
|
97
|
+
config.fog_directory = ENV['FOG_DIRECTORY']
|
98
|
+
config.aws_access_key_id = ENV['AWS_ACCESS_KEY_ID']
|
99
|
+
config.aws_secret_access_key = ENV['AWS_SECRET_ACCESS_KEY']
|
100
|
+
|
101
|
+
# Don't delete files from the store
|
102
|
+
# config.existing_remote_files = "keep"
|
103
|
+
#
|
91
104
|
# Increase upload performance by configuring your region
|
92
|
-
# config.
|
105
|
+
# config.fog_region = 'eu-west-1'
|
106
|
+
#
|
93
107
|
# Automatically replace files with their equivalent gzip compressed version
|
94
108
|
# config.gzip_compression = true
|
95
|
-
#
|
109
|
+
#
|
110
|
+
# Use the Rails generated 'manifest.yml' file to produce the list of files to
|
111
|
+
# upload instead of searching the assets directory.
|
96
112
|
# config.manifest = true
|
97
113
|
end
|
98
114
|
|
@@ -102,62 +118,85 @@ The generator will create a Rails initializer at `config/initializers/asset_sync
|
|
102
118
|
If you used the `--use-yml` flag, the generator will create a YAML file at `config/asset_sync.yml`.
|
103
119
|
|
104
120
|
defaults: &defaults
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
121
|
+
fog_provider: "AWS"
|
122
|
+
fog_directory: "rails-app-assets"
|
123
|
+
aws_access_key_id: "<%= ENV['AWS_ACCESS_KEY_ID'] %>"
|
124
|
+
aws_secret_access_key: "<%= ENV['AWS_SECRET_ACCESS_KEY'] %>"
|
125
|
+
# You may need to specify what region your storage bucket is in
|
126
|
+
# fog_region: "eu-west-1"
|
127
|
+
existing_remote_files: keep # Existing pre-compiled assets on S3 will be kept
|
128
|
+
# To delete existing remote files.
|
129
|
+
# existing_remote_files: delete
|
110
130
|
# Automatically replace files with their equivalent gzip compressed version
|
111
|
-
# gzip_compression
|
112
|
-
|
131
|
+
# gzip_compression: true
|
113
132
|
|
114
133
|
development:
|
115
134
|
<<: *defaults
|
116
|
-
aws_bucket: "rails-app-development"
|
117
|
-
existing_remote_files: keep # Existing pre-compiled assets on S3 will be kept
|
118
135
|
|
119
136
|
test:
|
120
137
|
<<: *defaults
|
121
|
-
aws_bucket: "rails-app-test"
|
122
|
-
|
123
|
-
staging:
|
124
|
-
<<: *defaults
|
125
|
-
aws_bucket: "rails-app-staging"
|
126
138
|
|
127
139
|
production:
|
128
140
|
<<: *defaults
|
129
|
-
aws_bucket: "rails-app-production"
|
130
|
-
# Existing pre-compiled assets on S3 will be deleted
|
131
|
-
# existing_remote_files: delete
|
132
141
|
|
133
142
|
### Environment Variables
|
134
143
|
|
135
144
|
Add your Amazon S3 configuration details to **heroku**
|
136
145
|
|
137
|
-
heroku config:add
|
138
|
-
heroku config:add
|
139
|
-
heroku config:add
|
146
|
+
heroku config:add AWS_ACCESS_KEY_ID=xxxx
|
147
|
+
heroku config:add AWS_SECRET_ACCESS_KEY=xxxx
|
148
|
+
heroku config:add FOG_DIRECTORY=xxxx
|
140
149
|
|
141
150
|
Or add to a traditional unix system
|
142
151
|
|
143
|
-
export
|
144
|
-
export
|
145
|
-
export
|
152
|
+
export AWS_ACCESS_KEY_ID=xxxx
|
153
|
+
export AWS_SECRET_ACCESS_KEY=xxxx
|
154
|
+
export FOG_DIRECTORY=xxxx
|
146
155
|
|
147
156
|
### Available Configuration Options
|
148
157
|
|
149
|
-
|
150
|
-
|
151
|
-
* **
|
152
|
-
* **existing\_remote\_files**: what to do with previously precompiled files, options are **keep** or **delete**
|
158
|
+
#### AssetSync
|
159
|
+
|
160
|
+
* **existing_remote_files**: what to do with previously precompiled files, options are **keep** or **delete**
|
153
161
|
* **gzip\_compression**: when enabled, will automatically replace files that have a gzip compressed equivalent with the compressed version.
|
154
162
|
* **manifest**: when enabled, will use the `manifest.yml` generated by Rails to get the list of local files to upload. **experimental**
|
155
163
|
|
156
|
-
|
164
|
+
#### Required (Fog)
|
165
|
+
* **fog\_provider**: your storage provider *AWS* (S3) or *Rackspace* (Cloud Files)
|
166
|
+
* **fog\_directory**: your bucket name
|
157
167
|
|
158
|
-
|
168
|
+
#### Optional
|
159
169
|
|
160
|
-
|
170
|
+
* **fog\_region**: the region your storage bucket is in e.g. *eu-west-1*
|
171
|
+
|
172
|
+
#### AWS
|
173
|
+
|
174
|
+
* **aws\_access\_key\_id**: your Amazon S3 access key
|
175
|
+
* **aws\_secret\_access\_key**: your Amazon S3 access secret
|
176
|
+
|
177
|
+
#### Rackspace
|
178
|
+
|
179
|
+
* **rackspace\_username**: your Rackspace username
|
180
|
+
* **rackspace\_api\_key**: your Rackspace API Key.
|
181
|
+
|
182
|
+
|
183
|
+
#### Required (Fog)
|
184
|
+
* **fog\_provider**: your storage provider *AWS* (S3) or *Rackspace* (Cloud Files)
|
185
|
+
* **fog\_directory**: your bucket name
|
186
|
+
|
187
|
+
#### Optional
|
188
|
+
|
189
|
+
* **fog\_region**: the region your storage bucket is in e.g. *eu-west-1*
|
190
|
+
|
191
|
+
#### AWS
|
192
|
+
|
193
|
+
* **aws\_access\_key\_id**: your Amazon S3 access key
|
194
|
+
* **aws\_secret\_access\_key**: your Amazon S3 access secret
|
195
|
+
|
196
|
+
#### Rackspace
|
197
|
+
|
198
|
+
* **rackspace\_username**: your Rackspace username
|
199
|
+
* **rackspace\_api\_key**: your Rackspace API Key.
|
161
200
|
|
162
201
|
|
163
202
|
## Amazon S3 Multiple Region Support
|
@@ -172,9 +211,16 @@ Or via the initializer
|
|
172
211
|
|
173
212
|
AssetSync.configure do |config|
|
174
213
|
# ...
|
175
|
-
config.
|
214
|
+
config.fog_region = 'eu-west-1'
|
176
215
|
end
|
177
216
|
|
217
|
+
## Automatic gzip compression
|
218
|
+
|
219
|
+
With the `gzip_compression` option enabled, when uploading your assets. If a file has a gzip compressed equivalent we will replace that asset with the compressed version and sets the correct headers for S3 to serve it. For example, if you have a file **master.css** and it was compressed to **master.css.gz** we will upload the **.gz** file to S3 in place of the uncompressed file.
|
220
|
+
|
221
|
+
If the compressed file is actually larger than the uncompressed file we will ignore this rule and upload the standard uncompressed version.
|
222
|
+
|
223
|
+
|
178
224
|
## Rake Task
|
179
225
|
|
180
226
|
A rake task is included in asset\_sync to enhance the rails precompile task by automatically running after it:
|
data/asset_sync.gemspec
CHANGED
@@ -6,13 +6,13 @@ require "asset_sync/version"
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "asset_sync"
|
8
8
|
s.version = AssetSync::VERSION
|
9
|
-
s.date = "2011-11-
|
9
|
+
s.date = "2011-11-15"
|
10
10
|
s.platform = Gem::Platform::RUBY
|
11
11
|
s.authors = ["Simon Hamilton", "David Rice"]
|
12
12
|
s.email = ["shamilton@rumblelabs.com", "me@davidjrice.co.uk"]
|
13
13
|
s.homepage = "https://github.com/rumblelabs/asset_sync"
|
14
|
-
s.summary = %q{Synchronises Assets in a Rails 3 application and S3/Cloudfront}
|
15
|
-
s.description = %q{After you run assets:precompile your assets will be synchronised with your S3 bucket
|
14
|
+
s.summary = %q{Synchronises Assets in a Rails 3 application and Amazon S3/Cloudfront and Rackspace Cloudfiles}
|
15
|
+
s.description = %q{After you run assets:precompile your compiled assets will be synchronised with your S3 bucket.}
|
16
16
|
|
17
17
|
s.rubyforge_project = "asset_sync"
|
18
18
|
|
data/lib/asset_sync/config.rb
CHANGED
@@ -4,22 +4,34 @@ module AssetSync
|
|
4
4
|
|
5
5
|
class Invalid < StandardError; end
|
6
6
|
|
7
|
-
|
8
|
-
attr_accessor :
|
9
|
-
attr_accessor :aws_bucket
|
10
|
-
attr_accessor :aws_region
|
11
|
-
attr_accessor :existing_remote_files
|
7
|
+
# AssetSync
|
8
|
+
attr_accessor :existing_remote_files # What to do with your existing remote files? (keep or delete)
|
12
9
|
attr_accessor :gzip_compression
|
13
10
|
attr_accessor :manifest
|
14
11
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
12
|
+
# FOG configuration
|
13
|
+
attr_accessor :fog_provider # Currently Supported ['AWS', 'Rackspace']
|
14
|
+
attr_accessor :fog_directory # e.g. 'the-bucket-name'
|
15
|
+
attr_accessor :fog_region # e.g. 'eu-west-1'
|
16
|
+
|
17
|
+
# Amazon AWS
|
18
|
+
attr_accessor :aws_access_key_id, :aws_secret_access_key
|
19
|
+
|
20
|
+
# Rackspace
|
21
|
+
attr_accessor :rackspace_username, :rackspace_api_key
|
22
|
+
|
23
|
+
validates :existing_remote_files, :inclusion => { :in => %w(keep delete) }
|
24
|
+
|
25
|
+
validates :fog_provider, :presence => true
|
26
|
+
validates :fog_directory, :presence => true
|
27
|
+
|
28
|
+
validates :aws_access_key_id, :presence => true, :if => :aws?
|
29
|
+
validates :aws_secret_access_key, :presence => true, :if => :aws?
|
30
|
+
validates :rackspace_username, :presence => true, :if => :rackspace?
|
31
|
+
validates :rackspace_api_key, :presence => true, :if => :rackspace?
|
19
32
|
|
20
33
|
def initialize
|
21
|
-
self.
|
22
|
-
self.aws_region = nil
|
34
|
+
self.fog_region = nil
|
23
35
|
self.existing_remote_files = 'keep'
|
24
36
|
self.gzip_compression = false
|
25
37
|
self.manifest = false
|
@@ -39,6 +51,13 @@ module AssetSync
|
|
39
51
|
(self.existing_remote_files == "keep")
|
40
52
|
end
|
41
53
|
|
54
|
+
def aws?
|
55
|
+
fog_provider == 'AWS'
|
56
|
+
end
|
57
|
+
|
58
|
+
def rackspace?
|
59
|
+
fog_provider == 'Rackspace'
|
60
|
+
end
|
42
61
|
|
43
62
|
def yml_exists?
|
44
63
|
File.exists?(self.yml_path)
|
@@ -53,28 +72,48 @@ module AssetSync
|
|
53
72
|
end
|
54
73
|
|
55
74
|
def load_yml!
|
56
|
-
self.
|
57
|
-
self.
|
58
|
-
self.
|
59
|
-
self.
|
75
|
+
self.fog_provider = yml["fog_provider"]
|
76
|
+
self.fog_directory = yml["fog_directory"]
|
77
|
+
self.fog_region = yml["fog_region"]
|
78
|
+
self.aws_access_key_id = yml["aws_access_key_id"]
|
79
|
+
self.aws_secret_access_key = yml["aws_secret_access_key"]
|
80
|
+
self.rackspace_username = yml["rackspace_username"]
|
81
|
+
self.rackspace_api_key = yml["rackspace_api_key"]
|
60
82
|
self.existing_remote_files = yml["existing_remote_files"] if yml.has_key?("existing_remote_files")
|
61
83
|
self.gzip_compression = yml["gzip_compression"] if yml.has_key?("gzip_compression")
|
62
84
|
self.manifest = yml["manifest"] if yml.has_key?("manifest")
|
63
85
|
|
86
|
+
# TODO deprecate the other old style config settings. FML.
|
87
|
+
self.aws_access_key_id = yml["aws_access_key"] if yml.has_key?("aws_access_key")
|
88
|
+
self.aws_secret_access_key = yml["aws_access_secret"] if yml.has_key?("aws_access_secret")
|
89
|
+
self.fog_directory = yml["aws_bucket"] if yml.has_key?("aws_bucket")
|
90
|
+
self.fog_region = yml["aws_region"] if yml.has_key?("aws_region")
|
91
|
+
|
64
92
|
# TODO deprecate old style config settings
|
65
|
-
self.
|
66
|
-
self.
|
67
|
-
self.
|
68
|
-
self.
|
93
|
+
self.aws_access_key_id = yml["access_key_id"] if yml.has_key?("access_key_id")
|
94
|
+
self.aws_secret_access_key = yml["secret_access_key"] if yml.has_key?("secret_access_key")
|
95
|
+
self.fog_directory = yml["bucket"] if yml.has_key?("bucket")
|
96
|
+
self.fog_region = yml["region"] if yml.has_key?("region")
|
69
97
|
end
|
70
98
|
|
99
|
+
|
71
100
|
def fog_options
|
72
|
-
options = {
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
101
|
+
options = { :provider => fog_provider }
|
102
|
+
if aws?
|
103
|
+
options.merge!({
|
104
|
+
:aws_access_key_id => aws_access_key_id,
|
105
|
+
:aws_secret_access_key => aws_secret_access_key
|
106
|
+
})
|
107
|
+
elsif rackspace?
|
108
|
+
options.merge!({
|
109
|
+
:rackspace_username => rackspace_username,
|
110
|
+
:rackspace_api_key => rackspace_api_key
|
111
|
+
})
|
112
|
+
else
|
113
|
+
raise ArgumentError, "AssetSync Unknown provider: #{fog_provider} only AWS and Rackspace are supported currently."
|
114
|
+
end
|
115
|
+
|
116
|
+
options.merge!({:region => fog_region}) if fog_region
|
78
117
|
return options
|
79
118
|
end
|
80
119
|
|
data/lib/asset_sync/engine.rb
CHANGED
@@ -12,9 +12,15 @@ class Engine < Rails::Engine
|
|
12
12
|
else
|
13
13
|
# STDERR.puts "AssetSync: using default configuration from built-in initializer"
|
14
14
|
AssetSync.configure do |config|
|
15
|
-
config.
|
16
|
-
config.
|
17
|
-
config.
|
15
|
+
config.fog_provider = ENV['FOG_PROVIDER']
|
16
|
+
config.fog_directory = ENV['FOG_DIRECTORY']
|
17
|
+
config.fog_directory = ENV['FOG_REGION']
|
18
|
+
|
19
|
+
config.aws_access_key_id = ENV['AWS_ACCESS_KEY_ID']
|
20
|
+
config.aws_secret_access_key = ENV['AWS_SECRET_ACCESS_KEY']
|
21
|
+
|
22
|
+
config.rackspace_username = ENV['RACKSPACE_USERNAME']
|
23
|
+
config.rackspace_api_key = ENV['RACKSPACE_API_KEY']
|
18
24
|
config.existing_remote_files = "keep"
|
19
25
|
end
|
20
26
|
end
|
data/lib/asset_sync/storage.rb
CHANGED
@@ -15,7 +15,7 @@ module AssetSync
|
|
15
15
|
|
16
16
|
def bucket
|
17
17
|
# fixes: https://github.com/rumblelabs/asset_sync/issues/18
|
18
|
-
@bucket ||= connection.directories.get(self.config.
|
18
|
+
@bucket ||= connection.directories.get(self.config.fog_directory, :prefix => 'assets')
|
19
19
|
end
|
20
20
|
|
21
21
|
def keep_existing_remote_files?
|
@@ -45,7 +45,7 @@ module AssetSync
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def get_remote_files
|
48
|
-
raise BucketNotFound.new("
|
48
|
+
raise BucketNotFound.new("#{self.config.fog_provider} Bucket: #{self.config.fog_directory} not found.") unless bucket
|
49
49
|
# fixes: https://github.com/rumblelabs/asset_sync/issues/16
|
50
50
|
# (work-around for https://github.com/fog/fog/issues/596)
|
51
51
|
files = []
|
data/lib/asset_sync/version.rb
CHANGED
@@ -4,18 +4,35 @@ module AssetSync
|
|
4
4
|
desc "Install a config/asset_sync.yml and the asset:precompile rake task enhancer"
|
5
5
|
|
6
6
|
# Commandline options can be defined here using Thor-like options:
|
7
|
-
class_option :use_yml,
|
7
|
+
class_option :use_yml, :type => :boolean, :default => false, :desc => "Use YML file instead of Rails Initializer"
|
8
|
+
class_option :provider, :type => :string, :default => "AWS", :desc => "Generate with support for 'AWS' or 'Rackspace'"
|
8
9
|
|
9
10
|
def self.source_root
|
10
11
|
@source_root ||= File.join(File.dirname(__FILE__), 'templates')
|
11
12
|
end
|
12
13
|
|
13
|
-
def
|
14
|
-
|
14
|
+
def aws?
|
15
|
+
options[:provider] == 'AWS'
|
15
16
|
end
|
16
17
|
|
17
|
-
def
|
18
|
-
|
18
|
+
def rackspace?
|
19
|
+
options[:provider] == 'Rackspace'
|
20
|
+
end
|
21
|
+
|
22
|
+
def aws_access_key_id
|
23
|
+
"<%= ENV['AWS_ACCESS_KEY_ID'] %>"
|
24
|
+
end
|
25
|
+
|
26
|
+
def aws_secret_access_key
|
27
|
+
"<%= ENV['AWS_SECRET_ACCESS_KEY'] %>"
|
28
|
+
end
|
29
|
+
|
30
|
+
def rackspace_username
|
31
|
+
"<%= ENV['RACKSPACE_USERNAME'] %>"
|
32
|
+
end
|
33
|
+
|
34
|
+
def rackspace_api_key
|
35
|
+
"<%= ENV['RACKSPACE_API_KEY'] %>"
|
19
36
|
end
|
20
37
|
|
21
38
|
def app_name
|
@@ -34,8 +51,5 @@ module AssetSync
|
|
34
51
|
end
|
35
52
|
end
|
36
53
|
|
37
|
-
# def generate_rake_task
|
38
|
-
# template "asset_sync.rake", "lib/tasks/asset_sync.rake"
|
39
|
-
# end
|
40
54
|
end
|
41
55
|
end
|
@@ -1,12 +1,25 @@
|
|
1
1
|
AssetSync.configure do |config|
|
2
|
-
|
3
|
-
config.
|
4
|
-
config.
|
5
|
-
config.
|
2
|
+
<%- if aws? -%>
|
3
|
+
config.fog_provider = 'AWS'
|
4
|
+
config.aws_access_key_id = ENV['AWS_ACCESS_KEY_ID']
|
5
|
+
config.aws_secret_access_key = ENV['AWS_SECRET_ACCESS_KEY']
|
6
|
+
<%- elsif rackspace? -%>
|
7
|
+
config.fog_provider = 'Rackspace'
|
8
|
+
config.rackspace_username = ENV['RACKSPACE_USERNAME']
|
9
|
+
config.rackspace_api_key = ENV['RACKSPACE_API_KEY']
|
10
|
+
<%- end -%>
|
11
|
+
config.fog_directory = ENV['FOG_DIRECTORY']
|
12
|
+
|
6
13
|
# Increase upload performance by configuring your region
|
7
|
-
# config.
|
14
|
+
# config.fog_region = 'eu-west-1'
|
15
|
+
#
|
16
|
+
# Don't delete files from the store
|
17
|
+
# config.existing_remote_files = "keep"
|
18
|
+
#
|
8
19
|
# Automatically replace files with their equivalent gzip compressed version
|
9
20
|
# config.gzip_compression = true
|
10
|
-
#
|
21
|
+
#
|
22
|
+
# Use the Rails generated 'manifest.yml' file to produce the list of files to
|
23
|
+
# upload instead of searching the assets directory.
|
11
24
|
# config.manifest = true
|
12
25
|
end
|
@@ -1,30 +1,30 @@
|
|
1
1
|
defaults: &defaults
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
2
|
+
<%- if aws? -%>
|
3
|
+
fog_provider: 'AWS'
|
4
|
+
aws_access_key_id: "<%= aws_access_key_id %>"
|
5
|
+
aws_secret_access_key: "<%= aws_secret_access_key %>"
|
6
|
+
<%- elsif rackspace? -%>
|
7
|
+
fog_provider: 'Rackspace'
|
8
|
+
rackspace_username: "<%= rackspace_username %>"
|
9
|
+
rackspace_api_key: "<%= rackspace_api_key %>"
|
10
|
+
<%- end -%>
|
11
|
+
fog_directory: "<%= app_name %>-assets"
|
12
|
+
# You may need to specify what region your storage bucket is in
|
13
|
+
# fog_region: "eu-west-1"
|
6
14
|
existing_remote_files: keep
|
15
|
+
# To delete existing remote files.
|
16
|
+
# existing_remote_files: delete
|
7
17
|
# Automatically replace files with their equivalent gzip compressed version
|
8
18
|
# gzip_compression = true
|
9
19
|
|
10
|
-
|
11
20
|
development:
|
12
21
|
<<: *defaults
|
13
|
-
aws_bucket: "<%= app_name %>_development"
|
14
|
-
# Existing pre-compiled assets on S3 will be kept
|
15
|
-
# existing_remote_files: keep
|
16
22
|
|
17
23
|
test:
|
18
24
|
<<: *defaults
|
19
|
-
aws_bucket: "<%= app_name %>_test"
|
20
25
|
|
21
26
|
staging:
|
22
27
|
<<: *defaults
|
23
|
-
aws_bucket: "<%= app_name %>_test"
|
24
28
|
|
25
29
|
production:
|
26
30
|
<<: *defaults
|
27
|
-
aws_bucket: "<%= app_name %>_production"
|
28
|
-
# Existing pre-compiled assets on S3 will be deleted
|
29
|
-
# existing_remote_files: delete
|
30
|
-
|
data/spec/asset_sync_spec.rb
CHANGED
@@ -7,32 +7,38 @@ describe AssetSync, 'with initializer' do
|
|
7
7
|
Rails.root = 'without_yml'
|
8
8
|
AssetSync.config = AssetSync::Config.new
|
9
9
|
AssetSync.configure do |config|
|
10
|
-
config.
|
11
|
-
config.
|
12
|
-
config.
|
13
|
-
config.
|
10
|
+
config.fog_provider = 'AWS'
|
11
|
+
config.aws_access_key_id = 'aaaa'
|
12
|
+
config.aws_secret_access_key = 'bbbb'
|
13
|
+
config.fog_directory = 'mybucket'
|
14
|
+
config.fog_region = 'eu-west-1'
|
14
15
|
config.existing_remote_files = "keep"
|
15
16
|
end
|
16
17
|
end
|
17
18
|
|
19
|
+
it "should configure provider as AWS" do
|
20
|
+
AssetSync.config.fog_provider.should == 'AWS'
|
21
|
+
AssetSync.config.should be_aws
|
22
|
+
end
|
23
|
+
|
18
24
|
it "should should keep existing remote files" do
|
19
25
|
AssetSync.config.existing_remote_files?.should == true
|
20
26
|
end
|
21
27
|
|
22
28
|
it "should configure aws_access_key" do
|
23
|
-
AssetSync.config.
|
29
|
+
AssetSync.config.aws_access_key_id.should == "aaaa"
|
24
30
|
end
|
25
31
|
|
26
32
|
it "should configure aws_access_key" do
|
27
|
-
AssetSync.config.
|
33
|
+
AssetSync.config.aws_secret_access_key.should == "bbbb"
|
28
34
|
end
|
29
35
|
|
30
36
|
it "should configure aws_access_key" do
|
31
|
-
AssetSync.config.
|
37
|
+
AssetSync.config.fog_directory.should == "mybucket"
|
32
38
|
end
|
33
39
|
|
34
40
|
it "should configure aws_access_key" do
|
35
|
-
AssetSync.config.
|
41
|
+
AssetSync.config.fog_region.should == "eu-west-1"
|
36
42
|
end
|
37
43
|
|
38
44
|
it "should configure aws_access_key" do
|
@@ -53,24 +59,24 @@ end
|
|
53
59
|
describe AssetSync, 'from yml' do
|
54
60
|
|
55
61
|
before(:all) do
|
56
|
-
Rails.root = '
|
62
|
+
Rails.root = 'aws_with_yml'
|
57
63
|
AssetSync.config = AssetSync::Config.new
|
58
64
|
end
|
59
65
|
|
60
|
-
it "should configure
|
61
|
-
AssetSync.config.
|
66
|
+
it "should configure aws_access_key_id" do
|
67
|
+
AssetSync.config.aws_access_key_id.should == "xxxx"
|
62
68
|
end
|
63
69
|
|
64
|
-
it "should configure
|
65
|
-
AssetSync.config.
|
70
|
+
it "should configure aws_secret_access_key" do
|
71
|
+
AssetSync.config.aws_secret_access_key.should == "zzzz"
|
66
72
|
end
|
67
73
|
|
68
74
|
it "should configure aws_access_key" do
|
69
|
-
AssetSync.config.
|
75
|
+
AssetSync.config.fog_directory.should == "rails_app_test"
|
70
76
|
end
|
71
77
|
|
72
78
|
it "should configure aws_access_key" do
|
73
|
-
AssetSync.config.
|
79
|
+
AssetSync.config.fog_region.should == "eu-west-1"
|
74
80
|
end
|
75
81
|
|
76
82
|
it "should configure aws_access_key" do
|
@@ -1,20 +1,20 @@
|
|
1
1
|
defaults: &defaults
|
2
|
-
|
3
|
-
|
2
|
+
fog_provider: "AWS"
|
3
|
+
aws_access_key_id: "xxxx"
|
4
|
+
aws_secret_access_key: "zzzz"
|
4
5
|
region: "eu-west-1"
|
5
6
|
|
6
7
|
development:
|
7
8
|
<<: *defaults
|
8
|
-
|
9
|
+
fog_directory: "rails_app_development"
|
9
10
|
existing_remote_files: keep
|
10
11
|
|
11
12
|
test:
|
12
13
|
<<: *defaults
|
13
|
-
|
14
|
+
fog_directory: "rails_app_test"
|
14
15
|
existing_remote_files: keep
|
15
16
|
|
16
17
|
production:
|
17
18
|
<<: *defaults
|
18
|
-
|
19
|
+
fog_directory: "rails_app_production"
|
19
20
|
existing_remote_files: delete
|
20
|
-
|
@@ -0,0 +1,83 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
|
4
|
+
describe AssetSync, 'using Rackspace with initializer' do
|
5
|
+
|
6
|
+
before(:all) do
|
7
|
+
Rails.root = 'without_yml'
|
8
|
+
AssetSync.config = AssetSync::Config.new
|
9
|
+
AssetSync.configure do |config|
|
10
|
+
config.fog_provider = 'Rackspace'
|
11
|
+
config.fog_directory = 'mybucket'
|
12
|
+
config.fog_region = 'dunno'
|
13
|
+
config.rackspace_username = 'aaaa'
|
14
|
+
config.rackspace_api_key = 'bbbb'
|
15
|
+
config.existing_remote_files = 'keep'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should configure provider as AWS" do
|
20
|
+
AssetSync.config.fog_provider.should == 'Rackspace'
|
21
|
+
AssetSync.config.should be_rackspace
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should keep existing remote files" do
|
25
|
+
AssetSync.config.existing_remote_files?.should == true
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should configure rackspace_username" do
|
29
|
+
AssetSync.config.rackspace_username.should == "aaaa"
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should configure rackspace_api_key" do
|
33
|
+
AssetSync.config.rackspace_api_key.should == "bbbb"
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should configure fog_directory" do
|
37
|
+
AssetSync.config.fog_directory.should == "mybucket"
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should configure fog_region" do
|
41
|
+
AssetSync.config.fog_region.should == "dunno"
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should configure existing_remote_files" do
|
45
|
+
AssetSync.config.existing_remote_files.should == "keep"
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
describe AssetSync, 'using Rackspace from yml' do
|
52
|
+
|
53
|
+
before(:all) do
|
54
|
+
Rails.root = 'rackspace_with_yml'
|
55
|
+
AssetSync.config = AssetSync::Config.new
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should keep existing remote files" do
|
59
|
+
AssetSync.config.existing_remote_files?.should == true
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should configure rackspace_username" do
|
63
|
+
AssetSync.config.rackspace_username.should == "xxxx"
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should configure rackspace_api_key" do
|
67
|
+
AssetSync.config.rackspace_api_key.should == "zzzz"
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should configure fog_directory" do
|
71
|
+
AssetSync.config.fog_directory.should == "rails_app_test"
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should configure fog_region" do
|
75
|
+
AssetSync.config.fog_region.should == "eu-west-1"
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should configure existing_remote_files" do
|
79
|
+
AssetSync.config.existing_remote_files.should == "keep"
|
80
|
+
end
|
81
|
+
|
82
|
+
|
83
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
defaults: &defaults
|
2
|
+
fog_provider: "Rackspace"
|
3
|
+
rackspace_username: "xxxx"
|
4
|
+
rackspace_api_key: "zzzz"
|
5
|
+
region: "eu-west-1"
|
6
|
+
|
7
|
+
development:
|
8
|
+
<<: *defaults
|
9
|
+
fog_directory: "rails_app_development"
|
10
|
+
existing_remote_files: keep
|
11
|
+
|
12
|
+
test:
|
13
|
+
<<: *defaults
|
14
|
+
fog_directory: "rails_app_test"
|
15
|
+
existing_remote_files: keep
|
16
|
+
|
17
|
+
production:
|
18
|
+
<<: *defaults
|
19
|
+
fog_directory: "rails_app_production"
|
20
|
+
existing_remote_files: delete
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: asset_sync
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,11 +10,11 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2011-11-
|
13
|
+
date: 2011-11-15 00:00:00.000000000Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: fog
|
17
|
-
requirement: &
|
17
|
+
requirement: &70139726871260 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: '0'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *70139726871260
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: activemodel
|
28
|
-
requirement: &
|
28
|
+
requirement: &70139726870840 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ! '>='
|
@@ -33,10 +33,10 @@ dependencies:
|
|
33
33
|
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *70139726870840
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: rspec
|
39
|
-
requirement: &
|
39
|
+
requirement: &70139726870420 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
42
42
|
- - ! '>='
|
@@ -44,10 +44,10 @@ dependencies:
|
|
44
44
|
version: '0'
|
45
45
|
type: :development
|
46
46
|
prerelease: false
|
47
|
-
version_requirements: *
|
47
|
+
version_requirements: *70139726870420
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: bundler
|
50
|
-
requirement: &
|
50
|
+
requirement: &70139726870000 !ruby/object:Gem::Requirement
|
51
51
|
none: false
|
52
52
|
requirements:
|
53
53
|
- - ! '>='
|
@@ -55,10 +55,10 @@ dependencies:
|
|
55
55
|
version: '0'
|
56
56
|
type: :development
|
57
57
|
prerelease: false
|
58
|
-
version_requirements: *
|
58
|
+
version_requirements: *70139726870000
|
59
59
|
- !ruby/object:Gem::Dependency
|
60
60
|
name: jeweler
|
61
|
-
requirement: &
|
61
|
+
requirement: &70139726869580 !ruby/object:Gem::Requirement
|
62
62
|
none: false
|
63
63
|
requirements:
|
64
64
|
- - ! '>='
|
@@ -66,9 +66,9 @@ dependencies:
|
|
66
66
|
version: '0'
|
67
67
|
type: :development
|
68
68
|
prerelease: false
|
69
|
-
version_requirements: *
|
70
|
-
description: After you run assets:precompile your assets will be synchronised
|
71
|
-
your S3 bucket
|
69
|
+
version_requirements: *70139726869580
|
70
|
+
description: After you run assets:precompile your compiled assets will be synchronised
|
71
|
+
with your S3 bucket.
|
72
72
|
email:
|
73
73
|
- shamilton@rumblelabs.com
|
74
74
|
- me@davidjrice.co.uk
|
@@ -89,13 +89,14 @@ files:
|
|
89
89
|
- lib/asset_sync/storage.rb
|
90
90
|
- lib/asset_sync/version.rb
|
91
91
|
- lib/generators/asset_sync/install_generator.rb
|
92
|
-
- lib/generators/asset_sync/templates/asset_sync.rake
|
93
92
|
- lib/generators/asset_sync/templates/asset_sync.rb
|
94
93
|
- lib/generators/asset_sync/templates/asset_sync.yml
|
95
94
|
- lib/tasks/asset_sync.rake
|
96
95
|
- spec/asset_sync_spec.rb
|
96
|
+
- spec/aws_with_yml/config/asset_sync.yml
|
97
|
+
- spec/rackspace_spec.rb
|
98
|
+
- spec/rackspace_with_yml/config/asset_sync.yml
|
97
99
|
- spec/spec_helper.rb
|
98
|
-
- spec/with_yml/config/asset_sync.yml
|
99
100
|
homepage: https://github.com/rumblelabs/asset_sync
|
100
101
|
licenses: []
|
101
102
|
post_install_message:
|
@@ -119,8 +120,11 @@ rubyforge_project: asset_sync
|
|
119
120
|
rubygems_version: 1.8.10
|
120
121
|
signing_key:
|
121
122
|
specification_version: 3
|
122
|
-
summary: Synchronises Assets in a Rails 3 application and S3/Cloudfront
|
123
|
+
summary: Synchronises Assets in a Rails 3 application and Amazon S3/Cloudfront and
|
124
|
+
Rackspace Cloudfiles
|
123
125
|
test_files:
|
124
126
|
- spec/asset_sync_spec.rb
|
127
|
+
- spec/aws_with_yml/config/asset_sync.yml
|
128
|
+
- spec/rackspace_spec.rb
|
129
|
+
- spec/rackspace_with_yml/config/asset_sync.yml
|
125
130
|
- spec/spec_helper.rb
|
126
|
-
- spec/with_yml/config/asset_sync.yml
|