text stringlengths 10 2.61M |
|---|
require "application_system_test_case"
class PersonCocoonsTest < ApplicationSystemTestCase
setup do
@person_cocoon = person_cocoons(:one)
end
test "visiting the index" do
visit person_cocoons_url
assert_selector "h1", text: "Person Cocoons"
end
test "creating a Person cocoon" do
visit perso... |
class AddApplicationIdToForumTopic < ActiveRecord::Migration
def change
add_column :tr8n_forum_topics, :application_id, :integer
add_index :tr8n_forum_topics, [:application_id], :name => :tr8n_fortop_app_id
end
end
|
class Api::V1::TokensController < ApiController
def create
if exchange_token = Token.where(type: params[:exchange_token]).first
token = Token.create!(user: exchange_token.user, token: SecureRandom.hex(32))
render :json, {message: :ok, data: {token: token.code}}
else
head :forbidden
end
... |
class Admin::LoansController < ApplicationController
before_filter :require_admin_login
# GET /admin/admins
# GET /admin/admins.json
def index
@admin_loans = Loan.pending
end
# # GET /admin/admins/1
# # GET /admin/admins/1.json
# def show
# @admin_admin = Admin.find(params[:id])
# end
# # ... |
class CreateDebits < ActiveRecord::Migration
def change
create_table :debits do |t|
t.string :emailcurrentuser
t.string :emailuser2
t.float :betrag
t.date :datum
t.string :info
t.boolean :gezahlt
t.timestamps
end
end
end
|
class Gword < ApplicationRecord
has_many :translations
has_many :vwords, through: :translations
has_many :comments
validates :entry, presence: true
end
|
#!/usr/bin/env ruby
require "cgi"
require "json"
require_relative "../fileserver"
class ServerHalt < StandardError
attr_reader :http_status
def initialize(http_status)
@http_status = http_status
end
end
begin
ENV["REQUEST_METHOD"] == "OPTIONS" and raise ServerHalt.new(:ok)
query = CGI.parse(ENV["... |
name 'ms-cpp-redistributable'
maintainer 'NetSrv Consulting Ltd.'
maintainer_email 'enquiries@netsrv-consulting.com'
license 'Apache License, Version 2.0'
description 'Installs/Configures ms-cpp-redistributable'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
ver... |
class UsuariosController < ApplicationController
def index
@usuarios = Usuario.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @usuarios }
end
end
def show
@usuario = Usuario.find(params[:id])
respond_to do |format|
format.html # s... |
class MainiAuthCreateDevices < ActiveRecord::Migration
def change
create_table(:devices) do |t|
<%= migration_data -%>
t.timestamps
end
add_index :devices, :authentication_token
end
end
|
require File.dirname(__FILE__) + '/../test_helper'
class UserSessionsControllerTest < ActionController::IntegrationTest
#setup :activate_authlogic
context "given data" do
setup do
@admin = Factory :admin_user
@user = User.new(:email => 'someone@example.com', :password => 'Password123', :password... |
# Your code goes here!
class Anagram
attr_accessor :word_finder
def initialize(word_finder)
@word_finder = word_finder
end
def match(word_array)
word_array.select {|word| word.split("").sort == @word_finder.split("").sort }
end
end |
class Map < ActiveRecord::Base
attr_accessible :user, :server, :points, :likes
has_one :user
belongs_to :server
has_many :likes
has_many :points
def find_points_by(node)
self.points.find_all_by_icon("/assets/tiles/#{node}.png")
end
end
|
require 'spec_helper'
RSpec.describe TelevisionShow do
describe "initialize" do
it 'has a title' do
show = TelevisionShow.new("Friends", "NBC", "1994", "Friends in NYC", "Comedy")
expect(show.title).to eq("Friends")
end
it 'has a network' do
show = TelevisionShow.new("Friends", "NBC",... |
FactoryGirl.define do
factory :user do
username "Taylor"
password "password"
role 0
end
factory :avatar do
name "Legolas"
image_url "blahblah"
skill_set
end
factory :skill_set do
strength 10
dexterity 10
intelligence 10
speed 10
money 10
health 10
end
fa... |
class CreateUsers < ActiveRecord::Migration
def change
create_table :users do |t|
t.string :username, null: false
t.string :password_hash, null: false
t.timestamps null: false
end
# Make the username unique
# (so you cannot create multiple accounts with the same username)
a... |
# encoding: utf-8
#
# This file is part of the mamertes gem. Copyright (C) 2013 and above Shogun <shogun@cowtech.it>.
# Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php.
#
# Yet another command line manager.
module Mamertes
# This exception is raised when somet... |
# frozen_string_literal: true
class Gossip
attr_reader :author, :content
def initialize(author, content)
@author = author
@content = content
end
def save
CSV.open('./db/gossips.csv', 'ab') do |csv|
csv << [@author, @content]
end
end
def self.all
all_gossips = []
CSV.read('.... |
# frozen_string_literal: true
require '../lib/pieces/king.rb'
describe King do
let(:white_king) { King.new(:white) }
let(:black_king) { King.new(:black) }
describe '#init' do
context 'when kings spawn' do
it 'has unique symbol' do
expect(white_king.symbol).to eq(" \u265a ")
expect(blac... |
class BooksController < ApplicationController
before_action :set_book, only: [:show, :edit, :update, :destroy]
# GET /books
def index
# With default scope
if params[:user_id]
if current_user && current_user.id == params[:user_id].to_i
@books = Book.where(user_id: params[:user_id]).order(:na... |
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe Organization, type: :model do
it 'is valid with name and user' do
user = create(:user)
organization = build(:organization, name: 'Ruby Conf', user: user)
organization.valid?
expect(organization.errors.full_messages).to be_blank
en... |
class SiteViewsController < ApplicationController
before_action :set_site_view, only: [:show, :edit, :update, :destroy]
# GET /site_views
# GET /site_views.json
def index
@site_views = SiteView.all
end
# GET /site_views/1
# GET /site_views/1.json
def show
end
# GET /site_views/new
def new
... |
require 'rails_helper'
describe 'Reporting Relationship Requests', type: :request, active_job: true do
let(:department) { create :department }
let(:user) { create :user, department: department }
let(:transfer_user) { create :user, department: department }
let(:transfer_note) { Faker::Lorem.characters(10) }
l... |
FactoryBot.define do
factory :character do
first_name { Faker::Name.first_name }
last_name { Faker::Name.last_name }
level { rand(1..10) }
speciality { Faker::Games::DnD.klass }
race { Faker::Games::DnD.race }
association :user
end
end
|
require 'aws/s3'
module IQ::Storage::Adapters # :nodoc:
class S3Config
# attr_accessor :access_key_id, :secret_access_key, :use_ssl, :bucket_name
#
# def initialize(options)
# options ||= {}
# options.assert_valid_keys(:access_key_id, :secret_access_key, :bucket_name, :use_ssl)
# raise ArgumentE... |
# -*- mode: ruby -*-
# vi: set ft=ruby :
# puts intro
puts "\n"
title = "Catapult Release Management - https://github.com/devopsgroup-io/catapult-release-management"
length = title.size
padding = 5
puts "+".ljust(padding,"-") + "".ljust(length,"-") + "+".rjust(padding,"-")
puts "|".ljust(padding) + title ... |
require 'json'
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 ServicereqsController < ApplicationController
before_action :set_servicereq, only: [:show, :edit, :update, :destroy]
# GET /servicereqs
# GET /servicereqs.json
def index
@servicereqs = Servicereq.all
end
# GET /servicereqs/1
# GET /servicereqs/1.json
def show
end
# GET /servicereqs/new
... |
class InterpretRequestLogTestClient < InterpretRequestLogClient
def initialize(options = {})
super(options)
@expected_cluster_status = 'yellow'
@refresh_on_save = true
end
def self.index_name
'tests-interpret_request_log'.freeze
end
def index_alias_name
"#{InterpretRequestLogTestClient.... |
# frozen_string_literal: true
# The XmlMapper 'namespace'
module XmlMapper
# An XmlResource mixin
module XmlResource
extend ActiveSupport::Concern
# rubocop:disable Metrics/BlockLength
class_methods do
# rubocop:enable Metrics/BlockLength
def root_element
@element ||= ElementDeclar... |
## What is enumerable?
# Ruby module (collection of methods and constants)
# can be mixed in to other classes
# the methods of the module are available in the class it is mixed into
# holds methods like map & each
# it is mixed into Array & Hash classes
## each method
# use each when you want to run some block of cod... |
Sequel.migration do
up do
add_column :articles, :image_url, String
end
down do
drop_column :articles, :image_url
end
end
|
# Tag Cloud for Octopress, modified by pf_miles, for use with utf-8 encoded blogs(all regexp added 'u' option).
# modified by alswl, tag_cloud -> category_cloud
# modified by psjay, fixed wrong category url bug.
#
# Category List for Octopress
# =======================
#
# Introduction
# ------------
# Easy output cat... |
class AddArtistIdToVideos < ActiveRecord::Migration
def change
add_column :videos, :artist_id, :integer
add_column :videos, :soundcloud_url, :string
add_column :videos, :featured_artists, :string
end
end
|
class CreateUniversities < ActiveRecord::Migration[5.0]
def change
create_table :universities do |t|
t.string :name, null: false
t.string :slug, null: false
t.string :website
t.string :phone
t.text :address, null: false
t.timestamps null: false
end
end
end
|
require 'spec_helper'
require 'belafonte/helpers/meta_data'
module Belafonte
module Helpers
describe MetaData do
let(:dummy) {Object.new.extend(described_class)}
describe '#title' do
it 'gets the title from the class' do
expect(dummy.class).
to receive(:info).
... |
class ExpenseSources < ActiveRecord::Migration
def change
create_table :expense_sources do |t|
t.string :source
t.references :user
t.timestamps
end
end
end
|
module MomentumCms
module Generators
class InstallGenerator < Rails::Generators::Base
source_root File.expand_path('../templates', __FILE__)
class_option :model, optional: true, type: :string, banner: 'model',
desc: "Specify the model class name if you will use anything other than ... |
require 'spec_helper'
describe SalarySummary do
it 'has a version number' do
expect(SalarySummary::VERSION).not_to be nil
end
it 'sets MongoDB client logging mechanism' do
subject = Class.new
expect(
Persisty::Databases::MongoDB::Client
).to receive(:set_database_logging).once
subjec... |
# frozen_string_literal: true
require 'jiji/test/test_configuration'
require 'jiji/composing/container_factory'
describe Jiji::Composing::ContainerFactory, '#instance' do
it '唯一のインスタンスを返す' do
factory = Jiji::Composing::ContainerFactory.instance
expect(Jiji::Composing::ContainerFactory.instance).to eq(factor... |
# encoding: utf-8
require 'rubygems'
require 'bundler'
begin
Bundler.setup(:default, :development)
rescue Bundler::BundlerError => e
$stderr.puts e.message
$stderr.puts "Run `bundle install` to install missing gems"
exit e.status_code
end
require 'rake'
require 'rspec'
require 'jeweler'
Jeweler::Tasks.new do ... |
# Generated by jeweler
# DO NOT EDIT THIS FILE
# Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = %q{flvorflv}
s.version = "0.1.0"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_versi... |
class Medication < ActiveRecord::Base
belongs_to :user
belongs_to :profile_medications
belongs_to :profiles, through: :profile_medications
end
|
# == Schema Information
#
# Table name: actors
#
# id :integer not null, primary key
# name :string
# dob :string
# bio :text
# image_url :string
# created_at :datetime not null
# updated_at :datetime not null
#
require 'rails_helper'
describe 'Actor' do
... |
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
# Create and configure the VM(s)
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# Assign a friendly name to this host VM
config.vm.hostname = "docker-host-vm"
# Skip checking for an updated Vagrant box
config.vm.box_check_update ... |
class Pos
def initialize(x,y)
@x, @y = x, y
end
def x
@x
end
def y
@y
end
def distance_to(other)
return Math.sqrt((other.x - @x)*(other.x - @x) + (other.y - @y)*(other.y - @y))
end
end
|
# vi: sw=2: ts=2
require 'sinatra'
get '/hello/:name' do |n|
"Hello #{n}!"
end
|
class CreateCalibrations < ActiveRecord::Migration[4.2]
def up
add_column(:readings, :original_temp, :integer)
add_index(:readings, :temp)
add_index(:readings, :created_at)
add_index(:readings, :user_id)
add_index(:readings, :sensor_id)
add_index(:readings, :violation)
ActiveRecord::Base... |
require "rails_helper"
describe "Authorization of user-facing pages" do
around(:each) do |x|
ENV["AUTH_KEY"] = "sesame"
x.call
ENV["AUTH_KEY"] = nil
end
it "authorizes you against the AUTH_KEY if present" do
get "/"
expect(response.code).to eq "401"
get "/?auth_key=jafar"
expect(res... |
Kanban::Application.routes.draw do
root to: "main#index"
resource :root, only: [:index]
resource :session, only: [:new, :create, :destroy]
get "login" => "sessions#new"
get "logout" => "sessions#destroy"
# resources :users, only: [:show]
namespace :api do
resources :users, only: [:show] do
c... |
class Course < ApplicationRecord
has_many :students, through: :enrollment
has_many :assignments
belongs_to :teacher
end
|
require 'pietr/interpreter'
require 'pietr/image'
require 'pietr/color'
require 'pietr/ops'
module Pietr
def self.run(filename)
image = Pietr::Image.new(filename)
interpreter = Pietr::Interpreter.new(image)
interpreter.run
end
end |
class AddExpDateToFunds < ActiveRecord::Migration
def change
add_column :funds, :exp_date, :string
end
end
|
class BlackDomain < ActiveRecord::Base
validates_uniqueness_of :domain_name
validates_format_of :domain_name, :with => /^([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,6}$/
validates_presence_of :domain_name
end
|
require 'spec_helper'
describe 'Simulator' do
let!(:simulator) { Simulator.new }
subject do
commands.each { |command| simulator.execute(command) }
simulator.execute('REPORT')
end
describe 'placing' do
let(:commands) { ['PLACE 1,2,SOUTH'] }
it { is_expected.to eq '1,2,SOUTH' }
end
describe 'moving' do
... |
require 'formula'
class ArmNoneEabiGcc < Formula
homepage 'https://launchpad.net/gcc-arm-embedded'
version '20130614'
url 'https://launchpadlibrarian.net/143625835/gcc-arm-none-eabi-4_7-2013q2-20130614-mac.tar.bz2'
sha1 'a2647aa321a70d848b2cfedc5b18b48e6619b394'
bottle do
sha1 'a2647aa321a70d848b2cfedc5... |
FactoryGirl.define do
factory :user do
name "Worker Bee"
email "1@2.three"
password "password"
role 0
end
end
|
class RailwayStation
extend ObjectManager
attr_reader :name, :trains
NAME_FORMAT = /^[\da-zа-я]{3}-?[\da-zа-я]{2}$/i
def initialize(name)
@name = name
@trains = []
validate!
self.class.add name, self
end
def accept(train)
validate_train! train
self.trains << train
end
def... |
#module for helping controller specs
module ValidUserHelper
def signed_in_as_a_valid_user
@user ||= FactoryGirl.create :user
sign_in @user # method from devise:TestHelpers
end
end
# module for helping request specs
module ValidUserRequestHelper
# for use in request specs
def sign_in_as_a_valid_user
... |
class HolidayFacade
def self.upcoming_holidays(quantity = 3)
holidays = HolidayService.holidays
holidays[0..(quantity - 1)].map do |holiday_data|
Holiday.new(holiday_data)
end
end
end
|
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# Used box
config.vm.box = "ubuntu/trusty64"
config.vm.hostname = 'vagrant-lamp-box'
# Accessing "loc... |
#!/usr/bin/env ruby
# To test the suitability of using a range to determine a valid
# coordinate instead of the current array method as used in
# Vedeu::Buffers::Terminal#within_terminal_boundary?
#
# vedeu/benchmarks:spike/benchmarking$ ./array_vs_range.rb
# Calculating -------------------------------------
# ... |
class Category < ActiveRecord::Base
belongs_to :website
has_many :tasks
def self.options_for_facebook
all.map{|r| "{id: %s, name: '%s'}" % [r.id, r.name]}.join(',')
end
def allow_rename?
true
end
end
# == Schema Information
#
# Table name: categories
#
# id :integer not null, pr... |
module CorePrint
class ApiResource
attr_accessor :id
def initialize(account, params)
@account = account
set_attributes(params)
end
def set_attributes(params)
params.each do |k,v|
send("#{k}=",v) if self.respond_to? k
end
end
def self.ensure_array(d)
if... |
class AddInfoToEmployees < ActiveRecord::Migration
def change
add_column :employees, :first_name, :string
add_column :employees, :last_name, :string
add_column :employees, :address_line_1, :string
add_column :employees, :address_line_2, :string
add_column :employees, :post_code, :string
end
end
|
"Big O-ctopus and Biggest Fish"
fishes = ['fish', 'fiiish', 'fiiiiish', 'fiiiish', 'fffish', 'ffiiiiisshh', 'fsh', 'fiiiissshhhhhh']
#bubble_sort
def sluggish_octopus(array)
sorted = false
until sorted
sorted = true
array.each_index do |i|
next if i == array.length - 1
if array[i].length >... |
class AddColumnsToPost < ActiveRecord::Migration
def change
add_column :posts, :private_status, :boolean, default:false
remove_column :posts, :remember_me
end
end
|
require 'rails_helper'
RSpec.describe TicketsController, type: :controller do
describe "#create" do
context "valid request" do
def valid_request
post :create, {ticket: {title: "Ticket",
body: "I need help",
author: "Zac"}}
end
... |
module Assetable
module ImageAsset
include BinaryBase
def asset_type
:image
end
def max_size
5.megabytes
end
def extension
'png'
end
end
end
|
module QBIntegration
class ReturnAuthorization < Base
attr_reader :order, :ra
def initialize(message = {}, config)
super
@ra = payload[:return]
@order = { id: payload[:return][:order_id] }
# for compatibility with sales receipt service
payload[:order] = @order
end
def ... |
class TelefoneFornecedorsController < ApplicationController
before_action :set_telefone_fornecedor, only: [:show, :edit, :update, :destroy]
# GET /telefone_fornecedors
# GET /telefone_fornecedors.json
def index
@telefone_fornecedors = TelefoneFornecedor.paginate(:page => params[:page]).order('id DESC').por... |
# -*- coding: utf-8 -*- #
module Rouge
module Lexers
class Hlb < RegexLexer
title "hlb"
tag 'Hlb'
mimetypes 'text/x-hlb'
filenames '*.hlb'
state:root do
rule /(#.*)/, Comment::Single
rule /((\b(0(b|B|o|O|x|X)[a-fA-F0-9]+)\b)|(\b(0|[1-9][0-9]*)\b)|(\b(t... |
class CreateBookings < ActiveRecord::Migration[5.0]
def change
create_table :bookings do |t|
t.string :name, null: false
t.string :phone, null: false
t.string :email, null: false
t.date :date, null: false
t.string :membership
t.belongs_to :course, index: true
end
end
end
|
module CDI
module V1
class SubscribersGroupSerializer < ActiveModel::Serializer
root false
attributes :id, :name, :total_members
end
end
end
|
class BaseService < ApplicationRecord
self.table_name = 'services'
class << self
def base_columns
%w[id name description thumbnail]
end
end
end
|
require 'oystercard'
describe Oystercard do
let(:entry_station) { :entry_station }
let(:exit_station) { :exit_station }
it "has a balance" do
expect(subject.balance).to eq(0)
end
describe '#top_up' do
it "allows customer to top up" do
expect(subject).to respond_to(:top_up).with(1).argument
... |
require "erb"
require "tilt"
module Conduit::Sureaddress::RequestMocker
class Base
FIXTURE_PREFIX = "#{File.dirname(__FILE__)}/../../../../spec/fixtures".freeze
def initialize(base, options = nil)
@base = base
@options = options
@mock_status = options[:mock_status].to_sym || :success
e... |
class UpdatePostCommand
include ActiveModel::Model
include ActiveEvent::Command
form_name 'Post'
attributes :id, :title, :text, :updated_at, :user_id, :topic_id, :editor_id
def persisted?; true end
end
|
class TournamentsController < ApplicationController
require 'will_paginate/array'
def index
@tournaments = Tournament.active.alphabetical.paginate(:page => params[:page]).per_page(10)
@inactive_tournaments = Tournament.inactive.alphabetical.paginate(:page => params[:page]).per_page(10)
end
def show
@tournam... |
class BrandsController < ApplicationController
def index
if params[:q].blank?
@brands = [] # suggestion(current_anonymous_or_user, :brand).map {|brand| {id: brand.id, text: brand.title }}
else
@brands = Brand.search("*#{params[:q]}*").records.map {|brand| {id: brand.id, text: brand.title }}
e... |
require 'rails_helper'
RSpec.describe "donors/donations/index", type: :view do
before(:each) do
assign(:donors_donations, [
Donors::Donation.create!(),
Donors::Donation.create!()
])
end
it "renders a list of donors/donations" do
render
end
end
|
# require 'redmine'
# require 'date'
# require 'active_support'
# require File.dirname(__FILE__) + '/lib/issues_controller_patch.rb'
# require File.dirname(__FILE__) + '/lib/project_patch.rb'
require_dependency 'project'
Project.send(:include, ProjectPatch)
require_dependency 'watchers_helper'
WatchersHe... |
module RotRails::Color
CACHE = {
"black"=> [0,0,0],
"navy"=> [0,0,128],
"darkblue"=> [0,0,139],
"mediumblue"=> [0,0,205],
"blue"=> [0,0,255],
"darkgreen"=> [0,100,0],
"green"=> [0,128,0],
"teal"=> [0,128,128],
"darkcyan"=> [0,139,139],
"deepskyblue"=> [0,191,255],
"darkturquoise"=> [0,206,209],
... |
class FixOpportunitiesForWall < ActiveRecord::Migration
def up
rename_column :opportunities, :in_range_swipes, :swipe_uses
add_column :opportunities, :wall_uses, :integer, :default => 0
add_column :opportunities, :sink_uses, :integer, :default => 0
remove_column :opportunities, :out_of_range_swipes
... |
# -*- encoding: utf-8 -*-
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
Gem::Specification.new do |gem|
gem.name = "ml-puppetdb-terminus"
gem.version = "3.2.1.1"
gem.authors = ["Mark Lawler"]
gem.email = ["marklawler@gmail.com"]
... |
class TripsController < ApplicationController
# POST /trips
def create
# binding.pry
begin
user = User.find_by(email: trip_params[:email])
if user.has_role? :driver
new_month_counter = 0
new_year_counter = 0
if Trip.where(user_id: user.id).last.created_at.month == Date.... |
# encoding: utf-8
require File.expand_path('../../mrblib/version.rb', __FILE__)
RAKEFILE_ROOT = File.dirname(File.expand_path(__FILE__))
MRUBY_ROOT = "#{RAKEFILE_ROOT}/vendor/mruby"
BUILD_CONFIG = "#{RAKEFILE_ROOT}/src/build_config.rb"
LIBMRUBY_DIR = "#{MRUBY_ROOT}/build/host/lib"
MRUBY_INCLUDE_DIR = "#{MRUBY_ROOT}/... |
# encoding: utf-8
##
# AudioUploader
#
class AudioUploader < CarrierWave::Uploader::Base
storage :file
#--------------
# Override default CarrierWave config
# to move files instead of copy them.
# Don't do it in test environment so
# the fixtures stay in place.
def move_to_cache
Rails.env == 'test' ... |
# require 'yaml'
require 'page-object'
# basic page for page object, can add basic methods for page object
class RubySelenium
# return link element by text
# page.get_link_by_text('User Guide') #how it is called
# self.get_link_by_text(template_name).click
# how it called (get the link element and click)
#... |
require 'spec_helper'
require 'belafonte/help'
require 'ostruct'
module Belafonte
describe Help do
describe '.content_for' do
let(:app) {Simple.new([])}
let(:generator) {OpenStruct.new(content: 'work, work, work')}
it 'generates content for the app' do
expect(Belafonte::Help::Generator... |
class NotificationChannel < ApplicationCable::Channel
def subscribed
stream_from "notification_channel_#{params[:room_id].to_s}"
end
def unsubscribed
# Any cleanup needed when channel is unsubscribed
end
def dual_request(data)
begin
ActionCable.server.broadcast(
"notification_chann... |
class AddStatusToPerson < ActiveRecord::Migration
def change
add_column :people, :status, :string, :default => 'unsubscribed'
end
end
|
class CoordinateValidator
MIN = 1
MAX = 250
def initialize(x, y, image)
@x = x
@y = y
@image = image
end
def valid?
numbers_only? && valid_coordinates?
end
private
def numbers_only?
Integer(x+y) rescue false
end
def valid_coordinates?
x_max = image ? image.row_size : MAX... |
class CreateLocations < ActiveRecord::Migration[5.1]
def change
create_table :locations do |t|
t.string :title
t.float :latitude
t.float :longitude
t.string :city_name
t.integer :city_id
t.string :country_name
end
end
end
|
class YeFlask < ExObj
def initialize()
super("ye flask")
@lit = false
end
def getDescription()
return "ye flask seems to be bolted onto a wall."
end
end |
class Answers
attr_accessor :all
def initialize
@all = [{response: 'It is certain', color: 'green'}, {response: 'It is decidedly so', color: 'green'}, {response: 'Without a doubt', color: 'green'}, {response: 'Yes definatly', color: 'green'},
{response: 'You may rely on it', color: 'green'}, {resp... |
class FontNotoSansHk < Formula
head "https://github.com/google/fonts/raw/main/ofl/notosanshk/NotoSansHK%5Bwght%5D.ttf", verified: "github.com/google/fonts/"
desc "Noto Sans HK"
desc "Sans-serif design using the traditional chinese variant of the han ideograms"
homepage "https://fonts.google.com/specimen/Noto+Sa... |
# Blackjack game (object oriented version)
#
# 2013.9.11
class Card # ex. ['Dimond','6']
attr_accessor :suit, :face_value, :value
def initialize(suit, face_value, value)
@suit = suit
@face_value = face_value
@value = value
end
end
class Deck
attr_accessor :car... |
# frozen_string_literal: true
require 'evss/response'
module EVSS
module PCIUAddress
class CountriesResponse < EVSS::Response
attribute :countries, Array[String]
def initialize(status, response = nil)
countries = response&.body&.dig('cnp_countries') || response&.body&.dig('countries')
... |
class UsuariosService < Service
def initialize params
@parametros = params
end
def existe_usuario
Usuario.exists?(id_externo: id_externo)
end
def nombre_esta_disponible
!Usuario.exists?(nombre: nombre)
end
def crear_usuario
on_transaction do
Usuario.create! parametros_de_creacion... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.