coffee-rails-source-maps 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +5 -0
- data/lib/coffee-rails-source-maps.rb +29 -34
- data/lib/coffee-rails-source-maps/version.rb +1 -1
- metadata +4 -4
data/README.md
CHANGED
@@ -57,3 +57,8 @@ This gem is based on the following Gist: [https://gist.github.com/naan/5096056](
|
|
57
57
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
58
58
|
4. Push to the branch (`git push origin my-new-feature`)
|
59
59
|
5. Create new Pull Request
|
60
|
+
|
61
|
+
## Contributers
|
62
|
+
|
63
|
+
* Mark Bates
|
64
|
+
* Thomas Walpole
|
@@ -18,27 +18,35 @@ if Rails.env.development?
|
|
18
18
|
end
|
19
19
|
|
20
20
|
pathname = options[:pathname]
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
21
|
+
if pathname.nil?
|
22
|
+
return Source.context.call("CoffeeScript.compile", script, options)
|
23
|
+
else
|
24
|
+
clean_name = pathname.basename.to_s.split(".").first
|
25
|
+
# adding source maps option. (source maps option requires filename option.)
|
26
|
+
options[:sourceMap] = true
|
27
|
+
options[:filename] = "#{clean_name}.coffee"
|
28
|
+
|
29
|
+
ret = Source.context.call("CoffeeScript.compile", script, options)
|
30
|
+
|
31
|
+
rel_path = if pathname.to_s.start_with?(Bundler.bundle_path.to_s)
|
32
|
+
Pathname('bundler').join(pathname.relative_path_from(Bundler.bundle_path)).dirname
|
33
|
+
else
|
34
|
+
pathname.relative_path_from(Rails.root.join("app", "assets", "javascripts")).dirname
|
35
|
+
end
|
36
|
+
|
37
|
+
map_dir = Rails.root.join("public", "source_maps", rel_path)
|
38
|
+
map_dir.mkpath
|
39
|
+
|
40
|
+
map_file = map_dir.join("#{clean_name}.map")
|
41
|
+
coffee_file = map_dir.join("#{clean_name}.coffee")
|
42
|
+
|
43
|
+
coffee_file.open('w') {|f| f.puts script }
|
44
|
+
map_file.open('w') {|f| f.puts ret["v3SourceMap"]}
|
45
|
+
|
46
|
+
comment = "//@ sourceMappingURL=/#{map_file.relative_path_from(Rails.root.join("public"))}\n"
|
47
|
+
return comment + ret['js']
|
48
|
+
end
|
49
|
+
|
42
50
|
end
|
43
51
|
|
44
52
|
end
|
@@ -56,16 +64,3 @@ if Rails.env.development?
|
|
56
64
|
end
|
57
65
|
|
58
66
|
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.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-03-
|
12
|
+
date: 2013-03-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: coffee-script-source
|
@@ -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: -2983782829991757151
|
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: -2983782829991757151
|
87
87
|
requirements: []
|
88
88
|
rubyforge_project:
|
89
89
|
rubygems_version: 1.8.25
|