code
stringlengths
1
1.73M
language
stringclasses
1 value
def get_mission Mission.find_by_name("MissionWithSettings") || FactoryGirl.create(:mission) end FactoryGirl.define do factory :mission do name "MissionWithSettings" settings { # use Saskatchewan timezone b/c no DST [Setting.new( :timezone => "Saskatchewan", :languages => "en", ...
Ruby
FactoryGirl.define do factory :form_type do name { Random.words(1) } end end
Ruby
def get_user User.find_by_login("test") || FactoryGirl.create(:user) end FactoryGirl.define do factory :user do login "test" name "Test Test" reset_password_method "print" password "kkkdddkkk" password_confirmation "kkkdddkkk" phone "+15558881212" after(:build) do |user| Role...
Ruby
FactoryGirl.define do factory :form do name { "Form #{rand(1000000)}" } association :type, :factory => :form_type mission { get_mission } end end
Ruby
FactoryGirl.define do factory :question do name_en "Questo" code "questo" question_type_id { QuestionType.find_by_name("integer").id } mission { get_mission } end end
Ruby
ENV["RAILS_ENV"] = "test" require File.expand_path('../../config/environment', __FILE__) # methods for testing sms forms functionality class ActiveSupport::TestCase # helper that sets up a new form with the given parameters def setup_form(options) # default question required option options[:required] ||= ...
Ruby
ENV["RAILS_ENV"] = "test" require File.expand_path('../../config/environment', __FILE__) require 'rails/test_help' class ActiveSupport::TestCase ##################################################### # REPORT TEST HELPERS def prep_objects Role.generate # clear out tables [Question, Question...
Ruby
class Switch attr_accessor :in_up, :in_down, :out_up, :out_down, :ind_bit, :packet_size, :zeropacket def initialize(add_bit, packet_size) @ind_bit = add_bit @zeropacket = Array.new packet_size, '0' end #--------------------------------------------------------- def run # puts in_up.inspe...
Ruby
kernel_path = (File.expand_path(__FILE__).split("/"))[0..-2].join("/") + '/' require kernel_path +'env' require kernel_path +'pdb_my_lib.rb' require kernel_path +'log_lib' require kernel_path +'db_lib' require kernel_path +'blast_lib' require kernel_path +'rmsd_lib' # 0) rsync with pdb server to get new files # 0....
Ruby
#init the globals $WARN_IO = $stdout if !$WARN_IO $DEBUG_IO = $stdout if !$DEBUG_IO $ERR_IO = $stderr if !$ERR_IO $LOG_IO = $stdout if !$LOG_IO def set_l_to_file(fname) $LOG_IO = File.new(fname,'w') end def set_w_to_file(fname) $WARN_IO = File.new(fname,'w') $WARN_IO.sync = true end def set_e_to_file(fname) $E...
Ruby
kernel_path = (File.expand_path(__FILE__).split("/"))[0..-2].join("/") + '/' require kernel_path +'env' require kernel_path +'pdb_my_lib.rb' require kernel_path +'log_lib' require kernel_path +'db_lib' require kernel_path +'blast_lib' $bl2seq = get_path('bl2seq') #'/home/snepomny/structures/progs/blast-2.2.22/bin/bl2...
Ruby
kernel_path = (File.expand_path(__FILE__).split("/"))[0..-2].join("/") + '/' require kernel_path+'pdb_my_lib.rb' require kernel_path+'log_lib' require kernel_path+'env' require kernel_path+'db_lib' $bl2seq = get_path('bl2seq') if ! $bl2seq $seq_files = get_path('seq_files') if ! $seq_files #-------------------------...
Ruby
# CREATE TABLE `proteins`.`seqres` ( # `pdbname` char(6) NOT NULL, # `chain` char(1) NOT NULL, # `seqres` text , # `precision` float , # PRIMARY KEY (`pdbname`, `chain`) # ) #------------------------------------------------------------------- #sets up the connection to mysql database. $connection global var...
Ruby
def get_path(key) home_hash = { 'open' => '/home/snepomny/structures/data/open/', 'TMscore' => '/home/snepomny/structures/progs/TMscore_32', 'bl2seq' => '/home/snepomny/structures/progs/blast-2.2.22/bin/bl2seq', 'seq_files' => '/home/snepomny/structures/data/seq', 'rxyz_files' => '/home/snepomny/structure...
Ruby
kernel_path = (File.expand_path(__FILE__).split("/"))[0..-2].join("/") + '/' require kernel_path + 'log_lib' require 'rubygems' $: << '/home/rsyncuser/.gem/ruby/1.9.0/gems/bio-1.4.0/lib/' require 'bio' unless $in_intel #parsing pdb files lib RESOLUTION_THRESHOLD = 3.5 RESOLUTION_HIGH = "[w][1] Resolution too high " ...
Ruby
#!/usr/intel/pkgs/ruby/1.8.2/bin/ruby $in_intel = (`id`.include? 'mpgall') $on_rachel_lx = (`whoami`.include? 'rsyncuser') $on_rachel2 = (`uname -a`.include? 'rachel-2') kernel_path = (File.expand_path(__FILE__).split("/"))[0..-2].join("/") + '/' require 'rubygems' require kernel_path +'env' require kernel_path +'pd...
Ruby
#!/usr/intel/pkgs/ruby/1.8.2/bin/ruby $in_intel = (`id`.include? 'mpgall') $on_rachel_lx = (`whoami`.include? 'rsyncuser') $on_rachel2 = (`uname -a`.include? 'rachel-2') kernel_path = (File.expand_path(__FILE__).split("/"))[0..-2].join("/") + '/' require 'rubygems' require kernel_path +'env' require kernel_path +'pd...
Ruby
# fname = (f = File.new ARGV[0]) # while (line=f.gets) # puts fname + "#" + line.split(':')[-1].strip if line.include? 'REMARK' # fname = line.chomp.strip # end #========================================================= # file = File.new(ARGV[0]) # hsh = {} # id = nil # rf = nil # while line=file.gets do # tmp = li...
Ruby
seq_files = '/home/snepomny/structures/data/new_seq_files' #'/nfs/iil/proj/mpgarch/gsr_data_bcs02/BCS/stuff/port/new_seq_files' str_files = '/home/snepomny/structures/data/new_str_files' bl2seq = '/home/snepomny/structures/progs/blast-2.2.22/bin/bl2seq' blast_pdbs = '/home/snepomny/structures/pdb_utils/bin/blast_pd...
Ruby
# This plugin use rails generator funcionality to generate contact_form # Autor: Daniel Lopes # Website: http://www.areacriacoes.com.br require 'contact_form'
Ruby
class ContactFormGenerator < Rails::Generator::Base def manifest record do |m| # Controller m.file "controllers/contact_controller.rb", "app/controllers/contact_controller.rb" , :collision => :skip # Models m.file "models/contact_form.rb", "app/models/contact_form.rb" , :coll...
Ruby
class ContactMailer < ActionMailer::Base def send_contact(fields) recipients "contato@areacriacoes.com.br" from fields[:email] subject "Contato" sent_on Time.now body :fields => fields content_type "text/html" end end
Ruby
class ContactForm < ActiveForm attr_accessor :name, :email, :message validates_presence_of :name, :email, :message validates_format_of :email, :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i end
Ruby
class ContactController < ApplicationController def send_contact begin @contact_form = ContactForm.new(:name => params[:name], :email => params[:email], :message => params[:message]) if @contact_form.valid? ContactMailer.deliver_send_conta...
Ruby
require 'rake' require 'rake/testtask' require 'rake/rdoctask' desc 'Default: run unit tests.' task :default => :test desc 'Test the contact_form plugin.' Rake::TestTask.new(:test) do |t| t.libs << 'lib' t.pattern = 'test/**/*_test.rb' t.verbose = true end desc 'Generate documentation for the contact_form plug...
Ruby
# desc "Explaining what the task does" # task :contact_form do # # Task goes here # end
Ruby
# Uninstall hook code here
Ruby
require 'fileutils' puts IO.read(File.join(File.dirname(__FILE__), 'README'))
Ruby
# ContactForm
Ruby
class CreateAuths < ActiveRecord::Migration def self.up create_table :auths do |t| t.timestamps end end def self.down drop_table :auths end end
Ruby
class CreateSessions < ActiveRecord::Migration def self.up create_table :sessions do |t| t.string :session_id, :null => false t.text :data t.timestamps end add_index :sessions, :session_id add_index :sessions, :updated_at end def self.down drop_table :sessions end end
Ruby
class CreateNetworkTypes < ActiveRecord::Migration def self.up create_table :network_types do |t| t.string :name t.timestamps end end def self.down drop_table :network_types end end
Ruby
class CreateUsers < ActiveRecord::Migration def self.up create_table :users do |t| t.string :loginid t.string :email t.string :fname t.string :lname t.string :hashed_password t.string :salt t.timestamps end end def self.down drop_table :users end end
Ruby
class CreateNetworks < ActiveRecord::Migration def self.up create_table :networks do |t| t.string :name t.string :description t.int :user_id t.string :is_private t.string :type t.int :team_id t.timestamps end end def self.down drop_table :networks end end
Ruby
class CreateNodes < ActiveRecord::Migration def self.up create_table :nodes do |t| t.integer :network_id t.string :name t.string :description t.timestamps end end def self.down drop_table :nodes end end
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
#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/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/dispat...
Ruby
#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/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 Fast...
Ruby
#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/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/dispat...
Ruby
#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/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/dispat...
Ruby
#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/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 Fast...
Ruby
#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/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/dispat...
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/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/destroy'
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/console'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/dbconsole'
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/server'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/dbconsole'
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/plugin'
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/spawner'
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/reaper'
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/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/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/request'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/generate'
Ruby
# Methods added to this helper will be available to all templates in the application. module ApplicationHelper end
Ruby
module AuthHelper end
Ruby
module UsersHelper end
Ruby
module NodesHelper end
Ruby
module NetworksHelper end
Ruby
class Network < ActiveRecord::Base belongs_to :user has_many :nodes def self.get_network_privacy(id) if Network.find_by_id(id).is_private? @privacy = "private" else @privacy = 'public' end end def self.get_network_privacy_image(id) if Network.find_by_id(id).is_private? "/images/ico...
Ruby
require 'digest/sha1' class User < ActiveRecord::Base has_many :networks has_many :nodes validates_presence_of :fname validates_presence_of :fname validates_presence_of :loginid validates_presence_of :email validates_uniqueness_of :loginid validates_uniqueness_of :email attr_accessor :passwor...
Ruby
class Node < ActiveRecord::Base belongs_to :network end
Ruby
class NetworkType < ActiveRecord::Base has_many :networks end
Ruby
class Auth < ActiveRecord::Base validates_presence_of :name validates_presence of :user_name end
Ruby
class NetworksController < ApplicationController # GET /networks # GET /networks.xml def index @networks = Network.find(:all) respond_to do |format| format.html # index.html.erb format.xml { render :xml => @networks } end end # GET /networks/1 # GET /networks/1.xml def show ...
Ruby
class AuthController < ApplicationController def login session[:user_id] = nil if request.post? user = User.authenticate(params[:loginid], params[:password]) if user session[:user_id] = user.id redirect_to(:action => user.id, :controller => "users") else ...
Ruby
class UsersController < ApplicationController # GET /users # GET /users.xml def index @users = User.find(:all, :order => :loginid) respond_to do |format| format.html # index.html.erb format.xml { render :xml => @users } end end # GET /users/1 # GET /users/1.xml def show ...
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 before_filter :authorize, :except => :login before_filter :fetch_logged_in_user helper :all # include all ...
Ruby
class NodesController < ApplicationController in_place_edit_for :node, :description def create @network = Network.find(params[:network_id]) @network.nodes.create params[:node] respond_to do |format| format.html { redirect_to @network } format.js end end def show @node = Node.find(params[:id]) ...
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
# 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. # Include Active Record class name as root for JSON serialized output. ActiveRecord::Base.include_root_in_json = true # Store the full class name (including module namespa...
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
ActionController::Routing::Routes.draw do |map| map.resources :nodes map.resources :networks map.resources :users # The priority is based upon order of creation: first created -> highest priority. # Sample of regular route: # map.connect 'products/:id', :controller => 'catalog', :action => 'view' # ...
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 # 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.1...
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
# 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
require 'digest/sha2' # This module contains functions for hashing and storing passwords module Password # Generates a new salt and rehashes the password def Password.update(password) salt = self.salt hash = self.hash(password,salt) self.store(hash, salt) end # Checks the password against the sto...
Ruby
require 'rake/tasklib' require 'thread' require 'webrick' require 'fileutils' include FileUtils require 'erb' class Browser def supported?; true; end def setup ; end def open(url) ; end def teardown ; end def host require 'rbconfig' Config::CONFIG['host'] end def macos? ...
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 =>...
Ruby
class CreateDataFiles < ActiveRecord::Migration def self.up create_table :data_files do |t| t.timestamps end end def self.down drop_table :data_files 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