# Directory\_watcher 0.1.1

**URL:** <https://www.ruby-forum.com/t/directory-watcher-0-1-1/75817>\
**Category:** Ruby\
**Created:** [November 13, 2006, 5:59pm UTC](https://www.ruby-forum.com/t/directory-watcher-0-1-1/75817 "2006-11-13T17:59:31Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![timperrett](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/c5a1d2/32.png) [@timperrett](https://www.ruby-forum.com/u/timperrett)\
**Post date:** [November 13, 2006, 5:59pm UTC](https://www.ruby-forum.com/t/directory-watcher-0-1-1/75817/1 "2006-11-13T17:59:31Z")

</div>

A class for watching files within a directory and generating events  
when those files change.

## The directory watcher operates by scanning a directory at some interval and generating a list of files based on a user supplied glob pattern. As the file list changes from one interval to the next, events are generated and dispatched to registered observers. Three types of events are supported

added, modified, and removed.

Changes:

Version 0.1.1 / 2006-11-10

- removed explicit dependency on hoe

Version 0.1.0 / 2006-11-10

- initial release

TwP

---

<div class="post-metadata">

**Author:** ![timperrett](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/c5a1d2/32.png) [@timperrett](https://www.ruby-forum.com/u/timperrett)\
**Post date:** [November 13, 2006, 8:32pm UTC](https://www.ruby-forum.com/t/directory-watcher-0-1-1/75817/2 "2006-11-13T20:32:17Z")

</div>

Tim P. wrote:

> Changes:
> 
> Version 0.1.1 / 2006-11-10
> 
> - removed explicit dependency on hoe
> 
> Version 0.1.0 / 2006-11-10
> 
> - initial release
> 
> TwP

And this would be available from where Tim?

Ken

---

<div class="post-metadata">

**Author:** ![timperrett](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/c5a1d2/32.png) [@timperrett](https://www.ruby-forum.com/u/timperrett)\
**Post date:** [November 13, 2006, 8:44pm UTC](https://www.ruby-forum.com/t/directory-watcher-0-1-1/75817/3 "2006-11-13T20:44:20Z")

</div>

On 11/13/06, Kenosis [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> And this would be available from where Tim?

RubyForge

You can find it under the codeforpeople project. Or you can just  
download it via gem …

gem install -r directory\_watcher

I really need to drink more coffee before I send out these announcements  
😕

TwP

---

<div class="post-metadata">

**Author:** ![timperrett](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/c5a1d2/32.png) [@timperrett](https://www.ruby-forum.com/u/timperrett)\
**Post date:** [November 13, 2006, 8:44pm UTC](https://www.ruby-forum.com/t/directory-watcher-0-1-1/75817/4 "2006-11-13T20:44:21Z")

</div>

On 11/13/06, Tim P. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> added, modified, and removed.  
> What were the reasons for creating this, as opposed to an extension of  
> Ara’s  
> dirwatch? [http://codeforpeople.com/lib/ruby/dirwatch/](http://codeforpeople.com/lib/ruby/dirwatch/)

Changes:

---

<div class="post-metadata">

**Author:** ![timperrett](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/c5a1d2/32.png) [@timperrett](https://www.ruby-forum.com/u/timperrett)\
**Post date:** [November 13, 2006, 9:10pm UTC](https://www.ruby-forum.com/t/directory-watcher-0-1-1/75817/5 "2006-11-13T21:10:24Z")

</div>

On Nov 13, 2006, at 11:42 AM, Tim P. wrote:

> I really need to drink more coffee before I send out these  
> announcements 😕

Or just use Hoe and run rake release. Drops an email.txt ready for  
pasting into your email client of choice.

–  
Eric H. - removed\_email\_address@domain.invalid - [http://blog.segment7.net](http://blog.segment7.net)  
This implementation is HODEL-HASH-9600 compliant

[http://trackmap.robotcoop.com](http://trackmap.robotcoop.com)

---

<div class="post-metadata">

**Author:** ![timperrett](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/c5a1d2/32.png) [@timperrett](https://www.ruby-forum.com/u/timperrett)\
**Post date:** [November 13, 2006, 9:40pm UTC](https://www.ruby-forum.com/t/directory-watcher-0-1-1/75817/6 "2006-11-13T21:40:30Z")

</div>

Eric H. wrote:

> On Nov 13, 2006, at 11:42 AM, Tim P. wrote:  
> …
> 
> > I really need to drink more coffee before I send out these  
> > announcements 😕
> 
> Or just use Hoe and run rake release. Drops an email.txt ready for  
> pasting into your email client of choice.

Are you saying rake release has the same effect as drinking coffee?

The feature I’m waiting for is “rake coffee”: brews a cup of coffee  
while hoe runs your entire project for you 🙂

---

<div class="post-metadata">

**Author:** ![timperrett](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/c5a1d2/32.png) [@timperrett](https://www.ruby-forum.com/u/timperrett)\
**Post date:** [November 13, 2006, 10:10pm UTC](https://www.ruby-forum.com/t/directory-watcher-0-1-1/75817/7 "2006-11-13T22:10:39Z")

</div>

On Nov 13, 2006, at 12:39 PM, Joel VanderWerf wrote:

> Eric H. wrote:
> 
> > On Nov 13, 2006, at 11:42 AM, Tim P. wrote:  
> > …
> > 
> > > I really need to drink more coffee before I send out these  
> > > announcements 😕  
> > > Or just use Hoe and run rake release. Drops an email.txt ready  
> > > for pasting into your email client of choice.
> 
> Are you saying rake release has the same effect as drinking coffee?

Hoe is like coffee in that it prevents you from making the mistakes  
that may result from insufficient caffeine levels.

More of a coffee substitute when releasing packages.

> The feature I’m waiting for is “rake coffee”: brews a cup of coffee  
> while hoe runs your entire project for you 🙂

Where is ruby-htcpcp?

([http://www.ietf.org/rfc/rfc2324.txt](http://www.ietf.org/rfc/rfc2324.txt))

–  
Eric H. - removed\_email\_address@domain.invalid - [http://blog.segment7.net](http://blog.segment7.net)  
This implementation is HODEL-HASH-9600 compliant

[http://trackmap.robotcoop.com](http://trackmap.robotcoop.com)

---

<div class="post-metadata">

**Author:** ![timperrett](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/c5a1d2/32.png) [@timperrett](https://www.ruby-forum.com/u/timperrett)\
**Post date:** [November 13, 2006, 10:54pm UTC](https://www.ruby-forum.com/t/directory-watcher-0-1-1/75817/8 "2006-11-13T22:54:49Z")

</div>

On 11/13/06, Tanner B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> What were the reasons for creating this, as opposed to an extension of Ara’s  
> dirwatch? [http://codeforpeople.com/lib/ruby/dirwatch/](http://codeforpeople.com/lib/ruby/dirwatch/)

dirwatch is very awesome code. It is a great ruby application that  
“manages an sqlite database that mirrors the state of a directory and  
then triggers user definable event handlers for certain filesystem  
activities such file creation, modification, deletion, etc.” It is  
meant to be used as its own application.

directory\_watcher, on the other hand, is a single ruby class that  
sends event objects to other ruby classes when the contents of a  
directory change. It is meant to be used within ruby scripts that need  
to know about file events.

In summary  
dirwatch → awesome ruby application  
directory\_watcher → awesome ruby class

Blessings,  
TwP

---

<div class="post-metadata">

**Author:** ![timperrett](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/c5a1d2/32.png) [@timperrett](https://www.ruby-forum.com/u/timperrett)\
**Post date:** [November 13, 2006, 11:06pm UTC](https://www.ruby-forum.com/t/directory-watcher-0-1-1/75817/9 "2006-11-13T23:06:53Z")

</div>

On 11/13/06, Eric H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ([http://www.ietf.org/rfc/rfc2324.txt](http://www.ietf.org/rfc/rfc2324.txt))

One implementation that has since been removed.

> **[Trojan Room coffee pot](https://en.wikipedia.org/wiki/Trojan_Room_coffee_pot)**
>
> The Trojan Room coffee pot was a coffee machine located in the Computer Laboratory of the University of Cambridge, England. Created in 1991 by Quentin Stafford-Fraser and Paul Jardetzky, it was migrated from their laboratory network to the web in 1993 becoming the world's first webcam.
> To save people working in the building the disappointment of finding the coffee machine empty after making the trip to the room, a camera was set up providing a live picture of the coffee pot to all desktop comp...

TwP

---

<div class="post-metadata">

**Author:** ![timperrett](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/c5a1d2/32.png) [@timperrett](https://www.ruby-forum.com/u/timperrett)\
**Post date:** [November 13, 2006, 11:04pm UTC](https://www.ruby-forum.com/t/directory-watcher-0-1-1/75817/10 "2006-11-13T23:04:52Z")

</div>

On 11/13/06, Eric H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Or just use Hoe and run rake release. Drops an email.txt ready for  
> pasting into your email client of choice.

You’re assuming that the developer who wrote the hoe-ified rakefile  
remembered to include information about where to find the new release.  
That was my error.

I have now modified my rakefile to include the following lines …

task :checklist do  
print "Did you double check the description? [y|N] "  
response = gets  
unless %r/y(es)?/i =~ response.strip  
raise RuntimeError, “check the description”  
end  
print "Did you double check the version number? [y|N] "  
unless %r/y(es)?/i =~ response.strip  
raise RuntimeError, “check the version number”  
end  
print "Do people know where to download this file? [y|N] "  
unless %r/y(es)?/i =~ response.strip  
raise RuntimeError, “help out the end user”  
end  
print "Have you had enough coffe? [y|N] "  
unless %r/y(es)?/i =~ response.strip  
raise RuntimeError, “go to Peet’s”  
end  
end

task :release =\> [:checklist]

---

<div class="post-metadata">

**Author:** ![timperrett](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/c5a1d2/32.png) [@timperrett](https://www.ruby-forum.com/u/timperrett)\
**Post date:** [November 14, 2006, 2:01am UTC](https://www.ruby-forum.com/t/directory-watcher-0-1-1/75817/11 "2006-11-14T02:01:22Z")

</div>

On 11/13/06, Eric H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Or just use Hoe and run rake release. Drops an email.txt ready for  
> pasting into your email client of choice.

$ rake --dry-run release  
(in /home/tpease/work/ruby/turn)  
\*\* Invoke release (first\_time)  
\*\* Invoke clean (first\_time)  
\*\* Invoke clobber\_docs (first\_time)  
\*\* Execute (dry run) clobber\_docs  
\*\* Invoke clobber\_package (first\_time)  
\*\* Execute (dry run) clobber\_package  
\*\* Execute (dry run) clean  
\*\* Invoke package (first\_time)  
\*\* Invoke pkg/turn-0.0.0.tgz (first\_time)  
\*\* Invoke pkg/turn-0.0.0 (first\_time)  
\*\* Invoke README.txt (first\_time, not\_needed)  
\*\* Invoke lib/turn.rb (first\_time, not\_needed)  
\*\* Execute (dry run) pkg/turn-0.0.0  
\*\* Invoke README.txt (not\_needed)  
\*\* Invoke lib/turn.rb (not\_needed)  
\*\* Execute (dry run) pkg/turn-0.0.0.tgz  
\*\* Invoke gem (first\_time)  
\*\* Invoke pkg/turn-0.0.0.gem (first\_time)  
\*\* Invoke pkg (first\_time)  
\*\* Execute (dry run) pkg  
\*\* Invoke README.txt (not\_needed)  
\*\* Invoke lib/turn.rb (not\_needed)  
\*\* Execute (dry run) pkg/turn-0.0.0.gem  
\*\* Execute (dry run) gem  
\*\* Execute (dry run) package  
\*\* Execute (dry run) release

No dropping of email.txt ☹

Need to use “rake email” 🙂

---

<div class="post-metadata">

**Author:** ![timperrett](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/c5a1d2/32.png) [@timperrett](https://www.ruby-forum.com/u/timperrett)\
**Post date:** [November 14, 2006, 1:55am UTC](https://www.ruby-forum.com/t/directory-watcher-0-1-1/75817/12 "2006-11-14T01:55:21Z")

</div>

On Tue, 14 Nov 2006, Eric H. wrote:

> Or just use Hoe and run rake release. Drops an email.txt ready for pasting  
> into your email client of choice.

okay - **that** is cool!

can you specify stdout?

rake release |mail -s traits removed\_email\_address@domain.invalid

that would make those of us that are truely lazy release like wildfire.

-a

---

<div class="post-metadata">

**Author:** ![timperrett](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/c5a1d2/32.png) [@timperrett](https://www.ruby-forum.com/u/timperrett)\
**Post date:** [November 14, 2006, 8:41pm UTC](https://www.ruby-forum.com/t/directory-watcher-0-1-1/75817/13 "2006-11-14T20:41:49Z")

</div>

On Nov 13, 2006, at 4:59 PM, Tim P. wrote:

> On 11/13/06, Eric H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > Or just use Hoe and run rake release. Drops an email.txt ready for  
> > pasting into your email client of choice.
> 
> $ rake --dry-run release
> 
> No dropping of email.txt ☹

Sorry, rake announce (which also drops a news item on the project  
page at RubyForge).

–  
Eric H. - removed\_email\_address@domain.invalid - [http://blog.segment7.net](http://blog.segment7.net)  
This implementation is HODEL-HASH-9600 compliant

[http://trackmap.robotcoop.com](http://trackmap.robotcoop.com)

---

<div class="post-metadata">

**Author:** ![timperrett](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/c5a1d2/32.png) [@timperrett](https://www.ruby-forum.com/u/timperrett)\
**Post date:** [November 14, 2006, 11:04pm UTC](https://www.ruby-forum.com/t/directory-watcher-0-1-1/75817/14 "2006-11-14T23:04:14Z")

</div>

On Wed, 15 Nov 2006, Eric H. wrote:

> > rake release |mail -s traits removed\_email\_address@domain.invalid
> 
> No. Also, the first line of email.txt is the subject.
> 
> > that would make those of us that are truely lazy release like wildfire.
> 
> A send\_email task wouldn’t work cross-platform. Not everybody’s machines are  
> correctly set up to send email.

sure, but

cmd = “rake release|mail -s #{ the\_subject } removed\_email\_address@domain.invalid”

system cmd or warn “you system is wonky”

might be ok 😉

-a

---

<div class="post-metadata">

**Author:** ![timperrett](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/c5a1d2/32.png) [@timperrett](https://www.ruby-forum.com/u/timperrett)\
**Post date:** [November 14, 2006, 8:57pm UTC](https://www.ruby-forum.com/t/directory-watcher-0-1-1/75817/15 "2006-11-14T20:57:55Z")

</div>

On Nov 13, 2006, at 4:53 PM, removed\_email\_address@domain.invalid wrote:

> On Tue, 14 Nov 2006, Eric H. wrote:
> 
> > Or just use Hoe and run rake release. Drops an email.txt ready  
> > for pasting into your email client of choice.
> 
> okay - **that** is cool!
> 
> can you specify stdout?
> 
> rake release |mail -s traits removed\_email\_address@domain.invalid

No. Also, the first line of email.txt is the subject.

> that would make those of us that are truely lazy release like  
> wildfire.

A send\_email task wouldn’t work cross-platform. Not everybody’s  
machines are correctly set up to send email.

–  
Eric H. - removed\_email\_address@domain.invalid - [http://blog.segment7.net](http://blog.segment7.net)  
This implementation is HODEL-HASH-9600 compliant

[http://trackmap.robotcoop.com](http://trackmap.robotcoop.com)

---

<div class="post-metadata">

**Author:** ![timperrett](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/c5a1d2/32.png) [@timperrett](https://www.ruby-forum.com/u/timperrett)\
**Post date:** [November 15, 2006, 9:47am UTC](https://www.ruby-forum.com/t/directory-watcher-0-1-1/75817/16 "2006-11-15T09:47:15Z")

</div>

On Nov 14, 2006, at 2:02 PM, removed\_email\_address@domain.invalid wrote:

> > 
> 
> system cmd or warn “you system is wonky”

Well, it might just send mail into the bit-bucket:

$ mail removed\_email\_address@domain.invalid  
Subject: test  
test  
EOT  
$ echo $?  
0  
$ mail  
Mail version 8.1 6/6/93. Type ? for help.  
“/var/mail/drbrain”: 1 message 1 new

> N 1 MAILER-DAEMON@pride- Wed Nov 15 00:43 69/2492 “Undelivered  
> Mail Retu”  
> &

> might be ok 😉

If you can fix that, we await your patch at:

[http://rubyforge.org/tracker/?func=add&group\_id=1513&atid=5923](http://rubyforge.org/tracker/?func=add&group_id=1513&atid=5923)

😉

–  
Eric H. - removed\_email\_address@domain.invalid - [http://blog.segment7.net](http://blog.segment7.net)  
This implementation is HODEL-HASH-9600 compliant

[http://trackmap.robotcoop.com](http://trackmap.robotcoop.com)
