monitaur 0.0.1
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/.gitignore +7 -0
 - data/README +45 -0
 - data/Rakefile +15 -0
 - data/lib/app/controllers/monitaur/monitaur_controller.rb +17 -0
 - data/lib/monitaur.rb +21 -0
 - data/lib/monitaur/monitor.rb +100 -0
 - data/lib/monitaur/routes.rb +9 -0
 - data/lib/monitaur/version.rb +3 -0
 - data/monitaur.gemspec +23 -0
 - data/rails.rb +7 -0
 - data/test/monitaur_controller_test.rb +26 -0
 - data/test/monitaur_inspector_test.rb +50 -0
 - data/test/monitaur_test.rb +7 -0
 - data/test/test_helper.rb +15 -0
 - metadata +83 -0
 
    
        data/.gitignore
    ADDED
    
    
    
        data/README
    ADDED
    
    | 
         @@ -0,0 +1,45 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            Monitaur
         
     | 
| 
      
 2 
     | 
    
         
            +
            =====
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            Rails 3 Web App Monitoring. Monitor your apps directly from your desktop. Lightweight. Built using Rails Engines.
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            Instructions
         
     | 
| 
      
 7 
     | 
    
         
            +
            =====
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
                gem install monitaur
         
     | 
| 
      
 10 
     | 
    
         
            +
                
         
     | 
| 
      
 11 
     | 
    
         
            +
            on your routes.rb file add "monitaur", for example
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                YourApplication::Application.routes.draw do
         
     | 
| 
      
 14 
     | 
    
         
            +
                  monitaur
         
     | 
| 
      
 15 
     | 
    
         
            +
                end
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
            then download the desktop client and add your site. Start *monitauring* your Rails 3 apps now!
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
            Customization
         
     | 
| 
      
 20 
     | 
    
         
            +
            =====
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
            You can freely add custom data via adding Proc, method or Hash objects on the config. Just add this on your initializer (config/initializers/monitaur.rb)
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                Monitaur::Monitor.config do |config|
         
     | 
| 
      
 25 
     | 
    
         
            +
                  
         
     | 
| 
      
 26 
     | 
    
         
            +
                  user_count = Proc.new do
         
     | 
| 
      
 27 
     | 
    
         
            +
                    { 'users_count' => User.count }
         
     | 
| 
      
 28 
     | 
    
         
            +
                  end
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
                  config.hooks << user_count
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
                  purchases = Proc.new do
         
     | 
| 
      
 33 
     | 
    
         
            +
                    { 'purchases' = yourpurchasecode }
         
     | 
| 
      
 34 
     | 
    
         
            +
                  end
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
                  config.hooks << purchases
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
                end
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
            License
         
     | 
| 
      
 41 
     | 
    
         
            +
            =====
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
            Copyright 2011 - Jason Torres (ProudCloud.net) 
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
            MIT License 
         
     | 
    
        data/Rakefile
    ADDED
    
    | 
         @@ -0,0 +1,15 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'rake'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'rake/testtask'
         
     | 
| 
      
 3 
     | 
    
         
            +
            require 'rake/rdoctask'
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            desc 'Default: run unit tests.'
         
     | 
| 
      
 6 
     | 
    
         
            +
            task :default => :test
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            desc 'Test'
         
     | 
| 
      
 9 
     | 
    
         
            +
            Rake::TestTask.new(:test) do |t|
         
     | 
| 
      
 10 
     | 
    
         
            +
              t.libs << 'lib'
         
     | 
| 
      
 11 
     | 
    
         
            +
              t.libs << 'test'
         
     | 
| 
      
 12 
     | 
    
         
            +
              t.pattern = 'test/**/*_test.rb'
         
     | 
| 
      
 13 
     | 
    
         
            +
              t.verbose = true
         
     | 
| 
      
 14 
     | 
    
         
            +
            end
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
         @@ -0,0 +1,17 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module Monitaur
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
              class MonitaurController < ApplicationController
         
     | 
| 
      
 4 
     | 
    
         
            +
                
         
     | 
| 
      
 5 
     | 
    
         
            +
                unloadable
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
                def index
         
     | 
| 
      
 8 
     | 
    
         
            +
                  @monitaur = Monitaur::Monitor.new
         
     | 
