code
stringlengths
1
1.73M
language
stringclasses
1 value
RubySite::Application.routes.draw do get "error/error" post "api/get_dict" get "create_word/create" get "create_word/edit" post "create_word/edit" post "create_word/create" get "create_word/edit" # register pages get "register/register" post "register/register" #login pages get "login/logi...
Ruby
require 'rubygems' # Set up gems listed in the Gemfile. ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
Ruby
require File.expand_path('../boot', __FILE__) require 'rails/all' if defined?(Bundler) # If you precompile assets before deploying to production, use this line Bundler.require(*Rails.groups(:assets => %w(development test))) # If you want your assets lazily compiled in production, use this line # Bundler.requi...
Ruby
# Load the rails application require File.expand_path('../application', __FILE__) # Initialize the rails application RubySite::Application.initialize!
Ruby
RubySite::Application.configure do # Settings specified here will take precedence over those in config/application.rb # Code is not reloaded between requests config.cache_classes = true # Full error reports are disabled and caching is turned on config.consider_all_requests_local = false config.actio...
Ruby
RubySite::Application.configure do # Settings specified here will take precedence over those in config/application.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 web s...
Ruby
RubySite::Application.configure do # Settings specified here will take precedence over those in config/application.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 RubySite::Application
Ruby
#!/usr/bin/env rake # 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__) RubySite::Application.load_tasks
Ruby
environment = :production project_type = :stand_alone http_path = "/" css_dir = "../styles" sass_dir = "." images_dir = "images" sass_options = { :line_numbers => false, :debug_info => false } # output_style = :compressed # output_style = :compact output_style = :expanded
Ruby
require 'webrick' include WEBrick s = HTTPServer.new( :Port => 2010, :DocumentRoot => Dir::pwd ) s.mount('/sh/scripts', WEBrick::HTTPServlet::FileHandler, '../scripts') s.mount('/sh/styles', WEBrick::HTTPServlet::FileHandler, '../styles') trap('INT') { s.stop } s.start
Ruby
require 'rubygems' require 'sinatra' require 'datamapper' require 'dm-core' require 'dm-validations' require 'logger' require 'erb' require 'json' module Jsonable def to_json(*a) { "#{self.class.name}" => get_instance_variables }.to_json(*a) end private def get_instance_variables h ...
Ruby
source "http://rubygems.org" gem "sinatra" gem "datamapper" gem "dm-sqlite-adapter" gem "dm-postgres-adapter" gem "json"
Ruby
require 'rubygems' require 'app/workflow' run Workflow::Application
Ruby
# Require any additional compass plugins here. require 'susy' # Project directories css_dir = "css" sass_dir = "sass" images_dir = "img" javascripts_dir = "js" # CSS generation output_style = :compressed line_comments = false relative_assets = true
Ruby
http_path = "/" css_dir = "css" sass_dir = "sass" images_dir = "img" javascripts_dir = "js" fonts_dir = "fonts" output_style = :compact line_comments = false relative_assets = true
Ruby
require 'sinatra/activerecord/rake' require './main'
Ruby
source :gemcutter gem 'sinatra', :require => 'sinatra/base' gem 'thin', '~> 1.3' gem 'pg' gem 'sinatra-activerecord' gem 'google-api-client', '>= 0.4.4', :require => 'google/api_client' group :development do gem 'rake' gem 'sqlite3-ruby' end
Ruby
class CreateUsers < ActiveRecord::Migration def up create_table :users do |t| t.string :profile_id t.string :email t.string :refresh_token end add_index :users, :profile_id end def down drop_table :users end end
Ruby
# Copyright (C) 2012 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writ...
Ruby
require 'sinatra.rb' # Sinatra defines #set at the top level as a way to set application configuration set :run, false set :env, (ENV['RACK_ENV'] ? ENV['RACK_ENV'].to_sym : :development) require './main' run Sinatra::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.join(File.dirname(__FILE__), 'config', 'boot')) require 'rake' require 'rake/testtask' require 'rake/rdoctask' require 'tasks/rails'
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
# 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 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.0...
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
ActionController::Routing::Routes.draw do |map| map.open_id_complete 'session', :controller => "session", :action => "create", :requirements => { :method => :get } map.activate '/activate/:activation_code', :controller => 'users', :action => 'activate', :activation_code => nil map.signup '/signup', :controller => ...
Ruby
# Methods added to this helper will be available to all templates in the application. module ApplicationHelper end
Ruby
module TasksHelper end
Ruby
module UsersHelper end
Ruby
module TeamHelper end
Ruby
module WorkreportsHelper end
Ruby
module SessionHelper end
Ruby
module ProjectsHelper end
Ruby
class Workreport < ActiveRecord::Base belongs_to :task end
Ruby
class Task < ActiveRecord::Base belongs_to :project has_many :workreports def associated_and_open_projects(user) user.projects.find_all_by_closed(false) end end
Ruby
class Project < ActiveRecord::Base has_and_belongs_to_many :users has_many :tasks validates_presence_of :title validates_presence_of :currency validates_numericality_of :budget, :greater_than_or_equal_to => 0.0 validates_numericality_of :hourly_rate, :greater_than_or_equal_to => 0.0 def unfinished_tasks Ta...
Ruby
require 'digest/sha1' class User < ActiveRecord::Base has_and_belongs_to_many :projects # Virtual attribute for the unencrypted password attr_accessor :password validates_presence_of :login, :email validates_presence_of :password, :if => :password_required? validates_presence_of ...
Ruby
class ProjectsController < ApplicationController before_filter :login_required # GET /projects def index @projects = @current_user.projects respond_to do |format| format.html # index.html.erb end end # GET /projects/1 def show @project = Project.find(params[:id]) respond_to do ...
Ruby
class WorkreportsController < ApplicationController before_filter :login_required # GET /workreports def index @projects = @current_user.projects.find_all_by_closed(false) end # GET /workreports/1 def show @workreport = Workreport.find(params[:id]) end # GET /workreports/new def new @proje...
Ruby
class TasksController < ApplicationController before_filter :login_required # GET /tasks def index @projects = @current_user.projects respond_to do |format| format.html # index.html.erb end end def open_projects #@projects = @current_user.projects @projects = Project.find_all_by_cl...
Ruby
# This controller handles the login/logout function of the site. class SessionController < ApplicationController # render new.rhtml def new end # POST /login def create if using_open_id? open_id_authentication(params[:openid_url]) else password_authentication(params[:login], params[:password]) ...
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 # Be sure to include AuthenticationSystem in Application Controller instead include AuthenticatedSystem hel...
Ruby
class TeamController < ApplicationController # GET /projects/:project_id/team def index @users = User.find(:all) @project = Project.find(params[:project_id]) render :action => 'index' end # PUT /projects/:project_id/team def assign params[:user_ids] flash[:notice] = "Project members assigned." @proje...
Ruby
class UsersController < ApplicationController # render new.rhtml def new end # POST /login def create cookies.delete :auth_token # protects against session fixation attacks, wreaks havoc with # request forgery protection. # uncomment at your own risk # reset_session @user = User.new...
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/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/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/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/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/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/inspector'
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/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 AddTaskIdColumnToWorkreports < ActiveRecord::Migration def self.up add_column :workreports, :task_id, :integer, :default => Task.find(:first) end def self.down remove_column :workreports, :task_id end end
Ruby
class CreateProjectsUsersJoin < ActiveRecord::Migration def self.up create_table 'projects_users', :id => false do |t| t.column 'project_id', :integer t.column 'user_id', :integer end end def self.down drop_table 'projects_users' end end
Ruby
class CreateProjects < ActiveRecord::Migration def self.up create_table :projects do |t| t.string :title t.string :description t.decimal :budget, {:default=>0, :scale=>2, :precision=>8} t.boolean :closed t.timestamps end end def self.down drop_table :projects end end
Ruby
class AddCurrencyToProjects < ActiveRecord::Migration def self.up add_column:projects,:currency,:string,:default=>'EUR' end def self.down remove_column:projects,:currency end end
Ruby
class CreateWorkreports < ActiveRecord::Migration def self.up create_table :workreports do |t| t.date :date t.decimal :time, {:default=>0, :scale=>2, :precision=>8} t.string :comment t.timestamps end end def self.down drop_table :workreports end end
Ruby
class AddOpenIdAuthenticationTables < ActiveRecord::Migration def self.up create_table :open_id_authentication_associations, :force => true do |t| t.integer :issued, :lifetime t.string :handle, :assoc_type t.binary :server_url, :secret end create_table :open_id_authentication_nonces, :f...
Ruby
class CreateTasks < ActiveRecord::Migration def self.up create_table :tasks do |t| t.string :name t.decimal :estimated_effort, {:default=>0, :scale=>2, :precision=>8} t.string :description t.boolean :finished t.timestamps end end def self.down drop_table :tasks end en...
Ruby
class AddProjectIdColumnToTasks < ActiveRecord::Migration def self.up add_column :tasks, :project_id, :integer, :default => Project.find(:first) end def self.down remove_column :tasks, :project_id end end
Ruby
class AddHourlyRateToProjects < ActiveRecord::Migration def self.up add_column:projects,:hourly_rate,:decimal, {:default=>0, :scale=>2, :precision=>8} end def self.down remove_column:projects,:hourly_rate end end
Ruby
class CreateUsers < ActiveRecord::Migration def self.up create_table "users", :force => true do |t| t.column :login, :string t.column :name, :string t.column :middle_initial, :string t.column :lastname, :string t.column :email, :string...
Ruby
module AuthenticatedSystem protected # Returns true or false if the user is logged in. # Preloads @current_user with the user model if they're logged in. def logged_in? !!current_user end # Accesses the current user from the session. # Future calls avoid the database because nil is not...
Ruby
module AuthenticatedTestHelper # Sets the current user in the session from the user fixtures. def login_as(user) @request.session[:user_id] = user ? users(user).id : nil end def authorize_as(user) @request.env["HTTP_AUTHORIZATION"] = user ? ActionController::HttpAuthentication::Basic.encode_credentials...
Ruby
#!/usr/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 impai...
Ruby
#!/usr/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 impai...
Ruby
#!/usr/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.lo...
Ruby
#!/usr/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 impai...
Ruby
#!/usr/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 impai...
Ruby
#!/usr/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.lo...
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
# 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. # 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 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 attac...
Ruby
# Be sure to restart your server when you modify this file. # # This file contains settings for ActionController::ParamsWrapper which # is enabled by default. # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. ActiveSupport.on_load(:action_controller) do wrap_parameters ...
Ruby
# Be sure to restart your server when you modify this file. WowAddonsChina::Application.config.session_store :cookie_store, key: '_wow-addons-china_session' # Use the database for sessions instead of the cookie-based default, # which shouldn't be used to store highly confidential information # (create the session tab...
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