Sha256: f37c935be6c74c4494631dc1a6259efad28bb3292caa3e124de5b291807f7c8c

Contents?: true

Size: 812 Bytes

Versions: 1

Compression:

Stored size: 812 Bytes

Contents

gem 'rspec', '~> 2.4'
require 'rspec'

require 'pp'
require 'pidly'
include Pidly

class Test < Pidly::Control

  before_start do
    "BEFORE START #{@pid}"
  end

  start :when_daemon_starts

  stop do
    "Attempting to kill process: #{@pid}"
  end

  after_stop :test_after_daemon_stops
  
  error do
    "SENDING EMAIL | Error Count: #{@error_count}"
  end

  def when_daemon_starts
    loop do
      print "TEST FROM #{@pid}"
      sleep 2
    end
  end
  
  def test_after_daemon_stops
    puts "AFTER STOP"
  end

end

def test_callback(callback, defined=false)
  test = @daemon.fetch_class_var(callback.to_sym)
  
  if defined
    return true if test
    false
  else
    
    if test.kind_of?(Symbol)
      test
    elsif test.respond_to?(:call)
      test.call
    else
      nil
    end
    
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pidly-0.1.3 spec/spec_helper.rb