code
stringlengths
1
1.73M
language
stringclasses
1 value
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
BiblioUff::Application.routes.draw do get "disciplinas/new" get "disciplinas/index" get "disciplinas/assoc" get "pastas/new" get "pastas/create" get "pastas/destroy" get "editoras/new" get "editoras/create" get "editoras/search" get "editoras/destroy" get "livros/new" get "livros/crea...
Ruby
module ApplicationHelper end
Ruby
module UsersHelper end
Ruby
module LivrosHelper end
Ruby
module SessionsHelper end
Ruby
module PastasHelper end
Ruby
module DisciplinasHelper end
Ruby
module EditorasHelper end
Ruby
class Editora < ActiveRecord::Base end
Ruby
class Disciplina < ActiveRecord::Base end
Ruby
class User < ActiveRecord::Base end
Ruby
class Livro < ActiveRecord::Base has_attached_file :arquivo_pdf has_attached_file :thumb end
Ruby
class Pasta < ActiveRecord::Base end
Ruby
class DisciplinasController < ApplicationController def new end def index end def assoc end end
Ruby
class PastasController < ApplicationController before_filter :authenticate add_breadcrumb "Principal", :root_path add_breadcrumb "Users", :users_path def new end def create end def destroy end def index end protected def authenticate if session[:tipo].upcase != 'PROF' ...
Ruby
class SessionsController < ApplicationController def new end def create @user = User.find(:first, :conditions => ['login = ? AND password = ?', params[:login],params[:password]]) if @user session[:logged] = true session[:username] = @user.login session[:tipo] = @user.tipo redirect_to livros_p...
Ruby
class LivrosController < ApplicationController before_filter :authenticate add_breadcrumb "Principal", :root_path add_breadcrumb "Livros", :livros_path def new @livro = Livro.new end def create @livro = Livro.new(params[:livro]) @livro.num_alugado = 0 if @livro.save redirect_to l...
Ruby
class ApplicationController < ActionController::Base protect_from_forgery private before_filter :instantiate_controller_and_action_names def instantiate_controller_and_action_names @current_action = action_name @current_controller = controller_name end end
Ruby
class EditorasController < ApplicationController before_filter :authenticate def new @editora = Editora.new end def create @editora = Editora.new(params[:editora]) if @editora.save redirect_to editoras_path else render :action => 'new' end end def search end def destroy ...
Ruby
class UsersController < ApplicationController before_filter :authenticate add_breadcrumb "Principal", :root_path add_breadcrumb "Users", :users_path def index @users = User.find(:all) end def new @user = User.new end def create @user = User.new(params[:user]) if @user.save redi...
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__) BiblioUff::Application.load_tasks
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__) BiblioUff::Application.load_tasks
Ruby
source 'http://rubygems.org' gem 'rails', '3.1.1' # Bundle edge Rails instead: # gem 'rails', :git => 'git://github.com/rails/rails.git' gem 'sqlite3' gem 'pg' # Gems used only for assets and not required # in production environments by default. group :assets do gem 'sass-rails', '~> 3.1.4' gem 'coffee-ra...
Ruby
class AddAttachmentArquivoPdfToLivro < ActiveRecord::Migration def self.up add_column :livros, :arquivo_pdf_file_name, :string add_column :livros, :arquivo_pdf_content_type, :string add_column :livros, :arquivo_pdf_file_size, :integer add_column :livros, :arquivo_pdf_updated_at, :datetime end def...
Ruby
class CreateLivros < ActiveRecord::Migration def change create_table :livros do |t| t.string :titulo t.string :autor t.string :editora t.string :path t.string :edicao t.string :tema t.string :volume t.integer :num_aluguel t.integer :num_alugado t.times...
Ruby
class AddArquivoFileNameToLivro < ActiveRecord::Migration def self.up add_column :livros, :arquivo_file_name, :string end def self.down remove_column :livros, :arquivo_file_name end end
Ruby
class CreateDisciplinas < ActiveRecord::Migration def change create_table :disciplinas do |t| t.string :codigo t.timestamps end end end
Ruby
class CreateEditoras < ActiveRecord::Migration def change create_table :editoras do |t| t.string :nome t.timestamps end end end
Ruby
class AddAttachmentThumbToLivro < ActiveRecord::Migration def self.up add_column :livros, :thumb_file_name, :string add_column :livros, :thumb_content_type, :string add_column :livros, :thumb_file_size, :integer add_column :livros, :thumb_updated_at, :datetime end def self.down remove_column ...
Ruby
class CreateUsers < ActiveRecord::Migration def change create_table :users do |t| t.string :login t.string :password t.string :tipo t.timestamps end end end
Ruby
class CreatePasta < ActiveRecord::Migration def change create_table :pasta do |t| t.string :assunto t.string :disciplina t.timestamps end end end
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
# This file is used by Rack-based servers to start the application. require ::File.expand_path('../config/environment', __FILE__) run BiblioUff::Application
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
require 'fileutils' task :default => [:clean] task :clean do [".", "tests"].each do |cd| puts "Cleaning directory #{cd}" Dir.new(cd).each do |t| if t =~ /.*\.pyc$/ puts "Removing #{File.join(cd, t)}" File.delete(File.join(cd, t)) end end end end desc "Upversion files" task...
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
# 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| # 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 def google_bar_chart(title, data) # TODO: add width, height # chartString = "<img src=\"http://chart.apis.google.com/chart?" # replace title with space chartSize = "chs=500x100" ch...
Ruby
module PlantHelper end
Ruby
module WelcomeHelper end
Ruby
module CompanyHelper def owner_filter_list(selected) filter_link_list("owner", Company::OWNER_TYPES, selected, true) end def state_filter_list(selected) filter_link_list("state", ApplicationController::STATE_ABBR, selected, false) end def filter_link_list(attribute, options, selected, show_all)...
Ruby
class Generator < ActiveRecord::Base belongs_to :company belongs_to :plant end
Ruby
class Plant < ActiveRecord::Base set_primary_key 'plntcode' belongs_to :company has_many :generators def total_nameplate_capacity nameplate = Generator.sum(:nameplate, :conditions => [ "plntcode = ?", self.id ]).to_i end end
Ruby
class Company < ActiveRecord::Base set_primary_key 'utilcode' has_many :plants, :foreign_key => 'utilcode' has_many :generators, :foreign_key => 'utilcode' OWNER_TYPES = { 'C' => 'Cooperative', 'F' => 'Federal', 'I' => 'Investor Owned', 'M' => 'Municipal', 'S' => 'State', 'O' => 'Ot...
Ruby
class WelcomeController < ApplicationController def index end end
Ruby
class PlantController < ApplicationController helper :all # include all helpers, all the time. TODO: revise this?? def index end def view @plant = Plant.find(params[:id]) @pageTitle = @plant.name end end
Ruby
class CompanyController < ApplicationController helper :all # include all helpers, all the time. TODO: revise this?? def index @pageTitle = "Electric Power Industry Companies" conditions = {} conditions[:ownertype] = params[:owner] if params[:owner] if params[:state] conditi...
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 helper :all # include all helpers, all the time # See ActionController::RequestForgeryProtection for detai...
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 CreatePlants < ActiveRecord::Migration def self.up create_table :plants do |t| t.timestamps end end def self.down drop_table :plants end end
Ruby
class CreateCompanies < ActiveRecord::Migration def self.up create_table :companies do |t| t.timestamps end end def self.down drop_table :companies end end
Ruby
class CreateGenerators < ActiveRecord::Migration def self.up create_table :generators do |t| t.timestamps end end def self.down drop_table :generators end end
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
#!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
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. # These settings change the behavior of Rails 2 apps and will be defaults # for Rails 3. You can remove this initializer when Rails 3 is released. if defined?(ActiveRecord) # Include Active Record class name as root for JSON serialized output. ActiveReco...
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