text stringlengths 10 2.61M |
|---|
require 'pry'
require 'tty-prompt'
require_relative '../../bin/globalvariable'
class CLI
def initialize
@prompt = TTY::Prompt.new
@font = TTY::Font.new(:doom)
@pastel = Pastel.new
# @user = []
end
def welcome
system("clear")
puts @pastel.magenta.bold(@font.write("ASTEROIDS".center(30), ... |
# frozen_string_literal: true
class User
def initialize(fio)
@fio = fio
end
attr_reader :fio
end
|
# frozen_string_literal: true
require 'sidekiq'
module SidekiqSimpleDelay
# Worker that handles the simple_delayed functionality for ActionMailers
class SimpleDelayedMailer
include Sidekiq::Worker
def perform(args)
target_klass = Object.const_get(args.fetch('target_klass'))
method_name = arg... |
require 'yt/config'
require 'yt/models/account'
require 'yt/models/content_owner'
RSpec.configure do |config|
# Create one global test account to avoid having to refresh the access token
# at every request
config.before :all do
attrs = {refresh_token: ENV['YT_TEST_DEVICE_REFRESH_TOKEN']}
$account = Yt::A... |
require_relative "./open_source_stats/version.rb"
require_relative "./open_source_stats/user"
require_relative "./open_source_stats/organization"
require_relative "./open_source_stats/event"
require 'active_support'
require 'active_support/core_ext/numeric/time'
require 'octokit'
require 'dotenv'
Dotenv.load
class Op... |
require 'nokogiri'
require 'open-uri'
require 'json'
require './websites'
# This module is for converting our data to a json file
module DataExporter
class << self
# We take in a hash and output json
def data_to_json(data)
return JSON.pretty_generate(data)
end
# We output our json to output.j... |
require "rails_helper"
RSpec.describe TrialPresenter do
before do
define_description_list_items
end
describe "#to_s" do
it "returns trial title" do
title = "Trial title"
trial = build(:trial, title: title)
trial_presenter = TrialPresenter.new(trial)
expect(trial_presenter.to_s)... |
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
# boxes at https://vagrantcloud.com/search.
config.vm.box_check_update = false
config.vm.define "jenkins", primary:true do |jenkins|
jenkins.vm.box = "centos/7"
jenkins.vm.hostname = 'node4'
jenkins.vm.net... |
class PotzsController < ApplicationController
# GET /potzs
# GET /potzs.json
def index
@potzs = Potz.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @potzs }
end
end
# GET /potzs/1
# GET /potzs/1.json
def show
@potz = Potz.find(p... |
class Budgets::MonthlyEarningsController < ApplicationController
before_action :authenticate_guest!
def index
@home_bg = 'budget-bg'
@title = 'Budget - Monthly Earnings'
@monthly_earnings = current_guest.budgets_monthly_earnings.order("updated_at ASC")
@monthly_earning = Budgets::MonthlyEarning.new... |
require_relative '../lib/chess.rb'
### fix tests
describe Chess do
let(:game) { Chess.new }
let(:plr1) { game.plr1 }
let(:plr2) { game.plr2 }
let(:active_player) { game.active_player }
let(:opposing_player) { game.opposing_player }
let(:update) { game.implement_changes }
describe '#can_castle?' do
i... |
# encoding: utf-8
require 'inspec/resource'
require 'plugins/inspec-init/lib/inspec-init/renderer'
module InspecPlugins
module ResourcePack
class GenerateCLI < Inspec.plugin(2, :cli_command)
subcommand_desc 'generate resource_pack', 'Create an InSpec profile that is resource pack'
# The usual rhyth... |
# Write a method that takes a string argument, and returns true if all of the
# alphabetic characters inside the string are uppercase, false otherwise.
# Characters that are not alphabetic should be ignored.
def uppercase?(str)
is_true = true
str.each_char do |char|
if char =~ /[[:alpha:]]/
is_true = fal... |
# frozen_string_literal: true
class BooksController < ApplicationController
def index
@books = Book.paginate(:page => params[:page])
end
def show
if storable_location?
store_user_location!
end
@book = Book.find params[:id]
# If the bib record has "n" or "e" in the "Bib Code 3 field"... |
class TagsController < ApplicationController
def index
@page_title = "All Video Links"
@tags = Tag.all.sort
authorize @tags
end
def show
@tag = Tag.find(params[:id])
name = @tag.tag
@page_title = "Video Links for #{name}"
authorize @tag
end
end |
require 'test_helper'
class SwimsetsControllerTest < ActionController::TestCase
setup do
@swimset = swimsets(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:swimsets)
end
test "should get new" do
get :new
assert_response :success
en... |
class AddPersonRefToUser < ActiveRecord::Migration
def change
add_reference :users, :person, index: true, foreign_key: true
end
end
|
When /^I am on the (.*) page$/ do |page_description|
path = path_for(page_description)
visit path
end
Then /^(.+) within the (.+)$/ do |step_content, context|
locator = locator_for(context)
within(locator){step(step_content)}
end
Then /^I should see "([^"]+)"$/ do |content|
expect(page).to have_content(cont... |
#
# Copyright 2011 National Institute of Informatics.
#
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required ... |
class Api::V1::MonthsController < ApplicationController
# respond_to :json
# def update
# month = Month.find(params[:id])
#
# month.update_attributes(month_params)
# month.save
# end
def update
month = Month.find(params[:id])
if month.update(month_params)
render json: month
els... |
require 'spec_helper'
describe QuestionsController do
describe "GET index" do
it "renders the index template" do
get :index
expect(response).to render_template("index")
end
it "assigns @questions to be an array of questions" do
new_question = Question.create(title: "test", content: "t... |
class ItemsController < ApplicationController
before_action :require_user_logged_in
include ParseHtmlHelper
def new
@item = Item.new
@user = current_user
api_url = api_item_create_url
user_id_str = @user.id.to_s
@bookmarklet = 'javascript:void ((function(b){var a=new XMLHttpRequest();a.open("... |
require File.expand_path(File.join(File.dirname(__FILE__), '../', 'test_helper' ))
class EventsTest < ActionController::IntegrationTest
def setup
factory_scenario :site_with_calendar
factory_scenario :calendar_with_event
Factory :calendar_event, :title => 'Miles Davis Live', :section => @section
@cal... |
module Base
module Step
def self.included(base)
base.extend ClassMethods
# base.singleton_class.extend Forwardable
# base.singleton_class.def_delegators base, :Transaction
end
def run
res = nil
pending_steps = self.class.steps.filter(&:present?)
pending_steps.each do ... |
require 'net/http'
class Net::HTTP
alias :create :initialize
def initialize(*args)
logger = Rails.logger
def logger.<< log
info "HTTP_LOG:#{log}"
end
create(*args)
self.set_debug_output logger
end
end
|
class Entry < ActiveRecord::Base
include ActionView::Helpers::SanitizeHelper
belongs_to :feed
# Besure to always destory, not delete to call this.
has_many :entry_users, :dependent => :destroy
has_many :users, through: :entry_users
validates :url, :uniqueness => {:scope => :guid}
validates_presence_... |
Rails.application.routes.draw do
devise_for :users
root to: redirect('/products')
# sitemap
get "sitemap", controller: "sitemaps", action: "show", format: "xml"
post "payment", controller: "pages", action: "payment", format: "json"
# error pages
get "/404", to: "errors#not_found"
get "/422", to: "err... |
class SessionsController < ApplicationController
skip_before_action :ensure_authenticated_user, only: %w( new create )
def new
@user = User.new
end
def destroy
unauthenticate_user
redirect_to new_session_url
end
end
|
class StylesheetsController < ApplicationController
before_action :set_stylesheet, only: [:show, :edit, :update, :destroy]
# GET /stylesheets
# GET /stylesheets.json
def index
@stylesheets = Stylesheet.all
end
# GET /stylesheets/1
# GET /stylesheets/1.json
def show
end
# GET /stylesheets/new
... |
require "test_helper"
describe OrganizationCategory do
let(:organization_category) { OrganizationCategory.new }
it "must be valid" do
value(organization_category).must_be :valid?
end
end
|
module StatusesHelper
def generate_hl7(status)
wp_patient = status.wound.patient
wp_wound = status.wound
run_parser(wp_patient, wp_wound, status)
end
private
def run_parser(patient,wound,status)
container = [build_MSH, build_PID(patient), build_PV1, build_OBX]
first_msgs = container.injec... |
class RemoveFieldsIdsFromGroups < ActiveRecord::Migration
def change
remove_column :groups, :field_id_1, :integer
remove_column :groups, :field_id_2, :integer
remove_column :groups, :field_id_3, :integer
end
end
|
require File.expand_path('../../../helpers/compute/data_helper', __FILE__)
module Fog
module Compute
class ProfitBricks
class Share < Fog::Models::ProfitBricks::Base
include Fog::Helpers::ProfitBricks::DataHelper
identity :id
# properties
attribute :edit_privilege, :ali... |
require 'backlog'
require 'thor'
require 'xmlrpc/client'
require 'yaml'
require 'pp'
module Backlog
class Command < Thor
@@config = YAML.load_file(File.join(__dir__, '../../config.yaml'))
@@proxy = XMLRPC::Client.new_from_hash({
"host" => @@config['backlog']['space'] + ".backlog.jp",
"path" ... |
class CreateRatingCaches < ActiveRecord::Migration[5.1]
def change
create_table :rating_caches do |t|
t.string :cacheable_type
t.integer :cacheable_id
t.float :avg
t.integer :qty
t.string :dimension
t.timestamps
end
end
end
|
# frozen_string_literal: true
FactoryBot.define do
factory :zombie do
name 'Peter'
hit_points 1000
brains_eaten 3
speed 10
turn_date '08/05/2018'.to_date
end
end
|
module Movement
def get_sliding_moves (vector, pos, board)
x, y = pos[0], pos[1]
possible_pos = [[x + vector, y + 1],[x + vector, y - 1]]
possible_pos.select! do |pos|
(pos.all?{ |val| within_boundaries?(val) }) && pos_empty?(pos)
end
possible_pos
end
def within_boundaries?(num)
nu... |
module Rightboat
class SitemapHelper
# note: it appears that items order in xml doesn't matter, what matters is priority attribute
def self.boats_with_makemodel_slugs
Boat.active.order('id DESC').joins(:manufacturer, :model)
.select('boats.id, boats.slug, boats.updated_at, manufacturers.slug ... |
class AddIndexToBook < ActiveRecord::Migration[5.2]
def change
add_index :books, :order_id
add_index :books, :user_id
end
end
|
require_relative '../models/address_book'
require 'bloc_record'
require_relative 'integrate'
class MenuController < BlocRecord
attr_reader :address_book
include Integrate
def main_menu
set unless @set_up
puts "Main Menu - #{self.count('entry')} entries"
puts "0 - View an address book"
puts "1 - ... |
module Builder
class << self
def parse_test(config = 'config.ru')
parse(config, 'test')
end
def parse_development(config = 'config.ru')
parse(config, 'development')
end
def parse_production(config = 'config.ru')
parse(config, 'production')
end
def parse(config, enviro... |
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
require File.expand_path(File.dirname(__FILE__) + '/../facebook_spec_helper')
module ProfileSpecHelper
def valid_attributes(options={})
options
end
end
describe Profile do
include ProfileSpecHelper
before(:each) do
@member = create_m... |
# -*- coding: utf-8 -*-
# ใฆใฃใณใใฆใใผใ้ๅฑคๆง้ ใฎๅญ
module Plugin::GUI::HierarchyChild
class << self
def included(klass)
if klass.include?(Plugin::GUI::HierarchyParent)
raise "Plugin::GUI::HierarchyChild must be included before the Plugin::GUI::HierarchyParent."
end
klass.extend(Extended)
end... |
puts 'Seeding PSP0.1 postmortem script'
psp00 = Script.where(name: "PSP0.1 Postmortem Script", level_number: LevelNumber.find(2)).first_or_create!
psp00.purpose = 'To Guide the PSP postmortem process'
psp00.entry_criteria = <<-HTML
<ul>
<li>Problem description and <a href="./edit">requirements
statement</a></li>
<... |
json.array!(@reviews) do |review|
json.extract! review, :id, :gig_id, :user_id, :subject, :body, :communication_rating, :service_rating, :recommend_rating
json.url review_url(review, format: :json)
end
|
require 'test_helper'
class PublicSuffixTest < Minitest::Unit::TestCase
def test_self_parse_a_domain_with_tld_and_sld
domain = PublicSuffix.parse("example.com")
assert_instance_of PublicSuffix::Domain, domain
assert_equal "com", domain.tld
assert_equal "example", domain.sld
assert_equal nil,... |
#==============================================================================
# ** Game_Map
#------------------------------------------------------------------------------
# This class handles maps. It includes scrolling and passage determination
# functions. The instance of this class is referenced by $game_map.
#... |
module Api
module V1
class AgentsController < ApplicationController
def index
render json: Agent.all
end
def show
render json: Agent.find(params[:id])
end
def create
agent = Agent.new(params.require(:agent).permit(:alias,:barcode))
if agent.save
... |
class Image < ApplicationRecord
mount_uploader :image_file, ImageFileUploader
# Direct associations
has_many :comments,
:foreign_key => "photo_id",
:dependent => :destroy
has_many :likes,
:foreign_key => "photo_id",
:dependent => :destroy
belongs_to ... |
RSpec.describe Game do
let(:player1) { spy :player }
let(:player2) { spy :player }
subject(:game) { Game.new(player1, player2)}
describe '#player 1' do
it 'creates an array of players' do
expect(game.player1).to be player1
end
end
describe '#player 2' do
it 'creates an array of players... |
class API
def search(q)
require 'GiphyClient'
urls = []
api_instance = GiphyClient::DefaultApi.new
api_key = "dc6zaTOxFJmzC" # Giphy API Key.
opts = {
limit: 10, # The maximum number of records to return.
offset: 0, # An optional results offset. Defaults to 0.
rating: "pg... |
class ActIndicatorRelation < ActiveRecord::Base
belongs_to :user
belongs_to :act, foreign_key: :act_id, touch: true
belongs_to :indicator, foreign_key: :indicator_id, touch: true
belongs_to :unit, foreign_key: :unit_id
belongs_to :relation_type
has_many :measurements, dependent: :destroy
val... |
FactoryBot.define do
factory :user do
name { Faker::Name.name.truncate(16) }
email { Faker::Internet.unique.email }
password { Faker::Internet.password }
admission_year { Faker::Number.between(90, 120) }
factory :test_user do
name { :test }
email { 'test@plus.nctu' }
password { '... |
require 'spec_helper'
feature "searching for coffee shops" do
before do
visit root_path
end
context "with a valid post code" do
before do
fill_in "search-input", :with => "E2 8RS"
click_button "search-submit"
end
scenario "show results", :vcr do
expect(page).to have_css("#shop-table tbody tr")
... |
module DLMSTrouble
class ActionResult
VALUES = {
0 => :success,
1 => :hardware_fault,
2 => :temporary_failure,
3 => :read_write_denied,
4 => :object_undefined,
9 => :object_class_inconsistent,
11 => :object_unavailable,
... |
FactoryGirl.define do
factory :operation do
invoice_num "Anynumber"
invoice_date DateTime.now
amount 25
operation_date DateTime.now
kind "anything1;anything2"
status "anystatus"
association :company
end
end
|
module HideFromBullet
def skip_bullet
if defined?(Bullet)
previous_value = Bullet.enable?
Bullet.enable = false
end
yield
ensure
Bullet.enable = previous_value if defined?(Bullet)
end
end
|
control 'node exporter should be installed' do
describe file('/opt/prometheus//bin/node_exporter') do
it { should be_file }
it { should be_executable }
end
end
control 'it should be running under ssystemd' do
describe file('/etc/systemd/system/prometheus-node_exporter.service') do
it { should be_file ... |
class InvitationsController < ApplicationController
before_action :set_company
before_action :check_admin
# GET /invitations/new
def new
@invitation = Invitation.new
end
# POST /invitations
# POST /invitations.json
def create
@invitation = Invitation.new(invitation_params)
respond_to do |f... |
# frozen_string_literal: true
class SlackIdImporter
def initialize(user)
@user = user
end
SLACK_API_URL = 'https://slack.com/api/users.lookupByEmail?email='
def perform
if @user.slack_id.blank?
url = "#{SLACK_API_URL}#{@user.email}&token=#{ENV['SLACK_OAUTH_TOKEN']}"
uri = URI(url)
re... |
CarrierWave.configure do |config|
config.fog_credentials = {
provider: 'AWS', # required
aws_access_key_id: ENV["S3_ID"], # required
aws_secret_access_key: ENV["S3_SecretKey"], # required
endpoint:'http://s3-us-west-... |
require 'commander'
require_relative "edit"
module ClusterFsck
module Commands
class Create
include ClusterFsckEnvArgumentParser
def run_command(args, options = {})
raise ArgumentError, "must provide a project name" if args.empty?
set_cluster_fsck_env_and_key_from_args(args)
... |
require 'soap/lc/wsdl/parser'
require 'soap/lc/request'
module SOAP
class WSDL
attr_reader :parse
def initialize(uri, binding) #:nodoc:
@parse = SOAP::WSDL::Parser.new(uri)
@binding = binding
end
# Call a method for the current WSDL and get the corresponding SOAP::Request
#... |
FactoryBot.define do
factory :dealer do
name { Faker::Name.name }
sf_id { SecureRandom.uuid }
category { Dealer::CATEGORIES[:point_of_sale] }
end
end
|
class Api::CompaniesController < ApplicationController
def index
if params[:page]
render_companies_by_page(Company.order(:name), params[:page])
return
end
render_companies_by_page(Company.order(:name), 1)
end
# Using json style guide https://google.github.io/styleguide/jsoncstyleguide.x... |
module Sandra
module Indices
module ClassMethods
#index_on :latitude, :group_by => :sector, :sub_group => :longitude
# by_index :latitude, :sector => "0/0", :longitude => {:from => 0.1, :to => 0.2},
# by_index :latitude, :sector => ["0/0", "0/1"], :longitude => 0.1, :latitude => {:from => ...
... |
class AddAccessTokenToAdminUsers < ActiveRecord::Migration[5.2]
def change
add_column :admin_users, :access_token, :string, default: nil
end
end
|
class WoPart < ActiveRecord::Base
belongs_to :workorder
belongs_to :inventory
after_create :remove_part_from_the_stock
def remove_part_from_the_stock
inv = self.inventory
inv.qty_in_stock -= self.qty_used
inv.save!
end
end
|
class UserInfoType < ActiveRecord::Base
belongs_to :user
def self.info_types_of_logon_user(user)
user.user_info_types
end
def self.info_type_ids_of_logon_user(user)
return user.user_info_types.collect{|user_info_type| user_info_type.info_type_id}
end
def self.update_user_info_types(user,user_selec... |
module Interpreter
class Formatter
private_class_method :new
class << self
def output(value)
case value
when NilClass then 'null'
when String then "\"#{value}\""
when Numeric then format_numeric value
when SdArray then format_sd_array value
else value... |
class Community < ApplicationRecord
extend FriendlyId
friendly_id :name, use: :slugged
has_many :posts
belongs_to :user
end
|
class AddThroughForAffiliateCertification < ActiveRecord::Migration
def change
add_column :affiliate_certifications, :affiliate_id, :integer
add_column :affiliate_certifications, :certificat_id, :integer
end
end
|
#orange_tree.rb
require_relative 'tree'
class OrangeTree < Tree
attr_reader :oranges
def initialize
super
@max_growable_age = 15
@death_age = 20
@annual_growth = 10
@min_growable_age = 5
end
def add_fruit
10.times do
@fruits << Orange.new
end
end
end |
# frozen_string_literal: true
# typed: false
require 'spec_helper'
describe AlphaCard::Attribute do
class User
include AlphaCard::Attribute
attribute :name
attribute :activated, values: [true, false]
attribute :role, default: 'user', writable: false
end
class Moderator < User
attribute :id... |
class Category < ActiveRecord::Base
has_many :sub_categories
has_many :event_masters
has_many :event_category_mappings, through: :event_masters
end
|
#
# Author:: Joshua Timberman <joshua@opscode.com>
# Copyright (c) 2013, Opscode, Inc. <legal@opscode.com>
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License... |
require_relative 'sequence_generator'
require_relative 'sequence'
require_relative 'guess_builder'
require_relative 'sequence_matcher'
require_relative 'guess'
require_relative 'guess_printer'
class Game
attr_reader :guess_history, :sequence, :turns, :game_over, :guess_builder
def initialize(code_length, colors)
... |
class CreateSales < ActiveRecord::Migration
def change
create_table :sales do |t|
t.string :site_name
t.string :url
t.string :staff_name
t.string :email
t.string :address
t.string :phone_number
t.timestamps null: false
t.index :email
end
end
end
|
class UserRolesController < ApplicationController
before_action :set_user_role, only: [:show, :edit, :update]
before_action :authenticate_user!
# GET /user_roles
# GET /user_roles.json
def index
@user_roles = UserRole.all
end
# GET /user_roles/1
# GET /user_roles/1.json
def show
end... |
# jekyll-i18n
# โ A simple plugin for multilingual Jekyll sites
# Author: Liam Edwards-Playne <liamz.co>
# License: GPLv3
require 'i18n'
require 'pathname'
module Jekyll
I18n.load_path += Dir['_i18n/*.yml']
class TranslateTag < Liquid::Tag
def initialize(tag_name, text, tokens)
super
@text = text
end... |
class VVrite
def initialize(filename)
@filename = filename
end
def slug
@slug ||= @filename.gsub(VVriter.config.vvrites_extension, '')
end
def title
@title ||= begin
File.open(full_path, &:readline).gsub(/^[\wะฐ-ัะ-ะฏ]+/, '').strip
rescue StandardError
... |
class AddTideField < ActiveRecord::Migration
def self.up
add_column :weather_locations, :tide_key, :string
end
def self.down
remove_column :weather_locations, :tide_key
end
end
|
# frozen_string_literal: true
# rubocop:todo all
module Mongo
module CRUD
# Represents a CRUD specification test.
class Spec
# Instantiate the new spec.
#
# @param [ String ] test_path The path to the file.
#
# @since 2.0.0
def initialize(test_path)
@spec = ::Util... |
require 'scripts/models/map'
require 'scripts/entity_system/component'
module Components
class Level < Base
register :level
field :map, type: Models::Map, default: nil
end
end
|
require 'capybara/poltergeist'
Capybara.register_driver :poltergeist do |app|
Capybara::Poltergeist::Driver.new(app, :inspector => true)
end
Capybara.javascript_driver = :poltergeist
# The lines like "The microcosm HAS..." are not behavior driven.
When("print body") do
print body
end
Given("there is a microcosm... |
class Order < ActiveRecord::Base
has_many :items, :class_name => 'OrderItem'
def add(product)
items << items.build(:product => product, :quantity => 1)
end
class << self
def next_in_queue
first
end
end
end
|
require 'spec_helper'
describe "RSpec Configuration" do
describe "configuring Capybara without Cucumber" do
it "should not set the driver to selenium_with_firebug by default" do
Capybara.current_driver.should_not == :selenium_with_firebug
end
it "should set the driver to selenium_with_firebug when... |
class ImagesController < ApplicationController
before_action :set_image, except: [:create, :index]
def index
@images = Image.all
end
def create
@image = Image.new(image_params)
respond_to do |format|
if @image.save
format.html {redirect_to images_path, notice: "Image Successfully Uplo... |
require 'rails_helper'
RSpec.describe Api::V1::PlayersController, :type => :controller do
let(:game) { build(:game, :id => 10) }
let(:player) { build(:player, :game => game) }
let(:user) { player.user }
describe 'PATCH /games/:game_id/player' do
subject { patch :update, {game_id: 10, organization_id: 20} ... |
#!/usr/bin/env ruby
# vim: noet
module Fuzz
module Error
class FuzzError < StandardError
end
# Raised by Fuzz::Parser when results
# are accessed before they have been
# built (by calling Fuzz::Parser#parse)
class NotParsedYet < FuzzError
end
end
end
|
class BubbleSortService
attr_reader :array
def initialize array
@array = array
end
def perform
return array if array.size <= 1
swapped = true
while swapped do
swapped = false
0.upto(array.size-2) do |i|
if array[i] > array[i+1]
array[i], array[i+1] = array[i+1], a... |
Mock Test Examples
A bunch of code snippets to analyze. None of them has any description, but most demonstrate one specific concept from RB101. I would normally copy 5โ10 into a separate doc in Boostnote, and describe them there.
num = 5
if (num < 10)
puts "small number"
else
puts "large number"
end
[1, 2, 3].map... |
class WamSms
require 'httparty'
include HTTParty
# Disable SSL Verification on CA since
# its failing on this particular vendor
# until futher investigation on the issue
# verification of the CA is disabled,
# security risk is 'LOW'
default_options.update(verify: false)
# debug_output $stderr
b... |
class Address < ActiveRecord::Base
belongs_to :country
validates :first_name, :last_name, :address,
:zip, :city, :phone, :country, presence: true
end
|
module Netlink
class Error < StandardError; end
class DecodeError < StandardError; end # Base error class during decoding
class IncompleteMessageError < DecodeError; end # Need more data to continue decoding
end
|
require 'nested_config/version'
# Simple, static, nested application configuration.
#
# == Example
#
# require 'nested_config'
#
# class MyApp
# def self.configure
# yield config
# end
#
# def self.config
# @config ||= MyConfig.new
# end
#
# class MyConfig < NestedConfig
# end
#... |
require 'spec_helper'
describe "partners/edit" do
before(:each) do
@partner = assign(:partner, stub_model(Partner,
:people_type => "MyString",
:partner_receives_email => false,
:partner_receives_sms => false,
:customer_receives_email => false,
:customer_receives_sms => false,
... |
# The base class for direction
module Direction
class BaseDirection
# Make a left turn from current direction.
# To be implemented by sub classes.
# ====== Returns
# - the new direction after left turn
def turnLeft
raise NotImplementedError, 'BaseDirection is not intended to be used direct... |
class Evaluator < ActiveRecord::Base
has_many :evaluations, inverse_of: :evaluator, dependent: :restrict_with_error
has_many :workers, through: :evaluations
has_many :instruments, through: :evaluations
def name
first_name.to_s + ' ' + last_name.to_s
end
end
|
module Test
class Client < Evil::Client
settings do
param :subdomain, type: Dry::Types["strict.string"]
option :version, type: Dry::Types["coercible.int"], default: proc { 1 }
option :user, type: Dry::Types["strict.string"]
option :password, type: Dry::Types["coercible.string"], o... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.