rails_external_assets 0.3.1 → 0.4.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/README.md +1 -1
- data/examples/webpack/Gemfile.lock +2 -2
- data/lib/rails_external_assets/asset_finder.rb +23 -21
- data/lib/rails_external_assets/rails/view_helpers.rb +3 -5
- data/lib/rails_external_assets/sprockets/directive_processor.rb +3 -5
- data/lib/rails_external_assets/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 75df987d26c4dedeb0a1f1ca9423f2568eace56d
|
4
|
+
data.tar.gz: fc0d7637e15e50864a1ee5698158fa43c3b2726d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed66d25349d5c8ebabce0bd3cda9fe08c603bc90270bbbe6ef2416a0bfbad4891a3464ab930741b67d4dcdce810095051ab218b532777757a4a419f6dd942c70
|
7
|
+
data.tar.gz: 5e397b9fc5e03c6d6ce7187d42cf544fe34781f7e51c4ec19924a645b55f3fed0d1a62e20bede5e78c9988a0f516e07e4858beaceaceeaf98b90c3a7b0a7da75
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 0.4.0 (2017-1-10)
|
4
|
+
|
5
|
+
Fixed:
|
6
|
+
|
7
|
+
- Sprockets methods like `asset_path` are no longer accidentally overloaded by methods in the `RailsExternalAssets::AssetFinder` module. [a426a4d](../../commit/a426a4d)
|
8
|
+
|
9
|
+
Changed:
|
10
|
+
|
11
|
+
- The `RailsExternalAssets::AssetFinder` is now a class instead of a module. The method names are the same as they were in the module, but they are now class methods. This won't break anything unless you were manually using the module yourself. [a426a4d](../../commit/a426a4d)
|
12
|
+
|
3
13
|
## 0.3.1 (2017-1-9)
|
4
14
|
|
5
15
|
Fixed:
|
data/README.md
CHANGED
@@ -91,7 +91,7 @@ This will include the first two JS assets, `normalAsset` and `anotherAsset` from
|
|
91
91
|
|
92
92
|
## With Plain Ruby
|
93
93
|
|
94
|
-
`RailsExternalAssets::AssetFinder` provides three methods for your disposal.
|
94
|
+
The `RailsExternalAssets::AssetFinder` class provides three class methods for your disposal.
|
95
95
|
|
96
96
|
`asset_path` takes a path to an external asset file, and returns the corresponding built asset path by looking up the key in the asset manifest JSON file.
|
97
97
|
|
@@ -1,33 +1,35 @@
|
|
1
1
|
require 'json'
|
2
2
|
|
3
3
|
module RailsExternalAssets
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
class AssetFinder
|
5
|
+
class << self
|
6
|
+
def external_asset(path)
|
7
|
+
external_path = File.join(RailsExternalAssets.config.base_path, asset_path(path))
|
8
|
+
block_given? ? yield(external_path) : external_path
|
9
|
+
end
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
def asset_path(path)
|
12
|
+
new_path = asset_manifest[path]
|
13
|
+
throw_unknown_path(path, RailsExternalAssets.config.manifest_file) unless new_path
|
14
|
+
new_path
|
15
|
+
end
|
15
16
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
17
|
+
def asset_manifest
|
18
|
+
manifest_file = RailsExternalAssets.config.manifest_file
|
19
|
+
throw_invalid_manifest(manifest_file) unless File.file? manifest_file
|
20
|
+
JSON.parse(File.read manifest_file)
|
21
|
+
end
|
21
22
|
|
22
23
|
|
23
|
-
|
24
|
+
private
|
24
25
|
|
25
|
-
|
26
|
-
|
27
|
-
|
26
|
+
def throw_unknown_path(path, manifest_file)
|
27
|
+
raise Errors::UnknownAssetManifestKey.new("No corresponding file found for \"#{path}\" in \"#{manifest_file}\".")
|
28
|
+
end
|
28
29
|
|
29
|
-
|
30
|
-
|
30
|
+
def throw_invalid_manifest(manifest_file)
|
31
|
+
raise Errors::InvalidManifestFile.new("Manifest file, \"#{manifest_file}\", was not found.")
|
32
|
+
end
|
31
33
|
end
|
32
34
|
end
|
33
35
|
end
|
@@ -1,22 +1,20 @@
|
|
1
1
|
module RailsExternalAssets
|
2
2
|
module Rails
|
3
3
|
module ViewHelpers
|
4
|
-
include RailsExternalAssets::AssetFinder
|
5
|
-
|
6
4
|
def external_asset_js(path)
|
7
5
|
ext_name = File.extname(path)
|
8
6
|
ext = ext_name.empty? ? '.js' : ''
|
9
|
-
external_asset("#{path}#{ext}") { |p| javascript_include_tag p }
|
7
|
+
RailsExternalAssets::AssetFinder.external_asset("#{path}#{ext}") { |p| javascript_include_tag p }
|
10
8
|
end
|
11
9
|
|
12
10
|
def external_asset_css(path)
|
13
11
|
ext_name = File.extname(path)
|
14
12
|
ext = ext_name.empty? ? '.css' : ''
|
15
|
-
external_asset("#{path}#{ext}") { |p| stylesheet_link_tag p }
|
13
|
+
RailsExternalAssets::AssetFinder.external_asset("#{path}#{ext}") { |p| stylesheet_link_tag p }
|
16
14
|
end
|
17
15
|
|
18
16
|
def external_asset_img(path)
|
19
|
-
external_asset(path) { |p| image_tag p }
|
17
|
+
RailsExternalAssets::AssetFinder.external_asset(path) { |p| image_tag p }
|
20
18
|
end
|
21
19
|
end
|
22
20
|
end
|
@@ -1,24 +1,22 @@
|
|
1
1
|
module RailsExternalAssets
|
2
2
|
module Sprockets
|
3
3
|
class DirectiveProcessor < ::Sprockets::DirectiveProcessor
|
4
|
-
include RailsExternalAssets::AssetFinder
|
5
|
-
|
6
4
|
def process_external_require_directive(path)
|
7
5
|
ext_name = File.extname(path)
|
8
6
|
ext = ext_name.empty? ? file_extension : ''
|
9
|
-
new_path = asset_path("#{path}#{ext}")
|
7
|
+
new_path = RailsExternalAssets::AssetFinder.asset_path("#{path}#{ext}")
|
10
8
|
process_require_directive new_path
|
11
9
|
end
|
12
10
|
|
13
11
|
def process_external_require_directory_directive(path)
|
14
|
-
selected_paths = asset_manifest.keys
|
12
|
+
selected_paths = RailsExternalAssets::AssetFinder.asset_manifest.keys
|
15
13
|
.select { |key| key.match "#{File.join(path, '[^/]+\..+')}" }
|
16
14
|
.select { |path| File.extname(path) == file_extension }
|
17
15
|
selected_paths.each { |path| process_external_require_directive path }
|
18
16
|
end
|
19
17
|
|
20
18
|
def process_external_require_tree_directive(path)
|
21
|
-
selected_paths = asset_manifest.keys
|
19
|
+
selected_paths = RailsExternalAssets::AssetFinder.asset_manifest.keys
|
22
20
|
.select { |key| key.match File.join(path) }
|
23
21
|
.select { |path| File.extname(path) == file_extension }
|
24
22
|
selected_paths.each { |path| process_external_require_directive path }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_external_assets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Lehman
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-01-
|
11
|
+
date: 2017-01-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|