sprockets-rails 2.1.3 → 2.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 52a7ec0aa2c5fd2bbddd32714dead301603b5755
4
- data.tar.gz: ce9c1b85209963b5483a73309172012baa73942e
3
+ metadata.gz: 02d24e7c7f1fde95838d5eea5ac20f508b061246
4
+ data.tar.gz: 95a911c0f112ba5ea650bdd6df9c9a022c29f5ca
5
5
  SHA512:
6
- metadata.gz: f5bdd1640fc69db3e648d8371ced294869835bb1d4d50207d4f92152ee1b751c2e0029d73dda06888acff3c6358fae2f6a977eae7de1530bc2582996e25ed9d7
7
- data.tar.gz: 73361f7ff7c7b5307a8ce592a272fbc86ce7c780f527bdc8f06908693dc9def6c417d6895a2a02660b2cfe7fe2d61b9906434032e9d86d638cd29d924581f18b
6
+ metadata.gz: 55c9d95c9d462e5b4cadbbcc9b33f4ef438065807b6ca54f8705a11164bd717e8895d2c07d87dd0ebea22f00eac1864575ef58468760bec3d0c5b52f392b05c1
7
+ data.tar.gz: fbad182eb782c40bf89bbb0a3631b9a346b0fa0843f13ce20f17cf7f40e45ba49c4b232851f25191ee3bb0f2b99367951fb0f1478abe242777ea483db29fa76b
data/README.md CHANGED
@@ -51,7 +51,7 @@ end
51
51
 
52
52
  Each asset task will invoke `assets:environment` first. By default this loads the Rails environment. You can override this task to add or remove dependencies for your specific compilation environment.
53
53
 
