rails_external_assets 0.3.1 → 0.4.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: 1926ed5ce1ed6267703c676d14911f30dbed3403
4
- data.tar.gz: 75f38c8a4e2a76903fc251f09095755f5ca11ec2
3
+ metadata.gz: 75df987d26c4dedeb0a1f1ca9423f2568eace56d
4
+ data.tar.gz: fc0d7637e15e50864a1ee5698158fa43c3b2726d
5
5
  SHA512:
6
- metadata.gz: 1f84c321887f6e668e71b4b72629998d0cc25dd9ed4e3c15d26ced35996089ae48d4f45a0b424223ad30a15c313e7680f20bedf18b4c3a896cfbce8c0298367d
7
- data.tar.gz: e276e66331eb9fe248aa300d020839da3d4817c0a3b3c52a62e21235cd3720a26ba0e589e9711142aa29a4cf2bec65cfddbd2d0fec967497a58abde951a47973
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,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../..
3
3
  specs:
4
- rails_external_assets (0.3.0)
4
+ rails_external_assets (0.3.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -163,4 +163,4 @@ DEPENDENCIES
163
163
  web-console (~> 2.0)
164
164
 
165
165
  BUNDLED WITH
166
- 1.12.5
166
+ 1.13.6
@@ -1,33 +1,35 @@
1
1
  require 'json'
2
2
 
3
3
  module RailsExternalAssets
4
- module AssetFinder
5
- def external_asset(path)
6
- external_path = File.join(RailsExternalAssets.config.base_path, asset_path(path))
7
- block_given? ? yield(external_path) : external_path
8
- end
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
- def asset_path(path)
11
- new_path = asset_manifest[path]
12
- throw_unknown_path(path, RailsExternalAssets.config.manifest_file) unless new_path
13
- new_path
14
- end
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
- def asset_manifest
17
- manifest_file = RailsExternalAssets.config.manifest_file
18
- throw_invalid_manifest(manifest_file) unless File.file? manifest_file
19
- JSON.parse(File.read manifest_file)
20
- end
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
- private
24
+ private
24
25
 
25
- def throw_unknown_path(path, manifest_file)
26
- raise Errors::UnknownAssetManifestKey.new("No corresponding file found for \"#{path}\" in \"#{manifest_file}\".")
27
- end
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
- def throw_invalid_manifest(manifest_file)
30
- raise Errors::InvalidManifestFile.new("Manifest file, \"#{manifest_file}\", was not found.")
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 }
@@ -1,3 +1,3 @@
1
1
  module RailsExternalAssets
2
- VERSION = '0.3.1'
2
+ VERSION = '0.4.0'
3
3
  end
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.3.1
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-09 00:00:00.000000000 Z
11
+ date: 2017-01-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler