guard 0.6.2 → 0.6.3

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## 0.6.3 - September 1, 2011
2
+
3
+ ### New features:
4
+
5
+ - Pull request [#130](https://github.com/guard/guard/pull/130): Adds ignore_paths option to DSL. ([@ianwhite][])
6
+ - Pull request [#128](https://github.com/guard/guard/pull/128): Users can add additional settings to ~/.guard.rb that augment the existing Guardfile. ([@tpope][])
7
+
1
8
  ## 0.6.2 - August 17, 2011
2
9
 
3
10
  ### Bugs fixes:
@@ -5,12 +12,12 @@
5
12
  - Re-add the possibility to use the `growl` gem since the `growl_notify` gem this is currently known to not work in conjunction with Spork. ([@netzpirat][])
6
13
  - Ensure that scoped groups and group name are symbolized before checking for inclusion. ([@rymai][])
7
14
 
8
- ### New features
15
+ ### New features:
9
16
 
10
17
  - Groups are now stored in a @groups variable (will be used for future features). ([@rymai][])
11
18
  - Guards will now receive their group in the options hash at initialization (will be used for future features). ([@rymai][])
12
19
 
13
- ### Improvement
20
+ ### Improvement:
14
21
 
15
22
  - Explain the growl/growl_notify differences in the README. ([@netzpirat][])
16
23
 
@@ -28,11 +35,11 @@
28
35
  - Pull request [#107](https://github.com/guard/guard/pull/107): Small spelling fix. ([@dnagir][])
29
36
  - Dir.glob now ignores files that don't need to be watched. ([@rymai][])
30
37
 
31
- ### New features
38
+ ### New features:
32
39
 
33
40
  - Pull request [#112](https://github.com/guard/guard/pull/112): Add `list` command to CLI. ([@docwhat][])
34
41
 
35
- ### Improvements
42
+ ### Improvements:
36
43
 
37
44
  - Pull request [#99](https://github.com/guard/guard/pull/99): [OS X] Switch from growl gem to growl_notify gem. ([@johnbintz][])
38
45
  - Pull request [#115](https://github.com/guard/guard/pull/115): [Linux] Add ':transient => true' to default libnotify options. ([@zonque][])
@@ -51,12 +58,12 @@
51
58
 
52
59
  ## 0.5.0 - July 2, 2011
53
60
 
54
- ### New features
61
+ ### New features:
55
62
 
56
63
  - Guard::Ego is now part of Guard, so Guardfile is automagically re-evaluated when modified. ([@thibaudgg][])
57
64
  - Pull request [#91](https://github.com/guard/guard/pull/91): Show Guards in Guardfile with the `guard -T`. ([@johnbintz][])
58
65
 
59
- ### Improvements
66
+ ### Improvements:
60
67
 
61
68
  - Issue [#98](https://github.com/guard/guard/issues/98): Multiple calls per watch event on linux with rb-inotify. ([@jeffutter][] & [@netzpirat][])
62
69
  - Pull request [#94](https://github.com/guard/guard/pull/94): Show backtrace in terminal when a problem with a watch action occurs. ([@capotej][])
@@ -78,7 +85,7 @@
78
85
 
79
86
  ## 0.4.1 - June 7, 2011
80
87
 
81
- ### Improvements
88
+ ### Improvements:
82
89
 
83
90
  - Pull request [#77](https://github.com/guard/guard/pull/77): Refactor `get_guard_class` to first try the constant and fallback to require + various tweaks. ([@mislav][])
84
91
  - Notifier improvement, don't use system notification library if could not be required. ([@yannlugrin][])
@@ -94,7 +101,7 @@
94
101
  - Pull request [#73](https://github.com/guard/guard/pull/73): Allow DSL's `group` method to accept a Symbol as group name. ([@johnbintz][])
95
102
  - Pull request [#51](https://github.com/guard/guard/pull/51): Allow options (like `:priority`) to be passed through to the Notifier. ([@indirect][] & [@netzpirat][])
96
103
 
97
- ### Improvements
104
+ ### Improvements:
98
105
 
99
106
  - Pull request [#74](https://github.com/guard/guard/pull/74): Added link definitions to make the CHANGELOG more DRY! That's for sure now, we have the cleanest CHANGELOG ever! (even the link definitions are sorted alphabetically!) ([@pcreux][])
100
107
 
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- Guard [![Build Status](https://secure.travis-ci.org/guard/guard.png)](http://travis-ci.org/guard/guard)
1
+ Guard [![Build Status](https://travis-ci.org/guard/guard.png)](http://travis-ci.org/guard/guard)
2
2
  =====
3
3
 
4
4
  Guard is a command line tool that easily handle events on files modifications.
@@ -255,10 +255,13 @@ Optional:
255
255
 
256
256
  * The `#watch` method allows you to define which files are supervised by this guard. An optional block can be added to overwrite the paths sent to the guard's `#run_on_change` method or to launch any arbitrary command.
257
257
  * The `#group` method allows you to group several guards together. Groups to be run can be specified with the Guard DSL option `--group` (or `-g`). This comes in handy especially when you have a huge Guardfile and want to focus your development on a certain part. Guards that don't belong to a group are considered global and are always run.
258
+ * The `#ignore_paths` method allows you to ignore top level directories altogether. This comes is handy when you have large amounts of non-source data in you project. By default .bundle, .git, log, tmp, and vendor are ignored. Currently it is only possible to ignore the immediate descendants of the watched directory.
258
259
 
259
260
  Example:
260
261
 
261
262
  ``` ruby
263
+ ignore_paths 'foo', 'bar'
264
+
262
265
  group 'backend' do
263
266
  guard 'bundler' do
264
267
  watch('Gemfile')
@@ -331,6 +334,21 @@ Group frontend:
331
334
  livereload
332
335
  ```
333
336
 
337
+ User config file
338
+ ----------------
339
+
340
+ If a .guard.rb is found in your home directory, it will be appended to
341
+ the Guardfile. This can be used for tasks you want guard to handle but
342
+ other users probably don't. For example, indexing your source tree with
343
+ [Ctags](http://ctags.sourceforge.net):
344
+
345
+ ``` ruby
346
+ guard 'shell' do
347
+ watch(%r{^(?:app|lib)/.+\.rb$}) { `ctags -R` }
348
+ end
349
+
350
+ ```
351
+
334
352
  Create a new guard
335
353
  ------------------
336
354
 
data/lib/guard/dsl.rb CHANGED
@@ -7,7 +7,8 @@ module Guard
7
7
  options.is_a?(Hash) or raise ArgumentError.new("evaluate_guardfile not passed a Hash!")
8
8
 
9
9
  @@options = options.dup
10
- instance_eval_guardfile(fetch_guardfile_contents)
10
+ fetch_guardfile_contents
11
+ instance_eval_guardfile(guardfile_contents_with_user_config)
11
12
 
12
13
  UI.error "No guards found in Guardfile, please add at least one." if !::Guard.guards.nil? && ::Guard.guards.empty?
13
14
  end
@@ -72,14 +73,17 @@ module Guard
72
73
  UI.error "The command file(#{@@options[:guardfile]}) seems to be empty."
73
74
  exit 1
74
75
  end
75
-
76
- guardfile_contents
77
76
  end
78
77
 
79
78
  def guardfile_contents
80
79
  @@options ? @@options[:guardfile_contents] : ""
81
80
  end
82
81
 
82
+ def guardfile_contents_with_user_config
83
+ config = File.read(user_config_path) if File.exist?(user_config_path)
84
+ [guardfile_contents, config].join("\n")
85
+ end
86
+
83
87
  def guardfile_path
84
88
  @@options ? @@options[:guardfile_path] : ""
85
89
  end
@@ -102,6 +106,10 @@ module Guard
102
106
  File.expand_path(File.join("~", ".Guardfile"))
103
107
  end
104
108
 
109
+ def user_config_path
110
+ File.expand_path(File.join("~", ".guard.rb"))
111
+ end
112
+
105
113
  end
106
114
 
107
115
  def group(name, &guard_definition)
@@ -126,5 +134,9 @@ module Guard
126
134
  @watchers << ::Guard::Watcher.new(pattern, action)
127
135
  end
128
136
 
137
+ def ignore_paths(*paths)
138
+ UI.info "Ignoring paths: #{paths.join(', ')}"
139
+ ::Guard.listener.ignore_paths.push(*paths)
140
+ end
129
141
  end
130
142
  end
@@ -9,8 +9,9 @@ module Guard
9
9
  autoload :Polling, 'guard/listeners/polling'
10
10
 
11
11
  class Listener
12
+ DefaultIgnorePaths = %w[. .. .bundle .git log tmp vendor]
12
13
 
13
- attr_reader :directory
14
+ attr_reader :directory, :ignore_paths
14
15
 
15
16
  def self.select_and_init(*a)
16
17
  if mac? && Darwin.usable?
@@ -29,6 +30,8 @@ module Guard
29
30
  @directory = directory.to_s
30
31
  @sha1_checksums_hash = {}
31
32
  @relativize_paths = options.fetch(:relativize_paths, true)
33
+ @ignore_paths = DefaultIgnorePaths
34
+ @ignore_paths |= options[:ignore_paths] if options[:ignore_paths]
32
35
  update_last_event
33
36
  end
34
37
 
@@ -77,14 +80,19 @@ module Guard
77
80
  def relativize_paths?
78
81
  !!@relativize_paths
79
82
  end
83
+
84
+ # return children of the passed dirs that are not in the ignore_paths list
85
+ def exclude_ignored_paths(dirs, ignore_paths = self.ignore_paths)
86
+ Dir.glob(dirs.map { |d| "#{d.sub(%r{/+$}, '')}/*" }, File::FNM_DOTMATCH).reject do |path|
87
+ ignore_paths.include?(File.basename(path))
88
+ end
89
+ end
80
90
 
81
91
  private
82
92
 
83
93
  def potentially_modified_files(dirs, options={})
84
- paths = Dir.glob(dirs.map { |d| "#{d.sub(%r{/+$}, '')}/*" }, File::FNM_DOTMATCH).reject do |path|
85
- %w[. .. .bundle .git log tmp vendor].include?(File.basename(path))
86
- end
87
-
94
+ paths = exclude_ignored_paths(dirs)
95
+
88
96
  if options[:all]
89
97
  paths.inject([]) do |array, path|
90
98
  if File.file?(path)
data/lib/guard/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Guard
2
- VERSION = "0.6.2" unless defined? Guard::VERSION
2
+ VERSION = "0.6.3" unless defined? Guard::VERSION
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guard
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.6.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-08-17 00:00:00.000000000Z
12
+ date: 2011-09-01 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
16
- requirement: &70138447631700 !ruby/object:Gem::Requirement
16
+ requirement: &70194363346280 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70138447631700
24
+ version_requirements: *70194363346280
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &70138447631080 !ruby/object:Gem::Requirement
27
+ requirement: &70194363334300 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 2.6.0
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70138447631080
35
+ version_requirements: *70194363334300
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: guard-rspec
38
- requirement: &70138447630400 !ruby/object:Gem::Requirement
38
+ requirement: &70194363333680 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 0.3.1
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70138447630400
46
+ version_requirements: *70194363333680
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: thor
49
- requirement: &70138447629860 !ruby/object:Gem::Requirement
49
+ requirement: &70194363333100 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: 0.14.6
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70138447629860
57
+ version_requirements: *70194363333100
58
58
  description: Guard is a command line tool to easily handle events on file system modifications.
59
59
  email:
60
60
  - thibaud@thibaud.me
@@ -108,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
108
108
  version: 1.3.6
109
109
  requirements: []
110
110
  rubyforge_project: guard
111
- rubygems_version: 1.8.7
111
+ rubygems_version: 1.8.9
112
112
  signing_key:
113
113
  specification_version: 3
114
114
  summary: Guard keeps an eye on your file modifications