text stringlengths 10 2.61M |
|---|
class CreateTickets < ActiveRecord::Migration
def change
create_table :tickets do |t|
t.integer :attendee_id, null: false
t.integer :gathering_id, null: false
t.timestamps null: false
end
add_index :tickets, :attendee_id
add_index :tickets, :gathering_id
end
end
|
# encoding: utf-8
require "logstash/devutils/rspec/spec_helper"
require "insist"
require "logstash/filters/hashid"
describe LogStash::Filters::Hashid do
let(:plugin) { described_class.new(config) }
describe 'Full MD5, no timestamp prefix' do
config <<-CONFIG
filter {
hashid {
source =... |
require 'rails_helper'
RSpec.describe UserEvent, type: :model do
describe 'validations' do
it{should belong_to(:user)}
it{should belong_to(:event)}
end
end
|
require 'test_helper'
class TranslateJobTest < ActiveJob::TestCase
describe "basic case works" do
it "can translate from english to spanish" do
content = Content.create(text: "Hello world", from_lang: "en")
::TranslateJob.perform_now(content)
end
end
describe "activerecord submission works" ... |
class CreateCharacters < ActiveRecord::Migration[5.2]
def change
create_table :characters do |t|
t.belongs_to :user
t.string :name, null: false
t.integer :skills, array: true, null: false, default: []
t.integer :lores, array: true, null: false, default: []
t.integer :faith, null: fa... |
class Course < ApplicationRecord
acts_as_taggable_on :tags
has_rich_text :body
has_many :progresses
has_many :users, through: :progresses
has_many :comments, through: :progresses
has_many :exercises, dependent: :destroy
has_one_attached :dataset
has_one_attached :photo
has_many_attached :images
... |
require 'sinatra/base'
require './lib/listings.rb'
require 'sinatra/flash'
require './lib/db_connection.rb'
require './lib/user.rb'
require './lib/listings.rb'
class Makersbnb < Sinatra::Base
enable :sessions
get '/' do
@user = session[:user_id]
erb :'index.html'
end
get '/add_listing' do
erb :'... |
FactoryBot.define do
factory :item do
id {1}
name {"上着"}
introduction {"とても暖かい上着です"}
category_id {3}
brand {"ユニクロ"}
item_condition_id {2}
postage_payer_id {3}
prefecture_code_id {5}
preparation_day_id {1}
posta... |
name 'static_eip'
maintainer 'The Login.gov Team'
maintainer_email 'identity-devops@login.gov'
license 'CC0-1.0'
description 'Automatic EIP association cookbook'
long_description 'Picks an EIP from a configured range and automatically grabs it for the instance based on role'
version '0.2.1'
chef_version '>= 13.0' if re... |
class RestaurantsController < ApplicationController
# GET /restaurants
# GET /restaurants.json
def index
@restaurants = Restaurant.all
if request.xhr?
render @restaurants
else
render :index
end
end
# GET /restaurants/1
# GET /restaurants/1.json
def show
@restaurant = Rest... |
module PUBG
class Player
class Data
class Attributes
def initialize(args)
@args = args
end
def titleId
@args["titleId"]
end
def shardId
@args["shardId"]
end
def createdAt
@args["createdAt"]
end
... |
#!/usr/bin/env ruby
# frozen_string_literal: true
require 'bundler/setup'
require 'vedeu'
class DSLApp
Vedeu.bind(:_initialize_) { Vedeu.trigger(:_refresh_) }
Vedeu.configure do
debug!
log Dir.tmpdir + '/vedeu.log'
run_once!
standalone!
end
Vedeu.interface :test1_interface do
geometry ... |
require 'pry'
module MealFinder
class CLI
def start
puts " -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-"
puts " | |"
puts " | Hello and welcome to the Meal Finder CLI. |"
puts " | ... |
class TaskStatusType < ActiveRecord::Base
attr_accessible :created_by, :description, :name, :updated_by
validates :name, :presence => true, :length => { :minimum => 1 }
validates_uniqueness_of :name
has_many :tasks, :class_name => "Task", :foreign_key => 'task_status_id'
scope :pending, where(:name => 'Pending')
... |
class Square
attr_accessor :color, :character
def initialize
@character = nil
@color = nil
end
def empty?
@character == nil
end
end |
# Huffman Encoder takes a string and encodes it
module Encoder
# takes a string of words, breaks it apart, encodes the words
# returns the words
def self.encode(message, wordList)
input = message.split(" ") # split message into array of words
encodedMessage = "" # this is what the function returns
... |
require "test_helper"
feature "Playlists" do
before do
before_each
visit "/auth/spotify"
end
after do
visit "/auth/signout"
end
GoSpotify::Application::PROVIDERS.each do |provider|
describe provider do
before do
visit "/auth/#{provider}"
@user = UserRepository.all.firs... |
require 'rails_helper'
RSpec.describe BlogPost, type: :model do
let(:blog_post) { FactoryBot.create(:blog_post) }
it 'has a valid factory' do
expect(blog_post).to be_valid
end
describe 'validations' do
it { should validate_presence_of(:title) }
it { should validate_length_of(:title).is_at_least(2... |
class AddEmpIdToRequisitions < ActiveRecord::Migration
def change
add_reference :requisitions, :emp, index: true
end
end
|
module GPIO
module BeagleboneBlack
extend Device
VALIDATE_FILE = "/sys/class/gpio/gpiochip96/label"
VALIDATE_VALUE = "chipset_gpio"
MAPPING = :hardware
HARDWARE_PINS = [2,3,4,5,7,14,15,20,26,27,30,31,40,44,45,46,47,48,49,51,60,61,65,66,67,68,69,117,120,121,122,123,125]
SOFTWARE_PINS = [2,3,4,5,7,14,15,20... |
class Tenant
attr_accessor :name, :smoker, :gender, :age
def initialize(options={})
@name = options[:name]
@smoker = options[:smoker]
@age = options[:age]
@gender = options[:gender]
end
end |
# 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 TimeConverter
attr_reader :seconds
def initialize(seconds = 0)
@seconds = seconds
end
def hours
format '%02d', (seconds / 3600)
end
def minutes
format '%02d', ((seconds % 3600) / 60)
end
def seconds_remaining
format '%02d', (seconds % 60)
end
def seconds_to_s
"#{hours}:... |
require 'rspec'
require 'deck'
describe Deck do
subject(:deck) { Deck.new }
describe "#initialize" do
it "creates a deck of 52 cards" do
expect(deck.cards).to be_a(Array)
expect(deck.cards.size).to be(52)
expect(deck.cards.sample).to be_a(Card)
end
it "should have the discard pile ... |
class Company < ApplicationRecord
validates :company_name, :fantasy_name, presence: true
validates :email, presence: true, email: true
validates :category_companies, nested_attributes_uniqueness: { field: :category_id }
has_many :category_companies, dependent: :destroy
has_many :categories, through... |
# frozen_string_literal: true
require 'spec_helper'
# FACEBOOK_ACCESS_TOKEN=... rspec spec/facebook_ads/ad_campaign_spec.rb
describe FacebookAds::AdCampaign do
let(:campaign) do
FacebookAds::AdCampaign.new(
id: '120330000008134915',
account_id: '10152335766987003',
buying_type: 'AUCTION',
... |
# p012zmm.rb
class Dummy
# method_missing - Exibe de um modo elegante o erro que é lançado quando um método de uma classe não existe.
def method_missing(m, *args, &block)
puts "Não há nenhum método chamado #{m} aqui."
end
end
Dummy.new.qualquer_coisa
|
class AddAlturaToOrdenclomuls < ActiveRecord::Migration[5.1]
def change
add_column :ordenclomuls, :altura, :string
end
end
|
class Notification < ApplicationRecord
belongs_to :collection
belongs_to :request
validates :message, presence: true
end
|
class CustomersController < ApplicationController
JSON_KEYS = [:id, :name, :register_at, :address, :city, :state, :postal_code, :phone]
def index
customers = Customer.all.as_json(only: JSON_KEYS)
render json: customers, status: :ok
end
private
def customer_params
params.permit(:id, :name, :reg... |
class FixBadParlId < ActiveRecord::Migration
def up
# agenda 26408 has parliament_id of 3 but it should be 1
Agenda.transaction do
a = Agenda.find(26408)
if a.present?
puts "found agenda, updating parliament id"
# update parliament id
a.parliament_id = 1
a.save
... |
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
before_action :configure_permitted_parameters, if: :devise_controller?
include ApplicationHelper
def needs_to_be_admin
unless is_admin?
respond_to do |format|
format.html { redirect_to root_path, :fla... |
require_relative '../acceptance_helper'
feature 'show question' do
given!(:current_user) { create(:user) }
given!(:other_user) { create(:user) }
given!(:question) { create(:question, user: current_user) }
given!(:other_question) { create(:question, user: other_user) }
scenario 'guest view questions' do
... |
require_relative 'computer'
class Game
def self.number_of_times_to_play
tries = 0
while tries < 12 do
puts "This is your number #{tries+1} guess. Game ends after 12 tries."
tries+=1
break
end
end
def self.exact_partial_matches (computer_code, user_guess)
... |
class ItaTaxonomyQuery < Query
def initialize(options = {})
super
@q = options[:q].downcase if options[:q].present?
@taxonomies = options[:taxonomies].downcase.split(',') if options[:taxonomies].present?
end
private
def generate_filter(json)
json.filter do
json.bool do
json.must ... |
class EspecsController < ApplicationController
before_filter :authenticate
# GET /especs
# GET /especs.json
def index
@especs = Espec.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @especs }
end
end
# GET /especs/1
# GET /especs/1.json
de... |
class AddChecksumToDropboxFiles < ActiveRecord::Migration
def change
add_column :dropbox_files, :asset_id, :integer, :after => :user_id
add_column :dropbox_files, :checksum, :string, :default => '', :null => false, :after => :size
add_column :dropbox_files, :taken_at, :timestamp, :after => :checksum
end... |
class MultipleProceduresController < ApplicationController
before_action :find_procedures, only: [:incomplete_all, :update_procedures]
def incomplete_all
@note = Note.new(kind: 'reason')
end
def update_procedures
@core_id = @procedures.first.sparc_core_id
status = params[:status]
if status =... |
require 'spec_helper_acceptance'
test_name 'compliance_markup class'
describe 'compliance_markup class' do
let(:manifest) {
<<~EOS
$compliance_profile = 'test_policy'
class test (
$var1 = 'test1'
) {
compliance_markup::compliance_map('test_policy', 'INTERNAL', 'Note')
}
... |
require 'spec_helper'
describe "User pages" do
subject { page }
let!(:admin) { create(:admin) }
let!(:user) { create(:user) }
before do
sign_in_as!(admin)
visit root_path
click_link "Admin"
click_link "Users"
end
describe "creating a new user" do
before { click_link "New User" }
describe "wit... |
class FamilyUserForm
include ActiveModel::Model
attr_accessor :user_id,
:user_email,
:creator_id,
:relation_id
def save
user_id = User.select(:id).find_by(email: user_email).id
Family.create(
user_id: user_id,
creator_id: creator_id,
relat... |
class ClaimantsDetail < BaseForm
acts_as_gov_uk_date :employment_start, :employment_end,
validate_if: :disagree_with_employment_dates?
attribute :claimants_name, :string
attribute :agree_with_early_conciliation_details, :boolean
attribute :disagree_conciliation_reason, :text
attribute :agree_with_employme... |
app = node.run_state[:current_app]
Chef::Log.info("Procfile detected for #{app['id']}, generating upstart scripts")
include_recipe "foreman"
# If we are using unicorn, override it
# FIXME: Move this out of the recipe and into the application?
if `grep -q unicorn #{app['app_root']}/Procfile`
template "#{app['shared... |
# frozen_string_literal: true
class UpdateEntityOperation < BaseOperation
def initialize(record)
@record = record
end
def call(input)
update_record(input)
end
private
attr_reader :record
def update_record(params)
record.update(params)
record
end
end
|
class AddMissingAllDelId < ActiveRecord::Migration
def up
Delegate.transaction do
update_count = 0
Delegate.select("distinct first_name, xml_id").where("all_delegate_id is null").each do |member|
# look for all delegate record
ad = AllDelegate.where(:first_name => member.first_name, :x... |
class CommentsController < ApplicationController
def create
@request = Request.find(params[:request_id])
@comment = @request.comments.new(comment_params)
@comment.user = current_user
if @comment.save
respond_to do |format|
format.html do
flash[:notice] = 'your message was save... |
class Card < ApplicationRecord
belongs_to :group
validates :front, presence: true
validates :back, presence: true
validates :picture, allow_blank: true, image_path: true
end
|
require 'find'
require_relative 'progressbar'
module OggEncode
class OggEncoder
class << self
def oggencdir
@pbar = ProgressBar.new( "Progress", ( count_flacs - count_oggs ) )
Find.find( @options.paths.flac ) do |path|
if FileTest.directory?( path )
Find.prune if File... |
module WordsHelper
def link_to_add_translation_row(name, f, association)
new_object = f.object.send(association).klass.new
new_object.build_translated_word
id = new_object.object_id
fields = f.simple_fields_for(association, new_object, child_index: id) do |builder|
render 'translation_fields', ... |
# encoding: UTF-8
module API
module V1
class Likes < API::V1::Base
namespace :likes do
Like.resource_types.keys.each do |key|
namespace key do
route_param :id do
desc 'Add a like in a given resource (aka. post, learning_track)'
post do
... |
class CreateInventoriesClothes < ActiveRecord::Migration
def change
create_table :inventories_clothes , :id => false do |t|
t.column :inventory_id, :integer
t.column :cloth_id, :integer
t.column :amount, :integer
end
end
end
|
class Address < ApplicationRecord
include Fae::BaseModelConcern
belongs_to :client
def fae_display_field
name
end
def self.for_fae_index
order(:id)
end
end
|
RSpec::Matchers.define :have_create_database_permission do
match do |glue|
glue.has_create_database_permission?(database: @databasename)
end
chain :for_database do |databasename|
@databasename = databasename
end
end
|
require_relative "car"
require_relative "driver"
require_relative "order"
class BaseCollection
attr_reader :items
def initialize
@items = []
end
def all
@items
end
def add(item)
if @items.length == 0
item.id = 1
else
last = @items.last.id + 1
item.id += last
end
... |
class MyProfilePage < SitePrism::Page
element :myprofile_link, :xpath, "//a[@href='/Page/MyProfile' and @class='headerUserProfile']"
element :editprofile_button, :xpath, ".//a[@title='Edit Profile']"
element :showprofile_checkbox, :xpath, ".//*[@id='show_profile']"
element :updateprivacy_button, :xpath,"//a/sp... |
require 'rbconfig'
require 'fileutils'
require 'tmpdir'
require 'rubygems'
require 'rjb'
include FileUtils
Rjb::load(File.join(File.dirname(__FILE__), 'iText-2.1.5.jar'), ['-Djava.awt.headless=true'])
module ITRPDF
class Filler
# == Example
#
# pdf = PDF::Stamper.new("my_template.pdf")
# pdf.text :... |
# frozen_string_literal: true
require 'bolt_spec/files'
require 'bolt/config'
require 'bolt/pal'
module BoltSpec
module PAL
include BoltSpec::Files
def config
conf = Bolt::Config.new
conf[:modulepath] = modulepath
conf
end
def modulepath
[File.join(__FILE__, '..', '..', '..... |
class ReceiversController < ApplicationController
layout 'base'
before_filter :authenticate_user!
before_filter :find_contacts, :only => [:index, :create]
def index
end
def new
@contact_type = params[:contact_type]
respond_to do |format|
format.js do
render :update do |page|
... |
require 'fog/core'
module Fog
module Radosgw
module MultipartUtils
require 'net/http'
class Headers
include Net::HTTPHeader
def initialize
initialize_http_header({})
end
# Parse a single header line into its key and value
# @param [String] chunk a ... |
#!/usr/bin/env ruby
numbers = (1..100).to_a
fizzbuzz = numbers.map do |numbers|
if numbers % 3 == 0 && numbers % 5 == 0
"FizzBuzz"
elsif numbers % 3 == 0
"Fizz"
elsif numbers % 5 == 0
"Buzz"
else
numbers
end
end
puts fizzbuzz
|
module Fakebook
class Engine < ::Rails::Engine
engine_name "fakebook"
isolate_namespace Fakebook
initializer "fakebook.configure_rails_initialization" do |app|
app.middleware.use Fakebook::DataInjectorMiddleware
end
end
end
|
class AddLawUrl < ActiveRecord::Migration
def change
add_column :agendas, :law_url, :string
end
end
|
class Project < ActiveRecord::Base
attr_accessible :description, :end, :name, :start, :project_type
default_scope order: 'created_at DESC'
validates :name, presence: true
end
|
module Antlr4::Runtime
class IntStream
EOF = -1
UNKNOWN_SOURCE_NAME = '<unknown>'.freeze
def consume
end
def la(i)
end
def mark
end
def release(marker)
end
def index
end
def seek(index)
end
def size
end
def source_name
end
end
end |
class Book < ActiveRecord::Base
has_many :users, through: :shelvings
has_many :copies, dependent: :destroy
def self.with_copies_at(locations)
where("books.id in (select distinct(copies.book_id) from copies where copies.location_id in (?))", Array(locations))
end
def self.without_copies_at(locations)
... |
require "yaml"
begin
require "mysql2"
rescue LoadError => e
if require "rubygems"
retry
else
raise e
end
end
module Hector
class ExpressionEngineIdentityAdapter
attr_reader :config, :database, :filename
def initialize(filename = nil)
@filename = filename || Hector.root.join("confi... |
class CreateMeetings < ActiveRecord::Migration[5.1]
def change
create_table :meetings do |t|
t.string :subject
t.text :description
t.string :meeting_time
t.belongs_to :property_manager, foreign_key: true
t.belongs_to :tenant, foreign_key: true
t.timestamps
end
end
end
|
# 18章はFile / Dir(ファイル / ディレクトリ) クラス
require "find"
# 1. Rubyが利用するライブラリのファイル名を出力するメソッド
def print_libraries
$:.each do |path|
next unless FileTest.directory?(path)
Dir.open(path) do |dir|
dir.each do |name|
if name =~ /\.rb$/i
puts name
end
end
end
end
end
print_lib... |
require "neovim/logging"
require "neovim/connection"
require "neovim/message"
module Neovim
# @api private
class EventLoop
include Logging
def self.tcp(host, port)
new Connection.tcp(host, port)
end
def self.unix(path)
new Connection.unix(path)
end
def self.child(argv)
... |
require_relative('../db/sql_runner')
require_relative('./album')
class Artist
attr_reader :id
attr_accessor :name
def initialize(options)
@id = options['id'].to_i if options['id']
@name = options['name']
end
def save
sql = "INSERT INTO artists (name) VALUES ($1) RETURNING *"
values = [@name... |
class Profile < ApplicationRecord
belongs_to:admin
belongs_to:genre
belongs_to:kind
validates :prof, presence: true,length: { maximum: 200 }
validates :num, numericality: { only_integer: true } # 数値のみ有効
validates :place, presence: true
mount_uploader :image, ImageUploader
end
|
desc 'Generate a new project at dir=foo'
task :generate do
# Generate the new 'dir' if it's not already created
system "mkdir #{(ENV['dir'])}" unless File.exists?(ENV['dir'])
# Archive the current HEAD to 'dir'
system "git archive HEAD | (cd #{ENV['dir']} && tar -xvf -)"
# Remove this rake task and the ... |
# frozen_string_literal: true
RSpec.describe 'User Role Update Request', type: :request do
include_context 'with json response'
include_context 'with branch location'
include_context 'with user token'
subject(:update_role!) do
patch "/api/users/#{user.id}", params: params, headers: headers
end
let(:u... |
require "rails_helper"
RSpec.feature "Company Signup Page", type: :feature do
describe "As a guest user, I" do
include Capybara::DSL
let! (:state) {
State.create(
abbr: "CO",
id: 14
)
}
let! (:usa_city1) {
UsaCity.create(
name: "Denver",
state_id: 1... |
class AuthenticatedController < ApplicationController
include Foyer::Controller::Helpers
before_filter :authenticate_user!
def index
render text: 'success'
end
end
|
require('minitest/autorun')
require("minitest/rg")
require_relative("../songs.rb")
require_relative("../rooms")
class SongTest < MiniTest::Test
def setup
@song1 = Song.new("Oklahoma")
@song2 = Song.new("Twinkle little star")
@song3 = Song.new("Battery")
@song4 = Song.new("Swamped")
@song_list... |
require 'nokogiri'
require 'awesome_print'
class Device
def initialize(sourcexml)
@doc = Nokogiri::XML(sourcexml)
end
def method_missing(called_name)
xmlname = called_name.upcase
xmlnode = @doc.xpath("//value[@id='#{xmlname}']")
raise KeyError, "no data for #{called_name}" unless(xmlnode.length>... |
class ApplicationController < ActionController::Base
def current_user
User.where(id: session[:user_id]).first
end
helper_method :current_user
end
|
class ActiveStorage::BlobsController < ActiveStorage::BaseController
include Rails.application.routes.url_helpers
before_action :authenticate_user!
before_action :authorize_user
include ActiveStorage::SetBlob
rescue_from CanCan::AccessDenied do
redirect_to not_permitted_path(service: 'facilities_manageme... |
class AddCreatorsUsersToEvents < ActiveRecord::Migration
def change
add_column :events, :creator_id, :integer
add_index :events, :creator_id
end
end
|
require 'rspec'
require_relative '../lib/connect_four'
describe ConnectFour do
let(:game){ ConnectFour.new(false, false) }
let(:comp_game){ ConnectFour.new(true, false) }
let(:auto_game){ ConnectFour.new(true, true) }
describe "#initialize" do
it "should initialize a blank board" do
expe... |
class AddFingerprintToGalleryItems < ActiveRecord::Migration
def change
add_column :gallery_items, :fingerprint, :string
end
end
|
class MealPlanMailer < ActionMailer::Base
default from: "from@cookingwithruby.com"
def meal_week_plan user, pdf
@user = user
attachments['plan for the week.pdf'] = {
mime_type: 'application/pdf',
content: pdf
}
mail to: @user.email, subject: t( 'mail.meal_plans_for_week' )
... |
if defined?(ChefSpec)
ChefSpec::Runner.define_runner_method(:collectd_plugin)
def add_collectd_plugin(plugin)
ChefSpec::Matchers::ResourceMatcher.new(:collectd_plugin, :add, plugin)
end
end
|
module ApplicationHelper
def time_ago_in_words(date, prefix='')
if date.future?
content = l(date)
else
content = super(date) +' '+ t(:ago)
content = "<span class='time-ago'>#{prefix} #{content}</span>" unless prefix.blank?
end
raw(content)
end
def url_for(options = nil)
if o... |
require_relative 'spec_helper'
describe Position do
subject(:position) { Position.new(rover_position) }
let(:rover_position) { "1 1 #{orientation}" }
context "when facing north" do
let(:orientation) { "N" }
# its(:north?) { should be_true }
# its(:east?) { should be_false }
# its(:south?) { sh... |
#!/usr/bin/ruby
#part 9
## Worked with Luke Woodruff
## http://pastebin.com/tk91Rxee
class Numeric
@@currencies = {'dollar' => 1, 'yen' => 0.013, 'euro' => 1.292, 'rupee' => 0.019}
def method_missing(method_id)
singular_currency = method_id.to_s.gsub(/s$/,'')
if @@currencies.has_key?(singular_currency)
... |
module Json
class << self
def valid?(file)
JSON.parse(file)
return true
rescue JSON::ParserError => e
return false
end
def generate(level, content)
begin
file_path = "#{Dir.pwd}/result/level#{level}_#{Time.now.to_i}.json"
File.open(file_path, "w") do |... |
require 'set'
require 'cerealizer/cerealizer_exception'
module Cerealizer
module FixedLengthArrayMethods
def self.string_partitions(string_length, n)
return 1 if string_length == 0 or n == 1
return n if string_length == 1
@@sp||={}
@@sp[[string_length,n]]||=begin
(0..string_length... |
class AddTechnicalFileToObservations < ActiveRecord::Migration[5.1]
def change
add_column :observations, :technical_file, :string
end
end
|
# require_relative 'questions_database'
# require_relative 'question'
# require_relative 'user'
# require_relative 'save'
class Reply
include Save
attr_accessor :id, :question_id, :parent_id, :body, :author_id
def self.find_by_author_id(author_id)
raw_data = QuestionsDatabase.instance.execute(<<-SQL, autho... |
# frozen_string_literal: true
require "rack"
require "json"
require "digest"
class Shrine
module Plugins
# The `upload_endpoint` plugin provides a Rack endpoint which accepts file
# uploads and forwards them to specified storage. On the client side it's
# recommended to use [Uppy] for asynchronous uplo... |
require 'workling/remote/invokers/base'
#
# A threaded polling Invoker.
#
# TODO: refactor this to make use of the base class.
#
module Workling
module Remote
module Invokers
class ThreadedPoller < Workling::Remote::Invokers::Base
cattr_accessor :sleep_time, :reset_time
... |
# frozen_string_literal: true
module Dry
module Monads
# Represents a value which can exist or not, i.e. it could be nil.
#
# @api public
class Maybe
include Transformer
extend Core::ClassAttributes
defines :warn_on_implicit_nil_coercion
warn_on_implicit_nil_coercion true
... |
class AddReactedOnToReactions < ActiveRecord::Migration[5.2]
def change
remove_reference :reactions, :geo_cache
remove_reference :reactions, :comment
remove_reference :reactions, :reply
add_reference :reactions, :reacted_on, polymorphic: true, index: true, type: :uuid
# change_column :reactions, :... |
class EvaluableCompetency < ActiveRecord::Base
attr_accessible :category, :name
COMPETENCY_TYPES = [
["professional", "professional"],
["personal", "personal"],
["social", "social"],
]
validates_inclusion_of :category, :in => COMPETENCY_TYPES.map { |disp, value| value }
end
|
require 'rails_helper'
RSpec.describe LineItem, type: :model do
it { is_expected.to belong_to(:protocol) }
it { is_expected.to belong_to(:arm) }
it { is_expected.to belong_to(:service) }
it { is_expected.to have_many(:visit_groups) }
it { is_expected.to have_many(:visits).dependent(:destroy) }
it { is_ex... |
class RemoveColumnsFromItems < ActiveRecord::Migration[5.2]
def change
remove_column :items, :status
remove_column :items, :prefectures
remove_column :items, :delivery_date
remove_column :items, :delivery_method
end
end
|
require 'spec_helper'
describe Price do
it { should validate_presence_of(:amount) }
it { should validate_presence_of(:currency) }
it { should allow_value(0.02, 1234.45).for(:amount) }
it { should_not allow_value('asdfjkl', '0.3').for(:amount) }
it { should ensure_inclusion_of(:currency).in_array(%w(USD RUB E... |
module GTD::BreakActions
class Ding < Base
def perform
#fork this off so we dont have to wait for the sound to finish before
#proceeding
fork do
`paplay --volume=50000 /usr/share/sounds/freedesktop/stereo/complete.oga`
end
end
end
end
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.