text stringlengths 10 2.61M |
|---|
begin
puts 'I am before the raise.'
raise 'An error has occurred.'
puts 'I am after the raise.'
rescue Exception => e
puts e.message
ensure
puts "I am sure"
end
puts 'I am after the begin block.'
def promptAndGet(prompt)
print prompt
res = readline.chomp
throw :lable i... |
module Referrer
module OwnerModelAdditions
extend ActiveSupport::Concern
included do
has_many :referrer_users_main_app_users, class_name: 'Referrer::UsersMainAppUser', as: :main_app_user
def referrer_users
referrer_users_main_app_users.includes(:user).map{|relation| relation.user}
... |
require 'provider'
describe Provider do
subject(:provider) { Provider.new(:name => 'Dr. Michael Smith', :npi => '123456789', :tin => '1234567890', :measure_preference => 'individual', :organization_id => 99) }
describe '#new' do
it 'has a name' do
expect(provider.name).to eq 'Dr. Michael Smith'
en... |
class BoatsJob < ApplicationRecord
belongs_to :boat
belongs_to :job
def self.no_boat_assignment_for?(boat_id)
where(boat_id: boat_id).empty?
end
def self.no_job_assignment_for?(job_id)
where(job_id: job_id).empty?
end
end
|
class SuggestionsController < ApplicationController
before_filter :authenticate_user!, :except => ["rss"]
before_filter :authenticate_admin!, :except => ["show", "create", "rss"]
# GET /suggestions
# GET /suggestions.json
def index
@suggestions = Suggestion.all
respond_to do |format|
format.ht... |
require 'integration_spec_helper'
describe 'CompraMedicamentosRepository' do
let(:plan) do
plan = Plan.new(nombre: 'Neo',
costo: 1000,
cobertura_visitas: CoberturaVisita.new(0, 0),
cobertura_medicamentos: CoberturaMedicamentos.new(0),
... |
class CreateLocations < ActiveRecord::Migration
def self.up
execute "CREATE TABLE locations ( id integer NOT NULL AUTO_INCREMENT PRIMARY KEY,
country_cd varchar(3) NOT NULL,
state_cd varchar(5) NOT NULL,
... |
class Chat < ApplicationRecord
# ユーザーが発言した内容を保存するテーブル
belongs_to :user
belongs_to :room
end
|
require 'rails_helper'
RSpec.describe User, type: :model do
let(:user) { FactoryBot.create(:user) }
it 'has a valid factory' do
expect(user).to be_valid
end
describe 'validations' do
it { should validate_presence_of(:username) }
it { should validate_length_of(:username).is_at_least(5) }
it { ... |
class RenameWorkspacesToViews < ActiveRecord::Migration[5.0]
def change
rename_table :workspaces, :views
end
end
|
class EventsController < ApplicationController
#This method will display all the events for the current month.
def index
time_range = Date.civil(Time.now.year,Time.now.month,1)..Date.civil(Time.now.year,Time.now.month,-1)
find_events(time_range)
end
def get_events_for_the_given_month
time_c... |
class PhonemesController < ApplicationController
before_action :set_phoneme, only: [:show, :edit, :update, :destroy]
# GET /phonemes
# GET /phonemes.json
def index
@phonemes = Phoneme.all
end
# GET /phonemes/1
# GET /phonemes/1.json
def show
end
# GET /phonemes/new
def new
@phoneme ... |
# encoding: utf-8
module Pakman
class Opts
def list=(value)
@list = value
end
def list?
return false if @list.nil? # default list flag is false
@list == true
end
def generate=(value)
@generate = value
end
def generate?
return false if @generate.nil? # default generate flag is... |
class DropApproversTable < ActiveRecord::Migration
def change
drop_table :approvers
end
end
|
class AddDateToOrders < ActiveRecord::Migration
def change
add_column :buy_orders, :purchase_date, :date
add_column :sell_orders, :sell_date, :date
add_column :sell_orders, :payment_check, :boolean, default:false
end
end
|
require_relative 'function.rb'
RSpec.describe StopTrolling do
describe "#disemvowel" do
it "responds to string removing vowels regardless of case ex1" do
statement = "This website is for losers LOL!"
stop_trolling = StopTrolling.new(statement)
expect(stop_trolling.disemvowel).to eq("Ths wbst s ... |
class Status < ActiveRecord::Base
attr_accessible :content, :user_id, :reported, :tag_list
acts_as_taggable
acts_as_votable
belongs_to :user
has_many :user_comments, :dependent => :destroy
validates_presence_of :content
validates_presence_of :tag_list
validate :must_exist_in_database
def tag_list
tags... |
# Helper Method
#require 'pry'
def position_taken?(board, index)
!(board[index].nil? || board[index] == " ")
end
# Define your WIN_COMBINATIONS constant
WIN_COMBINATIONS = [
[0,1,2], # Top row
[3,4,5], # Middle row
[6,7,8], # Bottom row
[0,3,6], # Right column
[1,4,7], # Middle column
[2,5,... |
require 'rest-client'
# This module perform the Request using the rest-client gem.
module RequestManager
def self.request(request)
RestClient::Request.execute(method: request.method,
url: request.endpoint,
payload: request.body,
... |
require 'rails_helper'
RSpec.describe "product_groups/index", type: :view do
before(:each) do
assign(:product_groups, [
ProductGroup.create!(
:group_name => "Group Name"
),
ProductGroup.create!(
:group_name => "Group Name"
)
])
end
it "renders a list of product_gr... |
require 'liquid'
require 'date'
module TackleBox
module Email
class Template
module Tags
class Day < Liquid::Tag
def render(context)
::Date.today.strftime("%e").strip
end
end
end
end
end
end
Liquid::Template.register_tag('day', TackleBox::Email... |
class FormationsController < ApplicationController
def update
@talentist = Talentist.find(params[:talentist_id])
@formation = Formation.find(params[:id])
if @formation.update(params_formation)
respond_to do |format|
format.html { redirect_to talents_path }
format.js # <-- will rend... |
class Admin::BaseController < ApplicationController
before_action :check_admin
def check_admin
if !current_user.admin?
render file: "#{Rails.root}/public/404", layout: false, status: :not_found
end
end
end
|
module Zulu
class Keeper
include Celluloid::IO
include Celluloid::Logger
def tick(now=Time.now)
debug "Looking for topics at: #{now} (#{now.to_i})"
count = 0
Topic.happening(now).each do |topic_id|
topic = Topic.new(id: topic_id)
debug "Found topic: #{topic_id}"
... |
class Draftterm < ApplicationRecord
has_one :company
has_one :user
has_one :draftagreement
acts_as_commentable
enum status:[:open,:in_progres,:published]
end
|
class DeliveryAddress < ApplicationRecord
extend ActiveHash::Associations::ActiveRecordExtensions
belongs_to_active_hash :prefecture
belongs_to :user, optional: true
validates :first_name, presence: true
validates :last_name, presence: true
validates :first_name_kana, presence: true
validates :last_na... |
cask :v1 => 'yubikey-neo-manager' do
version '0.2.2'
sha256 '4ea699743fd90586ef48b9d906bd4ad109eedeaa11b58028431197bd8396897a'
url "https://developers.yubico.com/yubikey-neo-manager/Releases/yubikey-neo-manager-#{version}-mac.pkg"
homepage 'https://www.yubico.com/2014/04/yubikey-neo-manager-application/'
lic... |
class Post < ActiveRecord::Base
#associations
has_many :comments
belongs_to :author, class_name: 'User'
#validations
end
|
require 'rails_helper'
RSpec.describe ReviewsController, type: :controller do
let (:category) { create(:category) }
let (:system) { create(:system) }
let (:reviews) { create_list(:review, 3, category: category, system: system) }
let(:valid_attributes) do
{
content: "I'm writing review now!",
}
e... |
class Api::UserDishTagsController < ApplicationController
before_action :set_user_dish_tag, only: [:show, :update, :destroy]
# GET /user_dish_tags
def index
@user_dish_tags = UserDishTag.all
render json: @user_dish_tags
end
# GET /user_dish_tags/1
def show
render json: @user_dish_tag
end
... |
class NewPostForm
include Capybara::DSL
def visit_page
visit('/posts')
click_on('New Post')
self
end
def fill_in_with(params={})
fill_in('Body', with: params.fetch(:body, "Secret message"))
self
end
def submit
click_on('Create Message')
self
end
end
|
require 'rails_helper'
RSpec.describe Team, type: :model do
describe "validations" do
it "is valid with valid attributes" do
team = Team.create(name: "Brett's Team", owned: true)
expect(team.name).to eq("Brett's Team")
expect(team.owned).to eq(true)
expect(team).to be... |
require 'rails_helper'
RSpec.describe Cognito::SignUpUser do
describe '#call' do
let(:email) { 'user@crowncommercial.gov.uk' }
let(:password) { 'ValidPass123!' }
let(:password_confirmation) { 'ValidPass123!' }
let(:roles) { %i[buyer st_access] }
let(:aws_client) { instance_double(Aws::CognitoIde... |
class Blog
def initialize(text)
@text = text
end
def parse
tokens = tokenize
unique_tokens = tokens.uniq
count = unique_tokens.inject({}) do |count, token|
count[token] = tokens.select { |t| t == token }.count
count = count
end
end
def tokenize
@text.split(' ')
end
end
|
require 'spec_helper'
describe Label do
describe "attribute validations" do
before(:each) do
@label = build(:label)
@label.valid?.should == true
end
it "should require a name" do
@label.name = ""
@label.valid?.should == false
@label.errors[:name].first.should == "can't be b... |
class Api::V1::SpinClassesController < ApplicationController
def index
@spin_classes = SpinClass.all
render json: @spin_classes
end
def show
@spin_class = SpinClass.find(params[:id])
render json: @spin_class
end
def create
@spin_class = SpinClass.create(spin_class_params)
render json... |
class Book < ActiveRecord::Base
has_and_belongs_to_many :users
belongs_to :author
belongs_to :category
has_many :reviews
has_many :order_books, dependent: :destroy
has_many :orders, through: :order_books
validates :title, :description, :quantity, :price,
:category_id, :author_id, pres... |
# frozen_string_literal: true
require 'test_helper'
module Vedeu
describe 'Bindings' do
it { Vedeu.bound?(:_menu_bottom_).must_equal(true) }
it { Vedeu.bound?(:_menu_current_).must_equal(true) }
it { Vedeu.bound?(:_menu_deselect_).must_equal(true) }
it { Vedeu.bound?(:_menu_items_).must_equal(true)... |
# @author Kristian Mandrup
#
# Single role Write Api
# @note all write methods should operate on the data store via #store
#
module Trole::Api
module Write
# Set the role of the subject to a new role
# @param [Symbol] the role to set
# @return [true, false, Error] true if ok, false if not valid, Error o... |
#!/usr/bin/env rspec
require 'spec_helper'
require File.join(File.dirname(__FILE__), "../../", "agent", "iptables.rb")
describe "iptables agent" do
before do
agent_file = File.join([File.dirname(__FILE__), "../../agent/iptables.rb"])
@agent = MCollective::Test::LocalAgentTest.new("iptables", :agent_file => ... |
require 'bcrypt'
class User < ActiveRecord::Base
has_many :aspireUnivs
has_many :univs, through: :aspireUnivs
validates :email, uniqueness: true
validates :email, format: { with: /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i, on: :create }
validates :email, presence: true
validates :password_hash, confirm... |
require 'css_parser'
include CssParser
require 'plist'
module MotionAwesome
class Generator
def self.plist
File.join( File.dirname( __FILE__),
%w(.. .. resources fontawesome.plist) )
end
def self.gen_plist( css )
parser = CssParser::Parser.new
parser.load_file!( css )
... |
# frozen_string_literal: true
class CreateStatusUpdates < ActiveRecord::Migration[5.1]
def change
create_table :status_updates do |t|
t.belongs_to :author, index: true
t.text :text
t.integer :likes_count
t.integer :comments_count
t.string :image
t.timestamps
end
end
end... |
puts "Input an integer:"
puts "Type q to quit"
while true
number = gets.chomp
if number.eql? 'q'
exit(true)
end
number = number.to_i
if number % 2 == 0
puts "Even"
else
puts "Odd"
end
end
|
class PicsController < ApplicationController
before_action :authorize_user, only: [:new, :edit, :create, :update, :destroy]
def create
@organization = Organization.find(params[:organization_id])
@pic = Pic.new(pic_params)
if @pic.save
redirect_to @organization
else
@organizations = Org... |
class CreateFunctionEquipments < ActiveRecord::Migration
def change
create_table :function_equipments do |t|
t.integer :user_id
t.integer :book_event_id
t.boolean :dj
t.boolean :stage
t.boolean :mike_speaker
t.boolean :break_fast
t.boolean :lunch
t.boolean :tea_snack
... |
require "rails_helper"
feature 'Logout', js: true do
scenario 'success' do
user = create(:user)
login(user.email, user.password)
logout()
expect(page).to have_content "Até logo"
expect(current_path).to eq new_session_path
end
end
|
module Api
module V1
class GamesController < ApplicationController
skip_before_action :verify_authenticity_token
before_action :authenticate_request
def index
@questions = Question.all
if @questions
@questions = @questions.map { |e|
e.attributes.merge({:ans... |
class AddFactToPost < ActiveRecord::Migration[5.0]
def change
add_column :posts, :fact, :text
end
end
|
class UsersController < ApplicationController
require 'digest/sha1'
# http://railsforum.com/viewtopic.php?pid=45490 or use act_as_state_machine
# #TODO user edit / update #TODO user delete
load_and_authorize_resource
before_filter :login_required, :only => [:edit, :show, :index]
before_filter :load_u... |
class Massless_object #used for global forces, explosions and animations that do not interact with the game (although i did want a corpse to be around)
attr_reader :x, :y, :vx, :vy, :angle, :hitpoints, :size, :window
attr_accessor :rot_speed, :x, :y, :vx, :vy
def initialize( x, y, vx, vy, angle, rot_speed, win... |
require "date"
require_relative "calendar"
require_relative "reservation"
require_relative "block"
require_relative "full_room"
module Hotel
class RoomReservation
Room = Struct.new(:id, :cost, :block_reserved)
attr_reader :rooms
attr_accessor :reservations, :blocks
def initialize
@rooms = pop... |
#
# Cookbook Name:: lamp
# Attribute:: default
#
# Copyright (C) 2013 Takahito Nakano
#
# 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
#
# Un... |
#!/usr/bin/env ruby
# Mainly based in capistrano's capify
require 'optparse'
require 'fileutils'
OptionParser.new do |opts|
opts.banner = "Usage: #{File.basename($0)} [path]"
opts.on("-h", "--help", "Displays this help info") do
puts opts
exit 0
end
begin
opts.parse!(ARGV)
rescue OptionParser:... |
Then(/^I verify that "([^"]*)" category title is displayed on View Sector page$/) do |category_title|
sleep 2
fail(ArgumentError.new("'#{@mainpage.getCategoryTitle(category_title)}' category title is not displayed.")) unless
has_xpath?(".//div[@id='view_sector_widget_fresh']//div[contains(@class,'category-headi... |
module Paramable
module InstanceMethods
def to_param
name.downcase.gsub(' ', '-')
end
end
endmodule MetaDancing
def metadata
"This class produces objects that love to dance."
end
end |
include ActionDispatch::TestProcess
FactoryGirl.define do
factory :post do
authors { FactoryGirl.build_list(:user, 1) }
title { Random.paper_title }
content { Random.paragraphs(4) }
post_image { fixture_file_upload(Rails.root.join('spec', 'images', 'cover_image.jpeg'), "image/jpeg") }
published_at... |
class WordSearchTest < ActiveRecord::Base
belongs_to :user
belongs_to :content
attr_accessor :word
def pick_a_word!
words = content.body.split(/\b/).select {|w| w =~ /\w/}
@word = words[rand(words.size)].downcase
end
class << self
def setup_for(test_taker)
res = new(
:user => te... |
require 'rails_helper'
RSpec.describe Like, type: :model do
before do
user = FactoryBot.create(:user)
cat = FactoryBot.create(:cat)
@photo = FactoryBot.create(:photo, user_id: user.id, cat_ids: cat.id)
@like = FactoryBot.create(:like, photo: @photo)
sleep(1) # Mysql2エラー防止
end
describe 'いいね... |
require "includes"
class AudioUtilsTest < Minitest::Test
def test_composite
assert_raises(ArgumentError) { AudioUtils.composite([[100, 200], [300, 400], [500, 600]], 0, 5) }
assert_raises(ArgumentError) { AudioUtils.composite([[100, 200], [300, 400], [500, 600]], -1, 5) }
# Mono empty arrays
assert_... |
class OrganizationCommissionOthersController < ApplicationController
before_action :set_model_class
before_action :set_organization_commission_other, only: [:show, :edit, :update, :approve,
:finance_check, :set_user, :update_user]
before_action :set_organization_charge_oth... |
class GroupsController < ApplicationController
include Response
include ExceptionHandler
before_action :set_group, only: [:show, :update, :destroy]
def index
if params[:user_id]
@groups = Group.joins(:users).where('user_id = ?', params[:user_id])
else
@groups = Group.all
... |
class RsvpqsController < ApplicationController
before_action :set_rsvp, only: [:show, :update]
# before_action :authenticate_user!
layout :resolve_layout
# GET /rsvps/1
def show
# :update
end
# POST /rsvps
def create
if current_user
@rsvp = current_user.rsvpqs.build(rsvpq_params)
#at... |
class RenameCourseDescriptionToDescription < ActiveRecord::Migration
def change
remove_column :courses, :course_description
add_column :courses, :description, :text
end
end
|
# frozen_string_literal: true
# Be sure to restart your server when you modify this file.
# Version of your assets, change this if you want to expire all your assets.
Rails.application.config.assets.version = '1.0'
# Add additional assets to the asset load path
# Rails.application.config.assets.paths << Emoji.images... |
module WebiniusCms
class List < ApplicationRecord
has_many :list_items, class_name: 'WebiniusCms::ListItem', foreign_key: :webinius_cms_list_id
belongs_to :page, class_name: 'WebiniusCms::Page', foreign_key: :webinius_cms_page_id
validates :name, uniqueness: true
end
end
|
require 'rails_helper'
describe 'Merge Reporting Relationship Requests', type: :request do
let(:department) { create :department }
let!(:user) { create :user, department: department }
before do
sign_in user
end
describe 'POST#create' do
let(:other_user) { user }
let(:phone_number) { '+141555555... |
module HomeWatcher
def self.root
File.expand_path('..', File.dirname(__FILE__))
end
def self.configure(&block)
yield(config)
end
def self.config
@config ||= Config.new
end
end
require "logger"
require "fileutils"
require 'lib/home_watcher/config'
|
require 'rails_helper'
RSpec.describe "investments/show", type: :view do
before(:each) do
@investment = assign(:investment, Investment.create!(
:investor_id => 1,
:forecast_id => 2,
:amount_cents => 3,
:dividend_rate => "9.99"
))
end
it "renders attributes in <p>" do
render
... |
class Like < ApplicationRecord
belongs_to :tweeet
belongs_to :user
end
|
class Job < ApplicationRecord
validates :title, :location, :description, presence: true
belongs_to :company
belongs_to :category
def expired?
created_at < 90.days.ago
end
end
|
class StatusLabels::ShowSerializer < ApplicationSerializer
object_as :status_label
identifier :slug
attributes(
:id,
:slug,
:name,
:status_type,
:description,
:created_at,
:updated_at,
)
end
|
lib = File.expand_path("../lib", __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "fog/brkt/version"
Gem::Specification.new do |spec|
spec.name = "fog-brkt"
spec.version = Fog::Brkt::VERSION
spec.authors = ["Maksim Zhylinski", "Berndt Jung"]
spec.email = ["... |
class User < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :validatable
has_one :ledger, dependent: :destroy
encrypts :pri... |
# frozen_string_literal: true
require 'bundler'
module Boring
module Ahoy
class InstallGenerator < Rails::Generators::Base
desc "Adds Ahoy to the application"
source_root File.expand_path("templates", __dir__)
def add_twitter_omniauth_gem
say "Adding Ahoy gem", :green
Bundler.... |
class IneSession < Mechanize
def initialize
super
get("http://www.ine.es/censo/es/inicio.jsp")
end
def population_page(city)
page(city, :_IDIOMA => "ES",
:c => "GRUPO_Q_EDAD",
:k => "MDDB.COLECTIVO_P1M",
:m => "SPERSONAS",
:r => "DISTRI... |
# -*- coding: utf-8 -*-
require 'spec_helper'
describe :string_utils do
describe 'utf8_roundtrip' do
context 'turn encode to utf-8' do
it 'utf-8 turns utf-8' do
str = 'Ruby1.8をつかっている人はもういない'
expect(str.utf8_roundtrip).to eq('Ruby1.8をつかっている人はもういない')
end
it 'euc-jp turns utf-8' ... |
class CreateBlogPost < ActiveRecord::Migration[5.2]
def change
create_table :blog_posts do |t|
t.integer :user_id
t.string :slug
t.string :title
t.boolean :published
t.datetime :published_at
t.string :markup_lang
t.text :raw_content
t.text :html_... |
require 'test_helper'
class PagesControllerTest < ActionDispatch::IntegrationTest
include Warden::Test::Helpers
def setup
@user = users(:shinji)
@followee = users(:chikuwa)
@not_followee = users(:emiya)
end
test 'should get home' do
get pages_home_url
assert_response :success
end
tes... |
# frozen_string_literal: true
module StatisticCalcs
module HypothesisTest
class Cases
CASE_1 = 1 # unilateral right
CASE_2 = 2 # unilateral left
CASE_3 = 3 # bilateral
end
end
end
|
require 'authentication'
module V1
class SubscribeLogic
extend Authentication
class << self
# circle channel is like /v1/circles/:id/messages
# person channel is like /v1/users/:id/messages
def incoming(faye_message)
return unless user = authenticate_user(faye_message)
un... |
=begin
#==============================================================================
** Parallel Pages
Author: Hime
Date: Apr 16, 2014
------------------------------------------------------------------------------
** Change log
Apr 16, 2014
- fixed conflicting name issue between Custom Page Conditions
Jul 30... |
{{ruby_copyright}}
module {{ project_name | underscore | camelize }}
class Foo
attr_reader :value
def initialize(value)
@value = value
end
end
end
|
class Score < ActiveRecord::Base
attr_accessible :workout_id, :score
belongs_to :workout
belongs_to :user
def to_parsed_score
if self.score =~ /#\d{1,}/
self.score.match('#\d{1,}')[0].gsub!('#', '')
else
self.score
end
end
end
|
# coding: utf-8
# plist.rb
# from http://www2a.biglobe.ne.jp/seki/ruby/plist.html
require 'rexml/document'
require 'time'
class Plist
def self.file_to_plist(fname)
File.open(fname) do |fp|
doc = REXML::Document.new(fp)
return self.new.visit(REXML::XPath.match(doc, '/plist/')[0])
end
end
... |
require 'spec_helper'
describe Shoulda::Matchers::ActiveModel::Callbacks do
ActiveRecord::Base::CALLBACKS.each do |callback_name|
context 'class with callbacks' do
subject{ ClassWithCallbacks }
it{ should send("have_#{callback_name}_callback_on", :method_to_call) }
end
context 'class with c... |
class Message < ApplicationRecord
belongs_to :user
belongs_to :channel
has_many :likes
def username
user.username
end
def username=(username)
self.user = User.find_or_create_by(username: username)
end
def like_count
likes.size
end
end
|
require 'rails_helper'
RSpec.describe 'Sendees API', type: :request do
let(:my_user) { User.create(staff_id_mb: 100000315, first_name: 'Erin', last_name: 'Coffey', email: 'erin@email.com', password: 'abc123', password_confirmation: 'abc123')}
let(:my_group) { Group.create(name: 'Yoga') }
startdatetime = Fake... |
require 'pry'
# Create a new class. This groups all our methods relating to nucleotides neatly, ensures the methods attached to this class will not conflict with other similarly named methods (eg 'valid?' 'counts', which are pretty generic), and embraces object oriented programming.
# We will create new instances of ... |
class LoadCsvWorker
include Sidekiq::Worker
def perform(physical_file)
@file = PhysicalFile.find(physical_file)
CsvImporterService.new(@file).import_file
end
end |
shared_context :routes do
include Rails.application.routes.url_helpers
let(:host) { "example.org" }
end
|
class Regexp
class << self
def email
/^([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})$/i
end
end
end |
class CreateEventChanges < ActiveRecord::Migration
def change
create_table :event_changes do |t|
t.belongs_to :event, index: true, foreign_key: true
t.belongs_to :order, index: true, foreign_key: true
t.datetime :old_start
t.datetime :old_stop
t.datetime :new_start
t.datetime :... |
json.array!(@downloads) do |download|
json.extract! download, :id, :title, :parent_path, :file_extension, :url
json.url download_url(download, format: :json)
end
|
class ModelsController < ApplicationController
def index
@models = Model.order(:id)
end
def train
model = Model.find(params[:id])
Thread.new { model.handler.train }
redirect_to action: 'index', notice: ('training model ' + model.klass)
end
def reset
model = Model.find(params[:id])
... |
require_relative '../app'
require 'capybara/rspec'
require 'capybara/poltergeist'
Sinatra::Application.set :logging, false
Capybara.app = Sinatra::Application
Capybara.default_max_wait_time = 1
# This is used for debugging: page.driver.debug
$console_output = StringIO.new
Capybara.register_driver :poltergeist_debug... |
# == Schema Information
#
# Table name: boards
#
# id :integer not null, primary key
# board_type_id :integer
# registration_key :string(255)
# created_at :datetime not null
# updated_at :datetime not null
#
class Board < ActiveRecord::Base
attr_accessor :n... |
# frozen_string_literal: true
module Sodor
class Line
class Set
extend Forwardable
def_delegators(:@lines, :add, :include?, :reject, :tap, :map, :classify, :to_a)
def initialize(lines = SortedSet[])
@lines = SortedSet.new(lines)
end
end
end
end
|
class Student
attr_accessor :name, :grade
attr_reader :id
def initialize (name, grade, id = nil)
@name = name
@grade = grade
@id = id
end
def self._table
sql = <<-SQL
TABLE IF NOT EXISTS students (
id INTEGER PRIMARY KEY,
name TEXT,
grade TEXT
)
SQ... |
# frozen_string_literal: true
module GeoPattern
module StructureGenerators
class BaseGenerator
include Roles::NamedGenerator
private
attr_reader :svg, :seed, :fill_color_dark, :fill_color_light, :stroke_color, :stroke_opacity, :opacity_min, :opacity_max, :preset
attr_accessor :height, :... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.