js-asset_paths 0.1.1 → 0.1.2
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/.gitignore +1 -0
- data/app/assets/javascripts/js-asset_paths.js.erb +25 -11
- data/lib/js_asset_paths/generator.rb +8 -2
- data/lib/js_asset_paths/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: fddbe746550478aa3f4dbad1c61e891af1d393f0
|
4
|
+
data.tar.gz: 576f7dd2c81dbffa9aa293925909e66f81ae0431
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 388aa20db6250b24f5c43c18f59e979978797bf7f6d63e2bc870924f584b154cdcedd42ba65a93bdc4f5b0dcfaf931a9aa8af6e3b15eaa2e189818644fb1eb47
|
7
|
+
data.tar.gz: e478efe495ef77530ce943c510e7d30eadbea080597b3ec6696cc9334c97c57d4c09f94aa62ae76ebf46026276a08adeae58678b67aee7f451a03d0ea81f236d
|
data/.gitignore
CHANGED
@@ -6,17 +6,7 @@ var PathHelper = (function(definitions) {
|
|
6
6
|
|
7
7
|
return {
|
8
8
|
assetPath: function(source, opts) {
|
9
|
-
|
10
|
-
|
11
|
-
if (opts && opts.type) {
|
12
|
-
key = [assetPublicDirectories[opts.type], key].join("/");
|
13
|
-
|
14
|
-
if (source.split(".").length === 1) {
|
15
|
-
key = [key, assetExtensions[opts.type]].join(".");
|
16
|
-
}
|
17
|
-
}
|
18
|
-
|
19
|
-
return ["assets", definitions[key] || key].join("/");
|
9
|
+
return [prefix(source), filename(source, opts)].join("/");
|
20
10
|
},
|
21
11
|
|
22
12
|
fontPath: function(source) {
|
@@ -35,4 +25,28 @@ var PathHelper = (function(definitions) {
|
|
35
25
|
return this.assetPath(source, { type: "stylesheet" });
|
36
26
|
},
|
37
27
|
};
|
28
|
+
|
29
|
+
function prefix(path) {
|
30
|
+
var prefix = path.split("/");
|
31
|
+
|
32
|
+
prefix.pop();
|
33
|
+
prefix.shift();
|
34
|
+
prefix.unshift("assets");
|
35
|
+
|
36
|
+
return prefix.join("/");
|
37
|
+
}
|
38
|
+
|
39
|
+
function filename(source, opts) {
|
40
|
+
var key = source;
|
41
|
+
|
42
|
+
if (opts && opts.type) {
|
43
|
+
key = [assetPublicDirectories[opts.type], key].join("/");
|
44
|
+
|
45
|
+
if (source.split(".").length === 1) {
|
46
|
+
key = [key, assetExtensions[opts.type]].join(".");
|
47
|
+
}
|
48
|
+
}
|
49
|
+
|
50
|
+
return definitions[key] || key.split("/").pop();
|
51
|
+
}
|
38
52
|
})(<%= JsAssetPaths::Generator.generate! %>);
|
@@ -10,12 +10,14 @@ module JsAssetPaths
|
|
10
10
|
|
11
11
|
def self.asset_hash
|
12
12
|
assets.each_file.each_with_object({}) do |filepath, memo|
|
13
|
-
|
13
|
+
relative_path = filepath.relative_path_from(base_asset_path)
|
14
|
+
|
15
|
+
memo[relative_path] = output_path(filepath) if local?(relative_path)
|
14
16
|
end
|
15
17
|
end
|
16
18
|
|
17
19
|
def self.base_asset_path
|
18
|
-
Rails.root.join('app', 'assets')
|
20
|
+
@base_asset_path || Rails.root.join('app', 'assets')
|
19
21
|
end
|
20
22
|
|
21
23
|
def self.output_path(filepath)
|
@@ -29,5 +31,9 @@ module JsAssetPaths
|
|
29
31
|
def self.assets
|
30
32
|
environment.assets
|
31
33
|
end
|
34
|
+
|
35
|
+
def self.local?(filepath)
|
36
|
+
!(filepath.to_s =~ /\.\.\//)
|
37
|
+
end
|
32
38
|
end
|
33
39
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: js-asset_paths
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sonnym
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-02-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|