asset_sync 0.0.3 → 0.0.4

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 CHANGED
@@ -23,24 +23,45 @@ Configure __config/environments/production.rb__ to use Amazon
23
23
  S3 as the asset host and ensure precompiling is enabled.
24
24
 
25
25
  # config/environments/production.rb
26
- config.action_controller.asset_host = Proc.new do |source|
27
- request.ssl? 'https://my_bucket.s3.amazonaws.com' : 'http://my_bucket.s3.amazonaws.com'
26
+ config.action_controller.asset_host = Proc.new do |source, request|
27
+ request.ssl? ? 'https://my_bucket.s3.amazonaws.com' : 'http://my_bucket.s3.amazonaws.com'
28
28
  end
29
29
 
30
- Add your Amazon S3 configuration details to **asset_sync.yml**
31
-
32
- # config/asset_sync.yml
30
+ ### asset_sync.yml
31
+
32
+ The recommend way to configure your **asset_sync.yml** is by adding an environment variable. That way your access keys are not checked into version control.
33
+
34
+ defaults: &defaults
35
+ access_key_id: "<%= ENV['AWS_ACCESS_KEY'] %>"
36
+ secret_access_key: "<%= ENV['AWS_ACCESS_SECRET'] %>"
37
+ # You may need to specify what region your S3 bucket is in
38
+ # region: "eu-west-1"
39
+
33
40
  development:
34
- access_key_id: 'MY_ACCESS_KEY'
35
- secret_access_key: 'MY_ACCESS_SECRET'
36
- bucket: "my_bucket"
37
- existing_remote_files: "keep"
41
+ <<: *defaults
42
+ bucket: "backoffice_development"
43
+ existing_remote_files: keep # Existing pre-compiled assets on S3 will be kept
44
+
45
+ test:
46
+ <<: *defaults
47
+ bucket: "backoffice_test"
48
+ existing_remote_files: keep
38
49
 
39
50
  production:
40
- access_key_id: 'MY_ACCESS_KEY'
41
- secret_access_key: 'MY_ACCESS_SECRET'
42
- bucket: "my_bucket"
43
- existing_remote_files: "delete"
51
+ <<: *defaults
52
+ bucket: "backoffice_production"
53
+ existing_remote_files: delete # Existing pre-compiled assets on S3 will be deleted
54
+
55
+
56
+ Add your Amazon S3 configuration details to **heroku**
57
+
58
+ heroku config:add AWS_ACCESS_KEY=xxxx
59
+ heroku config:add AWS_ACCESS_KEY=xxxx
60
+
61
+ Or add to a traditional unix system
62
+
63
+ export AWS_ACCESS_KEY=xxxx
64
+ export AWS_ACCESS_SECRET=xxxx
44
65
 
45
66
  If you are using anything other than the US buckets with S3 then you'll want to set the **region**. For example with an EU bucket you could set the following
46
67
 
@@ -49,6 +70,15 @@ If you are using anything other than the US buckets with S3 then you'll want to
49
70
  secret_access_key: 'MY_ACCESS_SECRET'
50
71
  region: 'eu-west-1'
51
72
 
73
+ ### Available Configuration Options
74
+
75
+ * **access\_key\_id**: your Amazon S3 access key
76
+ * **secret_access\_key**: your Amazon S3 access secret
77
+ * **region**: the region your S3 bucket is in e.g. *eu-west-1*
78
+ * **existing_remote_files**: what to do with previously precompiled files, options are **keep** or **delete**
79
+
80
+ ## Rake Task
81
+
52
82
  A rake task is installed with the generator to enhance the rails
53
83
  precompile task by automatically running after it:
54
84
 
data/asset_sync.gemspec CHANGED
@@ -6,7 +6,7 @@ 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-07-30"
9
+ s.date = "2011-08-05"
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"]
@@ -1,3 +1,3 @@
1
1
  module AssetSync
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -13,12 +13,24 @@ module AssetSync
13
13
  @source_root ||= File.join(File.dirname(__FILE__), 'templates')
14
14
  end
15
15
 
16
+ def aws_access_key
17
+ "<%= ENV['AWS_ACCESS_KEY'] %>"
18
+ end
19
+
20
+ def aws_access_secret
21
+ "<%= ENV['AWS_ACCESS_SECRET'] %>"
22
+ end
23
+
24
+ def app_name
25
+ @app_name ||= Rails.application.is_a?(Rails::Application) && Rails.application.class.name.sub(/::Application$/, "").downcase
26
+ end
27
+
16
28
  def generate_config
17
- copy_file "asset_sync.yml", "config/asset_sync.yml"
29
+ template "asset_sync.yml", "config/asset_sync.yml"
18
30
  end
19
31
 
20
32
  def generate_rake_task
21
- copy_file "asset_sync.rake", "lib/tasks/asset_sync.rake"
33
+ template "asset_sync.rake", "lib/tasks/asset_sync.rake"
22
34
  end
23
35
  end
24
36
  end
@@ -1,11 +1,21 @@
1
+ defaults: &defaults
2
+ access_key_id: "<%= aws_access_key %>"
3
+ secret_access_key: "<%= aws_access_secret %>"
4
+ # You may need to specify what region your S3 bucket is in
5
+ # region: "eu-west-1"
6
+
1
7
  development:
2
- access_key_id: 'MY_ACCESS_KEY'
3
- secret_access_key: 'MY_ACCESS_SECRET'
4
- bucket: "my_bucket"
8
+ <<: *defaults
9
+ bucket: "<%= app_name %>_development"
10
+ existing_remote_files: keep # Existing pre-compiled assets on S3 will be kept
11
+
12
+ test:
13
+ <<: *defaults
14
+ bucket: "<%= app_name %>_test"
5
15
  existing_remote_files: keep
6
16
 
7
17
  production:
8
- access_key_id: 'MY_ACCESS_KEY'
9
- secret_access_key: 'MY_ACCESS_SECRET'
10
- bucket: "my_bucket"
11
- existing_remote_files: delete
18
+ <<: *defaults
19
+ bucket: "<%= app_name %>_production"
20
+ existing_remote_files: delete # Existing pre-compiled assets on S3 will be deleted
21
+
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: asset_sync
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.3
5
+ version: 0.0.4
6
6
  platform: ruby
7
7
  authors:
8
8
  - Simon Hamilton
@@ -11,7 +11,7 @@ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
13
 
14
- date: 2011-07-30 00:00:00 Z
14
+ date: 2011-08-05 00:00:00 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: fog