Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
TEAMOD committed Mar 11, 2009
0 parents commit 0dcf303
Show file tree
Hide file tree
Showing 90 changed files with 8,216 additions and 0 deletions.
Binary file added app/._controllers
Binary file not shown.
Binary file added app/._helpers
Binary file not shown.
Binary file added app/._models
Binary file not shown.
Binary file added app/._views
Binary file not shown.
Binary file added app/controllers/._application.rb
Binary file not shown.
15 changes: 15 additions & 0 deletions app/controllers/application.rb
@@ -0,0 +1,15 @@
# Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.

class ApplicationController < ActionController::Base
helper :all # include all helpers, all the time

# See ActionController::RequestForgeryProtection for details
# Uncomment the :secret if you're not using the cookie session store
protect_from_forgery # :secret => '9130aadf73a0469f57dfb3d8e06f528b'

# See ActionController::Base for details
# Uncomment this to filter the contents of submitted sensitive data parameters
# from your application log (in this case, all fields with names like "password").
# filter_parameter_logging :password
end
Binary file added app/helpers/._application_helper.rb
Binary file not shown.
3 changes: 3 additions & 0 deletions app/helpers/application_helper.rb
@@ -0,0 +1,3 @@
# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
end
Binary file added app/models/._scheduler.rb
Binary file not shown.
78 changes: 78 additions & 0 deletions app/models/scheduler.rb
@@ -0,0 +1,78 @@
require 'rubygems'
require 'hpricot'
require 'open-uri'
require 'rufus/scheduler'

# Uses the rufus scheduler to check for builds that passed or failed. Performs X10 action with bottlerocket's 'br' command

class Scheduler
include Singleton

def start
@last = {}
@failing_builds = Set.new

scheduler = Rufus::Scheduler.start_new
scheduler.every "10s" do
parse(Conf.ruby1_url)
parse(Conf.build1_url)
end
end


def parse(url)
file = open(url);
doc = Hpricot.XML(file)
file.close
# name="2008-07-25-homepage" activity="Sleeping" lastBuildStatus="Failure" lastBuildLabel="" lastBuildTime="2008-10-01T20:51:46"
doc.search("/projects/project").each do |project|
project_name = project.attributes["name"]
status = project.attributes["lastBuildStatus"]
time = project.attributes["lastBuildTime"]

followed_builds = Conf.branches.split(",").map {|x| x.strip}

if followed_builds.include?(project_name)
previous_build = @last[project_name]
@last[project_name] = {"project" => project_name, "time" => time, "status" => status}

if status.include?("Fail")
@failing_builds << project_name
on_fail(project_name)
elsif !previous_build.nil? && (previous_build["time"] != time) && status.include?("Success")
@failing_builds.delete(project_name)
if (!previous_build["status"].include?("Fail"))
on_pass(project_name)
off_pass
off_pass
elsif @failing_builds.empty?
off_fail
end
end
end
end
end

def on_pass(project_name)
puts "#{project_name} Bubbles!!!!!"
system("br #{Conf.x10_house_code}#{Conf.x10_pass_device} ON")
sleep 3
end

def off_pass
puts "Bubbles Off"
system("br #{Conf.x10_house_code}#{Conf.x10_pass_device} OFF")
sleep 2
end

def on_fail(project_name)
puts "#{project_name} Red Light!!!"
system("br #{Conf.x10_house_code}#{Conf.x10_failure_device} ON")
end

def off_fail
puts "Light Off"
system("br #{Conf.x10_house_code}#{Conf.x10_failure_device} OFF")
end

end
79 changes: 79 additions & 0 deletions app/models/scheduler.rb~
@@ -0,0 +1,79 @@
require 'rubygems'
require 'hpricot'
require 'open-uri'
require 'rufus/scheduler'

# Uses the rufus scheduler to check for builds that passed or failed. Performs X10 action with bottlerocket's 'br' command
# Author: Patrick Foley

class Scheduler
include Singleton

def start
@last = {}
@failing_builds = Set.new

scheduler = Rufus::Scheduler.start_new
scheduler.every "10s" do
parse(Conf.ruby1_url)
parse(Conf.build1_url)
end
end


def parse(url)
file = open(url);
doc = Hpricot.XML(file)
file.close
# name="2008-07-25-homepage" activity="Sleeping" lastBuildStatus="Failure" lastBuildLabel="" lastBuildTime="2008-10-01T20:51:46"
doc.search("/projects/project").each do |project|
project_name = project.attributes["name"]
status = project.attributes["lastBuildStatus"]
time = project.attributes["lastBuildTime"]

followed_builds = Conf.branches.split(",").map {|x| x.strip}

if followed_builds.include?(project_name)
previous_build = @last[project_name]
@last[project_name] = {"project" => project_name, "time" => time, "status" => status}

if status.include?("Fail")
@failing_builds << project_name
on_fail(project_name)
elsif !previous_build.nil? && (previous_build["time"] != time) && status.include?("Success")
@failing_builds.delete(project_name)
if (!previous_build["status"].include?("Fail"))
on_pass(project_name)
off_pass
off_pass
elsif @failing_builds.empty?
off_fail
end
end
end
end
end

def on_pass(project_name)
puts "#{project_name} Bubbles!!!!!"
system("br #{Conf.x10_house_code}#{Conf.x10_pass_device} ON")
sleep 3
end

def off_pass
puts "Bubbles Off"
system("br #{Conf.x10_house_code}#{Conf.x10_pass_device} OFF")
sleep 2
end

