watch_and_do 0.0.1 → 0.0.2

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 (3) hide show
  1. data/README.rdoc +1 -1
  2. data/bin/watch_and_do +6 -6
  3. metadata +2 -2
data/README.rdoc CHANGED
@@ -1,6 +1,6 @@
1
1
  = watch_and_do
2
2
 
3
- Description goes here.
3
+ watches files ending with specific extensions in directories and executes a command/script
4
4
 
5
5
  == Contributing to watch_and_do
6
6
 
data/bin/watch_and_do CHANGED
@@ -6,6 +6,7 @@ require 'optparse'
6
6
  optparse = OptionParser.new do|opts|
7
7
  opts.banner = "Usage: watch_and_do directory_name extension1,extension2 scriptName \n
8
8
  Example: watch_and_do /tmp/ss js,coffee,rb /tmp/do.rb
9
+ Example: watch_and_do . coffee ./rebuild.sh
9
10
  "
10
11
 
11
12
  opts.on( '-h', '--help', 'Displays this screen' ) do
@@ -18,7 +19,9 @@ optparse.parse!
18
19
 
19
20
  # returns full path in case relatives paths are passed
20
21
  def get_full_path(path)
21
- if !File::exists? path
22
+ if path == '.'
23
+ path = Dir.pwd
24
+ elsif !File::exists? path
22
25
  Dir.pwd + File::SEPARATOR + path
23
26
  end
24
27
 
@@ -39,17 +42,14 @@ if ARGV.size == 3
39
42
  puts "invalid directory name"
40
43
  end
41
44
 
42
-
43
45
  if valid
44
46
  # start watch + call script on modified file
45
47
  while true do
46
48
  line = %x[inotifywait -e modify -q -r #{dir.path}]
47
- # line = "/tmp/ss/ MODIFY asd.txt"
48
49
 
49
- str = dir.path + " MODIFY "
50
+ words = line.split(' MODIFY ')
50
51
 
51
- filename = line.gsub(str, '')
52
- filename = dir.path + filename
52
+ filename = words[0] + words[1]
53
53
  filename.strip!
54
54
 
55
55
  extensions.each do |ext|
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: watch_and_do
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.1
5
+ version: 0.0.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - hbt
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-12-04 00:00:00 Z
13
+ date: 2012-02-11 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: shoulda