text stringlengths 10 2.61M |
|---|
require 'rails_helper'
include AdminHelpers
RSpec.feature 'Listing performances' do
before do
@hr = create(:hr)
assign_permission(@hr, :read, Performance)
login_as(@hr, scope: :hr)
@employee = create(:employee)
@performance1 = create(:performance, employee: @employee)
@performance2 = create(:... |
class BackupGenerator < Rails::Generator::Base
# This method gets initialized when the generator gets run.
# It will receive an array of arguments inside @args
def initialize(runtime_args, runtime_options = {})
super
end
# Processes the file generation/templating
# This will automatically be run aft... |
require 'json'
require 'cgi'
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', 'puppet_x', 'nexus', 'config.rb'))
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', 'puppet_x', 'nexus', 'exception.rb'))
require File.expand_path(File.join(File.dirname(__FILE__), '..',... |
class RenameOrchIdColumnToConcers < ActiveRecord::Migration
def change
rename_column :concerts, :orch_id, :orchestra_id
end
end
|
module Algorithmia
class Client
attr_reader :api_key
def initialize(api_key)
@api_key = api_key
end
def algo(endpoint)
Algorithmia::Algorithm.new(self, endpoint)
end
def file(endpoint)
Algorithmia::DataFile.new(self, endpoint)
end
def dir(endpoint)
Algorithm... |
require 'rails_helper'
feature 'User adds a Procedure to an unstarted visit', js: true do
let!(:protocol) { create_and_assign_protocol_to_me }
let!(:participant) { Participant.first }
let!(:appointment) { Appointment.first }
let!(:services) { protocol.organization.inclusive_child_services(:per_parti... |
class Dietdocument < ActiveRecord::Base
has_attached_file :dietscan
do_not_validate_attachment_file_type :dietscan
validates_presence_of :student_id
belongs_to :student
end
|
Rails.application.routes.draw do
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
# get '/current_user', to: 'application#current_user'
get '/check_user', to: 'application#check_user'
namespace :api do
namespace :v1 do
resources :users #, only: [:cre... |
# frozen_string_literal: true
class Voter < ApplicationRecord
before_save { username.downcase! }
self.primary_key = 'username'
has_many :texts, inverse_of: 'author'
has_many :links, inverse_of: 'author'
has_many :comments, inverse_of: 'author'
has_many :jets, inverse_of: 'owner'
has_many :saved_posts
... |
class HomePageController < ApplicationController
def index
if signed_in?
@feed_photos = current_user.feed_photos.order(created_at: 'desc').includes(album: :user).first(10)
end
end
end
|
require_relative 'sliding_piece.rb'
require_relative 'pieces.rb'
require 'byebug'
class Bishop < Piece
include SlidingPiece
attr_reader :move_dirs
def initialize(board, pos, color)
@move_dirs = {:diagonals => true, :straight => false}
super(board,pos, color)
end
end
|
class Article < ApplicationRecord
belongs_to :user
has_many :comments, dependent: :destroy
has_many :has_categories, dependent: :destroy
has_many :categories, through: :has_categories
#validaciones para el titulo del articulo y cuerpo del articulo
validates :title, presence: true, length: { minimum: 2}, unique... |
class EdtfDateValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
errors = value.reject(&:empty?).select { |date| invalid?(date) }
return if errors.to_a.empty?
record.errors.add(attribute, "Invalid EDTF #{'date'.pluralize(errors.size)}: #{errors.join(',')}")
end
def inv... |
# Book order entity
class Order
attr_accessor :book, :reader, :date
def initialize(book, reader, date = Time.new)
@book = book
@reader = reader
@date = date
end
def to_s
"Order: #{@book}, #{@reader}, #{@date}"
end
def hash
@id
end
end
|
Rails.application.routes.draw do
devise_for :users
resources :contacts, only: :index do
get 'errors', on: :collection
end
resources :contact_lists, except: %i[new show destroy]
root to: 'contacts#index'
end
|
require 'tech_docs_gem/version'
require 'middleman'
require 'middleman-autoprefixer'
require 'middleman-sprockets'
require 'middleman-syntax'
require 'tech_docs_gem/unique_identifier_generator'
require 'tech_docs_gem/unique_identifier_extension'
require 'tech_docs_gem/tech_docs_html_renderer'
require 'table_of_conte... |
module OnTheWay
class MapquestDirections
include Endpoint
def initialize(start_point, end_point)
@start_point = start_point
@end_point = end_point
end
def url
"/directions/v2/route?key=#{mapquest_api_key}&ambiguities=ignore&from=#{start_location}&to=#{end_location}&#{options}"
... |
module GamestateManagement
require 'yaml'
def save_game(name, word, dash_row, gallow, failure_count, used_letters)
# create save_games directory or check existance
directory_path = 'save_games'
Dir.mkdir(directory_path) unless File.exist?(directory_path)
# create file to save game
puts 'Enter ... |
# frozen_string_literal: true
shared_examples "manage opinions permissions" do
context "when authorization handler is Everyone" do
before do
component = opinion.component
visit ::Decidim::EngineRouter.admin_proxy(component.participatory_space).edit_component_permissions_path(component.id)
end
... |
require 'test_helper'
class NewArticleTest < ActionDispatch::IntegrationTest
def setup
@user = User.create(username: "Chris", email: "Chris@example.com", password: "password", admin: true)
end
test "create a new article" do
sign_in_as(@user, "password")
get create_article_path
assert_templa... |
require 'pry'
class String
def sentence?
self.end_with?(".")
end
def question?
self.end_with?("?")
end
def exclamation?
self.end_with?("!")
end
# def count_sentences
# self.split("." || "?" || "!").length
# end
def count_sentences
count = 0
array = self.split(" ")
array.each ... |
class CreateLocations < ActiveRecord::Migration[5.1]
def change
create_table :locations do |t|
t.string :name
t.string :address
t.string :phone
t.string :open_time
t.text :description
t.float :radius
t.boolean :status
t.integer :max_table
t.integer :sum_rate
... |
def translate(sentence)
latin = sentence.split.map{ |word|
phoneme = word[0, %w(a e i o u).map { |vowel|
"#{word}aeiou".index(vowel)
}.min]
if phoneme.include?("q") || phoneme.include?("Q")
if word[phoneme.length] == "u"
phoneme += "u"
end... |
class CreateParticipate < ActiveRecord::Migration
def change
create_table :participates do |t|
t.string :user, null: false, unique: true
t.string :contest, null: false, unique: true
t.integer :year, null: false, unique: true
t.string :division, null: false, unique: true
... |
json.array!(@graduations) do |graduation|
json.extract! graduation, :id
json.url graduation_url(graduation, format: :json)
end
|
class Hexadecimal
attr_reader :input
def initialize(input)
@input = input
end
def to_decimal
hex_pattern = /^[[:xdigit:]]+$/
if hex_pattern === input
input.to_i(16)
else
return 0
end
end
end |
class RemoveWorkoutIdFromWorkoutDetails < ActiveRecord::Migration[5.2]
def change
remove_column :workout_details, :workout_id
end
end
|
class ApplicationController < ActionController::Base
protect_from_forgery
before_filter :set_page_name
private
def set_page_name
@current_action = action_name
@current_controller = controller_name
@page_name ||= "#{@current_controller.humanize}#{@current_action.humanize}"
end
end
|
# frozen_string_literal: true
class Api::V1::CompaniesController < ApplicationController
before_action :set_company, only: %i[ show ]
def index
@companies = Company.all
render json: @companies.select(:id, :name)
end
def show
render json: {
id: @company.id,
name: @company.name
}, ... |
class LikesController < ApplicationController
before_action :authenticate_user!
before_action :set_like
def create
@like = current_user.likes.create(review_id: params[:review_id])
redirect_back(fallback_location: root_path)
end
def destroy
@like = Like.find_by(review_id: params[:review_id], user... |
class Interaction < ApplicationRecord
belongs_to :client
belongs_to :artist
has_one :tattoo_information, dependent: :destroy
has_one :conversation, dependent: :destroy
has_many :appointments, dependent: :destroy
scope :booked, -> { where(type: 'Booking') }
scope :inquired, -> { where(type: 'Inquiry') }
... |
require 'spec_helper'
require 'appdirect_logfile'
describe AppdirectLogfile do
describe '#records' do
subject(:logfile) do
described_class.new(io)
end
let(:io) { double('file', lines:[line]) }
let(:line) { double('line') }
it 'parses the log lines' do
record = double('log record')
... |
FactoryGirl.define do
factory :appointment do
start Time.current + Random.new.rand(1..10).hours
status 'free'
cost 100
showing_time 30
user
after(:build) do |appointment|
appointment.phone = appointment.user.phone if appointment.user
end
trait :with_organization do
organi... |
class Cgo < Formula
desc "A terminal based gopher client"
homepage "https://github.com/kieselsteini/cgo"
url "https://github.com/kieselsteini/cgo/archive/ca69bbb.tar.gz"
version "0.4.1"
sha256 "fda68e99e5aaa72198183c19264d61cfaa3e90a16f60c0150e1f79083499d170"
depends_on "telnet"=> :optional
depends_on "m... |
#--
# Copyright (c) 2010-2013 Michael Berkovich, tr8nhub.com
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, mod... |
class PostsController < ApplicationController
rescue_from ActiveRecord::RecordNotFound do |exception|
render :json => { :success => false }, :status => :not_found
end
# GET /posts
# GET /posts.ext_json
def index
@posts =Post.all
respond_to do |format|
format.html # index.html.erb (no d... |
class BoatsController < ApplicationController
before_action :authenticate_user!
before_action :owned_boat, only: [:edit, :update, :destroy]
before_action :set_boat, only: [:show, :edit, :update, :destroy]
def index
@boats = Boat.all
end
def show
@boat = Boat.find(params[:id])
end
def new
@... |
# frozen_string_literal: true
require 'net/http'
require 'uri'
module JsonWebTokenModule
class JsonWebToken
def self.verify(token)
JWT.decode(
token,
nil,
true, # Verify the signature of this token
algorithm: 'RS256',
iss: Rails.application.credentials.dig(:auth0, :d... |
require "asmaa/version"
require 'sqlite3'
module Asmaa
@db = SQLite3::Database.new File.join(File.dirname(File.expand_path(__FILE__)), 'asmaa.db')
def self.get_gender name
query = @db.prepare "SELECT * FROM names WHERE first_name=?"
first_name = name.split()[0]
query.bind_param 1, first_name
... |
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel... |
class AddMinPriceToSurveys < ActiveRecord::Migration
def change
add_column :surveys, :min_price, :integer
end
end
|
require 'delegate'
# present a person for the view
class PersonPresenter < SimpleDelegator
def bio_html
html_from(bio)
end
def twitter_handle
"@#{twitter}"
end
def twitter_url
"http://twitter.com/#{twitter}"
end
private
def html_from(markdown)
Kramdown::Document.new(markdown || '').... |
require 'rails_helper'
RSpec.describe 'Users API', type: :request do
# rubocop:disable Style/BlockDelimiters
let(:valid_attributes) {
{ name: 'louiss', email: 'louiss@yahoo.com',
password: 'password' }
}
# rubocop:enable Style/BlockDelimiters
before { post '/api/v1/users', params: valid_attributes ... |
require 'rails_helper'
feature "Membership" do
scenario "User can see their membership" do
user = User.create(name: "Ian Douglas", email: "ian@turing.io", password: "password")
allow_any_instance_of(ApplicationController).to receive(:current_user).and_return(user)
visit '/account/membership'
expec... |
class CouncilsProperties < ActiveRecord::Base
attr_accessible :council_id, :property_id
belongs_to :council
belongs_to :property
end
|
class CreateDelays < ActiveRecord::Migration[5.0]
OLD_AVERAGE_DELAYS = {
"Shortly after payment" => "shortly",
"See description / T-O-S" => "see_description",
"3 days at most" => "three_days",
"One week at most" => "one_week",
"2 weeks at most" => "two_weeks",
"One month at most" => "one_mo... |
#encoding: utf-8
class Inscricao < ActiveRecord::Base
attr_accessible :atividade_id, :nome, :cpf, :rg, :celular, :email, :endereco, :numero, :complemento, :bairro, :cep, :matricula, :tamanho, :contrato, :termo, :adessao
attr_accessor :contrato
attr_accessor :termo
attr_accessor :adessao
validate :termos_ace... |
begin
require 'jeweler'
Jeweler::Tasks.new do |gemspec|
gemspec.name = "rsolr-em"
gemspec.summary = "EventMachine Connection for RSolr"
gemspec.description = "EventMachine/async based connection driver for RSolr -- compatible with Ruby 1.8"
gemspec.email = "goodieboy@gmail.com"
gemspec.homepage ... |
class AddTypeToOrders < ActiveRecord::Migration
def change
add_column :orders , :readyorpo , :string
end
end
|
class PhotoGallery
attr_reader :title, :photos, :filter, :page, :tag, :total_pages
def initialize(params, photo_filter=nil)
if photo_filter
@title = photo_filter.title
@photos = photo_filter.photos
@filter = photo_filter.filter
end
# TODO: fix this
@page_size = PhotosController:... |
#
# Author:: Kaustubh Deorukhkar (<kaustubh@clogeny.com>)
# Copyright:: Copyright (c) 2013 Opscode, Inc.
#
require 'chef/knife/cloud/service'
require 'chef/knife/cloud/exceptions'
class Chef
class Knife
class Cloud
class FogService < Service
attr_accessor :fog_version
def initialize(optio... |
class CreateBoatTypeModifications < ActiveRecord::Migration[5.0]
def change
create_table :boat_type_modifications do |t|
t.integer :boat_type_id
t.integer :boat_option_type_id
t.string :name
t.string :description
t.boolean :is_active, default: true
t.string :bow_view
t.st... |
class BookSubjectsController < ApplicationController
before_action :set_book_subject, only: [:show, :edit, :update, :destroy]
# GET /book_subjects
# GET /book_subjects.json
def index
@book_subjects = BookSubject.all
end
# GET /book_subjects/1
# GET /book_subjects/1.json
def show
end
# GET /bo... |
module AEditor
class IntegrityError < Exception; end
module Helpers
def check_integer(int)
raise TypeError, 'expected integer' unless int.kind_of?(Integer)
end
def check_boolean(bool)
raise TypeError, 'expected boolean' unless bool == true or bool == false
end
def check_valid_utf8(str)
raise TypeError unless st... |
class Support::Schools::HeadteacherController < Support::BaseController
before_action :set_school
attr_reader :form, :school
def edit
@form = Support::School::ChangeHeadteacherForm.new(school: school, **contact_details)
end
def update
@form = Support::School::ChangeHeadteacherForm.new(school: schoo... |
require 'open3'
require 'colorize'
require 'lock'
def sheepdog_ping(tag,r)
host = Socket.gethostname
ok = redis_ping(r,host)
errval = !ok
event = {
time: Time.new.to_s,
elapsed: 0,
user: ENV['USER'],
host: host, # sending host
command: 'sheepdog_ping.rb',
tag: tag,
stdout: "",
... |
class Reminder < ApplicationRecord
include ApplicationHelper
belongs_to :user
before_save :send_notification_reminder
validates :title, uniqueness: true
validates :description, uniqueness: true
def send_notification_reminder
registration_id = self.user.fcm_token
puts "starttttttt"
send_notific... |
#Add remote data source and pull in stories from Reddit, Mashable and Digg.
# http://mashable.com/stories.json
#http://www.reddit.com/r/aww/.json
# These stories will also be upvoted based on our rules. No more user input!
# Pull the json, parse it and then make a new story hash out of each story(Title, Category, ... |
module Nails
class Router
def clear()
@controller = nil
@method = nil
@route_table = []
end
def initialize()
clear
end
# A url in the router such as /user/:user_id/post/:post_id gets converted to a regular expression
# where each param gets converted to a named grou... |
class PostSearchResultsController < ApplicationController
def show
if params[:q]
keywords = params[:q].split(/[\p{blank}\s]+/)
groupings = keywords.reduce({}) do |acc, elem|
acc.merge(elem => { title_or_body_or_tags_name_cont: elem })
end
posts = Post.ransack(combinator: 'and', gro... |
require File.dirname(__FILE__) + '/../spec_helper'
describe 'Event' do
describe 'when triggered' do
it 'should create an instance' do
lambda { RandomEvent.trigger }.should change(RandomEvent, :count).from(0).to(1)
end
describe 'with a source' do
it 'should create an instance with the speci... |
class QuestionsController < ApplicationController
def index
@questions = Question.order(created_at: :desc)
end
def show
@question = Question.find(params[:id])
@body = Redcarpet::Markdown.new(Redcarpet::Render::HTML).render(@question.body)
@answer = Answer.new
@answers = Answer.where(question_... |
module Awspec::Type
class Glue < ResourceBase
def initialize(name)
super
@display_name = name
end
def resource_via_client
@resource_via_client ||= get_catalog(@display_name)
end
def id
@id ||= @display_name
end
def has_catalog?(catalog)
check_existence
... |
require 'optparse'
require 'lol_dba/sql_generator'
module LolDba
class CLI
class << self
def start
options = {}
OptionParser.new do |opts|
opts.on('-d', '--debug', 'Show stack traces when an error occurs.') { |v| options[:debug] = v }
opts.on_tail("-v", "--version", "Sh... |
# => Author:: DanAurea
# => Version:: 0.1
# => Copyright:: © 2016
# => License:: Distributes under the same terms as Ruby
##
## Controls the data flow into an item object and updates the view whenever data changes.
##
class Controller
##
## Initialisation
##
def initialize ()
@title = "... |
require 'money'
require_relative './item_presenter.rb'
class ItemsPresenter
# The following has been added to resolve deprecation warnings
Money.rounding_mode = BigDecimal::ROUND_HALF_UP
Money.locale_backend = :i18n
I18n.locale = :en
def initialize(items)
@items = items
end
def show_all
header ... |
class ChangeBaknIdToStockHolds < ActiveRecord::Migration[5.0]
def change
change_column(:stock_holds, :bank_id, :string, :limit => 50)
rename_column :stock_holds, :bank_id, :bank_name
end
end
|
class ChangeLastDoneFormatForChores < ActiveRecord::Migration
def self.up
change_table :chores do |t|
t.change :last_done, :date
end
end
def self.down
change_table :chores do |t|
t.change :last_done, :datetime
end
end
end
|
$:.unshift File.join(File.dirname(__FILE__), "..", "lib")
require 'pdf/merger'
describe PDF::Merger do
before(:each) do
@pdf = PDF::Merger.new
@pdf.add_file :text_field01, "test_template.pdf"
@pdf.add_file :text_field02, "test_template.pdf"
end
it "should create PDF document" do
@pdf.to_s.should... |
class User < ActiveRecord::Base
belongs_to :race
has_many :dependents
has_one :qualification
has_one :agency, through: :qualification
has_many :applications
has_many :dwellings, through: :applications
validates :email, :presence => true,
:uniqueness => true,
... |
json.array!(@breeders) do |breeder|
json.extract! breeder, :name, :address1, :address2, :city, :state, :zip, :phone, :website, :email
json.url breeder_url(breeder, format: :json)
end
|
require 'rails_helper'
RSpec.describe Referrer::User, type: :model do
before :each do
@user = Referrer::User.create!
end
before :each, with_main_app_user: true do
@main_app_user = User.create!
end
before :each, with_sources: true do
@session = @user.sessions.create!(active_from: 10.days.ago, ac... |
class ApplicationController < ActionController::Base
# protect_from_forgery with: :exception
def current_user
@current_user ||= User.find_by(id: session[:user_id]) if session[:user_id]
end
helper_method :current_user
def authenticate_user!
redirect_to '/login' unless current_user
end
def curren... |
=begin
識別子判定プログラム
compiler.rb
7061-0503 Ryosuke Takata
=end
# 判定用定数(識別子なら1)
EMPTY = 0
ID = "識別子"
# 各種変数
str = ""
token = ""
tokens = []
judges = []
# 区切り文字判定
def isseparater?(ch)
return true if ch.match(/\s|\W/)
return false
end
# ファイル入力
File.open('./test.c', 'r') do |file|
str = file.read
end
# トークン分割... |
require 'test_helper'
class ProductsControllerTest < ActionDispatch::IntegrationTest
include Devise::Test::IntegrationHelpers
setup do
@client = users(:client)
@admin = users(:admin)
end
test 'all can view products' do
get products_path, xhr: true
assert_response :success
end
test 'only ... |
# Raised when executing a SEC.
class Tem::SecExecError < StandardError
attr_reader :line_info
attr_reader :buffer_state, :key_state
attr_reader :trace
def initialize(secpack, tem_trace, buffer_state, key_state)
super 'SEC execution failed on the TEM'
if tem_trace
if tem_trace[:ip]
... |
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe Assertion do
before(:each) do
@valid_attributes = {
:type => ,
:ind => ,
:version => ,
:submitter => ,
:modified => ,
:modifiable => ,
:disputing => ,
:contributor => ,
:tempId => ,... |
require 'game'
describe Game do
subject(:game) { described_class.new(player1, player2, weapons) }
let(:player1) { double :player1, name: 'Ed', choice: :paper, add_score: nil }
let(:player2) { double :player2, name: 'Computer', choice: :paper}
let(:weapons) { double :weapons, compare: nil, result: :paper }
l... |
module Concerns::Help::Association
extend ActiveSupport::Concern
included do
belongs_to :help_category
belongs_to :help_content
accepts_nested_attributes_for :help_content
end
end
|
module Task
module RecordScopes
def generic_effective_in(beginning_col, ending_col, interval)
return where("0 AND 'interval is empty'") if interval.empty?
int_beginning, int_ending = *interval.endpoints
s = scoped
if int_ending != Time::FOREVER
# Beginning column is never null
... |
class PlayersController < ApplicationController
require 'will_paginate/array'
autocomplete :player, :name, display_value: :autocomplete_display, full: true
# GET /players
# GET /players.json
def index
@players = Player.paginate(page: params[:page]).order("name")
@title = "All Players"
end
# GET ... |
class BuyersController < ApplicationController
wrap_parameters format: :json
wrap_parameters :buyer, include: [:first_name, :last_name, :password, :email]
# before_action :set_buyer, only: [:show, :edit, :update, :destroy]
def index
render json: Buyer.all, except: :password_digest
end
def show
buy... |
require 'spec_helper'
describe 'EXIM Trade Events API V1', type: :request do
include_context 'TradeEvent::Exim data'
describe 'GET /v1/trade_events/exim/search' do
let(:params) { { size: 100 } }
before { get '/v1/trade_events/exim/search', params }
subject { response }
context 'when search parame... |
class CreateLeaveResets < ActiveRecord::Migration
def self.up
create_table :leave_resets do |t|
t.date :reset_date
t.integer :reset_type
t.string :reset_remark
t.integer :resetted_by
t.integer :status
t.integer :reset_value
t.integer :employee_count
t.timestamps
... |
FactoryBot.define do
sequence(:email) { |n| "user#{n}@example.com" }
factory :user do
email
password "1234567890"
admin false
end
factory :admin, parent: :user do
id 1
admin true
end
end
|
require 'spec_helper'
describe User do
describe '#profile_incomplete?' do
context 'when user has both home and work zips filled out' do
let!(:user){ create(:user, home_zip: '90405', work_zip: '90305') }
it 'returns false' do
expect(user.profile_incomplete?).to eq false
end
end
... |
class CreateDonationAdditionalFields < ActiveRecord::Migration
def self.up
create_table :donation_additional_fields do |t|
t.string :name
t.boolean :status
t.boolean :is_mandatory
t.string :input_type
t.integer :priority
t.timestamps
end
end
def self.down
drop_tab... |
class AddTweetBodyToPosts < ActiveRecord::Migration
def change
add_column :posts, :tweet_body, :text
end
end
|
class CreateTaggings < ActiveRecord::Migration
def change
create_table :taggings do |t|
t.references :tag, null: false
t.references :taggable, polymorphic: true, index: true, null: false
t.string :source
t.references :last_updated_by
t.integer :confidence
t.text :notes
t... |
class TransactionBuilder
def initialize(activity, account, transaction_list)
@activity = activity
@account = account
@transaction_list = transaction_list
end
def build_transactions
clear_old_transactions
create_transactions
end
private
def create_transactions
@trans... |
class AddGamesTable < ActiveRecord::Migration[5.1]
def change
create_table :games do |t|
t.string :secret_word
t.string :guesses
end
end
end
|
class PrizeLocal < ActiveRecord::Base
belongs_to :prize
belongs_to :local
attr_accessor :association_should_exist
end
|
class Blog < ApplicationRecord
belongs_to :user
validates :title, uniqueness: {case_sensitive: false}, presence: true
validates :body, uniqueness: {case_sensitive: false}, length: {maximum: 200}, presence: true
# validates :book_name, presence: true
# validates :comment, presence: true
end
|
# Copyright (c) 2014 Mitchell Hashimoto
# Under The MIT License (MIT)
#---------------------------------------------------------------------------
# Copyright (c) Microsoft Open Technologies, Inc.
# All Rights Reserved. Licensed under the Apache License, Version 2.0.
# See License.txt in the project root for license i... |
# frozen_string_literal: true
require 'prometheus/client'
module Vmpooler
class Metrics
class Promstats < Metrics
attr_reader :prefix, :endpoint, :metrics_prefix
# Constants for Metric Types
M_COUNTER = 1
M_GAUGE = 2
M_SUMMARY = 3
M_HISTOGRAM = 4
# Customised ... |
require 'rails_helper'
RSpec.describe Skill, type: :model do
it_behaves_like 'it has a valid factory', :skill
subject { build(:skill) }
describe '#level' do
it 'has a minimum value of 0.0' do
subject.level = -0.1
expect(subject.save).to be_falsey
end
it 'has a maximum value of 100.0' d... |
class User < ActiveRecord::Base
devise :database_authenticatable, :registerable, :confirmable,
:recoverable, :rememberable, :trackable, :validatable, :omniauthable
mount_uploader :avatar, AvatarUploader
has_many :topics, dependent: :destroy
has_many :comments, dependent: :destroy
has_many :messages... |
module RTALogger
class LogTopicWrapper
def initialize(context_id, topic, level = 0)
@context_id = context_id
@topic = topic
level = level - 1
level = 0 if level.negative?
level = 5 if level > 5
self.level = level
end
attr_accessor :progname
attr_accessor :context_i... |
require_relative '../code.rb'
describe "bracket_match?" do
it "returns true" do
expect(bracket_match?("Hi! What is your name again (I forgot)?")).to eq true
end
it "returns false" do
expect(bracket_match?("Hi! What is (your name again? I forgot")).to eq false
end
it "returns false" do
expect(brac... |
module Nlg
class Paragraph
attr_accessor :defaults, :dataset, :sentences
# The parameters, dataset and defaults are both hashes.
# For example:
#
# defaults = { "tense" => "present",
# "verb" => "have",
# "pronoun" => "it",
# "voice" => "a... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.