guard-coffeescript 1.3.0 → 1.3.1

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: 24a6195fc1fff8e16472f70c0b180a438db86fb7
4
- data.tar.gz: 2e820053adeb23a86c2519e593c7636f43ad911e
3
+ metadata.gz: d29aa90eaa37f97f4e47bc98a6da2e12d9338538
4
+ data.tar.gz: 9938de4203837a8562b1d1c80544080cc49bf53d
5
5
  SHA512:
6
- metadata.gz: ce4e12f06fcd9c87db5ae48887e4c6bbf6ebb8da07a10f24df6e8b5adf6774b30719f99bd919453234a867d121e5b1a1401a86c9d28a4998113fa95bcc902d76
7
- data.tar.gz: 1fb52043830f8c0791f02ef9bdc1d66f0c12b0e8104e4b5a2a1ee05b1813deb70ed9c93faaedb0133ff91a31aa73b00d98a04e0ee0bea046d0a238b82eea168a
6
+ metadata.gz: 50d48e75f299611a4abb6725b04419b947b8dd4a1468cdaf12820713f36a8065d605a241682046eead976337cfe964d5e69a1b7ba3da4238255b548a81c25596
7
+ data.tar.gz: 9cdd0abe9754a97c7c301252ed78099c0d2bc9dacdf16e58dcba431be02820a472fd18881540c48d75976c6ea3cccec2f3d567928ad1c1bc3d786585642cee3a
data/README.md CHANGED
@@ -181,6 +181,10 @@ There following options can be passed to Guard::CoffeeScript:
181
181
  :source_map => true # Do create the source map file.
182
182
  # default: false
183
183
 
184
+ :source_root => 'coffeescripts' # Root path for coffeescript sources.
185
+ # Used in source map to determine root URL for all sources
186
+ # default: nil (using the `:input` directory)
187
+
184
188
  :hide_success => true # Disable successful compilation messages.
185
189
  # default: false
186
190
 
@@ -117,8 +117,13 @@ module Guard
117
117
  def compile(filename, options)
118
118
  file = File.read(filename)
119
119
  file_options = options_for_file(file, options)
120
- js = ::CoffeeScript.compile(file, file_options)
121
- map = options[:source_map] ? ::CoffeeScript.compile(file, file_options.merge(:sourceMap => true, :filename => file)) : nil
120
+ if options[:source_map]
121
+ file_options.merge! options_for_source_map(filename, options)
122
+ result = ::CoffeeScript.compile(file, file_options)
123
+ js, map = result['js'], result['v3SourceMap']
124
+ else
125
+ js = ::CoffeeScript.compile(file, file_options)
126
+ end
122
127
 
123
128
  [js, map]
124
129
  end
@@ -139,6 +144,23 @@ module Guard
139
144
  file_options
140
145
  end
141
146
 
147
+ # Gets the CoffeeScript source map options.
148
+ #
149
+ # @param [String] filename the CoffeeScript filename
150
+ # @param [Hash] options the options for the execution
151
+ #
152
+ def options_for_source_map(filename, options)
153
+ # if :input was provided, make all filenames relative to that
154
+ filename = Pathname.new(filename).relative_path_from(Pathname.new(options[:input])).to_s if options[:input]
155
+
156
+ {
157
+ :sourceMap => true,
158
+ :generatedFile => filename.gsub(/(js\.coffee|coffee)$/, 'js'),
159
+ :sourceFiles => [filename],
160
+ :sourceRoot => options[:source_root] || options[:input] || '',
161
+ }
162
+ end
163
+
142
164
  # Analyzes the CoffeeScript compilation output and creates the
143
165
  # nested directories and writes the output file.
144
166
  #
@@ -156,11 +178,15 @@ module Guard
156
178
 
157
179
  return filename if options[:noop]
158
180
 
181
+ if options[:source_map]
182
+ map_name = filename + '.map'
183
+ js += "\n/*\n//@ sourceMappingURL=#{File.basename(map_name)}\n*/\n"
184
+ end
185
+
159
186
  FileUtils.mkdir_p(File.expand_path(directory)) if !File.directory?(directory)
160
187
  File.open(File.expand_path(filename), 'w') { |f| f.write(js) }
161
188
 
162
189
  if options[:source_map]
163
- map_name = filename + '.map'
164
190
  File.open(File.expand_path(map_name), 'w') { |f| f.write(map) }
165
191
  [filename, map_name]
166
192
  else
@@ -1,6 +1,6 @@
1
1
  module Guard
2
2
  module CoffeeScriptVersion
3
3
  # Guard::CoffeeScript version that is used for the Gem specification
4
- VERSION = '1.3.0'
4
+ VERSION = '1.3.1'
5
5
  end
6
6
  end
@@ -42,7 +42,7 @@ module Guard
42
42
 
43
43
  if options[:input]
44
44
  defaults.merge!({ :output => options[:input] })
45
- watchers << ::Guard::Watcher.new(%r{^#{ options.delete(:input) }/(.+\.coffee)$})
45
+ watchers << ::Guard::Watcher.new(%r{^#{ options[:input] }/(.+\.coffee)$})
46
46
  end
47
47
 
48
48
  super(watchers, defaults.merge(options))
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guard-coffeescript
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Kessler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-03-05 00:00:00.000000000 Z
11
+ date: 2013-05-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: guard
@@ -119,7 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
119
119
  version: 1.3.6
120
120
  requirements: []
121
121
  rubyforge_project: guard-coffeescript
122
- rubygems_version: 2.0.0
122
+ rubygems_version: 2.0.3
123
123
  signing_key:
124
124
  specification_version: 4
125
125
  summary: Guard gem for CoffeeScript