guard-coffeescript 1.2.1 → 1.3.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.
- checksums.yaml +7 -0
- data/README.md +5 -0
- data/lib/guard/coffeescript/formatter.rb +1 -1
- data/lib/guard/coffeescript/inspector.rb +1 -1
- data/lib/guard/coffeescript/runner.rb +33 -14
- data/lib/guard/coffeescript/version.rb +1 -1
- data/lib/guard/coffeescript.rb +3 -1
- metadata +17 -64
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 24a6195fc1fff8e16472f70c0b180a438db86fb7
|
4
|
+
data.tar.gz: 2e820053adeb23a86c2519e593c7636f43ad911e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ce4e12f06fcd9c87db5ae48887e4c6bbf6ebb8da07a10f24df6e8b5adf6774b30719f99bd919453234a867d121e5b1a1401a86c9d28a4998113fa95bcc902d76
|
7
|
+
data.tar.gz: 1fb52043830f8c0791f02ef9bdc1d66f0c12b0e8104e4b5a2a1ee05b1813deb70ed9c93faaedb0133ff91a31aa73b00d98a04e0ee0bea046d0a238b82eea168a
|
data/README.md
CHANGED
@@ -178,6 +178,9 @@ There following options can be passed to Guard::CoffeeScript:
|
|
178
178
|
:shallow => true # Do not create nested output directories.
|
179
179
|
# default: false
|
180
180
|
|
181
|
+
:source_map => true # Do create the source map file.
|
182
|
+
# default: false
|
183
|
+
|
181
184
|
:hide_success => true # Disable successful compilation messages.
|
182
185
|
# default: false
|
183
186
|
|
@@ -189,6 +192,8 @@ There following options can be passed to Guard::CoffeeScript:
|
|
189
192
|
# default: false
|
190
193
|
```
|
191
194
|
|
195
|
+
The `:source_map` option needs at least CoffeeScript version 1.6.1.
|
196
|
+
|
192
197
|
### Output short notation
|
193
198
|
|
194
199
|
In addition to the standard configuration, this Guard has a short notation for configure projects with a single input
|
@@ -25,7 +25,7 @@ module Guard
|
|
25
25
|
|
26
26
|
# Tests if the file is valid.
|
27
27
|
#
|
28
|
-
# @param [String]
|
28
|
+
# @param [String] path the file
|
29
29
|
# @param [Hash] options the clean options
|
30
30
|
# @option options [String] :missing_ok don't remove missing files from list
|
31
31
|
# @return [Boolean] when the file valid
|
@@ -9,7 +9,7 @@ module Guard
|
|
9
9
|
# creates nested directories and the output file, writes the result
|
10
10
|
# to the console and triggers optional system notifications.
|
11
11
|
#
|
12
|
-
# @param [Array<String>]
|
12
|
+
# @param [Array<String>] files the spec files or directories
|
13
13
|
# @param [Array<Guard::Watcher>] watchers the Guard watchers in the block
|
14
14
|
# @param [Hash] options the options for the execution
|
15
15
|
# @option options [String] :input the input directory
|
@@ -18,6 +18,7 @@ module Guard
|
|
18
18
|
# @option options [Boolean] :shallow do not create nested directories
|
19
19
|
# @option options [Boolean] :hide_success hide success message notification
|
20
20
|
# @option options [Boolean] :noop do not generate an output file
|
21
|
+
# @option options [Boolean] :source_map generate the source map files
|
21
22
|
# @return [Array<Array<String>, Boolean>] the result for the compilation run
|
22
23
|
#
|
23
24
|
def run(files, watchers, options = { })
|
@@ -31,7 +32,7 @@ module Guard
|
|
31
32
|
# The remove function deals with CoffeeScript file removal by
|
32
33
|
# locating the output javascript file and removing it.
|
33
34
|
#
|
34
|
-
# @param [Array<String>]
|
35
|
+
# @param [Array<String>] files the spec files or directories
|
35
36
|
# @param [Array<Guard::Watcher>] watchers the Guard watchers in the block
|
36
37
|
# @param [Hash] options the options for the removal
|
37
38
|
# @option options [String] :output the output directory
|
@@ -86,8 +87,9 @@ module Guard
|
|
86
87
|
directories.each do |directory, scripts|
|
87
88
|
scripts.each do |file|
|
88
89
|
begin
|
89
|
-
|
90
|
-
changed_files << write_javascript_file(
|
90
|
+
js, map = compile(file, options)
|
91
|
+
changed_files << write_javascript_file(js, map, file, directory, options)
|
92
|
+
|
91
93
|
rescue => e
|
92
94
|
error_message = file + ': ' + e.message.to_s
|
93
95
|
|
@@ -102,17 +104,23 @@ module Guard
|
|
102
104
|
end
|
103
105
|
end
|
104
106
|
|
105
|
-
[changed_files.compact, errors]
|
107
|
+
[changed_files.flatten.compact, errors]
|
106
108
|
end
|
107
109
|
|
108
|
-
# Compile the
|
110
|
+
# Compile the CoffeeScript and generate the source map.
|
109
111
|
#
|
110
|
-
# @param [String]
|
112
|
+
# @param [String] filename the CoffeeScript file n
|
111
113
|
# @param [Hash] options the options for the execution
|
114
|
+
# @option options [Boolean] :source_map generate the source map files
|
115
|
+
# @return [Array<String, String>] the JavaScript source and the source map
|
112
116
|
#
|
113
|
-
def compile(
|
117
|
+
def compile(filename, options)
|
118
|
+
file = File.read(filename)
|
114
119
|
file_options = options_for_file(file, options)
|
115
|
-
::CoffeeScript.compile(
|
120
|
+
js = ::CoffeeScript.compile(file, file_options)
|
121
|
+
map = options[:source_map] ? ::CoffeeScript.compile(file, file_options.merge(:sourceMap => true, :filename => file)) : nil
|
122
|
+
|
123
|
+
[js, map]
|
116
124
|
end
|
117
125
|
|
118
126
|
# Gets the CoffeeScript compilation options.
|
@@ -134,19 +142,30 @@ module Guard
|
|
134
142
|
# Analyzes the CoffeeScript compilation output and creates the
|
135
143
|
# nested directories and writes the output file.
|
136
144
|
#
|
137
|
-
# @param [String]
|
145
|
+
# @param [String] js the JavaScript content
|
146
|
+
# @param [String] map the source map content
|
138
147
|
# @param [String] file the CoffeeScript file name
|
139
148
|
# @param [String] directory the output directory
|
140
149
|
# @param [Hash] options the options for the execution
|
141
150
|
# @option options [Boolean] :noop do not generate an output file
|
151
|
+
# @return [String] the JavaScript file name
|
142
152
|
#
|
143
|
-
def write_javascript_file(
|
153
|
+
def write_javascript_file(js, map, file, directory, options)
|
144
154
|
directory = Dir.pwd if !directory || directory.empty?
|
145
|
-
FileUtils.mkdir_p(File.expand_path(directory)) if !File.directory?(directory) && !options[:noop]
|
146
155
|
filename = javascript_file_name(file, directory)
|
147
|
-
File.open(File.expand_path(filename), 'w') { |f| f.write(content) } if !options[:noop]
|
148
156
|
|
149
|
-
filename
|
157
|
+
return filename if options[:noop]
|
158
|
+
|
159
|
+
FileUtils.mkdir_p(File.expand_path(directory)) if !File.directory?(directory)
|
160
|
+
File.open(File.expand_path(filename), 'w') { |f| f.write(js) }
|
161
|
+
|
162
|
+
if options[:source_map]
|
163
|
+
map_name = filename + '.map'
|
164
|
+
File.open(File.expand_path(map_name), 'w') { |f| f.write(map) }
|
165
|
+
[filename, map_name]
|
166
|
+
else
|
167
|
+
filename
|
168
|
+
end
|
150
169
|
end
|
151
170
|
|
152
171
|
# Calculates the output filename from the coffescript filename and
|
data/lib/guard/coffeescript.rb
CHANGED
@@ -19,7 +19,8 @@ module Guard
|
|
19
19
|
:hide_success => false,
|
20
20
|
:noop => false,
|
21
21
|
:error_to_js => false,
|
22
|
-
:all_on_start => false
|
22
|
+
:all_on_start => false,
|
23
|
+
:source_map => false
|
23
24
|
}
|
24
25
|
|
25
26
|
# Initialize Guard::CoffeeScript.
|
@@ -33,6 +34,7 @@ module Guard
|
|
33
34
|
# @option options [Boolean] :hide_success hide success message notification
|
34
35
|
# @option options [Boolean] :all_on_start generate all JavaScripts files on start
|
35
36
|
# @option options [Boolean] :noop do not generate an output file
|
37
|
+
# @option options [Boolean] :source_map generate the source map files
|
36
38
|
#
|
37
39
|
def initialize(watchers = [], options = {})
|
38
40
|
watchers = [] if !watchers
|
metadata
CHANGED
@@ -1,126 +1,83 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: guard-coffeescript
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
5
|
-
prerelease:
|
4
|
+
version: 1.3.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Michael Kessler
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2013-03-05 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: guard
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: 1.1.0
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - '>='
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: 1.1.0
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: coffee-script
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - '>='
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: 2.2.0
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - '>='
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: 2.2.0
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: bundler
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - '>='
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: '0'
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - '>='
|
60
53
|
- !ruby/object:Gem::Version
|
61
54
|
version: '0'
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: guard-rspec
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
|
-
- -
|
59
|
+
- - '>='
|
68
60
|
- !ruby/object:Gem::Version
|
69
61
|
version: '0'
|
70
62
|
type: :development
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
|
-
- -
|
66
|
+
- - '>='
|
76
67
|
- !ruby/object:Gem::Version
|
77
68
|
version: '0'
|
78
69
|
- !ruby/object:Gem::Dependency
|
79
70
|
name: rspec
|
80
71
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
72
|
requirements:
|
83
|
-
- -
|
73
|
+
- - '>='
|
84
74
|
- !ruby/object:Gem::Version
|
85
75
|
version: '0'
|
86
76
|
type: :development
|
87
77
|
prerelease: false
|
88
78
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
79
|
requirements:
|
91
|
-
- -
|
92
|
-
- !ruby/object:Gem::Version
|
93
|
-
version: '0'
|
94
|
-
- !ruby/object:Gem::Dependency
|
95
|
-
name: yard
|
96
|
-
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
|
-
requirements:
|
99
|
-
- - ! '>='
|
100
|
-
- !ruby/object:Gem::Version
|
101
|
-
version: '0'
|
102
|
-
type: :development
|
103
|
-
prerelease: false
|
104
|
-
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
|
-
requirements:
|
107
|
-
- - ! '>='
|
108
|
-
- !ruby/object:Gem::Version
|
109
|
-
version: '0'
|
110
|
-
- !ruby/object:Gem::Dependency
|
111
|
-
name: redcarpet
|
112
|
-
requirement: !ruby/object:Gem::Requirement
|
113
|
-
none: false
|
114
|
-
requirements:
|
115
|
-
- - ! '>='
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: '0'
|
118
|
-
type: :development
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
none: false
|
122
|
-
requirements:
|
123
|
-
- - ! '>='
|
80
|
+
- - '>='
|
124
81
|
- !ruby/object:Gem::Version
|
125
82
|
version: '0'
|
126
83
|
description: Guard::CoffeeScript automatically generates your JavaScripts from your
|
@@ -145,30 +102,26 @@ files:
|
|
145
102
|
- README.md
|
146
103
|
homepage: http://github.com/netzpirat/guard-coffeescript
|
147
104
|
licenses: []
|
105
|
+
metadata: {}
|
148
106
|
post_install_message:
|
149
107
|
rdoc_options: []
|
150
108
|
require_paths:
|
151
109
|
- lib
|
152
110
|
required_ruby_version: !ruby/object:Gem::Requirement
|
153
|
-
none: false
|
154
111
|
requirements:
|
155
|
-
- -
|
112
|
+
- - '>='
|
156
113
|
- !ruby/object:Gem::Version
|
157
114
|
version: '0'
|
158
|
-
segments:
|
159
|
-
- 0
|
160
|
-
hash: -1070839901487914149
|
161
115
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
162
|
-
none: false
|
163
116
|
requirements:
|
164
|
-
- -
|
117
|
+
- - '>='
|
165
118
|
- !ruby/object:Gem::Version
|
166
119
|
version: 1.3.6
|
167
120
|
requirements: []
|
168
121
|
rubyforge_project: guard-coffeescript
|
169
|
-
rubygems_version:
|
122
|
+
rubygems_version: 2.0.0
|
170
123
|
signing_key:
|
171
|
-
specification_version:
|
124
|
+
specification_version: 4
|
172
125
|
summary: Guard gem for CoffeeScript
|
173
126
|
test_files: []
|
174
127
|
has_rdoc:
|