| 
      
 9 
     | 
    
         
            +
                 
         
     | 
| 
      
 10 
     | 
    
         
            +
                  @output = @monitaur.render
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                  render :json => @output.to_hash, :layout => false
         
     | 
| 
      
 13 
     | 
    
         
            +
                end
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
              end
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/monitaur.rb
    ADDED
    
    | 
         @@ -0,0 +1,21 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'rails'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'action_controller'
         
     | 
| 
      
 3 
     | 
    
         
            +
            require 'active_support'
         
     | 
| 
      
 4 
     | 
    
         
            +
            require 'active_support/dependencies'
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            require 'monitaur/monitor' 
         
     | 
| 
      
 7 
     | 
    
         
            +
            require 'monitaur/routes'
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            require 'sysinfo'
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
            module Monitaur
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
              %w{ controllers }.each do |dir|
         
     | 
| 
      
 14 
     | 
    
         
            +
                path = File.join(File.dirname(__FILE__), 'app', dir)
         
     | 
| 
      
 15 
     | 
    
         
            +
                $LOAD_PATH << path
         
     | 
| 
      
 16 
     | 
    
         
            +
                ActiveSupport::Dependencies.autoload_paths << path
         
     | 
| 
      
 17 
     | 
    
         
            +
                ActiveSupport::Dependencies.autoload_once_paths.delete(path)
         
     | 
| 
      
 18 
     | 
    
         
            +
              end
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
            end
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
         @@ -0,0 +1,100 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module Monitaur
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
              class Configuration
         
     | 
| 
      
 4 
     | 
    
         
            +
                cattr_accessor :hooks
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
                @@hooks = [] # initialize an empty array
         
     | 
| 
      
 7 
     | 
    
         
            +
              end
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
              class Monitor
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
                @@config = Monitaur::Configuration
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                attr_accessor :output
         
     | 
| 
      
 14 
     | 
    
         
            +
                attr_accessor :hooks
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
                def initialize
         
     | 
| 
      
 17 
     | 
    
         
            +
                  @hooks ||= @@config.hooks 
         
     | 
| 
      
 18 
     | 
    
         
            +
                end
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
                ##
         
     | 
| 
      
 21 
     | 
    
         
            +
                # Returns a hash of the sysinfo values including values from hooks
         
     | 
| 
      
 22 
     | 
    
         
            +
                def render
         
     | 
| 
      
 23 
     | 
    
         
            +
                  @output ||= {}
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
                  @output.merge!(system_info)
         
     | 
| 
      
 26 
     | 
    
         
            +
                  @output.merge!(active_record_connection)
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
                  apply_hooks
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
                  @output
         
     | 
| 
      
 31 
     | 
    
         
            +
                end
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
                ##
         
     | 
| 
      
 34 
     | 
    
         
            +
                # Apply hooks. Hooks are methods that gets executed after all the other info has been collected.
         
     | 
| 
      
 35 
     | 
    
         
            +
                # The hooks collection accepts a Proc, a method name (Symbol) or a Hash. Symbols has to be a special case 
         
     | 
| 
      
 36 
     | 
    
         
            +
                # because the method has to be visible on the Monitaur::Monitor class. Methods should return a Hash object 
         
     | 
| 
      
 37 
     | 
    
         
            +
                # that gets merged in the global output hash
         
     | 
| 
      
 38 
     | 
    
         
            +
                #
         
     | 
| 
      
 39 
     | 
    
         
            +
                def apply_hooks
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
                  @hooks.each do |hook|
         
     | 
| 
      
 42 
     | 
    
         
            +
                    
         
     | 
| 
      
 43 
     | 
    
         
            +
                    hook_output = nil
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
                    if hook.is_a?(Proc)
         
     | 
| 
      
 46 
     | 
    
         
            +
                      hook_output = hook.call
         
     | 
| 
      
 47 
     | 
    
         
            +
                    elsif hook.is_a?(Symbol)
         
     | 
| 
      
 48 
     | 
    
         
            +
                      hook_output = eval(hook.to_s) # run the symbol
         
     | 
| 
      
 49 
     | 
    
         
            +
                    elsif hook.is_a?(Hash)
         
     | 
| 
      
 50 
     | 
    
         
            +
                      hook_output = hook # hash already? assign to output
         
     | 
