code stringlengths 1 1.73M | language stringclasses 1
value |
|---|---|
#!/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/spawner'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/process/inspector'
| 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/reaper'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/process/inspector'
| 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/request'
| 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/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/request'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/generate'
| Ruby |
# This file is copied to ~/spec when you run 'ruby script/generate rspec'
# from the project root directory.
ENV["RAILS_ENV"] = "test"
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
require 'spec'
require 'spec/rails'
Spec::Runner.configure do |config|
# If you're not using ActiveRecord ... | Ruby |
module WelcomeHelper
end
| Ruby |
# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
require 'recaptcha'
include ReCaptcha::ViewHelper
end
| Ruby |
module EntriesHelper
end
| Ruby |
module AccountsHelper
end
| Ruby |
module PasswordHelper
end
| Ruby |
module Admin::OptionsHelper
end
| Ruby |
module Admin::LoughsHelper
end
| Ruby |
module Admin::BaseHelper
end
| Ruby |
module Admin::UsersHelper
end
| Ruby |
module Admin::DashboardHelper
end
| Ruby |
module Admin::ArticlesHelper
end
| Ruby |
module XmlHelper
end
| Ruby |
module PhotosHelper
end
| Ruby |
class Photo < ActiveRecord::Base
def photo=(image)
self.name = base_part_of(image.original_filename)
self.content_type = image.content_type
self.data = image.read
end
protected
def base_part_of(file_name)
name = File.basename(file_name)
name.gsub(/[^\w._-]/, '')
end
end
| Ruby |
class PasswordMailer < ActionMailer::Base
def recovery(password_recovery, email)
@subject = 'Password Recovery - babaru.net'
@recipients = email
@from = ''
@sent_on = Time.now
@headers = {}
@body[:password_recovery] = password_recovery
end
end
| Ruby |
module ConfigManager
def self.append_features(base)
super
base.extend(ClassMethods)
end
module ClassMethods
def fields
@fields ||= Hash.new { Item.new }
end
def setting(name, type=:object, default=nil)
item = Item.new
item.name, item.ruby_type, item.default = name.to_s, typ... | Ruby |
class Lough < ActiveRecord::Base
include ConfigManager
belongs_to :user
has_many :articles
has_many (:published_articles,
:class_name => 'Article',
:conditions => {:published => true},
:order => 'published_at DESC')
validates_presence_of :screen_name
validates_uniqueness_of :s... | Ruby |
class PasswordRecovery < ActiveRecord::Base
belongs_to :user
def recovery_url
"http://babaru.net/password/recover/#{read_attribute('token')}"
end
protected
before_create :create_token
def create_token
write_attribute('token', UUID.new)
end
end
| Ruby |
require 'digest/sha1'
class User < ActiveRecord::Base
has_one :lough
has_many :articles
has_many :password_recoveries
has_one (:avatar,:class_name => 'Photo')
# validations
validates_presence_of :email, :login_name
validates_format_of :email, :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i
va... | Ruby |
class AccountMailer < ActionMailer::Base
def registration_confirm(user)
@subject = 'Babaru.net Registration Successful'
@recipients = user.email
@from = 'automan@babaru.net'
@sent_on = Time.now
@headers = {}
@body[:user] = user
end
end
| Ruby |
class Article < ActiveRecord::Base
belongs_to :user
belongs_to :lough
validates_presence_of :title, :lough_id, :user_id
before_save :strip_all_html
# Finds all articles by date using pagination help.
def self.find_pagination_by_date(year, month = nil, day = nil, page = 1)
if !year.blank?
... | Ruby |
class WelcomeController < ApplicationController
def index
end
end
| Ruby |
class Admin::ArticlesController < Admin::BaseController
verify :method => :post, :only => [:create, :update, :destroy],
:redirect_to => {:action => 'index'}
def index
@articles = Article.paginate_all_by_lough_id(current_user.lough.id,
:page => params[:p... | Ruby |
class Admin::DashboardController < Admin::BaseController
def index
@action_title = 'Dashboard'
end
end
| Ruby |
class Admin::UsersController < Admin::BaseController
def index
edit
render :action => 'edit'
end
def edit
@action_title = 'Your Profile'
@user = current_user
if !@user.avatar.nil?
@avatar_url = url_for(:controller => '/photos', :action => 'show', :id => @user.avatar.id)
end
end
... | Ruby |
class Admin::BaseController < ApplicationController
layout 'administration'
before_filter :login_required, :set_tinymce_plugin_default
attr_reader :tinymce_used
protected
$page_title = 'Administration'
def set_tinymce_plugin_default
@tinymce_used = false
end
end
| Ruby |
class Admin::OptionsController < Admin::BaseController
verify :method => :post, :only => [:update], :redirect_to => {:action => 'edit'}
def index
edit
render :action => 'edit'
end
def edit
@lough = current_lough
@action_title = 'Options'
end
def update
if request.post?
@loug... | Ruby |
class EntriesController < ApplicationController
layout 'entries'
before_filter :set_per_page, :set_ancillaries
def index
@articles = current_lough.request_pagination_articles(params)
end
attr_reader :recent_entries
def show
@article = current_lough.request_article(params)
end
prot... | Ruby |
class XmlController < ApplicationController
def rss
@articles = Article.find(:all, :order => 'published_at DESC',
:limit => 25)
end
end
| Ruby |
class PhotosController < ApplicationController
def show
@photo = Photo.find(params[:id])
send_data(@photo.data, :file_name => @photo.name, :type => @photo.content_type, :disposition => "inline")
end
end
| Ruby |
# 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
include LoginSystem
# Pick a unique cookie name to distinguish our session data from others'
session :se... | Ruby |
require 'digest/sha1'
class PasswordController < ApplicationController
layout 'account'
verify :method => :post, :only => [:update_password],
:redirect_to => {:action => 'recover_password'}
verify :method => :post, :only => [:send_recovery],
:redirect_to => {:action => 'fotget'}... | Ruby |
require 'recaptcha'
class AccountsController < ApplicationController
include ReCaptcha::AppHelper
layout 'accounts'
def login
if current_user
redirect_to admin_url
end
@action_title = 'Login'
if request.post?
if @user = User.authenticate(params[:user_login], params[:user_p... | Ruby |
# Be sure to restart your server when you modify this file.
# Add new inflection rules using the following format
# (all these examples are active by default):
# Inflector.inflections do |inflect|
# inflect.plural /^(ox)$/i, '\1en'
# inflect.singular /^(ox)en/i, '\1'
# inflect.irregular 'person', 'people'
# i... | Ruby |
# Be sure to restart your server when you modify this file.
# Add new mime types for use in respond_to blocks:
# Mime::Type.register "text/richtext", :rtf
# Mime::Type.register_alias "text/html", :iphone
| 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 |
# Don't change this file!
# Configure your app in config/environment.rb and config/environments/*.rb
RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
module Rails
class << self
def boot!
unless booted?
preinitialize
pick_boot.run
end
end
def booted?
... | Ruby |
# Be sure to restart your 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 = '2... | 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 |
# 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 |
#
# = uuid.rb - UUID generator
#
# Author:: Assaf Arkin assaf@labnotes.org
# Documentation:: http://trac.labnotes.org/cgi-bin/trac.cgi/wiki/Ruby/UuidGenerator
# Copyright:: Copyright (c) 2005,2007 Assaf Arkin
# License:: MIT and/or Creative Commons Attribution-ShareAlike
require 'thread'
require 'yaml'
require 'sing... | Ruby |
# bare_migration.rb
# Scott Bronson
# 26 Jan 2006
#
# This module provides bare ActiveRecord::Base objects for migration
# scripts.
#
# Most migration scripts use model classes to move data. This is
# fine when the schema you're migrating from is compatible with your
# current models. It's disastrous when your models... | Ruby |
module LoginSystem
protected
def authorize?(user)
if user
# Check current user is owner of this lough or not.
return true
end
return false
end
# A filter that any login required controller should be called.
def login_required
if current_user && authoriz... | Ruby |
#Copyright (c) 2007 McClain Looney
#
#Permission is hereby granted, free of charge, to any person obtaining a copy
#of this software and associated documentation files (the "Software"), to deal
#in the Software without restriction, including without limitation the rights
#to use, copy, modify, merge, publish, distribut... | Ruby |
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
# Mayor.create(:name =>... | Ruby |
ENV["RAILS_ENV"] = "test"
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
require 'rails/test_help'
class ActiveSupport::TestCase
# Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
#
# Note: You'll currently still have to declare fixtures explicitly... | Ruby |
# Edit this Gemfile to bundle your application's dependencies.
source 'http://gemcutter.org'
gem "rails", "3.0.0.beta"
## Bundle edge rails:
# gem "rails", :git => "git://github.com/rails/rails.git"
# ActiveRecord requires a database adapter. By default,
# Rails has selected sqlite3.
gem "sqlite3-ruby", :require =>... | Ruby |
# This file is copied to ~/spec when you run 'ruby script/generate rspec'
# from the project root directory.
ENV["RAILS_ENV"] ||= 'test'
require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT)
require 'rspec/rails'
# Requires supporting files with custom matchers and macros, etc,
# in ./s... | Ruby |
module ApplicationHelper
end
| Ruby |
class ApplicationController < ActionController::Base
protect_from_forgery
end
| Ruby |
# Be sure to restart your server when you modify this file.
# Add new inflection rules using the following format
# (all these examples are active by default):
# ActiveSupport::Inflector.inflections do |inflect|
# inflect.plural /^(ox)$/i, '\1en'
# inflect.singular /^(ox)en/i, '\1'
# inflect.irregular 'person',... | Ruby |
# Be sure to restart your server when you modify this file.
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
# You can also remove all the silencers if you're trying to debug a probl... | Ruby |
Babaru::Application.configure do
config.generators do |g|
g.integration_tool :rspec
g.test_framework :rspec
end
end
| Ruby |
# Be sure to restart your server when you modify this file.
# Add new mime types for use in respond_to blocks:
# Mime::Type.register "text/richtext", :rtf
# Mime::Type.register_alias "text/html", :iphone
| Ruby |
# Be sure to restart your server when you modify this file.
# Your secret key for verifying cookie session data integrity.
# If you change this key, all old sessions will become invalid!
# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to dictionary attacks.
Act... | Ruby |
# Be sure to restart your server when you modify this file.
# Your secret key for verifying the integrity of signed cookies.
# If you change this key, all old signed cookies will become invalid!
# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to dictionary atta... | Ruby |
Babaru::Application.routes.draw do |map|
# The priority is based upon order of creation:
# first created -> highest priority.
# Sample of regular route:
# match 'products/:id' => 'catalog#view'
# Keep in mind you can assign values other than :controller and :action
# Sample of named route:
# match '... | Ruby |
# Use Bundler (preferred)
begin
require File.expand_path('../../.bundle/environment', __FILE__)
rescue LoadError
require 'rubygems'
require 'bundler'
Bundler.setup
# To use 2.x style vendor/rails and RubyGems
#
# vendor_rails = File.expand_path('../../vendor/rails', __FILE__)
# if File.exist?(vendor_ra... | Ruby |
require File.expand_path('../boot', __FILE__)
require 'rails/all'
# Auto-require default libraries and those for the current Rails environment.
Bundler.require :default, Rails.env
module Babaru
class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.... | Ruby |
# Load the rails application
require File.expand_path('../application', __FILE__)
# Initialize the rails application
Babaru::Application.initialize!
| Ruby |
Babaru::Application.configure do
# 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
# Full error reports are disabled and caching is turned on
... | Ruby |
Babaru::Application.configure do
# 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 webser... | Ruby |
Babaru::Application.configure do
# 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 s... | Ruby |
# This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment', __FILE__)
run Babaru::Application
| 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.expand_path('../config/application', __FILE__)
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
Rails::Application.load_tasks
| Ruby |
begin
require 'rspec/core'
require 'rspec/core/rake_task'
rescue MissingSourceFile
module Rspec
module Core
class RakeTask
def initialize(name)
task name do
# if rspec-rails is a configured gem, this will output helpful material and exit ...
require File.expand... | Ruby |
class CreatePasswordRecoveries < ActiveRecord::Migration
def self.up
create_table :password_recoveries do |t|
t.column :user_id, :integer
t.column :token, :string
t.timestamps
end
end
def self.down
drop_table :password_recoveries
end
end
| Ruby |
class AddLoughSettings < ActiveRecord::Migration
def self.up
Lough.transaction do
add_column :loughs, :settings, :text
Lough.find(:all).each do |l|
l.lough_name = l.name
l.save!
end
remove_column :loughs, :name
end
end
def self.down
Lough.transac... | Ruby |
class AddSalt < ActiveRecord::Migration
def self.up
add_column :users, :salt, :string
end
def self.down
remove_column :users, :salt
end
end
| Ruby |
class MoveScreenName < ActiveRecord::Migration
def self.up
remove_column :users, :screen_name
add_column :loughs, :screen_name, :string
end
def self.down
remove_column :loughs, :screen_name
add_column :users, :screen_name, :string
end
end
| Ruby |
class AddArticlePublishedAt < ActiveRecord::Migration
def self.up
Article.transaction do
add_column :articles, :published_at, :datetime
Article.find(:all).each do |article|
article.published_at = article.created_at
article.save!
end
end
end
def self.down
remov... | Ruby |
class AddHashedPassword < ActiveRecord::Migration
def self.up
add_column :users, :encrypted_password, :string
remove_column :users, :password
end
def self.down
remove_column :users, :encrypted_password
add_column :users, :password, :string
end
end
| Ruby |
class RemoveBodyHtml < ActiveRecord::Migration
def self.up
remove_column :articles, :body_html
end
def self.down
add_column :articles, :body_html, :text
end
end
| Ruby |
class RecoverBodyHtml < ActiveRecord::Migration
def self.up
add_column :articles, :body_html, :text
end
def self.down
remove_column :articles, :body_html
end
end
| Ruby |
class InitialSchema < ActiveRecord::Migration
def self.up
ActiveRecord::Base.transaction do
create_table :users do |t|
t.column :screen_name, :string
t.column :first_name, :string
t.column :last_name, :string
t.column :password, :string
t.column :avatar, :strin... | Ruby |
class AddLoginName < ActiveRecord::Migration
def self.up
add_column :users, :login_name, :string
end
def self.down
remove_column :users, :login_name
end
end
| Ruby |
ENV["RAILS_ENV"] = "test"
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
require 'test_help'
class Test::Unit::TestCase
# Transactional fixtures accelerate your tests by wrapping each test method
# in a transaction that's rolled back on completion. This ensures that the
# test datab... | Ruby |
#!C:/ruby/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... | Ruby |
#!C:/ruby/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
#... | Ruby |
#!C:/ruby/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... | Ruby |
#!C:/ruby/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... | Ruby |
#!C:/ruby/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
#... | Ruby |
#!C:/ruby/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... | Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/breakpointer' | Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.