asset_sync 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -221,6 +221,7 @@ AssetSync.config.gzip_compression == ENV['ASSET_SYNC_GZIP_COMPRESSION']
221
221
  * **existing_remote_files**: (`'keep', 'delete', 'ignore'`) what to do with previously precompiled files. **default:** `'keep'`
222
222
  * **gzip\_compression**: (`true, false`) when enabled, will automatically replace files that have a gzip compressed equivalent with the compressed version. **default:** `'false'`
223
223
  * **manifest**: (`true, false`) when enabled, will use the `manifest.yml` generated by Rails to get the list of local files to upload. **experimental**. **default:** `'false'`
224
+ * **enabled**: (`true, false`) when false, will disable asset sync. **default:** `'true'` (enabled)
224
225
 
225
226
  #### Fog (Required)
226
227
  * **fog\_provider**: your storage provider *AWS* (S3) or *Rackspace* (Cloud Files) or *Google* (Google Storage)
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 = "2012-04-18"
9
+ s.date = "2012-05-04"
10
10
  s.platform = Gem::Platform::RUBY
11
11
  s.authors = ["Simon Hamilton", "David Rice", "Phil McClure"]
12
12
  s.email = ["shamilton@rumblelabs.com", "me@davidjrice.co.uk", "pmcclure@rumblelabs.com"]
@@ -21,6 +21,8 @@ module AssetSync
21
21
  end
22
22
 
23
23
  def sync
24
+ return unless AssetSync.enabled?
25
+
24
26
  if config.fail_silently?
25
27
  self.warn config.errors.full_messages.join(', ') unless config && config.valid?
26
28
  else
@@ -37,6 +39,10 @@ module AssetSync
37
39
  STDOUT.puts msg if ENV["RAILS_GROUPS"] == "assets"
38
40
  end
39
41
 
42
+ def enabled?
43
+ config.enabled?
44
+ end
45
+
40
46
  end
41
47
 
42
- end
48
+ end
@@ -10,6 +10,7 @@ module AssetSync
10
10
  attr_accessor :manifest
11
11
  attr_accessor :fail_silently
12
12
  attr_accessor :always_upload
13
+ attr_accessor :enabled
13
14
 
14
15
  # FOG configuration
15
16
  attr_accessor :fog_provider # Currently Supported ['AWS', 'Rackspace']
@@ -44,6 +45,7 @@ module AssetSync
44
45
  self.manifest = false
45
46
  self.fail_silently = false
46
47
  self.always_upload = []
48
+ self.enabled = true
47
49
  load_yml! if yml_exists?
48
50
  end
49
51
 
@@ -69,6 +71,10 @@ module AssetSync
69
71
  fail_silently == true
70
72
  end
71
73
 
74
+ def enabled?
75
+ enabled == true
76
+ end
77
+
72
78
  def rackspace?
73
79
  fog_provider == 'Rackspace'
74
80
  end
@@ -95,6 +101,7 @@ module AssetSync
95
101
  end
96
102
 
97
103
  def load_yml!
104
+ self.enabled = yml["enabled"] if yml.has_key?('enabled')
98
105
  self.fog_provider = yml["fog_provider"]
99
106
  self.fog_directory = yml["fog_directory"]
100
107
  self.fog_region = yml["fog_region"]
@@ -25,6 +25,9 @@ class Engine < Rails::Engine
25
25
  config.google_storage_access_key_id = ENV['GOOGLE_STORAGE_ACCESS_KEY_ID']
26
26
  config.google_storage_secret_access_key = ENV['GOOGLE_STORAGE_SECRET_ACCESS_KEY']
27
27
 
28
+ if ENV.has_key? 'ASSET_SYNC_ENABLED'
29
+ config.enabled = ENV['ASSET_SYNC_ENABLED'] == 'true'
30
+ end
28
31
  config.existing_remote_files = ENV['ASSET_SYNC_EXISTING_REMOTE_FILES'] || "keep"
29
32
  config.gzip_compression = ENV['ASSET_SYNC_GZIP_COMPRESSION'] == 'true'
30
33
  config.manifest = ENV['ASSET_SYNC_MANIFEST'] == 'true'
@@ -1,3 +1,3 @@
1
1
  module AssetSync
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.1"
3
3
  end
@@ -10,4 +10,4 @@ else
10
10
  # Rake::Task["assets:environment"].invoke if Rake::Task.task_defined?("assets:environment")
11
11
  AssetSync.sync
12
12
  end
13
- end
13
+ end
@@ -16,6 +16,11 @@ describe AssetSync do
16
16
  end
17
17
  end
18
18
 
19
+ it "should default AssetSync to enabled" do
20
+ AssetSync.config.enabled?.should be_true
21
+ AssetSync.enabled?.should be_true
22
+ end
23
+
19
24
  it "should configure provider as AWS" do
20
25
  AssetSync.config.fog_provider.should == 'AWS'
21
26
  AssetSync.config.should be_aws
@@ -60,6 +65,11 @@ describe AssetSync do
60
65
  AssetSync.config = AssetSync::Config.new
61
66
  end
62
67
 
