js-asset_paths 0.1.1 → 0.1.2

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: e71a626267813a44330759040855bb79398c4514
4
- data.tar.gz: 7f5eb2009ca8e56139a9a6773adbbbcf3bf46760
3
+ metadata.gz: fddbe746550478aa3f4dbad1c61e891af1d393f0
4
+ data.tar.gz: 576f7dd2c81dbffa9aa293925909e66f81ae0431
5
5
  SHA512:
6
- metadata.gz: cbdffe97506147d167c8bc663bb02f89125489aabc834891d4848828acc26619a58cdb3df9c1cd88e1e5d77aa65769edadf16a7243385ce08fcbfaee86a664a9
7
- data.tar.gz: cf25c74fff2c6e119903c3cae150bfedc46aea4b5282911fc19d0184a2a0fdf338e75dd8931d8a6e63cbc3b6a02c3e98677dab1ec1c83d6e634e9468e3d9081a
6
+ metadata.gz: 388aa20db6250b24f5c43c18f59e979978797bf7f6d63e2bc870924f584b154cdcedd42ba65a93bdc4f5b0dcfaf931a9aa8af6e3b15eaa2e189818644fb1eb47
7
+ data.tar.gz: e478efe495ef77530ce943c510e7d30eadbea080597b3ec6696cc9334c97c57d4c09f94aa62ae76ebf46026276a08adeae58678b67aee7f451a03d0ea81f236d
data/.gitignore CHANGED
@@ -1 +1,2 @@
1
1
  Gemfile.lock
2
+ *.gem
@@ -6,17 +6,7 @@ var PathHelper = (function(definitions) {
6
6
 
7
7
  return {
8
8
  assetPath: function(source, opts) {
9
- var key = source;
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
- memo[filepath.relative_path_from(base_asset_path)] = output_path(filepath)
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
@@ -1,3 +1,3 @@
1
1
  module JsAssetPaths
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'
3
3
  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.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-01-02 00:00:00.000000000 Z
11
+ date: 2014-02-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails