text stringlengths 10 2.61M |
|---|
class AddDeadlineFieldToSubmissions < ActiveRecord::Migration[6.0]
def up
add_column :submissions, :deadline, :date
end
def down
remove_column :submissions, :deadline, :date
end
end
|
class EndecaEvent < ActiveRecord::Base
belongs_to :target, :polymorphic => true
####
# MODEL ANNOTATIONS
####
extend ValidationHelper
####
# CONSTANTS
####
TARGET_TYPE_MIN_LENGTH = 1
TARGET_TYPE_MAX_LENGTH = 64
TARGET_TYPE_REGEX = /^([[:alnum:]]+(::[[:alnum:]]+)*){#{TARGET_TYPE_MIN_... |
FactoryGirl.define do
factory :question do
title "MyTitleString"
body "MyBodyText"
end
end
|
require_relative '../lib/news_source'
RSpec.describe 'Paddy::NewsSource' do
subject { Paddy::NewsSource.new }
let(:url) { 'https://www.channelstv.com/category/world-news' }
let(:elem) { 'div.cat_page' }
let(:scrappr) { subject.send(:scrapper, url, elem) }
let(:bbc) { subject.send(:bbc) }
let(:channelstv) {... |
#!/usr/local/bin/ruby
#
# check.rb - part of rbayes
# Dan Peterson <danp@danp.net>
# you can do whatever you want with this file but i appreciate credit
#
# given a message on stdin, find tokens and determine the message's spam
# probability based on token ratings as described at
# http://www.paulgraham.com/spam.html
#... |
load %{./config/boot.rb}
load %{./config/database.rb}
load %{./config/apps.rb}
require 'padrino-core/cli/console'
require 'padrino-core/cli/adapter'
require 'padrino-core/cli/base'
require 'padrino-core/cli/rake'
require 'padrino-core/cli/rake_tasks'
def app
Padrino.application
end
def start( server = :puma )
put... |
require 'rails_helper'
describe 'Experiences API' do
let(:user) { create(:user) }
let!(:alt_user) { create(:user) }
describe 'GET /v1/experiences' do
it 'returns array of all Experiences' do
create(:experience)
create(:experience)
get api_v1_experiences_url, nil, authentication_headers(us... |
class CenterOfAttention < ActiveRecord::Base
has_many :delivery_order_detail
belongs_to :cost_center
end
|
require 'cases/sqlserver_helper'
require 'models/order'
class SqlServerRailsOrders < ActiveRecord::Base
set_table_name 'rails.orders'
end
class TableNameTestSqlserver < ActiveRecord::TestCase
self.use_transactional_fixtures = false
def setup
Order.table_name = '[orders]'
Order.reset_column_informa... |
class LibraryHours < ActiveRecord::Base
attr_accessible :opens, :closes, :date, :library_id
belongs_to :library
def to_day_of_week
date.strftime('%a')
end
def to_opens_closes
result = ''
if opens && closes
if opens.strftime('%l:%M%p') == '12:00PM'
opens_display = 'Noon'
els... |
class ApplicationController < ActionController::Base
protect_from_forgery
helper_method :current_user
private
def current_user
#reset_session
@current_user ||= User.find(session[:user_id]) if session[:user_id]
end
def set_current_nav(nav)
@current_nav = session[:current_nav] = nav
e... |
require 'spec_helper'
module RSpec::Rails::HyperShortcut
describe Behavior do
let(:matcher_placeholder) {stub(:matcher_placeholder).as_null_object}
before :each do
@behavior = Behavior.new :should, matcher_placeholder
@subject = stub(:subject)
end
describe "block_to_test(subject)" do
... |
# frozen_string_literal: true
# RangeFilter is used for many-to-many
# relation between Category and RangeParameter
class RangeFilter < ApplicationRecord
belongs_to :category
belongs_to :range_parameter
end
|
class CreateUserMedicalQuestions < ActiveRecord::Migration
def change
create_table :user_medical_questions do |t|
t.string :notes, limit: 150
t.references :medical_question, null: false
t.references :user, null: false
t.foreign_key :users, dependent: :delete
t.foreign_key :medical_qu... |
class TalksController < ApplicationController
def index
@groups = current_user.groups
end
def show
@group = Group.find(params[:id])
@talk = Talk.new
@talk_logs = @group.talks
@group.users.each do |user|
if user.name != current_user.name
@else_user = user
end
end
end... |
class CreateWashingMachinePrograms < ActiveRecord::Migration[5.2]
def change
create_table :washing_machine_programs do |t|
t.string :name, null: false
t.references :space, foreign_key: true
t.integer :temp, null: false
t.string :temp_unit, null: false
t.integer :speed, null: false
... |
class UploadImageForm
include Virtus.model
include RailsHelpers
extend ActiveModel::Naming
include ActiveModel::Conversion
include ActiveModel::Validations
attribute :image, String
def self.render(image)
self.new(image).render
end
def initialize(image)
end
def current_image
end
... |
FactoryGirl.define do
factory :character do
sequence(:name) { |n| "Warrior#{n}" }
avatar {Rack::Test::UploadedFile.new(File.join(Rails.root, 'spec', 'support', 'characters', 'warrior.jpg')) }
association :user
end
end
|
#!/usr/bin/ruby
class Array
def filter(&bl)
self.inject([]){|r, e| if e=bl.call(e)
r.push(e)
else
r
end}
# self.map(&bl).map{|e|nil if e == false}.compact
end
end
class String
def translat... |
require 'spec_helper'
describe Analyst::Entities::InstanceMethod do
let(:code) {<<-CODE
class DefaultCarrier
def initialize
@foo = "bar"
end
end
CODE
}
let(:parser) { Analyst.for_source(code) }
let(:klass) { parser.classes.first }
let(:method) { klass.imethods.firs... |
require 'class.rb'
require 'gd_const.rb'
AScore = Struct.new('AScore',:name, :kills, :overkills, :wins)
class AScore
private :initialize
class << self
def create(name, kills, overkills, wins)
a = self.new
a.name = name
a.kills = kills
a.overkills = overkills
a.wins = wins
r... |
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
describe EdgesController, 'routing' do
it "should map :controller => 'edges', :action => 'create' to /edges" do
route_for(:controller => 'edges', :action => 'create').should == { :path => '/edges', :method => 'post' }
end
it "should map... |
=begin
Наименьшее общее кратное: На вход подаётся строка, содержащая натуральные числа.
Вывести наименьшее общее кратное этих чисел.
=end
def maxdel(a, b)
#Euclidean_algorithm, нахождение наибольшего общего делителя для 2-х чисел
while b != 0
a, b = b, a % b
end
a
end
def minmult2(a,b)
#наименьшее общ... |
# ArduinoSketch is the main access point for working with RAD. Sub-classes of ArduinoSketch have access to a wide array of convenient class methods (documented below) for doing the most common kinds of setup needed when programming the Arduino such as configuring input and output pins and establishing serial connection... |
class Dashboard
include ActiveModel::AttributeAssignment
attr_accessor :role, :periods
def initialize(attributes)
att = check_attributes(attributes)
self.role = att[:role]
self.periods = att[:periods]
end
def self.played_since(starting, ending = nil, role_nr = 0)
# returns [count_me, perso (... |
require 'rails_helper'
require 'time'
require 'date'
RSpec.describe Event, type: :model do
before(:each) do
@event = FactoryBot.create(:event)
end
it "has a valid factory" do
expect(build(:event)).to be_valid
end
context "validation" do
it "is valid with valid attributes" do
expect(@ev... |
require 'spec_helper'
describe Api::Endpoints::TeamsEndpoint do
include Api::Test::EndpointTest
context 'cursor' do
before do
allow(Team).to receive(:where).with(token: nil).and_return(Team.all)
end
it_behaves_like 'a cursor api', Team
end
context 'team' do
let(:existing_team) { Fabric... |
class Photo < ActiveRecord::Base
has_many :albums, :foreign_key => "photo_id",
:dependent => :destroy
has_many :tags
has_many :folders, :through => :albums, :source => :photo
has_many :keywords, :through => :tags, :source => :keyword
has_many :print_products
end
|
# Author:: Derek Wang (mailto:derek.yuanzhi.wang@gmail.com)
# Copyright::
# License::
# Description::
# Usage::
class CustomerTypesController < ApplicationController
include AppExceptions
include Data::Initialisor
include ReportHelper
before_filter :authenticate_user!
before_filter :load_customer_ty... |
# -*- encoding : utf-8 -*-
class CreateSettings < ActiveRecord::Migration
def change
create_table :settings do |t|
t.string :font
t.string :font_color
t.string :bg_color
t.string :font_size
t.string :decoration
t.string :caption
t.timestamps
end
end
end
|
class PrinciplesController < ApplicationController
respond_to :html
def show
@principle = Principle.find(params[:id])
unless @principle.published
not_found
else
respond_with(@principle)
end
end
end
|
# == Schema Information
#
# Table name: items
#
# id :integer not null, primary key
# restaurant_id :integer
# dish :string
# description :string
# vegetarian :boolean
# vegan :boolean
# glutenfree :boolean
# size :string
# price :string
# created_... |
#!/usr/bin/env ruby
# frozen_string_literal: true
load 'conf.rb'
RUBY_VER = WebApiConf::UNICORN[:ruby_ver]
APP_DIR = WebApiConf::UNICORN[:working_dir]
UNICORN_CONTAINER_NAME = WebApiConf::UNICORN[:container_name]
UNICORN_HOST = WebApiConf::UNICORN[:host]
UNICOR... |
class Mcq < ApplicationRecord
has_many :surveys, through: :survey_mcq
end
|
require 'test_helper'
class ExercisesPerformedsControllerTest < ActionController::TestCase
setup do
@exercise = exercises_performeds(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:exercises_performeds)
end
test "should get show" do
get :... |
class UpdateContentPagesForTree < ActiveRecord::Migration
def self.up
add_column :content_pages, :parent_id, :integer, :null => false, :default => 0
add_index :content_pages, :parent_id
end
def self.down
remove_index :content_pages, :parent_id
remove_column :content_pages, :parent_id
end
end |
class Game < SPSprite
include Sparrow
attr_accessor :game_width, :game_height
def initWithWidth(width, height:height)
init
@game_width = width
@game_height = height
self.setup
self
end
def setup
SPAudioEngine.start
Media.init_atlas
Media.init_sound
background = SP... |
require 'date'
module ModelCitizen
class Validations
def not_nil_or_empty?(attributes)
!attributes.include?(nil) && !attributes.include?("")
end
def value_included?(*value, attribute)
[*value].include? attribute
end
def valid_date?(date)
valid_string?(date) && past_date?(date)... |
describe "put project" do
context "when modify project" do
let(:user) { build(:user) }
let(:token) { ApiUser.token(user.email, user.password) }
let(:original_project) { ApiProject.create_project(build(:new_project, assignedTo: user.id).to_hash, token) }
let(:id_original_project) { original_project["pr... |
class Conversation < ApplicationRecord
has_many :entities
has_many :diseases
end
|
# require 'rails_helper'
# RSpec.describe "contacts/new.html.erb", :type => :view do
# context "visual elements" do
# it "displays the contact title" do
# render
# expect(rendered).to match /Novo Contato/
# end
# it "renders a form to create a contact" do
# # assign(:contact, double... |
class AddingNewFieldReplaceDamaper < ActiveRecord::Migration
def change
add_column :lsspdfassets, :u_di_installed_access_door, :string
add_column :lsspdfassets, :u_di_replace_damper, :string
end
end
|
# encoding: utf-8
require 'spec_helper'
describe ManufacturersController do
before(:each) do
#the following recognizes that there is a before filter without execution of it.
controller.should_receive(:require_signin)
controller.should_receive(:require_employee)
end
render_views
describe "'in... |
# frozen_string_literal: true
class GameSerializer < ActiveModel::Serializer
attributes :id, :sport_id, :name, :record_user_id, :score_count, :left_users, :right_users, :created_at, :updated_at
def score_count
object.score_count
end
def left_users
object.units[0].users
end
def right_users
ob... |
class AddGoalToUserStats < ActiveRecord::Migration
def change
add_column :user_stats, :goal, :string
end
end
|
class Survey::QuestionsController < ApplicationController
# GET /survey/questions
# GET /survey/questions.json
load_and_authorize_resource
acts_as_flagable
def index
@survey_questions = Survey::Question.all
respond_to do |format|
format.html # index.html.erb
end
end
def answer
@surv... |
Rails.application.routes.draw do
resources :posts, defaults: {format: 'json'}
root 'main#index'
end
|
class AddStatusDateToJobInterest < ActiveRecord::Migration
def change
add_column :job_interests, :status_date, :datetime
end
end
|
class WatchesController < ApplicationController
before_action :find_issue
before_action :find_watch, only: [:destroy]
def create
if current_user != nil
if already_watched?
flash[:notice] = "You can't watch more than once"
else
@issue.watches.create(user_id: current_user.id)
... |
require 'spec_helper'
module Alf
module Operator
describe Signature, '#to_shell' do
subject{ signature.to_shell }
describe "on a nullary signature" do
let(:clazz){ Operator::NonRelational::Generator }
describe "on an empty signature" do
let(:signature){ Signature.new(clazz... |
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.0.0'
# Use mysql as the database for Active Record
gem 'mysql2', '~> 0.4.4'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= ... |
def unique_email_addresses(email_addresses)
#rules: each email has local name and domain name, ignore .(period),remove all characters from the + sign in the local name
formatted_email_addresses = {}
email_addresses.each do |email_address|
local_name, domain_name = email_address.split(/@/)
if local_nam... |
class Team < ActiveRecord::Base
belongs_to :league
def api_json
{ "id" => id, "name" => name }
end
end
|
require "rails_helper"
RSpec.describe SimpleServerExtensions do
it "has a git ref method" do
expected_ref = `git rev-parse HEAD`.chomp
expect(SimpleServer.git_ref).to eq(expected_ref)
end
it "knows the SIMPLE_SERVER_ENV" do
expect(SimpleServer.env).to eq("test")
end
it "can ask about env like R... |
When /^I switch to non-secure version of the same page$/ do
insecure_url = current_url.gsub(/^https/, 'http')
visit insecure_url
end
Given /^domain "([^\"]*)" supports SSL$/ do |domain|
Domain.stubs(:supports_ssl?).with(domain).returns(true)
end
|
class UpdateColumnToTheses < ActiveRecord::Migration
def change
rename_column :theses, :name_c, :name
remove_column :theses, :name_e
end
end
|
class Preference < ActiveRecord::Base
belongs_to :patient_appointment
validates :start_time, :date, presence: true
end
|
require 'spec_helper'
describe EmailNotification do
subject { EmailNotification }
describe 'send_individual' do
let(:credential) { {username: 'fdfd', password: 'fdfds'} }
let(:data) { mock.as_null_object }
it 'posts to mailgun server with api key' do
subject.should_receive :verify_required_para... |
require 'eb_ruby_client/support/members'
require 'eb_ruby_client/resource/user'
require 'eb_ruby_client/resource/address'
RSpec.describe EbRubyClient::Support::Members do
class MemberTest
include EbRubyClient::Support::Members
extend EbRubyClient::Support::MembersClassMethods
contains_many :users
co... |
require 'aws/templates/utils'
module Aws
module Templates
module Utils
module Parametrized
class Getter
##
# Syntax sugar for getters definition
#
# It injects the methods as class-scope methods into mixing classes.
# The methods are factories to cr... |
class CustomerSerializer < ActiveModel::Serializer
attributes :id,
:first_name,
:last_name,
:address,
:city,
:post_code,
:country,
:email,
:phone
end
|
class Node
attr_accessor :value, :next
def initialize(data)
@value = data
@next
end
end
class LinkedList
attr_accessor :head
def initialize
@head
end
def push(element)
new_node = Node.new(element)
new_node.next = @head
@head = new_node
end
def print_list
current = @head... |
class CreditCardEnrollmentProcess
include PageObject
include FooterPanel
include HeaderPanel
include DataMagic
page_url FigNewton.cos_url_prefix + FigNewton.cos_url_app_context + '/#/cardEnrollment/access'
h1(:header_creditcard, :id => 'page_header')
element(:icon_header,'i', :class => 'icon icon-credit... |
# encoding: utf-8
module Jenner
class Site
attr_reader :root
def initialize(root)
@root = root
Liquid::Template.file_system = Jenner::TemplateFileSystem.new(File.join(@root,'_templates'))
end
def to_liquid
{
'root' => @root,
'assets' => assets,
'item... |
require 'test_helper'
class ProductApi < ActionDispatch::IntegrationTest
describe 'Product API' do
it 'should connect and read a list' do
get '/products'
answer = JSON.parse(response.body, symbolize_names: true)[:products]
response.status.must_equal 200
response.content_type.must_equal M... |
class Api::V1::ListsController < ApplicationController
skip_before_action :verify_authenticity_token
def show
@list = List.find(params[:id])
@media = @list.media
respond_to do |format|
format.json { render :json => {:list => @list, :media => @media }}
end
end
def create
if List.find... |
require File.dirname(__FILE__) + '/../test_helper'
class TestLineChart < Test::Unit::TestCase
should 'have a default chart type' do
assert_match(/\bcht=lc\b/, GoogleChart::LineChart.new.to_url)
end
should 'support xy chart type' do
assert_match(/\bcht=lxy\b/, GoogleChart::LineChart.new(:type => :xy).t... |
#!/usr/bin/env rake
begin
require 'bundler/setup'
rescue LoadError
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
end
begin
require 'rdoc/task'
rescue LoadError
require 'rdoc/rdoc'
require 'rake/rdoctask'
require 'rdoc/task'
RDoc::Task = Rake::RDocTask
end
Bundler::GemHelper.instal... |
class AllMobile < ActiveRecord::Base
belongs_to :client
validates_presence_of :mobile
validates_numericality_of :mobile
end
|
class ChangeColName < ActiveRecord::Migration[5.2]
def change
rename_column :products, :origin_country, :country
end
end
|
class ContactsController < ApplicationController
# before "/contacts/*" do
# if !request.post?
# if !logged_in
# @alert_msg[:danger_alert] = "Please login to choose new contacts."
# erb :'users/login'
# end
# end
# end
# INDEX: contacts view all.
get '/contacts' do
@con... |
class B2 < Formula
desc "B2 command line tool."
homepage "https://www.backblaze.com/b2/docs/quick_command_line.html"
url "https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/tarball/a298c0a8b4d57c500e1e533cfe3c66d3f15e722b"
sha256 "3dcc97a494563b094aa02c48e8db2cf604d9b26e1f7a2f6f60844b81... |
module FileDefinition
ADMIN_OPERATIONS_FILE = File.expand_path('../data/admin_options.txt', File.dirname(__FILE__))
STUDENT_OPERATIONS_FILE = File.expand_path('../data/student_options.txt', File.dirname(__FILE__))
FACULTY_OPERATIONS_FILE = File.expand_path('../data/faculty_options.txt', File.dirname(__FILE__))
... |
module StarWarsAPI
module Swapi
class Request
SWAPI_URI = "https://swapi.dev/api/".freeze
def get_people(page: 1)
request(:get, "people/?page=#{page}")
end
def get_planets(page: 1)
request(:get, "planets/?page=#{page}")
end
def get_species(page: 1)
re... |
# frozen_string_literal: true
# Account Model
class Account < ApplicationRecord
belongs_to :user
validates :provider, presence: true
validates :identifier, presence: true
validates :access_token, presence: true
class << self
def find_by_credentials(provider, identifier, access_token)
account = Ac... |
# frozen_string_literal: true
FactoryBot.define do
factory :product do
name { Faker::Hipster.unique.words(number: 2).join(" ") }
end
end
|
require "rails_helper"
describe PatientStates::Hypertension::MissedVisitsPatientsQuery do
around do |example|
with_reporting_time_zone { example.run }
end
let(:regions) { setup_district_with_facilities }
let(:period) { Period.current }
context "missed visits" do
it "returns patients under care with... |
class Submission < ApplicationRecord
validates :user_id, presence: true
belongs_to :user
belongs_to :proposal
has_many :comments, dependent: :destroy
has_attached_file :avatar, styles: { large: "500x500>", medium: "300x300>", thumb: "100x100>" }, default_url: "/images/:style/default-avatar.jpg"
validates_a... |
FactoryGirl.define do
factory :text do
title 'Test text'
text 'Ruby on Rails is good'
language
end
end
|
require 'rails_helper'
require 'capybara/rspec'
# rubocop:disable Metrics/BlockLength
RSpec.describe PostsController, type: :feature do
context 'timeline displays friends posts' do
let(:user) { User.create(id: '1', name: 'Peter', email: 'peter@example.com', password: 'password') }
scenario 'display current u... |
require 'minitest/autorun'
require_relative '../lib/cyk'
class CykTest < MiniTest::Unit::TestCase
def test_sample_1_short_success
file = "files/sample-input1.txt"
string = "abbbbc"
assert_equal true, Cyk.can_generate(string, file)
end
def test_sample_1_short_failure
file = "files/sample-input1.t... |
# frozen_string_literal: true
class Campus < ActiveRecord::Base
self.table_name = "campuses"
# attr_accessible :name
has_many :schools
belongs_to :borough
default_scope { order('name ASC') }
end
|
require 'spec_helper'
describe Immutable::Vector do
describe '#fetch' do
let(:vector) { V['a', 'b', 'c'] }
context 'with no default provided' do
context 'when the index exists' do
it 'returns the value at the index' do
vector.fetch(0).should == 'a'
vector.fetch(1).should ==... |
class Member < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
has_many :community_members
has_many :communities, ... |
require_relative 'app_iconifier/asset_maker.rb'
class AppIconifier
def self.make_icons(source_image, destination, settings = {})
raise "Source image not found: #{source_image}" unless File.exist? source_image
IconMaker.new(source_image, destination).generate_set(settings)
end
def self.make_splash_screen... |
require 'faker'
Fabricator(:user) do
name { Faker::Name.name }
user_name { Faker::Internet.user_name + Faker::Number.number(3) }
email { Faker::Internet.email }
bio { Faker::Company.buzzword }
password { Faker::Internet.password(8) }
end
|
# All files in the 'lib' directory will be loaded
# before nanoc starts compiling.
include Nanoc::Helpers::LinkTo
include Nanoc::Helpers::Rendering
class String
def slugify()
return self.downcase.gsub(/[\s\.\/_]/, ' ').squeeze(' ').strip.tr(' ', '-')
end
end
|
# frozen_string_literal: true
class MovieSerializer
include JSONAPI::Serializer
attributes :title, :duration, :description, :genre, :director
has_many :screenings
end
|
#!/usr/bin/env ruby
require 'bundler'
Bundler.setup
require 'bcrypt'
if ARGV.size == 1
puts "Enter password:"
File.open(ARGV.shift, 'wb') do |f|
f.write(BCrypt::Password.create(gets.chomp))
end
else
puts "Usage: bin/passwd <path to passwd file>"
puts "Usually shared/password.hash (production) or db/passw... |
require 'rails_helper'
RSpec.describe Report, :type => :model do
before do
FactoryGirl.create(:active_employee, id: 1)
FactoryGirl.create(:active_employee, id: 2)
@report = new_report
end
context "with valid data" do
it "should have start date" do
expect(@report).to respond_to :date_start
... |
require 'net/http'
require 'htmlentities'
class RubyWolf
def initialize(query)
@query = query
getpods()
end
def listpods()
if (@pods.nil?)
return {}
end
return @pods.keys
end
def getpods()
if (@pods.nil?)
puts "Loading"
host = Net::HTTP.start("www.wolframalpha.com")
res = host.get("/inp... |
class SliderPhoto < ActiveRecord::Base
WIDTH = 700
HEIGHT = 250
mount_uploader :image, SliderImageUploader
attr_writer :x, :y, :w, :h
validates :image, :presence => true
def crop!
image.manipulate! do |img|
img.crop!(x, y, w, h)
img.resize_to_fit(WIDTH, HEIGHT)
end
end
... |
class Board < ApplicationRecord
has_many :introductions
belongs_to :user,optional: true
validates :users_id ,uniqueness: true
end
|
# frozen_string_literal: true
class AddCodeToSchoolsTable < ActiveRecord::Migration[4.2]
def change
add_column :schools, :code, :string, :limit => 8
add_index :schools, [:code], :unique => true
end
end
|
# == Schema Information
#
# Table name: floors
#
# id :bigint not null, primary key
# label :string
# building_id :bigint
# created_at :datetime not null
# updated_at :datetime not null
#
require "rails_helper"
describe Floor do
let(:building) { build(:building) }
... |
require 'spec_helper'
describe Log4r::RemoteSyslogOutputter do
describe '#initialize' do
let(:name) { 'name' }
let(:host) { 'host' }
let(:port) { 65535 }
subject { Log4r::RemoteSyslogOutputter }
it 'should create a new RemoteSyslogLogger::UdpSender' do
RemoteSyslogLogger::UdpSender.
... |
# == Schema Information
#
# Table name: shipments
#
# id :integer not null, primary key
# order_id :integer not null
# external_id :string not null
# ship_date :date not null
# quantity :integer ... |
# CircularQueue
class CircularQueue
attr_accessor :queue, :recently_added, :oldest_added
def initialize(length)
@queue = Array.new(length)
@recently_added = 0
@oldest_added = 0
end
def dequeue
# guard clause
return nil if empty?
last_item = @queue[@oldest_added]
@queue[@oldest_add... |
# THESE METHODS RESEMBLE TEXTBOOK PSEUDO CODE OR PROFESSOR CALLAHAN'S PYTHON CODE
# TODO: MIN HEAP METHODS TO BE ADDED
# NOTE: This kind of dynamic method addition to in-built classes is called
# MONKEY PATCHING(that's right) and its beautiful when done carefully
# This implementation does not factor in t... |
module Sqlite3Table
class Leaf
attr_accessor :header, :cells
def initialize(node, has_parent=true)
@has_parent = has_parent
@f = node.file
@pos = @f.pos
#print "reading leaf tree at #{@pos} w/ cells "
#p node.cells
@header = node.header
@cells = node.cells
en... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.