code
stringlengths
1
1.73M
language
stringclasses
1 value
#!/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 AddTagSupport < ActiveRecord::Migration def self.up #Table for your Tags create_table :tags do |t| t.column :name, :string end create_table :taggings do |t| t.column :tag_id, :integer #id of tagged object t.column :taggable_id, :integer #type of object tagged ...
Ruby
class SWFChart require_gem 'builder' attr_accessor :height attr_accessor :width attr_accessor :bg_color attr_accessor :transparent attr_accessor :license attr_accessor :lib_path attr_accessor :flash_file attr_accessor :data_source attr_accessor :data_array attr_accessor :vt_array #direct...
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
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
# Copyright 2008-2009 Nokia Siemens Networks Oyj # # 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...
Ruby
#!/usr/bin/env ruby class ExampleRemoteLibrary def count_items_in_directory(path) Dir.entries(path).find_all{|i| not i.match('^\.')}.length end def strings_should_be_equal(str1, str2) puts "Comparing '#{str1}' to '#{str2}'" if str1 != str2 raise RuntimeError, "Given strings are not equal" ...
Ruby
class RubyLibraryExample def get_server_language 'ruby' end # Basic communication def passing end def failing(message) raise message end def logging(message, level='INFO') puts "*#{level}* #{message}" end def returning 'returned string' end # Logging def one_message_w...
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
# include the utils rb file which has extra functionality for the ext theme dir = File.dirname(__FILE__) require File.join(dir, 'lib', 'utils.rb') # register ext4 as a compass framework Compass::Frameworks.register 'ext4', dir
Ruby
# $ext_path: This should be the path of the Ext JS SDK relative to this file $ext_path = "../../extjs" # sass_path: the directory your Sass files are in. THIS file should also be in the Sass folder # Generally this will be in a resources/sass folder # <root>/resources/sass sass_path = File.dirname(__FILE__) # css_pat...
Ruby
# Compass configurations sass_path = File.dirname(__FILE__) css_path = File.join(sass_path, "..", "css") # Require any additional compass plugins here. images_dir = File.join(sass_path, "..", "img") output_style = :expanded environment = :production
Ruby
module ExtJS4 module SassExtensions module Functions module Utils def parsebox(list, n) assert_type n, :Number if !n.int? raise ArgumentError.new("List index #{n} must be an integer") elsif n.to_i < 1 raise ArgumentError.new("List index #{n} must...
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: 'Emanuel...
Ruby
class CreateProductos < ActiveRecord::Migration def change create_table :productos do |t| t.column :nombre, :string, :limit => 255, :null => false t.column :descripcion, :string, :limit => 255, :null => false t.column :tipo, :string, :limit => 255, :null => false t.column :productor_id, :integer, ...
Ruby
class CreateForumPosts < ActiveRecord::Migration def self.up create_table :forum_posts do |table| table.column :name, :string, :limit => 50, :null => false table.column :subject, :string, :limit => 255, :null => false table.column :body, :text table.column :root_id, :integer, :null => fals...
Ruby
class CreatePosts < ActiveRecord::Migration def self.up create_table :posts do |t| t.text :content t.string :nombre_autor t.timestamps end end def self.down drop_table :posts end end
Ruby
class AddForeignToTopics < ActiveRecord::Migration def change add_column :topics, :forum_id, :integer end end
Ruby
class AddLogoProductorAttachmentToProductors < ActiveRecord::Migration def up add_attachment :productors, :logo_productor end def down remove_attachment :productors, :logo_productor end end
Ruby
class CreateOrders < ActiveRecord::Migration def change create_table :orders do |t| # contact information t.string :email t.string :phone_number # shipping address t.string :ship_to_first_name t.string :ship_to_last_name t.string :ship_to_address t.string :ship_to_c...
Ruby
class AddForeignToPosts < ActiveRecord::Migration def change add_column :posts, :topic_id, :integer end end
Ruby
class CreateProductors < ActiveRecord::Migration def change create_table :productors do |t| t.column :nombre, :string, :limit => 255, :null => false t.column :direccion, :string, :limit => 255, :null => false t.column :telefono, :integer t.column :email, :string t.timestamps end ...
Ruby
class AddCoverImageAttachmentToProductos < ActiveRecord::Migration def up add_attachment :productos, :cover_image end def down remove_attachment :productos, :cover_image end end
Ruby
class CreateUsers < ActiveRecord::Migration def change create_table :users do |t| t.string :name, :null => false, :unique => true t.string :login, :null => false, :unique => true t.string :email, :null => false, :unique => true t.string :crypted_password, :null => false t.string :pas...
Ruby
class CreateForums < ActiveRecord::Migration def self.up create_table :forums do |t| t.string :name t.text :description t.timestamps end end def self.down drop_table :forums end end
Ruby
class CreateTopics < ActiveRecord::Migration def self.up create_table :topics do |t| t.string :name t.string :nombre_autor t.integer :last_poster_id t.datetime :last_post_at t.timestamps end end def self.down drop_table :topics end end
Ruby
class CreateCarts < ActiveRecord::Migration def change create_table :carts do |t| t.timestamps end end end
Ruby
class CreateOrderItems < ActiveRecord::Migration def change create_table :order_items do |t| t.integer :producto_id t.integer :order_id t.float :price t.integer :amount t.timestamps end end end
Ruby
class CreateCartItems < ActiveRecord::Migration def change create_table :cart_items do |t| t.column :producto_id, :integer t.column :cart_id, :integer t.column :precio, :float t.column :cantidad, :integer t.timestamps end end end
Ruby
ENV["RAILS_ENV"] = "test" require File.expand_path('../../config/environment', __FILE__) 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 in int...
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__) Campina::Application.load_tasks
Ruby
source 'https://rubygems.org' gem 'rails', '3.2.9' # Bundle edge Rails instead: # gem 'rails', :git => 'git://github.com/rails/rails.git' gem 'mysql2', '0.3.11' gem 'json', '1.7.5' gem 'prototype-rails' # Gems used only for assets and not required # in production environments by default. group :assets do gem 's...
Ruby
#!/usr/bin/env ruby # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application. APP_PATH = File.expand_path('../../config/application', __FILE__) require File.expand_path('../../config/boot', __FILE__) require 'rails/commands'
Ruby
#!/usr/bin/env ruby # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application. APP_PATH = File.expand_path('../../config/application', __FILE__) require File.expand_path('../../config/boot', __FILE__) require 'rails/commands'
Ruby
xml.instruct! :xml, :version=>"1.0", :encoding=>"UTF-8" xml.rss("version" => "2.0", "xmlns:dc" => "http://purl.org/dc/elements/1.1/") do xml.channel do xml.title @page_title xml.link(url_for(:action => "index", :only_path => false)) xml.language "en-us" xml.ttl "40" xml.description "Campi...
Ruby
module HistoriaHelper end
Ruby
#encoding: UTF-8 module ApplicationHelper def add_producto_link(text, producto) link_to text, { :url => { :controller => "cart", :action => "add", :id => producto}, :r...
Ruby
module PasswordResetInstructionsHelper end
Ruby
module ErrorMessagesHelper # Render error messages for the given objects. The :message and :header_message options are allowed. def error_messages_for(*objects) options = objects.extract_options! options[:header_message] ||= I18n.t(:"activerecord.errors.header", :default => "Invalid Fields") options[:me...
Ruby
module UserHelper end
Ruby
module Admin::ProductoHelper end
Ruby
module Admin::ProductorHelper end
Ruby
module TopicsHelper end
Ruby
module CheckoutHelper end
Ruby
module CatalogHelper end
Ruby
module PostsHelper end
Ruby
module ForumsHelper end
Ruby
# These helper methods can be called in your template to set variables to be used in the layout # This module should be included in all views globally, # to do so you may need to add this line to your ApplicationController # helper :layout module LayoutHelper def title(page_title, show_title = true) content_for...
Ruby
module AboutHelper end
Ruby
module UserSessionHelper end
Ruby
class Notifier < ActionMailer::Base default from: 'Campina virtual Notifier' def password_reset_instructions(user) @user= user @subject = 'Password reset instructions.' @sent_on = Time.now # default host is defined in development.rb configuration file @edit_password_reset_url = url_for :control...
Ruby
class UserSession < Authlogic::Session::Base logout_on_timeout true # default if false end
Ruby
class Productor < ActiveRecord::Base attr_accessible :nombre, :direccion, :telefono, :email, :logo_productor has_many :productos has_attached_file :logo_productor, styles: { medium: '200x200>', thumb: '48x48>' } validates_length_of :nombre, :in => 1..255 validates_length_of :direccion, :in => 1..255 val...
Ruby
class Producto < ActiveRecord::Base attr_accessible :nombre, :descripcion, :tipo, :precio, :productor_id, :productor, :cover_image belongs_to :productor has_attached_file :cover_image, styles: { medium: '200x200>', thumb: '40x40>' } validates_length_of :nombre, :in => 1..255 validates_length_of :descr...
Ruby
class Post < ActiveRecord::Base attr_accessible :content, :topic_id, :nombre_autor belongs_to :topic validates_length_of :content, :in => 1..255 validates_length_of :nombre_autor, :in => 1..255 end
Ruby
class Forum < ActiveRecord::Base attr_accessible :name, :description has_many :topics, :dependent => :destroy validates_length_of :name, :in => 1..255 validates_length_of :description, :in => 1..255 def most_recent_post topic = Topic.first(:order => 'last_post_at DESC', :conditions => ['forum_id...
Ruby
class Cart < ActiveRecord::Base has_many :cart_items has_many :productos, :through => :cart_items def add(producto_id) items = cart_items.find_all_by_producto_id producto_id producto = Producto.find producto_id if items.size < 1 ci = cart_items.create :producto_id => producto_id, :cantidad => ...
Ruby
class User < ActiveRecord::Base acts_as_authentic do |a| a.validate_login_field = true a.validate_password_field = true a.require_password_confirmation = true a.logged_in_timeout = 5.minutes # default is 10.minutes end attr_accessible :name, :login, :email, :password, :password_confirmation val...
Ruby
class CartItem < ActiveRecord::Base attr_accessible :producto_id, :cart_id, :precio, :cantidad belongs_to :cart belongs_to :producto end
Ruby
class Topic < ActiveRecord::Base attr_accessible :name, :last_poster_id, :last_post_at, :forum_id, :nombre_autor belongs_to :forum has_many :posts, :dependent => :destroy validates_length_of :name, :in => 1..255 validates_length_of :nombre_autor, :in => 1..255 end
Ruby
#encoding: UTF-8 class Order < ActiveRecord::Base attr_protected :id, :customer_ip, :status, :error_message, :created_at, :updated_at attr_accessor :card_type, :card_number, :card_expiration_month, :card_expiration_year, :card_verification_value has_many :order_items has_many :pro...
Ruby
#encoding: UTF-8 class OrderItem < ActiveRecord::Base attr_accessible :producto_id, :order_id, :price, :amount belongs_to :order belongs_to :producto def validate errors.add(:amount, "Tiene que ser superior o igual a 1") unless amount.nil? || amount > 0 errors.add(:price, "Debe ser un numer...
Ruby
class UserController < ApplicationController before_filter :require_user, :only => [:show, :edit, :update] def new @user = User.new @page_title = 'Crear cuenta nueva' if current_user flash[:notice] = 'Solo se permite una cuenta por sesion.' redirect_to :controller => 'about', :action => 'in...
Ruby
class PostsController < ApplicationController def index @posts = Post.all end def new @post = Post.new end def create @post = Post.new(:content => params[:post][:content], :topic_id => params[:post][:topic_id], :nombre_autor => params[:post][:nombre_autor]) if @post.save ...
Ruby
# encoding: utf-8 class AboutController < ApplicationController def index @page_title = 'About Campiña Virtual' end end
Ruby
class ApplicationController < ActionController::Base protect_from_forgery helper_method :current_user_session, :current_user private def initialize_cart if session[:cart_id] @cart = Cart.find session[:cart_id] else @cart = Cart.create session[:cart_id] = @cart.id en...
Ruby
class UserSessionController < ApplicationController before_filter :require_no_user, :only => [:new, :create] def new @user_session = UserSession.new @page_title = 'Inicio de sesion' end def create @user_session = UserSession.new(params[:user_session]) @user_session.remember_me = false # just i...
Ruby
#encoding: UTF-8 class CatalogController < ApplicationController before_filter :initialize_cart, :except => [:show, :latest] before_filter :require_no_user def show @producto = Producto.find(params[:id]) @page_title = @producto.nombre end def index @productos = Producto.paginate :page => params[...
Ruby
#encoding: UTF-8 class CartController < ApplicationController before_filter :initialize_cart def add params[:id].gsub!(/producto_/, "") @producto = Producto.find params[:id] @page_title = 'Añadir producto' if request.xhr? @item = @cart.add(params[:id]) flash.now[:cart_notice] = "Añ...
Ruby
class Admin::AuthenticatedController < ApplicationController before_filter :require_user end
Ruby
class Admin::OrderController < Admin::AuthenticatedController def close order = Order.find(params[:id]) order.close flash[:notice] = "El pedido ##{order.id} ha sido cerrado." redirect_to :action => 'index' end def show @order = Order.find(params[:id]) @page_title = "Detalles de pedido ##{...
Ruby
class Admin::ProductoController < Admin::AuthenticatedController def new load_data @producto = Producto.new @page_title = 'Creando producto nuevo' end def create @producto = Producto.new(params[:producto]) if @producto.save flash[:notice] = "Producto #{@producto.nombre} fue creado c...
Ruby
class Admin::ProductorController < Admin::AuthenticatedController def new @productor = Productor.new @page_title = 'Alta productor' end def create @productor = Productor.new(params[:productor]) if @productor.save flash[:notice] = "Productor #{@productor.nombre} fue creado con exito." ...
Ruby