code
stringlengths
1
1.73M
language
stringclasses
1 value
#!/usr/bin/env ruby require File.expand_path('../../../config/boot', __FILE__) require 'commands/performance/profiler'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/generate'
Ruby
# Methods added to this helper will be available to all templates in the application. module ApplicationHelper end
Ruby
module BlocksHelper end
Ruby
module CategoriesHelper 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_fo...
Ruby
module BlockDocumentsHelper end
Ruby
class BlockDocument < ActiveRecord::Base attr_accessible :block_id, :category_id, :expiry_date, :name, :document belongs_to :block belongs_to :category has_attached_file :document, :url => "/documents/:id/:style/:basename.:extension", :path => ":rails_root/publi...
Ruby
class Block < ActiveRecord::Base attr_accessible :name, :postcode, :build_date has_many :block_documents end
Ruby
class Category < ActiveRecord::Base attr_accessible :description, :expiry_date_required, :build_date_depended, :before_build_date has_many :block_documents 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 helper :all # include all helpers, all the time protect_from_forgery # See ActionController::RequestForgeryPr...
Ruby
class CategoriesController < ApplicationController def index @categories = Category.all end def show @category = Category.find(params[:id]) end def new @category = Category.new end def create @category = Category.new(params[:category]) if @category.save flash[:notice] = ...
Ruby
class BlockDocumentsController < ApplicationController def index @block = Block.find(params[:block_id]) @block_documents = @block.block_documents.all end def show @block = Block.find(params[:block_id]) @block_document = @block.block_documents.find(params[:id]) end def new @block = ...
Ruby
class BlocksController < ApplicationController def index @blocks = Block.all @categories = Category.all end def show @block = Block.find(params[:id]) end def new @block = Block.new end def create @block = Block.new(params[:block]) if @block.save flash[:notice] = "S...
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 do debug a probl...
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. # 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
ActionController::Routing::Routes.draw do |map| # map.resources :block_documents map.resources :categories map.resources :blocks, :has_many => :block_documents map.root :controller => 'blocks', :action => 'index' # The priority is based upon order of creation: first created -> highest priority. # Sample of ...
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 # Specifies gem version of Rails to use when vendor/rails is not present RAILS_GEM_VERSION = '2.3.5' unless defined? RAILS_GEM_VERSION # Bootstrap the Rails environment, frameworks, and default configuration require File.join(File.dirname(__FILE__), 'boot') ...
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 # Full error reports are disabled and caching is turned on config.action_controller.consider_all_reque...
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
# 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. # 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
# A Site key gives additional protection against a dictionary attack if your # DB is ever compromised. With no site key, we store # DB_password = hash(user_password, DB_user_salt) # If your database were to be compromised you'd be vulnerable to a dictionary # attack on all your stupid users' passwords. With a site...
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 do debug a probl...
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 # Full error reports are disabled and caching is turned on config.action_controller.consider_all_reque...
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 # Specifies gem version of Rails to use when vendor/rails is not present RAILS_GEM_VERSION = '2.3.4' unless defined? RAILS_GEM_VERSION # Bootstrap the Rails environment, frameworks, and default configuration require File.join(File.dirname(__FILE__), 'boot') ...
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.supervision '/supervision', :controller => 'supervisions', :action => 'tree' map.mobiles '/mobiles', :controller => 'mobiles', :action => 'index' map.resources :operations map.resources :computers map.resources :networks map.resources :rooms ...
Ruby
# Methods added to this helper will be available to all templates in the application. module ApplicationHelper end
Ruby
module ContactsHelper end
Ruby
module UsersHelper # # Use this to wrap view elements that the user can't access. # !! Note: this is an *interface*, not *security* feature !! # You need to do all access control at the controller level. # # Example: # <%= if_authorized?(:index, User) do link_to('List all users', users_path) end %> ...
Ruby
module OperationsHelper end
Ruby
module SessionsHelper end
Ruby
module CompaniesHelper end
Ruby
module HomeHelper end
Ruby
require 'snmp' include SNMP module ComputersHelper def pingecho(host, timeout=5, service="echo") begin timeout(timeout) do s = TCPSocket.new(host, service) s.close end rescue Errno::ECONNREFUSED return true rescue Timeout::Error return false rescue ret...
Ruby
module RoomsHelper end
Ruby
module NetworksHelper end
Ruby
class Operation < ActiveRecord::Base validates_presence_of :name validates_presence_of :description OPERATION_STATUS = { 0=>"Draft", 1=>"Validated", 2=>"In wait", 3=>"Cancelled", 4=>"Closed" } has_and_belongs_to_many :computers end
Ruby
class Contact < ActiveRecord::Base validates_presence_of :name validates_presence_of :company_id validates_length_of :phone_num, :within => 0..10 belongs_to :user belongs_to :company end
Ruby
require 'digest/sha1' class User < ActiveRecord::Base include Authentication include Authentication::ByPassword include Authentication::ByCookieToken has_many :contacts validates_presence_of :login validates_length_of :login, :within => 3..40 validates_uniqueness_of :login validates_...
Ruby
class Network < ActiveRecord::Base validates_presence_of :name validates_presence_of :computer_id validates_presence_of :submask belongs_to :computer has_many :computers has_and_belongs_to_many :rooms end
Ruby
class Company < ActiveRecord::Base has_many :rooms has_many :contacts validates_presence_of :name validates_presence_of :num_siret validates_uniqueness_of :num_siret validates_presence_of :phone_num validates_length_of :phone_num, :within => 0..10 validates_presence_of :a...
Ruby
class Computer < ActiveRecord::Base validates_presence_of :name validates_presence_of :os validates_presence_of :room_id validates_presence_of :mac_address validates_format_of :mac_address, :with => /^([0-9A-F]{2}:|-){5}([0-9A-F]{2})$/, :message => "should look like an mac address." ...
Ruby
class Room < ActiveRecord::Base validates_presence_of :code validates_presence_of :capacity validates_presence_of :company_id belongs_to :company has_many :computers has_and_belongs_to_many :networks end
Ruby
class HomeController < ApplicationController before_filter :login_required #Declare struc ComputerByStartDate = Struct.new(:status, :count) ComputerCountByOs = Struct.new(:os, :count) def index @title="Dashboard" @companies = Company.all @rooms = Room.find(:all) @networks = Network.fin...
Ruby
class CompaniesController < ApplicationController # GET /companies # GET /companies.xml before_filter :login_required def index @title = "Index Companies" @companies = Company.all respond_to do |format| format.html # index.html.erb format.xml { render :xml => @companies } end ...
Ruby
class RoomsController < ApplicationController before_filter :login_required # GET /rooms # GET /rooms.xml def index @title = "Index Rooms" @rooms = Room.all respond_to do |format| format.html # index.html.erb format.xml { render :xml => @rooms } end end # GET /rooms/1 ...
Ruby
class NetworksController < ApplicationController # GET /networks # GET /networks.xml before_filter :login_required def index @title = "Index Networks" @networks = Network.all respond_to do |format| format.html # index.html.erb format.xml { render :xml => @networks } end end...
Ruby
# This controller handles the login/logout function of the site. class SessionsController < ApplicationController # Be sure to include AuthenticationSystem in Application Controller instead # render new.erb.html def new @title="Login" end def create @title = "New Login" logout_keeping_session! ...
Ruby
class OperationsController < ApplicationController # GET /operations # GET /operations.xml before_filter :login_required def index @title = "Index Operations" @operations = Operation.all respond_to do |format| format.html # index.html.erb format.xml { render :xml => @operations }...
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 AuthenticatedSystem helper :all # include all helpers, all the time protect_from_forgery # See A...
Ruby
class ComputersController < ApplicationController # GET /computers # GET /computers.xml before_filter :login_required def index @title = "Index Computers" @computers = Computer.all respond_to do |format| format.html # index.html.erb format.xml { render :xml => @computers } en...
Ruby
class MobilesController < ApplicationController # GET /companies # GET /companies.xml def index @parent = :index @companies = Company.all @activeComputerSize = 0 @inactiveComputerSize = 0 @operationComputerSize = 0 @allComputerSize = 0 # allComputers allComputers = Computer...
Ruby
class UsersController < ApplicationController # Be sure to include AuthenticationSystem in Application Controller instead # render new.rhtml #before_filter :login_required def index @title = "Users" @users = User.all respond_to do |format| format.html # index.html.erb format.xml ...
Ruby
class ContactsController < ApplicationController # GET /contacts # GET /contacts.xml before_filter :login_required def index @title = "Index Contacts" @contacts = Contact.all respond_to do |format| format.html # index.html.erb format.xml { render :xml => @contacts } end end...
Ruby
class SupervisionsController < ApplicationController before_filter :login_required # GET /rooms # GET /rooms.xml def tree @title = "Tree Rooms" @companies = Company.all @computers = [] for computer in Computer.all if (computer.room_id == nil) @computers << computer end...
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.expand_path('../../config/boot', __FILE__) require 'commands/dbconsole'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/console'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/runner'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../../config/boot', __FILE__) require 'commands/performance/benchmarker'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../../config/boot', __FILE__) require 'commands/performance/benchmarker'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../../config/boot', __FILE__) require 'commands/performance/profiler'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../../config/boot', __FILE__) require 'commands/performance/profiler'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/plugin'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/destroy'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) $LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info" require 'commands/about'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/dbconsole'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/runner'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/server'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/generate'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/console'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/destroy'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/generate'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/server'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) $LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info" require 'commands/about'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/plugin'
Ruby
class PingAllComputers < ActiveRecord::Base computers = Computer.all for computer in computers if (computer.status != 2) if (ComputersHelper::pingecho(computer.ip_address)) computer.status = 1 else computer.status = 0 end computer.save end end end
Ruby
class CreateCompanies < ActiveRecord::Migration def self.up create_table :companies do |t| t.string :name t.string :num_siret t.string :phone_num t.string :address t.timestamps end end def self.down drop_table :companies end end
Ruby
class CreateNetworksRoomsJoinTable < ActiveRecord::Migration def self.up create_table :networks_rooms, :id => false do |t| t.references :network, :room # Pour créer les clés etrangères end add_index :networks_rooms, [:network_id, :room_id] # Optionnel end def self.down drop_table :networks_...
Ruby
class CreateUsers < ActiveRecord::Migration def self.up create_table "users", :force => true do |t| t.string :login, :limit => 40 t.string :name, :limit => 100, :default => '', :null => true t.string :email, :limit => 100 t...
Ruby
class CreateComputersOperationsJoinTable < ActiveRecord::Migration def self.up create_table :computers_operations, :id => false do |t| t.references :computer, :operation # Pour créer les clés etrangères end add_index :computers_operations, [:computer_id, :operation_id] # Optionnel end def self....
Ruby
class CreateNetworks < ActiveRecord::Migration def self.up create_table :networks do |t| t.string :name t.string :computer_id t.string :submask t.timestamps end end def self.down drop_table :networks end end
Ruby
class CreateComputers < ActiveRecord::Migration def self.up create_table :computers do |t| t.string :name t.string :os t.string :mac_address t.string :ip_address t.date :start_date t.integer :status t.integer :network_id t.integer :room_id t.timestamps en...
Ruby
class CreateRooms < ActiveRecord::Migration def self.up create_table :rooms do |t| t.string :code t.boolean :stock t.integer :capacity t.integer :company_id t.timestamps end end def self.down drop_table :rooms end end
Ruby
class CreateOperations < ActiveRecord::Migration def self.up create_table :operations do |t| t.string :name t.string :description t.date :start_date t.date :end_date t.integer :status t.timestamps end end def self.down drop_table :operations end end
Ruby
class CreateContacts < ActiveRecord::Migration def self.up create_table :contacts do |t| t.string :name t.string :firstname t.integer :user_id t.integer :company_id t.string :mail t.string :phone_num t.timestamps end end def self.down drop_table :contacts ...
Ruby
class CreateComputersContactsJoinTable < ActiveRecord::Migration def self.up create_table :computers_contacts, :id => false do |t| t.references :computer, :contact # Pour créer les clés etrangères end add_index :computers_contacts, [:computer_id, :contact_id] # Optionnel end def self.down d...
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' }]) # Major.create(:name...
Ruby