coffee-rails-source-maps 1.0.0 → 1.1.0
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.
- data/README.md +10 -0
- data/lib/coffee-rails-source-maps.rb +23 -7
- data/lib/coffee-rails-source-maps/version.rb +1 -1
- metadata +3 -3
data/README.md
CHANGED
@@ -40,6 +40,16 @@ Open the Chrome console and click on the settings tab. You'll see an option to e
|
|
40
40
|
|
41
41
|
Finally to see your CoffeeScript code in the Chrome console just add a `debugger` call in your code and you'll see the CoffeeScript in your console to debug.
|
42
42
|
|
43
|
+
## Help! I'm Not Seeing Maps!
|
44
|
+
|
45
|
+
Ah, yes, I too have run into this. If you're using the asset-pipeline, and you probably are since this gem requires it. Then you need to touch your CoffeeScript files in order for the asset-pipeline to generate the map for that file. Once you do that the next time you access the file in Chrome a source map should be generated for you and you'll see it in the browser.
|
46
|
+
|
47
|
+
Good luck!
|
48
|
+
|
49
|
+
## Acknowledgements
|
50
|
+
|
51
|
+
This gem is based on the following Gist: [https://gist.github.com/naan/5096056](https://gist.github.com/naan/5096056).
|
52
|
+
|
43
53
|
## Contributing
|
44
54
|
|
45
55
|
1. Fork it
|
@@ -17,23 +17,26 @@ if Rails.env.development?
|
|
17
17
|
options[:bare] = false
|
18
18
|
end
|
19
19
|
|
20
|
+
pathname = options[:pathname]
|
21
|
+
clean_name = pathname.basename.to_s.split(".").first
|
22
|
+
|
20
23
|
# adding source maps option. (source maps option requires filename option.)
|
21
24
|
options[:sourceMap] = true
|
22
|
-
options[:filename] =
|
25
|
+
options[:filename] = "#{clean_name}.coffee"
|
23
26
|
|
24
27
|
ret = Source.context.call("CoffeeScript.compile", script, options)
|
25
28
|
|
26
|
-
|
29
|
+
rel_path = pathname.relative_path_from(Rails.root.join("app", "assets", "javascripts")).dirname
|
30
|
+
map_dir = Rails.root.join("public", "source_maps", rel_path)
|
27
31
|
map_dir.mkpath
|
28
32
|
|
29
|
-
|
30
|
-
|
31
|
-
coffee_file = map_dir.join("#{basename}.coffee")
|
33
|
+
map_file = map_dir.join("#{clean_name}.map")
|
34
|
+
coffee_file = map_dir.join("#{clean_name}.coffee")
|
32
35
|
|
33
36
|
coffee_file.open('w') {|f| f.puts script }
|
34
37
|
map_file.open('w') {|f| f.puts ret["v3SourceMap"]}
|
35
38
|
|
36
|
-
comment = "//@ sourceMappingURL
|
39
|
+
comment = "//@ sourceMappingURL=/#{map_file.relative_path_from(Rails.root.join("public"))}\n"
|
37
40
|
return comment + ret["js"]
|
38
41
|
|
39
42
|
end
|
@@ -52,4 +55,17 @@ if Rails.env.development?
|
|
52
55
|
end
|
53
56
|
end
|
54
57
|
|
55
|
-
end
|
58
|
+
end
|
59
|
+
|
60
|
+
__END__
|
61
|
+
11:06:13 web.1 | options: {:bare=>false, :pathname=>#<Pathname:/Users/markbates/Dropbox/development/vogon-next/app/assets/javascripts/controllers/authors/edit_controller.js.coffee.erb>, :sourceMap=>true, :filename=>"edit_controller.js.coffee.erb"}
|
62
|
+
11:06:13 web.1 | basename: #<Pathname:edit_controller.js.coffee.erb>
|
63
|
+
11:06:13 web.1 | map_file: #<Pathname:/Users/markbates/Dropbox/development/vogon-next/public/source_maps/edit_controller.js.coffee.erb.map>
|
64
|
+
11:06:13 web.1 | coffee_file: #<Pathname:/Users/markbates/Dropbox/development/vogon-next/public/source_maps/edit_controller.js.coffee.erb.coffee>
|
65
|
+
11:06:13 web.1 | comment: "//@ sourceMappingURL=/source_maps/edit_controller.js.coffee.erb.map\n"
|
66
|
+
|
67
|
+
11:06:13 web.1 | options: {:bare=>false, :pathname=>#<Pathname:/Users/markbates/Dropbox/development/vogon-next/app/assets/javascripts/application.js.coffee>, :sourceMap=>true, :filename=>"application.js.coffee"}
|
68
|
+
11:06:13 web.1 | basename: #<Pathname:application.js>
|
69
|
+
11:06:13 web.1 | map_file: #<Pathname:/Users/markbates/Dropbox/development/vogon-next/public/source_maps/application.js.map>
|
70
|
+
11:06:13 web.1 | coffee_file: #<Pathname:/Users/markbates/Dropbox/development/vogon-next/public/source_maps/application.js.coffee>
|
71
|
+
11:06:13 web.1 | comment: "//@ sourceMappingURL=/source_maps/application.js.map\n"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: coffee-rails-source-maps
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -74,7 +74,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
74
74
|
version: '0'
|
75
75
|
segments:
|
76
76
|
- 0
|
77
|
-
hash: -
|
77
|
+
hash: -1311622888147507941
|
78
78
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
79
|
none: false
|
80
80
|
requirements:
|
@@ -83,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
83
83
|
version: '0'
|
84
84
|
segments:
|
85
85
|
- 0
|
86
|
-
hash: -
|
86
|
+
hash: -1311622888147507941
|
87
87
|
requirements: []
|
88
88
|
rubyforge_project:
|
89
89
|
rubygems_version: 1.8.25
|