68
+ it "should default AssetSync to enabled" do
69
+ AssetSync.config.enabled?.should be_true
70
+ AssetSync.enabled?.should be_true
71
+ end
72
+
63
73
  it "should configure aws_access_key_id" do
64
74
  AssetSync.config.aws_access_key_id.should == "xxxx"
65
75
  end
@@ -89,6 +99,22 @@ describe AssetSync do
89
99
  end
90
100
  end
91
101
 
102
+ describe 'from yml, exporting to a mobile hybrid development directory' do
103
+ before(:each) do
104
+ Rails.env.replace('hybrid')
105
+ set_rails_root('aws_with_yml')
106
+ AssetSync.config = AssetSync::Config.new
107
+ end
108
+
109
+ it "should be disabled" do
110
+ lambda{ AssetSync.sync }.should_not raise_error(AssetSync::Config::Invalid)
111
+ end
112
+
113
+ after(:each) do
114
+ Rails.env.replace('test')
115
+ end
116
+ end
117
+
92
118
  describe 'with no configuration' do
93
119
  before(:each) do
94
120
  AssetSync.config = AssetSync::Config.new
@@ -99,6 +125,19 @@ describe AssetSync do
99
125
  end
100
126
  end
101
127
 
128
+ describe "with no other configuration than enabled = false" do
129
+ before(:each) do
130
+ AssetSync.config = AssetSync::Config.new
131
+ AssetSync.configure do |config|
132
+ config.enabled = false
133
+ end
134
+ end
135
+
136
+ it "should do nothing, without complaining" do
137
+ lambda{ AssetSync.sync }.should_not raise_error(AssetSync::Config::Invalid)
138
+ end
139
+ end
140
+
102
141
  describe 'with fail_silent configuration' do
103
142
  before(:each) do
104
143
  AssetSync.config = AssetSync::Config.new
@@ -18,3 +18,7 @@ production:
18
18
  <<: *defaults
19
19
  fog_directory: "rails_app_production"
20
20
  existing_remote_files: delete
21
+
22
+ hybrid:
23
+ <<: *defaults
24
+ enabled: false
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.0
4
+ version: 0.4.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,11 +11,11 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2012-04-18 00:00:00.000000000 Z
14
+ date: 2012-05-04 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: fog
18
- requirement: &70252796863900 !ruby/object:Gem::Requirement
18
+ requirement: &70254273780720 !ruby/object:Gem::Requirement
19
19
  none: false
20
20
  requirements:
21
21
  - - ! '>='
@@ -23,10 +23,10 @@ dependencies:
23
23
  version: '0'
24
24
  type: :runtime
25
25
  prerelease: false
26
- version_requirements: *70252796863900
26
+ version_requirements: *70254273780720
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activemodel
29
- requirement: &70252796862460 !ruby/object:Gem::Requirement
29
+ requirement: &70254273780280 !ruby/object:Gem::Requirement
30
30
  none: false
31
31
  requirements:
32
32
  - - ! '>='
@@ -34,10 +34,10 @@ dependencies:
34
34
  version: '0'
35
35
  type: :runtime
36
36
  prerelease: false
37
- version_requirements: *70252796862460
37
+ version_requirements: *70254273780280
38
38
  - !ruby/object:Gem::Dependency
39
39
  name: rspec
40
- requirement: &70252796896120 !ruby/object:Gem::Requirement
40
+ requirement: &70254273779760 !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
43
  - - ! '>='
@@ -45,10 +45,10 @@ dependencies:
45
45
  version: '0'
46
46
  type: :development
47
47
  prerelease: false
48
- version_requirements: *70252796896120
48
+ version_requirements: *70254273779760
49
49
  - !ruby/object:Gem::Dependency
50
50
  name: bundler
51
- requirement: &70252796894920 !ruby/object:Gem::Requirement
51
+ requirement: &70254273779320 !ruby/object:Gem::Requirement
52
52
  none: false
53
53
  requirements:
54
54
  - - ! '>='
@@ -56,10 +56,10 @@ dependencies:
56
56
  version: '0'
57
57
  type: :development
58
58
  prerelease: false
59
- version_requirements: *70252796894920
59
+ version_requirements: *70254273779320
60
60
  - !ruby/object:Gem::Dependency
61
61
  name: jeweler
62
- requirement: &70252796893900 !ruby/object:Gem::Requirement
62
+ requirement: &70254273778800 !ruby/object:Gem::Requirement
63
63
  none: false
64
64
  requirements:
65
65
  - - ! '>='
@@ -67,7 +67,7 @@ dependencies:
67
67
  version: '0'
68
68
  type: :development
69
69
  prerelease: false
70
- version_requirements: *70252796893900
70
+ version_requirements: *70254273778800
71
71
  description: After you run assets:precompile your compiled assets will be synchronised
72
72
  with your S3 bucket.
73
73
  email:
@@ -138,3 +138,4 @@ test_files:
138
138
  - spec/rackspace_with_yml/config/asset_sync.yml
139
139
  - spec/spec_helper.rb
140
140
  - spec/storage_spec.rb
141
+ has_rdoc: