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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 357925324638cdab20f5c2da6181287eaee7f525
4
- data.tar.gz: 91f6994e85409428d08a1a97194544a9332a45c9
3
+ metadata.gz: 40034dd2af17e908723825efaef6804d273bdd8b
4
+ data.tar.gz: 5dff131821fb72330181677566e1c288363b199e
5
5
  SHA512:
6
- metadata.gz: 7ceccc59b66c32e98efc15a144021c722b70adbb43b3bac274d04d753c4fed2110df13a5fb18203bd5e241cf26b4dee433a7dbfb5a2ca15ef37a9cb9ecac8ab8
7
- data.tar.gz: b166352f0b80b6e0021520f9fcc6b6a57ba5c6e81efb3da9619a23480814f6d4f2ee680902a798100ab8bdee9a1a694b340f3f8e1eca9d42fe55028b6bc81f84
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 "coffee-script" # make sure CoffeeScript is loaded before we overwrite it.
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)).dirname
29
+ Pathname('bundler').join(pathname.relative_path_from(Bundler.bundle_path))
29
30
  else
30
- pathname.relative_path_from(Rails.root).dirname
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
- file_path = "var sourcePath='#{rel_path}';\n"
58
- ret = Source.context.call(wrapper, file_path + script, options)
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
- comment += "//# Hello :)\n"
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
@@ -1,3 +1,3 @@
1
1
  module CoffeeRailsSourceMaps
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  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
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-02 00:00:00.000000000 Z
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