Module: Build::Files

Defined in:
lib/build/files/glob.rb,
lib/build/files/list.rb,
lib/build/files/path.rb,
lib/build/files/state.rb,
lib/build/files/monitor.rb,
lib/build/files/version.rb,
lib/build/files/directory.rb,
lib/build/files/path/filesystem.rb

Defined Under Namespace

Classes: Composite, Directory, FileTime, Glob, Handle, IOState, List, Monitor, Path, Paths, State

Constant Summary collapse

VERSION =
"0.3.1"

Class Method Summary collapse

Class Method Details

.run_with_fsevent(monitor, options = {}, &block) ⇒ Object



122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/build/files/monitor.rb', line 122

def self.run_with_fsevent(monitor, options = {}, &block)
	require 'rb-fsevent'
	
	notifier = FSEvent.new
	
	catch(:interrupt) do
		while true
			notifier.watch monitor.roots do |directories|
				monitor.update(directories)
				
				yield
				
				if monitor.updated
					notifier.stop
				end
			end
	
			notifier.run
		end
	end
end

.run_with_inotify(monitor, options = {}, &block) ⇒ Object



98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/build/files/monitor.rb', line 98

def self.run_with_inotify(monitor, options = {}, &block)
	require 'rb-inotify'
	
	notifier = INotify::Notifier.new
	
	catch(:interrupt) do
		while true
			monitor.roots.each do |root|
				notifier.watch root, :create, :modify, :delete do |event|
					monitor.update([root])
					
					yield
					
					if monitor.updated
						notifier.stop
					end
				end
			end
			
			notifier.run
		end
	end
end

.run_with_polling(monitor, options = {}, &block) ⇒ Object



144
145
146
147
148
149
150
151
152
153
154
# File 'lib/build/files/monitor.rb', line 144

def self.run_with_polling(monitor, options = {}, &block)
	catch(:interrupt) do
		while true
			monitor.update(monitor.roots)
			
			yield
			
			sleep(options[:latency] || 1.0)
		end
	end
end