text stringlengths 10 2.61M |
|---|
class CreateAttributeValues < ActiveRecord::Migration[5.1]
def change
create_table :attribute_values do |t|
t.string :str_attribute_value
t.integer :int_attribute_value
t.boolean :bool_attribute_value
t.timestamps
t.belongs_to :attribute, index: true
t.belongs_to :sheet, index: true
end
... |
class CreateMarketCoinStreams < ActiveRecord::Migration[5.1]
def change
create_table :market_coin_streams do |t|
t.datetime :last_broadcast_at
t.belongs_to :market_coin
t.timestamps
end
end
end
|
class InterestListWork < ApplicationRecord
belongs_to :interest_list
belongs_to :work
end
|
# Example of [Virtual File System](index.html) working with SFTP.
#
# This is exactly the same [basic example](basics.html) but this time
# we using SFTP as storage instead of local file system.
# Adding examples folder to load paths.
$LOAD_PATH << File.expand_path("#{__FILE__}/../..")
# Connecting to SFTP and prepar... |
require 'pry'
=begin
# Short Long Short
# Write a method that takes two strings as arguments, determines the longer of the two
# return a concatenated short + long + short, can assume strings are different lengths
P:roblem
write a method
takes two arguments
and determines longer of the two
return a concate... |
class DashboardController < ApplicationController
layout 'dashboard'
def index
@promotion = Promotion.where(['start_date <= :date AND stop_date >= :date', date: Date.current]).first
if session[:social_share].nil?
session[:social_share] = true
end
end
end
|
class MeetupClient
def initialize(oauth_token)
@oauth_token = oauth_token
end
def get_user_email
get_profile_info['email']
end
def get_profile_info
res = RestClient.post(
"https://api.meetup.com/gql",
{query: ' query { self { id name email memberships { edges { node { name urlname } ... |
# @since 0.1.0
module Ars
# @since 0.1.0
module AttachedConfig
def self.included(subclass)
subclass.ns.extend(ExtendedMethods)
subclass.ns.define_singleton_method(:configuration) do
@configuration ||= subclass.new
end
end
module ExtendedMethods
# @since 0.1.0
att... |
class CreateDingUsers < ActiveRecord::Migration
def change
create_table :ding_users do |t|
t.references :user, index: true, foreign_key: true
t.string :userid
t.string :unionid
t.string :mobile
t.string :tel
t.string :workPlace
t.string :remark
t.bigint :order
... |
class CreateEntries < ActiveRecord::Migration
def self.up
create_table :entries do |t|
t.references :user, :null => false
t.string :name
t.string :grains
t.boolean :autolyse
t.boolean :pre_ferment
t.decimal :hydration, :precision => 3, :scale => 2
t.timestamps
end
... |
# frozen_string_literal: true
class EmployeeScheduleSeeds
def initialize(db)
@db = db
@employee_ids = @db["SELECT * FROM Staff.Employees"].to_a.map { |employee| employee[:id] }
end
def run
@employee_ids.each do |employee_id|
create_schedule(employee_id)
end
end
def create_schedule(emp... |
describe Bullock::Parse::FirstSet do
let(:x_Y) do
symbol = Bullock::Parse::Symbol.new('Y')
Bullock::Parse::ExtendedSymbol.new(0, symbol, 1)
end
let(:x_Z) do
symbol = Bullock::Parse::Symbol.new('Z')
Bullock::Parse::ExtendedSymbol.new(0, symbol, 1)
end
let(:x_a) do
symbol = Bullock::Parse:... |
module Hand
def show_hand
puts "---- #{name}'s Hand ----"
cards.each do |card|
puts "=> #{card}"
end
puts "=> Total: #{hand_total}"
puts ""
end
def hand_total
total = 0
cards.each do |card|
if card.ace?
total += 11
elsif card.jack? || card.queen? || card.king... |
class V1::CartItemsController < V1::ApiController
before_action :set_cart_item, only: [:update, :destroy]
def index
if user_signed_in?
@cart_items = CartItem.where(user_id: @current_user.id)
else
if cookies.encrypted[:cart_tracker] == nil
@cart_items = []
else
@cart_items ... |
class AddAssignmentsCountToAppointments < ActiveRecord::Migration
def up
add_column :appointments, :assignments_count, :integer, :default => 0
Appointment.reset_column_information
Appointment.all.each do |a|
Appointment.reset_counters(a.id, :assignments)
end
end
def down
remove_c... |
class Api::UserproductsController < ApplicationController
# GET /userproducts/1
def show
@products = Product.where("user_id = ?", params[:id])
render json: @products
end
end
|
# == Schema Information
#
# Table name: plannings
#
# id :bigint not null, primary key
# structure_id :bigint
# status :string
# user_id :bigint
# created_at :datetime not null
# updated_at :datetime not null
#
class Planning < ApplicationRecord
belongs_to :st... |
require 'spec_helper'
describe DataValue do
describe "constraints" do
context "One association allowed - either a min value, a max value, an allowed value, or a data value for a datum" do
it "should raise exception if another association is added" do
datum = create(:datum, data_dictionary: create(:... |
require "Day4"
RSpec.describe Day4 do
let(:start_range) { 367479 }
let(:end_range) { 893698 }
subject { described_class.new(start_range, end_range) }
describe "#check_increasing" do
it "passes" do
expect(subject.check_increasing(12345)).to be_truthy
end
it "passes on same" do
expect... |
require 'acceptance_helper'
feature 'user logout', '
In order to leave system
As logged in user
I want to be able to logout
' do
given(:user) { create(:user) }
scenario 'logged in user logging out' do
sign_in(user)
click_on 'Sign out'
expect(page).to have_content('You need to sign in or sign u... |
class MoviesAddDirector < ActiveRecord::Migration
def change
add_column("movies", "director", "string")
end
end
|
class RemoveSaveS3BucketFromFirstSetup < ActiveRecord::Migration
def change
remove_column :first_setups, :save_s3_bucket, :string
end
end
|
class NewsController < ApplicationController
before_action :authenticate_user!, except: [:index, :show]
def index
@news = News.all
end
def show
@news = News.find(params[:id])
end
def new
end
def create
@news = News.new(news_params)
if @news.images == nil
@news.images = ... |
class AddFieldsToVendors < ActiveRecord::Migration
def change
add_column :vendors, :business_name, :string
add_column :vendors, :biography, :string
add_column :vendors, :cost, :float
add_column :vendors, :average_cost, :float
add_column :vendors, :accept_credit_card, :string
add_column :v... |
class PetsController < ApplicationController
def index
@pets = Pet.all
end
def new
@shelter = Shelter.find(params[:id])
end
def create
@shelter = Shelter.find(params[:id])
@pet = @shelter.pets.create!(pet_params)
redirect_to "/shelters/#{@shelter.id}/pets"
end
# def create
# s... |
class OmniauthAuthenticator
class << self
def create_authentication(storage_object, auth_hash)
storage_object.create do |c|
c.provider = auth_hash.provider
c.uid = auth_hash.uid.to_s
c.token = auth_hash.credentials.token
c.secret = auth_hash.credentials.secret
... |
require 'pp'
require 'rmagick'
require 'chunky_png'
require 'AnimeFace'
require_relative './image'
require_relative './otaku_generator'
class Collage < Image
def initialize(otaku_gen, img, faces)
@otaku_gen = otaku_gen
@img = img # ChunkyPNG::Image
@faces = faces
end
def fus... |
class AddFacebookAndTwitterToMicrocosm < ActiveRecord::Migration[5.1]
def change
add_column :microcosms, :facebook, :string
add_column :microcosms, :twitter, :string
end
end
|
class Aadgadmin::GalleriesController < Aadgadmin::AadgController
before_filter :find_dimension
def index
if @dimension
@galleries = @dimension.galleries
else
@galleries = @holder_url.galleries
end
end
def show
if @dimension
@gallery = @dimension.galleries.find(params[... |
class ChangeAmountTypeInOpportunities < ActiveRecord::Migration
def change
change_column :opportunities, :amount, :string
end
end
|
class ChangeProjects < ActiveRecord::Migration
change_table :projects do |t|
t.remove :construction_requirement, :test_run_requirement, :test_run_date, :turn_over_date
t.date :design_start_date
end
end
|
require "spec_helper"
describe HighriseEndpoint::Application do
pending "| POST -> '/add_order'" do
context "with an existing order" do
before(:each) do
VCR.use_cassette(:add_existing_deal) do
@existing_order = HighriseEndpoint::Requests.new(:order, "existing").to_hash
set_highr... |
ActiveAdmin.register Supplier do
menu priority: 4
permit_params :name, :domain, :description
index do
selectable_column
column :name
column :domain
column :created_at
column :updated_at
actions
end
end
|
# ruby -r "./scheme_automation/web_scheme_discovery.rb" -e "WebSchemeDiscovery.new.execute()"
require 'mechanize'
require 'webdrivers'
require 'rubygems'
require 'fileutils'
require 'nokogiri'
require 'open-uri'
class WebSchemeDiscovery
def initialize
@arr = []
@meta_tags = [
'meta[name="branch:deepl... |
class Tribunal < ActiveRecord::Base
validates :name, :code, presence: true, uniqueness: true
has_and_belongs_to_many :users
end
|
namespace :lastfm do
task :artists => :environment do
require 'open-uri'
lastfm = YAML.load_file Rails.root.join('config', 'lastfm.yml')
artists = ActiveSupport::JSON.decode(open("#{lastfm["api_url"]}?method=user.gettopartists&user=#{lastfm["user"]}&api_key=#{lastfm["api_key"]}&period=3month&format=json")... |
module Chronic
class Handler
# tokens - An Array of tokens to process.
# token_index - Index from which token to start matching from.
# pattern - An Array of patterns to check against. (eg. [ScalarDay, [SeparatorSpace, SeparatorDash, nil], MonthName])
#
# Returns true if a match is found.
def ... |
module Spektrix
module Events
# An event instance.
class Instance
include Spektrix::Base
collection_path "instances"
after_find ->(r) do
# parse times
[:start,
:start_utc,
:start_selling_at,
:start_selling_at_utc,
:stop_selling_at,
... |
class ChangeAlbumBandUniqueness < ActiveRecord::Migration[5.1]
def change
remove_index :albums, name: "index_albums_on_band_id"
add_index :albums, :band_id
end
end
|
require 'pry'
# ActiveRecord::Base.logger = Logger.new(STDOUT)
ActiveRecord::Base.establish_connection(
:adapter => "postgresql",
:host =>"localhost",
:database => "battleship_db"
)
def reset_tables
ActiveRecord::Base.connection.tables.each do |table|
ActiveRecord::Base.connection.drop_table(table)
e... |
class LeaveRequest < ActiveRecord::Base
has_paper_trail
acts_as_paranoid
# allow can_xxx?(user) based auth checks ( a role your own cancan )
include RoleBasedResource
# Handle links to other resources
belongs_to :user
has_one :leave_request_extra, :dependent=>:destroy
has_one :travel_request
accepts... |
class BasicDialogPage
include PageObject
page_url "file://#{File.expand_path(File.dirname(__FILE__) + '/../../html/basic_dialog.html')}"
jqueryui_basic_dialog(:the_dialog, :class => 'ui-dialog')
end
|
# version.rb
module Ruby2D
VERSION = '0.2.0'
end
|
require 'pastel'
require 'tty-font'
require_relative 'methods/steg_methods'
def print_help
font = TTY::Font.new(:standard)
pastel = Pastel.new
puts pastel.cyan(font.write("HELP"))
puts "COMMAND LINE ARGUMENTS"
puts "\nCOMMAND: -h"
puts "COMMAND: --help"
puts "Takes you to straight to this... |
#!/usr/bin/env ruby
# frozen_string_literal: true
# Released under the MIT License.
# Copyright, 2020-2022, by Samuel Williams.
require 'benchmark/ips'
require 'fiber'
# GC.disable
puts RUBY_VERSION
class Fiber
attr_accessor :my_local
end
class MyObject
attr_accessor :my_local
end
Benchmark.ips do |benchmark|
... |
execute "clone dotphiles" do
command "git clone --recursive https://github.com/cobyrne/dotphiles.git ~/.dotfiles"
user WS_USER
not_if { File.exist? "/Users/cobyrne/.dotfiles" }
end
execute "update dotphiles" do
command "cd ~/.dotfiles && git pull"
user WS_USER
end
execute "use dotphiles" do
command "~/.do... |
# Author:: Joseph Bauser (mailto:coderjoe@coderjoe.net)
# Copyright:: Copyright (c) 2010 Joseph Bauser
# License:: See LICENSE file
module YahooGeo
# Error
# The base error type
#
# All errors should store the code and message for the HTTP response they
# represent.
class Error < RuntimeError;
at... |
# frozen_string_literal: true
module RubotHandlers::Create
def self.handle(payload)
"created #{payload['ref_type']} **#{payload['ref']}**"
end
end |
class LeagueDraftPicksDecorator < LeagueDecorator
def all_draft_picks
draft_picks.order(:pick_number).includes(:player, :fpl_team, player: [:team, :position]).pluck_to_hash(
:id,
:pick_number,
:fpl_team_id,
'fpl_teams.name as fpl_team_name',
:player_id,
:position_id,
:sin... |
require 'open-uri'
require 'hpricot'
class Schneier < CampfireBot::Plugin
BASE_URL = 'http://geekz.co.uk/schneierfacts/'
on_command 'schneier', :schneier
def schneier(msg)
quote = case msg[:message].split(/\s+/)[0]
when 'latest'
fetch_quote(true)
when 'random'
fetch_quote
else... |
#initializers/carrierwave.rb
require 'serve_gridfs_image'
CarrierWave.configure do |config|
config.storage = :grid_fs
config.grid_fs_connection = Mongoid.database
# Storage access url
config.grid_fs_access_url = "/grid"
end
|
# frozen_string_literal: true
require_relative '../lib/rmk.rb'
class PlanMock
def md5
'md5'
end
def build_dir
'/tmp/rmk'
end
def dir
'/tmp/rmk'
end
end
PLAN = PlanMock.new
describe Rmk::Job do
around(:each) do |example|
EventMachine.run do
Fiber.new do
example.run
... |
require 'app/models/guild'
require 'miniskirt'
require 'ffaker'
Factory.define :guild do |f|
f.name { "#{Faker::AddressUS.state} Brewer's Guild" }
f.description { Faker::Lorem.paragraph }
f.website { Faker::Internet.uri(:http) }
f.established { rand(1943..Date.today.year) }
f.brewerydb_id { S... |
require 'configatron'
module Databender
class Config
class << self
def load!(db_name, config_path = 'config/database.yml')
db_yml = config_path
db_config = YAML::load(IO.read(db_yml))
filter_config = YAML::load(IO.read("config/filters/#{db_name}.yml"))
configatron.configure... |
# -*- coding: utf-8 -*-
require 'rubygems'
require 'sinatra'
require 'rdf'
require 'rdf/rdfxml'
require 'json'
require './../olap_etl/util.rb'
@geonames
@layers
PARENT_FEATURE = "http://www.geonames.org/ontology#parentFeature"
GEONAMES_NAME = "http://www.geonames.org/ontology#name"
get '/' do
'/:id に GeoNames の I... |
class Profile < ActiveRecord::Base
belongs_to :user
validates :zip_code, numericality: { only_integer: true }, allow_blank: true, length: { is: 5 }
validates :phone_number, format: { with: /\A\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})\z/, message: "Please enter a valid phone number with area code."}, allow... |
module Collavoce
def self.stop
@running = false
end
def self.running
@running.nil? || @running
end
end
trap("INT") do
Collavoce.stop
end
|
module RpsRpg
class Quest
NOUN = ["Dragon", "Giant", "Orge", "Village", "Goblin Army", "Treasure",
"Nest", "Bees", "Giant Flower", "Princess", "King", "Sausage",
"Peasant", "Milk", "Steak", "Thief", "Murderer", "Werewolf", "Mayo",
"Little Girl", "Old Man", "Terrorist", "Vampi... |
class CreatePartWorkers < ActiveRecord::Migration
def change
create_table :part_workers do |t|
t.string :number_part
t.date :date_of_creation
t.integer :company_id
t.timestamps
end
end
end
|
class DistritosController < ApplicationController
before_action :set_distrito, only: [:show, :update, :destroy]
# GET /distritos
# GET /distritos.json
def index
@distritos = Distrito.all
render json: @distritos
end
# GET /distritos/1
# GET /distritos/1.json
def show
render json: @distrito... |
# frozen_string_literal: true
# test database connect
module JewelerTest
require 'erb'
require 'yaml'
# Configuration defaults
class Database
def self.environment
env = 'production'
env = 'development' if Dir.pwd.include?('Dropbox')
env = 'test' if ENV['ENVIRONMENT'] == 'test'
env... |
Rails.application.routes.draw do
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
resources :tvshows, only: [:index, :show, :create] do
resources :seasons, only: [:index, :show] do
resources :episodes, only: [:index, :show]
end
end
end
|
class RatingsController < ApplicationController
before_action :set_rating, only: [:show, :edit, :update, :destroy]
before_action :authenticate_user!
# GET /ratings
def index
@ratings = Rating.all
end
# GET /ratings/1
def show
end
# GET /ratings/new
def new
@rating = Rating.new
end
# ... |
class Post < ActiveRecord::Base
validates :title, presence: true
validates :content, length: { minimum: 250 }
validates :summary, length: { maximum: 250 }
validates :category, inclusion: { in: %w(Fiction Non-Fiction) }
validate :clickbait_title
def clickbait_title
clickbaits = ["Won't B... |
require 'csv_row_model/internal/concerns/column_shared'
module CsvRowModel
class AttributeBase
include ColumnShared
attr_reader :column_name, :row_model
def initialize(column_name, row_model)
@column_name = column_name
@row_model = row_model
end
def formatted_value
@formatted... |
class ConceptoPersona < ActiveRecord::Base
attr_accessible :concepto_pago_id, :persona_id, :puesto_id, :activo, :base, :factor, :cantidad, :cuenta_aplicacion, :limite_aplicacion, :monto, :beneficiario_id
validates_presence_of :concepto_pago_id, :persona_id, :message => "Este campo no puede quedar vacio."
belon... |
module Navigation
class Step < Direction
attr_reader :prev_step, :details, :next_step, :duration, :distance
def self.create(info)
new(info, nil)
end
def initialize(params, parent)
@prev_step = parent
@details = params
@duration = details[:duration]
@distance = details[:... |
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
Pod::Spec.new do |s|
s.name = "react-native-image-crop-picker"
s.version = package['version']
s.summary = package["description"]
s.requires_arc = true
s.license = 'MIT'
s.homepage = 'https://github.co... |
# Plase where all constant values should be stored
module ConstHelper
DEFAULT_PASSWORD = 'napoleon'
DEFAULT_PIN_CODE = '1111'
UserStruct = Struct.new(:gsm_number, :password, :pin_code, :username, :email)
AgentStruct = Struct.new(:gsm_number, :password, :pin_code, :username, :code, :email)
TOAST_FILL_FORM = ... |
require 'rails_helper'
describe "Model Types", :type => :feature do
describe "GET models/:model_slug/model_types" do
let(:organization) { Organization.create!(name: 'BMW', public_name: 'Flexible BMW', organization_type: "Show room", pricing_policy: "Flexible") }
let(:model) { organization.models.create!(nam... |
##
# Copyright 2017-2018 Bryan T. Meyers
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in w... |
class Card
attr_accessor :name, :values, :overall_comparison, :best_comparison
def initialize(line)
@overall_comparison = {w: 0, l: 0, e: 0}
@best_comparison = {w: 0, l: 0, e: 0}
@values = []
line.split(',').each_with_index do |value, index|
if index == 0
@name = value.strip
el... |
Rails.application.routes.draw do
# devise_for :members, class_name: "Api::V1::Member"
resources :publishing_houses
resources :authors
resources :books
use_doorkeeper
devise_for :members
# devise_for :members,skip: :all
# devise_for :users
namespace :api do
namespace :v1 do
resources :... |
module Errors
module Cell
class NotFound < Abroaders::Cell::Base
def title
'Page Not Found'
end
end
end
end
|
class FreeswitchEventSocket
DEFAULT_HOST = "127.0.0.1"
DEFAULT_PORT = 8021
DEFAULT_PASSWORD = "ClueCon"
DEFAULT_SOCKET_TIMEOUT = 20
@socket = nil
def auth(password)
self.command("auth #{password}")
result = self.result()
if result && result["Reply-Text"] == "+OK accepted"
return true
... |
if not @places.empty?
json.success true
json.set! :result do
json.set! :places do
json.array! (@places) do |place|
json.extract! place, :id, :category, :description, :name, :longitude, :latitude, :active, :ratio
end
end
end
else
json.success true
json.set! :result do
json.nil!... |
module LogMerge
class MergeCLI
def self.run(args)
files = []
output_filename = "./merged"
build_index = true
opts = OptionParser.new do |opts|
opts.on("-f", "--file FILE", "Files to merge") do |f|
file_struct = OpenStruct.new
file_struct.filename = f
... |
require 'rails_helper'
RSpec.describe FetchSlackUser do
subject { described_class }
let(:perform) { subject.call(slack_identifier: slack_identifier) }
let(:user) { build(:user) }
let(:slack_identifier) { user.slack_identifier }
before do
allow(User).to receive(:find_or_initialize_by).and_return(user)
... |
class ItemCategoriesController < ApplicationController
before_action :set_item_category, only: [:show, :update, :destroy]
before_action :authenticate_user, only: [:create, :update, :destroy]
def index
@item_categories = ItemCategory.all
paginate json: @item_categories
end
def show
render js... |
class ShoppingCart < ApplicationRecord
belongs_to :user, optional: true
belongs_to :product
validates :quantity, numericality: { greater_than_or_equal_to: 1 }, on: :create
def self.update_quantity(quantity, prd, type)
if type
prd.quantity -= quantity.to_i
else
prd.quantity += quantity.to_i... |
require 'spec_helper'
describe S3MPI::Interface do
let(:bucket) { 'some_bucket' }
let(:path) { 'some_folder' }
let(:interface) { described_class.new(bucket, path) }
describe '#bucket' do
subject { interface.bucket }
it { is_expected.to be_a Aws::S3::Bucket }
it { is_expected.to have_attributes(... |
require 'pry'
WINNING_LINES = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] +
[[1, 4, 7], [2, 5, 8], [3, 6, 9]] +
[[1, 5, 9], [3, 5, 7]]
INITIAL_MARKER = ' '
PLAYER_MARKER = 'X'
COMPUTER_MARKER = 'O'
FIRST_MOVE_DECIDER = 'choose'
PLAYER_MOVE = 'player'
COMPUTER_MOVE = 'computer'
def prompt(tex... |
# frozen_string_literal: true
class Problem4
TITLE = 'Largest palindrome product'
DESCRIPTION = 'A palindromic number reads the same both ways.'\
'The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99.'\
'Find the largest palindrome made from the prod... |
class CreateAddCommentToQuestions < ActiveRecord::Migration[5.2]
def change
add_column :questions, :comment, :text, null: false, default: ''
end
end
|
class ApplicationController < ActionController::API
rescue_from(ActionController::ParameterMissing) do |exception|
error = {}
error[exception.param] = exception.message
response = { errors: [error] }
render json: response, status: :unprocessable_entity
end
rescue_from(ActiveRecord::RecordInvalid)... |
require_relative "base"
module FuzzyClassnames
class Lexer
class Whitespace < Base
def applies?(token)
token == " "
end
def match?(string, pattern)
pattern.last? && string.last.end_with?(pattern.tokens[-2])
end
end
end
end
|
module TicTacToe
class Player
attr_reader :moves, :name
def initialize(name)
@name = name
@moves = []
end
def add_move(move)
@moves << move
end
def xs
@moves.map(&:x)
end
def ys
@moves.map(&:y)
end
end
end |
Rails.application.routes.draw do
ActiveAdmin.routes(self)
root to: "homepages#index"
resources :golden_horses
resources :oscars
resources :movies
resources :productors
resources :people
resources :distributors
resources :origins
resources :countries
# For details on the DSL available within this f... |
# == Schema Information
#
# Table name: events
#
# id :integer not null, primary key
# name :string(255) not null
# start_datetime :datetime not null
# end_datetime :datetime
# organization :string(255)
# website :string(255)
... |
require "minitest/autorun"
require_relative "../../src/diff"
class DiffTest < Minitest::Test
# sanity check test
def test_linesplit
str = "hello\nworld"
assert_equal ["hello\n", "world"], DiffUtils.linesplit(str)
assert_equal str.lines, DiffUtils.linesplit(str)
end
# spec test... |
require 'fileutils'
require 'erb'
class Delve
def initialize(name)
raise 'Cannot create a new roguelike without a name' unless name
@name = name
@renderers = [:curses]
@generators = [:noise, :rogue, :cellular]
@renderer = :curses
@generator = :rogue
@statements = {
:curses => {
... |
class StopCycleJob < ActiveJob::Base
queue_as :urgent
def perform(cycle_id)
cycle = Cycle.find(cycle_id)
Cycle::Stop.call(cycle)
end
end
|
require 'rails_helper'
RSpec.describe Event, type: :model do
let(:my_user){create(:user)}
let(:my_app){create(:registered_app, user: my_user)}
let!(:my_event){create(:event, registered_app: my_app)}
describe "tests for attributes" do
it "has correct a values" do
expect(my_event).to have_attri... |
module Relevance
module CoreExtensions
module TestCaseExtensions
def tarantula_crawl(integration_test, options = {})
url = options[:url] || "/"
t = tarantula_crawler(integration_test, options)
t.crawl url
end
def tarantula_crawler(integration_test, options = {})
... |
class AddingCategoryToLeaveTable < ActiveRecord::Migration[5.1]
def change
add_column :leave_applications, :category, :string
end
end
|
class AddTypeToStrategy < ActiveRecord::Migration
def change
add_column :strategies, :classification, :string
end
end
|
Gem::Specification.new do |s|
s.name = 'couchy'
s.version = '0.0.3'
s.date = '2008-10-07'
s.summary = 'Simple, no-frills, Ruby wrapper around the nice CouchDB HTTP API'
s.description = 'Simple, no-frills, Ruby wrapper around the nice CouchDB HTTP API'
s.homepage = 'http://github.com/sr/couchy'
s... |
class ApplicationController < ActionController::Base
include PublicActivity::StoreController
before_action :get_activities
before_action :authenticate_user!
before_action :is_name?
# enter admin should has role = admin
def authenticate_admin
unless current_user.admin?
flash[:alert] = "Not al... |
require "./lib/ims/ArtistRecord.rb"
require 'yaml/store'
class DJTable
def initialize(args = {})
@id_to_record = {}
@id_to_artist = {}
@id_to_track = {}
@played = []
end
attr_accessor :id_to_record
attr_accessor :id_to_artist
attr_accessor :id_to_track
attr_accessor :played
def info()
... |
require 'sinatra/base'
require 'bcrypt'
class Application < Sinatra::Application
enable :sessions
def initialize(app=nil)
super(app)
end
get '/' do
if session[:user_id]
user_id = session[:user_id]
user = DB[:users][:id => user_id]
email = user[:email]
else
email = nil
e... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.