code stringlengths 1 1.73M | language stringclasses 1
value |
|---|---|
class String
# see if string has any content
def blank?; self.length.zero?; end
# strip space after :, remove newlines, replace multiple spaces with only one space, remove comments
def strip_space!
replace self.gsub(/:\s*/, ":").gsub(/\n/, "").gsub(/\s+/, " ").gsub(/(\/\*).*?(\*\/)/, "")
end
# remove ... | Ruby |
require "yaml"
require "optparse"
module Blueprint
class Compressor
TEST_FILES = ["index.html",
"parts/elements.html",
"parts/forms.html",
"parts/grid.html",
"parts/sample.html"]
attr_accessor :namespace, :custom_css, :custom_layout, :se... | Ruby |
begin
require "rubygems"
gem "rmagick"
require "rvg/rvg"
rescue Exception => e
puts " #{"*" * 100}"
puts " **"
puts " ** Warning:"
puts " ** Could not load the Rmagick gem. Please check your installation."
puts " ** grid.png will not be generated."
puts " **"
puts " #{"*" * 100}\n"
end... | Ruby |
module Blueprint
# Strips out most whitespace and can return a hash or string of parsed data
class CSSParser
attr_accessor :namespace
attr_reader :css_output, :raw_data
# ==== Options
# * <tt>css_string</tt> String of CSS data
# * <tt>options</tt>
# * <tt>:namespace</tt> -- Namespace to... | Ruby |
module Blueprint
class Namespace
# Read html to string, remove namespace if any,
# set the new namespace, and update the test file.
def initialize(path, namespace)
html = File.path_to_string(path)
remove_current_namespace(html)
add_namespace(html, namespace)
File.string_to_file(ht... | Ruby |
require 'fileutils'
module Blueprint
# path to the root Blueprint directory
ROOT_PATH = File.join(File.expand_path(File.dirname(__FILE__)), "../../")
# path to where the Blueprint CSS files are stored
BLUEPRINT_ROOT_PATH = File.join(Blueprint::ROOT_PATH, "blueprint")
# path to where the Blueprin... | Ruby |
module Blueprint
# Validates generated CSS against the W3 using Java
class Validator
attr_reader :error_count
def initialize
@error_count = 0
end
# Validates all three CSS files
def validate
java_path = `which java`.rstrip
raise "You do not have a Java installed, but it is re... | Ruby |
require 'erb'
module Blueprint
# Generates a custom grid file, using ERB to evaluate custom settings
class CustomLayout
# path to ERB file used for CSS template
CSS_ERB_FILE = File.join(Blueprint::LIB_PATH, 'grid.css.erb')
attr_writer :column_count, :column_width, :gutter_width, :input_padding,
... | Ruby |
#!/usr/bin/env ruby
require "blueprint/blueprint"
require "blueprint/validator"
# This script will validate the core Blueprint files.
#
# The files are not completely valid. This has to do
# with a small number of CSS hacks needed to ensure
# consistent rendering across browsers.
#
# To add your own CSS files for val... | Ruby |
#!/usr/bin/env ruby
require File.join(File.dirname(__FILE__), "blueprint", "blueprint")
# **Basic
#
# Calling this file by itself will pull files from blueprint/src and
# concatenate them into three files; ie.css, print.css, and screen.css.
#
# ruby compress.rb
#
# However, argument variables can be set to c... | Ruby |
# Require any additional compass plugins here.
# Set this to the root of your project when deployed:
http_path = "/"
css_dir = "theme/css"
sass_dir = "theme/scss"
images_dir = "images"
javascripts_dir = "js"
# You can select your preferred output style here (can be overridden via the command line):
output_style = :co... | Ruby |
# This defines a deployment "recipe" that you can feed to capistrano
# (http://manuals.rubyonrails.com/read/book/17). It allows you to automate
# (among other things) the deployment of your application.
# =============================================================================
# REQUIRED VARIABLES
# =============... | Ruby |
# Settings specified here will take precedence over those in config/environment.rb
# The production environment is meant for finished, "live" apps.
# Code is not reloaded between requests
config.cache_classes = true
# Use a different logger for distributed setups
# config.logger = SyslogLogger.new
# Full error repor... | Ruby |
# Settings specified here will take precedence over those in config/environment.rb
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the webserver when you make code changes.
config.ca... | Ruby |
# Settings specified here will take precedence over those in config/environment.rb
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suite and is wiped
# and recreated between... | Ruby |
# Be sure to restart your web server when you modify this file.
# Uncomment below to force Rails into production mode when
# you don't control web/app server and can't set it the proper way
# ENV['RAILS_ENV'] ||= 'production'
# Specifies gem version of Rails to use when vendor/rails is not present
RAILS_GEM_VERSION ... | Ruby |
# Don't change this file. Configuration is done in config/environment.rb and config/environments/*.rb
unless defined?(RAILS_ROOT)
root_path = File.join(File.dirname(__FILE__), '..')
unless RUBY_PLATFORM =~ /mswin32/
require 'pathname'
root_path = Pathname.new(root_path).cleanpath(true).to_s
end
RAILS... | Ruby |
ActionController::Routing::Routes.draw do |map|
# The priority is based upon order of creation: first created -> highest priority.
# Sample of regular route:
# map.connect 'products/:id', :controller => 'catalog', :action => 'view'
# Keep in mind you can assign values other than :controller and :action
# ... | Ruby |
# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
end
| Ruby |
module HouseAdminHelper
end
| Ruby |
module AuthHelper
end
| Ruby |
module RushHelper
end
| Ruby |
module DeskHelper
end
| Ruby |
class DeskEndAction < DeskAction
belongs_to :desk_action_aggregate,
:class_name => 'DeskActionAggregate',
:foreign_key => 'desk_action_aggregate_id'
end
| Ruby |
class DeskStartAction < DeskAction
belongs_to :desk_action_aggregate,
:class_name => 'DeskActionAggregate',
:foreign_key => 'desk_action_aggregate_id'
end
| Ruby |
class Constraint < ActiveRecord::Base
def self.getValueByKeyAndTime(thiskey,thistime)
thisconstraintobj = Constraint.find(:first,
:conditions => ["(`key` LIKE ?) AND (((start_time < ?) OR (start_time IS NULL)) AND ((end_time > ?) OR (end_time IS NULL)))", thiskey, thistime, thistime],
... | Ruby |
class DeskAction < ActiveRecord::Base
validates_presence_of :effective_at, :recorded_at, :recorded_by
has_one :user, :foreign_key => 'recorded_by'
belongs_to :desk_action_aggregate,
:class_name => 'DeskActionAggregate',
:foreign_key => 'desk_action_aggregate_id'
end
| Ruby |
class HouseVisit < DeskActionAggregate
validates_presence_of :house_id
belongs_to :house
has_one :entrance,
:class_name => "Entrance",
:foreign_key => 'desk_action_aggregate_id'
has_one :exit,
:class_name => "Exit",
:foreign_key => 'desk_action_aggregate_id'
... | Ruby |
class FavoriteFreshman < ActiveRecord::Base
belongs_to :freshman
belongs_to :house
validates_uniqueness_of :freshman_id, :scope => :house_id
acts_as_list :scope => :house
end
| Ruby |
class DeskActionAggregate < ActiveRecord::Base
validates_presence_of :freshman_id
belongs_to :freshman
has_one :desk_start_action,
:class_name => "DeskStartAction"
has_one :desk_end_action,
:class_name => "DeskEndAction"
has_many :desk_actions
def currently_active
return desk_e... | Ruby |
class Freshman < ActiveRecord::Base
validates_presence_of :first_name, :last_name, :hometown, :athena_name
validates_uniqueness_of :athena_name
has_many :freshman_jaunts
has_many :favorite_freshmen
has_many :house_visits
has_many :overnights
has_many :desk_action_aggregates
has_many :entrances, :thro... | Ruby |
class Check < ActiveRecord::Base
validates_presence_of :user_id, :freshman_id, :checked_at
belongs_to :user
belongs_to :freshman
def found_actions
actions_to_return = freshman.desk_actions.find(:all,
:conditions => ["effective_at < ?", checked_at],
... | Ruby |
class Wakeup < DeskEndAction
belongs_to :overnight,
:class_name => 'Overnight',
:foreign_key => 'desk_action_aggregate_id'
end
| Ruby |
class Jaunt < ActiveRecord::Base
validates_presence_of :name, :description, :house_id, :start_time, :end_time
belongs_to :house
has_many :freshman_jaunts
def currently_active
if start_time < 1.hour.from_now and end_time > Time.now
return true
else
return !(current_freshman_jaunts.empty?)... | Ruby |
class Overnight < DeskActionAggregate
validates_presence_of :house_id
validates_presence_of :wakeup_time
belongs_to :house
has_one :overnight_start,
:class_name => "OvernightStart",
:foreign_key => 'desk_action_aggregate_id'
has_one :wakeup,
:class_name => "Wakeup",
... | Ruby |
require 'digest/sha1'
class User < ActiveRecord::Base
validates_presence_of :username, :pass_hash, :house_id
validates_uniqueness_of :username
belongs_to :house
has_many :checks
def self.authenticate(username, password)
user = self.find_by_username(username)
if user
expected_password = encrypte... | Ruby |
class House < ActiveRecord::Base
validates_presence_of :name, :abbrev, :address, :phone
validates_uniqueness_of :name, :abbrev
has_many :jaunts
has_many :overnights
has_many :users
has_many :house_visits
has_many :favorite_freshmen, :order => :position
has_many :checks, :through => :users
def active_jaunts... | Ruby |
class Entrance < DeskStartAction
belongs_to :house_visit,
:class_name => 'HouseVisit',
:foreign_key => 'desk_action_aggregate_id'
end
| Ruby |
class FreshmanJaunt < DeskActionAggregate
validates_presence_of :jaunt_id
belongs_to :jaunt
has_one :departure,
:class_name => "Departure",
:foreign_key => 'desk_action_aggregate_id'
has_one :jaunt_return,
:class_name => "JauntReturn",
:foreign_key => 'desk_action_aggr... | Ruby |
class JauntReturn < DeskEndAction
belongs_to :freshman_jaunt,
:class_name => 'FreshmanJaunt',
:foreign_key => 'desk_action_aggregate_id'
end
| Ruby |
class OvernightStart < DeskStartAction
belongs_to :overnight,
:class_name => 'Overnight',
:foreign_key => 'desk_action_aggregate_id'
end
| Ruby |
class Departure < DeskStartAction
belongs_to :freshman_jaunt,
:class_name => 'FreshmanJaunt',
:foreign_key => 'desk_action_aggregate_id'
end
| Ruby |
class Exit < DeskEndAction
validates_presence_of :destination
belongs_to :house_visit,
:class_name => 'HouseVisit',
:foreign_key => 'desk_action_aggregate_id'
end
| Ruby |
class AuthController < ApplicationController
layout "auth"
before_filter :general_authorize, :except => [:login, :xhr_auth_failure]
def login
session[:user_id] = nil
if request.post?
user = User.authenticate(params[:username], params[:password])
if user
session[:user_id] = user.id... | Ruby |
class RushController < ApplicationController
require "facebook"
layout "rush"
before_filter :general_authorize
before_filter :rush_authorize
def index
@this_houses_favorite_freshmen=@logged_in_user.house.favorite_freshmen
max_checks = Constraint.getValueByKeyAndTime('ChecksPerHousePerHour',Time.now... | Ruby |
class DeskController < ApplicationController
layout "desk"
before_filter :general_authorize
before_filter :desk_authorize
def index
@logged_in_house = @logged_in_user.house
@freshmen_in_house = @logged_in_house.freshmen_in_house
@active_jaunts = @logged_in_house.active_jaunts
@overnightin... | Ruby |
# Filters added to this controller will be run for all controllers in the application.
# Likewise, all the methods added will be available for all controllers.
class ApplicationController < ActionController::Base
private
def general_authorize
@logged_in_user = User.find_by_id(session[:user_id])
if @logged_... | Ruby |
class HouseAdminController < ApplicationController
scaffold :jaunt
end
| Ruby |
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require(File.join(File.dirname(__FILE__), 'config', 'boot'))
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
require 'tasks/rails'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/breakpointer' | Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/console' | Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/runner' | Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/performance/benchmarker'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/performance/benchmarker'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/performance/profiler'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/performance/profiler'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/plugin' | Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/destroy' | Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/about' | Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/runner' | Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/breakpointer' | Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/server' | Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/generate' | Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/console' | Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/process/reaper'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/process/spawner'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/process/reaper'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/process/spawner'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/destroy' | Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/generate' | Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/server' | Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/about' | Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/plugin' | Ruby |
class AddStubUsers < ActiveRecord::Migration
def self.up
User.create(:username => 'abdesk@mit.edu', :password => 'wibble', :house_id => House.find_by_abbrev('AB').id, :admin_priv => true, :desk_priv => true, :rush_priv => true)
User.create(:username => 'gddesk@mit.edu', :password => 'wibble', :house_i... | Ruby |
class AddWakeupTime < ActiveRecord::Migration
def self.up
add_column :desk_action_aggregates, :wakeup_time, :datetime
end
def self.down
remove_column :desk_action_aggregates, :wakeup_time
end
end
| Ruby |
class AddPositionToFavoriteFreshmen < ActiveRecord::Migration
def self.up
add_column :favorite_freshmen, :position, :integer
end
def self.down
remove_column :favorite_freshmen, :position
end
end
| Ruby |
class AddSessions < ActiveRecord::Migration
def self.up
create_table :sessions do |t|
t.column :session_id, :string
t.column :data, :text
t.column :updated_at, :datetime
end
add_index :sessions, :session_id
end
def self.down
drop_table :sessions
end
end
| Ruby |
class AddTestHouses < ActiveRecord::Migration
def self.up
House.create(:name => 'Alpha Beta', :abbrev => 'AB', :address=> '77 Massachusetts Av, Cambridge MA 02139', :phone => '555-1234')
House.create(:name => 'Gamma Delta', :abbrev => 'GD', :address=> '32 Vassar St, Cambridge MA 02139', :phone => '555-5678')
... | Ruby |
class PopulateBasicConstraints < ActiveRecord::Migration
def self.up
Constraint.create(:key => 'ActionsPerCheck', :value => 2, :priority => 0)
Constraint.create(:key => 'MonitorsPerHouse', :value => 5, :priority => 0)
Constraint.create(:key => 'ChecksPerHousePerHour', :value => 4, :priority => 0)
end
... | Ruby |
class CreateFreshmen < ActiveRecord::Migration
def self.up
create_table :freshmen do |t|
t.column :first_name, :string, :null => false
t.column :last_name, :string, :null => false
t.column :hometown, :string, :null => false
t.column :athena_name, :string, :null => false
end
end
... | Ruby |
class AddDeskActionTimestamps < ActiveRecord::Migration
def self.up
add_column :freshman_jaunts, :leave_recorded_at, :datetime, :null => false
add_column :freshman_jaunts, :return_recorded_at, :datetime, :null => true
add_column :house_visits, :enter_recorded_at, :datetime, :null => false
add_column :... | Ruby |
class AddTestFreshmen < ActiveRecord::Migration
def self.up
Freshman.create(:first_name => 'George', :last_name => 'Washington', :athena_name => 'gwash', :hometown => 'Mount Vernon, VA')
Freshman.create(:first_name => 'Abraham', :last_name => 'Lincoln', :athena_name => 'abrahaml', :hometown => 'Sinking Spring... | Ruby |
class DeskActionSti < ActiveRecord::Migration
def self.up
create_table :desk_actions do |t|
t.column :type, :string
t.column :effective_at, :datetime, :null => false
t.column :recorded_at, :datetime, :null => false
t.column :recorded_by, :integer, :null => false
t.column :destinatio... | Ruby |
class RefactorJaunts < ActiveRecord::Migration
def self.up
create_table :departures do |t|
t.column :departure_time, :datetime, :null => false
t.column :recorded_at, :datetime, :null => false
t.column :recorded_by, :integer, :null => false
end
create_table :jaunt_returns do |t|
t.... | Ruby |
class CreateDeskEndActions < ActiveRecord::Migration
def self.up
add_column :desk_actions, :desk_action_aggregate_id, :integer
remove_column :desk_action_aggregates, :start_action_id
remove_column :desk_action_aggregates, :end_action_id
end
def self.down
add_column :desk_action_aggregates, :start... | Ruby |
class CreateDeskActionAggregates < ActiveRecord::Migration
def self.up
create_table :desk_action_aggregates do |t|
t.column :type, :string
t.column :freshman_id, :int
t.column :start_action_id, :int
t.column :end_action_id, :int
t.column :house_id, :int
t.column :jaunt_id, :int... | Ruby |
class CreateFavoriteFreshmen < ActiveRecord::Migration
def self.up
create_table :favorite_freshmen do |t|
t.column :freshman_id, :int
t.column :house_id, :int
t.column :last_monitor_check, :datetime
end
end
def self.down
drop_table :favorite_freshmen
end
end
| Ruby |
class AddHouseExitDestination < ActiveRecord::Migration
def self.up
add_column :house_visits, :destination, :string, :null=> true
end
def self.down
remove_column :house_visits, :destination
end
end
| Ruby |
class ChangeJauntsFromLengthToEndTime < ActiveRecord::Migration
def self.up
add_column :jaunts, :end_time, :datetime, :null => false
remove_column :jaunts, :length
end
def self.down
add_column :jaunts, :length, :time, :null => false
remove_column :jaunts, :end_time
end
end
| Ruby |
class CreateConstraints < ActiveRecord::Migration
def self.up
create_table :constraints do |t|
t.column :key, :string
t.column :value, :int
t.column :priority, :int
t.column :start_time, :datetime
t.column :end_time, :datetime
end
end
def self.down
drop_table :constraint... | Ruby |
class CreateJaunts < ActiveRecord::Migration
def self.up
create_table :jaunts do |t|
t.column :name, :string, :null => false
t.column :description, :text, :null => false
t.column :house_id, :int, :null => false
t.column :start_time, :datetime, :null => false
t.column :length, :time, ... | Ruby |
class CreateHouseVisits < ActiveRecord::Migration
def self.up
create_table :house_visits do |t|
t.column :freshman_id, :integer, :null => false
t.column :house_id, :integer, :null => false
t.column :enter_time, :datetime, :null => false
t.column :exit_time, :datetime, :null => true
end... | Ruby |
class CreateTestJaunts < ActiveRecord::Migration
def self.up
Jaunt.create(:name=> 'Big Block of Cheese Day',
:description => "President Andrew Jackson, in the main foyer of his White House, had a big block of cheese. (And a Wheat Thin the size of Lake Tahoe!)",
:house_id => 1,
... | Ruby |
class RefactorHouseVisits < ActiveRecord::Migration
def self.up
create_table :entrances do |t|
t.column :entrance_time, :datetime, :null => false
t.column :recorded_at, :datetime, :null => false
t.column :recorded_by, :integer, :null => false
end
create_table :exits do |t|
t.colum... | Ruby |
class CreateOvernights < ActiveRecord::Migration
def self.up
create_table :overnights do |t|
t.column :freshman_id, :integer, :null => false
t.column :house_id, :integer, :null => false
t.column :specified_wakeup_time, :datetime, :null => false
t.column :actual_wakeup_time, :datetime, :nul... | Ruby |
class CreateChecks < ActiveRecord::Migration
def self.up
create_table :checks do |t|
t.column :user_id, :integer, :null => false
t.column :freshman_id, :integer, :null => false
t.column :checked_at, :datetime, :null => false
end
end
def self.down
drop_table :checks
end
end
| Ruby |
class CreateUsers < ActiveRecord::Migration
def self.up
create_table :users do |t|
t.column :username, :string, :null => false
t.column :pass_hash, :string, :null => false
t.column :salt, :string, :null => false
t.column :house_id, :integer, :null => false
t.column :admin_priv, ... | Ruby |
class CreateFreshmanJaunts < ActiveRecord::Migration
def self.up
create_table :freshman_jaunts do |t|
t.column :freshman_id, :integer, :null => false
t.column :jaunt_id, :integer, :null => false
t.column :leave_time, :datetime, :null => false
t.column :return_time, :datetime, :null => true... | Ruby |
class CreateHouses < ActiveRecord::Migration
def self.up
create_table :houses do |t|
t.column :name, :string, :null => false
t.column :abbrev, :string, :null => false
t.column :address, :string, :null => false
t.column :phone, :string, :null => false
end
end
def self.down
drop... | Ruby |
#!/usr/bin/env ruby
# An implementation of the Facebook[http://www.facebook.com] API as
# documented at http://developers.facebook.com/documentation.php
#
# See Facebook::Session for details.
#
# Author:: Alpha Chen
# Date:: 2006.08.18
require "digest/md5"
require "hpricot"
require "logger"
require "net/https"
requi... | Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.