asset_sync 0.5.3 → 0.5.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -2
- data/Gemfile +2 -1
- data/README.md +3 -2
- data/Rakefile +18 -2
- data/asset_sync.gemspec +1 -1
- data/lib/asset_sync.rb +1 -0
- data/lib/asset_sync/asset_sync.rb +9 -4
- data/lib/asset_sync/multi_mime.rb +18 -0
- data/lib/asset_sync/storage.rb +2 -2
- data/lib/asset_sync/version.rb +1 -1
- data/lib/generators/asset_sync/templates/asset_sync.yml +2 -2
- data/spec/spec_helper.rb +9 -0
- data/spec/unit/asset_sync_spec.rb +1 -0
- data/spec/unit/multi_mime_spec.rb +47 -0
- metadata +7 -4
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
[![Build Status](https://secure.travis-ci.org/rumblelabs/asset_sync.png)](http://travis-ci.org/rumblelabs/asset_sync)
|
2
|
+
[![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/rumblelabs/asset_sync)
|
2
3
|
|
3
4
|
# Asset Sync
|
4
5
|
|
@@ -217,7 +218,7 @@ defaults: &defaults
|
|
217
218
|
# Automatically replace files with their equivalent gzip compressed version
|
218
219
|
# gzip_compression: true
|
219
220
|
# Fail silently. Useful for environments such as Heroku
|
220
|
-
# fail_silently
|
221
|
+
# fail_silently: true
|
221
222
|
# Always upload. Useful if you want to overwrite specific remote assets regardless of their existence
|
222
223
|
# eg: Static files in public often reference non-fingerprinted application.css
|
223
224
|
# note: You will still need to expire them from the CDN's edge cache locations
|
@@ -400,4 +401,4 @@ Inspired by:
|
|
400
401
|
|
401
402
|
## License
|
402
403
|
|
403
|
-
MIT License. Copyright 2011 Rumble Labs Ltd. [rumblelabs.com](http://rumblelabs.com)
|
404
|
+
MIT License. Copyright 2011-2013 Rumble Labs Ltd. [rumblelabs.com](http://rumblelabs.com)
|
data/Rakefile
CHANGED
@@ -5,14 +5,30 @@ namespace :spec do
|
|
5
5
|
RSpec::Core::RakeTask.new(:unit) do |spec|
|
6
6
|
spec.pattern = 'spec/unit/*_spec.rb'
|
7
7
|
spec.rspec_opts = ['--backtrace']
|
8
|
+
|
9
|
+
rbx = defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx'
|
10
|
+
jruby = defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby'
|
11
|
+
if RUBY_VERSION == '1.8.7' && !(rbx || jruby)
|
12
|
+
spec.rcov = true
|
13
|
+
spec.rcov_opts = %w{--exclude gems\/,spec\/}
|
14
|
+
end
|
8
15
|
end
|
9
16
|
RSpec::Core::RakeTask.new(:integration) do |spec|
|
10
17
|
spec.pattern = 'spec/integration/*_spec.rb'
|
11
18
|
spec.rspec_opts = ['--backtrace']
|
12
19
|
end
|
13
20
|
task :all do
|
14
|
-
|
15
|
-
|
21
|
+
Rake::Task['spec:unit'].execute
|
22
|
+
|
23
|
+
# Travis CI does not expose encrypted ENV variables for pull requests, so
|
24
|
+
# do not run integration specs
|
25
|
+
# http://about.travis-ci.org/docs/user/build-configuration/#Set-environment-variables
|
26
|
+
#
|
27
|
+
pull_request = ENV['TRAVIS_PULL_REQUEST'] == 'true'
|
28
|
+
ci_build = ENV['TRAVIS'] == 'true'
|
29
|
+
if !ci_build || (ci_build && pull_request)
|
30
|
+
Rake::Task['spec:integration'].execute
|
31
|
+
end
|
16
32
|
end
|
17
33
|
end
|
18
34
|
|
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 = "2013-01-
|
9
|
+
s.date = "2013-01-16"
|
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"]
|
data/lib/asset_sync.rb
CHANGED
@@ -23,12 +23,17 @@ module AssetSync
|
|
23
23
|
def sync
|
24
24
|
return unless AssetSync.enabled?
|
25
25
|
|
26
|
-
|
27
|
-
|
26
|
+
errors = config.valid? ? "" : config.errors.full_messages.join(', ')
|
27
|
+
|
28
|
+
if !(config && config.valid?)
|
29
|
+
if config.fail_silently?
|
30
|
+
self.warn(errors)
|
31
|
+
else
|
32
|
+
raise Config::Invalid.new(errors)
|
33
|
+
end
|
28
34
|
else
|
29
|
-
|
35
|
+
self.storage.sync
|
30
36
|
end
|
31
|
-
self.storage.sync if config && config.valid?
|
32
37
|
end
|
33
38
|
|
34
39
|
def warn(msg)
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module AssetSync
|
2
|
+
class MultiMime
|
3
|
+
|
4
|
+
def self.lookup(ext)
|
5
|
+
|
6
|
+
if defined?(Mime::Type)
|
7
|
+
Mime::Type.lookup_by_extension(ext)
|
8
|
+
elsif defined?(Rack::Mime)
|
9
|
+
ext_with_dot = ".#{ext}"
|
10
|
+
Rack::Mime.mime_type(ext_with_dot)
|
11
|
+
else
|
12
|
+
MIME::Types.type_for(ext).first
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
data/lib/asset_sync/storage.rb
CHANGED
@@ -106,7 +106,7 @@ module AssetSync
|
|
106
106
|
# TODO output files in debug logs as asset filename only.
|
107
107
|
one_year = 31557600
|
108
108
|
ext = File.extname(f)[1..-1]
|
109
|
-
mime =
|
109
|
+
mime = MultiMime.lookup(ext)
|
110
110
|
file = {
|
111
111
|
:key => f,
|
112
112
|
:body => File.open("#{path}/#{f}"),
|
@@ -146,7 +146,7 @@ module AssetSync
|
|
146
146
|
# http://docs.amazonwebservices.com/AmazonCloudFront/latest/DeveloperGuide/ServingCompressedFiles.html
|
147
147
|
uncompressed_filename = f[0..-4]
|
148
148
|
ext = File.extname(uncompressed_filename)[1..-1]
|
149
|
-
mime =
|
149
|
+
mime = MultiMime.lookup(ext)
|
150
150
|
file.merge!({
|
151
151
|
:content_type => mime,
|
152
152
|
:content_encoding => 'gzip'
|
data/lib/asset_sync/version.rb
CHANGED
@@ -21,9 +21,9 @@ defaults: &defaults
|
|
21
21
|
# To delete existing remote files.
|
22
22
|
# existing_remote_files: delete
|
23
23
|
# Automatically replace files with their equivalent gzip compressed version
|
24
|
-
# gzip_compression
|
24
|
+
# gzip_compression: true
|
25
25
|
# Fail silently. Useful for environments such as Heroku
|
26
|
-
# fail_silently
|
26
|
+
# fail_silently: true
|
27
27
|
|
28
28
|
development:
|
29
29
|
<<: *defaults
|
data/spec/spec_helper.rb
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'bundler'
|
3
|
+
|
4
|
+
if RUBY_VERSION != '1.8.7'
|
5
|
+
require 'simplecov'
|
6
|
+
SimpleCov.start do
|
7
|
+
add_filter 'spec'
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
3
11
|
begin
|
4
12
|
Bundler.setup(:default, :development)
|
5
13
|
rescue Bundler::BundlerError => e
|
@@ -12,6 +20,7 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
|
12
20
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
13
21
|
require 'asset_sync'
|
14
22
|
|
23
|
+
require 'rspec'
|
15
24
|
RSpec.configure do |config|
|
16
25
|
config.mock_framework = :rspec
|
17
26
|
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe AssetSync::MultiMime do
|
4
|
+
|
5
|
+
describe 'Mime::Type' do
|
6
|
+
|
7
|
+
it 'should detect mime type' do
|
8
|
+
Object.send(:remove_const, :Rails) if defined?(Rails)
|
9
|
+
require 'rails'
|
10
|
+
AssetSync::MultiMime.lookup('css').should == "text/css"
|
11
|
+
end
|
12
|
+
|
13
|
+
after(:each) do
|
14
|
+
Object.send(:remove_const, :Rails) if defined?(Rails)
|
15
|
+
Object.send(:remove_const, :Mime) if defined?(Mime)
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
describe 'Rack::Mime' do
|
21
|
+
|
22
|
+
it 'should detect mime type' do
|
23
|
+
require 'rack/mime'
|
24
|
+
AssetSync::MultiMime.lookup('css').should == "text/css"
|
25
|
+
end
|
26
|
+
|
27
|
+
after(:each) do
|
28
|
+
Object.send(:remove_const, :Rack) if defined?(Rack)
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
describe 'MIME::Types' do
|
34
|
+
|
35
|
+
it 'should detect mime type' do
|
36
|
+
Object.send(:remove_const, :MIME) if defined?(MIME)
|
37
|
+
require 'mime/types'
|
38
|
+
AssetSync::MultiMime.lookup('css').should == "text/css"
|
39
|
+
end
|
40
|
+
|
41
|
+
after(:each) do
|
42
|
+
Object.send(:remove_const, :MIME) if defined?(MIME)
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
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.5.
|
4
|
+
version: 0.5.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2013-01-
|
14
|
+
date: 2013-01-16 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: fog
|
@@ -163,6 +163,7 @@ files:
|
|
163
163
|
- lib/asset_sync/asset_sync.rb
|
164
164
|
- lib/asset_sync/config.rb
|
165
165
|
- lib/asset_sync/engine.rb
|
166
|
+
- lib/asset_sync/multi_mime.rb
|
166
167
|
- lib/asset_sync/railtie.rb
|
167
168
|
- lib/asset_sync/storage.rb
|
168
169
|
- lib/asset_sync/version.rb
|
@@ -179,6 +180,7 @@ files:
|
|
179
180
|
- spec/spec_helper.rb
|
180
181
|
- spec/unit/asset_sync_spec.rb
|
181
182
|
- spec/unit/google_spec.rb
|
183
|
+
- spec/unit/multi_mime_spec.rb
|
182
184
|
- spec/unit/rackspace_spec.rb
|
183
185
|
- spec/unit/railsless_spec.rb
|
184
186
|
- spec/unit/storage_spec.rb
|
@@ -196,7 +198,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
196
198
|
version: '0'
|
197
199
|
segments:
|
198
200
|
- 0
|
199
|
-
hash:
|
201
|
+
hash: 331776732301041592
|
200
202
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
201
203
|
none: false
|
202
204
|
requirements:
|
@@ -205,7 +207,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
205
207
|
version: '0'
|
206
208
|
segments:
|
207
209
|
- 0
|
208
|
-
hash:
|
210
|
+
hash: 331776732301041592
|
209
211
|
requirements: []
|
210
212
|
rubyforge_project: asset_sync
|
211
213
|
rubygems_version: 1.8.24
|
@@ -223,6 +225,7 @@ test_files:
|
|
223
225
|
- spec/spec_helper.rb
|
224
226
|
- spec/unit/asset_sync_spec.rb
|
225
227
|
- spec/unit/google_spec.rb
|
228
|
+
- spec/unit/multi_mime_spec.rb
|
226
229
|
- spec/unit/rackspace_spec.rb
|
227
230
|
- spec/unit/railsless_spec.rb
|
228
231
|
- spec/unit/storage_spec.rb
|