js_assets 0.0.2 → 0.0.3
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/lib/js_assets/list.rb +28 -29
- data/lib/js_assets/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 237eaf5e9692bb47d8c034053b37d0157fe91598
|
4
|
+
data.tar.gz: 37103bc00378399fa92e7feefbbcf256df0a523b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d35409b898d09e36c1898ee5214a8770509d96cb9061f09aab57a7785048b43fff5dc9a05c1a4ed3bcaff1a108780e9e00e9469dbb8a64279c2428cb0eb78653
|
7
|
+
data.tar.gz: 070b623a1982ae03f36983748d2b720a46d610b56fe5ccd4e4be84d8c09178b072d715b994ce4aef8cfd147c80d34a746046e1f0b8d756d01724d20fe4f9f210
|
data/lib/js_assets/list.rb
CHANGED
@@ -2,41 +2,40 @@ module JsAssets
|
|
2
2
|
class List
|
3
3
|
class << self
|
4
4
|
attr_accessor :exclude, :allow
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
end
|
5
|
+
end
|
6
|
+
@exclude = ['application.js']
|
7
|
+
@allow = ['*.html']
|
8
|
+
def self.fetch
|
9
|
+
project_assets = {}
|
10
|
+
assets_filters = ::Rails.application.config.assets.precompile
|
11
|
+
::Rails.application.assets.each_file do |filename|
|
12
|
+
if logical_path = ::Rails.application.assets.send(:logical_path_for_filename, filename, assets_filters)
|
13
|
+
next if matches_filter(@exclude, logical_path, filename)
|
14
|
+
next unless matches_filter(@allow, logical_path, filename)
|
15
|
+
project_assets[logical_path] = ::ApplicationController.helpers.asset_path(logical_path)
|
17
16
|
end
|
18
|
-
return project_assets
|
19
17
|
end
|
18
|
+
return project_assets
|
19
|
+
end
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
21
|
+
protected
|
22
|
+
# from
|
23
|
+
# https://github.com/sstephenson/sprockets/blob/master/lib/sprockets/base.rb:418
|
24
|
+
def self.matches_filter(filters, logical_path, filename)
|
25
|
+
return true if filters.nil? || filters.empty?
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
else
|
34
|
-
filter.call(logical_path, filename.to_s)
|
35
|
-
end
|
27
|
+
filters.any? do |filter|
|
28
|
+
if filter.is_a?(Regexp)
|
29
|
+
filter.match(logical_path)
|
30
|
+
elsif filter.respond_to?(:call)
|
31
|
+
if filter.arity == 1
|
32
|
+
filter.call(logical_path)
|
36
33
|
else
|
37
|
-
|
38
|
-
File.fnmatch(filter.to_s, logical_path)
|
34
|
+
filter.call(logical_path, filename.to_s)
|
39
35
|
end
|
36
|
+
else
|
37
|
+
# puts filter
|
38
|
+
File.fnmatch(filter.to_s, logical_path)
|
40
39
|
end
|
41
40
|
end
|
42
41
|
end
|
data/lib/js_assets/version.rb
CHANGED