text stringlengths 10 2.61M |
|---|
#!/usr/bin/env ruby
require 'fileutils'
$name = "git merge-from-svn"
def usage retcode=0
puts <<USAGE
usage: #{$name} [options] <ref>
-b <name>, --branch_name=<name> select the svn branch name
-e, --edit edit the message before commit
-l, --log show log in message (... |
Rails.application.routes.draw do
scope module: :api do
scope module: :v1 do
post "/shorten", to: 'urls#shorten', as: 'shorten'
get '/:key', to: 'urls#redirect', as: 'redirect'
end
end
end
|
class Api::V1::MailboxController < ApiController
include Api::V1::MailboxDoc
before_action :set_user
def inbox
@inbox = @user.mailbox.conversations
@active = :inbox
end
def compose
receiver = User.find_by_id(params[:receiver_id])
if receiver
@user.send_message(receiver, params[:messag... |
# def none?(array)
# array.each do |ele|
# return false if yield(ele)
# end
# true
# end
def none?(collection, &block)
!any?(collection, block)
end
def any?(array, block)
raise NoMethodError unless array.kind_of?(Array)
array.each do |ele|
return true if block.call(ele)
end
false
end
puts... |
class Book < ApplicationRecord
validates_presence_of :title,:author
end
|
class InsurancesController < ApplicationController
before_action :set_insurance, only: [:show, :update, :destroy]
def index
@insurances = Insurance.all
render json: @insurances
end
def show
render json: @insurance
end
def create
@insurance = Insurance.new insurance_secure_params
if ... |
module OneDBFsck
def check_fix_user_quotas
# This block is not needed for now
=begin
@db.transaction do
@db.fetch("SELECT oid FROM user_pool") do |row|
found = false
@db.fetch("SELECT user_oid FROM user_quotas WHERE user_oid=#{row[:oid]}") do |q_row|
... |
class Mms::SuppliersController < Mms::MmsBackEndController
# GET /mms_suppliers
# GET /mms_suppliers.xml
def index
page = (params[:page] unless params[:page].blank?) || 1
@suppliers = ::Supplier.paginate :per_page => 22, :page => page, :order => 'created_at DESC'
respond_to do |format|
format.h... |
class MessagesController < ApplicationController
before_action :set_message, only: [:show, :edit, :update, :destroy]
# GET /messages
# GET /messages.json
def index
@messages = Message.all
end
# GET /messages/1
# GET /messages/1.json
def show; end
def first
@message = Message.first
rende... |
# frozen_string_literal: true
module Vedeu
# Provides a mechanism to control a running client application via
# DRb.
#
module Distributed
# A class for the server side of the DRb server/client
# relationship.
#
# @api private
#
class Server
$SAFE = 1 # disable `eval` and relate... |
=begin
#Topological Inventory Ingest API
#Topological Inventory Ingest API
OpenAPI spec version: 0.0.1
Contact: agrare@redhat.com
Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.3.1
=end
require "uri"
module TopologicalInventory
module IngressApi
module Client
... |
choice = ''
loop do
puts ">> Do you want me to print something? (y/n)"
choice = gets.chomp.downcase
break if choice == 'y' || choice == 'n'
puts "Invalid input! Enter y or n"
end
if choice == 'y'
puts "Something"
end
# %w(y n ) -- awesome alt array syntax |
class MessageEventAttachment
# require 'RMagick'
include Mongoid::Document
include Mongoid::Timestamps
store_in database: 'sribulancer_development', collection: 'message_event_attachments'
MAXIMUM_IN_MESSAGE = 5
belongs_to :message_event
field :image
field :name
field :message_event_attachment_gr... |
class PartnersController < ApplicationController
before_filter :signed_in_user
before_filter :correct_user, only: [:destroy]
def index
if current_user.admin?
@partners = Partner.paginate(page: params[:page])
else
@partners = Partner.where("collaborator_id = ?", current_user.id).
... |
class Restaurant < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
has_many :menu_items
has_many :gifts, throug... |
require_relative('../db/sql_runner')
class Student
attr_reader :first_name, :last_name, :age, :id, :house_id
def initialize(options)
@first_name = options['first_name']
@last_name = options['last_name']
@age = options['age'].to_i
@id = options['id'].to_i
@house_id = options['house_id'].to_i
... |
require "yaml"
RSpec.describe "Integration", type: :aruba do
example "SQLite" do
run_tests("sqlite://db/test.sqlite3")
end
example "SQLite with timestamps" do
run_tests("sqlite://db/test.sqlite3", timestamps: true)
end
example "PostgreSQL" do
run_tests("postgresql://localhost:5432/communard_te... |
class Pencil < ActiveRecord::Base
def self.info
'pencil'
end
end
|
class ProjectUserRole < ActiveRecord::Base
belongs_to :user
belongs_to :role
belongs_to :project
def self.search(search)
if search
Project.where("project_name iLIKE ?", "%#{search}%" )
# Project.find(:all, :conditions => ['project_name LIKE ?', "%#{search}%"])
else
Project.all
end
end
e... |
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe Comment, type: :model do
let(:user) { create(:user) }
let(:avatar) { create(:avatar) }
let(:comment) { create(:comment) }
describe 'validation' do
it { is_expected.to validate_presence_of :avatar_id }
it { is_expected.to validate_pres... |
class Kid < ActiveRecord::Base
#Associations
has_many :relationships
has_many :care_takers, through: :relationships
accepts_nested_attributes_for :care_takers
# Validations
validates :name, presence: { message: " - must be given, please." }
validates :age, presence: { message: " - must be given, please."... |
Sequel.migration do
up do
run "create index series_register_id_date_part_hour_idx on series(time, date_part('hour',time))"
end
down do
alter_table(:series) do
drop_index name: 'series_register_id_date_part_hour_idx'
end
end
end
|
class Picture < ApplicationRecord
belongs_to :imageable, polymorphic: true ,
:optional=>:true
has_attached_file :avatar, styles: { medium: "300x300>", thumb: "100x100>" }
validates_attachment_content_type :avatar, :content_type => ["image/jpg", "image/jpeg", "image/png", "image/gif"]
end
|
class AddDateToTransferSlip < ActiveRecord::Migration
def change
add_column :transfer_slips, :user_id, :integer, :after => :id
add_column :transfer_slips, :date, :date, :after => :report_id
add_column :transfer_slips, :whole_day, :boolean, :after => :note
end
end
|
#coding: utf-8
class Noticium < ActiveRecord::Base
attr_accessible :cuerpo, :imagen_id, :persona_id, :titulo, :updated_at
belongs_to :persona
belongs_to :imagen
has_many :calificaciones
has_many :comentarios
has_many :notificaciones
validate :titulo_must_be_present
validate :cuerpo_must_be_present... |
require 'spec_helper'
describe RightSupport::Net::DNSResolver do
before(:all) do
@ips = ["1.2.3.4","5.6.7.8"]
@info = [["AF_INET", 443, "amazonaws.com", @ips[0], 2, 1, 6], ["AF_INET", 443, "amazonaws.com", @ips[1], 2, 1, 6]]
@hostname = "reposeX.rightscale.com"
flexmock(Socket).should_receive(:getadd... |
class ArtistsController < ApplicationController
before_action :authenticate_user!, only: [:follow, :unfollow, :favorite, :unfavorite]
before_action :set_artist, only: [:show, :edit, :update, :destroy,
:follow, :unfollow, :favorite, :unfavorite]
# GET /artists
# GET /artists.json
def index
@artists = Ar... |
require 'spec_helper'
describe StripeEvent::WebhookController do
before do
StripeEvent.clear_subscribers!
@base_params = { :use_route => :stripe_event }
end
context "with valid event data" do
let(:event_id) { 'evt_charge_succeeded' }
before do
stub_event(event_id)
end
it "is succ... |
require 'date'
require_relative '../model/evento'
class EventoNoRecurrente < Evento
def periodo_dentro_de_Evento?(fechainicio, fechafin)
if(fecha_ocupada?(fechainicio) || fecha_ocupada?(fechafin))
return true
end
return fechainicio.to_time.utc <= getInicio().to_time.utc && getFin().to_time.utc <=... |
class Launch::ParseNested
attr_reader :components, :component_info, :class_name, :args, :component_class
def initialize(component_info, class_name, args)
@component_info = component_info
@class_name = class_name
@args = args
@component_class = send("find_class_from_#{component.class.name.downcase}... |
class Settings::ProxiesController < ApplicationController
def index
@proxies = Proxy.all.order(created_at: :desc)
end
def new
@proxy = Proxy.new
end
def create
@proxy = Proxy.new(proxy_params)
if @proxy.save
redirect_to settings_proxies_url
else
render :new
end
end
... |
require_relative 'spec_helper.rb'
describe RPS::Match do
it 'exists' do
expect(RPS::Match).to be_a(Class)
end
it 'has a unique id' do
RPS::Match.class_variable_set :@@counter, 0
expect(RPS::Match.new(1,2).id).to eq(1)
expect(RPS::Match.new(1,2).id).to eq(2)
expect(RPS::Match.new(1,2).id).to... |
# == Schema Information
#
# Table name: albums
#
# id :integer not null, primary key
# band_id :integer not null
# kind :string not null
# created_at :datetime not null
# updated_at :datetime not null
# album_name :string not null
#
class Alb... |
module CamaleonCms
module Frontend
module SiteHelper
# return full current visited url
def site_current_url
request.original_url
end
# return current url visited as path
# http://localhost:9001/category/cat-post-2 => /category/cat-post-2
def site_current_path
... |
require_relative '../../lib/uploader/parsers/sentinels_parser'
RSpec.describe Uploader::SentinelsParser, type: :parser do
let(:subject) { described_class.new(read_zip('sentinels')).parse }
it 'correct parse routes from files' do
is_expected.to contain_exactly(
Uploader::Route.new('sentinels', 'alpha', '... |
require_relative "generador_texto"
require_relative "observador_teclado"
class Sesion
attr_reader :texto_guia_lista
attr_reader :texto_guia
attr_reader :tiempo_inicial
def initialize(cant_letras)
@texto_guia_lista = GeneradorTexto.letras(cant_letras)
@texto_guia = @texto_guia_lista.joi... |
def create(options = {})
puts "Creating #{options[:database]} for owner #{options[:user]}..."
end
def connect(database:, host: "localhost", port: 3306, user: "root")
puts "Connecting to #{database} on #{host} port #{port} as #{user}..."
end
Creating catalog for owner carl.
|
require "benchmark"
require "rspec"
require "task_runner"
describe TaskRunner do
subject { TaskRunner.new(@tasks) }
describe "example from README" do
before do
@tasks = [Foo.new, Foo.new, Foo.new]
end
it "will print call say on each object" do
@tasks.each do |task|
expect(task).to... |
require 'spec_helper'
require 'shanty/plugins/cucumber_plugin'
RSpec.describe(Shanty::Plugins::CucumberPlugin) do
include_context('with plugin')
it('adds the cucumber tag automatically') do
expect(described_class).to provide_tags(:cucumber)
end
it('finds projects by calling a method to locate the ones th... |
class MaterialsUsedSerializer
include FastJsonapi::ObjectSerializer
attributes :task_item_id, :quantity, :uom
attributes :name do |object|
object.catalogue&.label
end
attributes :catalogue_id do |object|
object.catalogue_id.to_s
end
attributes :qty do |object|
object.quantity
end
attr... |
class CreateOrdersProducts < ActiveRecord::Migration
def change
create_table :orders_products do |t|
t.integer :order_id, null:false
t.integer :product_id, null:false
t.timestamps
end
end
end
|
class Box
attr_accessor :row, :column, :square, :value, :possibilities, :row_checked, :square_checked, :column_checked
def initialize(x, y, z, val)
@row = x
@column = y
@square = z
@possibilities = [1,2,3,4,5,6,7,8,9]
@value = val
@row_checked = false
@square_checked = false
@column... |
class ApplicationController < ActionController::Base
before_action :authenticate_user!
before_action :configure_permitted_parameters, if: :devise_controller?
rescue_from CanCan::AccessDenied do |exception|
respond_to do |format|
format.json { head :forbidden }
format.html { redirect_to root_url, ... |
Rails.application.routes.draw do
resources :shows
resources :songwriters
resources :played_tracks
resources :tracks
resources :artists
resources :venues
resources :licenses
post "/login", to: "auth#login"
post "/logout", to: "auth#logout"
get "/autologin", to: "auth#autologin"
# For details on th... |
require 'spec_helper'
describe "interim_attestations/index.html.erb" do
before(:each) do
assign(:interim_attestations, [
stub_model(InterimAttestation),
stub_model(InterimAttestation)
])
end
it "renders a list of interim_attestations" do
render
end
end
|
class CreateHomes < ActiveRecord::Migration
def change
create_table :homes do |t|
t.integer :idcnum
t.string :name
t.string :address
t.string :city
t.string :state
t.integer :zip
t.string :hometype
t.integer :lot
t.integer :sqft
t.float :bath
t.flo... |
require "rails_helper"
RSpec.describe Contestant do
subject { build(:contestant) }
it "has a valid factory" do
expect(subject.valid?).to eq true
subject.save!
end
describe "validations" do
it { is_expected.to validate_presence_of :pool }
it { is_expected.to validate_presence_of :first_name }
... |
# create a hash for data to be stored in
# ask the user for details that are listed on the questionaire
# name, email, phone, favourite colour, etc
# make sure data is converted to correct data type
# give the user the ability to change their answers
# print the hash at the end
#create hash
questionaire_an... |
class A265389Builder
def self.sequence(terms = 100)
x = (1..10 * terms).to_a
(0...terms).map do
y = x.shift(3).reduce(:+); x.delete_at x.index(y); y
end
end
end
class OEIS
A265389_SEQUENCE = A265389Builder.sequence
def self.a265389(n)
raise "A265389 is not defined for n = #{n} < 1" if... |
Rails.application.routes.draw do
devise_for :users
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
namespace :api, defaults: { format: 'json' } do
devise_for :users, path_names: { sign_in: 'login', sign_out: 'logout', sign_up: 'register' }
resources :b... |
#
# Tests de la class Site
#
require 'spec_helper'
require_model 'projet'
describe Site do
before(:all) do
Site.init
end
before(:each) do
cv_set(Site, :pisite => nil)
end
describe "Constantes" do
it "doit définir MAIN_FOLDER_DEFAULT" do
defined?(Site::MAIN_FOLDER_DEFAULT).should be_true
end
en... |
Rails.application.routes.draw do
namespace :admin do
resources :projects
resources :members
resource :dashboard, only: [:show]
root to: 'dashboards#show'
end
end
|
class AddTargetLanguageToLearnerDictionaries < ActiveRecord::Migration
def change
add_column :learner_dictionaries, :target_language, :string
end
end
|
require 'rails_helper'
RSpec.describe Admin::MasterpiecesController, type: :controller do
describe 'GET #index' do
# 全てのデータを配列にまとめること
it "populates an array of all masterpieces" do
smith = create(:masterpiece)
jones = create(:masterpiece)
get :index
expect(assigns(:masterpieces)).to m... |
describe UseCase::FindClustersForEnvironment do
subject { described_class.new(gateway: ecs_gateway, environment:) }
let(:ecs_gateway) do
double(list_clusters: [
"arn:aws:ecs:eu-west-2:abc123:cluster/frontend-fargate",
"arn:aws:ecs:eu-west-2:abc123:cluster/other-cluster",
])
end
context "gi... |
# Iodine setup - use conditional setup to allow command-line arguments to override these:
if(defined?(Iodine))
Iodine.threads = ENV.fetch("RAILS_MAX_THREADS", 5).to_i if Iodine.threads.zero?
Iodine.workers = ENV.fetch("WEB_CONCURRENCY", 3).to_i if Iodine.workers.zero?
Iodine::DEFAULT_SETTINGS[:port] = ENV.fetch("... |
def tokenize(p)
p.gsub('(',' ( ').gsub(')',' ) ').split
end
def parse(p)
parse_tokens(tokenize(p))
end
def parse_tokens(tokens)
token = tokens.shift
if token == '('
l = []
while tokens[0] != ')'
l.push(parse_tokens(tokens))
end
tokens.shift
return l
elsif token == ')'
raise S... |
require 'minitest'
require 'minitest/autorun'
require './lib/event_reporter'
class EventReporterTest < MiniTest::Test
def setup
@event = EventReporter.new
@list = Array.new
end
def test_find_should_exist
assert_equal "Hello", @event.find(1, 1)
end
def test_queue_should_exist
assert_equal [], @event.queu... |
class EventsignupController < ApplicationController
skip_before_action :verify_authenticity_token
before_action :find_event, only: [:new, :create, :share]
def new
if session[:user_id]
user=User.find_by_id session[:user_id]
signup = UserEvent.new(user: user ,event: @event )
# byebu... |
class OrderItem
include Mongoid::Document
field :product_id, type: String, default: ''
field :title, type: String, default: ''
field :photo, type: String, default: ''
field :origin_price, type: Float, default: 0.0
field :price, type: Float, default: 0.0
field :count, type: Integer, default: 1
embedded_... |
class HabitsController < ApplicationController
before_action :find_habit, only: [:show, :edit, :update, :destroy]
def index
@habits = Habit.where(user: current_user)
@day = DatePicker.call
@done = false
end
def show
end
def new
@habit = Habit.new
en... |
class SingleLinkedList
attr_reader :size, :first_node
def initialize
@first_node = nil
@last_node = nil
@size = 0
end
def first
return nil if @first_node.nil?
@first_node.value
end
def last
return nil if @last_node.nil?
@last_node.value
end
def append(element)
if @las... |
require "net/http"
require "uri"
require "celluloid/io"
require "json"
require "timeout"
require_relative "logging"
module Crawler
module Api
class Requester
VK_TIMEOUT=30
MAX_RETRIES = 3
include Celluloid::IO
include Logging
def initialize(args={})
@timeout=args[:timeout]... |
class AddIsAcceptedToNegotiateLines < ActiveRecord::Migration
def change
add_column :negotiate_lines, :is_accepted, :boolean
end
end
|
# encoding: UTF-8
# frozen_string_literal: true
module WalletService
class Wcg < Peatio::WalletService::Base
def create_address(options = {})
@client.create_address!(options)
end
def collect_deposit!(deposit, options={})
if deposit.currency.is_token_asset?
collect_asset_deposit(depo... |
class Picture < ActiveRecord::Base
belongs_to :spot
has_attached_file :picture,
styles: { large: "1000x1000>", medium: "300x300>", thumb: "100x100>" },
default_url: "/images/:style/nophotos.jpg",
url: "/system/spots/:attachment/:id_partition/:style/:filename",
path: ":rails_root/public/system/spots/... |
require_relative 'spec_helper'
describe Barracks do
before :each do
@barracks = Barracks.new
end
it "has and knows its HP" do
expect(@barracks.health_points).to eq(500)
end
describe "#damage" do
it "should reduce the building's health_points by the attack_power specified" do
@barracks.da... |
#lib/cc.rb
class Cc
def caesar_cipher(string, shift)
lower_string = string.to_s.downcase
char_array = lower_string.split(//)
num_array = char_array.map!(&:ord).map!(&:to_i)
shifted_array = []
num_array.map! { |int| int + shift }
num_array.each do |value|
if value > 122
y = value ... |
# Build a number from a string one character at a time
# account for sign and a decimal point
# the number may be an integer or may be a float!
# "Fail fast" is ok (throws exception on a non number)
# "14"
# "-45"
# "+514"
# "15.5" <=> 155 * 10 ^ (-1)
# "
# r = r * 10 + c
def number_builder( number_as_string )
... |
# Encoding: utf-8
include_recipe "ohai_plugins_test::vhosts"
node.override['wordpress']['parent_dir'] = '/srv/wordpress_sample'
node.override['wordpress']['dir'] = '/srv/wordpress_sample'
include_recipe "wordpress"
remote_file ::File.join(Chef::Config[:file_cache_path], "wordpress-cli-installer.sh") do
source "htt... |
class Player
attr_accessor :name, :life_points
@@all_players = []
def initialize (name)
@name = name
@life_points = 10
@@all_players << self
end
def show_state
puts "#{@name} à #{@life_points} points de vie !"
end
def gets_damages (damages_points)
@life_points = @life_points-damages_points
if @l... |
class Redis
attr_accessor :values
def initialize(ip)
@values = {}
end
def set(key, value)
@values[key] = value
end
def get(key, value)
@values[key]
end
end
#虚拟节点
class VNode
attr_accessor :node
def execute(*params)
node.execute(*params)
end
end
#真实节点
class Node
attr_accessor :v... |
module TodoApp
module Models
class Command
attr_accessor :commands, :description, :usage
def initialize( commands, description, usage )
@commands = commands
@description = description
@usage = usage
end
end
end
end |
require 'happymapper'
require 'netvisor/sales_invoice'
module Netvisor
class Root
include HappyMapper
tag 'root'
has_one :sales_invoice, SalesInvoice
end
end
|
class User < ApplicationRecord
has_many :contracts
def full_name
"#{first_name} #{last_name}"
end
end
|
class UserSubscriptionPlansController < ApplicationController
expose(:user) { current_user }
expose(:subscription_plans, ancestor: :user)
expose(:subscription_plan, attributes: :subscription_plan_params)
def index
end
def new
end
def create
subscription_plan.save!
respond_with subscription_pl... |
class EventsController < ApplicationController
before_filter :authenticate_user!
skip_before_filter :check_for_current_event
authorize_resource
def index
@events = Event.all
end
def show
@event = Event.find(params[:id])
end
def new
@event = Event.new
end
def edit
@event = Even... |
module Process
class Bittrex
attr_reader :currencies, :currencies_usdt
def initialize(api_key:, secret_key:)
::Bittrex.config do |c|
c.key = api_key
c.secret = secret_key
end
end
def request!
ThreadsWait.all_waits(
Thread.new do
wallet_all = ::Bitt... |
# Object models a Room with a number, capacity, and patients
#
# Room.new(number: "303L", capacity: 2)
class Room
class CapacityExceededError < StandardError; end
# attr_reader :number, :capacity
def initialize(attributes = {})
@number = attributes[:number]
# if the attributes doesn't include the :capac... |
class Idea < ApplicationRecord
enum priority: %i[high medium low]
belongs_to :user
has_rich_text :description
end
|
class FriendshipController < ApplicationController
# before_action :set_friend, only: [:show, :edit, :update, :destroy]
before_action :authenticate_user!
# GET /friends
# GET /friends.json
def index
@current_user = current_user
@friendships = current_user.friendships
@potentialFriends = User.al... |
require_relative '../spec_helper'
describe User do
before do
@user = create(:user, email: "user@example.com",
password: "foobar", password_confirmation: "foobar")
end
subject { @user }
it { should respond_to(:email) }
it { should respond_to(:password_digest) }
it { should respon... |
class AddFieldFinancialTicket < ActiveRecord::Migration
def change
add_column :financial_tickets, :payment_date, :date
end
end
|
require './client.rb'
EXAMPLE_HOSTGROUP_NAME = 'lck-hostgroup'
EXAMPLE_TEMPLATE_NAME = 'lck-ping-template'
EXAMPLE_APPLICATION_NAME = 'lck-status'
EXAMPLE_ITEM_NAME = 'lck-ping'
EXAMPLE_TRIGGER_NAME = 'lck-ping-status'
EXAMPLE_HOST_NAME = 'codingkata.tardate.com'
def client
@client ||= get_client
end
def hostgroup... |
require 'rails/generators'
require 'rails/generators/generated_attribute'
module Unic
module Generators
class UnicGenerator < ::Rails::Generators::Base
source_root File.expand_path('../templates', __FILE__)
argument :controller_path, :type => :string
#argument :controller_path, :type => :... |
require 'json'
class PivotalService
class << self
def set_token(token)
Scorer::Client.token = token
end
def all_projects(fields=[])
api_url = append_fields('/projects', fields)
response = Scorer::Client.get(api_url)
json_projects = JSON.parse(response, {:symbolize_names => true... |
class FontTrispace < Formula
head "https://github.com/google/fonts/raw/main/ofl/trispace/Trispace%5Bwdth%2Cwght%5D.ttf", verified: "github.com/google/fonts/"
desc "Trispace"
desc "Designed by tyler finck (etc)"
homepage "https://fonts.google.com/specimen/Trispace"
def install
(share/"fonts").install "Tris... |
require "test_helper"
require 'test_helper'
require 'persistable/cloud_storage_adapter'
require 'fileutils'
class CloudStorageTest < Test::Unit::TestCase
def test_write_file
persistable = get_persistable
persistable.persistence_data = File.open(__FILE__)
assert adapter.write persistable
assert_true ... |
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 'jeweler'
Jeweler::Tasks.new do |gem|
# gem is a Gem::Specificati... |
require 'rake/testtask'
task :default => [:test]
# SPECS =====================================================================
desc 'Run tests (default)'
Rake::TestTask.new(:test) do |t|
t.test_files = FileList['test/*_test.rb']
t.warning = false
end
# DOCUMENTATION ==============================================... |
# frozen_string_literal: true
require 'sead'
require 'turnip_price/pattern'
require 'turnip_price/formula'
module TurnipPrice
# Price Calculator
#
# @since 0.1.0
class Calculator
# @param pattern [Number] current pattern
# @param seed [Number] the random seed
#
# @since 0.1.0
def initializ... |
module TicTacToeGame
class HumanHumanToggle
attr_reader :current_player
def current_turn(current_player=nil)
current_player == "player1" ? "player2" : "player1"
end
end
end
|
class Ckeditor::Picture < Ckeditor::Asset
has_attached_file :data,
PAPERCLIP_PHOTO_OPTIONS
validates_attachment_size :data, :less_than => 2.megabytes
validates_attachment_presence :data
def url_content
url(:content)
end
end
|
require 'rails_helper'
RSpec.describe 'garden show page' do
before :each do
@garden = Garden.create!(name: "Sunshine Gardens", organic: true)
@plot_1 = @garden.plots.create!(number: 10, size: "Big", direction: "East")
@plot_2 = @garden.plots.create!(number: 20, size: "small", direction: "West")
@pla... |
require 'gooddata'
describe "Spin a project", :constraint => 'slow' do
before(:all) do
spec = MultiJson.load(File.read("./spec/data/test_project_model_spec.json"), :symbolize_keys => true)
ConnectionHelper::create_default_connection
@source_project = GoodData::Model::ProjectCreator.migrate({:spec => spe... |
class LinkedinController < ApplicationController
def index
# get your api keys at https://www.linkedin.com/secure/developer
linkedin_options ={ :request_token_path =>'/uas/oauth/requestToken?scope=r_fullprofile+r_emailaddress+r_contactinfo'}
client = LinkedIn::Client.new(ENV["LINKEDIN_KEY"], ENV["LINKED... |
class AddCountableToDeaths < ActiveRecord::Migration
def change
add_column :deaths, :countable, :boolean, default: true
reversible do |dir|
dir.up do
Death.update_all(countable: true)
end
end
end
end
|
require ("minitest/autorun")
require ("minitest/rg")
require_relative("../Student")
class TestStudent < MiniTest::Test
#setup method below which means it will be constant for functions that follow it
def setup
@daniel = Student.new("Daniel", 1)
end
#getter methods below
def test_student_get_name
assert_... |
require("sorbet-rails/model_rbi_formatter")
require("sorbet-rails/routes_rbi_formatter")
require("sorbet-rails/utils")
# this is ugly but it's a way to get the current directory of this script
# maybe someone coming along will know a better way
@@sorbet_rails_rake_dir = File.dirname(__FILE__)
namespace :rails_rbi do
... |
Given /^a (\d+) (\w+) (\w+) (\w+) exists with license "([^"]*)"$/ do |year, color, make_name, model_name, license_plate_number|
make = Make.find_or_create_by_name make_name
model = Model.find_or_create_by_make_id_and_name(make.id, model_name)
Vehicle.create! :model => model, :color => color, :year => year, :licen... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.