| 
      
 51 
     | 
    
         
            +
                    end
         
     | 
| 
      
 52 
     | 
    
         
            +
             
     | 
| 
      
 53 
     | 
    
         
            +
                    @output.merge!(hook_output) if hook_output && hook_output.is_a?(Hash)
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
      
 55 
     | 
    
         
            +
             
     | 
| 
      
 56 
     | 
    
         
            +
                  end unless @hooks.empty?
         
     | 
| 
      
 57 
     | 
    
         
            +
             
     | 
| 
      
 58 
     | 
    
         
            +
                end
         
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
      
 60 
     | 
    
         
            +
                def self.config
         
     | 
| 
      
 61 
     | 
    
         
            +
             
     | 
| 
      
 62 
     | 
    
         
            +
                  if block_given?
         
     | 
| 
      
 63 
     | 
    
         
            +
                    yield(@@config)
         
     | 
| 
      
 64 
     | 
    
         
            +
                  end
         
     | 
| 
      
 65 
     | 
    
         
            +
             
     | 
| 
      
 66 
     | 
    
         
            +
                end
         
     | 
| 
      
 67 
     | 
    
         
            +
             
     | 
| 
      
 68 
     | 
    
         
            +
             
     | 
| 
      
 69 
     | 
    
         
            +
             
     | 
| 
      
 70 
     | 
    
         
            +
              protected
         
     | 
| 
      
 71 
     | 
    
         
            +
             
     | 
| 
      
 72 
     | 
    
         
            +
                # TODO: Refactor this and move this to another module
         
     | 
| 
      
 73 
     | 
    
         
            +
                def system_info
         
     | 
| 
      
 74 
     | 
    
         
            +
                  si = SysInfo.new
         
     | 
| 
      
 75 
     | 
    
         
            +
                  si.to_hash
         
     | 
| 
      
 76 
     | 
    
         
            +
                rescue 
         
     | 
| 
      
 77 
     | 
    
         
            +
                  {}
         
     | 
| 
      
 78 
     | 
    
         
            +
                end
         
     | 
| 
      
 79 
     | 
    
         
            +
             
     | 
| 
      
 80 
     | 
    
         
            +
                def active_record_connection
         
     | 
| 
      
 81 
     | 
    
         
            +
                  running = false
         
     | 
| 
      
 82 
     | 
    
         
            +
             
     | 
| 
      
 83 
     | 
    
         
            +
                  if defined?(ActiveRecord)
         
     | 
| 
      
 84 
     | 
    
         
            +
                    begin
         
     | 
| 
      
 85 
     | 
    
         
            +
                      if ActiveRecord::Base.connection.execute("select 1")
         
     | 
| 
      
 86 
     | 
    
         
            +
                        running = true
         
     | 
| 
      
 87 
     | 
    
         
            +
                      end
         
     | 
| 
      
 88 
     | 
    
         
            +
                   end
         
     | 
| 
      
 89 
     | 
    
         
            +
             
     | 
| 
      
 90 
     | 
    
         
            +
                  
         
     | 
| 
      
 91 
     | 
    
         
            +
                  end
         
     | 
| 
      
 92 
     | 
    
         
            +
                    
         
     | 
| 
      
 93 
     | 
    
         
            +
                  {:database => running}
         
     | 
| 
      
 94 
     | 
    
         
            +
                end
         
     | 
| 
      
 95 
     | 
    
         
            +
             
     | 
| 
      
 96 
     | 
    
         
            +
              end
         
     | 
| 
      
 97 
     | 
    
         
            +
             
     | 
| 
      
 98 
     | 
    
         
            +
             
     | 
| 
      
 99 
     | 
    
         
            +
             
     | 
| 
      
 100 
     | 
    
         
            +
            end
         
     | 
    
        data/monitaur.gemspec
    ADDED
    
    | 
         @@ -0,0 +1,23 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # -*- encoding: utf-8 -*-
         
     | 
| 
      
 2 
     | 
    
         
            +
            $:.push File.expand_path("../lib", __FILE__)
         
     | 
| 
      
 3 
     | 
    
         
            +
            require "monitaur/version"
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            Gem::Specification.new do |s|
         
     | 
| 
      
 6 
     | 
    
         
            +
              s.name        = "monitaur"
         
     | 
| 
      
 7 
     | 
    
         
            +
              s.version     = Monitaur::VERSION
         
     | 
| 
      
 8 
     | 
    
         
            +
              s.platform    = Gem::Platform::RUBY
         
     | 
| 
      
 9 
     | 
    
         
            +
              s.authors     = ["Jason Torres"]
         
     | 
| 
      
 10 
     | 
    
         
            +
              s.email       = ["jason@proudcloud.net"]
         
     | 
| 
      
 11 
     | 
    
         
            +
              s.homepage    = "http://github.com/jasontorres/monitaur"
         
     | 
| 
      
 12 
     | 
    
         
            +
              s.summary     = %q{Rails 3 Website Monitoring Tool}
         
     | 
| 
      
 13 
     | 
    
         
            +
              s.description = %q{Monitaur monitors your website from your desktop.}
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
              s.rubyforge_project = "monitaur"
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
              s.add_dependency('sysinfo', '>= 0.7.3')
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
              s.files         = `git ls-files`.split("\n")
         
     | 
| 
      
 20 
     | 
    
         
            +
              s.test_files    = `git ls-files -- {test,spec,features}/*`.split("\n")
         
     | 
| 
      
 21 
     | 
    
         
            +
              s.executables   = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
         
     | 
| 
      
 22 
     | 
    
         
            +
              s.require_paths = ["lib"]
         
     | 
| 
      
 23 
     | 
    
         
            +
            end
         
     | 
    
        data/rails.rb
    ADDED
    
    
| 
         @@ -0,0 +1,26 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'test_helper'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require 'monitaur/routes'
         
     | 
| 
      
 4 
     | 
    
         
            +
            require 'monitaur/monitaur_controller'
         
     | 
| 
      
 5 
     | 
    
         
            +
             
         
     | 
| 
      
 6 
     | 
    
         
            +
            unless defined?(ApplicationController)
         
     | 
| 
      
 7 
     | 
    
         
            +
            class ApplicationController; end; 
         
     | 
| 
      
 8 
     | 
    
         
            +
            end
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
            class Monitaur::MonitaurController; def rescue_action(e) raise e end; end
         
     | 
| 
      
 11 
     | 
    
         
            +
             
         
     | 
| 
      
 12 
     | 
    
         
            +
            class Monitaur::MonitaurControllerTest < ActionController::TestCase
         
     | 
| 
      
 13 
     | 
    
         
            +
              
         
     | 
| 
      
 14 
     | 
    
         
            +
              def setup 
         
     | 
| 
      
 15 
     | 
    
         
            +
                Rails.application.routes.draw do 
         
     | 
| 
      
 16 
     | 
    
         
            +
                  monitaur
         
     | 
| 
      
 17 
     | 
    
         
            +
                end
         
     | 
| 
      
 18 
     | 
    
         
            +
              end
         
     | 
| 
      
 19 
     | 
    
         
            +
             
         
     | 
| 
      
 20 
     | 
    
         
            +
              def test_index
         
     | 
| 
      
 21 
     | 
    
         
            +
                get :index
         
     | 
| 
      
 22 
     | 
    
         
            +
                assert_response :success
         
     | 
| 
      
 23 
     | 
    
         
            +
              end
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
            end
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
         @@ -0,0 +1,50 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'test_helper'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require 'monitaur/monitor'
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            class Monitaur::MonitorTest < ActiveSupport::TestCase
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
              def test_monitor_render
         
     | 
| 
      
 8 
     | 
    
         
            +
                monitor = Monitaur::Monitor.new
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
                output = monitor.render
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                assert_equal output.class, Hash
         
     | 
| 
      
 13 
     | 
    
         
            +
              end
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
              def test_monitor_hooks
         
     | 
| 
      
 16 
     | 
    
         
            +
                monitor = Monitaur::Monitor.new
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
                test_hook = Proc.new do
         
     | 
| 
      
 19 
     | 
    
         
            +
                  {'test'=> 'hook'}
         
     | 
| 
      
 20 
     | 
    
         
            +
                end
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
                monitor.hooks.push test_hook 
         
     | 
| 
      
 23 
     | 
    
         
            +
                
         
     | 
| 
      
 24 
     | 
    
         
            +
                output = monitor.render
         
     | 
| 
      
 25 
     | 
    
         
            +
             
         
     | 
