js-asset_paths 0.4.2 → 0.4.3

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: 434846a6d6beec40ebd69ae9c0b8f7fa4299a2ee
4
- data.tar.gz: ade5dc4f6bf8d7bf15e3b966c56d61cd2bbcab8f
3
+ metadata.gz: 5e8f95af4b58712151ef9f237345f0546a95d67e
4
+ data.tar.gz: 664cca57ab4041c46f36d2dfda64ea0353f009dc
5
5
  SHA512:
6
- metadata.gz: c93f6aabf1d1290b54cf506b4bd8916d46b760e31ba9b0048fd623c524de152b54a63b3ac0f790b19312be0569d53879a5cf2dcbdad670894a61b8105b32e4c8
7
- data.tar.gz: 4297496d9088efb1e6fd44a126aa284d98ca9d25ed77e4ab3498453f243b4b2de377a5776fd93f5e0c9626ec1016c04a6694073e4defcf6a1d84c5e4cd7fc7e5
6
+ metadata.gz: 7ee47050e597cde02c12e83317f7b19ca6de371290eab4d7eacb22001b9a8ed366554c6f680a64619e6aa23f4e927f94f3e1093455aaef2d4f0559c04ea3664a
7
+ data.tar.gz: 0a62de50dc0f26ddbbcb2aea49dc917638415e0a687cb64d419f75ebf6bd39e9acc4782abf4c28b56f2fb51571f3d2f090597ecad629a454eb6e9363bfff9add
@@ -0,0 +1,46 @@
1
+ <%# encoding: utf-8 %>
2
+
3
+ var PathHelper = (function(definitions) {
4
+ var assetExtensions = <%= ActionView::Helpers::AssetUrlHelper::ASSET_EXTENSIONS.to_json %>;
5
+ var assetPublicDirectories = <%= ActionView::Helpers::AssetUrlHelper::ASSET_PUBLIC_DIRECTORIES.to_json %>;
6
+
7
+ return {
8
+ assetPath: function(source, opts) {
9
+ return [prefix(source), filename(source, opts)].join("/");
10
+ },
11
+
12
+ <% JsAssetPaths::ASSET_METHODS.map(&:to_s).each_with_index do |method, i| %>
13
+ <%= "#{method.split('_').first}Path: function(source) {" %>
14
+ <%= %Q(return this.assetPath(source, { type: "#{method.split('_').first}" });) %>
15
+ <%= "}#{',' unless i == JsAssetPaths::ASSET_METHODS.count - 1}" %>
16
+ <% end %>
17
+ };
18
+
19
+ function prefix(path) {
20
+ var prefix = path.split("/");
21
+
22
+ prefix.pop();
23
+ prefix.shift();
24
+ prefix.unshift("assets");
25
+
26
+ return prefix.join("/");
27
+ }
28
+
29
+ function filename(source, opts) {
30
+ var key = source;
31
+
32
+ if (opts && opts.type) {
33
+ key = [assetPublicDirectories[opts.type], key].join("/");
34
+
35
+ if (source.split(".").length === 1) {
36
+ key = [key, assetExtensions[opts.type]].join(".");
37
+ }
38
+ }
39
+
40
+ if (definitions[key]) {
41
+ return definitions[key];
42
+ } else {
43
+ throw "Unknown asset '" + key + "'. If you created it recently, you may need to restart Rails.";
44
+ }
45
+ }
46
+ })(<%= JsAssetPaths::Generator.generate! %>);
@@ -1,3 +1,3 @@
1
1
  module JsAssetPaths
2
- VERSION = '0.4.2'
2
+ VERSION = '0.4.3'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: js-asset_paths
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sonny Michaud
@@ -135,6 +135,7 @@ executables: []
135
135
  extensions: []
136
136
  extra_rdoc_files: []
137
137
  files:
138
+ - app/assets/javascripts/js-asset_paths.js.erb
138
139
  - lib/js-asset_paths.rb
139
140
  - lib/js_asset_paths.rb
140
141
  - lib/js_asset_paths/engine.rb