guard-coffeescript 0.1.9 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -69,30 +69,31 @@ Please read the [Guard usage documentation](http://github.com/guard/guard#readme
69
69
  Guard::CoffeeScript can be adapted to all kind of projects. Please read the
70
70
  [Guard documentation](http://github.com/guard/guard#readme) for more information about the Guardfile DSL.
71
71
 
72
- ### Standard ruby gems
72
+ In addition to the standard configuration, this Guard has a short notation for configure projects with a single input a output
73
+ directory. This notation creates a watcher from the `:input` parameter that matches all CoffeeScript files under the given directory
74
+ and you don't have to specify a watch regular expression.
73
75
 
74
- guard 'coffeescript' do
75
- watch(%r{coffeescripts/(.+\.coffee)})
76
- end
76
+ ### Standard ruby gem
77
77
 
78
- ### Rails app
78
+ guard 'coffeescript', :input => 'coffeescripts', :output => 'javascripts'
79
79
 
80
- guard 'coffeescript', :output => 'public/javascripts/compiled' do
81
- watch(%r{app/coffeescripts/(.+\.coffee)})
82
- end
80
+ ### Rails app
83
81
 
82
+ guard 'coffeescript', :input => 'app/coffeescripts', :output => 'public/javascripts/compiled'
84
83
 
85
84
  ## Options
86
85
 
87
86
  There following options can be passed to Guard::CoffeeScript:
88
87
 
89
- :output => 'javascripts' # Relative path to the output directory
90
- :bare => true # Compile without the top-level function wrapper
91
- :shallow => true # Do not create nested output directories
88
+ :input => 'coffeescripts' # Relative path to the input directory, default: nil
89
+ :output => 'javascripts' # Relative path to the output directory, default: nil
90
+ :bare => true # Compile without the top-level function wrapper, default: false
91
+ :shallow => true # Do not create nested output directories, default: false
92
92
 
93
93
  ### Nested directories
94
94
 
95
- The guard detects by default nested directories and creates these within the output directory. The detection is based on the match of the watch regular expression:
95
+ The guard detects by default nested directories and creates these within the output directory. The detection is based on the match
96
+ of the watch regular expression:
96
97
 
97
98
  A file
98
99
 
@@ -110,10 +111,37 @@ will be compiled to
110
111
 
111
112
  public/javascripts/compiled/ui/buttons/toggle_button.js
112
113
 
114
+ Note the parenthesis around the `.+\.coffee`. This enables Guard::CoffeeScript to place the full path that was matched inside the
115
+ parenthesis into the proper output directory.
113
116
 
114
- Note the parenthesis around the `.+\.coffee`. This enables guard-coffeescript to place the full path that was matched inside the parenthesis into the proper output directory.
117
+ This behaviour can be switched off by passing the option `:shallow => true` to the guard, so that all JavaScripts will be compiled
118
+ directly to the output directory.
115
119
 
116
- This behaviour can be switched off by passing the option `:shallow => true` to the guard, so that all JavaScripts will be compiled directly to the output directory.
120
+ ### Multiple source directories
121
+
122
+ The Guard short notation
123
+
124
+ guard 'coffeescript', :input => 'app/coffeescripts', :output => 'public/javascripts/compiled'
125
+
126
+ will be internally converted into the standard notation by adding `(.+\.coffee)` to the `input` option string and create a Watcher
127
+ that is equivalent to:
128
+
129
+ guard 'coffeescript', :output => 'public/javascripts/compiled' do
130
+ watch(%r{app/coffeescripts/(.+\.coffee)})
131
+ end
132
+
133
+ To add a second source directory that will be compiled to the same output directory, just add another watcher:
134
+
135
+ guard 'coffeescript', :input => 'app/coffeescripts', :output => 'public/javascripts/compiled' do
136
+ watch(%r{lib/coffeescripts/(.+\.coffee)})
137
+ end
138
+
139
+ which is equivalent to:
140
+
141
+ guard 'coffeescript', :output => 'public/javascripts/compiled' do
142
+ watch(%r{app/coffeescripts/(.+\.coffee)})
143
+ watch(%r{lib/coffeescripts/(.+\.coffee)})
144
+ end
117
145
 
118
146
  ## Development
119
147
 
@@ -1,3 +1 @@
1
- guard 'coffeescript', :output => 'public/javascripts/compiled' do
2
- watch(%r{app/coffeescripts/(.+\.coffee)})
3
- end
1
+ guard 'coffeescript', :input => 'app/coffeescripts', :output => 'public/javascripts/compiled'
@@ -1,5 +1,5 @@
1
1
  module Guard
2
2
  module CoffeeScriptVersion
3
- VERSION = '0.1.9'
3
+ VERSION = '0.2.0'
4
4
  end
5
5
  end
@@ -10,10 +10,12 @@ module Guard
10
10
  autoload :Compiler, 'guard/coffeescript/compiler'
11
11
 
12
12
  def initialize(watchers = [], options = {})
13
+ watchers = [] if !watchers
14
+ watchers << ::Guard::Watcher.new(%r{#{ options.delete(:input) }/(.+\.coffee)}) if options[:input]
15
+
13
16
  super(watchers, {
14
- :output => 'javascripts',
15
- :bare => false,
16
- :shallow => false
17
+ :bare => false,
18
+ :shallow => false
17
19
  }.merge(options))
18
20
  end
19
21
 
@@ -34,6 +36,6 @@ module Guard
34
36
  guard.run_on_change paths unless paths.empty?
35
37
  end
36
38
  end
37
-
39
+
38
40
  end
39
41
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: guard-coffeescript
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.9
5
+ version: 0.2.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Michael Kessler
@@ -10,8 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-04-01 00:00:00 +02:00
14
- default_executable:
13
+ date: 2011-04-04 00:00:00 Z
15
14
  dependencies:
16
15
  - !ruby/object:Gem::Dependency
17
16
  name: guard
@@ -43,7 +42,7 @@ dependencies:
43
42
  requirements:
44
43
  - - ~>
45
44
  - !ruby/object:Gem::Version
46
- version: 1.0.10
45
+ version: 1.0.11
47
46
  type: :development
48
47
  version_requirements: *id003
49
48
  - !ruby/object:Gem::Dependency
@@ -85,7 +84,6 @@ files:
85
84
  - lib/guard/coffeescript.rb
86
85
  - LICENSE
87
86
  - README.md
88
- has_rdoc: true
89
87
  homepage: http://github.com/netzpirat/guard-coffeescript
90
88
  licenses: []
91
89
 
@@ -109,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
107
  requirements: []
110
108
 
111
109
  rubyforge_project: guard-coffeescript
112
- rubygems_version: 1.6.2
110
+ rubygems_version: 1.7.1
113
111
  signing_key:
114
112
  specification_version: 3
115
113
  summary: Guard gem for CoffeeScript