actionview-rev_manifest 0.1.1 → 0.2.0

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: 0f8cfddd9764a05f5dc4205f91b0f513cb9d7035
4
- data.tar.gz: 15fd301b84a69424c707bcebc5b071daa524fa1e
3
+ metadata.gz: 481885e74b670eebecc555d9f797d2857745ffdf
4
+ data.tar.gz: b2b4fb55930c82c9a9c3dfd23763886539da048e
5
5
  SHA512:
6
- metadata.gz: 24cd88c4c65b39ac688dbe93bcf74aa729667e13257f2a782cec5f05bd86e9b3c96389ac42f599231474f106377c783bf8c1a0d0e91822ddf5c4063fd35db9d4
7
- data.tar.gz: f870b6368789197ae46fb9d75eedd353dce0b276d4c4718938be5fe5f5907d3ad24a0ccf93fec87b0f0c5dccdab20919263967be3250671ef31ccf652b364343
6
+ metadata.gz: ffc5a874529d219ea372931b7d322084460bbefd24ea914d2af13e6c51c38ece3c24bec3c959065150dc132b262e5c8d1c79008290a31eb61c135af92178aea4
7
+ data.tar.gz: 269dd0d2c20aae40c808f8d9fd87b136139771ad4eb6597496847593839a5ac58b4732f95827a0d6bb1f342c3491858c0cf64fcede742b64c44b0b87ec9573fa
data/README.md CHANGED
@@ -19,9 +19,30 @@ bundle install
19
19
  ## Setup
20
20
 
21
21
  ```rb
22
- #config/initializers/actionview-rev_manifest.rb
22
+ # config/environments/production.rb
23
23
 
24
- RevManifest.enabled = Rails.env.production?
24
+ MyApp::Application.config do
25
+ config.rev_manifest.enabled = true
26
+ end
27
+ ```
28
+
29
+ ### With Sprockets
30
+
31
+ If you want to serve some assets with RevManifest and rest of them with Sprockets, specify all
32
+ sources' name, which you want to serve with RevManifest, as `config.rev_manifest.sources`:
33
+
34
+ ```rb
35
+ MyApp::Application.config do
36
+ config.rev_manifest.sources = ["new_application.js", "new_application.css"]
37
+ end
38
+ ```
39
+
40
+ In addition, make sure that sprockets is loaded ahead:
41
+
42
+ ```rb
43
+ # Gemfile
44
+ gem "sprockets"
45
+ gem "actionview-rev_manifest"
25
46
  ```
26
47
 
27
48
  ## Sample gulpfile.coffee
data/Rakefile CHANGED
@@ -1 +1 @@
1
- require 'bundler/gem_tasks'
1
+ require "bundler/gem_tasks"
@@ -1,5 +1,6 @@
1
- require "rev_manifest/version"
2
1
  require "rev_manifest/actionview/base"
2
+ require "rev_manifest/railtie"
3
+ require "rev_manifest/version"
3
4
 
4
5
  module RevManifest
5
6
  DEFAULT_ASSET_PUBLIC_DIRECTORIES = {
@@ -25,7 +26,8 @@ module RevManifest
25
26
  DEFAULT_MANIFEST_PATH = "public/assets/rev-manifest.json"
26
27
 
27
28
  class << self
28
- attr_writer :enabled, :asset_prefixes, :asset_public_directories, :asset_root, :manifest_path
29
+ attr_writer :enabled, :asset_prefixes, :asset_public_directories, :asset_root, :manifest_path,
30
+ :sources
29
31
 
30
32
  # @return [true, false]
31
33
  def enabled?
@@ -37,6 +39,12 @@ module RevManifest
37
39
  @asset_public_directories || DEFAULT_ASSET_PUBLIC_DIRECTORIES
38
40
  end
39
41
 
42
+ # @return [true, false]
43
+ def include?(source)
44
+ return false unless @sources
45
+ @sources == :all ? true : @sources.include?(source)
46
+ end
47
+
40
48
  # @return [String]
41
49
  def resolve(source, options)
42
50
  asset_root + manifest[asset_prefixes[options[:type]] + source]
@@ -1,13 +1,19 @@
1
1
  module ActionView
2
2
  class Base
3
- # @note Override {ActionView::Helpers::AssetUrlHelper#compute_asset_path}.
4
- def compute_asset_path(source, options = {})
5
- if RevManifest.enabled?
6
- RevManifest.resolve(source, options)
3
+ # @note Patch {ActionView::Helpers::AssetUrlHelper#compute_asset_path}.
4
+ def compute_asset_path_with_rev_manifest(source, options = {})
5
+ if RevManifest.include?(source)
6
+ if RevManifest.enabled?
7
+ RevManifest.resolve(source, options)
8
+ else
9
+ dir = RevManifest.asset_public_directories[options[:type]] || ""
10
+ File.join(dir, source)
11
+ end
7
12
  else
8
- dir = RevManifest.asset_public_directories[options[:type]] || ""
9
- File.join(dir, source)
13
+ compute_asset_path_without_rev_manifest(source, options)
10
14
  end
11
15
  end
16
+
17
+ alias_method_chain :compute_asset_path, :rev_manifest
12
18
  end
13
19
  end
@@ -0,0 +1,13 @@
1
+ module RevManifest
2
+ class Railtie < ::Rails::Railtie
3
+ config.rev_manifest = ActiveSupport::OrderedOptions.new
4
+
5
+ config.rev_manifest.enabled = false
6
+ config.rev_manifest.sources = :all
7
+
8
+ initializer "rev_manifest.config", group: :all do |app|
9
+ RevManifest.enabled = app.config.rev_manifest.enabled
10
+ RevManifest.sources = app.config.rev_manifest.sources
11
+ end
12
+ end
13
+ end
@@ -1,3 +1,3 @@
1
1
  module RevManifest
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: actionview-rev_manifest
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuku Takahashi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-13 00:00:00.000000000 Z
11
+ date: 2015-10-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionview
@@ -82,6 +82,7 @@ files:
82
82
  - actionview-rev_manifest.gemspec
83
83
  - lib/actionview-rev_manifest.rb
84
84
  - lib/rev_manifest/actionview/base.rb
85
+ - lib/rev_manifest/railtie.rb
85
86
  - lib/rev_manifest/version.rb
86
87
  homepage: https://github.com/yuku-t/actionview-rev_manifest
87
88
  licenses: