Skip to content

Instantly share code, notes, and snippets.

@jonbartlett
Last active January 10, 2017 23:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonbartlett/ced4f59fff96f9b3a5085668026a7684 to your computer and use it in GitHub Desktop.
Save jonbartlett/ced4f59fff96f9b3a5085668026a7684 to your computer and use it in GitHub Desktop.
Auto DB2 Proc Compilation with Ruby Guard
source 'https://rubygems.org'
group :development do
gem 'guard'
gem 'guard-shell'
end
GEM
remote: https://rubygems.org/
specs:
coderay (1.1.1)
ffi (1.9.10)
formatador (0.2.5)
guard (2.13.0)
formatador (>= 0.2.4)
listen (>= 2.7, <= 4.0)
lumberjack (~> 1.0)
nenv (~> 0.1)
notiffany (~> 0.0)
pry (>= 0.9.12)
shellany (~> 0.0)
thor (>= 0.18.1)
guard-compat (1.2.1)
guard-shell (0.7.1)
guard (>= 2.0.0)
guard-compat (~> 1.0)
listen (3.1.2)
rb-fsevent (>= 0.9.3)
rb-inotify (>= 0.9.7)
ruby_dep (~> 1.1)
lumberjack (1.0.10)
method_source (0.8.2)
nenv (0.3.0)
notiffany (0.0.8)
nenv (~> 0.1)
shellany (~> 0.0)
pry (0.10.3)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
slop (~> 3.4)
rb-fsevent (0.9.7)
rb-inotify (0.9.7)
ffi (>= 0.5.0)
ruby_dep (1.1.0)
shellany (0.0.1)
slop (3.6.0)
thor (0.19.1)
PLATFORMS
ruby
DEPENDENCIES
guard
guard-shell
BUNDLED WITH
1.12.1
require 'guard/compat/plugin'
# A sample Guardfile
# More info at https://github.com/guard/guard#readme
## Uncomment and set this to only include directories you want to watch
# directories %w(app lib config test spec features) \
# .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
## Note: if you are using the `directories` clause above and you are not
## watching the project directory ('.'), then you will want to move
## the Guardfile to a watched dir and symlink it back, e.g.
#
# $ mkdir config
# $ mv Guardfile config/
# $ ln -s config/Guardfile .
#
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"
# Add files and commands to this file, like the example:
# watch(%r{file/path}) { `command(s)` }
#
#
# Guardfile
#
clearing :on
notification :tmux,
display_message: true,
timeout: 5, # in seconds
default_message_format: '%s >> %s',
# the first %s will show the title, the second the message
# Alternately you can also configure *success_message_format*,
# *pending_message_format*, *failed_message_format*
change_color: false, # prevent status of changing colour and staying that way
line_separator: ' > ', # since we are single line we need a separator
color_location: 'status-left-bg', # to customize which tmux element will change color
# Other options:
default_message_color: 'black',
success: 'colour150',
failure: 'colour174',
pending: 'colour179',
# Notify on all tmux clients
display_on_all_clients: false
# the double-colons below are *required* for inline Guards!!!
module ::Guard
class MyPlugin < Plugin
def start
puts "connecting to db"
system("db2 connect to TSTDWD01 user dev_jbartlett")
system("db2 -v set session authorization prddwi01")
end
def stop
puts "stop"
system("db2 terminate")
end
end
end
guard('my-plugin')
guard :shell do
# watch(/(di_stg_out_.+sql)/) do |m|
watch('^code\/procedures\/.+.(ddl|sql)') do |m|
if system("db2 -td@ -f #{m[0]}")
n "#{m[0]} complilation success", "DB2", :success
else
n "#{m[0]} complilation failed", "DB2", :failed
end
end
end
#guard :shell do
#watch(/(.*).txt/) do |m|
#if system("grep jon #{m[0]}")
#n "#{m[0]} contains the word", "Grep", :success
#else
#n "#{m[0]} does not contain the word", "Grep", :failed
#end
#end
#end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment