guard-coffeescript 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +85 -40
- data/lib/guard/coffeescript.rb +4 -2
- data/lib/guard/coffeescript.rbc +79 -41
- data/lib/guard/coffeescript/formatter.rb +9 -3
- data/lib/guard/coffeescript/formatter.rbc +182 -55
- data/lib/guard/coffeescript/inspector.rbc +15 -10
- data/lib/guard/coffeescript/runner.rb +2 -1
- data/lib/guard/coffeescript/runner.rbc +153 -94
- data/lib/guard/coffeescript/version.rb +1 -1
- data/lib/guard/coffeescript/version.rbc +1 -1
- metadata +36 -2
data/README.md
CHANGED
@@ -6,26 +6,34 @@ Guard::CoffeeScript compiles you CoffeeScripts automatically when files are modi
|
|
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).
|
10
|
+
|
9
11
|
## Install
|
10
12
|
|
11
|
-
Please be sure to have [Guard](https://github.com/guard/guard) installed
|
13
|
+
Please be sure to have [Guard](https://github.com/guard/guard) installed.
|
12
14
|
|
13
15
|
Install the gem:
|
14
16
|
|
15
|
-
|
17
|
+
```bash
|
18
|
+
$ gem install guard-coffeescript
|
19
|
+
```
|
16
20
|
|
17
21
|
Add it to your `Gemfile`, preferably inside the development group:
|
18
22
|
|
19
|
-
|
23
|
+
```ruby
|
24
|
+
gem 'guard-coffeescript'
|
25
|
+
```
|
20
26
|
|
21
27
|
Add guard definition to your `Guardfile` by running this command:
|
22
28
|
|
23
|
-
|
29
|
+
```bash
|
30
|
+
$ guard init coffeescript
|
31
|
+
```
|
24
32
|
|
25
33
|
## JSON
|
26
34
|
|
27
35
|
The JSON library is also required but is not explicitly stated as a gem dependency. If you're on Ruby 1.8 you'll need
|
28
|
-
to install the json or json_pure gem. On Ruby 1.9, JSON is included in the standard library.
|
36
|
+
to install the `json` or `json_pure` gem. On Ruby 1.9, JSON is included in the standard library.
|
29
37
|
|
30
38
|
## CoffeeScript
|
31
39
|
|
@@ -44,20 +52,24 @@ JavaScript Core is packaged with Mac OS X.
|
|
44
52
|
|
45
53
|
### V8
|
46
54
|
|
47
|
-
To use CoffeeScript on V8, simple add `therubyracer` to your Gemfile
|
55
|
+
To use CoffeeScript on V8, simple add `therubyracer` to your `Gemfile`. The Ruby Racer acts as a bridge between Ruby
|
48
56
|
and the V8 engine, that will be automatically installed by the Ruby Racer.
|
49
57
|
|
50
|
-
|
51
|
-
|
52
|
-
|
58
|
+
```ruby
|
59
|
+
group :development do
|
60
|
+
gem 'therubyracer'
|
61
|
+
end
|
62
|
+
```
|
53
63
|
|
54
64
|
### Mozilla Rhino
|
55
65
|
|
56
|
-
If you're using JRuby, you can embed the Mozilla Rhino runtime by adding `therubyrhino` to your Gemfile
|
66
|
+
If you're using JRuby, you can embed the Mozilla Rhino runtime by adding `therubyrhino` to your `Gemfile`:
|
57
67
|
|
58
|
-
|
59
|
-
|
60
|
-
|
68
|
+
```ruby
|
69
|
+
group :development do
|
70
|
+
gem 'therubyrhino'
|
71
|
+
end
|
72
|
+
```
|
61
73
|
|
62
74
|
### Microsoft Windows Script Host
|
63
75
|
|
@@ -79,89 +91,122 @@ and you don't have to specify a watch regular expression.
|
|
79
91
|
|
80
92
|
### Standard Ruby gem
|
81
93
|
|
82
|
-
|
94
|
+
```ruby
|
95
|
+
guard 'coffeescript', :input => 'coffeescripts', :output => 'javascripts'
|
96
|
+
```
|
83
97
|
|
84
98
|
### Rails 3.1 app
|
85
99
|
|
86
|
-
|
100
|
+
```ruby
|
101
|
+
guard 'coffeescript', :input => 'app/assets/javascripts'
|
102
|
+
```
|
87
103
|
|
88
104
|
## Options
|
89
105
|
|
90
106
|
There following options can be passed to Guard::CoffeeScript:
|
91
107
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
108
|
+
```ruby
|
109
|
+
:input => 'coffeescripts' # Relative path to the input directory
|
110
|
+
# default: nil
|
111
|
+
|
112
|
+
:output => 'javascripts' # Relative path to the output directory
|
113
|
+
# default: the path given with the :input option
|
114
|
+
|
115
|
+
:bare => true # Compile without the top-level function wrapper
|
116
|
+
# default: false
|
117
|
+
|
118
|
+
:shallow => true # Do not create nested output directories
|
119
|
+
# default: false
|
120
|
+
|
121
|
+
:hide_success => true # Disable successful compilation messages
|
122
|
+
# default: false
|
123
|
+
```
|
97
124
|
|
98
125
|
### Nested directories
|
99
126
|
|
100
|
-
The
|
127
|
+
The Guard detects by default nested directories and creates these within the output directory. The detection is based on the match
|
101
128
|
of the watch regular expression:
|
102
129
|
|
103
130
|
A file
|
104
131
|
|
105
|
-
|
132
|
+
```bash
|
133
|
+
/app/coffeescripts/ui/buttons/toggle_button.coffee
|
134
|
+
```
|
106
135
|
|
107
136
|
that has been detected by the watch
|
108
137
|
|
109
|
-
|
138
|
+
```ruby
|
139
|
+
watch(%r{^app/coffeescripts/(.+\.coffee)$})
|
140
|
+
```
|
110
141
|
|
111
142
|
with an output directory of
|
112
143
|
|
113
|
-
|
144
|
+
```ruby
|
145
|
+
:output => 'public/javascripts/compiled'
|
146
|
+
```
|
114
147
|
|
115
148
|
will be compiled to
|
116
149
|
|
117
|
-
|
150
|
+
```bash
|
151
|
+
public/javascripts/compiled/ui/buttons/toggle_button.js
|
152
|
+
```
|
118
153
|
|
119
154
|
Note the parenthesis around the `.+\.coffee`. This enables Guard::CoffeeScript to place the full path that was matched inside the
|
120
155
|
parenthesis into the proper output directory.
|
121
156
|
|
122
|
-
This behavior can be switched off by passing the option `:shallow => true` to the
|
157
|
+
This behavior can be switched off by passing the option `:shallow => true` to the Guard, so that all JavaScripts will be compiled
|
123
158
|
directly to the output directory.
|
124
159
|
|
125
160
|
### Multiple source directories
|
126
161
|
|
127
162
|
The Guard short notation
|
128
163
|
|
129
|
-
|
164
|
+
```ruby
|
165
|
+
guard 'coffeescript', :input => 'app/coffeescripts', :output => 'public/javascripts/compiled'
|
166
|
+
```
|
130
167
|
|
131
168
|
will be internally converted into the standard notation by adding `(.+\.coffee)` to the `input` option string and create a Watcher
|
132
169
|
that is equivalent to:
|
133
170
|
|
134
|
-
|
135
|
-
|
136
|
-
|
171
|
+
```ruby
|
172
|
+
guard 'coffeescript', :output => 'public/javascripts/compiled' do
|
173
|
+
watch(%r{^app/coffeescripts/(.+\.coffee)$})
|
174
|
+
end
|
175
|
+
```
|
137
176
|
|
138
177
|
To add a second source directory that will be compiled to the same output directory, just add another watcher:
|
139
178
|
|
140
|
-
|
141
|
-
|
142
|
-
|
179
|
+
```ruby
|
180
|
+
guard 'coffeescript', :input => 'app/coffeescripts', :output => 'public/javascripts/compiled' do
|
181
|
+
watch(%r{lib/coffeescripts/(.+\.coffee)})
|
182
|
+
end
|
183
|
+
```
|
143
184
|
|
144
185
|
which is equivalent to:
|
145
186
|
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
187
|
+
```ruby
|
188
|
+
guard 'coffeescript', :output => 'public/javascripts/compiled' do
|
189
|
+
watch(%r{app/coffeescripts/(.+\.coffee)})
|
190
|
+
watch(%r{lib/coffeescripts/(.+\.coffee)})
|
191
|
+
end
|
192
|
+
```
|
150
193
|
|
151
194
|
## Development
|
152
195
|
|
153
196
|
- Source hosted at [GitHub](https://github.com/netzpirat/guard-coffeescript)
|
154
|
-
- Report issues
|
197
|
+
- Report issues and feature requests to [GitHub Issues](https://github.com/netzpirat/guard-coffeescript/issues)
|
155
198
|
|
156
199
|
Pull requests are very welcome! Make sure your patches are well tested.
|
157
200
|
|
201
|
+
For questions please join us on our [Google group](http://groups.google.com/group/guard-dev) or on `#guard` (irc.freenode.net).
|
202
|
+
|
158
203
|
## Contributors
|
159
204
|
|
160
205
|
* [Aaron Jensen](https://github.com/aaronjensen)
|
161
|
-
* [Patrick Ewing](https://github.com/hoverbird)
|
162
206
|
* [Andrew Assarattanakul](https://github.com/vizjerai)
|
207
|
+
* [Patrick Ewing](https://github.com/hoverbird)
|
163
208
|
|
164
|
-
|
209
|
+
## Acknowledgment
|
165
210
|
|
166
211
|
The [Guard Team](https://github.com/guard/guard/contributors) for giving us such a nice pice of software
|
167
212
|
that is so easy to extend, one *has* to make a plugin for it!
|
data/lib/guard/coffeescript.rb
CHANGED
@@ -19,7 +19,7 @@ module Guard
|
|
19
19
|
|
20
20
|
if options[:input]
|
21
21
|
defaults.merge!({ :output => options[:input] })
|
22
|
-
watchers << ::Guard::Watcher.new(%r{
|
22
|
+
watchers << ::Guard::Watcher.new(%r{^#{ options.delete(:input) }/(.+\.coffee)$})
|
23
23
|
end
|
24
24
|
|
25
25
|
super(watchers, defaults.merge(options))
|
@@ -30,8 +30,10 @@ module Guard
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def run_on_change(paths)
|
33
|
-
changed_files = Runner.run(Inspector.clean(paths), watchers, options)
|
33
|
+
changed_files, success = Runner.run(Inspector.clean(paths), watchers, options)
|
34
34
|
notify changed_files
|
35
|
+
|
36
|
+
success
|
35
37
|
end
|
36
38
|
|
37
39
|
private
|
data/lib/guard/coffeescript.rbc
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
!RBIX
|
2
|
-
|
2
|
+
6235178746665710376
|
3
3
|
x
|
4
4
|
M
|
5
5
|
1
|
@@ -308,7 +308,7 @@ x
|
|
308
308
|
10
|
309
309
|
initialize
|
310
310
|
i
|
311
|
-
|
311
|
+
201
|
312
312
|
23
|
313
313
|
0
|
314
314
|
10
|
@@ -387,7 +387,7 @@ i
|
|
387
387
|
7
|
388
388
|
1
|
389
389
|
9
|
390
|
-
|
390
|
+
185
|
391
391
|
20
|
392
392
|
2
|
393
393
|
44
|
@@ -427,7 +427,7 @@ i
|
|
427
427
|
12
|
428
428
|
47
|
429
429
|
9
|
430
|
-
|
430
|
+
154
|
431
431
|
47
|
432
432
|
49
|
433
433
|
13
|
@@ -436,48 +436,52 @@ i
|
|
436
436
|
44
|
437
437
|
43
|
438
438
|
14
|
439
|
+
7
|
440
|
+
15
|
439
441
|
20
|
440
442
|
1
|
441
443
|
7
|
442
444
|
6
|
443
445
|
49
|
444
|
-
|
446
|
+
16
|
445
447
|
1
|
446
448
|
47
|
447
449
|
101
|
448
|
-
16
|
449
|
-
7
|
450
450
|
17
|
451
|
+
7
|
452
|
+
18
|
451
453
|
63
|
452
|
-
|
454
|
+
3
|
453
455
|
78
|
454
456
|
49
|
455
457
|
12
|
456
458
|
2
|
457
459
|
47
|
458
460
|
49
|
459
|
-
|
461
|
+
19
|
460
462
|
1
|
461
463
|
15
|
462
464
|
8
|
463
|
-
|
465
|
+
180
|
464
466
|
44
|
465
467
|
43
|
466
468
|
14
|
469
|
+
7
|
470
|
+
15
|
467
471
|
20
|
468
472
|
1
|
469
473
|
7
|
470
474
|
6
|
471
475
|
49
|
472
|
-
|
476
|
+
16
|
473
477
|
1
|
474
478
|
47
|
475
479
|
101
|
476
|
-
16
|
477
|
-
7
|
478
480
|
17
|
481
|
+
7
|
482
|
+
18
|
479
483
|
63
|
480
|
-
|
484
|
+
3
|
481
485
|
78
|
482
486
|
49
|
483
487
|
12
|
@@ -486,10 +490,10 @@ i
|
|
486
490
|
12
|
487
491
|
1
|
488
492
|
49
|
489
|
-
|
493
|
+
20
|
490
494
|
1
|
491
495
|
8
|
492
|
-
|
496
|
+
186
|
493
497
|
1
|
494
498
|
15
|
495
499
|
20
|
@@ -499,15 +503,15 @@ i
|
|
499
503
|
20
|
500
504
|
1
|
501
505
|
49
|
502
|
-
|
506
|
+
21
|
503
507
|
1
|
504
508
|
54
|
505
509
|
52
|
506
|
-
|
510
|
+
19
|
507
511
|
2
|
508
512
|
11
|
509
513
|
I
|
510
|
-
|
514
|
+
a
|
511
515
|
I
|
512
516
|
3
|
513
517
|
I
|
@@ -516,7 +520,7 @@ I
|
|
516
520
|
2
|
517
521
|
n
|
518
522
|
p
|
519
|
-
|
523
|
+
22
|
520
524
|
x
|
521
525
|
4
|
522
526
|
Hash
|
@@ -562,6 +566,9 @@ allocate
|
|
562
566
|
x
|
563
567
|
6
|
564
568
|
Regexp
|
569
|
+
s
|
570
|
+
1
|
571
|
+
^
|
565
572
|
x
|
566
573
|
6
|
567
574
|
delete
|
@@ -569,8 +576,8 @@ x
|
|
569
576
|
4
|
570
577
|
to_s
|
571
578
|
s
|
572
|
-
|
573
|
-
/(.+\.coffee)
|
579
|
+
14
|
580
|
+
/(.+\.coffee)$
|
574
581
|
x
|
575
582
|
10
|
576
583
|
initialize
|
@@ -581,7 +588,7 @@ x
|
|
581
588
|
5
|
582
589
|
merge
|
583
590
|
p
|
584
|
-
|
591
|
+
29
|
585
592
|
I
|
586
593
|
-1
|
587
594
|
I
|
@@ -591,6 +598,10 @@ I
|
|
591
598
|
I
|
592
599
|
d
|
593
600
|
I
|
601
|
+
22
|
602
|
+
I
|
603
|
+
0
|
604
|
+
I
|
594
605
|
23
|
595
606
|
I
|
596
607
|
12
|
@@ -623,15 +634,19 @@ I
|
|
623
634
|
I
|
624
635
|
16
|
625
636
|
I
|
626
|
-
|
637
|
+
b9
|
627
638
|
I
|
628
639
|
14
|
629
640
|
I
|
630
|
-
|
641
|
+
ba
|
642
|
+
I
|
643
|
+
0
|
644
|
+
I
|
645
|
+
bb
|
631
646
|
I
|
632
647
|
19
|
633
648
|
I
|
634
|
-
|
649
|
+
c9
|
635
650
|
x
|
636
651
|
70
|
637
652
|
/Users/michi/Repositories/guard-coffeescript/lib/guard/coffeescript.rb
|
@@ -764,7 +779,7 @@ x
|
|
764
779
|
13
|
765
780
|
run_on_change
|
766
781
|
i
|
767
|
-
|
782
|
+
43
|
768
783
|
45
|
769
784
|
0
|
770
785
|
1
|
@@ -785,9 +800,18 @@ i
|
|
785
800
|
49
|
786
801
|
7
|
787
802
|
3
|
803
|
+
97
|
804
|
+
37
|
788
805
|
19
|
789
806
|
1
|
790
807
|
15
|
808
|
+
37
|
809
|
+
19
|
810
|
+
2
|
811
|
+
15
|
812
|
+
15
|
813
|
+
2
|
814
|
+
15
|
791
815
|
5
|
792
816
|
20
|
793
817
|
1
|
@@ -795,11 +819,14 @@ i
|
|
795
819
|
49
|
796
820
|
8
|
797
821
|
1
|
822
|
+
15
|
823
|
+
20
|
824
|
+
2
|
798
825
|
11
|
799
826
|
I
|
800
|
-
|
827
|
+
7
|
801
828
|
I
|
802
|
-
|
829
|
+
3
|
803
830
|
I
|
804
831
|
1
|
805
832
|
I
|
@@ -831,7 +858,7 @@ x
|
|
831
858
|
6
|
832
859
|
notify
|
833
860
|
p
|
834
|
-
|
861
|
+
9
|
835
862
|
I
|
836
863
|
-1
|
837
864
|
I
|
@@ -841,16 +868,20 @@ I
|
|
841
868
|
I
|
842
869
|
21
|
843
870
|
I
|
844
|
-
|
871
|
+
20
|
845
872
|
I
|
846
873
|
22
|
847
874
|
I
|
848
|
-
|
875
|
+
28
|
876
|
+
I
|
877
|
+
24
|
878
|
+
I
|
879
|
+
2b
|
849
880
|
x
|
850
881
|
70
|
851
882
|
/Users/michi/Repositories/guard-coffeescript/lib/guard/coffeescript.rb
|
852
883
|
p
|
853
|
-
|
884
|
+
3
|
854
885
|
x
|
855
886
|
5
|
856
887
|
paths
|
@@ -859,6 +890,9 @@ x
|
|
859
890
|
changed_files
|
860
891
|
x
|
861
892
|
7
|
893
|
+
success
|
894
|
+
x
|
895
|
+
7
|
862
896
|
private
|
863
897
|
x
|
864
898
|
6
|
@@ -976,19 +1010,23 @@ x
|
|
976
1010
|
13
|
977
1011
|
run_on_change
|
978
1012
|
p
|
979
|
-
|
1013
|
+
9
|
980
1014
|
I
|
981
1015
|
0
|
982
1016
|
I
|
983
|
-
|
1017
|
+
2a
|
984
1018
|
I
|
985
1019
|
4
|
986
1020
|
I
|
987
|
-
|
1021
|
+
2b
|
988
1022
|
I
|
989
1023
|
12
|
990
1024
|
I
|
991
|
-
|
1025
|
+
2c
|
1026
|
+
I
|
1027
|
+
23
|
1028
|
+
I
|
1029
|
+
0
|
992
1030
|
I
|
993
1031
|
24
|
994
1032
|
x
|
@@ -1010,11 +1048,11 @@ p
|
|
1010
1048
|
I
|
1011
1049
|
-1
|
1012
1050
|
I
|
1013
|
-
|
1051
|
+
29
|
1014
1052
|
I
|
1015
1053
|
0
|
1016
1054
|
I
|
1017
|
-
|
1055
|
+
2a
|
1018
1056
|
I
|
1019
1057
|
c
|
1020
1058
|
x
|
@@ -1054,11 +1092,11 @@ I
|
|
1054
1092
|
I
|
1055
1093
|
4d
|
1056
1094
|
I
|
1057
|
-
|
1095
|
+
27
|
1058
1096
|
I
|
1059
1097
|
51
|
1060
1098
|
I
|
1061
|
-
|
1099
|
+
29
|
1062
1100
|
I
|
1063
1101
|
5f
|
1064
1102
|
x
|