54
- Also see [Sprockets::Rails::Task](https://github.com/josh/sprockets-rails/blob/master/lib/sprockets/rails/task.rb) and [Rake::SprocketsTask](https://github.com/sstephenson/sprockets/blob/master/lib/rake/sprocketstask.rb).
54
+ Also see [Sprockets::Rails::Task](https://github.com/rails/sprockets-rails/blob/master/lib/sprockets/rails/task.rb) and [Rake::SprocketsTask](https://github.com/sstephenson/sprockets/blob/master/lib/rake/sprocketstask.rb).
55
55
 
56
56
 
57
57
  ### Initializer options
@@ -85,7 +85,7 @@ Defaults to `/assets`. Changes the directory to compile assets to.
85
85
 
86
86
  **`config.assets.manifest`**
87
87
 
88
- Defines the full path to be used for the asset precompiler's manifest file. Defaults to using the `config.assets.prefix` directory within the public folder.
88
+ Defines the full path to be used for the asset precompiler's manifest file. Defaults to a randomly-generated filename in the `config.assets.prefix` directory within the public folder.
89
89
 
90
90
  **`config.assets.digest`**
91
91
 
@@ -134,6 +134,7 @@ The following plugins provide some extras for the Sprockets Asset Pipeline.
134
134
  * Unmanaged asset paths and urls fallback to linking to public/. This should make it easier to work with both compiled assets and simple static assets. As a side effect, there will never be any "asset not precompiled errors" when linking to missing assets. They will just link to a public file which may or may not exist.
135
135
  * JS and CSS compressors must be explicitly set. Magic detection has been removed to avoid loading compressors in environments where you want to avoid loading any of the asset libraries. Assign `config.assets.js_compressor = :uglify` or `config.assets.css_compressor = :sass` for the standard compressors.
136
136
  * The manifest file is now in a JSON format. Since it lives in public/ by default, the initial filename is also randomized to obfuscate public access to the resource.
137
+ * `config.assets.manifest` (if used) must now include the manifest filename, e.g. `Rails.root.join('config/manifest.json')`. It cannot be a directory.
137
138
  * Two cleanup tasks. `rake assets:clean` is now a safe cleanup that only removes older assets that are no longer used. While `rake assets:clobber` nukes the entire `public/assets` directory and clears your filesystem cache. The clean task allows for rolling deploys that may still be linking to an old asset while the new assets are being built.
138
139
 
139
140
 
@@ -30,6 +30,14 @@ module Sprockets
30
30
  end
31
31
  end
32
32
 
33
+ class AbsoluteAssetPathError < ArgumentError
34
+ def initialize(bad_path, good_path, prefix)
35
+ msg = "Asset names passed to helpers should not include the #{prefix.inspect} prefix. " <<
36
+ "Instead of #{bad_path.inspect}, use #{good_path.inspect}"
37
+ super(msg)
38
+ end
39
+ end
40
+
33
41
  if defined? ActionView::Helpers::AssetUrlHelper
34
42
  include ActionView::Helpers::AssetUrlHelper
35
43
  include ActionView::Helpers::AssetTagHelper
@@ -77,17 +85,12 @@ module Sprockets
77
85
  # Computes the full URL to a asset in the public directory. This
78
86
  # method checks for errors before returning path.
79
87
  def asset_path(source, options = {})
80
- check_errors_for(source, options)
81
- path_to_asset(source, options)
82
- end
83
- alias :path_to_asset_with_errors :asset_path
84
-
85
- # Computes the full URL to a asset in the public directory. This
86
- # will use +asset_path+ internally, so most of their behaviors
87
- # will be the same.
88
- def asset_url(source, options = {})
89
- path_to_asset_with_errors(source, options.merge(:protocol => :request))
88
+ unless options[:debug]
89
+ check_errors_for(source, options)
90
+ end
91
+ super(source, options)
90
92
  end
93
+ alias :path_to_asset :asset_path
91
94
 
92
95
  # Get digest for asset path.
93
96
  #
@@ -173,17 +176,30 @@ module Sprockets
173
176
  def check_dependencies!(dep)
174
177
  depend_on(dep)
175
178
  depend_on_asset(dep)
179
+ rescue Sprockets::FileNotFound
176
180
  end
177
181
 
178
- # Raise errors when source does not exist or is not in the precompiled list
182
+ # Raise errors when source is not in the precompiled list, or
183
+ # incorrectly contains the assets_prefix.
179
184
  def check_errors_for(source, options)
185
+ return unless self.raise_runtime_errors
186
+
180
187
  source = source.to_s
181
- return source if !self.raise_runtime_errors || source.blank? || source =~ URI_REGEXP
188
+ return if source.blank? || source =~ URI_REGEXP
189
+
182
190
  asset = lookup_asset_for_path(source, options)
183
191
 
184
192
  if asset && asset_needs_precompile?(asset.logical_path, asset.pathname.to_s)
185
193
  raise AssetFilteredError.new(asset.logical_path)
186
194
  end
195
+
196
+ full_prefix = File.join(self.assets_prefix || "/", '')
197
+ if !asset && source.start_with?(full_prefix)
198
+ short_path = source[full_prefix.size, source.size]
199
+ if lookup_asset_for_path(short_path, options)
200
+ raise AbsoluteAssetPathError.new(source, short_path, full_prefix)
201
+ end
202
+ end
187
203
  end
188
204
 
189
205
  # Returns true when an asset will not be available after precompile is run
@@ -34,6 +34,10 @@ module Sprockets
34
34
  end
35
35
  alias_method :path_to_asset, :asset_path
36
36
 
37
+ def asset_url(source, options = {})
38
+ path_to_asset(source, options.merge(:protocol => :request))
39
+ end
40
+
37
41
  ASSET_EXTENSIONS = {
38
42
  :javascript => '.js',
39
43
  :stylesheet => '.css'
@@ -1,6 +1,7 @@
1
1
  require 'rake'
2
2
  require 'rake/sprocketstask'
3
3
  require 'sprockets'
4
+ require 'action_view'
4
5
  require 'action_view/base'
5
6
 
6
7
  module Sprockets
@@ -37,6 +38,14 @@ module Sprockets
37
38
  end
38
39
  end
39
40
 
41
+ def manifest
42
+ if app
43
+ Sprockets::Manifest.new(index, output, app.config.assets.manifest)
44
+ else
45
+ super
46
+ end
47
+ end
48
+
40
49
  def cache_path
41
50
  if app
42
51
  "#{app.config.root}/tmp/cache/assets"
@@ -1,5 +1,5 @@
1
1
  module Sprockets
2
2
  module Rails
3
- VERSION = "2.1.3"
3
+ VERSION = "2.1.4"
4
4
  end
5
5
  end
@@ -66,7 +66,7 @@ module Sprockets
66
66
  config.after_initialize do |app|
67
67
  config = app.config
68
68
 
69
- manifest_path = config.assets.manifest || File.join(config.paths['public'].first, config.assets.prefix)
69
+ manifest_assets_path = File.join(config.paths['public'].first, config.assets.prefix)
70
70
 
71
71
  # Configuration options that should invalidate
72
72
  # the Sprockets cache when changed.
@@ -74,8 +74,8 @@ module Sprockets
74
74
  app.assets.version,
75
75
  config.assets.version,
76
76
  config.action_controller.relative_url_root,
77
- config.action_controller.asset_host,
78
- Sprockets::Rails::VERSION,
77
+ (config.action_controller.asset_host unless config.action_controller.asset_host.respond_to?(:call)),
78
+ Sprockets::Rails::VERSION
79
79
  ].compact.join('-')
80
80
 
81
81
  # Copy config.assets.paths to Sprockets
@@ -99,9 +99,9 @@ module Sprockets
99
99
 
100
100
  if config.assets.compile
101
101
  self.assets_environment = app.assets
102
- self.assets_manifest = Sprockets::Manifest.new(app.assets, manifest_path)
102
+ self.assets_manifest = Sprockets::Manifest.new(app.assets, manifest_assets_path, config.assets.manifest)
103
103
  else
104
- self.assets_manifest = Sprockets::Manifest.new(manifest_path)
104
+ self.assets_manifest = Sprockets::Manifest.new(manifest_assets_path, config.assets.manifest)
105
105
  end
106
106
  end
107
107
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sprockets-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.3
4
+ version: 2.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua Peek
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-11 00:00:00.000000000 Z
11
+ date: 2014-09-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sprockets
@@ -120,3 +120,4 @@ signing_key:
120
120
  specification_version: 4
121
121
  summary: Sprockets Rails integration
122
122
  test_files: []
123
+ has_rdoc: