code
stringlengths
1
1.73M
language
stringclasses
1 value
# # Copyright 2008 Garth Williams # # This file is part of CommandPost. # # CommandPost is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later ve...
Ruby
# # Copyright 2008 Garth Williams # # This file is part of CommandPost. # # CommandPost is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later ve...
Ruby
# # Copyright 2008 Garth Williams # # This file is part of CommandPost. # # CommandPost is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later ve...
Ruby
# # Copyright 2008 Garth Williams # # This file is part of CommandPost. # # CommandPost is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later ve...
Ruby
# # Copyright 2008 Garth Williams # # This file is part of CommandPost. # # CommandPost is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later ve...
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
# Hijacker class # # This class is used by RoleRequirementTestHelper to temporarily hijack a controller action for testing # # It can be used for other tests as well. # # You can contract the author with questions # Tim C. Harper - irb(main):001:0> ( 'tim_see_harperATgmail._see_om'.gsub('_see_', 'c').gsub('AT'...
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
# Include this is test_helper.rb to enable test-case helper support for RoleRequirement via: # include RoleRequirementTestHelper # # RoleRequirementTestHelper uses the power of ruby to temporarily "hijack" your target action. (don't worry, it puts things back the way it was after it runs) # This means that the o...
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
# Main module for authentication. # Include this in ApplicationController to activate RoleRequirement # # See RoleSecurityClassMethods for some methods it provides. module RoleRequirementSystem def self.included(klass) klass.send :class_inheritable_array, :role_requirements klass.send :include, RoleS...
Ruby
Pod::Spec.new do |s| s.name = "EventSource" s.version = "1.0.0" s.summary = "HTML5 Server-Sent Events in your Cocoa app." s.homepage = "http://github.com/neilco/EventSource" s.license = 'MIT (see LICENSE.txt)' s.author = { "Neil Cowburn" => "git@neilcowburn.com" } s.source ...
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 CreateDistribuidors < ActiveRecord::Migration def change create_table :distribuidors do |t| t.string :nombre t.string :rif t.float :costo_mensual_contrato t.date :fecha_inicio_contrato t.date :fecha_fin_contrato t.string :comentario_contrato t.float :costo_total_cot...
Ruby
class AddTipoDepToProducto < ActiveRecord::Migration def self.up add_column :productos, :tipo, :string add_column :productos, :departamento, :string remove_column :productos, :categoria end def self.down remove_column :productos, :tipo remove_column :productos, :departamento add_column ...
Ruby
class AddFotoProducto < ActiveRecord::Migration def self.up add_column :productos, :photo_file_name, :string add_column :productos, :photo_content_type, :string add_column :productos, :photo_file_size, :integer add_column :productos, :photo_updated_at, :datetime end def self.down remov...
Ruby
class AddCantidadLineaArticulos < ActiveRecord::Migration def self.up add_column :linea_articulos, :cantidad, :integer, :default => 1 end def self.down remove_column :linea_articulos, :cantidad end end
Ruby
class CreateDireccionPrecios < ActiveRecord::Migration def change create_table :direccion_precios do |t| t.string :nombre t.float :precio t.references :distribuidor t.timestamps end add_index :direccion_precios, :distribuidor_id end end
Ruby
class CreateBancos < ActiveRecord::Migration def change create_table :bancos do |t| t.string :nombre t.string :rif t.string :numero_cuenta t.timestamps end end end
Ruby
class CreateLineaArticulos < ActiveRecord::Migration def change create_table :linea_articulos do |t| t.integer :producto_id t.integer :carrito_id t.timestamps end end end
Ruby
class CreateCarritos < ActiveRecord::Migration def change create_table :carritos do |t| t.timestamps end end end
Ruby
class CreateClientes < ActiveRecord::Migration def change create_table :clientes do |t| t.string :nombre t.string :hashed_password t.string :salt t.string :correo t.boolean :is_admin, :default => 0 t.string :telefono t.string :ci_rif t.timestamps end end end
Ruby
class AddClienteIdToCarrito < ActiveRecord::Migration def change add_column :carritos, :cliente_id, :integer end end
Ruby
class CreateProductos < ActiveRecord::Migration def change create_table :productos do |t| t.string :nombre t.text :descripcion t.float :precio t.string :categoria t.string :talla t.timestamps end end end
Ruby
class CreateEmpresas < ActiveRecord::Migration def change create_table :empresas do |t| t.string :nombre t.string :direccion t.string :telefono t.string :fax t.string :correo t.string :rif 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 integrati...
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__) EntrededosWeb::Application.load_tasks
Ruby
source 'https://rubygems.org' gem 'rails', '3.2.1' # Bundle edge Rails instead: # gem 'rails', :git => 'git://github.com/rails/rails.git' gem 'mysql2' # Gems used only for assets and not required # in production environments by default. group :assets do gem 'sass-rails', '~> 3.2.3' gem 'coffee-rails', '~> 3.2...
Ruby
module ProductosHelper end
Ruby
module ApplicationHelper def hidden_div_if(condition, attributes = {}, &block) if condition attributes["style"] = "display: none" end content_tag("div", attributes, &block) end def direcciones() [ "Amazonas", "Anzoategui", "Apure", "Aragua", "Barinas", "Bolivar", "Carabobo...
Ruby
module EmpresasHelper end
Ruby
module DistribuidorsHelper end
Ruby
module BancosHelper end
Ruby
module LineaArticulosHelper end
Ruby
module AdminHelper end
Ruby
module CarritosHelper end
Ruby
module SesionHelper end
Ruby
module ClientesHelper end
Ruby
module HomeHelper end
Ruby
require 'digest/sha2' class Cliente < ActiveRecord::Base default_scope :order => 'nombre' validates :ci_rif, :presence => true, :uniqueness => true, :numericality => { :only_integer => true }, :length => { :in => 6..8 } validates :correo, :presence => true, :uniqueness => true validates :telefono, :length => {...
Ruby
class Carrito < ActiveRecord::Base has_many :linea_articulos, :dependent => :destroy belongs_to :cliente def add_product(producto_id) current_item = linea_articulos.find_by_producto_id(producto_id) if current_item current_item.cantidad += 1 else current_item = linea_articulos.build(:pro...
Ruby
class Empresa < ActiveRecord::Base validates :nombre, :presence => true, :uniqueness => true validates :rif, :presence => true, :uniqueness => true validates :telefono, :presence => true, :uniqueness => true validates :direccion, :presence => true, :uniqueness => true end
Ruby
class DireccionPrecio < ActiveRecord::Base belongs_to :distribuidor end
Ruby
class Producto < ActiveRecord::Base TIPO_TYPES = ["Franela","Franelilla Cuello Redondo", "Franela Cuello V", "Interior", "Boxer", "Bikini","Panties", "Medias Altas", "Medias Tobillera"] TALLAS_TYPES = ["S","M","L","XL"] DEPARTAMENTO_TYPES = ["Infantes", "Ni\u00F1a...
Ruby
class LineaArticulo < ActiveRecord::Base belongs_to :producto belongs_to :carrito def total_precio producto.precio * cantidad end end
Ruby
class Banco < ActiveRecord::Base validates :nombre, :presence => true, :uniqueness => true validates :rif, :presence => true, :uniqueness => true validates :numero_cuenta, :presence => true, :uniqueness => true end
Ruby
class Distribuidor < ActiveRecord::Base validates :nombre, :presence => true, :uniqueness => true validates :rif, :presence => true, :uniqueness => true validates :nombre, :presence => true, :uniqueness => true validates :costo_mensual_contrato, :presence => true validates :costo_total_cotrato, :presence => true ...
Ruby
class BancosController < ApplicationController before_filter :authorize_admin # GET /bancos # GET /bancos.json def index @bancos = Banco.paginate( :page => params[:page], :per_page => 3) respond_to do |format| format.html # index.html.erb format.json { re...
Ruby
class EmpresasController < ApplicationController before_filter :authorize, :only => [:show] before_filter :authorize_admin, :only => [:update] # GET /empresas # GET /empresas.json def index @empresas = Empresa.paginate( :page => params[:page], :per_page => 3) respon...
Ruby
class LineaArticulosController < ApplicationController skip_before_filter :authorize, :only => :create # GET /linea_articulos # GET /linea_articulos.json def index @linea_articulos = LineaArticulo.paginate( :page => params[:page], :per_page => 3) respond_to do |form...
Ruby
class ApplicationController < ActionController::Base before_filter :authorize protect_from_forgery private def current_cart Carrito.find(session[:cart_id]) rescue ActiveRecord::RecordNotFound cart = Carrito.create session[:cart_id] = cart.id cart end protected def auth...
Ruby
class DistribuidorsController < ApplicationController before_filter :authorize_admin # GET /distribuidors # GET /distribuidors.json def index @distribuidors = Distribuidor.paginate( :page => params[:page], :per_page => 3) respond_to do |format| format.h...
Ruby
class CarritosController < ApplicationController skip_before_filter :authorize # GET /carritos # GET /carritos.json def index @carritos = Carrito.all respond_to do |format| format.html # index.html.erb format.json { render json: @carritos } end end # GET /carritos/1 # GET /carri...
Ruby
class SesionController < ApplicationController skip_before_filter :authorize def create if cliente = Cliente.authenticate(params[:correo], params[:password]) session[:cliente_id] = cliente.id session[:cliente_admin] = cliente.is_admin cart = Carrito.find_by_cliente_id(cliente.id) ...
Ruby
class ClientesController < ApplicationController before_filter :authorize, :only => [:show, :edit, :update] before_filter :authorize_admin, :only => [:index] # GET /clientes # GET /clientes.json def index @clientes = Cliente.paginate( :page => params[:page], :per_page =>...
Ruby
class HomeController < ApplicationController skip_before_filter :authorize def inicio @productos = Producto.paginate( :page => params[:page], :per_page => 3).order(:nombre) @carrito = current_cart end end
Ruby
class AdminController < ApplicationController def inicio @carrito = Carrito.find(session[:cart_id]) @productos_otros = Producto.paginate( :page => params[:page], :per_page => 3).order(:id) end end
Ruby
class ProductosController < ApplicationController skip_before_filter :authorize # GET /productos # GET /productos.json def index @productos = Producto.paginate( :page => params[:page], :per_page => 3) respond_to do |format| format.html # index.html.erb fo...
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
# 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. # 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. # 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. EntrededosWeb::Application.config.session_store :cookie_store, key: '_entrededosWeb_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 table w...
Ruby
EntrededosWeb::Application.routes.draw do resources :linea_articulos resources :carritos get 'sesion' => "admin#inicio" controller :sesion do get 'acceder' => :new post 'acceder' => :create delete 'salir' => :destroy end resources :clientes resources :empresas resources :distribuidors...
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 EntrededosWeb::Application.initialize!
Ruby
EntrededosWeb::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....
Ruby
EntrededosWeb::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 ...
Ruby
EntrededosWeb::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 t...
Ruby
# This file is used by Rack-based servers to start the application. require ::File.expand_path('../config/environment', __FILE__) run EntrededosWeb::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__) EntrededosWeb::Application.load_tasks
Ruby
require 'mkmf' $CPPFLAGS = $CPPFLAGS + " -I../../include" $LDFLAGS = $LDFLAGS + " -L../../" $LIBS = $LIBS + " -lhpdf -lpng -lz" create_makefile 'hpdf'
Ruby
# # << Haru Free PDF Library 2.0.0 >> -- demo.rb # # Copyright (c) 1999-2006 Takeshi Kanno <takeshi_kanno@est.hi-ho.ne.jp> # # Permission to use, copy, modify, distribute and sell this software # and its documentation for any purpose is hereby granted without fee, # provided that the above copyright notice appea...
Ruby
# # << Haru Free PDF Library 2.0.0 >> -- encryption.rb # # Copyright (c) 1999-2006 Takeshi Kanno <takeshi_kanno@est.hi-ho.ne.jp> # # Permission to use, copy, modify, distribute and sell this software # and its documentation for any purpose is hereby granted without fee, # provided that the above copyright notice...
Ruby
# # << Haru Free PDF Library 2.0.0 >> -- font_example.rb # # Copyright (c) 1999-2006 Takeshi Kanno <takeshi_kanno@est.hi-ho.ne.jp> # # Permission to use, copy, modify, distribute and sell this software # and its documentation for any purpose is hereby granted without fee, # provided that the above copyright noti...
Ruby
# # << Haru Free PDF Library 2.0.2 >> -- arc_demo.rb # # http://libharu.org/ # # Copyright (c) 1999-2006 Takeshi Kanno # # Permission to use, copy, modify, distribute and sell this software # and its documentation for any purpose is hereby granted without fee, # provided that the above copyright notice appear ...
Ruby
# # << Haru Free PDF Library 2.0.6 >> -- ext_gstate_demo.rb # # http://libharu.org/ # # Copyright (c) 1999-2006 Takeshi Kanno # # Permission to use, copy, modify, distribute and sell this software # and its documentation for any purpose is hereby granted without fee, # provided that the above copyright notice ...
Ruby
# # << Haru Free PDF Library 2.0.2 >> -- ttfont_demo.rb # # http://libharu.org/ # # Copyright (c) 1999-2006 Takeshi Kanno # # Permission to use, copy, modify, distribute and sell this software # and its documentation for any purpose is hereby granted without fee, # provided that the above copyright notice appe...
Ruby
# # << Haru Free PDF Library 2.0.0 >> -- text_demo2.rb # # Copyright (c) 1999-2006 Takeshi Kanno <takeshi_kanno@est.hi-ho.ne.jp> # # Permission to use, copy, modify, distribute and sell this software # and its documentation for any purpose is hereby granted without fee, # provided that the above copyright notice...
Ruby
# # << Haru Free PDF Library 2.0.2 >> -- line_demo.rb # # http://libharu.org/ # # Copyright (c) 1999-2006 Takeshi Kanno # # Permission to use, copy, modify, distribute and sell this software # and its documentation for any purpose is hereby granted without fee, # provided that the above copyright notice appear...
Ruby
# # << Haru Free PDF Library 2.0.6 >> -- slideshow_demo.rb # # http://libharu.org/ # # Copyright (c) 1999-2006 Takeshi Kanno # # Permission to use, copy, modify, distribute and sell this software # and its documentation for any purpose is hereby granted without fee, # provided that the above copyright notice a...
Ruby
class CreateRoles < ActiveRecord::Migration def self.up create_table :roles, :options => "ENGINE=NDBCLUSTER" do |t| t.string :name t.text :description end end def self.down drop_table :roles end end
Ruby
class CreateProjects < ActiveRecord::Migration def self.up create_table :projects, :options => "ENGINE=NDBCLUSTER" do |t| t.string :name t.datetime :time t.auto_dates t.string :location t.text :description t.text :details t.integer :user_id t.integer :owner_id ...
Ruby
class CreateTaskStatuses < ActiveRecord::Migration def self.up create_table :task_statuses, :options => "ENGINE=NDBCLUSTER" do |t| t.string :name t.text :description end end def self.down drop_table :task_statuses end end
Ruby
class CreateInfos < ActiveRecord::Migration def self.up create_table :infos, :options => "ENGINE=NDBCLUSTER" do |t| t.string :site_title t.string :site_header t.text :site_info_text t.text :site_footer_text end end def self.down drop_table :infos end end
Ruby
class AddRepeatFields < ActiveRecord::Migration def self.up add_column "tasks", :repeat_number, :integer add_column "tasks", :repeat_peorid, :string end def self.down remove_column "tasks", :repeat_number remove_column "tasks", :repeat_peorid end end
Ruby
class CreateLogs < ActiveRecord::Migration def self.up create_table :logs, :options => "ENGINE=NDBCLUSTER" do |t| t.auto_dates t.integer :user_id t.integer :task_id t.datetime :deleted_at t.text :comment end end def self.down drop_table :logs end end
Ruby
class CreateUserRoles < ActiveRecord::Migration def self.up create_table :user_roles, :options => "ENGINE=NDBCLUSTER" do |t| t.integer :role_id t.integer :user_id end end def self.down drop_table :user_roles end end
Ruby
class AddAdministratorFlag < ActiveRecord::Migration def self.up add_column "users", :administrator, :boolean end def self.down remove_column "users", :administrator end end
Ruby
class CreateAssignments < ActiveRecord::Migration def self.up create_table :assignments, :options => "ENGINE=NDBCLUSTER" do |t| t.integer :task_id t.integer :user_id end end def self.down drop_table :assignments end end
Ruby
class AddSessions < ActiveRecord::Migration def self.up create_table :sessions, :options => "ENGINE=NDBCLUSTER" do |t| t.column :session_id, :string t.column :data, :text t.column :updated_at, :datetime end add_index :sessions, :session_id add_index :sessions, :updated_at end ...
Ruby
class CreateTaskKinds < ActiveRecord::Migration def self.up create_table :task_kinds, :options => "ENGINE=NDBCLUSTER" do |t| t.string :name end end def self.down drop_table :task_kinds end end
Ruby
class CreateRights < ActiveRecord::Migration def self.up create_table :rights, :options => "ENGINE=NDBCLUSTER" do |t| t.string :name t.text :description t.string :model end end def self.down drop_table :rights end end
Ruby
class CreateRoleRights < ActiveRecord::Migration def self.up create_table :role_rights, :options => "ENGINE=NDBCLUSTER" do |t| t.integer :role_id t.integer :right_id t.boolean :create t.boolean :read t.boolean :update t.boolean :delete end end def self.down drop_t...
Ruby
class CreateUsers < ActiveRecord::Migration def self.up create_table :users, :options => "ENGINE=NDBCLUSTER" do |t| t.string :username t.string :crypted_password, :salt, :limit => 40 t.string :remember_token t.datetime :remember_token_expires_at t.auto_dates end Us...
Ruby
class CreateTasks < ActiveRecord::Migration def self.up create_table :tasks, :options => "ENGINE=NDBCLUSTER" do |t| t.integer :owner_id t.string :name t.text :instructions t.datetime :run_through t.datetime :due_date t.auto_dates t.integer :task_status_id t.integer :task_kind_id ...
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
#!/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