guard-coffeescript 0.3.3 → 0.4.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 CHANGED
@@ -2,11 +2,12 @@
2
2
 
3
3
  ![travis-ci](http://travis-ci.org/netzpirat/guard-coffeescript.png)
4
4
 
5
- Guard::CoffeeScript compiles you CoffeeScripts automatically when files are modified.
5
+ Guard::CoffeeScript compiles or validates your CoffeeScripts automatically when files are modified.
6
6
 
7
7
  Tested on MRI Ruby 1.8.7, 1.9.2 and the latest versions of JRuby & Rubinius.
8
8
 
9
- If you have any questions please join us on our [Google group](http://groups.google.com/group/guard-dev) or on `#guard` (irc.freenode.net).
9
+ If you have any questions please join us on our [Google group](http://groups.google.com/group/guard-dev) or on `#guard`
10
+ (irc.freenode.net).
10
11
 
11
12
  ## Install
12
13
 
@@ -40,30 +41,48 @@ to install the `json` or `json_pure` gem. On Ruby 1.9, JSON is included in the s
40
41
  Guard::CoffeeScript uses [Ruby CoffeeScript](https://github.com/josh/ruby-coffee-script/) to compile the CoffeeScripts,
41
42
  that in turn uses [ExecJS](https://github.com/sstephenson/execjs) to pick the best runtime to evaluate the JavaScript.
42
43
 
43
- ### node.js
44
+ ## Choose a runtime
45
+
46
+ ### CoffeeScript executable on node.js
44
47
 
45
48
  Please refer to the [CoffeeScript documentation](http://jashkenas.github.com/coffee-script/) for more information about
46
- how to install the latest CoffeeScript version on node.js.
49
+ how to install the latest CoffeeScript version on [node.js](http://nodejs.org/).
47
50
 
48
- ### JavaScript Core
51
+ ### V8 JavaScript Engine
49
52
 
50
- JavaScript Core is only available on Mac OS X. To use JavaScript Core you don't have to install anything, because
51
- JavaScript Core is packaged with Mac OS X.
53
+ To use the [V8 JavaScript Engine](http://code.google.com/p/v8/), simple add `therubyracer` to your `Gemfile`.
54
+ The Ruby Racer acts as a bridge between Ruby and the V8 engine, that will be automatically installed by the Ruby Racer.
52
55
 
53
- ### V8
56
+ ```ruby
57
+ group :development do
58
+ gem 'therubyracer'
59
+ end
60
+ ```
54
61
 
55
- To use CoffeeScript on V8, simple add `therubyracer` to your `Gemfile`. The Ruby Racer acts as a bridge between Ruby
56
- and the V8 engine, that will be automatically installed by the Ruby Racer.
62
+ Another alternative is [Mustang](https://github.com/nu7hatch/mustang), a Ruby proxy library for the awesome Google V8
63
+ JavaScript engine. Just add `mustang` to your `Gemfile`:
57
64
 
58
65
  ```ruby
59
66
  group :development do
60
- gem 'therubyracer'
67
+ gem 'mustang'
68
+ end
69
+ ```
70
+
71
+ ### Mozilla SpiderMonkey
72
+
73
+ To use [Mozilla SpiderMonkey](https://developer.mozilla.org/en/SpiderMonkey), simple add `johnson` to your `Gemfile`.
74
+ Johnson embeds the Mozilla SpiderMonkey JavaScript runtime as a C extension.
75
+
76
+ ```ruby
77
+ group :development do
78
+ gem 'johnson'
61
79
  end
62
80
  ```
63
81
 
64
82
  ### Mozilla Rhino
65
83
 
66
- If you're using JRuby, you can embed the Mozilla Rhino runtime by adding `therubyrhino` to your `Gemfile`:
84
+ If you're using JRuby, you can embed the [Mozilla Rhino](http://www.mozilla.org/rhino/) runtime by adding `therubyrhino`
85
+ to your `Gemfile`:
67
86
 
68
87
  ```ruby
69
88
  group :development do
@@ -71,6 +90,11 @@ group :development do
71
90
  end
72
91
  ```
73
92
 
93
+ ### Apple JavaScriptCore
94
+
95
+ JavaScriptCore is only available on Mac OS X. To use JavaScript Core you don't have to install anything, because
96
+ JavaScriptCore is packaged with Mac OS X.
97
+
74
98
  ### Microsoft Windows Script Host
75
99
 
76
100
  [Microsoft Windows Script Host](http://msdn.microsoft.com/en-us/library/9bbdkx3k.aspx) is available on any Microsoft
@@ -85,20 +109,44 @@ Please read the [Guard usage documentation](https://github.com/guard/guard#readm
85
109
  Guard::CoffeeScript can be adapted to all kind of projects. Please read the
86
110
  [Guard documentation](https://github.com/guard/guard#readme) for more information about the Guardfile DSL.
87
111
 
88
- In addition to the standard configuration, this Guard has a short notation for configure projects with a single input a output
89
- directory. This notation creates a watcher from the `:input` parameter that matches all CoffeeScript files under the given directory
90
- and you don't have to specify a watch regular expression.
91
-
92
112
  ### Standard Ruby gem
93
113
 
114
+ In a custom Ruby project you want to configure your `:input` and `:output` directories.
115
+
94
116
  ```ruby
95
117
  guard 'coffeescript', :input => 'coffeescripts', :output => 'javascripts'
96
118
  ```
97
119
 
98
- ### Rails 3.1 app
120
+ If your output directory is the same as the input directory, you can simply skip it:
99
121
 
100
122
  ```ruby
101
- guard 'coffeescript', :input => 'app/assets/javascripts'
123
+ guard 'coffeescript', :input => 'javascripts'
124
+ ```
125
+
126
+ ### Rails app with the asset pipeline
127
+
128
+ With the introduction of the [asset pipeline](http://guides.rubyonrails.org/asset_pipeline.html) in Rails 3.1 there is
129
+ no need to compile your CoffeeScripts with this Guard. However if you like to have instant validation feedback
130
+ (preferably with a Growl notification) directly after you save a change, then you may want still use this Guard and just
131
+ skip the generation of the output file:
132
+
133
+ ```ruby
134
+ guard 'coffeescript', :input => 'app/assets/javascripts', :noop => true
135
+ ```
136
+
137
+ This give you a faster compilation feedback compared to making a subsequent request to your Rails application. If you
138
+ just want to be notified when an error occurs you can hide the success compilation message:
139
+
140
+ ```ruby
141
+ guard 'coffeescript', :input => 'app/assets/javascripts', :noop => true, :hide_success => true
142
+ ```
143
+
144
+ ### Rails app without the asset pipeline
145
+
146
+ Without the asset pipeline you just define an input and output directory like within a normal Ruby project:
147
+
148
+ ```ruby
149
+ guard 'coffeescript', :input => 'app/coffeescripts', :output => 'public/javascripts',
102
150
  ```
103
151
 
104
152
  ## Options
@@ -113,6 +161,9 @@ There following options can be passed to Guard::CoffeeScript:
113
161
  :output => 'javascripts' # Relative path to the output directory.
114
162
  # default: the path given with the :input option
115
163
 
164
+ :noop => true # No operation: do not write an output file.
165
+ # default: false
166
+
116
167
  :bare => true # Compile without the top-level function wrapper.
117
168
  # Provide either a boolean value or an Array of filenames.
118
169
  # default: false
@@ -124,27 +175,39 @@ There following options can be passed to Guard::CoffeeScript:
124
175
  # default: false
125
176
  ```
126
177
 
178
+ ### Output short notation
179
+
180
+ In addition to the standard configuration, this Guard has a short notation for configure projects with a single input
181
+ and output directory. This notation creates a watcher from the `:input` parameter that matches all CoffeeScript files
182
+ under the given directory and you don't have to specify a watch regular expression.
183
+
184
+ ```ruby
185
+ guard 'coffeescript', :input => 'javascripts'
186
+ ```
187
+
127
188
  ### Selective bare option
128
189
 
129
- The `:bare` option can take a boolean value that indicates if all scripts should be compiled without the top-level function wrapper.
190
+ The `:bare` option can take a boolean value that indicates if all scripts should be compiled without the top-level
191
+ function wrapper.
130
192
 
131
193
  ```ruby
132
194
  :bare => true
133
195
  ```
134
196
 
135
- But you can also pass an Array of filenames that should be compiled without the top-level function wrapper. The path of the file to compile is
136
- ignored, so the list of filenames should not contain any path information:
197
+ But you can also pass an Array of filenames that should be compiled without the top-level function wrapper. The path of
198
+ the file to compile is ignored, so the list of filenames should not contain any path information:
137
199
 
138
200
  ```ruby
139
201
  :bare => %w{ a.coffee b.coffee }
140
202
  ```
141
203
 
142
- In the above example, all `a.coffee` and `b.coffee` files will be compiled with option `:bare => true` and all other files with option `:bare => false`.
204
+ In the above example, all `a.coffee` and `b.coffee` files will be compiled with option `:bare => true` and all other
205
+ files with option `:bare => false`.
143
206
 
144
207
  ### Nested directories
145
208
 
146
- The Guard detects by default nested directories and creates these within the output directory. The detection is based on the match
147
- of the watch regular expression:
209
+ The Guard detects by default nested directories and creates these within the output directory. The detection is based on
210
+ the match of the watch regular expression:
148
211
 
149
212
  A file
150
213
 
@@ -170,11 +233,11 @@ will be compiled to
170
233
  public/javascripts/compiled/ui/buttons/toggle_button.js
171
234
  ```
172
235
 
173
- Note the parenthesis around the `.+\.coffee`. This enables Guard::CoffeeScript to place the full path that was matched inside the
174
- parenthesis into the proper output directory.
236
+ Note the parenthesis around the `.+\.coffee`. This enables Guard::CoffeeScript to place the full path that was matched
237
+ inside the parenthesis into the proper output directory.
175
238
 
176
- This behavior can be switched off by passing the option `:shallow => true` to the Guard, so that all JavaScripts will be compiled
177
- directly to the output directory.
239
+ This behavior can be switched off by passing the option `:shallow => true` to the Guard, so that all JavaScripts will be
240
+ compiled directly to the output directory.
178
241
 
179
242
  ### Multiple source directories
180
243
 
@@ -184,8 +247,8 @@ The Guard short notation
184
247
  guard 'coffeescript', :input => 'app/coffeescripts', :output => 'public/javascripts/compiled'
185
248
  ```
186
249
 
187
- will be internally converted into the standard notation by adding `/(.+\.coffee)` to the `input` option string and create a Watcher
188
- that is equivalent to:
250
+ will be internally converted into the standard notation by adding `/(.+\.coffee)` to the `input` option string and
251
+ create a Watcher that is equivalent to:
189
252
 
190
253
  ```ruby
191
254
  guard 'coffeescript', :output => 'public/javascripts/compiled' do
@@ -217,7 +280,8 @@ end
217
280
 
218
281
  Pull requests are very welcome! Make sure your patches are well tested.
219
282
 
220
- For questions please join us on our [Google group](http://groups.google.com/group/guard-dev) or on `#guard` (irc.freenode.net).
283
+ For questions please join us on our [Google group](http://groups.google.com/group/guard-dev) or on `#guard`
284
+ (irc.freenode.net).
221
285
 
222
286
  ## Contributors
223
287
 
@@ -19,7 +19,7 @@ module Guard
19
19
  private
20
20
 
21
21
  def notify_start(files, options)
22
- message = options[:message] || "Compile #{ files.join(', ') }"
22
+ message = options[:message] || (options[:noop] ? 'Verify ' : 'Compile ') + files.join(', ')
23
23
  Formatter.info(message, :reset => true)
24
24
  end
25
25
 
@@ -32,7 +32,7 @@ module Guard
32
32
  scripts.each do |file|
33
33
  begin
34
34
  content = compile(file, options)
35
- changed_files << process_compile_result(content, file, directory)
35
+ changed_files << process_compile_result(content, file, directory, options)
36
36
  rescue ExecJS::ProgramError => e
37
37
  error_message = file + ': ' + e.message.to_s
38
38
  errors << error_message
@@ -58,10 +58,10 @@ module Guard
58
58
  file_options
59
59
  end
60
60
 
61
- def process_compile_result(content, file, directory)
62
- FileUtils.mkdir_p(File.expand_path(directory)) if !File.directory?(directory)
61
+ def process_compile_result(content, file, directory, options)
62
+ FileUtils.mkdir_p(File.expand_path(directory)) if !File.directory?(directory) && !options[:noop]
63
63
  filename = File.join(directory, File.basename(file.gsub(/(js\.coffee|coffee)$/, 'js')))
64
- File.open(File.expand_path(filename), 'w') { |f| f.write(content) }
64
+ File.open(File.expand_path(filename), 'w') { |f| f.write(content) } if !options[:noop]
65
65
 
66
66
  filename
67
67
  end
@@ -89,7 +89,7 @@ module Guard
89
89
  if !errors.empty?
90
90
  Formatter.notify(errors.join("\n"), :title => 'CoffeeScript results', :image => :failed, :priority => 2)
91
91
  elsif !options[:hide_success]
92
- message = "Successfully generated #{ changed_files.join(', ') }"
92
+ message = "Successfully #{ options[:noop] ? 'verified' : 'generated' } #{ changed_files.join(', ') }"
93
93
  Formatter.success(message)
94
94
  Formatter.notify(message, :title => 'CoffeeScript results')
95
95
  end
@@ -1,5 +1,5 @@
1
1
  module Guard
2
2
  module CoffeeScriptVersion
3
- VERSION = '0.3.3'
3
+ VERSION = '0.4.0'
4
4
  end
5
5
  end
@@ -15,6 +15,7 @@ module Guard
15
15
  :bare => false,
16
16
  :shallow => false,
17
17
  :hide_success => false,
18
+ :noop => false
18
19
  }
19
20
 
20
21
  if options[:input]
@@ -32,7 +33,7 @@ module Guard
32
33
  def run_on_change(paths)
33
34
  changed_files, success = Runner.run(Inspector.clean(paths), watchers, options)
34
35
  notify changed_files
35
-
36
+
36
37
  success
37
38
  end
38
39
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guard-coffeescript
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 15
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 3
9
- - 3
10
- version: 0.3.3
8
+ - 4
9
+ - 0
10
+ version: 0.4.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Michael Kessler
@@ -15,8 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-08-17 00:00:00 +02:00
19
- default_executable:
18
+ date: 2011-09-03 00:00:00 Z
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
22
21
  name: guard
@@ -117,7 +116,6 @@ files:
117
116
  - lib/guard/coffeescript.rbc
118
117
  - LICENSE
119
118
  - README.md
120
- has_rdoc: true
121
119
  homepage: http://github.com/netzpirat/guard-coffeescript
122
120
  licenses: []
123
121
 
@@ -149,7 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
149
147
  requirements: []
150
148
 
151
149
  rubyforge_project: guard-coffeescript
152
- rubygems_version: 1.6.2
150
+ rubygems_version: 1.8.6
153
151
  signing_key:
154
152
  specification_version: 3
155
153
  summary: Guard gem for CoffeeScript