-
Notifications
You must be signed in to change notification settings - Fork 7
/
autopush.watchr
executable file
·57 lines (41 loc) · 1013 Bytes
/
autopush.watchr
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env watchr
require 'rubygems'
require 'json'
begin
require 'ruby-growl'
is_growl = true
rescue LoadError
puts "growl skiped ..."
end
Signal.trap('INT') { abort("\nTerminated Successfuly.") } # Ctrl-C
def check_file(filename)
filepath = File.join(Dir.pwd, filename)
unless File.exist?(filepath)
puts "missing #{filename}"
exit
end
filepath
end
def push(appname, growl)
if growl
growl.notify("CouchApp AutoPush", "backbone-couch '#{appname}' Pushed", "test", 1, true)
end
run "soca push test"
end
def run(cmd)
puts cmd
system cmd
end
configjs = check_file("config.js")
configjs = JSON.parse(File.read(configjs))
appname = configjs["id"]
if is_growl
growl = Growl.new("localhost", "ruby-growl", ["CouchApp AutoPush"])
growl.notify("CouchApp AutoPush", "backbone-couch", "default & test.", 1, true)
end
watch('.*') do |m|
unless m[0].match(/\/.idea\//) or m[0].match(/\/.git\//)
puts "#{m[0]} was changed."
push(appname, growl)
end
end