guard 1.0.3 → 1.1.0.alpha

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.
Files changed (77) hide show
  1. data/CHANGELOG.md +0 -6
  2. data/README.md +38 -30
  3. data/lib/guard.rb +158 -285
  4. data/lib/guard/cli.rb +16 -2
  5. data/lib/guard/dsl.rb +41 -20
  6. data/lib/guard/dsl_describer.rb +1 -1
  7. data/lib/guard/group.rb +1 -1
  8. data/lib/guard/guard.rb +39 -5
  9. data/lib/guard/guardfile.rb +70 -0
  10. data/lib/guard/runner.rb +179 -0
  11. data/lib/guard/ui.rb +1 -1
  12. data/lib/guard/version.rb +2 -4
  13. data/lib/guard/watcher.rb +1 -0
  14. metadata +16 -77
  15. data/bin/fsevent_watch_guard_guard +0 -0
  16. data/lib/guard/listener.rb +0 -376
  17. data/lib/guard/listeners/darwin.rb +0 -62
  18. data/lib/guard/listeners/linux.rb +0 -93
  19. data/lib/guard/listeners/polling.rb +0 -55
  20. data/lib/guard/listeners/windows.rb +0 -63
  21. data/lib/vendor/darwin/Gemfile +0 -6
  22. data/lib/vendor/darwin/Guardfile +0 -8
  23. data/lib/vendor/darwin/LICENSE +0 -20
  24. data/lib/vendor/darwin/README.rdoc +0 -255
  25. data/lib/vendor/darwin/Rakefile +0 -21
  26. data/lib/vendor/darwin/bin/fsevent_watch +0 -0
  27. data/lib/vendor/darwin/ext/fsevent_watch/Info.plist +0 -38
  28. data/lib/vendor/darwin/ext/fsevent_watch/LICENSE +0 -21
  29. data/lib/vendor/darwin/ext/fsevent_watch/fsevent_watch.xcodeproj/project.pbxproj +0 -254
  30. data/lib/vendor/darwin/ext/fsevent_watch/fsevent_watch/TSICTString.c +0 -394
  31. data/lib/vendor/darwin/ext/fsevent_watch/fsevent_watch/TSICTString.h +0 -74
  32. data/lib/vendor/darwin/ext/fsevent_watch/fsevent_watch/cli.c +0 -160
  33. data/lib/vendor/darwin/ext/fsevent_watch/fsevent_watch/cli.h +0 -45
  34. data/lib/vendor/darwin/ext/fsevent_watch/fsevent_watch/common.h +0 -34
  35. data/lib/vendor/darwin/ext/fsevent_watch/fsevent_watch/compat.c +0 -20
  36. data/lib/vendor/darwin/ext/fsevent_watch/fsevent_watch/compat.h +0 -40
  37. data/lib/vendor/darwin/ext/fsevent_watch/fsevent_watch/main.c +0 -509
  38. data/lib/vendor/darwin/ext/fsevent_watch/xcconfig/Common.xcconfig +0 -82
  39. data/lib/vendor/darwin/ext/fsevent_watch/xcconfig/Debug.xcconfig +0 -19
  40. data/lib/vendor/darwin/ext/fsevent_watch/xcconfig/Release.xcconfig +0 -23
  41. data/lib/vendor/darwin/ext/fsevent_watch/xcconfig/fsevent_watch.xcconfig +0 -17
  42. data/lib/vendor/darwin/ext/rakefile.rb +0 -47
  43. data/lib/vendor/darwin/ext/rb-fsevent.xcconfig +0 -33
  44. data/lib/vendor/darwin/lib/rb-fsevent.rb +0 -2
  45. data/lib/vendor/darwin/lib/rb-fsevent/fsevent.rb +0 -111
  46. data/lib/vendor/darwin/lib/rb-fsevent/version.rb +0 -3
  47. data/lib/vendor/darwin/rb-fsevent.gemspec +0 -25
  48. data/lib/vendor/darwin/spec/fixtures/folder1/file1.txt +0 -0
  49. data/lib/vendor/darwin/spec/fixtures/folder1/folder2/file2.txt +0 -0
  50. data/lib/vendor/darwin/spec/rb-fsevent/fsevent_spec.rb +0 -88
  51. data/lib/vendor/darwin/spec/spec_helper.rb +0 -23
  52. data/lib/vendor/linux/MIT-LICENSE +0 -20
  53. data/lib/vendor/linux/README.md +0 -66
  54. data/lib/vendor/linux/Rakefile +0 -54
  55. data/lib/vendor/linux/VERSION +0 -1
  56. data/lib/vendor/linux/lib/rb-inotify.rb +0 -17
  57. data/lib/vendor/linux/lib/rb-inotify/event.rb +0 -139
  58. data/lib/vendor/linux/lib/rb-inotify/native.rb +0 -31
  59. data/lib/vendor/linux/lib/rb-inotify/native/flags.rb +0 -89
  60. data/lib/vendor/linux/lib/rb-inotify/notifier.rb +0 -308
  61. data/lib/vendor/linux/lib/rb-inotify/watcher.rb +0 -83
  62. data/lib/vendor/linux/rb-inotify.gemspec +0 -53
  63. data/lib/vendor/windows/Gemfile +0 -4
  64. data/lib/vendor/windows/README.md +0 -34
  65. data/lib/vendor/windows/Rakefile +0 -18
  66. data/lib/vendor/windows/lib/rb-fchange.rb +0 -14
  67. data/lib/vendor/windows/lib/rb-fchange/event.rb +0 -29
  68. data/lib/vendor/windows/lib/rb-fchange/native.rb +0 -45
  69. data/lib/vendor/windows/lib/rb-fchange/native/flags.rb +0 -78
  70. data/lib/vendor/windows/lib/rb-fchange/notifier.rb +0 -149
  71. data/lib/vendor/windows/lib/rb-fchange/version.rb +0 -3
  72. data/lib/vendor/windows/lib/rb-fchange/watcher.rb +0 -99
  73. data/lib/vendor/windows/rb-fchange.gemspec +0 -34
  74. data/lib/vendor/windows/spec/fixtures/folder1/file1.txt +0 -0
  75. data/lib/vendor/windows/spec/fixtures/folder1/folder2/file2.txt +0 -0
  76. data/lib/vendor/windows/spec/rb-fchange/fchange_spec.rb +0 -119
  77. data/lib/vendor/windows/spec/spec_helper.rb +0 -21
@@ -1,23 +0,0 @@
1
- require 'rspec'
2
- require 'rb-fsevent'
3
-
4
- RSpec.configure do |config|
5
- config.color_enabled = true
6
- config.filter_run :focus => true
7
- config.run_all_when_everything_filtered = true
8
-
9
- config.before(:each) do
10
- @fixture_path = Pathname.new(File.expand_path('../fixtures/', __FILE__))
11
- end
12
-
13
- config.before(:all) do
14
- system "cd ext; rake"
15
- puts "fsevent_watch compiled"
16
- end
17
-
18
- config.after(:all) do
19
- gem_root = Pathname.new(File.expand_path('../../', __FILE__))
20
- system "rm -rf #{gem_root.join('bin')}"
21
- end
22
-
23
- end
@@ -1,20 +0,0 @@
1
- Copyright (c) 2009 Nathan Weizenbaum
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,66 +0,0 @@
1
- # rb-inotify
2
-
3
- This is a simple wrapper over the [inotify](http://en.wikipedia.org/wiki/Inotify) Linux kernel subsystem
4
- for monitoring changes to files and directories.
5
- It uses the [FFI](http://wiki.github.com/ffi/ffi) gem to avoid having to compile a C extension.
6
-
7
- [API documentation is available on rdoc.info](http://rdoc.info/projects/nex3/rb-inotify).
8
-
9
- ## Basic Usage
10
-
11
- The API is similar to the inotify C API, but with a more Rubyish feel.
12
- First, create a notifier:
13
-
14
- notifier = INotify::Notifier.new
15
-
16
- Then, tell it to watch the paths you're interested in
17
- for the events you care about:
18
-
19
- notifier.watch("path/to/foo.txt", :modify) {puts "foo.txt was modified!"}
20
- notifier.watch("path/to/bar", :moved_to, :create) do |event|
21
- puts "#{event.name} is now in path/to/bar!"
22
- end
23
-
24
- Inotify can watch directories or individual files.
25
- It can pay attention to all sorts of events;
26
- for a full list, see [the inotify man page](http://www.tin.org/bin/man.cgi?section=7&topic=inotify).
27
-
28
- Finally, you get at the events themselves:
29
-
30
- notifier.run
31
-
32
- This will loop infinitely, calling the appropriate callbacks when the files are changed.
33
- If you don't want infinite looping,
34
- you can also block until there are available events,
35
- process them all at once,
36
- and then continue on your merry way:
37
-
38
- notifier.process
39
-
40
- ## Advanced Usage
41
-
42
- Sometimes it's necessary to have finer control over the underlying IO operations
43
- than is provided by the simple callback API.
44
- The trick to this is that the \{INotify::Notifier#to_io Notifier#to_io} method
45
- returns a fully-functional IO object,
46
- with a file descriptor and everything.
47
- This means, for example, that it can be passed to `IO#select`:
48
-
49
- # Wait 10 seconds for an event then give up
50
- if IO.select([notifier.to_io], [], [], 10)
51
- notifier.process
52
- end
53
-
54
- It can even be used with EventMachine:
55
-
56
- require 'eventmachine'
57
-
58
- EM.run do
59
- EM.watch notifier.to_io do
60
- notifier.process
61
- end
62
- end
63
-
64
- Unfortunately, this currently doesn't work under JRuby.
65
- JRuby currently doesn't use native file descriptors for the IO object,
66
- so we can't use the notifier's file descriptor as a stand-in.
@@ -1,54 +0,0 @@
1
- require 'rubygems'
2
- require 'rake'
3
-
4
- begin
5
- require 'jeweler'
6
- Jeweler::Tasks.new do |gem|
7
- gem.name = "rb-inotify"
8
- gem.summary = "A Ruby wrapper for Linux's inotify, using FFI"
9
- gem.description = gem.summary
10
- gem.email = "nex342@gmail.com"
11
- gem.homepage = "http://github.com/nex3/rb-inotify"
12
- gem.authors = ["Nathan Weizenbaum"]
13
- gem.add_dependency "ffi", ">= 0.5.0"
14
- gem.add_development_dependency "yard", ">= 0.4.0"
15
- end
16
- Jeweler::GemcutterTasks.new
17
- rescue LoadError
18
- puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
19
- end
20
-
21
- task(:permissions) {sh %{chmod -R a+r .}}
22
- Rake::Task[:build].prerequisites.unshift('permissions')
23
-
24
- module Jeweler::VersionHelper::PlaintextExtension
25
- def write_with_inotify
26
- write_without_inotify
27
- filename = File.join(File.dirname(__FILE__), "lib/rb-inotify.rb")
28
- text = File.read(filename)
29
- File.open(filename, 'w') do |f|
30
- f.write text.gsub(/^( VERSION = ).*/, '\1' + [major, minor, patch].inspect)
31
- end
32
- end
33
- alias_method :write_without_inotify, :write
34
- alias_method :write, :write_with_inotify
35
- end
36
-
37
- class Jeweler::Commands::Version::Base
38
- def commit_version_with_inotify
39
- return unless self.repo
40
- self.repo.add(File.join(File.dirname(__FILE__), "lib/rb-inotify.rb"))
41
- commit_version_without_inotify
42
- end
43
- alias_method :commit_version_without_inotify, :commit_version
44
- alias_method :commit_version, :commit_version_with_inotify
45
- end
46
-
47
- begin
48
- require 'yard'
49
- YARD::Rake::YardocTask.new
50
- rescue LoadError
51
- task :yardoc do
52
- abort "YARD is not available. In order to run yardoc, you must: sudo gem install yard"
53
- end
54
- end
@@ -1 +0,0 @@
1
- 0.8.8
@@ -1,17 +0,0 @@
1
- require 'rb-inotify/native'
2
- require 'rb-inotify/native/flags'
3
- require 'rb-inotify/notifier'
4
- require 'rb-inotify/watcher'
5
- require 'rb-inotify/event'
6
-
7
- # The root module of the library, which is laid out as so:
8
- #
9
- # * {Notifier} -- The main class, where the notifications are set up
10
- # * {Watcher} -- A watcher for a single file or directory
11
- # * {Event} -- An filesystem event notification
12
- module INotify
13
- # An array containing the version number of rb-inotify.
14
- # The numbers in the array are the major, minor, and patch versions,
15
- # respectively.
16
- VERSION = [0, 8, 8]
17
- end
@@ -1,139 +0,0 @@
1
- module INotify
2
- # An event caused by a change on the filesystem.
3
- # Each {Watcher} can fire many events,
4
- # which are passed to that watcher's callback.
5
- class Event
6
- # A list of other events that are related to this one.
7
- # Currently, this is only used for files that are moved within the same directory:
8
- # the `:moved_from` and the `:moved_to` events will be related.
9
- #
10
- # @return [Array<Event>]
11
- attr_reader :related
12
-
13
- # The name of the file that the event occurred on.
14
- # This is only set for events that occur on files in directories;
15
- # otherwise, it's `""`.
16
- # Similarly, if the event is being fired for the directory itself
17
- # the name will be `""`
18
- #
19
- # This pathname is relative to the enclosing directory.
20
- # For the absolute pathname, use \{#absolute\_name}.
21
- # Note that when the `:recursive` flag is passed to {Notifier#watch},
22
- # events in nested subdirectories will still have a `#name` field
23
- # relative to their immediately enclosing directory.
24
- # For example, an event on the file `"foo/bar/baz"`
25
- # will have name `"baz"`.
26
- #
27
- # @return [String]
28
- attr_reader :name
29
-
30
- # The {Notifier} that fired this event.
31
- #
32
- # @return [Notifier]
33
- attr_reader :notifier
34
-
35
- # An integer specifying that this event is related to some other event,
36
- # which will have the same cookie.
37
- #
38
- # Currently, this is only used for files that are moved within the same directory.
39
- # Both the `:moved_from` and the `:moved_to` events will have the same cookie.
40
- #
41
- # @private
42
- # @return [Fixnum]
43
- attr_reader :cookie
44
-
45
- # The {Watcher#id id} of the {Watcher} that fired this event.
46
- #
47
- # @private
48
- # @return [Fixnum]
49
- attr_reader :watcher_id
50
-
51
- # Returns the {Watcher} that fired this event.
52
- #
53
- # @return [Watcher]
54
- def watcher
55
- @watcher ||= @notifier.watchers[@watcher_id]
56
- end
57
-
58
- # The absolute path of the file that the event occurred on.
59
- #
60
- # This is actually only as absolute as the path passed to the {Watcher}
61
- # that created this event.
62
- # However, it is relative to the working directory,
63
- # assuming that hasn't changed since the watcher started.
64
- #
65
- # @return [String]
66
- def absolute_name
67
- return watcher.path if name.empty?
68
- return File.join(watcher.path, name)
69
- end
70
-
71
- # Returns the flags that describe this event.
72
- # This is generally similar to the input to {Notifier#watch},
73
- # except that it won't contain options flags nor `:all_events`,
74
- # and it may contain one or more of the following flags:
75
- #
76
- # `:unmount`
77
- # : The filesystem containing the watched file or directory was unmounted.
78
- #
79
- # `:ignored`
80
- # : The \{#watcher watcher} was closed, or the watched file or directory was deleted.
81
- #
82
- # `:isdir`
83
- # : The subject of this event is a directory.
84
- #
85
- # @return [Array<Symbol>]
86
- def flags
87
- @flags ||= Native::Flags.from_mask(@native[:mask])
88
- end
89
-
90
- # Constructs an {Event} object from a string of binary data,
91
- # and destructively modifies the string to get rid of the initial segment
92
- # used to construct the Event.
93
- #
94
- # @private
95
- # @param data [String] The string to be modified
96
- # @param notifier [Notifier] The {Notifier} that fired the event
97
- # @return [Event, nil] The event, or `nil` if the string is empty
98
- def self.consume(data, notifier)
99
- return nil if data.empty?
100
- ev = new(data, notifier)
101
- data.replace data[ev.size..-1]
102
- ev
103
- end
104
-
105
- # Creates an event from a string of binary data.
106
- # Differs from {Event.consume} in that it doesn't modify the string.
107
- #
108
- # @private
109
- # @param data [String] The data string
110
- # @param notifier [Notifier] The {Notifier} that fired the event
111
- def initialize(data, notifier)
112
- ptr = FFI::MemoryPointer.from_string(data)
113
- @native = Native::Event.new(ptr)
114
- @related = []
115
- @cookie = @native[:cookie]
116
- @name = data[@native.size, @native[:len]].gsub(/\0+$/, '')
117
- @notifier = notifier
118
- @watcher_id = @native[:wd]
119
-
120
- raise Exception.new("inotify event queue has overflowed.") if @native[:mask] & Native::Flags::IN_Q_OVERFLOW != 0
121
- end
122
-
123
- # Calls the callback of the watcher that fired this event,
124
- # passing in the event itself.
125
- #
126
- # @private
127
- def callback!
128
- watcher.callback!(self)
129
- end
130
-
131
- # Returns the size of this event object in bytes,
132
- # including the \{#name} string.
133
- #
134
- # @return [Fixnum]
135
- def size
136
- @native.size + @native[:len]
137
- end
138
- end
139
- end
@@ -1,31 +0,0 @@
1
- require 'ffi'
2
-
3
- module INotify
4
- # This module contains the low-level foreign-function interface code
5
- # for dealing with the inotify C APIs.
6
- # It's an implementation detail, and not meant for users to deal with.
7
- #
8
- # @private
9
- module Native
10
- extend FFI::Library
11
- ffi_lib "c"
12
-
13
- # The C struct describing an inotify event.
14
- #
15
- # @private
16
- class Event < FFI::Struct
17
- layout(
18
- :wd, :int,
19
- :mask, :uint32,
20
- :cookie, :uint32,
21
- :len, :uint32)
22
- end
23
-
24
- attach_function :inotify_init, [], :int
25
- attach_function :inotify_add_watch, [:int, :string, :uint32], :int
26
- attach_function :inotify_rm_watch, [:int, :uint32], :int
27
-
28
- attach_function :read, [:int, :pointer, :size_t], :ssize_t
29
- attach_function :close, [:int], :int
30
- end
31
- end
@@ -1,89 +0,0 @@
1
- module INotify
2
- module Native
3
- # A module containing all the inotify flags
4
- # to be passed to {Notifier#watch}.
5
- #
6
- # @private
7
- module Flags
8
- # File was accessed.
9
- IN_ACCESS = 0x00000001
10
- # Metadata changed.
11
- IN_ATTRIB = 0x00000004
12
- # Writtable file was closed.
13
- IN_CLOSE_WRITE = 0x00000008
14
- # File was modified.
15
- IN_MODIFY = 0x00000002
16
- # Unwrittable file closed.
17
- IN_CLOSE_NOWRITE = 0x00000010
18
- # File was opened.
19
- IN_OPEN = 0x00000020
20
- # File was moved from X.
21
- IN_MOVED_FROM = 0x00000040
22
- # File was moved to Y.
23
- IN_MOVED_TO = 0x00000080
24
- # Subfile was created.
25
- IN_CREATE = 0x00000100
26
- # Subfile was deleted.
27
- IN_DELETE = 0x00000200
28
- # Self was deleted.
29
- IN_DELETE_SELF = 0x00000400
30
- # Self was moved.
31
- IN_MOVE_SELF = 0x00000800
32
-
33
- ## Helper events.
34
-
35
- # Close.
36
- IN_CLOSE = (IN_CLOSE_WRITE | IN_CLOSE_NOWRITE)
37
- # Moves.
38
- IN_MOVE = (IN_MOVED_FROM | IN_MOVED_TO)
39
- # All events which a program can wait on.
40
- IN_ALL_EVENTS = (IN_ACCESS | IN_MODIFY | IN_ATTRIB | IN_CLOSE_WRITE |
41
- IN_CLOSE_NOWRITE | IN_OPEN | IN_MOVED_FROM | IN_MOVED_TO | IN_CREATE |
42
- IN_DELETE | IN_DELETE_SELF | IN_MOVE_SELF)
43
-
44
-
45
- ## Special flags.
46
-
47
- # Only watch the path if it is a directory.
48
- IN_ONLYDIR = 0x01000000
49
- # Do not follow a sym link.
50
- IN_DONT_FOLLOW = 0x02000000
51
- # Add to the mask of an already existing watch.
52
- IN_MASK_ADD = 0x20000000
53
- # Only send event once.
54
- IN_ONESHOT = 0x80000000
55
-
56
-
57
- ## Events sent by the kernel.
58
-
59
- # Backing fs was unmounted.
60
- IN_UNMOUNT = 0x00002000
61
- # Event queued overflowed.
62
- IN_Q_OVERFLOW = 0x00004000
63
- # File was ignored.
64
- IN_IGNORED = 0x00008000
65
- # Event occurred against dir.
66
- IN_ISDIR = 0x40000000
67
-
68
- # Converts a list of flags to the bitmask that the C API expects.
69
- #
70
- # @param flags [Array<Symbol>]
71
- # @return [Fixnum]
72
- def self.to_mask(flags)
73
- flags.map {|flag| const_get("IN_#{flag.to_s.upcase}")}.
74
- inject(0) {|mask, flag| mask | flag}
75
- end
76
-
77
- # Converts a bitmask from the C API into a list of flags.
78
- #
79
- # @param mask [Fixnum]
80
- # @return [Array<Symbol>]
81
- def self.from_mask(mask)
82
- constants.map {|c| c.to_s}.select do |c|
83
- next false unless c =~ /^IN_/
84
- const_get(c) & mask != 0
85
- end.map {|c| c.sub("IN_", "").downcase.to_sym} - [:all_events]
86
- end
87
- end
88
- end
89
- end