text stringlengths 10 2.61M |
|---|
aclass BankAccount
#auto generate getter/setter
attr_accessor :holder_name, :amount, :type
# read only mode would be :
# attr_reader :amount
#initialize is called a "constructor"
def initialize(holder_name, amount, type) #names here dont have to be the same as the below, its just good practice
#insta... |
class Invoice < ApplicationRecord
has_many :leads
belongs_to :user
def display_xero_invoice_number
"INV-#{xero_invoice_number}" if xero_invoice_number
end
end
|
require 'spec_helper'
require_relative '../../../../lib/paths'
module Jabverwock
currnt = Dir.pwd
testFolderPath = currnt + "/spec/lib/sampleCode/layouts/"
sampleName = "page_centering_1/"
RSpec.describe sampleName do
def cHeader
CSS.new("header").background_color("#ffe080")
end
def cC... |
class CreateAprofiles < ActiveRecord::Migration
def change
create_table :aprofiles do |t|
t.integer :aprofile_id, :null => false
t.integer :urn
t.string :f_name
t.string :l_name
t.string :department
t.timestamps
end
add_index :aprofiles, :urn, :name => 'aprofiles_urn... |
# ruby_twitter_bot.rb
# Copyright 2018 davd <davd@cherishedhipster>
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version... |
# -*- coding: utf-8 -*-
Given /^バックエンドとして ([a-zA-Z]+) を指定したサーバーコンフィグレータ$/ do | scm |
@messenger = StringIO.new
@verbose = true
@configurator = Configurator::Server.new( scm, options )
end
Given /^バックエンドの SCM が指定されていないサーバーコンフィグレータ$/ do
@messenger = StringIO.new
@verbose = true
@configurator = Configurator:... |
# encoding: utf-8
# Inspec test for recipe jnj_chef_stack::backend
# The Inspec reference, with examples and extensive documentation, can be
# found at https://docs.chef.io/inspec_reference.html
packages = %w(chef chef-backend)
packages.each do |p|
describe package(p) do
it { should be_installed }
end
end
c... |
require 'spec_helper'
resource "Tableau" do
let(:dataset) { datasets(:chorus_view) }
let(:workspace) { workspaces(:public) }
let(:user) { dataset.gpdb_instance.owner }
before do
log_in user
any_instance_of(TableauWorkbook) do |wb|
stub(wb).save { true }
end
end
post "/workspaces/:worksp... |
class AddJobIdToJobDescriptions < ActiveRecord::Migration
def change
add_column :job_descriptions, :job_id, :int
end
end
|
class AddReverseLookupToSwitchboard < ActiveRecord::Migration
def change
add_column :switchboards, :reverse_lookup_activated, :boolean
end
end
|
describe "read_json should" do
it "load a hash containing name and age property from json file" do
json = Fastlane::Actions::ReadJsonAction.run({
json_path: "#{__dir__}/resources/example.json"
})
expect(json).to have_key(:name)
expect(json).to have_key(:age)
expect(json[:name]).to eq("Marti... |
# frozen_string_literal: true
module Inferno
module Sequence
class ClinicalNoteAttachment
attr_reader :resource_class
attr_reader :attachment
def initialize(resource_class)
@resource_class = resource_class
@attachment = {}
end
end
class USCoreR4ClinicalNotesSeque... |
class ProductTag < ApplicationRecord
belongs_to :product, inverse_of: :product_tags
validates :product, presence: true
validates :name, uniqueness: { scope: :product_id }
scope :select_tags_by_name, ->(tag_name) { where(name: tag_name) }
scope :count_used_over_all_product_with_tag_name, ->(tag_name) { selec... |
Vagrant.configure(2) do |config|
config.vm.box = "giovannicode/neiu-rebuild-old"
config.vm.network "forwarded_port", guest: 8080, host: 8081
end
|
#!/usr/bin/env ruby
#
# require 'rubygems'
# require 'bundler'
# Bundler.require
require 'trollop'
require 'memcached'
require 'yajl'
require 'librato/metrics'
$:.unshift File.join(File.dirname(__FILE__), '../lib')
require 'librato-metrics-memcached'
parser = Trollop::Parser.new do
version "librato-metrics-memc... |
class TopsController < ApplicationController
def index
redirect_to '/home' if user_signed_in?
end
end
|
class Backend::CategoriesController < ApplicationController
before_filter :authenticate_user!
def index
@categories = Category.all
end
def new
@category = Category.new
end
def create
@category = Category.new(category_parameters)
if @category.save
flash[:success] = 'Kategorie erfolgr... |
require 'rails_helper'
RSpec.describe "When I visit an author's show page", type: :feature do
before :each do
@author_1 = Author.create(name:"Author 1")
@author_2 = Author.create(name:"Author 2")
@book_1 = @author_1.books.create(title:"Author 1 book", page_count: 100, year: 2010)
@book_2 = @author_... |
class SearchesController < ApplicationController
before_action :set_q, only:[:index, :search]
def index
@q = Book.ransack(:q)
@books = @q.result(distinct: true).page(params[:page]).per(10).reverse_order
end
def search
@q = Book.search(search_params)
@books = @q.result(distinct: true)
end
... |
module Xapit
# Singleton class for storing Xapit configuration settings. Currently this only includes the database path.
class Config
class << self
attr_reader :options
# See Xapit#setup
def setup(options = {})
if @options && options[:database_path] != @options[:database_path]
... |
class CompaniesController < ApplicationController
before_filter :company_params,only: :create
before_filter :authenticate_user
def new
p '================='
@company = Company.new(user_id: current_user.id)
end
def create
@company = Company.new(company_params)
if @company.save
redirect_to root_path
els... |
# Problem: Take 2 arrays and combine them in alternating fashion
# Input: 2 Arrays
# Output: 1 Array
# Steps:
# 1: Define a method with 2 arguments
# 2: Initialize a new array
# 3: Create a loop that we will itterate through array.size times
# - Use counter as idx and add elements from each of the arrays
# 4: retur... |
require 'rails_helper'
RSpec.describe SessionsController, type: :controller do
context 'with VALID credentials' do
before :each do
get :destroy
end
# ----------------------------------------
describe 'GET #index' do
# it 'returns http success, even not logged' do
# get :index
... |
require 'exchange_rate'
RSpec.describe ExchangeRate do
describe 'file fetching' do
before(:each) do
@retriever = DataRetriever.new
end
it 'fetches the dev xml and stores it locally' do
url = 'http://www.ecb.europa.eu/stats/eurofxref/eurofxref-hist-90d.xml?526da90c43e51cc5b44bf360e6f1dac3'
... |
require "spec_helper"
describe V1::CitiesApi do
let(:cities_path) { "/v1/cities" }
def city_districts_path city
"v1/cities/#{city.id}/districts"
end
context "city" do
it "get all cities" do
create_list :city, 2
res = auth_json_get cities_path
expect(res.size).to eq(2)
... |
class CreateBundleInstance < ActiveRecord::Migration[5.0]
def change
create_table :bundle_instances do |t|
t.integer :site_id
t.integer :bundle_id
t.timestamps
end
add_column :application_instances, :bundle_instance_id, :integer
add_column :bundles, :key, :string
add_index(:bund... |
module ApplicationHelper
NEAR_EXPIRY_SECONDS = 60
def valid_session?
if session['uid'].nil? || session['credentials'].nil?
return false
elsif session_near_expiry?
attempt_token_refresh
elsif session['credentials']['expires_at'] <= Time.now.to_i
session.delete('credentials') # Wipe ou... |
class TagHelper
# merge tag 'tag_from' to tag 'tag_to'
def self.merge_tags(tag_from, tag_to)
tag_from.taggings.each do |tagging|
taggable = tagging.taggable
taggable.tag_list.remove(tag_from.name)
taggable.tag_list.add(tag_to.name)
taggable.save
end
tag_from.reload
#... |
ENV['REDISCLOUD_URL'] = 'redis://localhost:6379/0'
Rails.application.configure do
# require 'sidekiq/testing/inline'
config.cache_classes = false
config.eager_load = false
config.consider_all_requests_local = true
config.action_controller.perform_... |
# frozen_string_literal: true
class TestPassage < ApplicationRecord
TEST_PASSED_VALUE = 85
belongs_to :user
belongs_to :test
belongs_to :current_question, class_name: 'Question', optional: true
before_validation :before_validation_set_first_question
def completed?
current_question.nil?
end
def a... |
require 'rails_helper'
RSpec.describe AccountWithdrawRequest, type: :model do
subject { create(:account_withdraw_request) }
describe 'validations' do
describe 'association' do
it { is_expected.to belong_to(:account) }
it { is_expected.to belong_to(:account_transaction).optional }
end
desc... |
# Inheritance
=begin
A class can inherit functionality and variables from a superclass, sometimes referred to as a parent class or base class. Ruby does not support multiple inheritances and so a class in Ruby can have only one superclass. The syntax is as follows:
=end
class ParentClass
def a_method
puts 'b'
... |
class AddStuff2ToCoaches < ActiveRecord::Migration[5.0]
def change
add_column :coaches, :price, :text
rename_column :coaches, :where, :locations
add_column :coaches, :comments, :text
end
end
|
require 'rails_helper'
describe User do
before do
@user = FactoryBot.build(:user)
end
describe '#create' do
it "is invalid without a nickname" do
user = build(:user, nickname: nil)
user.valid?
expect(user.errors[:nickname]).to include(“can’t be blank”)
end
it "is invalid without ... |
class Event < ActiveRecord::Base
has_many :check_ins, dependent: :destroy
has_many :citizens, through: :check_ins
has_one :keyword_listener, as: :listening, dependent: :destroy
validates :name, presence: true
validates :keyword, presence: true
normalize_attribute :keyword, with: [:strip, :blank] do |value... |
require 'text'
require 'time'
describe Text do
it 'sends a text' do
fake_message = {
from: '123',
to: '456',
body: 'testing my message'
}
expect(subject).to receive(:send_text).with(fake_message)
subject.send_text(fake_message)
end
it 'has a delivery time of an hour' do
al... |
require 'spec_helper'
RSpec.describe FreezeTag do
let!(:article) { Article.create(title: "Article") }
let!(:article1) { Article.create(title: "Article 1") }
let!(:article2) { Article.create(title: "Article 2") }
it "has a version number" do
expect(FreezeTag::VERSION).not_to be nil
end
it "allows tags... |
class Profile < ActiveRecord::Base
belongs_to :user
before_update :send_update_mail
RENOVATION_TEXTS = {
"0" => "Un minimum",
"1" => "Quelques aménagements",
"2" => "De gros travaux"
}
BLANK = {
"" => "",
nil => ""
}
PERIOD_TEXTS = {
"0" => "Tout de suite",
"1" => "Dans l... |
# == Schema Information
#
# Table name: products
#
# id :integer not null, primary key
# name :string
# system_name :string
# brand_type :string
# price :integer
# image :string
# image_2 :string
# width :float
# height ... |
require 'cocoapods-x/extension/sandbox/protocol'
module Pod
module X
class Sandbox
class Project < Pod::Sandbox
include Pod::X::Sandbox::Protocol
attr_reader :repos, :conf
def initialize conf
@conf = conf
... |
# Notes
# Write a function that will return the count of distinct
# case-insensitive alphabetic characters and numeric digits that
# occur more than once in the input string. The input string can
# be assumed to contain only alphabets (both uppercase and
# lowercase) and numeric digits.
# Problem
# Input: string
... |
# typed: false
# frozen_string_literal: true
require "test_helper"
module Packwerk
module Inflections
class CustomTest < Minitest::Test
test "#initialize with nil inflection file returns empty inflections" do
empty_inflection = Packwerk::Inflections::Custom.new
assert_empty empty_inflectio... |
class DeleteResumeFromUser < ActiveRecord::Migration[6.0]
def change
remove_column :users, :resume, :text
end
end
|
class Session < ApplicationRecord
has_many :users
has_one_attached :file
validates :title, presence: true
validates :description, presence: true
# has_many :users, :through => :session
end
|
##
# The guess numeber program gets you to choose the sides of a dice
# then guess the random number
#
# @author Cameron Teed
# @version 1.0
# @since 2020-04-26
# frozen_string_literal: true
# Asks user for input
puts 'Please enter the range of your dice (1-?):'
# Gets the user input
side_amounts = gets.chomp
begi... |
class ApplicationController < ActionController::Base
include Jpmobile::ViewSelector
include Pundit
before_action :set_view_path
protect_from_forgery with: :exception
helper_method :current_user_session, :current_user
private
def set_view_path
path = request.smart_phone? ? 'mobile' : 'pc'
prepen... |
class WelcomeController < ApplicationController
# Skip the before action on all controllers (will not force user to login at index)
skip_before_action :authenticate_user!, only: [:index]
def index
end
end
|
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
protected
def cart
@cart ||= Cart.new(session[:cart])
end
helper_method :cart
def current_user
@cu... |
class CampsController < ApplicationController
def index
@camps = Camp.all
end
def create
@camp = Camp.create(camp_params)
if @camp.save
redirect_to @camp, notice: "You have successfully created a Dojo!"
else
flash[:errors] = @camp.errors.full_messages
redirect_to :back
end
... |
require 'mandrill'
include VisionboardHelper
class SendVisionboardNotificationEmail
@queue = :normal
# kind: intention, thank, intention_image, thank_image
def self.perform(plan_uuid, kind)
Rails.logger.info "SendVisionboardNotificationEmail(#{kind}) for plan #{plan_uuid}"
action_plan = StressLessAppWe... |
class ChangeGroupIdsToStrings < ActiveRecord::Migration
def up
change_column :group_wallpaper_images, :group_id, 'CHAR(8)', null: false
change_column :message_attachments, :group_id, 'CHAR(8)'
end
def down
raise ActiveRecord::IrreversibleMigration
end
end
|
module TheCityAdmin
class GroupExportReader < ApiReader
# Constructor.
#
# @param group_id The ID of the group to load.
# @param options A hash of options for requesting data from the server.
# :: group_id is required
# @param cacher (optional) The CacheAdapter cacher to be us... |
require 'json'
require 'rest_client'
module MiniFB
# Global constants
FB_URL = "http://api.facebook.com/restserver.php"
FB_VIDEO_URL = "http://api-video.facebook.com/restserver.php"
FB_API_VERSION = "1.0"
class FaceBookError < StandardError
attr_accessor :code
# Error that happens... |
class AddFeaturesToRevision < ActiveRecord::Migration
def change
add_column :revisions, :features, :text
end
end
|
require 'httparty'
class SubscriptionsController < ApplicationController
before_action :authenticate_user
def subscriber
transaction = Transaction.find_by_ref_no(params[:id])
plan = transaction.transaction_for
amount = transaction.amount
case
when plan == "BASIC"
basic transaction
... |
# frozen_string_literal: true
class PerformancesController < ApplicationController
before_action :search_stage, only: %i[index search]
before_action :set_performance, only: %i[show edit update destroy]
def index
@performances = Performance.all
end
def search
@results = @p.result(distinct: true).pag... |
module Fundraiser
class ApplicationController < ActionController::Base
def method_missing(method_name)
if method_name == :authenticate_user!
Rails.logger.warn("authenticate_user! in Crowdblog::ApplicationController should be overriden")
end
end
protected
def sanity_check
red... |
require 'spec_helper'
describe 'panamax:templates:load' do
include_context 'rake'
before do
allow(TemplateRepo).to receive(:load_templates_from_all_repos)
end
its(:prerequisites) { should include('environment') }
it 'loads templates' do
expect(TemplateRepo).to receive(:load_templates_from_all_repo... |
require 'rails_helper'
describe 'ExternalMember::index', type: :feature do
describe '#index' do
context 'when shows all external members' do
it 'shows all external members with options', js: true do
responsible = create(:responsible)
login_as(responsible, scope: :professor)
externa... |
#!/usr/bin/env ruby
require 'byebug'
require_relative 'silo_particle'
require_relative 'opts'
require_relative 'parsing_utils'
require_relative 'silo_dynamics'
def random_x
Random.rand((2 * R)..(W - 2 * R))
end
def random_y
Random.rand((2 * R)..(L - 2 * R))
end
opts = parse_opts({})
L = opts[:l].to_i.abs
W = op... |
# $Id$
namespace :reports do
namespace :backup do
desc "Generate backup storage use report"
task :storage => :environment do
EternosBackup::BackupReporter.storage_usage
end
desc "Generate daily backup jobs report"
task :jobs => :environment do
EternosBackup::BackupReporter.backup_job... |
namespace :panamax do
namespace :templates do
desc 'Populate local template cache from all registered repositories'
task :load => :environment do
TemplateRepo.load_templates_from_all_repos
end
desc 'Clear local template cache'
task :unload => :environment do
Template.destroy_all
e... |
require 'rubygems'
require 'bankjob' # this require will pull in all the classes we need
require 'base_scraper' # this defines scraper that BpiScraper extends
include Bankjob # access the namespace of Bankjob
##
# BpiScraper is a scraper tailored to the BPI bank in Portugal (www.bpinet.pt).
# It takes adv... |
require './test/test_helper'
require './lib/gameteam'
class GameteamTest < Minitest::Test
def setup
gameteaminfo = {
game_id: "2012030221",
team_id: 3,
HoA: "away",
result: "LOSS",
settled_in: "OT",
head_coach: "John Tortorella",
goals: "2",
shots: "8",
tack... |
class CategoriesController < ApplicationController
before_action :authenticate_user!
before_action :check_user
before_action :set_category, only: %i[edit update destroy]
rescue_from ActiveRecord::RecordNotFound, with: :invalid_category
def index
@category = Category.ransack(params[:q])
@categories_... |
# Control series where the players in the games take turns
class TurnBased < Controller
private
def setup_round
@series.new_game(@id_of_leader)
end
def play_round
mover = whose_go ^ 1
game_over ||= @series.take_turn(mover ^= 1) until game_over
game_over == 'saved' || stop_playing?
end
def... |
require 'test_helper'
class EmployeesControllerTest < ActionController::TestCase
setup do
@employee = employees(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:employees)
end
test "should get new" do
get :new
assert_response :success
... |
module JwtRest
module Authenticable
def demand_application_json
unless request.format.symbol == :json
render status: :not_acceptable, json: { error: "only application/json Content-Tyle is allowed" }
end
end
def demand_api_key
api_key = request.headers["HTTP_X_API_KEY"]
unl... |
class ReviewsController < ApplicationController
before_action :authenticate_user!, except: [:index, :show]
def create
@restaurant = Restaurant.find(params[:restaurant_id])
@review = @restaurant.reviews.new(review_params)
@review.user = current_user
@reviews = @restaurant.reviews.order('created_at d... |
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :user do |u|
u.password "password"
u.password_confirmation "password"
u.sequence(:email) { |n| "tester#{n}@example.com"}
end
end
|
require './lib/deck.rb'
require './lib/round_result.rb'
require './lib/player.rb'
class Game
attr_accessor :player1, :player2, :deck, :winner, :loser, :rounds_played
def initialize(player1: Player.new, player2: Player.new)
@player1 = player1
@player2 = player2
@deck = Deck.new(type: 'regular')
@wi... |
describe Cinemas::Representers::Relationship do
let(:call_class) do
described_class.new(
cinema: Cinemas::Model.last
).call
end
before do
create(:cinema)
end
it 'has correct attributes' do
expect(call_class[:attributes].keys).to contain_exactly(
:cinema_number, :total_seats, :row... |
class Track < ActiveRecord::Base
include PublicActivity::Model
tracked owner: ->(controller, model) { controller && controller.current_user },
:on => {:destroy => proc {|model, controller| model.activities.delete_all }},
:only => [:create]
has_many :stems, :dependent => :destroy
has_many :comments, :depend... |
FactoryGirl.define do
factory :registered_app do
name Faker::Lorem.word
url "https://example.com/"
user
end
end
|
# frozen_string_literal: true
class Reindexer
attr_reader :collection_name
def initialize(collection_name: "Latin American Ephemera")
@collection_name = collection_name
end
def index!
solr_documents.each_slice(500) do |docs|
solr.add(docs, params: { softCommit: true })
end
solr.commit
e... |
class FriendsController < ApplicationController
before_action :set_friend, only: [:show, :update, :destroy]
# GET /friends
def index
@friends = Friend.all
render json: @friends
end
# GET /friends/1
def show
render json: @friend
end
# POST /friends
def create
@friend = Friend.new(fr... |
module ApplicationHelper
def currentpage(controller)
"current" if params[:controller] == controller
end
def EntityObjectByChild(child)
if child.entity_type
case child.entity_type
when 1
CrmContact
when 2
CrmCase
when 3
Deal
end.find(child.entity_id)
end
end
de... |
class EbayAPI
scope :sell do
scope :inventory do
scope :offers do
# https://developer.ebay.com/api-docs/sell/inventory/resources/offer/methods/getListingFees
operation :get_listing_fees do
option :offer_ids,
->(ids) { Array(ids).map { |id| { offerId: id.to_s } } },... |
class ChangeMiscInfoToJson < ActiveRecord::Migration
def change
remove_column :characters, :misc_info
add_column :characters, :misc_info, :json
end
end
|
class CarDealer
def initialize
@inventory = []
end
def add_car(car)
brand_exist = false
if @inventory.empty?
@inventory << car
else
@inventory.each do |car_inv|
if car_inv[:brand] == car[:brand]
car_inv[:model] = car_inv[:model] | car[:model]
brand_exist = true
end
end
if !bra... |
class PressOnSerializer < ActiveModel::Serializer
attributes :id, :name, :shape, :color, :add_on, :description, :price, :quantity, :image, :item_type
end |
class ChangeDateFormatInExmas < ActiveRecord::Migration
def change
remove_column :exams, :data_prenotazione, :time
remove_column :exams, :data_effettuazione, :time
end
end
|
#!/usr/bin/env ruby
# functions
#
# Created by Carlos Maximiliano Giorgio Bort on 2011-03-06.
# Copyright (c) 2011 University of Trento. All rights reserved.
#
=begin
As Hillstrom [1] proposed, here the starting points used in the optimizations are chosen from a box surrounding the standard starting point.
One can e... |
class SessionController < ApplicationController
def new; end
def sign_in
user = User.auth(params[:email], params[:pass])
if user.nil?
redirect_to signin_path, notice: 'Неверный логин или пароль!'
else
session[:current_user_id] = user.id
redirect_to root_path
end
end
def sign_... |
require "thinwestlake/version"
require "logger"
module ThinWestLake
LOGGER = Logger.new( STDERR )
def logger
LOGGER
end
end
|
# 1) Edit the method definition in exercise #4 so that it does print words on the screen. 2) What does it return now?
# Original code:
# def scream(words)
# words = words + "!!!!"
# return
# puts words
# end
# scream("Yippeee")
# New code:
def scream(words)
words = words + "!!!!"
puts words
end
scream("Yipp... |
# frozen_string_literal: true
# Released under the MIT License.
# Copyright, 2018-2023, by Samuel Williams.
module Async
module REST
VERSION = "0.12.4"
end
end
|
class RomanNumeral
attr_reader :numeral
attr_reader :decimal
attr_reader :error
def initialize num_or_numeral
begin
converted_num_or_numeral = RomeConversor.parse num_or_numeral
if converted_num_or_numeral.is_a? String
@numeral = converted_num_or_numeral
@decimal = num_or_numera... |
class Song < ActiveRecord::Base
validates :title, presence: true, uniqueness: {:scope => [:release_year, :artist_name]}
validates :release_year, presence: true, if: :released?, numericality: {less_than_or_equal_to: Time.now.year}
# validates :artist_name, presence: true
# validate :same_song
# def song_is_... |
require 'rails_helper'
RSpec.describe OperationsController, type: :controller do
context 'when the user not logged in' do
describe 'GET #new' do
it 'redirects to the login page' do
get :new, user_id: 1, company_id: 1
expect(response).to redirect_to(login_path)
end
end
describe... |
# frozen_string_literal: true
module Queries
module Plays
class FetchPlay < ::Queries::BaseQuery
type Types::PlayType, null: false
argument :id, ID, required: true
def resolve(id)
Play.includes(:game).find id[:id]
rescue ActiveRecord::RecordNotFound => _e
GraphQL::Executi... |
require 'dm-core'
require 'dm-migrations'
class Student
include DataMapper::Resource
property :id, Serial
property :name, String
property :email, String
property :gpa, String
end
configure do
enable :sessions
set :username, 'saumya'
set :password, 'ruby'
end
DataMapper.finalize
get '/students' do
... |
class Bid < ActiveRecord::Base
enum suit: Suits::ALL_SUITS
MIN_TRICKS = 6
MAX_TRICKS = 10
ALLOWED_TRICKS = (MIN_TRICKS..MAX_TRICKS).to_a
belongs_to :round, touch: true
belongs_to :player
validates :round, :player, presence: true
validates :number_of_tricks, :suit, presence: true, unless: :pa... |
# encoding: utf-8
class JmesPath
VERSION = '1.0.0.pre0'.freeze
end |
require 'test_helper'
class ReplacementOrderTest < ActiveSupport::TestCase
test "record_order" do
claim = LtClaim.new(:state => :replacement_order)
order = SlowReplacementOrder.new(:claim => claim)
order.record_replacement_product
assert_equal "complete", order.state
assert_equal "claim_charge", ... |
class Receipt
attr_reader :items_sold, :business_address, :business_name
def initialize(items_sold, business_name, business_address)
@items_sold = items_sold
@business_address = business_address
@business_name = business_name
end
def to_s
receipt_string = "#{@business_name}\n"
receipt_stri... |
class County < ActiveRecord::Base
validates :name, presence: true
has_many :rentals
has_many :cities
belongs_to :state
end
|
require 'formula'
class Shntool < Formula
homepage 'http://etree.org/shnutils/shntool/'
url 'http://etree.org/shnutils/shntool/dist/src/shntool-3.0.10.tar.gz'
sha1 '7a2bc8801e180cf582f0e39775603582e35d50d2'
def install
system "./configure", "--disable-dependency-tracking",
"--pre... |
# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'activerecord_data_importer/version'
Gem::Specification.new do |spec|
spec.name = "activerecord_data_importer"
spec.version = ActiverecordDataImporter::VERSION
spec.authors ... |
require "spec_helper"
require "time"
require "massive_sitemap/writer/file"
describe MassiveSitemap::Writer::File do
let(:filename) { 'sitemap.xml' }
let(:filename2) { 'sitemap-1.xml' }
let(:writer) { MassiveSitemap::Writer::File.new.tap { |w| w.init! } }
after do
FileUtils.rm(filename) rescue nil
Fi... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.