file-watcher 1.0.1 → 1.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.
data/README.textile ADDED
@@ -0,0 +1,50 @@
1
+ h1. Overview
2
+
3
+ file-watcher wraps some configuration around Ruby's INotify library to allow configurable actions to be taken upon notification.
4
+
5
+ h1. Usage
6
+
7
+ <pre>
8
+ user@host ~$ watcher -?? -??
9
+ </pre>
10
+
11
+ h2. Watcher Configuration
12
+
13
+ <pre>
14
+ class ExampleWatch < WatchJob
15
+
16
+ new_watch_job do |watch_job|
17
+ watch_job.watch_criteria = {
18
+ :events => [:create],
19
+ :file_glob => /.trigger$/,
20
+ :target_dir => "/tmp"
21
+ }
22
+
23
+ watch_job.watch_action =
24
+ {:http =>
25
+ {:method => :post,
26
+ :hostname => "example.server.com",
27
+ :port => "443",
28
+ :auth_user => "username",
29
+ :auth_pass => "password",
30
+ :uri => "/some/http/interface",
31
+ :ssl => true,
32
+ :body => {:some => "form", :paramters => "expected", :by => "the target to be triggered"}
33
+ }}
34
+ end
35
+ end
36
+ </pre>
37
+
38
+ h2. Supported Watch Actions
39
+
40
+ Currently only a post over http is supported.
41
+
42
+ h1. Authors
43
+
44
+ Josh m'fin Crean
45
+
46
+ Paul The Heart Santa Clara
47
+
48
+ Kylebot is watching you
49
+
50
+ h1. License
@@ -1,10 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'rubygems'
3
- require 'ruby-debug'
4
3
  require 'base_app'
5
4
  require 'rb-inotify'
6
5
  require 'json'
7
- require File.join( File.dirname(__FILE__), 'watch_job' )
6
+ require 'file_watcher/watch_job'
8
7
 
9
8
 
10
9
  #
@@ -85,6 +84,4 @@ class Watcher < BaseApp
85
84
  end
86
85
  end
87
86
 
88
- if $0 == __FILE__
89
- Watcher.main
90
- end
87
+ Watcher.main
@@ -22,10 +22,10 @@ class WatchJob
22
22
  protocol = 'http'
23
23
  end
24
24
 
25
- url = "#{protocol}://#{watch_action[:http][:auth_user]}:#{watch_action[:http][:auth_pass]}@#{watch_action[:http][:hostname]}:#{watch_action[:http][:port]}#{watch_action[:http][:command_uri]}"
25
+ url = "#{protocol}://#{watch_action[:http][:auth_user]}:#{watch_action[:http][:auth_pass]}@#{watch_action[:http][:hostname]}:#{watch_action[:http][:port]}#{watch_action[:http][:uri]}"
26
26
 
27
27
 
28
- body = watch_action[:http][:command].merge({ :args => watch_action[:http][:command][:args].dup.push(event.name) } )
28
+ body = watch_action[:http][:body].merge({ :args => watch_action[:http][:body][:args].dup.push(event.name) } )
29
29
 
30
30
  puts "URL: #{url}"
31
31
  puts "body: #{body}"
@@ -39,8 +39,9 @@ class WatchJob
39
39
  return unless event.name =~ watch_criteria[:file_glob]
40
40
 
41
41
  if watch_action.keys.first == :http && watch_action[:http][:method] == :post
42
- do_post event
42
+ return do_post event
43
43
  end
44
44
 
45
+ raise "Error: unsupported watch action in: #{watch_action.inspect}"
45
46
  end
46
47
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 0
8
- - 1
9
- version: 1.0.1
8
+ - 2
9
+ version: 1.0.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Paul Santa Clara
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-02-25 00:00:00 -05:00
19
+ date: 2011-02-28 00:00:00 -05:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -33,28 +33,58 @@ dependencies:
33
33
  version: 0.8.4
34
34
  type: :runtime
35
35
  version_requirements: *id001
36
+ - !ruby/object:Gem::Dependency
37
+ name: base_app
38
+ prerelease: false
39
+ requirement: &id002 !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ segments:
44
+ - 1
45
+ - 0
46
+ - 4
47
+ version: 1.0.4
48
+ type: :runtime
49
+ version_requirements: *id002
50
+ - !ruby/object:Gem::Dependency
51
+ name: json
52
+ prerelease: false
53
+ requirement: &id003 !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ segments:
58
+ - 1
59
+ - 4
60
+ - 3
61
+ version: 1.4.3
62
+ type: :runtime
63
+ version_requirements: *id003
36
64
  description: |
37
65
  Use inotify to watch for file system modifcations and take a configured action.'
38
66
 
39
67
  email: "kburton@relaynetwork.com "
40
- executables: []
41
-
68
+ executables:
69
+ - watcher
42
70
  extensions: []
43
71
 
44
- extra_rdoc_files: []
45
-
72
+ extra_rdoc_files:
73
+ - README.textile
46
74
  files:
47
- - watch_config.rb
48
- - watcher.rb
49
- - watch_job.rb
75
+ - bin/watcher
76
+ - lib/file_watcher/watch_config.rb
77
+ - lib/file_watcher/watch_job.rb
78
+ - README.textile
50
79
  has_rdoc: true
51
- homepage:
80
+ homepage: https://github.com/relaynetwork/file-watcher
52
81
  licenses: []
53
82
 
54
83
  post_install_message:
55
84
  rdoc_options: []
56
85
 
57
86
  require_paths:
87
+ - bin
58
88
  - lib
59
89
  required_ruby_version: !ruby/object:Gem::Requirement
60
90
  requirements: