guard 0.10.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,22 @@
1
+ ## 1.0.0 - 19 January, 2012
2
+
3
+ ### Improvements
4
+
5
+ - Add Gemnasium dependency status image to README. ([@laserlemon][])
6
+ - Update vendor/darwin. ([@thibaudgg][])
7
+ - [#223](https://github.com/guard/guard/issues/223): Warn if Guard isn't launched with `bundle exec`. (Proposed by [@thibaudgg][], done by [@netzpirat][])
8
+
9
+ ### Bug fixes
10
+
11
+ - [#226](https://github.com/guard/guard/issues/226): Use a direct file descriptor with stty. ([@netzpirat][])
12
+ - [#218](https://github.com/guard/guard/issues/174): Watching directory with `-A` option only reports a deleted file the first time around. ([@rymai][])
13
+ - [#174](https://github.com/guard/guard/issues/174): Not creating timestamps for new files with `-A` option. ([@rymai][])
14
+ - [#216](https://github.com/guard/guard/issues/216): Fix exit-status codes for Guard. ([@Maher4Ever][])
15
+ - [#213 & 214](https://github.com/guard/guard/issues/214): Fixes the "ERROR: No guards found in Guardfile" message wrongly displayed when running `guard list`. ([@pirukire][])
16
+
1
17
  ## 0.10.0 - 1 January, 2012
2
18
 
3
- ### Improvement
19
+ ### Improvements
4
20
 
5
21
  - Improved Readline constraints. ([@netzpirat][])
6
22
  - Stop & start all guards on Guardfile reevaluation. ([@thibaudgg][])
@@ -397,6 +413,7 @@
397
413
  [@johnbintz]: https://github.com/johnbintz
398
414
  [@jrsacks]: https://github.com/jrsacks
399
415
  [@koshigoe]: https://github.com/koshigoe
416
+ [@laserlemon]: https://github.com/laserlemon
400
417
  [@limeyd]: https://github.com/limeyd
401
418
  [@madtrick]: https://github.com/madtrick
402
419
  [@Maher4Ever]: https://github.com/Maher4Ever
@@ -410,6 +427,7 @@
410
427
  [@niklas]: https://github.com/niklas
411
428
  [@oliamb]: https://github.com/oliamb
412
429
  [@pcreux]: https://github.com/pcreux
430
+ [@pirukire]: https://github.com/pirukire
413
431
  [@rmm5t]: https://github.com/rmm5t
414
432
  [@rymai]: https://github.com/rymai
415
433
  [@scottdavis]: https://github.com/scottdavis
data/README.md CHANGED
@@ -832,7 +832,7 @@ When you file an issue, please try to follow to these simple rules if applicable
832
832
  * Add your `Guardfile` and `Gemfile` to the issue.
833
833
  * Make sure that the issue is reproducible with your description.
834
834
 
835
- Development
835
+ Development [![Dependency Status](https://gemnasium.com/guard/guard.png?branch=master)](https://gemnasium.com/guard/guard)
836
836
  -----------
837
837
 
838
838
  * Documentation hosted at [RubyDoc](http://rubydoc.info/github/guard/guard/master/frames).
@@ -46,13 +46,13 @@ module Guard
46
46
  elsif File.exist?(File.join(HOME_TEMPLATES, guard_name))
47
47
  content = File.read('Guardfile')
48
48
  template = File.read(File.join(HOME_TEMPLATES, guard_name))
49
-
49
+
50
50
  File.open('Guardfile', 'wb') do |f|
51
51
  f.puts(content)
52
52
  f.puts("")
53
53
  f.puts(template)
54
54
  end
55
-
55
+
56
56
  ::Guard::UI.info "#{ guard_name } template added to Guardfile, feel free to edit it"
57
57
  else
58
58
  const_name = guard_name.downcase.gsub('-', '')
@@ -180,6 +180,7 @@ module Guard
180
180
  setup(options)
181
181
 
182
182
  Dsl.evaluate_guardfile(options)
183
+ UI.error 'No guards found in Guardfile, please add at least one.' if ::Guard.guards.empty?
183
184
 
184
185
  options[:notify] && ENV['GUARD_NOTIFY'] != 'false' ? Notifier.turn_on : Notifier.turn_off
185
186
 
@@ -213,7 +214,6 @@ module Guard
213
214
 
214
215
  interactor.stop if interactor
215
216
  listener.stop
216
- abort
217
217
  end
218
218
 
219
219
  # Reload all Guards currently enabled.
@@ -71,9 +71,11 @@ module Guard
71
71
  # @see Guard.start
72
72
  #
73
73
  def start
74
+ verify_bundler_presence
74
75
  ::Guard.start(options)
75
76
  rescue Interrupt
76
77
  ::Guard.stop
78
+ abort
77
79
  end
78
80
 
79
81
  desc 'list', 'Lists guards that can be used with init'
@@ -84,6 +86,7 @@ module Guard
84
86
  # @see Guard::DslDescriber.list
85
87
  #
86
88
  def list
89
+ verify_bundler_presence
87
90
  ::Guard::DslDescriber.list(options)
88
91
  end
89
92
 
@@ -95,7 +98,8 @@ module Guard
95
98
  # @see Guard::VERSION
96
99
  #
97
100
  def version
98
- ::Guard::UI.info "Guard version #{ Guard::VERSION }"
101
+ verify_bundler_presence
102
+ ::Guard::UI.info "Guard version #{ ::Guard::VERSION }"
99
103
  end
100
104
 
101
105
  desc 'init [GUARD]', 'Generates a Guardfile at the current working directory, or insert the given GUARD to an existing Guardfile'
@@ -108,6 +112,7 @@ module Guard
108
112
  # @param [String] guard_name the name of the Guard to initialize
109
113
  #
110
114
  def init(guard_name = nil)
115
+ verify_bundler_presence
111
116
  ::Guard.initialize_template(guard_name)
112
117
  end
113
118
 
@@ -115,13 +120,23 @@ module Guard
115
120
  map %w(-T) => :show
116
121
 
117
122
  # Shows all Guards and their options that are defined in
118
- # the `Guardfile`.
123
+ # the `Guardfile`
119
124
  #
120
125
  # @see Guard::DslDescriber.show
121
126
  #
122
127
  def show
128
+ verify_bundler_presence
123
129
  ::Guard::DslDescriber.show(options)
124
130
  end
125
131
 
132
+ private
133
+
134
+ # Verifies if Guard is run with `bundle exec` and
135
+ # shows a hint to do so if not.
136
+ #
137
+ def verify_bundler_presence
138
+ ::Guard::UI.warning "You are using Guard outside of Bundler, this is dangerous and could not work. Using `bundle exec guard` is safer." unless ENV['BUNDLE_GEMFILE']
139
+ end
140
+
126
141
  end
127
142
  end
@@ -100,8 +100,6 @@ module Guard
100
100
 
101
101
  fetch_guardfile_contents
102
102
  instance_eval_guardfile(guardfile_contents_with_user_config)
103
-
104
- UI.error 'No guards found in Guardfile, please add at least one.' if !::Guard.guards.nil? && ::Guard.guards.empty?
105
103
  end
106
104
 
107
105
  # Re-evaluate the `Guardfile` to update the current Guard configuration.
@@ -117,6 +115,7 @@ module Guard
117
115
  ::Guard::Notifier.clear_notifications
118
116
  @@options.delete(:guardfile_contents)
119
117
  Dsl.evaluate_guardfile(@@options)
118
+ UI.error 'No guards found in Guardfile, please add at least one.' if ::Guard.guards.empty?
120
119
  msg = 'Guardfile has been re-evaluated.'
121
120
  UI.info(msg)
122
121
  Notifier.notify(msg)
@@ -48,7 +48,7 @@ module Guard
48
48
  evaluate_guardfile(options)
49
49
 
50
50
  installed_guards = guardfile_structure.inject([]) do |installed, group|
51
- group[:guards].each { |guard| installed << guard[:name] } if group[:guards]
51
+ group[:guards].each { |guard| installed << guard[:name].to_s } if group[:guards]
52
52
  installed
53
53
  end
54
54
 
@@ -96,6 +96,7 @@ module Guard
96
96
  # Kill interactor thread if not current
97
97
  #
98
98
  def stop
99
+ return if ENV['GUARD_ENV'] == 'test'
99
100
  unless Thread.current == @thread
100
101
  @thread.kill
101
102
  end
@@ -122,6 +123,7 @@ module Guard
122
123
  help
123
124
  when :stop
124
125
  ::Guard.stop
126
+ exit
125
127
  when :pause
126
128
  ::Guard.pause
127
129
  when :reload
@@ -98,13 +98,13 @@ module Guard
98
98
  # when stopping.
99
99
  #
100
100
  def store_terminal_settings
101
- @stty_save = `stty -g`.chomp
101
+ @stty_save = `stty -g 2>/dev/null`.chomp
102
102
  end
103
103
 
104
104
  # Restore terminal settings
105
105
  #
106
106
  def restore_terminal_settings
107
- system('stty', @stty_save)
107
+ system('stty', @stty_save, '2>/dev/null')
108
108
  end
109
109
  end
110
110
  end
@@ -98,7 +98,7 @@ module Guard
98
98
  #
99
99
  def start
100
100
  watch(@directory)
101
- timestamp_files
101
+ timestamp_files if watch_all_modifications?
102
102
  end
103
103
 
104
104
  # Stop listening for events.
@@ -154,6 +154,7 @@ module Guard
154
154
  def modified_files(dirs, options = {})
155
155
  last_event = @last_event
156
156
  files = []
157
+
157
158
  if watch_all_modifications?
158
159
  deleted_files = @file_timestamp_hash.collect do |path, ts|
159
160
  unless File.exists?(path)
@@ -165,7 +166,10 @@ module Guard
165
166
  files.concat(deleted_files.compact)
166
167
  end
167
168
  update_last_event
168
- files.concat(potentially_modified_files(dirs, options).select { |path| file_modified?(path, last_event) })
169
+ updated_files = potentially_modified_files(dirs, options).select do |path|
170
+ file_modified?(path, last_event)
171
+ end
172
+ files.concat(updated_files)
169
173
 
170
174
  relativize_paths(files)
171
175
  end
@@ -195,7 +199,7 @@ module Guard
195
199
  def relativize_paths(paths)
196
200
  return paths unless relativize_paths?
197
201
  paths.map do |path|
198
- path.gsub(%r{^(!)?#{ @directory }/},'\1')
202
+ path.gsub(%r{^(!)?#{ @directory }/},'\1')
199
203
  end
200
204
  end
201
205
 
@@ -219,7 +223,7 @@ module Guard
219
223
  # Populate initial timestamp file hash to watch for deleted or moved files.
220
224
  #
221
225
  def timestamp_files
222
- all_files.each {|path| set_file_timestamp_hash(path, file_timestamp(path)) } if watch_all_modifications?
226
+ all_files.each { |path| set_file_timestamp_hash(path) }
223
227
  end
224
228
 
225
229
  # Removes the ignored paths from the directory list.
@@ -273,10 +277,12 @@ module Guard
273
277
  def file_modified?(path, last_event)
274
278
  ctime = File.ctime(path).to_i
275
279
  mtime = File.mtime(path).to_i
280
+
276
281
  if [mtime, ctime].max == last_event.to_i
277
- file_content_modified?(path, sha1_checksum(path))
282
+ file_content_modified?(path)
278
283
  elsif mtime > last_event.to_i
279
- set_sha1_checksums_hash(path, sha1_checksum(path))
284
+ set_sha1_checksums_hash(path)
285
+ set_file_timestamp_hash(path) if watch_all_modifications?
280
286
  true
281
287
  elsif watch_all_modifications?
282
288
  ts = file_timestamp(path)
@@ -295,11 +301,11 @@ module Guard
295
301
  # comparing the SHA1 checksum.
296
302
  #
297
303
  # @param [String] path the file path
298
- # @param [String] sha1_checksum the checksum of the file
299
304
  #
300
- def file_content_modified?(path, sha1_checksum)
301
- if @sha1_checksums_hash[path] != sha1_checksum
302
- set_sha1_checksums_hash(path, sha1_checksum)
305
+ def file_content_modified?(path)
306
+ checksum = sha1_checksum(path)
307
+ if @sha1_checksums_hash[path] != checksum
308
+ set_sha1_checksums_hash(path, checksum)
303
309
  true
304
310
  else
305
311
  false
@@ -311,8 +317,8 @@ module Guard
311
317
  # @param [String] path the file path
312
318
  # @param [Integer] file_timestamp the files modified timestamp
313
319
  #
314
- def set_file_timestamp_hash(path, file_timestamp)
315
- @file_timestamp_hash[path] = file_timestamp
320
+ def set_file_timestamp_hash(path, timestamp = nil)
321
+ @file_timestamp_hash[path] = timestamp ? timestamp : file_timestamp(path)
316
322
  end
317
323
 
318
324
  # Set the current checksum of a file.
@@ -320,8 +326,8 @@ module Guard
320
326
  # @param [String] path the file path
321
327
  # @param [String] sha1_checksum the checksum of the file
322
328
  #
323
- def set_sha1_checksums_hash(path, sha1_checksum)
324
- @sha1_checksums_hash[path] = sha1_checksum
329
+ def set_sha1_checksums_hash(path, checksum = nil)
330
+ @sha1_checksums_hash[path] = checksum ? checksum : sha1_checksum(path)
325
331
  end
326
332
 
327
333
  # Gets a files modified timestamp
@@ -24,6 +24,18 @@ module Guard
24
24
  end
25
25
  end
26
26
 
27
+ # Show a yellow warning message that is prefixed with WARNING.
28
+ #
29
+ # @param [String] message the message to show
30
+ # @option options [Boolean] reset whether to clean the output before
31
+ #
32
+ def warning(message, options = { })
33
+ unless ENV['GUARD_ENV'] == 'test'
34
+ reset_line if options[:reset]
35
+ STDERR.puts color('WARNING: ', :yellow) + message
36
+ end
37
+ end
38
+
27
39
  # Show a red error message that is prefixed with ERROR.
28
40
  #
29
41
  # @param [String] message the message to show
@@ -1,6 +1,6 @@
1
1
  module Guard
2
2
  unless defined? Guard::VERSION
3
3
  # The current gem version of Guard
4
- VERSION = '0.10.0'
4
+ VERSION = '1.0.0'
5
5
  end
6
6
  end
@@ -43,11 +43,11 @@ module Guard
43
43
  def self.match_files(guard, files)
44
44
  guard.watchers.inject([]) do |paths, watcher|
45
45
  files.each do |file|
46
- if matches = watcher.match_file?(file)
46
+ if matches = watcher.match(file)
47
47
  if watcher.action
48
48
  result = watcher.call_action(matches)
49
49
  if guard.options[:any_return]
50
- paths << result
50
+ paths << result
51
51
  elsif result.respond_to?(:empty?) && !result.empty?
52
52
  paths << Array(result)
53
53
  end
@@ -56,7 +56,7 @@ module Guard
56
56
  end
57
57
  end
58
58
  end
59
-
59
+
60
60
  guard.options[:any_return] ? paths : paths.flatten.map { |p| p.to_s }
61
61
  end
62
62
  end
@@ -70,21 +70,35 @@ module Guard
70
70
  def self.match_files?(guards, files)
71
71
  guards.any? do |guard|
72
72
  guard.watchers.any? do |watcher|
73
- files.any? { |file| watcher.match_file?(file) }
73
+ files.any? { |file| watcher.match(file) }
74
74
  end
75
75
  end
76
76
  end
77
77
 
78
+ # @deprecated Use .match instead
79
+ #
80
+ def match_file?(file)
81
+ UI.info "Guard::Watcher.match_file? is deprecated, please use Guard::Watcher.match instead."
82
+ match(file)
83
+ end
84
+
78
85
  # Test the watchers pattern against a file.
79
86
  #
80
87
  # @param [String] file the file to test
81
- # @return [Boolean] whether the given file is matched
88
+ # @return [Array<String>] an array of matches (or containing a single path if the pattern is a string)
82
89
  #
83
- def match_file?(file)
90
+ def match(file)
91
+ f = file
92
+ deleted = file.start_with?('!')
93
+ f = deleted ? f[1..-1] : f
84
94
  if @pattern.is_a?(Regexp)
85
- file.match(@pattern)
95
+ if m = f.match(@pattern)
96
+ m = m.to_a
97
+ m[0] = file
98
+ m
99
+ end
86
100
  else
87
- file == @pattern ? [file] : nil
101
+ f == @pattern ? [file] : nil
88
102
  end
89
103
  end
90
104
 
@@ -21,12 +21,15 @@ else
21
21
  raise "Only Darwin systems greater than 8 (Mac OS X 10.5+) are supported" unless sdk_version
22
22
 
23
23
  core_flags = %W{
24
- -isysroot #{xcode_path}/SDKs/MacOSX#{sdk_version}.sdk
24
+ -isysroot "#{xcode_path}/SDKs/MacOSX#{sdk_version}.sdk"
25
25
  -mmacosx-version-min=#{sdk_version} -mdynamic-no-pic -std=gnu99
26
26
  }
27
27
 
28
28
  cflags = core_flags + %w{-Os -pipe}
29
29
 
30
+ arch_sig = `uname -m`
31
+ cflags << '-arch i386' if arch_sig =~ /i386$/i
32
+
30
33
  wflags = %w{
31
34
  -Wmissing-prototypes -Wreturn-type -Wmissing-braces -Wparentheses -Wswitch
32
35
  -Wunused-function -Wunused-label -Wunused-parameter -Wunused-variable
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.10.0
4
+ version: 1.0.0
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: 2012-01-01 00:00:00.000000000 Z
12
+ date: 2012-01-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor
16
- requirement: &70103690365860 !ruby/object:Gem::Requirement
16
+ requirement: &70098870288860 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 0.14.6
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70103690365860
24
+ version_requirements: *70098870288860
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: ffi
27
- requirement: &70103690365180 !ruby/object:Gem::Requirement
27
+ requirement: &70098870331220 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 0.5.0
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70103690365180
35
+ version_requirements: *70098870331220
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: bundler
38
- requirement: &70103690358380 !ruby/object:Gem::Requirement
38
+ requirement: &70098870377140 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,62 +43,62 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70103690358380
46
+ version_requirements: *70098870377140
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rspec
49
- requirement: &70103690357140 !ruby/object:Gem::Requirement
49
+ requirement: &70098870399680 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
53
53
  - !ruby/object:Gem::Version
54
- version: 2.7.0
54
+ version: 2.8.0
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70103690357140
57
+ version_requirements: *70098870399680
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: guard-rspec
60
- requirement: &70103690356380 !ruby/object:Gem::Requirement
60
+ requirement: &70098870396740 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
64
64
  - !ruby/object:Gem::Version
65
- version: 0.5.0
65
+ version: 0.6.0
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70103690356380
68
+ version_requirements: *70098870396740
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: yard
71
- requirement: &70103690355840 !ruby/object:Gem::Requirement
71
+ requirement: &70098870407720 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
- - - ~>
74
+ - - ! '>='
75
75
  - !ruby/object:Gem::Version
76
- version: 0.7.3
76
+ version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70103690355840
79
+ version_requirements: *70098870407720
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: redcarpet
82
- requirement: &70103690355140 !ruby/object:Gem::Requirement
82
+ requirement: &70098870444360 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
- - - ~>
85
+ - - ! '>='
86
86
  - !ruby/object:Gem::Version
87
- version: 1.17.2
87
+ version: '0'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *70103690355140
90
+ version_requirements: *70098870444360
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: pry
93
- requirement: &70103690354660 !ruby/object:Gem::Requirement
93
+ requirement: &70098870442760 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
- - - ~>
96
+ - - ! '>='
97
97
  - !ruby/object:Gem::Version
98
- version: 0.9.6.2
98
+ version: '0'
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *70103690354660
101
+ version_requirements: *70098870442760
102
102
  description: Guard is a command line tool to easily handle events on file system modifications.
103
103
  email:
104
104
  - thibaud@thibaud.me
@@ -195,6 +195,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
195
195
  - - ! '>='
196
196
  - !ruby/object:Gem::Version
197
197
  version: '0'
198
+ segments:
199
+ - 0
200
+ hash: 3509592351307849355
198
201
  required_rubygems_version: !ruby/object:Gem::Requirement
199
202
  none: false
200
203
  requirements: