Repository is archived
No commit activity in last 3 years
No release in over 3 years
Notify Guard Events by HTTP POST Requests
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

~> 1.7
~> 10.0
>= 0

Runtime

~> 0.8
~> 2.8
 Project Readme

Build Status

NAME

GuardWebHookNotifier - Notify Guard Events by HTTP POST Requests.

SYNOPSIS

# Guardfile

require 'guard-webhook-notifier'
GuardWebHookNotifier.register

guard 'rspec' do
  watch(%r{spec/.+_spec\.rb$})
  notification :webhook, url: 'http://10.0.2.2:4001'
end

Server Example

# Running on OS X machine.

require 'listen'
require 'terminal-notifier'
require 'json'
require 'webrick'

# Forwarding events to Vagrant over TCP.
listener = Listen.to './', forward_to: '127.0.0.1:4000'

# HTTP server.
server = WEBrick::HTTPServer.new(Port: 4001)

# Handle POST requests sent from guard-webhook-notifier in Vagrant.
class TerminalNotifierServlet < 
  def do_POST(req, res)
    json = JSON.parse(req.body)
    message = json['message']
    opts = json['options']
    # Show notification.
    TerminalNotifier.notify(message, title: opts['title'])
    res.status = 200
  end
end
server.mount('/', TerminalNotifierServlet)

trap 'INT' do
  listener.stop
  server.shutdown
end

listener.start
server.start

INSTALLATION

gem install guard-webhook-notifier

LICENSE

This software is licensed under MIT license.