asset_sync 0.5.3 → 0.5.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/.gitignore CHANGED
@@ -4,8 +4,9 @@
4
4
  Gemfile.lock
5
5
  pkg/*
6
6
  *.swp
7
-
7
+ coverage/*
8
8
  .env
9
9
  spec/dummy_app/public/*
10
10
  spec/dummy_app/log/*
11
- spec/dummy_app/tmp/*
11
+ spec/dummy_app/tmp/*
12
+ .rbx
data/Gemfile CHANGED
@@ -1,4 +1,5 @@
1
1
  source :rubygems
2
2
  gemspec
3
-
3
+ gem 'rcov', :platforms => :mri_18, :group => [:development, :test]
4
+ gem 'simplecov', :platforms => [:jruby, :mri_19, :ruby_19, :rbx], :group => [:development, :test], :require => false
4
5
  gem 'jruby-openssl', :platform => :jruby
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 = true
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
- Rake::Task['spec:unit'].execute
15
- Rake::Task['spec:integration'].execute
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
 
@@ -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-08"
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"]
@@ -4,6 +4,7 @@ require 'erb'
4
4
  require "asset_sync/asset_sync"
5
5
  require 'asset_sync/config'
6
6
  require 'asset_sync/storage'
7
+ require 'asset_sync/multi_mime'
7
8
 
8
9
 
9
10
  require 'asset_sync/railtie' if defined?(Rails)
@@ -23,12 +23,17 @@ module AssetSync
23
23
  def sync
24
24
  return unless AssetSync.enabled?
25
25
 
26
- if config.fail_silently?
27
- self.warn config.errors.full_messages.join(', ') unless config && config.valid?
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
- raise Config::Invalid.new(config.errors.full_messages.join(', ')) unless config && config.valid?
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
@@ -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 = Mime::Type.lookup_by_extension(ext)
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 = Mime::Type.lookup_by_extension( ext )
149
+ mime = MultiMime.lookup(ext)
150
150
  file.merge!({
151
151
  :content_type => mime,
152
152
  :content_encoding => 'gzip'
@@ -1,3 +1,3 @@
1
1
  module AssetSync
2
- VERSION = "0.5.3"
2
+ VERSION = "0.5.4"
3
3
  end
@@ -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 = true
24
+ # gzip_compression: true
25
25
  # Fail silently. Useful for environments such as Heroku
26
- # fail_silently = true
26
+ # fail_silently: true
27
27
 
28
28
  development:
29
29
  <<: *defaults
@@ -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
@@ -192,4 +192,5 @@ describe AssetSync do
192
192
  AssetSync.config.manifest_path.should =~ /public\/custom_assets\/manifest.yml/
193
193
  end
194
194
  end
195
+
195
196
  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.3
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-08 00:00:00.000000000 Z
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: 3874412606411759569
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: 3874412606411759569
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