assets_precompile_enforcer 1.0.5 → 1.1.0

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.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZTU5MGVjZjhhMTQ0ZmM1NTc0NTI5OTMyNjEyZDVmM2U5YTk2ZDFhOA==
5
+ data.tar.gz: !binary |-
6
+ ODIyN2QwYzhiZmNhMmEyYTgyM2JhMzAwYWUwMDQ1NDBjOTdjMDYzNw==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ YTI0ZmJhNjI0ZWE0MTAzMDg5MDUxMDk3NjhjODI3NDUyZDhkZjBhZWIxN2Zl
10
+ ZDcxMTg3NDJjYTcyMmUzZWVjZmJmODQ5ZjYwNzA0ZjE0NjVmNzkyZGM3NGU4
11
+ MDI3MTU0NjY2MjBkOGU1ZDgzOTA3ZDhiNWQ5MzVlYjE3ZjU0MDQ=
12
+ data.tar.gz: !binary |-
13
+ ZDJlODdiYThkZDc0ZGU3MWY2MTc1YmU1NDZhNDJhZWZkNDJhZWVkMWMwNGQx
14
+ NDFiNGY3MGYyNzAxZGIyOTYzNjViYzA0Mjk1YjYzZjNiN2IxNTAwZTM5YjNk
15
+ OWM1ZTFkMDdiYmVlOGE0NTdmY2UwNzE2ZWIyYWY1MzI3ZWYxYWY=
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Assets Precompile Enforcer
2
2
 
3
3
  This gem ensures that developers won't forget to add assets to `config.assets.precompile` while they are developing.
4
- An exception will be raised if you include an asset via `javascript_include_tag` or `stylesheet_link_tag`,
4
+ An exception will be raised if you include an asset via `javascript_include_tag` or `stylesheet_link_tag`,
5
5
  and it doesn't match a filter in `config.assets.precompile`.
6
6
 
7
7
  ## Installation
@@ -33,6 +33,13 @@ You also need to add the following line to `config/environments/development.rb`:
33
33
  You will need to restart your Rails server whenever you make any changes to `config.assets.precompile`.
34
34
 
35
35
 
36
+ ## Behavior
37
+
38
+ Whenever you call `javascript_include_tag` or `stylesheet_link_tag` for an asset that doesn't exist in the `config.assets.precompile` array, Rails will throw an error in your development environment:
39
+
40
+ <asset file> must be added to config.assets.precompile, otherwise it won't be precompiled for production!
41
+
42
+
36
43
  ## Advanced Usage
37
44
 
38
45
  To avoid restarting your server when you change `config.assets.precompile`, add the following lines to `config/application.rb`:
@@ -43,7 +50,7 @@ To avoid restarting your server when you change `config.assets.precompile`, add
43
50
  config.watchable_files << 'config/assets_precompile.rb'
44
51
 
45
52
  Then move your `config.assets.precompile` settings to a new file at `config/assets_precompile.rb`:
46
-
53
+
47
54
  # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
48
55
  assets = Rails.application.config.assets
49
56
  assets.precompile = assets.original_precompile + %w( extra_assets.js )
@@ -51,6 +58,13 @@ Then move your `config.assets.precompile` settings to a new file at `config/asse
51
58
  Now you will be able to make changes to `config/assets_precompile.rb` without needing to restart your server.
52
59
 
53
60
 
61
+ You can also configure a custom error message so that other developers know where to register their missing assets:
62
+
63
+ ```ruby
64
+ config.assets.precompile_error_message_proc = -> asset_file { "#{File.basename(asset_file)} must be added to `config/assets_precompile.rb`, otherwise it won't be precompiled for production!" }
65
+ ```
66
+
67
+
54
68
  ## Contributing
55
69
 
56
70
  1. Fork it
@@ -1,5 +1,6 @@
1
1
  require "assets_precompile_enforcer/version"
2
2
 
3
- unless defined?(Rake)
3
+ # Needs to be disabled for Konacha
4
+ unless defined?(Konacha)
4
5
  require "assets_precompile_enforcer/sprockets/helpers/rails_helper"
5
- end
6
+ end
@@ -41,11 +41,19 @@ module Sprockets
41
41
  return if asset_paths.is_uri?(source)
42
42
  asset_file = asset_environment.resolve(asset_paths.rewrite_extension(source, nil, ext))
43
43
  unless asset_environment.send(:logical_path_for_filename, asset_file, asset_list)
44
- raise AssetPaths::AssetNotPrecompiledError.new("#{asset_file} must be added to config.assets.precompile, " <<
45
- "otherwise it won't be precompiled for production!")
44
+
45
+ # Allow user to define a custom error message
46
+ error_message_proc = Rails.application.config.assets.precompile_error_message_proc
47
+
48
+ error_message = if error_message_proc
49
+ error_message_proc.call(asset_file)
50
+ else
51
+ "#{File.basename(asset_file)} must be added to config.assets.precompile, otherwise it won't be precompiled for production!"
52
+ end
53
+
54
+ raise AssetPaths::AssetNotPrecompiledError.new(error_message)
46
55
  end
47
56
  end
48
-
49
57
  end
50
58
  end
51
59
  end
@@ -1,3 +1,3 @@
1
1
  module AssetsPrecompileEnforcer
2
- VERSION = "1.0.5"
2
+ VERSION = "1.1.0"
3
3
  end
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: assets_precompile_enforcer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
5
- prerelease:
4
+ version: 1.1.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Nathan Broadbent
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-07-03 00:00:00.000000000 Z
11
+ date: 2013-11-19 00:00:00.000000000 Z
13
12
  dependencies: []
14
13
  description: Raises an exception if assets are missing from config.assets.precompile
15
14
  during development
@@ -31,32 +30,25 @@ files:
31
30
  homepage: https://github.com/ndbroadbent/assets_precompile_enforcer
32
31
  licenses:
33
32
  - MIT
33
+ metadata: {}
34
34
  post_install_message:
35
35
  rdoc_options: []
36
36
  require_paths:
37
37
  - lib
38
38
  required_ruby_version: !ruby/object:Gem::Requirement
39
- none: false
40
39
  requirements:
41
40
  - - ! '>='
42
41
  - !ruby/object:Gem::Version
43
42
  version: '0'
44
- segments:
45
- - 0
46
- hash: -2970029651410170092
47
43
  required_rubygems_version: !ruby/object:Gem::Requirement
48
- none: false
49
44
  requirements:
50
45
  - - ! '>='
51
46
  - !ruby/object:Gem::Version
52
47
  version: '0'
53
- segments:
54
- - 0
55
- hash: -2970029651410170092
56
48
  requirements: []
57
49
  rubyforge_project:
58
- rubygems_version: 1.8.24
50
+ rubygems_version: 2.0.5
59
51
  signing_key:
60
- specification_version: 3
52
+ specification_version: 4
61
53
  summary: Enforces config.assets.precompile in development
62
54
  test_files: []