coffee-rails-source-paths 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/coffee-rails-source-maps.rb +13 -10
- data/lib/coffee-rails-source-maps/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: 40034dd2af17e908723825efaef6804d273bdd8b
|
4
|
+
data.tar.gz: 5dff131821fb72330181677566e1c288363b199e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 557b582925cd1752bddb6a73014ed718036288896d06ac2668521889b218ca9bf88de99aabb2907b9af983823d8fcec4f217fbb4728109dec362f98ccb0981fd
|
7
|
+
data.tar.gz: e2279961089a17301d39d68a13eff939ca61133c3dc599c13881fd2a9514384ae2e103840712f345b8498cdcc2645223254b341ba7b69865fb58ecfb15ae95c4
|
@@ -4,7 +4,7 @@ require "coffee-rails-source-maps/version"
|
|
4
4
|
# config/initializers/source_maps.rb
|
5
5
|
|
6
6
|
if Rails.env.development?
|
7
|
-
require
|
7
|
+
require 'coffee-script' #make sure CoffeeScript is loaded before we overwrite it.
|
8
8
|
module CoffeeScript
|
9
9
|
|
10
10
|
class << self
|
@@ -24,13 +24,14 @@ if Rails.env.development?
|
|
24
24
|
else
|
25
25
|
clean_name = pathname.basename.to_s.split(".").first
|
26
26
|
|
27
|
+
|
27
28
|
rel_path = if pathname.to_s.start_with?(Bundler.bundle_path.to_s)
|
28
|
-
Pathname('bundler').join(pathname.relative_path_from(Bundler.bundle_path))
|
29
|
+
Pathname('bundler').join(pathname.relative_path_from(Bundler.bundle_path))
|
29
30
|
else
|
30
|
-
pathname.relative_path_from(Rails.root)
|
31
|
+
pathname.relative_path_from(Rails.root)
|
31
32
|
end
|
32
33
|
|
33
|
-
map_dir = Rails.root.join("public/" + Rails.configuration.assets.prefix, "source_maps", rel_path)
|
34
|
+
map_dir = Rails.root.join("public/" + Rails.configuration.assets.prefix, "source_maps", rel_path.dirname)
|
34
35
|
map_dir.mkpath
|
35
36
|
|
36
37
|
map_file = map_dir.join("#{clean_name}.map")
|
@@ -54,17 +55,19 @@ if Rails.env.development?
|
|
54
55
|
})
|
55
56
|
WRAPPER
|
56
57
|
|
57
|
-
|
58
|
-
ret = Source.context.call(wrapper,
|
58
|
+
source_path = "rootScope = angular.element(document).scope()\nrootScope.$apply(-> rootScope.sourcePath = '#{rel_path}') if rootScope\n"
|
59
|
+
ret = Source.context.call(wrapper, source_path + script, options)
|
60
|
+
javascript = ret['js']
|
61
|
+
controller_declaration_rg = /\.controller\(.+ {/
|
62
|
+
javascript.gsub!(controller_declaration_rg, '\0' + " $scope._sourcePath = '#{rel_path}';")
|
63
|
+
link_declaration_rg = /link: function\(scope.+{/
|
64
|
+
javascript.gsub!(link_declaration_rg, '\0' + " scope._sourcePath = '#{rel_path}';")
|
59
65
|
|
60
|
-
puts file_path
|
61
66
|
coffee_file.open('w') {|f| f.puts script }
|
62
67
|
map_file.open('w') {|f| f.puts ret["v3SourceMap"]}
|
63
68
|
|
64
69
|
comment = "//# sourceMappingURL=/#{map_file.relative_path_from(Rails.root.join("public"))}\n"
|
65
|
-
|
66
|
-
# This will add file source that can be used in directives or controllers
|
67
|
-
return file_path + ret['js'] + comment
|
70
|
+
return javascript + comment
|
68
71
|
end
|
69
72
|
|
70
73
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: coffee-rails-source-paths
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Damian Trojnar
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-09-
|
11
|
+
date: 2015-09-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: coffee-script-source
|