Permalink
Browse files

Remove manifest script

  • Loading branch information...
1 parent b9e858b commit 32ce012c27a4e60778d8c1036393082c64094b97 @mynyml committed Nov 17, 2009
Showing with 0 additions and 71 deletions.
  1. +0 −1 Manifest
  2. +0 −70 manifest.watchr
View
@@ -14,7 +14,6 @@ lib/watchr/event_handlers/base.rb
lib/watchr/event_handlers/portable.rb
lib/watchr/event_handlers/unix.rb
lib/watchr/script.rb
-manifest.watchr
specs.watchr
test/README
test/event_handlers/test_base.rb
View
@@ -1,70 +0,0 @@
-# Run me with:
-#
-# $ watchr manifest.watchr
-#
-# This script will remove a file from from the Manifest when it gets deleted,
-# and will rebuild the Manifest on Ctrl-\
-#
-# Mostly serves as a demo for the :delete event type (and eventually for the
-# :added event type). In reality this is much better implemented as a git
-# post-commit script.
-#
-
-require 'pathname'
-# --------------------------------------------------
-# Helpers
-# --------------------------------------------------
-module Project
- extend self
- def files
- `git ls-files --full-name`.strip.split($/).sort
- end
-end
-
-class Manifest
- attr_accessor :path
-
- def initialize(path)
- @path = Pathname(path).expand_path
- create!
- end
-
- def remove(path)
- paths = @path.read.strip.split($/)
- @path.open('w') {|f| f << (paths - [path]).join("\n") }
- end
-
- def add(path)
- paths = @path.read.strip.split($/)
- @path.open('w') {|f| f << paths.push(path).sort.join("\n") }
- end
-
- private
- def create!
- File.open(@path.to_s, 'w') {} unless @path.exist?
- end
-end
-
-
-@manifest = Manifest.new('Manifest')
-
-# --------------------------------------------------
-# Watchr Rules
-# --------------------------------------------------
-watch('.*', :deleted ) do |md|
- @manifest.remove(md[0])
- puts "removed #{md[0].inspect} from Manifest"
-end
-
-# --------------------------------------------------
-# Signal Handling
-# --------------------------------------------------
-# Ctrl-\
-Signal.trap('QUIT') do
- puts " --- Updated Manifest ---\n"
- @manifest.path.open('w') {|m| m << Project.files.join("\n").strip }
-end
-
-# Ctrl-C
-Signal.trap('INT') { abort("\n") }
-

0 comments on commit 32ce012

Please sign in to comment.