guard-coffeescript 1.3.0 → 1.3.1
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.
- checksums.yaml +4 -4
- data/README.md +4 -0
- data/lib/guard/coffeescript/runner.rb +29 -3
- data/lib/guard/coffeescript/version.rb +1 -1
- data/lib/guard/coffeescript.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d29aa90eaa37f97f4e47bc98a6da2e12d9338538
|
4
|
+
data.tar.gz: 9938de4203837a8562b1d1c80544080cc49bf53d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
121
|
-
|
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
|
data/lib/guard/coffeescript.rb
CHANGED
@@ -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
|
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.
|
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-
|
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.
|
122
|
+
rubygems_version: 2.0.3
|
123
123
|
signing_key:
|
124
124
|
specification_version: 4
|
125
125
|
summary: Guard gem for CoffeeScript
|