text stringlengths 10 2.61M |
|---|
class Crossref < CrossrefAdapter
def as_json options = {}
{
title: title,
alt_title: alt_title,
abstract: abstract,
pubyear: pubyear,
keywords: keywords,
author: author,
publanguage: language,
sourcetitle: sourcetitle,
sourceissue: sourceissue,
sourcevol... |
class FontFirago < Formula
version "1.000"
sha256 "b2f97f1ee02921ca1776903fa0e6f1358b017bf854c0e8776b6b8512e3c9d4a1"
url "https://github.com/bBoxType/FiraGO/archive/#{version}.tar.gz", verified: "github.com/bBoxType/FiraGO/"
desc "FiraGO"
homepage "https://bboxtype.com/typefaces/FiraGO/"
def install
par... |
require File.dirname(__FILE__) + '/../test_helper'
class RequisicoesControllerTest < ActionController::TestCase
def test_should_get_index
get :index
assert_response :success
assert_not_nil assigns(:requisicoes)
end
def test_should_get_new
get :new
assert_response :success
end
def test_s... |
json.message do
json.name @message.user.name
json.image @message.image.url
json.created_at @message.created_at.to_s(:published_on)
json.text @message.text
end
|
class EnlargeBucketsLogColumn < ActiveRecord::Migration
def self.up
change_column :buckets, :log, :text, :limit => 20.megabytes
end
def self.down
change_column :buckets, :log, :text
end
end
|
# Allow not limited to doubles, can be used for real objects as well
RSpec.describe 'allow method review' do
it 'can customize return values for methods' do
calculator = double
allow(calculator).to receive(:add).and_return(10)
expect(calculator.add(1,2)).to eq(10)
end
it 'can stub one or more metho... |
class Song < ApplicationRecord
mount_uploader :audio, AudioUploader
has_and_belongs_to_many :albums
end
|
#Float class methods
=begin
%
*
+
-
/
<
>
-@
**
<=>
<=
>=
==
===
eql?
inspect
to_int
to_s
to_i
to_f
hash
coerce
divmod
fdiv
modulo
abs
magnitude
zero?
floor
ceil
round
truncate
positive?
negative?
quo
nan?
infinite?
finite?
next_float
prev_float
to_r
numerator
denominator
rationalize
arg
angle
phase
+@
singleton_meth... |
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe GrantsController do
def mock_grant(stubs={})
@mock_grant ||= mock_model(Grant, stubs)
end
describe "responding to GET index" do
it "should expose all grants as @grants" do
Grant.should_receive(:find).with(:all).and_r... |
require_relative 'base_page'
# Class contain locators and basic interaction with page
class LandingPage < BasePage
element :logo, '.header-logo.go-right'
element :navigate_tabs, "ul[class='nav row-reverse ']"
# menu
element :cars, '.text-center.transfer'
element :visa, '.text-center.visa'
elements :visa_di... |
class CreateFontindustries < ActiveRecord::Migration
def change
create_table :fontindustries do |t|
t.references :industry, index: true, foreign_key: true
t.references :font, index: true, foreign_key: true
t.timestamps null: false
end
end
end
|
require 'rails_helper'
RSpec.describe LocksController, type: :controller do
let(:stage) { create(:stage) }
let(:lock) { create(:lock, stage_id: stage.id) }
describe 'GET new' do
context 'when existing stage specified' do
before { get :new, stage_id: stage.id }
it { expect(assigns(:lock)).to be_... |
require "test/unit"
require "package-updater.rb"
include PackageUpdater
class TestSimple < Test::Unit::TestCase
def test_usable_version
assert(Updater.usable_version?('1'));
assert(Updater.usable_version?('4.5'));
assert(!Updater.usable_version?('4.5.'));
assert(!Updater.usable_version?('4..5'));
... |
class Country < ApplicationRecord
# Extensions
include GeoData
include Manageable
include HasClient
include ActivityMonitorable
nilify_blanks
searchable_columns %w[name country_code translations]
audited except: %i[summary_email_sent_at summary_metadata]
# Associations
has_many :regions, inverse_... |
require "spec_helper"
describe("choria") do
before(:each) do
Puppet::Parser::Functions.newfunction(:assert_private, :type => :rvalue) {|_| }
end
let(:facts) do
{
"aio_agent_version" => "1.7.0",
"os" => {
"family" => "RedHat"
}
}
end
it { should compile.with_all_deps }
... |
class FontSimonetta < Formula
head "https://github.com/google/fonts.git", verified: "github.com/google/fonts", branch: "main", only_path: "ofl/simonetta"
desc "Simonetta"
homepage "https://fonts.google.com/specimen/Simonetta"
def install
(share/"fonts").install "Simonetta-Black.ttf"
(share/"fonts").inst... |
require_relative "board.rb"
require_relative "pawn.rb"
require_relative "queen.rb"
require_relative "rook.rb"
require_relative "bishop.rb"
require_relative "knight.rb"
require_relative "king.rb"
class Display
def initialize(board)
@board = board
end
def render
p ' 0 1 2 3 4 5 6 7'
... |
# == Schema Information
#
# Table name: questions
#
# id :integer not null, primary key
# text :text not null
# poll_id :integer
# created_at :datetime not null
# updated_at :datetime not null
#
class Question < ApplicationRecord
belongs_to :poll,
prima... |
require 'pry'
class PigLatinizer
def piglatinize(word)
start = word.slice(/^[^aeiouAEIOU]+/).to_s
new_word = word[start.length,word.length] + start
if start == ""
return new_word + "way"
else
return new_word + "ay"
end
binding.pry
end
def to_pig_latin(sentence)
sentence.split(' ').map { |e| sel... |
class Membership < ApplicationRecord
belongs_to :user
belongs_to :team
belongs_to :creator, class_name: 'User'
validates :user, uniqueness: { scope: :team }
def invited_by_leader!
self.invited_by_leader = true
end
def permissions
@permissions ||= ::Permissions.new(self[:permissions])
end
... |
# frozen_string_literal: true
shared_examples "it has a coerced attr_accessor" do |attribute, klass|
describe "##{attribute} attr_accessor" do
subject(:coerced_attribute_subject) { described_class.new }
context "when passing in a #{klass.name}" do
before { coerced_attribute_subject.public_send "#{attr... |
#Fedena
#Copyright 2011 Foradian Technologies Private Limited
#
#This product includes software developed at
#Project Fedena - http://www.projectfedena.org/
#
#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 ... |
require "heroku/command/base"
# manage dynos (dynos, workers)
#
class Heroku::Command::Ps < Heroku::Command::Base
PRICES = {
"P" => 0.8,
"PX" => 0.8,
}
# ps:dynos [QTY]
#
# DEPRECATED: use `heroku ps:scale dynos=N`
#
# scale to QTY web processes
#
# if QTY is not specified, display the numb... |
class Football
include Mongoid::Document
include Mongoid::Timestamps
field :player, type: String
field :team, type: String
field :status, type: String
field :player_url, type: String
validates :player, presence: true
validates :team, presence: true
validates :status, presence: true
validates :... |
class AddSuggestionsToSupplier < ActiveRecord::Migration
def change
add_column :suppliers, :suggested_description, :text
add_column :suppliers, :suggested_machines, :text
end
end
|
require 'rails_helper'
describe User do
before do
@user = FactoryBot.build(:user)
end
describe 'ユーザー新規登録' do
context '新規登録が正しくできるとき' do
it 'nickname、first_name、last_name、first_name_kana、last_neme_kana、email、password、password_confirmation、birth_dateが存在すれば登録できること' do
expect(@user).to be_valid
... |
require "matrix"
module Blind
class Point
def initialize(x,y)
@data = Vector[x,y]
end
def x
data[0]
end
def y
data[1]
end
def distance(other)
(self.data - other.data).r
end
def ==(other)
distance(other).zero?
end
def to_a
[x,y]
... |
require 'rails_helper'
RSpec.describe "Rewords", type: :request do
let!(:user) { create(:user) }
let!(:reword) { user.create_reword }
let!(:auth_params) do
login(user)
auth_params = get_auth_params_from_login_response_headers(response)
auth_params
end
describe "GET /info" do
it "returns http... |
class User < ApplicationRecord
enum gender: { unanswered: 0, male: 1, female: 2, other: 9 }
belongs_to :prefecture
scope :search, -> (search_params) do
return if search_params.blank?
name_like(search_params[:name])
.gender_is(search_params[:gender])
.birthday_from(search_params[:birthday_fr... |
module ShopifyImport
module Creators
class InventoryUnitsCreator
def initialize(shopify_line_item, spree_shipment)
@shopify_line_item = shopify_line_item
@spree_shipment = spree_shipment
end
def save!
Spree::InventoryUnit.transaction do
@shopify_line_item.quant... |
# Step 3 Basic Ruby stuff
# a) constant variable
Test = "A Constant Variable"
puts Test
# What are constants?
# constants are similar to variable, not a true objects, they are a part of the language construct and they point the objects the same way that variables do. They can be represented in Ruby by a variable name ... |
require 'rubygems'
require 'spork'
Spork.prefork do
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'rspec/autorun'
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Dir[Rail... |
require 'active_support'
require 'active_support/core_ext'
require 'active_support/inflector'
require 'erb'
require_relative './session'
require_relative './flash'
require_relative './action_view_lite/view_methods'
require_relative './action_controller_lite/parameters'
class ControllerBase
include ViewMethods
AUT... |
# Mamimum Number
# I was trying to figure out how some things worked so I expanded on this excercise a little bit.
def get_input amount_of_input
numbers = []
puts "Please enter #{amount_of_input} numbers. Hit enter after each number"
i = 1;
amount_of_input.times do
puts "Please enter number... |
#!/usr/bin/ruby --
#-*- mode: ruby-mode; coding: utf-8 -*-
# file: check_https_validity_date.rb
# Created: <2016/04/28 16:03:49>
# Last Modified: <2017/04/21 15:40:31>
require 'time'
# [HOSTNAME, DAYS]
hosts = [
["example.com", 14],
["example.jp", 14]
]
now = Time.now
hosts.each do |host|
not_afte... |
require "rails_helper"
feature "View current user's articles list" do
include_context "current user signed in"
let!(:article) { create :article, user: current_user }
scenario "User visits user articles page" do
visit user_articles_path
expect(page).to have_content(article.title)
expect(page).to ha... |
# Copyright 2019 The inspec-gcp-cis-benchmark Authors
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law... |
require 'pg'
class Diary
def self.check_environment
if ENV['DB_TEST_ENV'] == 'test'
connection = which_db('diary_manager_test')
else
connection = which_db('diary_manager')
end
end
def self.which_db(database)
PG.connect(dbname: "#{database}")
end
def self.all
connection = ch... |
class Pedido < ApplicationRecord
validates :placa, presence: true
default_scope { order("id desc") }
before_validation :valida_placa
def valida_placa
if Veiculo.where(placa: self.placa).count == 0
errors[:base] << 'Placa do veículo não encontrada'
end
end
PAGO = "1"
AGUARDANDO = "2"
... |
module Vanity
# Helper methods available on Object.
#
# @example From ERB template
# <%= ab_test(:greeting) %> <%= current_user.name %>
# @example From Rails controller
# class AccountController < ApplicationController
# def create
# track! :signup
# Acccount.create! params[:accoun... |
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
describe EventsController, 'synchronize' do
it 'should redirect to ssl if not requested via ssl' do
put :synchronize, :user_id => 'login'
expected_url = synchronize_user_events_url(:protocol => 'https', :user_id => 'logi... |
class AddFieldsToRents < ActiveRecord::Migration
def change
add_column :rents, :tenant_name, :string
add_column :rents, :email_id, :string
add_column :rents, :previous_residing_address, :text
add_column :rents, :permanent_address, :text
add_column :rents, :rent_per_month, :string
add_column :rents, ... |
class CreateInteractionsTable < ActiveRecord::Migration[5.2]
def change
create_table :interactions do |t|
t.text :description #what the description is
t.integer :goodwill #this interaction affects player reputation xp
t.integer :bounty #this interaction produces x bounty
t.integer :npc_id
... |
require_relative '../global.rb'
require_relative '../utils.rb'
require_relative '../build.rb'
require_relative '../command_options.rb'
class InstallOptions
extend CommandOptions
attr_accessor :platform
def initialize(opts)
@all_versions = false
opts.each do |opt|
case opt
when '--all-ver... |
require 'spec_helper'
describe InOrOut::Geocode do
describe 'build_address_string_for' do
let(:data) { { "street"=>"via Sommarive", "number"=>"18", "zip"=>"38123", "city"=>"Trento", "state"=>"TN" } }
describe "when a valid template is provided" do
let(:template) { InOrOut::Template.new "%{street} %{n... |
class Ability
include CanCan::Ability
def initialize(user)
user ||= User.new
can :manage, :all if user.has_role? :admin
can :manage, Organization,
id: Organization.with_role(:admin, user).pluck(:id)
end
end
|
class FilterSection < SitePrism::Section
element :filter_button, '.button'
def select(score_group)
filter_button.click
click_link score_group
Home.new
end
end
|
module Omada
module API
module Schemas
module Token
User = Dry::Validation.Schema do
configure do
# add custom error message for name validation
def self.messages
super.merge(
en: { errors: { invalid_encoding: 'token is contains invali... |
class RemoveRecievedAmountFromCompanies < ActiveRecord::Migration[5.0]
def change
remove_column :companies, :received_amount
end
end
|
class Discipline < ApplicationRecord
has_many :university_classes
validates :title, presence: true
validates :code, presence: true, uniqueness: true
def active?
active
end
end
|
class RenamePinColumns < ActiveRecord::Migration[5.1]
def change
remove_column :pins, :all_results
remove_column :pins, :jan
remove_column :pins, :feb
remove_column :pins, :mar
remove_column :pins, :apr
remove_column :pins, :may
remove_column :pins, :jun
remove_column :pins, :ju... |
class Person
#Setter
def name=(n)
@name = n
end
def job=(j)
@job = j
end
#Getter
def name
@name
end
def job
@job
end
#Member Variable
def name
@name
end
def job
@job
end
end
|
# Check doc at http://jekyllrb.com/docs/plugins/#tags
# use in page with <p>{% render_time page rendered at: %}</p>
module Jekyll
class RenderTimeTag < Liquid::Tag
def initialize(tag_name, text, tokens)
super
@text = text
end
def render(context)
"#{@text} #{Time.now}"
end
end
en... |
class CreateOrUpdateSwiftypeJob < ActiveJob::Base
queue_as :default
def perform(post)
# Add documents to index
CreateOrUpdateSwiftypeDocument.new(post).run
end
end
|
class GistQuestionService
def initialize(question, client: github_client)
@question = question
@test = @question.test
@client = client
end
def call
response = @client.create_gist(gist_params)
Result.new(response)
end
private
def github_client
Octokit::Client.new(access_token: ENV["... |
class RemoveDealsScrollHeight < ActiveRecord::Migration[5.0]
def up
remove_column :preferences, :deals_scroll_height
end
def down
add_column :preferences, :deals_scroll_height, :string, limit: 20
end
end
|
require "spec_helper"
require "v1/appointment_decorator"
describe V1::AppointmentDecorator do
before(:each) do
if Trip.count == 0
create(:trip)
end
@trip = Trip.first
end
describe "#title" do
context "in English" do
before(:each) do
I18n.locale = :en
end
it "ou... |
class Category
include DataMapper::Resource
property :id, Serial, :key => true
property :title, String
property :synopsis, Text
property :slug, String
property :icon, String
property :colour, String
property :created_at, DateTime, :lazy => [ :show ]
property :update_at, DateTime, :lazy => [ :show ]
... |
#!/usr/bin/ruby
#
# mkrd [-a] [-o file] files...
#
# -a append given files
# -o output to the file
#
require "optparse"
DEFAULT_OUTPUT = "rd.img"
options = [ ["a", ""], ["o", "string"] ]
program_config = Hash.new
program_config[:a] = "wb"
program_config[:o] = DEFAULT_OUTPUT
opts = OptionParser.new
opts.bann... |
class ApplicationController < ActionController::Base
include UserDependency
include Pundit
before_action :authenticate_user!
protect_from_forgery
rescue_from Pundit::NotAuthorizedError, with: :pundit_not_authorized
rescue_from ActiveRecord::RecordNotFound, with: :not_found
helper_method :current_user
... |
json.array!(@expense_entries) do |expense_entry|
json.extract! expense_entry, :id, :expense_id, :expense_type, :planned_date, :amount_cents, :amount_currency, :edit_method
json.url expense_entry_url(expense_entry, format: :json)
end
|
require './players'
require './questions'
# Welcome message
puts 'Welcome to the two player Math Game!'
puts 'Player 1, please enter your name... '
player1_name = gets.chomp
puts "Thank you #{player1_name}."
puts 'Player 2, please enter your name... '
player2_name = gets.chomp
puts "Thank you #{player2_name}."
# Crea... |
# Helpers to initialize the page objects
module PageObjectHelpers
def department_page
@department_page ||= DepartmentPage.new(@browser)
end
def home_page
@home_page ||= HomePage.new(@browser)
end
def login_page
@login_page ||= LoginPage.new(@browser)
end
def employee_page
@employee_page... |
class AddJumpstartToUsers < ActiveRecord::Migration[5.2]
def change
add_column :users, :jumpstart, :text
add_index :users, :jumpstart, length: 1
end
end
|
require 'spec_helper'
describe BackpackTF::Price::Interface do
it 'has these default attributes' do
expect(described_class.name).to eq :IGetPrices
expect(described_class.version).to eq 4
expect(described_class.raw).to eq nil
expect(described_class.since).to eq nil
end
describe '::defaults' do
... |
class Task < ApplicationRecord
validates :name, presence: true
validates :content, presence: true
def mark
self.todo = !self.todo
self.save!
end
end
|
class Work < ApplicationRecord
has_many :votes
has_many :users, through: :votes
belongs_to :user
validates :category, presence: true
validates :category, inclusion: { in: ["movie", "book", "album"], message: "%{value} is not a valid category" }
validates :title, presence: true
validates :title, uniquen... |
require('spec_helper')
describe(Line) do
describe("#name") do
it("returns the name of the line") do
test_line = Line.new({:name => "Pink", :id => nil})
expect(test_line.name()).to(eq("Pink"))
end
end
describe("#id") do
it("returns the id of a line") do
test_line = Line.new({:name ... |
require "delegate"
module SpecRunner
class RubyPath < SimpleDelegator
def initialize(object)
super(object.to_s)
end
def exists?
File.exists?(self)
end
def points_to_spec_file?
!!match(/_spec.rb/)
end
def to_implementation
new { gsub("_spec.rb", ".rb") }
end
... |
require 'bundler/gem_tasks'
require 'rspec/core/rake_task'
# The available camera models for shooting test
# model_tags = [:HDR_AZ1, :FDR_X1000V, :DSC_RX100M4, :ILCE_QX1]
model_tags = [:DSC_RX100M4, :ILCE_QX1, :FDR_X1000V]
# The available camera models for contents test
model_tags_contents = [:HDR_AZ1]
# The availab... |
# Because we did not put prefix the block with the & symbol necassary to interpret it as block
# and not just a regular parameter.
# Right now the function is interpreting the parameter as just a regular parameter and not a block.
# and the block does not take a parameter either.
|
require 'spec_helper'
describe SessionsController do
render_views
describe "GET 'new'" do
it "returns http success" do
get 'new'
response.should be_success
end
it "should have the right title" do
get :new
response.should have_selector('title', :content => "Sign in")
en... |
class Franchise < ActiveRecord::Base
belongs_to :franchisee
has_and_belongs_to_many :ops_leaders
has_many :stores
attr_encrypted :name, :key => ENV['ENCRYPTION_KEY']
# def complete?
# percentage_complete >= 100
# end
#
# def percentage_complete
# ((stores.has_submission.count.to_f / stores.coun... |
class AuthenticateUser
attr_reader :token
def initialize(username, password)
@username = username
@password = password
end
def run
user = User.find_by_username(@username)
raise RuntimeError.new "User not found" unless user
raise RuntimeError.new "Password invalid" unless user.authentica... |
class InputOpener
DATE_REGEX = /\d+-\d+-\d+/
def self.open(name, regex = nil)
files = Dir["#{ ENV["HOME"] }/workspace/*#{name}*.txt"]
files = files.select {|file| file.match regex} if regex
files.sort_by! do |file|
last_date = file.to_s.match DATE_REGEX
date = DateTime.parse(last_date.to_s)
dat... |
class AddFooterInformationToSettings < ActiveRecord::Migration
def change
add_column :settings, :system_email, :string
add_column :settings, :vk_link, :string
add_column :settings, :fb_link, :string
add_column :settings, :instagram_link, :string
add_column :settings, :twitter_link, :string
add... |
class Contact < ActiveRecord::Base
after_save :load_into_soulmate
validates_presence_of :name
validate :at_least_one_number
def at_least_one_number
if !mobile and !voip
errors[:base] << "Please enter at least one contact nubmer"
end
end
def load_into_soulmate
loader = Soulmate::Loader.... |
require 'spec_helper'
describe 'arrow_alignment' do
let(:msg) { 'indentation of => is not properly aligned' }
context 'with fix disabled' do
context 'selectors inside a resource' do
let(:code) { "
file { 'foo':
ensure => $ensure,
require => $ensure ? {
present =>... |
require "active_storage/previewer"
class ActiveStorage::Previewer::OfficePreviewer < ActiveStorage::Previewer
ACCEPTABLE_CONTENT_TYPES = [
"application/msword", # .doc
"application/vnd.openxmlformats-officedocument.wordprocessingml.document", # .docx
"application/vnd.ms-powerpoint", # .ppt
"applicat... |
require 'deploy/host'
module Deploy
class State
attr_reader :hostname, :username, :homedir
def initialize
@hostname = Host.hostname()
@username = Host.username()
@homedir = Host.homedir()
end
# if it is not absolute, make it relative to $HOME
def abspath path
if ... |
require './test/test_helper'
class GameTeamTest < Minitest::Test
def setup
game_path = './data/samples/game.csv'
team_path = './data/samples/team_info.csv'
game_teams_path = './data/samples/game_teams_stats.csv'
locations = {
games: game_path,
teams: team_path,
game_teams: game_te... |
require 'spec_helper'
describe Post do
it 'has valid factory' do
expect(build(:post)).to be_valid
end
it { should belong_to(:writer) }
it { should belong_to(:subject) }
it { should validate_presence_of(:writer_id) }
it { should validate_presence_of(:subject_id) }
it { should ensure_length_of(:conten... |
class UsersController < ApplicationController
before_action :set_user, only: [:show, :destroy, :update, :generate_pdf, :download]
# GET /users
# GET /users.json
def index
@users = User.all
end
# GET /users/1
# GET /users/1.json
def show
end
def welcome
end
def login
end
def generate... |
class AddColumnsToProducts < ActiveRecord::Migration
def change
add_column :products, :title, :string
add_column :products, :description, :text
add_column :products, :deadline, :datetime
end
end
|
class AddClassPatternToClassDate < ActiveRecord::Migration[5.0]
def change
add_reference :class_dates, :class_pattern, index: true
add_foreign_key :class_dates, :class_patterns
add_column :class_dates, :repeat, :bool, default: false
end
end
|
require 'rails_helper'
RSpec.describe "reports/edit", type: :view do
before(:each) do
@report = assign(:report, Report.create!(
:generate_by => 1,
:unit => false,
:state => false,
:kind => false,
:onu => false,
:blend => false,
:code => false,
:total => false,
... |
# 2017-04-26
# David Lin
# Method: DP
# Time Comlexity: O(n)
# @param {Integer} num
# @return {Integer[]}
def count_bits(num)
res = [0]
while res.length <= num
res = res + res.map { |count| count + 1 }
end
return res[0..num]
end
|
class RemoveIndicesFromResponses < ActiveRecord::Migration
def change
remove_index "responses", name: "index_responses_on_responder_id_and_question_id"
end
end
|
class User < ApplicationRecord
has_many :reviews
has_many :reviewed_sneakers, through: :reviews, source: :sneaker
has_many :sneakers #sneaker that user has created
validates :username, :email, uniqueness: true, presence: true
has_secure_password
def self.from_omniauth(auth)
where(e... |
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :token_authenticatable, :confirmable,
# :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :recoverable, :rememberable, :trackable
# Setup accessible (or protected) attributes for your model
a... |
class CreateSpawns < ActiveRecord::Migration
def change
create_table :spawns do |t|
t.belongs_to :area, index: true
t.string :type
t.string :name
t.integer :x
t.integer :y
t.timestamps null: false
end
end
end
|
# frozen_string_literal: true
module SXS
require 'sxs/config'
require 'sxs/publisher'
require 'sxs/publishers'
class << self
def config
@config ||= ::SXS::Config.new
end
def configure
yield config
end
end
end
|
json.array!(@trade_types) do |trade_type|
json.extract! trade_type, :id, :type_id, :group, :symbol_name, :description, :deposit_description, :withdrawal_description
json.url trade_type_url(trade_type, format: :json)
end
|
require 'test_helper'
class UserTest < ActiveSupport::TestCase
# Validation Tests
#
test "user is valid with all attributes" do
user = FactoryGirl.build(:user)
assert user.valid?, "User was not valid with all attributes"
end
test "user is invalid without a first name" do
user = FactoryGirl.bui... |
#! /usr/bin/ruby
require "rubygems"
require "xmpp4r"
require "xmpp4r/pubsub"
require "xmpp4r/pubsub/helper/servicehelper.rb"
require "xmpp4r/pubsub/helper/nodebrowser.rb"
require "xmpp4r/pubsub/helper/nodehelper.rb"
include Jabber
Jabber::debug = true
TRIVIAROOMS_USER = "triviarooms@dev.triviapad.com"
TRIVIAROOMS_P... |
require 'rails_helper'
RSpec.describe SessionsHelper, type: :helper do
let(:user){
user_params = {
id: 1,
created_at: Time.new,
updated_at: Time.new,
email: 'admin@admin.com',
password: '123456789',
password_confirmation: '123456789',
remember_digest: 'aaaa'
}
Ad... |
class PuzzlesController < ApplicationController
def index
@puzzles = Puzzle.order('kind_id, name').includes(:kind)
end
def new
@puzzle = Puzzle.new
end
def create
@puzzle = Puzzle.new params[:puzzle]
if @puzzle.save
redirect_to puzzles_path
else
render :new
end
end
d... |
module SearchService
class Result
attr_accessor :title,:id, :description
end
def self.search()
result1 = SearchService::Result.new
result1.title = "Cool restaurant 1"
result1.description = "Vivamus volutpat elit sit amet ex feugiat pharetra. Curabitur sed velit et enim ultri... |
require_relative '../helpers/rake_helper_template'
class DrawingMetadata < RakeHelperTemplate
def main
template do |logger|
File.open('component_drawings.csv', 'w') do |csv|
csv.puts 'Component Name, Width, Height'
all_component_drawings = all_drawings
logger.info("#{all_component... |
class Topic < ActiveRecord::Base
belongs_to :committee
attr_accessor :image_url
mount_uploader :image_url, ImageUploader
validates :order_id, presence: true
validates :topic_name, presence: true, uniqueness: true, length: { maximum: 100 }
validates :description, presence: true, length: { maximum: 750 }
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.