def on_fail(project_name)
puts "#{project_name} Red Light!!!"
system("br #{Conf.x10_house_code}#{Conf.x10_failure_device} ON")
end

def off_fail
puts "Light Off"
system("br #{Conf.x10_house_code}#{Conf.x10_failure_device} OFF")
end

end
Binary file added app/views/._layouts
Binary file not shown.
Binary file added doc/._README_FOR_APP
Binary file not shown.
5 changes: 5 additions & 0 deletions doc/README_FOR_APP
@@ -0,0 +1,5 @@
To build the guides:

* Install source-highlighter (http://www.gnu.org/software/src-highlite/source-highlight.html)
* Install the mizuho gem (http://github.com/FooBarWidget/mizuho/tree/master)
* Run `rake guides` from the railties directory
Binary file added lib/._tasks
Binary file not shown.
Binary file added public/._404.html
Binary file not shown.
Binary file added public/._422.html
Binary file not shown.
Binary file added public/._500.html
Binary file not shown.
Binary file added public/._dispatch.cgi
Binary file not shown.
Binary file added public/._dispatch.fcgi
Binary file not shown.
Binary file added public/._dispatch.rb
Binary file not shown.
Binary file added public/._favicon.ico
Binary file not shown.
Binary file added public/._images
Binary file not shown.
Binary file added public/._index.html
Binary file not shown.
Binary file added public/._javascripts
Binary file not shown.
Binary file added public/._robots.txt
Binary file not shown.
Binary file added public/._stylesheets
Binary file not shown.
30 changes: 30 additions & 0 deletions public/404.html
@@ -0,0 +1,30 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>The page you were looking for doesn't exist (404)</title>
<style type="text/css">
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
div.dialog {
width: 25em;
padding: 0 4em;
margin: 4em auto 0 auto;
border: 1px solid #ccc;
border-right-color: #999;
border-bottom-color: #999;
}
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
</style>
</head>

<body>
<!-- This file lives in public/404.html -->
<div class="dialog">
<h1>The page you were looking for doesn't exist.</h1>
<p>You may have mistyped the address or the page may have moved.</p>
</div>
</body>
</html>
30 changes: 30 additions & 0 deletions public/422.html
@@ -0,0 +1,30 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>The change you wanted was rejected (422)</title>
<style type="text/css">
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
div.dialog {
width: 25em;
padding: 0 4em;
margin: 4em auto 0 auto;
border: 1px solid #ccc;
border-right-color: #999;
border-bottom-color: #999;
}
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
</style>
</head>

<body>
<!-- This file lives in public/422.html -->
<div class="dialog">
<h1>The change you wanted was rejected.</h1>
<p>Maybe you tried to change something you didn't have access to.</p>
</div>
</body>
</html>
33 changes: 33 additions & 0 deletions public/500.html
@@ -0,0 +1,33 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>We're sorry, but something went wrong (500)</title>
<style type="text/css">
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
div.dialog {
width: 25em;
padding: 0 4em;
margin: 4em auto 0 auto;
border: 1px solid #ccc;
border-right-color: #999;
border-bottom-color: #999;
}
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
</style>
</head>

<body>
<!-- This file lives in public/500.html -->
<div class="dialog">
<h1>We're sorry, but something went wrong.</h1>
<p>We've been notified about this issue and we'll take a look at it shortly.</p>
<p><small>(If you're the administrator of this website, then please read
the log file "<%=h RAILS_ENV %>.log"
to find out what went wrong.)</small></p>
</div>
</body>
</html>
10 changes: 10 additions & 0 deletions public/dispatch.cgi
@@ -0,0 +1,10 @@
#!/opt/local/bin/ruby

require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT)

# If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like:
# "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impaired
require "dispatcher"

ADDITIONAL_LOAD_PATHS.reverse.each { |dir| $:.unshift(dir) if File.directory?(dir) } if defined?(Apache::RubyRun)
Dispatcher.dispatch
24 changes: 24 additions & 0 deletions public/dispatch.fcgi
@@ -0,0 +1,24 @@
#!/opt/local/bin/ruby
#
# You may specify the path to the FastCGI crash log (a log of unhandled
# exceptions which forced the FastCGI instance to exit, great for debugging)
# and the number of requests to process before running garbage collection.
#
# By default, the FastCGI crash log is RAILS_ROOT/log/fastcgi.crash.log
# and the GC period is nil (turned off). A reasonable number of requests
# could range from 10-100 depending on the memory footprint of your app.
#
# Example:
# # Default log path, normal GC behavior.
# RailsFCGIHandler.process!
#
# # Default log path, 50 requests between GC.
# RailsFCGIHandler.process! nil, 50
#
# # Custom log path, normal GC behavior.
# RailsFCGIHandler.process! '/var/log/myapp_fcgi_crash.log'
#
require File.dirname(__FILE__) + "/../config/environment"
require 'fcgi_handler'

RailsFCGIHandler.process!
10 changes: 10 additions & 0 deletions public/dispatch.rb
@@ -0,0 +1,10 @@
#!/opt/local/bin/ruby

require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT)

# If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like:
# "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impaired
require "dispatcher"

ADDITIONAL_LOAD_PATHS.reverse.each { |dir| $:.unshift(dir) if File.directory?(dir) } if defined?(Apache::RubyRun)
Dispatcher.dispatch
Empty file added public/favicon.ico
Empty file.
Binary file added public/images/._rails.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/rails.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 0dcf303

Please sign in to comment.