| 
      
 26 
     | 
    
         
            +
                assert output['test'], 'hook'
         
     | 
| 
      
 27 
     | 
    
         
            +
              end
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
              def test_global_monitor_hooks
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
                test_hook = Proc.new do
         
     | 
| 
      
 32 
     | 
    
         
            +
                  {'test'=> 'hook'}
         
     | 
| 
      
 33 
     | 
    
         
            +
                end
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
                another_hook = Proc.new do 
         
     | 
| 
      
 36 
     | 
    
         
            +
                  {'disk' => `df`}
         
     | 
| 
      
 37 
     | 
    
         
            +
                end
         
     | 
| 
      
 38 
     | 
    
         
            +
             
         
     | 
| 
      
 39 
     | 
    
         
            +
                Monitaur::Monitor.config do |config|
         
     | 
| 
      
 40 
     | 
    
         
            +
                  config.hooks << test_hook
         
     | 
| 
      
 41 
     | 
    
         
            +
                end
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
                monitor = Monitaur::Monitor.new
         
     | 
| 
      
 44 
     | 
    
         
            +
                assert_equal monitor.hooks, [test_hook]
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
              end
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
            end
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
    
        data/test/test_helper.rb
    ADDED
    
    | 
         @@ -0,0 +1,15 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'rubygems'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'test/unit'
         
     | 
| 
      
 3 
     | 
    
         
            +
            require 'active_support'
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            require 'monitaur'
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            ENV['RAILS_ENV'] = 'test'
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            ENV['RAILS_ROOT'] ||= "/Users/Jason/Sites/rubyrumble/monitaur_sample" #File.dirname(__FILE__) + '/../../..' 
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
            require File.expand_path(File.join(ENV['RAILS_ROOT'], 'config/environment.rb'))
         
     | 
| 
      
 12 
     | 
    
         
            +
            require 'rails/test_help'
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
    
        metadata
    ADDED
    
    | 
         @@ -0,0 +1,83 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            --- !ruby/object:Gem::Specification 
         
     | 
| 
      
 2 
     | 
    
         
            +
            name: monitaur
         
     | 
| 
      
 3 
     | 
    
         
            +
            version: !ruby/object:Gem::Version 
         
     | 
| 
      
 4 
     | 
    
         
            +
              prerelease: 
         
     | 
| 
      
 5 
     | 
    
         
            +
              version: 0.0.1
         
     | 
| 
      
 6 
     | 
    
         
            +
            platform: ruby
         
     | 
| 
      
 7 
     | 
    
         
            +
            authors: 
         
     | 
| 
      
 8 
     | 
    
         
            +
            - Jason Torres
         
     | 
| 
      
 9 
     | 
    
         
            +
            autorequire: 
         
     | 
| 
      
 10 
     | 
    
         
            +
            bindir: bin
         
     | 
| 
      
 11 
     | 
    
         
            +
            cert_chain: []
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            date: 2011-05-28 00:00:00 +08:00
         
     | 
| 
      
 14 
     | 
    
         
            +
            default_executable: 
         
     | 
| 
      
 15 
     | 
    
         
            +
            dependencies: 
         
     | 
| 
      
 16 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency 
         
     | 
| 
      
 17 
     | 
    
         
            +
              name: sysinfo
         
     | 
| 
      
 18 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 19 
     | 
    
         
            +
              requirement: &id001 !ruby/object:Gem::Requirement 
         
     | 
| 
      
 20 
     | 
    
         
            +
                none: false
         
     | 
| 
      
 21 
     | 
    
         
            +
                requirements: 
         
     | 
| 
      
 22 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 23 
     | 
    
         
            +
                  - !ruby/object:Gem::Version 
         
     | 
| 
      
 24 
     | 
    
         
            +
                    version: 0.7.3
         
     | 
| 
      
 25 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
      
 26 
     | 
    
         
            +
              version_requirements: *id001
         
     | 
| 
      
 27 
     | 
    
         
            +
            description: Monitaur monitors your website from your desktop.
         
     | 
| 
      
 28 
     | 
    
         
            +
            email: 
         
     | 
| 
      
 29 
     | 
    
         
            +
            - jason@proudcloud.net
         
     | 
| 
      
 30 
     | 
    
         
            +
            executables: []
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
            extensions: []
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
            extra_rdoc_files: []
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
            files: 
         
     | 
