filewatcher 0.3.0 → 0.3.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 931616017d17d3dbca73187c1b6fe31887975115
4
- data.tar.gz: 24cec3cbfe8256a906a0067d628438d2bc4176d8
3
+ metadata.gz: e11975d24379196fffe99ab55fae2aa8c8f7d6e1
4
+ data.tar.gz: 9cc8ce2b4587d2f7753e613b82e18de81f17d076
5
5
  SHA512:
6
- metadata.gz: eddb01f13c12345438352bb1450f22078462d1b392baacdd0796ddf40a82f80aab5164fc2be36d0c15493cf257164de2f41a2b4a46cfe84400b67c4a1438d6d4
7
- data.tar.gz: efeff47ff4fb01fc3e9af4e9f7a0af47fc33d59fa6b67a19d077055438c43c4839428bc4f8ca8de42d74e44093df2f092532a36e27f5e6efa05b91283a25f91c
6
+ metadata.gz: 06ac3efd3fbf4e58c93a0b712470aa17d95a6459af64fb54fc8f6feac1710352d67a03044cb9aaa75ec14d688f14b065112adcdf319d8f2a69d31be18f2fc40c
7
+ data.tar.gz: c4db481b3f44d80cc8175690d7b662ffa8ac85caadf666b52ca067894dab5b668cdcab841ced8ba56b505ccea6f078ea1d35e8feb02f92d7dcfa95ed7c0bbc29
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2009 Thomas Flemming
1
+ Copyright (c) 2009 - 2014 Thomas Flemming
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.rdoc CHANGED
@@ -1,6 +1,6 @@
1
1
  = Filewatcher
2
2
 
3
- Simple file watcher. Monitors changes in files by polling.
3
+ Simple file watcher. Monitors changes in filesystem by polling. No dependencies.
4
4
 
5
5
  = Install
6
6
 
@@ -24,12 +24,14 @@ Run the echo command when the file myfile is changed:
24
24
 
25
25
  $ filewatcher "myfile" "echo 'myfile has changed'"
26
26
 
27
- Run any javascript in current folder when it is updated on Linux/OSX:
28
- $ filewatcher *.js "node $FILENAME"
27
+ Run any javascript in the current folder when it is updated in Windows Powershell:
28
+
29
+ > filewatcher *.js "node %FILENAME%"
29
30
 
30
- In Windows Powershell:
31
+ In Linux/OSX:
32
+
33
+ $ filewatcher *.js "node $FILENAME"
31
34
 
32
- > filewatcher *.js "node %FILENAME%"
33
35
 
34
36
  Run the ruby script when it is changed:
35
37
 
@@ -91,13 +93,13 @@ To detect if a file is updated or deleted:
91
93
 
92
94
  FileWatcher.new(["README.rdoc"]).watch() do |filename, event|
93
95
  if(event == :changed)
94
- puts "Updated " + filename
96
+ puts "File updated: " + filename
95
97
  end
96
- if(event == :deleted)
97
- puts "Deleted " + filename
98
+ if(event == :delete)
99
+ puts "File deleted: " + filename
98
100
  end
99
101
  if(event == :new)
100
- puts "New file " + filename
102
+ puts "New file: " + filename
101
103
  end
102
104
  end
103
105
 
data/Rakefile CHANGED
@@ -13,7 +13,7 @@ begin
13
13
  gem.authors = ["Thomas Flemming"]
14
14
  gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
15
15
  gem.add_dependency "trollop", ">= 1.16.2"
16
- # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
16
+ gem.licenses = ["MIT"]
17
17
  end
18
18
  rescue LoadError
19
19
  puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.0
1
+ 0.3.1
data/bin/filewatcher CHANGED
@@ -5,7 +5,7 @@ require 'trollop'
5
5
  require 'pathname'
6
6
 
7
7
  options = Trollop::options do
8
- version "filewatcher, version #{FileWatcher.VERSION} by Thomas Flemming 2013"
8
+ version "filewatcher, version #{FileWatcher.VERSION} by Thomas Flemming 2014"
9
9
  banner <<-EOS
10
10
  Filewatcher scans filesystem and execute shell commands when files changes.
11
11
 
@@ -48,13 +48,9 @@ if(options[:recurse])
48
48
  files = inc - exc
49
49
  end
50
50
 
51
- if(options[:list])
52
- puts "watching:", files.inspect
53
- end
54
-
55
51
  runners = {".py" => "python", ".rb" => "ruby", ".pl" => "perl", ".awk" => "awk"}
56
52
 
57
- FileWatcher.new(files).watch(options[:interval]) do |filename|
53
+ FileWatcher.new(files, options[:list]).watch(options[:interval]) do |filename, event|
58
54
  if(options[:exec])
59
55
  extension = filename[/(\.[^\.]*)/,0]
60
56
  runner = runners[extension].to_s
@@ -64,12 +60,24 @@ FileWatcher.new(files).watch(options[:interval]) do |filename|
64
60
  cmd = ARGV[-1]
65
61
  env = {
66
62
  'FILENAME'=> path.to_s,
67
- 'FILEPATH' => path.realpath.to_s,
68
63
  'FILEDIR' => path.parent.realpath.to_s
69
64
  }
65
+ if(event != :delete)
66
+ ENV['FILEPATH'] = path.realpath.to_s
67
+ end
70
68
  pid = Process.spawn(env, cmd);
71
69
  pid = Process.wait();
72
70
  else
73
- puts "file updated: " + filename
71
+ case(event)
72
+ when :changed
73
+ print "file updated"
74
+ when :delete
75
+ print "file eleted"
76
+ when :new
77
+ print "new file"
78
+ else
79
+ print event.to_s
80
+ end
81
+ puts ": " + filename
74
82
  end
75
83
  end
data/lib/filewatcher.rb CHANGED
@@ -4,7 +4,7 @@
4
4
  class FileWatcher
5
5
 
6
6
  def self.VERSION
7
- return "0.3.0"
7
+ return "0.3.1"
8
8
  end
9
9
 
10
10
  def initialize(unexpanded_filenames, print_filelist=false)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: filewatcher
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas Flemming
@@ -56,7 +56,8 @@ files:
56
56
  - test/helper.rb
57
57
  - test/test_filewatcher.rb
58
58
  homepage: http://github.com/thomasfl/filewatcher
59
- licenses: []
59
+ licenses:
60
+ - MIT
60
61
  metadata: {}
61
62
  post_install_message:
62
63
  rdoc_options: []