Commit 74683c9c authored by John E. Vincent's avatar John E. Vincent

merging in testing

parents ae0e610d c9a725d2
require 'autotest/growl'
Autotest.add_hook(:initialize) {|at|
at.add_exception %r{^\.git} # ignore Version Control System
at.add_exception %r{^./tmp} # ignore temp files, lest autotest will run again, and again...
at.clear_mappings # take out the default (test/test*rb)
at.add_mapping(%r{^noah\.rb$}) {|f, _|
Dir['spec/**/*.rb']
}
at.add_mapping(%r{^lib/.*\.rb$}) {|f, _|
Dir['spec/**/*.rb']
}
nil
}
.rvmrc
*.swp
coverage.data
.idea
.gem
pkg/*
logs/*
PATH
remote: .
specs:
noah (0.0.5)
haml (= 3.0.25)
ohm (= 0.1.3)
ohm-contrib (= 0.1.0)
rake (= 0.8.7)
sinatra (= 1.1.2)
sinatra-namespace (= 0.6.1)
thin (= 1.2.7)
vegas (= 0.1.8)
yajl-ruby (= 0.7.9)
GEM
remote: http://rubygems.org/
specs:
ZenTest (4.4.2)
autotest (4.4.6)
ZenTest (>= 4.4.1)
autotest-growl (0.2.9)
backports (1.18.2)
daemons (1.1.0)
diff-lcs (1.1.2)
eventmachine (0.12.10)
haml (3.0.25)
monkey-lib (0.5.4)
backports
nest (1.1.0)
redis (~> 2.1)
ohm (0.1.3)
nest (~> 1.0)
ohm-contrib (0.1.0)
ohm
rack (1.2.1)
rack-test (0.5.7)
rack (>= 1.0)
rake (0.8.7)
rcov (0.9.9)
redis (2.1.1)
rspec (2.4.0)
rspec-core (~> 2.4.0)
rspec-expectations (~> 2.4.0)
rspec-mocks (~> 2.4.0)
rspec-core (2.4.0)
rspec-expectations (2.4.0)
diff-lcs (~> 1.1.2)
rspec-mocks (2.4.0)
sinatra (1.1.2)
rack (~> 1.1)
tilt (~> 1.2)
sinatra-advanced-routes (0.5.1)
monkey-lib (~> 0.5.0)
sinatra (~> 1.0)
sinatra-sugar (~> 0.5.0)
sinatra-namespace (0.6.1)
sinatra (~> 1.1)
sinatra-reloader (0.5.0)
sinatra (~> 1.0)
sinatra-advanced-routes (~> 0.5.0)
sinatra-sugar (0.5.0)
monkey-lib (~> 0.5.0)
sinatra (~> 1.0)
thin (1.2.7)
daemons (>= 1.0.9)
eventmachine (>= 0.12.6)
rack (>= 1.0.0)
tilt (1.2.2)
vegas (0.1.8)
rack (>= 1.0.0)
yajl-ruby (0.7.9)
PLATFORMS
java
ruby
DEPENDENCIES
ZenTest (= 4.4.2)
autotest (= 4.4.6)
autotest-growl (= 0.2.9)
noah!
rack-test (= 0.5.7)
rcov (= 0.9.9)
rspec (= 2.4.0)
sinatra-reloader (= 0.5.0)
This diff is collapsed.
require 'bundler'
begin
Bundler.setup(:default, :development)
rescue Bundler::BundlerError => e
$stderr.puts e.message
$stderr.puts "Run `bundle install` to install missing gems"
exit e.status_code
end
require 'rake'
require 'rspec/core'
require 'rspec/core/rake_task'
Bundler::GemHelper.install_tasks
desc "Populate database with sample dataset"
task :sample, :redis_url do |t, args|
require 'ohm'
begin
require 'yajl'
rescue LoadError
require 'json'
end
require File.join(File.dirname(__FILE__), 'lib','noah')
Ohm::connect(:url => args.redis_url)
Ohm::redis.flushdb
puts "Creating Host entry for 'localhost'"
h = Host.create(:name => 'localhost', :status => "up")
if h.save
%w[redis noah].each do |service|
puts "Create Service entry for #{service}"
s = Service.create(:name => service, :status => "up", :host => h)
h.services << s
end
end
puts "Creating Application entry for 'noah'"
a = Application.create(:name => 'noah')
if a.save
puts "Creating Configuration entry for 'noah'"
cr = Configuration.create(:name => 'redis', :format => 'string', :body => 'redis://127.0.0.1:6379/0', :application => a)
ch = Configuration.create(:name => 'host', :format => 'string', :body => 'localhost', :application => a)
cp = Configuration.create(:name => 'port', :format => 'string', :body => '9292', :application => a)
%w[cr ch cp].each do |c|
a.configurations << eval(c)
end
end
puts "Creating sample entries - Host and Service"
%w[host1.domain.com host2.domain.com host3.domain.com].each do |host|
h = Host.create(:name => host, :status => "up")
if h.save
%w[http https smtp mysql].each do |service|
s = Service.create(:name => service, :status => "pending", :host => h)
h.services << s
end
end
end
puts "Creating sample entries - Application and Configuration"
my_yaml = <<EOY
development:
database: development_database
adapter: mysql
username: dev_user
password: dev_password
EOY
my_json = <<EOJ
{
"id":"hostname",
"data":"localhost"
}
EOJ
a1 = Application.create(:name => 'myrailsapp1')
if a1.save
c1 = Configuration.create(:name => 'database.yml', :format => 'yaml', :body => my_yaml, :application => a1)
a1.configurations << c1
end
a2 = Application.create(:name => 'myrestapp1')
if a2.save
c2 = Configuration.create(:name => 'config.json', :format => 'json', :body => my_json, :application => a2)
a2.configurations << c2
end
puts "Sample data populated!"
end
RSpec::Core::RakeTask.new(:spec) do |spec|
spec.pattern = FileList['spec/**/*_spec.rb']
end
namespace :coverage do
desc "Delete aggregate coverage data."
task(:clean) { rm_f "coverage.data" }
end
desc "Run Rcov code coverage analysis"
RSpec::Core::RakeTask.new(:coverage) do |t|
t.rcov = true
t.verbose = true
t.rcov_opts = %q[--aggregate coverage.data --sort coverage --text-report --exclude "config,.bundle/*,gems/*,spec/*" -o doc/coverage -Ilib -i "noah.rb"]
end
Autotest.add_discovery { "rspec2" }
#!/usr/bin/env ruby
$:.unshift(File.expand_path(File.join(File.dirname(__FILE__), "..", "lib")))
require 'noah'
require 'vegas'
Vegas::Runner.new(Noah::App, 'noah') do |runner, opts, app|
opts.on("-r", "--redis URL", "redis url to connect to (default: redis://localhost:6379/0)") {|r| ENV["REDIS_URL"] = r }
end
require File.join(File.dirname(__FILE__), 'lib','noah')
ENV['REDIS_URL'] = "redis://localhost:6379/0"
run Noah::App
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang='en' xml:lang='en' xmlns='http://www.w3.org/1999/xhtml'>
<head>
<meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
<title>Noah C0 Coverage Information - RCov</title>
<link href="screen.css" media="all" rel="stylesheet" type="text/css" />
<link href="print.css" media="print" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="jquery.tablesorter.min.js"></script>
<script type="text/javascript" src="rcov.js"></script>
</head>
<body>
<h1>Noah C0 Coverage Information - RCov</h1>
<noscript><style type="text/css">.if_js { display:none; }</style></noscript>
<div class="filters if_js">
<fieldset>
<label>File Filter:</label>
<select id="file_filter" class="filter">
<option value="all_files">Show All</option>
<option value="lib">lib/</option>
</select>
</fieldset>
<fieldset>
<label>Code Coverage Threshold:</label>
<select id="coverage_filter" class="filter">
<option value="all_coverage">Show All</option>
<option value="10">&lt; 10% Coverage</option><option value="20">&lt; 20% Coverage</option><option value="30">&lt; 30% Coverage</option><option value="40">&lt; 40% Coverage</option><option value="50">&lt; 50% Coverage</option><option value="60">&lt; 60% Coverage</option><option value="70">&lt; 70% Coverage</option><option value="80">&lt; 80% Coverage</option><option value="90">&lt; 90% Coverage</option><option value="100">&lt; 100% Coverage</option>
<option value="110">= 100% Coverage</option>
</select>
</fieldset>
</div>
<div class="report_table_wrapper">
<table class='report' id='report_table'>
<thead>
<tr>
<th class="left_align">Name</th>
<th class="right_align">Total Lines</th>
<th class="right_align">Lines of Code</th>
<th class="left_align">Total Coverage</th>
<th class="left_align">Code Coverage</th>
</tr>
</thead>
<tfoot>
<tr>
<td class="left_align">TOTAL</td>
<td class='right_align'><tt>612</tt></td>
<td class='right_align'><tt>521</tt></td>
<td class="left_align"><div class="percent_graph_legend"><tt class=''>83.33%</tt></div>
<div class="percent_graph">
<div class="covered" style="width:83px"></div>
<div class="uncovered" style="width:17px"></div>
</div></td>
<td class="left_align"><div class="percent_graph_legend"><tt class='coverage_total'>81.96%</tt></div>
<div class="percent_graph">
<div class="covered" style="width:82px"></div>
<div class="uncovered" style="width:18px"></div>
</div></td>
</tr>
</tfoot>
<tbody>
<tr class="all_files all_coverage 60 70 80 90 100 lib even">
<td class="left_align"><a href="lib-helpers_rb.html">lib/helpers.rb</a></td>
<td class='right_align'><tt>55</tt></td>
<td class='right_align'><tt>45</tt></td>
<td class="left_align"><div class="percent_graph_legend"><tt class=''>56.36%</tt></div>
<div class="percent_graph">
<div class="covered" style="width:56px"></div>
<div class="uncovered" style="width:44px"></div>
</div></td>
<td class="left_align"><div class="percent_graph_legend"><tt class=''>57.78%</tt></div>
<div class="percent_graph">
<div class="covered" style="width:58px"></div>
<div class="uncovered" style="width:42px"></div>
</div></td>
</tr>
<tr class="all_files all_coverage 90 100 odd">
<td class="left_align"><a href="noah_rb.html">noah.rb</a></td>
<td class='right_align'><tt>326</tt></td>
<td class='right_align'><tt>285</tt></td>
<td class="left_align"><div class="percent_graph_legend"><tt class=''>82.52%</tt></div>
<div class="percent_graph">
<div class="covered" style="width:83px"></div>
<div class="uncovered" style="width:17px"></div>
</div></td>
<td class="left_align"><div class="percent_graph_legend"><tt class=''>81.05%</tt></div>
<div class="percent_graph">
<div class="covered" style="width:81px"></div>
<div class="uncovered" style="width:19px"></div>
</div></td>
</tr>
<tr class="all_files all_coverage 90 100 lib even">
<td class="left_align"><a href="lib-models_rb.html">lib/models.rb</a></td>
<td class='right_align'><tt>231</tt></td>
<td class='right_align'><tt>191</tt></td>
<td class="left_align"><div class="percent_graph_legend"><tt class=''>90.91%</tt></div>
<div class="percent_graph">
<div class="covered" style="width:91px"></div>
<div class="uncovered" style="width:9px"></div>
</div></td>
<td class="left_align"><div class="percent_graph_legend"><tt class=''>89.01%</tt></div>
<div class="percent_graph">
<div class="covered" style="width:89px"></div>
<div class="uncovered" style="width:11px"></div>
</div></td>
</tr>
</tbody>
</table>
</div>
<p>Generated on 2011-01-31 05:03:32 -0500 with <a href="http://github.com/relevance/rcov">rcov 0.9.8</a></p>
<script type="text/javascript">
$(document).ready(function(){$("#report_table").tablesorter({widgets: ['zebra'], textExtraction: 'complex'});});
$('.filter').change(function(){
ff = $('#file_filter').val();
cf = $('#coverage_filter').val();
$('table#report_table tbody tr').each(function(i){
if ((this.className.split(" ").indexOf(ff) > -1) && (this.className.split(" ").indexOf(cf) > -1)) {
this.style.display = "";
} else {
this.style.display = "none";
};
restripe();
})
})
</script>
</body>
</html>
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/* Hide controls */
body {
color: #000000;
background-color: #ffffff;
}
/* Hide controls */
div.filters {
display: none;
}
\ No newline at end of file
function toggleCode( id ) {
if ( document.getElementById ) {
elem = document.getElementById( id );
} else if ( document.all ) {
elem = eval( "document.all." + id );
} else {
return false;
}
elemStyle = elem.style;
if ( elemStyle.display != "block" ) {
elemStyle.display = "block";
} else {
elemStyle.display = "none";
}
return true;
}
function restripe() {
i = 0;
$('table#report_table tbody tr').each(function(){
if (this.style.display != "none") {
i += 1;
classes = this.className.split(" ");
if ($.inArray("even",classes) != -1) {
classes.splice($.inArray("even",classes),1);
} else if ($.inArray("odd",classes) != -1) {
classes.splice($.inArray("odd",classes),1);
}
if (i % 2 === 0) {
this.className = classes.join(" ") + " odd";
} else {
this.className = classes.join(" ") + " even";
}
}
});
}
// Fix IE's lack of support for indexOf (!)
if (!Array.indexOf) { Array.prototype.indexOf = function(obj){ for(var i=0; i<this.length; i++){ if(this[i]==obj){return i;} } return -1; }}
\ No newline at end of file
/* @group General */
body {
font-family: Verdana, Helvetica, Arial, Sans-Serif;
font-size: 12px;
color: #4C4C4C;
background-color: #F4F2ED;
padding: 1em;
}
a:link {
color: #191919;
}
a:visited {
color: #191919;
}
pre, code {
color: #000000;
font-family: "Bitstream Vera Sans Mono","Monaco","Courier New",monospace;
font-size: 95%;
line-height: 1.3em;
margin-top: 0;
margin-bottom: 0;
padding: 0;
word-wrap: break-word;
}
h1, h2, h3, h4, h5, h6 {
margin: 0em 0em 1em 0em;
color: #666666;
}
h1 {
display: block;
font-size: 2em;
letter-spacing: -1px;
}
h2 {
margin-top: -1em;
}
fieldset {
display: inline;
border: 0px;
padding: 0px;
margin-right: 1em;
}
div.filters {
margin-bottom: 1em;
}
.hidden {
display: none;
}
/* @end */
/* @group Cross-References */
span.cross-ref-title {
font-size: 140%;
}
span.cross-ref a {
text-decoration: none;
}
span.cross-ref {
background-color:#f3f7fa;
border: 1px dashed #333;
margin: 1em;
padding: 0.5em;
overflow: hidden;
}
a.crossref-toggle {
text-decoration: none;
}
/* @end */
/* @group Report Table */
div.report_table_wrapper {
min-width: 900px;
}
table.report {
border-collapse: collapse;
border: 1px solid #666666;
width: 100%;
margin-bottom: 1em;
}
table.report tr {
line-height: 1.75em;
}
table.report th {
background: #666666;
color: #ffffff;
text-align: right;
text-transform: uppercase;
font-size: .8em;
font-weight: bold;
padding: 0em .5em;
border: 1px solid #666666;
}
table.report tfoot tr {
background: #dddddd;
font-weight: bold;
padding: .5em;
border: 1px solid #666666;
}
th.left_align, td.left_align {
text-align: left !important;
}
th.right_align, td.right_align {
text-align: right;
padding-right: 2em !important;
}
table.report th.header:hover {
cursor: pointer;
text-decoration: underline;
}
table.report th.headerSortUp:after{
content: "\25BC";
margin-left: 1em;
}
table.report th.headerSortDown:after {
content: "\25B2";
margin-left: 1em;
}
table.report tr.summary_row {
background: #cccccc;
border: 1px solid #cccccc;
}
table.report tr.summary_row td {
padding-left: .2em !important;
color: #333333;
font-weight: bold;
}
table.report td {
padding: .2em .5em .2em .5em;
}
table.report td a {
text-decoration: none;
}
table.report tbody tr:hover {
background: #cccccc !important;
}
table.report tr.summary_row td {
border-bottom: 1px solid #aaaaaa;
}
table.report tr {
background-color: #eeeeee;
}
table.report tr.odd {
background-color: #dddddd;
}
/* @end */
/* @group Percentage Graphs */
div.percent_graph_legend {
width: 5.5em;
float: left;
margin: .5em 1em .5em 0em;
height: 1em;
line-height: 1em;
}
div.percent_graph {
height: 1em;
border: #333333 1px solid;
empty-cells: show;
padding: 0px;
border-collapse: collapse;
width: 100px !important;
float: left;
margin: .5em 1em .5em 0em;
}
div.percent_graph div {
float: left;
height: 1em;
padding: 0px !important;
}
div.percent_graph div.covered {
background: #649632;
}
div.percent_graph div.uncovered {
background: #a92730;
}
div.percent_graph div.NA {
background: #eaeaea;
}
/* @end */
/* @group Details page */
table.details {
margin-top: 1em;
border-collapse: collapse;
width: 100%;
border: 1px solid #666666;
}
table.details tr {
line-height: 1.75em;
}
table.details td {
padding: .25em;
}
span.inferred, span.inferred1, span.marked, span.marked1, span.uncovered, span.uncovered1 {
display: block;
padding: .25em;
}
tr.inferred td, span.inferred {
background-color: #e0dedb;
}
tr.inferred1 td, span.inferred1 {
background-color: #e0dedb;
}
tr.marked td, span.marked, span.marked1 {
background-color: #bed2be;
}
tr.uncovered td, span.uncovered {
background-color: #ce8b8c;
}
tr.uncovered1 td, span.uncovered1 {
background-color: #ce8b8c;
}
div.key {
border: 1px solid #666666;
margin: 1em 0em;
}
/* @end */
require 'ohm'
require 'ohm/contrib'
begin
require 'yajl'
rescue LoadError
require 'json'
end
require 'haml'
require 'yaml'
require 'sinatra/base'
require 'sinatra/namespace'
require File.join(File.dirname(__FILE__), 'noah','hosts')
require File.join(File.dirname(__FILE__), 'noah','services')
require File.join(File.dirname(__FILE__), 'noah','applications')
require File.join(File.dirname(__FILE__), 'noah','configurations')
require File.join(File.dirname(__FILE__), 'noah','watchers')
require File.join(File.dirname(__FILE__), 'noah','app')
This diff is collapsed.
class Application < Ohm::Model
include Ohm::Typecast
include Ohm::Timestamping
include Ohm::Callbacks
include Ohm::ExtraValidations
attribute :name
collection :configurations, Configuration
index :name
def validate
assert_present :name
assert_unique :name
end
def to_hash
arr = []
configurations.sort.each {|c| arr << c.to_hash}
super.merge(:name => name, :updated_at => updated_at, :configurations => arr)
end
def is_new?
self.created_at == self.updated_at
end
class << self
def find_or_create(opts = {})
begin
find(opts).first.nil? ? (app = create(opts)) : (app = find(opts).first)
if app.valid?
app.save
end
app
rescue Exception => e
e.message
end
end
end
end
class Applications
def self.all(options = {})
options.empty? ? Application.all.sort : Application.find(options).sort
end
end
class Configuration < Ohm::Model
include Ohm::Typecast
include Ohm::Timestamping
include Ohm::Callbacks
include Ohm::ExtraValidations
attribute :name
attribute :format
attribute :body
attribute :new_record
reference :application, Application
index :name
def validate
assert_present :name
assert_present :format
assert_present :body
assert_unique [:name, :application_id]
end
def to_hash
super.merge(:name => name, :format => format, :body => body, :update_at => updated_at, :application => Application[application_id].name)
end
def is_new?
self.created_at == self.updated_at
end
class << self
def find_or_create(opts={})
begin
if find(opts).first.nil?
conf = create(opts)
else
conf = find(opts).first
end
rescue Exception => e
e.message
end
end
end
end
class Configurations
def self.all(options = {})
options.empty? ? Configuration.all.sort : Configuration.find(options).sort
end
end
This diff is collapsed.
This diff is collapsed.
require File.join(File.dirname(__FILE__),'hosts')
require File.join(File.dirname(__FILE__),'services')
require File.join(File.dirname(__FILE__),'applications')
require File.join(File.dirname(__FILE__),'configurations')
require File.join(File.dirname(__FILE__),'watchers')
This diff is collapsed.
module Noah
VERSION = "0.0.5"
end
class Watcher < Ohm::Model #NYI
include Ohm::Typecast
include Ohm::Timestamping
include Ohm::Callbacks
attribute :client
attribute :endpoint
attribute :event
attribute :action
index :client
index :event
def validate
assert_present :client, :endpoint, :event, :action
assert_unique [:client, :endpoint, :event, :action]
end
end
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
<%= {:status => "success"}.merge(api_call_results).to_json %>
{"result":"failure","error_message":"Resource not found"}
{"result":"failure","error_message":"<%= request.env['sinatra.error'].message %>"}
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment