text stringlengths 10 2.61M |
|---|
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby '2.6.3'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 6.0.x'
# Use postgresql as the database for Active Record
gem 'pg', '>= 0.18', '< 2.0'
# Use Puma as the app server
gem 'puma', '~... |
class UserAnalyticsPresenter
include ApplicationHelper
include DashboardHelper
include ActionView::Helpers::NumberHelper
include Reports::Percentage
include BustCache
def initialize(current_facility)
@current_facility = current_facility.source
end
attr_reader :current_facility
CACHE_VERSION = 5... |
# frozen_string_literal: true
require 'autosign/validator/validator_base'
module Autosign
module Validator
# Validate certificate signing requests using a simple password list.
# This is not a very secure or flexible validation scheme, but is provided
# because so many existing autosign policy scripts imp... |
Gem::Specification.new do |s|
s.name = 'argshelper'
s.version = '0.1.11'
s.date = Time.now.strftime('%Y-%m-%d')
s.summary = 'Command line arg aid'
s.description = 'A simple command line argument helper'
s.authors = [ "sleepless-p03t" ]
s.email = 'sleepless.genesis6@gmail.com'
s.files = [ "lib/argshelper.rb" ]
... |
class Url
include Enumerable
attr_accessor :urls
def initialize(key)
@urls = Utils::get_webhook_urls(key).uniq
return @urls
end
def new(key)
end
def each(&block)
@urls.each(&block)
end
def <<(url)
@urls << url
end
def delete(url)
@urls.delete(url)
end
def uniq
@... |
# frozen_string_literal: true
class CreateProducts < ActiveRecord::Migration[5.2]
def change
create_table :products do |table|
table.belongs_to :category, index: true
table.string :name, null: false
table.string :description, null: false
table.integer :price, null: false
table.float... |
require 'rails_helper'
feature 'Vendor manages invoices' do
let :vendor { FactoryGirl.create(:vendor_with_stripe_acct) }
before do
login_as(vendor, scope: :vendor)
end
scenario 'by creating new invoice' do
visit new_invoice_path
expect(page).to have_content 'New Invoice'
fill_in 'invoice[name... |
class Knight < Piece
include Steppable
# sorted clockwise using row, column coordinates
KNIGHT = [
[-2,1],
[-1,2],
[1,2],
[2,1],
[2,-1],
[1,-2],
[-1,-2],
[-2,-1],
]
def try_moves
KNIGHT
end
def... |
puts "Hi, there!"
while true
answer = gets.chomp
if answer == "I'm a dummy"
puts "I'm not stupid"
break
end
puts answer
end
|
class ScreenshotWorker
include Sidekiq::Worker
def perform(url, slug)
image_path = "/Users/fscott/Personal/projects/webnark/webnark-rails/public/screenshots"
image = `/Users/fscott/Personal/projects/webnark/screenshot/make_screenshot.sh '#{url}'`
if not image or image.empty?
FileUtils.cp("#{ima... |
shared_examples_for 'a RESTful controller with an index action' do
before :each do
path_name_setup
end
describe "handling GET /plural (index)" do
before(:each) do
@object = stub(@model_name)
@objects = [@object]
@model_class.stubs(:find).returns(@objects)
do_login if needs_log... |
class ApplicationController < ActionController::Base
attr_accessor :current_user
helper_method :current_user, :logged_in?
def log_in_user!(user)
session[:session_token] = user.reset_session_token!
@current_user = user
flash[:success] = "Successfully logged in."
redirect_t... |
require 'test_helper'
class TeamcommitmentsControllerTest < ActionController::TestCase
def test_should_get_index
get :index, {}, { :user_id => users(:fred).id }
assert_response :success
assert_not_nil assigns(:teamcommitments)
end
def test_should_get_new
get :new, {}, { :user_id => users(:fred)... |
require 'optics-agent/rack-middleware'
require 'optics-agent/instrumenters/field'
require 'optics-agent/reporting/report_job'
require 'optics-agent/reporting/schema_job'
require 'optics-agent/reporting/query-trace'
require 'optics-agent/reporting/detect_server_side_error'
require 'net/http'
require 'faraday'
require 'l... |
class MoviesController < ApplicationController
def index
end
def show
@movie = Movie.find(params[:id])
end
def list
@movies = Movie.all
end
def new
@movie = Movie.new
end
def create
@movie = Movie.new(movie_params)
if @movie.save
redirect_to "/movies/#{@movie.id}"
else
render :new
end
... |
class TaskRepository
def find_by_id(id)
Task.find(id)
end
def find_by_user_and_task_id(user, task_id)
user.tasks.find_by_id(task_id)
end
def update_from_user_and_attributes(user, attributes)
task = user.tasks.find_by_id(attributes[:id])
return nil unless task
attrs = validate_attrs(attr... |
class CreateDiverseExpensesOfManagements < ActiveRecord::Migration
def change
create_table :diverse_expenses_of_managements do |t|
t.string :name
t.string :amount
t.string :expenses
t.string :total_delivered
t.integer :cost_center_id
t.float :percentage
t.timestamps
... |
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
# protect_from_forgery with: :exceptionz
include Pundit
rescue_from Pundit::NotAuthorizedError, with: :permission_denied
layout :page_layout
# Filt... |
class AddAttachmentDocument3ToProgramas < ActiveRecord::Migration[5.1]
def self.up
change_table :programas do |t|
t.attachment :document3
end
end
def self.down
remove_attachment :programas, :document3
end
end
|
# frozen_string_literal: true
ActiveAdmin.register Tag do
permit_params :name, :color, :description
index do
id_column
column :name do |t|
status_tag(t.name, style: "background-color: #{t.color}")
end
column :description
actions
end
filter :name
end
|
# -*- coding: utf-8 -*-
class Tile
FREQ = {
brick: 3,
wood: 4,
desert: 1,
sheep: 4,
ore: 3,
wheat: 4
}
SYMBOLS = {
2 => "②",
3 => "③",
4 => "④",
5 => "⑤",
6 => "⑥",
7 => "⑦",
8 => "⑧",
9 => "⑨",
10 => "⑩",
11 => "⑪",
12 => "⑫"
}
attr_acce... |
class TypeOfReceivedLetter < ActiveRecord::Base
has_many :received_letters
end
|
class VotesController < ApplicationController
def create
if params[:video_id]
@element = Video.find(params[:video_id])
@voter = Tempuser.where("pku_id = ?",vote_params[:pku_id]).last
if @voter
@voter.like(@element)
@vote = @element.votes.create(vote_params)
respond_to do |f|
f.js
... |
class User < ActiveRecord::Base
authenticates_with_sorcery! do |config|
config.authentications_class = Authentication
end
has_many :authentications, dependent: :destroy
accepts_nested_attributes_for :authentications
has_many :packs
belongs_to :current_pack, class_name: 'Pack', foreign_key: 'current_pac... |
class Comment < ApplicationRecord
# Associations
# belongs_to :parent, class_name: 'Comment', foreign_key: 'parent_id', :optional => true
# has_many :children, class_name: 'Comment', foreign_key: 'parent_id', dependent: :destroy
belongs_to :post
belongs_to :user
has_ancestry
end
|
class Menu < ApplicationRecord
has_many:orders
validates :name, presence: { message: "Nama menu harus diisi" }, length: { in:3..25 }
validates :price, presence: { message: "price harus diisi" }, numericality: true
end
|
class Duck
def initialize(name)
@name = name
end
def eat
puts("Duck #{@name} is eating.")
end
def speak
puts("Duck #{@name} says Quack!")
end
def sleep
puts("Duck #{@name} sleeps quietly.")
end
end
class Frog
def initialize(name)
@name = name
end
def eat
puts("Frog #{@... |
# frozen_string_literal: true
RSpec.describe SC::Billing::Stripe::PaymentSources::CreateOperation, :stripe do
subject(:call) do
described_class.new.call(user, token)
end
let(:stripe_customer) { Stripe::Customer.create }
let(:user) { create(:user, stripe_customer_id: stripe_customer.id) }
let(:token) { s... |
require 'todobot/services/base_service'
module TodoBot
module Lists
class CreateListService < BaseService
def execute
if name.present?
create_list
else
set_status
end
end
private
attr_reader :name
def post_initialize(args)
@name... |
class PlayerTournamentsController < ApplicationController
before_action :set_player_tournament, only: [:show, :update, :destroy]
# GET /player_tournaments
def index
@player_tournaments = PlayerTournament.all
render json: @player_tournaments
end
# GET /player_tournaments/1
def show
render json... |
class User < ActiveRecord::Base
has_many :performer_tasks, :class_name => "Task", :foreign_key => "performer_user_id"
has_many :requester_tasks, :class_name => "Task", :foreign_key => "requester_user_id"
has_many :creator_decisions, :class_name => "Decision", :foreign_key => "creator_user_id"
has_many :task_sha... |
class MovementsController < ApplicationController
helper_method :sort_column, :sort_direction, :sort_apartment_column
before_action :logged_in_user
before_action :movement_getter, except: [:index, :new, :create]
before_action :permissions, except: [:index, :show, :children, :create]
before_action :check_amoun... |
class UsersController < ApplicationController
def new
@user = User.new
end
def create
@user = User.new(params[user_params])
if @user.save
redirect_to @user, notice: "Thank yo for signing up for Ribbit"
else
render 'new'
end
end
private
# Never trust parameters from the scary internet, only al... |
class Notification < ActiveRecord::Base
belongs_to :user
belongs_to :group
belongs_to :status
validates :description, presence: true
validates :recipient, presence: true
class << self
def unread(user)
where("id > ? and #{notify_condition}",
user.last_checked_notification,
user.id... |
#
# Cookbook Name:: wercker-develop
# Recipe:: wercker-sentinel
#
# Copyright 2013, wercker
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitati... |
module Acl9
module ModelExtensions
module ForSubject
def role_for(object)
(role_objects.select(&role_selecting_lambda(object)).first.try(:name) || '').downcase.to_sym
end
private
# TODO Update gem and remove if/when my pull request gets accepted (https://github.com/be... |
module Home::Index
def self.table_name_prefix
'home_index_'
end
end
|
class Airport < ApplicationRecord
# Needs a migration for indexes and references(?)
has_many :departing_flights, class_name: "Flight",
foreign_key: "from_id"
has_many :arriving_flights, class_name: "Flight",
foreign_key: "to_id"
end
|
class AddMeasurementFieldsToTopics < ActiveRecord::Migration[5.0]
def change
change_table :topics do |t|
t.float :min_value
t.float :max_value
t.float :step
t.string :units_of_measurement, array: true
end
end
end
|
describe RecipeManager do
describe "#initialize" do
it "should instantiate properly" do
test = RecipeManager.new
expect(test).not_to be_nil
end
end
describe "#add_category" do
before :each do
@test = RecipeManager.new
end
it "should allow a category to be added" do
@t... |
#!/usr/bin/env ruby
require 'date'
require 'optparse'
def make_calendar(year, month)
caption = "#{month}月 #{year}".center(20)
header = '日 月 火 水 木 金 土'
first = Date.new(year, month, 1)
last = Date.new(year, month, -1)
spaces = Array.new(first.wday, '')
days = [*first.day..last.day]
weeks = (spaces + d... |
module Enumerable
def my_each
if !block_given?
return self
else
for i in self
yield(i)
end
end
end
def my_each_with_index
if !block_given?
return self
else
for i in self
yield(i,self.index(i))
end
end
end
def my_select
arr = []
for i in self
if yield(i)
arr.push... |
# encoding: UTF-8
require "minitest_helper"
require "ostruct"
require "airbrussh/command_formatter"
class Airbrussh::CommandFormatterTest < Minitest::Test
def setup
@sshkit_command = OpenStruct.new(
:host => host("deployer", "12.34.56.78"),
:options => { :user => "override" },
:runtime => 1.23... |
class RentsController < ApplicationController
before_filter :authenticate_user!
before_filter :set_artwork
layout 'kunst'
# Get content about rent process and show it to user
#
def new
@page = Page.find_by_title('Huren bij Xposers')
end
# Register new rental and emails user
#
def create
@... |
LightningTalker::Application.routes.draw do
resources :users
resources :topics do
put 'claim' => 'topics#claim', on: :member
put 'unclaim' => 'topics#unclaim', on: :member
get 'schedule' => 'topics#schedule', on: :collection
end
resources :sessions, only: [:new, :create]
get 'sign_up' => 'users... |
class AddConfigToCrawler < ActiveRecord::Migration
def self.up
add_column :crawlers, :config, :text, :null => false
end
def self.down
remove_column :crawlers, :config
end
end
|
# Usage: $ ruby find_common_layers.rb path/to/folder [path_filter] [layer_filter]
#
# Reads a sample (n=500) of the grib2 inventories deeper than the given directory and outputs the common layers to STDOUT.
#
# Uncommon layers are output to STDERR.
#
# Optional `path_filter` is straight Ruby you can provide. The path i... |
##
# *this class controls the orders' actions
# *created using scaffold
# *the class methods are all common controller methods
# [index] the index page for model is defined
# [show] the page for each specific model instance eg. cart[6] is defined
# [new] the page for creating new model instances is defined
# [create... |
require 'spec_helper'
require 'rails_helper'
require Rails.root.join("spec/helpers/restaurant_helper.rb")
describe RestaurantsController, "test" do
context "Index action" do
before :each do
@admin = create(:user)
@admin.update_column(:admin_role, true)
@user1 = create(:user)
@restaurant ... |
# prereqs: iterators, hashes, conditional logic
# Given a hash with numeric values, return the key for the smallest value
def key_for_min_value(name_hash)
min_k = nil
min_v = nil
name_hash.each do |key, value|
# returns the KEY of the smallest VALUE in the hash
if min_v == nil
min_v = value
m... |
class REntriesToLinksController < ApplicationController
before_action :set_r_entries_to_link, only: [:show, :edit, :update, :destroy]
# GET /r_entries_to_links
# GET /r_entries_to_links.json
def index
@r_entries_to_links = REntriesToLink.all
end
# GET /r_entries_to_links/1
# GET /r_entries_to_links/... |
class Fight < ActiveRecord::Base
belongs_to :player
belongs_to :enemy
end |
class Task < ApplicationRecord
#validations
validates :name, presence: true
#associations
belongs_to :project
has_many :comments
module Status
FRESH = 'fresh'.freeze
DONE = 'done'.freeze
ALL = Task::Status.constants.map{ |roles| Task::Status.const_get(roles) }.flatten.uniq
end
module Prio... |
#!/usr/bin/env ruby
require 'optparse'
require 'ostruct'
require 'json'
require_relative '../lib/WRAzureNetworkManagement'
require_relative '../lib/WRAzureWebServers'
require_relative '../lib/CSRELogger'
@options = OpenStruct.new
@options[:location] = 'WestEurope'
def parse_args(args)
opt_parser = Optio... |
class Recipe < ApplicationRecord
paginates_per 2
has_one_attached :image
# could also attached more than one image wiht has_many_attached
end |
# Copyright (C) 2008-2015 Kouhei Sutou <kou@clear-code.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
... |
module AdminLte
class AuthorizedstaffsController < AdminLte::ApplicationController
respond_to :json, :html
before_action :set_authoriziedstaff, only: [:show, :edit, :update, :destroy]
# GET /faculties
# GET /faculties.json
def index
@authoriziedstaffs = Authorizedstaff.all
end
# GE... |
module Flint
def self.declare(*args)
Sass::Script::Functions.declare(*args)
end
#
# Use ruby functions
#
# @return {Bool}
#
def flint_use_ruby()
Sass::Script::Bool.new(true)
end
#
# Fetch value from map
#
# @param {Map} map - map to fetch value from
# @param {ArgList} keys - ... |
class CreateSpeakers < ActiveRecord::Migration
def self.up
create_table :speakers do |t|
t.string :name
t.text :bio
t.string :presentation
t.text :description
t.string :filename
t.integer :size
t.string :content_type
t.timestamps
end
add_index :speaker... |
require 'fileutils'
Then(/^I should receive a file '([^']*)' of type '([^']*)' matching:$/) do |file_name, mime_type, table|
begin
content_type = page.response_headers['Content-Type']
content_disposition = page.response_headers['Content-Disposition']
expect(content_type).to eq(mime_type)
expect(conte... |
require "hotel_beds/parser"
module HotelBeds
module Parser
class CancellationPolicy
include HotelBeds::Parser
attribute :amount, attr: "amount"
attribute :from_date, attr: "dateFrom"
attribute :from_time, attr: "time"
attribute :add_to_cart_from_date, selector: "DateTimeFrom", att... |
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Tested with Vagrant 2.0.2 https://releases.hashicorp.com/vagrant/2.0.2/
require 'fileutils'
require 'find'
require 'pathname'
vagrant_use_proxy = ENV.fetch('VAGRANT_USE_PROXY', nil)
http_proxy = ENV.fetch('HTTP_PROXY', nil)
box_name = ENV.fetch('BOX_NAME', 't... |
module Smite
class Queue < Smite::Object
QUEUES = [
{ 'name' => 'Conquest', 'id' => 426 },
{ 'name' => 'MOTD', 'id' => 434 },
{ 'name' => 'Arena', 'id' => 435 },
{ 'name' => 'JoustLeague', 'id' => 440 },
{ 'name' => 'Assault', 'id' => 445 },
{ 'name' => 'Joust3v3', 'id' => 448 ... |
# Documentation: https://docs.brew.sh/Formula-Cookbook
# https://rubydoc.brew.sh/Formula
# PLEASE REMOVE ALL GENERATED COMMENTS BEFORE SUBMITTING YOUR PULL REQUEST!
class TencentMarsXlogUtil < Formula
version "0.1.4"
desc "腾讯Xlog 日志解码"
homepage "https://github.com/0x1306a94/tencent-mars-xlog-rust"
... |
class SetPlaceDefaultRating < ActiveRecord::Migration
def up
change_column_default :places, :rating, 0
end
def down
change_column_default :places, :rating, nil
end
end
|
class FileChunk < ApplicationRecord
has_attached_file :data
belongs_to :chunked_upload_task
validates :data, presence: true
validates_attachment_content_type :data, content_type: /.+\/.+/
validates :chunked_upload_task, presence: true
end
|
# -*- encoding: utf-8 -*-
# stub: opengraph 0.0.4 ruby lib
Gem::Specification.new do |s|
s.name = "opengraph"
s.version = "0.0.4"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.require_paths = ["lib"]
s.authors = ["Michael Bleigh"]
s.date = "2010-... |
json.array! @banners do |b|
json.id b.id
json.url b.image.url
json.filename File.basename(b.image.url)
end
|
module MoneyMover
module Dwolla
class CustomerFundingSourceResource < BaseResource
list_filters :removed
endpoint_path "/customers/:customer_id/funding-sources", action: [:list, :create]
endpoint_path "/funding-sources/:id", action: [:update, :destroy, :find]
end
end
end
|
class Stop < ActiveRecord::Base
has_and_belongs_to_many :buses
has_many :sapeadas
has_many :centroids
end
|
class BlogsController < ApplicationController
before_action :authenticate_user!, only: [:new, :create, :index, :edit, :update, :destroy]
before_action :correct_blog_owner, only: [:edit, :update, :destroy]
before_action :set_blog, only: [:show, :edit, :update, :destroy]
respond_to :json
def new
@blog = Blog.... |
module Avito
module API
module V1
class Advertisements < Grape::API
resource :advertisements do
get '/', jbuilder: 'advertisements/index', skip_auth: true do
@ads = rom.relations.advertisements.filter(params).to_a
end
params do
requires :title, ... |
#------------------------------------------------------------------------------
# FILE: filter-neon-kube.rb
# CONTRIBUTOR: Jeff Lill, Marcus Bowyer
# COPYRIGHT: Copyright (c) 2016-2020 by neonFORGE LLC. All rights reserved.
#
# This Fluentd filter plugin detects container log events forwarded by Kubernetes... |
require 'spec_helper'
require './spec/features/web_helpers'
feature '#signup', %q{
As a Maker
So that I can post messages on Chitter as me
} do
scenario 'I want to sign up for Chitter' do
expect { signup }.to change { User.count }.by(1)
end
scenario '&& a successful signup should not throw an error' ... |
# Write a method that takes a String of digits, and returns the appropriate
# number as an integer. You may not use any of the methods mentioned above.
# I.E * Integer() .to_i
def check_which_num(mini_string)
case mini_string
when '1' then 1
when '2' then 2
when '3' then 3
when '4' then 4
when '5' then 5
... |
class Post < ApplicationRecord
has_many :choses, class_name: 'Chose', foreign_key: "posts_id"
scope :pager, ->(page: 1, per: 10) {
num = page.to_i.positive? ? page.to_i - 1 : 0
limit(per).offset(per * num)
}
end
|
require 'test_helper'
class Logic::NginxProxyTest < ActionController::TestCase
def setup
@provider = FactoryBot.create(:provider_account)
end
def test_generate_proxy_zip
assert @provider.generate_proxy_zip
end
def test_generate_proxy_zip_oauth
@provider.services.update_all(backend_version: 'oa... |
# Cookbook Name:: selenium
#
# Copyright 2013, NetSrv Consulting Ltd.
#
# 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 by... |
class MeetingsController < ApplicationController
before_action :set_meeting, only: [:show, :edit, :update, :destroy]
before_action :authenticate_user!
def index
@meetings = current_user.meetings
end
def all_users_meetings
@meetings = Meeting.all
end
def show
end
def new
@meeting = Me... |
# encoding: utf-8
class ZipFile < ActiveRecord::Base
default_scope order: 'id desc'
attr_accessible :name,:file,:download
mount_uploader :file, FileUploader
end |
class ChangeCommentAndAttachmentDefaultsOnPosts < ActiveRecord::Migration
def self.up
change_column_default :posts, :attachment_count, 0
change_column_default :posts, :comment_count, 0
end
def self.down
change_column_default :posts, :comment_count, "NULL"
change_column_default :posts, :attachment... |
module ApiPresenter
module Parsers
# Parses values into array of acceptable association map keys:
# * Removes blanks and dups
# * Underscores camel-cased keys
# * Converts to symbol
#
# @param values [String, Array<String>, Array<Symbol>] Comma-delimited string or array
#
# @return [A... |
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
after_initialize :init
has_many :daily_activities, ... |
module Comments
module CommentMethods
extend ActiveSupport::Concern
def self.included(comment_model)
comment_model.extend Finders
comment_model.scope :in_order, -> { comment_model.order('created_at ASC') }
comment_model.scope :recent, -> { comment_model.reorder('created_at DESC') }
end... |
require "spec_helper"
describe Api::TransactionsController, type: :controller do
describe "GET #index" do
it "should query 2 Transactions" do
user = create(:user)
login(user)
product = create(:product)
create_list(:transaction,
2,
product_id: product.id... |
Rails.application.routes.draw do
# The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes".
# You can have the root of your site routed with "root"
root 'pages#index'
resources :patients, only: [:show] do
end
get '/login' =>... |
class BankAccount
@@no_of_accounts = 0
def initialize
set_number
@checking = 0
@savings = 0
@interest_rate = 0
end
def get_number
puts @account_number
self
end
def get_checking
puts @checking
self
end
def get_savings
puts @savings
self
end
def get_total
puts @savings + @checking
se... |
class ComponentDashboardSerializer < ActiveModel::Serializer
attributes :id, :row, :col, :endpoint, :secret_key, :response_data_location, :refresh_time, :title, :subtitle, :sizeX, :sizeY
belongs_to :component
end
|
require 'thor'
require 'fileutils'
require 'highline'
require 'f5_tools'
require 'json'
require 'utils/cli_utils'
module F5_Tools::CLI
# 'Define' Subcommand CLI Class. See thor help for descriptions of methods
class Define < Thor
include F5_Object
include F5_Tools::Resolution
include F5_Tools::YAMLUti... |
require 'spec_helper'
describe Immutable::Hash do
[:to_hash, :to_h].each do |method|
describe "##{method}" do
it 'converts an empty Immutable::Hash to an empty Ruby Hash' do
H.empty.send(method).should eql({})
end
it 'converts a non-empty Immutable::Hash to a Hash with the same keys an... |
require 'rest-client'
require 'json'
require 'pry'
def get_character_movies_from_api(character_name)
response_string = RestClient.get("http://www.swapi.co/api/people/")
response_hash = JSON.parse(response_string)["results"]
film_urls = nil
film_array = []
response_hash.each_with_index do |char, index|
if... |
require 'spec_helper'
describe SearchPresenter, :type => :view do
let(:user) { users(:owner) }
before do
reindex_solr_fixtures
stub(ActiveRecord::Base).current_user { user }
end
describe "#to_hash" do
context "searching without workspace" do
before do
search = Search.new(user, :qu... |
# frozen_string_literal: true
class PaperTrailTestWithCustomAssociation < ActiveRecord::Base
self.table_name = :paper_trail_tests
has_paper_trail versions: {class_name: 'Trail'}
end
|
require 'rails_helper'
RSpec.describe Project do
describe "initialization" do
let(:project){Project.new}
let(:task){Task.new}
it "considers a project with no tasks to be done" do
expect(project.done?).to be_truthy
end
it "knows that a project with an incomplete task is not done" do
project.tasks... |
require_relative 'game_state'
require_relative 'state_main_game'
require 'gosu'
require_relative '../button'
require_relative '../input'
class StateMenu < GameState
def initialize(state_stack)
@state_stack = state_stack
@menu_font = Gosu::Font.new(50)
@frog_button = Button.new($window_x/2-110, $window_... |
require 'rails_helper'
RSpec.describe TravelPlan::Form, type: :model do
let(:account) { Account.new }
let(:form) { new_form }
subject { form }
def new_form
described_class.new(account.travel_plans.new)
end
# Returns the errors object for the given attributes. For convenience, if
# your attributes h... |
Vagrant.configure("2") do |config|
config.vm.provider "virtualbox" do |v|
v.memory = 2048
v.cpus = 1
end
config.vm.define "server1" do |server1|
server1.vm.hostname = "server1"
server1.vm.box = "ubuntu/bionic64"
server1.vm.network "private_network", ip: "192.168.60.50"
server1.vm.network "forwarde... |
module NoMethodErrorSpecs
class NoMethodErrorA; end
class NoMethodErrorB; end
class NoMethodErrorC;
protected
def a_protected_method;end
private
def a_private_method; end
end
class NoMethodErrorD; end
end
module ExceptionSpecs
class Exceptional < Exception; end
class Backtrace
d... |
class Ride < ActiveRecord::Base
# write associations here
belongs_to :attraction
belongs_to :user
def take_ride
user = self.user
attraction = self.attraction
if too_short?(user, attraction) || too_broke?(user, attraction)
return "Sorry. You do not have enough tickets to ride the #{attractio... |
class Maze
START = 's'
GOAL = 'g'
PATH = '.'
WALL = 'X'
WALL_INPUT = '1'
PATH_INPUT = '0'
def initialize(grids)
@grids = grids.map { |row| row.map { |col| convert_grid_value(col) } }
@num_rows = @grids.size
@num_cols = @grids.first.size
@grids = @grids.map { |row| [WALL] + row + ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.