| 
      
 37 
     | 
    
         
            +
            - .gitignore
         
     | 
| 
      
 38 
     | 
    
         
            +
            - README
         
     | 
| 
      
 39 
     | 
    
         
            +
            - Rakefile
         
     | 
| 
      
 40 
     | 
    
         
            +
            - lib/app/controllers/monitaur/monitaur_controller.rb
         
     | 
| 
      
 41 
     | 
    
         
            +
            - lib/monitaur.rb
         
     | 
| 
      
 42 
     | 
    
         
            +
            - lib/monitaur/monitor.rb
         
     | 
| 
      
 43 
     | 
    
         
            +
            - lib/monitaur/routes.rb
         
     | 
| 
      
 44 
     | 
    
         
            +
            - lib/monitaur/version.rb
         
     | 
| 
      
 45 
     | 
    
         
            +
            - monitaur.gemspec
         
     | 
| 
      
 46 
     | 
    
         
            +
            - rails.rb
         
     | 
| 
      
 47 
     | 
    
         
            +
            - test/monitaur_controller_test.rb
         
     | 
| 
      
 48 
     | 
    
         
            +
            - test/monitaur_inspector_test.rb
         
     | 
| 
      
 49 
     | 
    
         
            +
            - test/monitaur_test.rb
         
     | 
| 
      
 50 
     | 
    
         
            +
            - test/test_helper.rb
         
     | 
| 
      
 51 
     | 
    
         
            +
            has_rdoc: true
         
     | 
| 
      
 52 
     | 
    
         
            +
            homepage: http://github.com/jasontorres/monitaur
         
     | 
| 
      
 53 
     | 
    
         
            +
            licenses: []
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
      
 55 
     | 
    
         
            +
            post_install_message: 
         
     | 
| 
      
 56 
     | 
    
         
            +
            rdoc_options: []
         
     | 
| 
      
 57 
     | 
    
         
            +
             
     | 
| 
      
 58 
     | 
    
         
            +
            require_paths: 
         
     | 
| 
      
 59 
     | 
    
         
            +
            - lib
         
     | 
| 
      
 60 
     | 
    
         
            +
            required_ruby_version: !ruby/object:Gem::Requirement 
         
     | 
| 
      
 61 
     | 
    
         
            +
              none: false
         
     | 
| 
      
 62 
     | 
    
         
            +
              requirements: 
         
     | 
| 
      
 63 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 64 
     | 
    
         
            +
                - !ruby/object:Gem::Version 
         
     | 
| 
      
 65 
     | 
    
         
            +
                  version: "0"
         
     | 
| 
      
 66 
     | 
    
         
            +
            required_rubygems_version: !ruby/object:Gem::Requirement 
         
     | 
| 
      
 67 
     | 
    
         
            +
              none: false
         
     | 
| 
      
 68 
     | 
    
         
            +
              requirements: 
         
     | 
| 
      
 69 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 70 
     | 
    
         
            +
                - !ruby/object:Gem::Version 
         
     | 
| 
      
 71 
     | 
    
         
            +
                  version: "0"
         
     | 
| 
      
 72 
     | 
    
         
            +
            requirements: []
         
     | 
| 
      
 73 
     | 
    
         
            +
             
     | 
| 
      
 74 
     | 
    
         
            +
            rubyforge_project: monitaur
         
     | 
| 
      
 75 
     | 
    
         
            +
            rubygems_version: 1.6.2
         
     | 
| 
      
 76 
     | 
    
         
            +
            signing_key: 
         
     | 
| 
      
 77 
     | 
    
         
            +
            specification_version: 3
         
     | 
| 
      
 78 
     | 
    
         
            +
            summary: Rails 3 Website Monitoring Tool
         
     | 
| 
      
 79 
     | 
    
         
            +
            test_files: 
         
     | 
| 
      
 80 
     | 
    
         
            +
            - test/monitaur_controller_test.rb
         
     | 
| 
      
 81 
     | 
    
         
            +
            - test/monitaur_inspector_test.rb
         
     | 
| 
      
 82 
     | 
    
         
            +
            - test/monitaur_test.rb
         
     | 
| 
      
 83 
     | 
    
         
            +
            - test/test_helper.rb
         
     |