text stringlengths 10 2.61M |
|---|
module Hermes
module Model
##
# Model used for storing words and the text associated with these words.
#
class Word < Sequel::Model
plugin :timestamps, :created => :created_at, :updated => :updated_at
##
# Validates the instance before creating or saving a record.
#
#
... |
# Write a method that takes a positive integer or zero, and converts it to a string
# representation.
# You may not use any of the standard conversion methods available in Ruby, such as
# Integer#to_s, String(), Kernel#format, etc. Your method should do this the old-fashioned way
# and construct the string by analyzi... |
#!/usr/bin/env ruby
# :title: PlanR::Query
=begin rdoc
(c) Copyright 2016 Thoughtgang <http://www.thoughtgang.org>
=end
require 'plan-r/document'
require 'plan-r/datatype/query'
module PlanR
=begin rdoc
A query storedin the Repository for later use.
=end
class StoredQuery < Document
PROP_ENGINE = :engines ... |
class Frame
def initialize
@roll1 = nil
@roll2 = nil
@extra_roll = nil
end
def add_roll(pins)
if @roll1.nil?
@roll1 = pins
elsif @roll2.nil?
@roll2 = pins
else
@extra_roll = pins
end
end
def add_bonus(roll)
@extra_roll = roll
self
end
def last_frame... |
require "open-uri"
require "chat_noir/version"
require "chat_noir/basic_search"
require "chat_noir/fetcher"
module ChatNoir
OPTIONS = { "Accept-Encoding" => "plain" }
def self.copyright(url)
begin
Fetcher.new(URI.open(url, OPTIONS)).copyright
rescue => e
puts "Error: #{e.message}"
nil
... |
puts "Select a valid mode [read|write|exit]"
action = gets.chomp
# if action == "read"
# puts "Entering read mode..."
# elsif action == "write"
# puts "Entering write mode..."
# elsif action == "exit"
# puts "Exiting the software. Bye bye"
# else
# puts "Invalid action."
# end
# switch case statement
# DRYam... |
# model to describe friend requests
class FriendRequest < ApplicationRecord
belongs_to :user
validate :stop_friending_yourself, :duplicate_friend_request, :already_friends
validates :friend_id, :user_id, presence: true
def stop_friending_yourself
errors.add(:user_id, "can't friend themself") if user_id == ... |
# frozen_string_literal: true
module Validators
class Labels < Base
include LabelsValidatorHelper
def initialize(fields)
@fields = fields
end
def validate(label)
@label = label
fields.each { |field| send(field) }
end
private
attr_reader :fields, :label
def colo... |
# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'js_invoker/version'
Gem::Specification.new do |spec|
spec.name = "js_invoker"
spec.version = JsInvoker::VERSION
spec.authors = ["J.Fukaya"]
spec.email = ["fuk... |
module TryPaper
# address object for recipient address
class Recipient
class InvalidDataError < StandardError; end
attr_accessor :name, :address1, :address2, :city, :state, :zipcode
attr_reader :formatted_address
def initialize(name = "", address1 = "", address2 = "", city = "", state = "", zip ... |
require 'test_helper'
class ChatSessionsControllerTest < ActionDispatch::IntegrationTest
test 'acces when feature chatbot is disabled' do
Feature.with_chatbot_disabled do
assert_raise(ActionController::RoutingError) do
put "/api/v1/chat_sessions/#{chat_sessions(:one).id}.json", params: {
... |
def fill_in_charity_information(options = {})
fill_in 'Name', :with => options[:name] || 'Bob\'s Bait and Tackle for the homeless'
fill_in 'Description', :with => options[:description] || 'Bob\'s Bait and Tackle is an awesome place to get bait and tackle.'
fill_in 'Website', :with => options[:website] || 'http://... |
Rails.application.routes.draw do
get 'sessions/new'
root 'statics#new'
get '/login', to: 'sessions#new'
post '/login', to: 'sessions#create'
delete 'logout', to: 'sessions#destroy'
resources :statics, only: [:new]
resources :posts, except: [:destroy]
resources :users, except: [:destroy, :index]
#... |
require File.dirname(__FILE__) + '/spec_helper'
describe MockedFixtures::MockFactory do
before do
@fixture = {:id => 6, :cid => 6, :name => 'Hot Mocks'}
end
[:rspec, :flexmock, :mocha].each do |type|
require "mocked_fixtures/mocks/#{type}"
describe "with #{type.to_s.titleize} integration" do
... |
class GitSecretsAutomated < Formula
desc ""
homepage ""
url "https://github.com/kartik1998/git-secrets-automated/archive/v1.0.0.tar.gz"
sha256 "dc31b17e20d9e47d882d840f81aea92826a0da156220a4a904cfd4b7d253cb45"
license ""
def install
bin.install "git-secrets-automated"
end
end
|
module JsonTableSchema
module Types
class Number < Base
def name
'number'
end
def self.supported_constraints
[
'required',
'pattern',
'enum',
'minimum',
'maximum',
]
end
def type
::Float
end
... |
input = File.readlines "input", "\n"
instructions = []
# Compass directions
NORTH = "N"
SOUTH = "S"
EAST = "E"
WEST = "W"
# Relative directions
LEFT = "L"
RIGHT = "R"
FORWARD = "F"
# Starting direction in degrees from NORTH
rotation = 90
position_x = 0
position_y = 0
input.each do |int|
type = int.split("")
in... |
class CreateItems < ActiveRecord::Migration
def change
create_table :items do |t|
t.string :name
t.string :model
t.string :serial
t.integer :category_id
t.integer :user_id
t.integer :price
t.datetime :end_of_warranty
t.string :purchase_location
t.datetime :pur... |
#
# Be sure to run `pod spec lint SGPlatform.podspec' to ensure this is a
# valid spec and to remove all comments including this before submitting the spec.
#
Pod::Spec.new do |s|
s.name = "SGPlatform"
s.version = "0.0.3"
s.summary = "Physical characteristics of iPhones and iPads."
s.descrip... |
class OrderLine < ActiveRecord::Base
belongs_to :product
belongs_to :order, :dependent => :delete
validates :amount , presence: true
validates :product_id , presence: true
validates :order_id , presence: true
before_destroy :delete_order
def delete_order
@pht = self.attributes
p @pht['order_id'... |
require_relative 'helper'
class TestSprite < Test::Unit::TestCase
RS = RubySketch
def sprite(*args, **kwargs)
RS::Sprite.new(*args, **kwargs)
end
def vec(*args, **kwargs)
RS::Vector.new(*args, **kwargs)
end
def image(w, h)
RS::Image.new Rays::Image.new(w, h)
end
def test_initialize()
... |
class Node
def initialize(data)
@data = data
@next = nil
end
attr_accessor :data, :next
def add(new)
if @next == nil
@next = new
elsif new.data < @next.data
new.next = @next
@next = new
else
@next.add(new)
... |
# Use this file to easily define all of your cron jobs.
#
# It's helpful, but not entirely necessary to understand cron before proceeding.
# http://en.wikipedia.org/wiki/Cron
# Example:
#
# set :output, "/path/to/my/cron_log.log"
#
# every 2.hours do
# command "/usr/bin/some_great_command"
# runner "MyModel.some_m... |
require 'test/unit'
require_relative 'words_from_string'
class WordFromStringTest < Test::Unit::TestCase
def test_0
p "But I didn't inhale, he said (emphatically)".split(' ')
p "But I didn't inhale, he said (emphatically)".scan(/[\w']+/)
end
def test_1
p WordFromString.new.word_from_string("But I did... |
require_relative 'factory_customizer'
module FactoryBoy
class Factory
include FactoryCustomizer
attr_reader :linked_class_name, :factory_name
def initialize(class_name, factory_name)
@factory_name = factory_name
@linked_class_name = class_name
yield if block_given?
end
def li... |
require "spec_helper"
require "mock_app"
require "rack/mock"
require "byebug"
RSpec.describe Rack::HttpTraceRejector do
let(:app) { MockApp.new }
let(:request) { Rack::MockRequest.new(subject) }
subject { Rack::HttpTraceRejector.new(app) }
context "when called with HTTP TRACE" do
it "should reject the req... |
require "open3"
require "fileutils"
require 'tmpdir'
module CherryPickingMoments
class Parapara
attr_reader :output_path
def initialize(file, rate: 3)
@file = file
@rate = rate
@output_path = Dir.tmpdir
end
def slice!
FileUtils.mkdir_p(@output_path)
cmd = "ffmpeg -ss 0... |
require 'csv'
module Importers
class CoreLogicLocationCSVImporter
DEFINITION_NAME = 'CoreLogic'.freeze
ATTRIBUTES = %w(
county_name
state
cbsa_name
zip_code
tier_name
new_listings_inventory_count
new_listings_inventory_count_12m_change
active_listings_inventory... |
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :map do
sequence(:name) { |n| "map #{n}" }
image_url "http://static.unchartedleague.com/maps/chateau.png"
end
end
|
require 'rails_helper'
RSpec.describe ManagementConsultancy::RateCard, type: :model do
subject(:rate_card) { build(:management_consultancy_rate_card) }
it { is_expected.to be_valid }
end
|
module SessionsHelper
def log_in(user)
session[:user_id] = user.id
end
# Calls the remember method on the input user object to generate a new token
# and save the token as a hash in the db. Creates two new cookies, one signed
# which holds the user.id, the other which holds the generated token.
d... |
require 'spec_helper'
describe Calibration do
let!(:sensor1) { FactoryBot.create(:sensor) }
let!(:sensor2) { FactoryBot.create(:sensor) }
let!(:sensor3) { FactoryBot.create(:sensor) }
let!(:sensor4) { FactoryBot.create(:sensor) }
let!(:calibration1) { FactoryBot.create(:calibration, offset: -2, start_at: 2.... |
class CreateArticles < ActiveRecord::Migration
def change
create_table :articles do |t|
t.references :author, null: false
t.foreign_key :users, column: :author_id, on_delete: :cascade
t.string :title, null: false, index: { unique: true }
t.text :content, null: false
... |
# use a stack to validate parenthesis completion
class Stack
def initialize
@store = []
end
def push(x)
@store.push(x)
end
def pop
@store.pop
end
def peek
@store.last
end
def empty?
@store.empty?
end
end
def paren_matcher(str)
stack = Stack.new
lsym = "{[(<"
rsym = "}]... |
module PhEMA
module HDS
class JsonTranslator
def initialize
@data_element_counter = 1
end
def measure_score(measure_score)
{
"name" => "Measure scoring",
"code" => "MSRSCORE",
"code_obj" => {
"code" => "MSRSCORE",
"system" =>... |
module Webex
module Meeting
# comment
class Report
include Webex
include Webex::Meeting
attr_accessor :recording_topic, :specify_url, :agenda, :registration,
:destination_address_after_session, :description, :email_address,
:duration_hours, :duration_m... |
require 'spec_helper'
describe Mongoid::History::Tracker do
before :each do
class ModelOne
include Mongoid::Document
include Mongoid::History::Trackable
field :name, type: String
belongs_to :user
embeds_one :one_embedded, as: :embedable
track_history
end
class Model... |
# frozen_string_literal: true
require 'set'
class KnightTravailsGame
BOARD_WIDTH = 8
POSSIBLE_MOVE_DELTAS = [-1, 1].product([2, -2]) + [-2, 2].product([1, -1])
def knight_moves(from_field, to_field)
raise 'Invalid fields provided to knight_moves' if
!valid_field?(*from_field) || !valid_field?(*to_fi... |
require 'test_helper'
class OauthClientsControllerTest < ActionController::TestCase
include Devise::TestHelpers
setup do
@admin = User.where(admin: true).first
@user = User.where(admin: false).first
@app = client_applications(:myapp)
@app_params = {
name: 'NewApp',
website: 'http://www.website.com',
... |
require 'spec_helper'
include AdiosNaco
describe Game do
context "when newly created" do
let(:game){ Game.create(:first_tick=>Time.at(10))}
# Would be nice if I stub in Time.now, but I'm not sure how to do this
# outside of an it-block as I don't think it is allowed in before or let block.
... |
class Activity < ApplicationRecord
belongs_to :zone
has_many :trip_activities
has_many :trips, through: :trip_activities
has_many :notes
has_many :users, through: :notes
validates :name, presence: true
validates :name, uniqueness: true
validates :address, presence: true
validates :address, uniqueness... |
FactoryGirl.define do
factory :user do
sequence(:name) { |n| "Person #{n}" }
sequence(:email) { |n| "person_#{n}@example.com"}
password "foobar"
password_confirmation "foobar"
factory :admin do
admin true
end
end
factory :workout do
date [2011, 10, 27]
duration [120]
... |
class AddColumnToFriendships < ActiveRecord::Migration[5.1]
def change
add_column(:friendships, :status, :string, :default => 0, :null=> false)
end
end
|
# frozen_string_literal: true
require 'rails_helper'
require 'sidekiq/testing'
require 'file_store/s3_store'
describe Jobs::RemoveUploadFromS3 do
let(:upload) { Fabricate(:upload) }
let(:fixture_file) { file_from_fixtures("logo.png") }
before do
GlobalSetting.stubs(:backup_uploads_to_s3_enabled).returns(tr... |
require 'rails_helper'
RSpec.describe Coupon, type: :model do
it{should belong_to :order}
describe "#coupon_active" do
context "#owner_changed? && #used? == true" do
before do
allow(subject).to receive(:owner_changed?).and_return(true)
allow(subject).to receive(:used?).and_return(true)
... |
require 'belafonte/errors'
require 'belafonte/argument/argv_processor'
require 'belafonte/argument/occurrence_normalizer'
module Belafonte
# Represents a command line argument
class Argument
attr_reader :name, :times
def initialize(options = {})
@name = options[:name]
@times = options[:times]
... |
class UserDishIngredient < ApplicationRecord
belongs_to :ingredient
belongs_to :user_dish
end
|
require "hash-from_mysql_query_result/version"
class Hash
module FromMysqlQueryResult
class << self
private
PARSE_STATUS = {
:header => 1,
:table_header => 2,
:table_body => 3,
:table_footer => 4,
:footer => 5
}
TABLE_FRAME_PATTERN = /\+\-+\+/
... |
class CardsController < ApplicationController
before_filter :ensure_logged_in
def new
@card = Card.new
end
def create
user = User.find session[:user_id]
card_data = params.require(:card).permit :number
@card = Card.new user_id: session[:user_id], number: card_data[:number]
@card.save
r... |
class Api::V1::YaumiyahController < Api::V1::ApiController
before_action :authenticate!
api :GET, '/yaumiyah', 'List yaumiyah'
param_group :auth, Api::V1::ApiController
description 'List yaumiyah'
formats ['json']
example '
[
{
"id": 6,
"name": "Tahajud",
"description": "I... |
require 'test_helper'
class ApplicationControllerTest < ActionController::TestCase
tests ApplicationController
fixtures :users, :accomplishments
context "on GET to index" do
setup { get :index }
should_respond_with :redirect
end
context "on GET to index with a user" do
setup do
@user = User.find 1
@... |
class User < ApplicationRecord
validates :name, :email, :uid, presence: true
has_many :job_users
has_many :jobs, through: :job_users
end
|
# Copyright (c) 2009-2011 VMware, Inc.
class VCAP::Services::Postgresql::PostgresqlError<
VCAP::Services::Base::Error::ServiceError
POSTGRESQL_DISK_FULL = [31801, HTTP_INTERNAL, 'Node disk is full.']
POSTGRESQL_CONFIG_NOT_FOUND = [31802, HTTP_NOT_FOUND, 'Postgresql configuration %s not found.']
POSTGRESQ... |
class NYTimesAPI
@@base_url = "https://api.nytimes.com/svc/books/v3/lists/"
@@api_key = ENV["NYT_API_KEY"]
# This is where I will store the various calls
# that can be made in the program.
#There should be a separate definition for
# each API call
def self.fetch_bestseller_list(date, category)
Book.... |
require 'pusher'
# A wrapper to external realtime service
class RealtimeMessager
CHANNEL_MATCHING_PETS = 'matching-pets'
EVENT_PET_CREATED = 'pet-created'
def publish(channel, event, message)
Pusher.trigger(channel, event, {
message: message
})
end
end
|
source 'https://rubygems.org'
gem 'rails', '3.2.7'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
# gem 'haml'
gem 'neo4j', '2.0.1'
gem 'neo4j-wrapper', '~> 2.0.1'
gem 'neo4j-core', '~> 2.0.1'
gem 'devise', '1.5.3'
gem 'devise-neo4j', :git => 'git://github.com/andreasronge/de... |
module MDB
class MarshalSerializer
# A fake content type for ruby marshal objects
def content_type
'application/mdb'
end
def serialize(obj)
#Marshal.dump(obj.nil? ? [] : [obj])
Marshal.dump obj
end
def deserialize(string)
Marshal.load string
end
end
class JSO... |
module Spiderable
module Connect
BASE_URL = 'http://www.spiderable.org'
def self.get_url_contents(url)
contents = Faraday.get("#{BASE_URL}/api/v1/pages.json?url=#{url}&token=#{Config.token}")
if contents.status == 200
JSON.parse(contents.body)['contents']
else
contents.... |
require "v1/base_decorator"
class V1::TripDecorator < V1::BaseDecorator
delegate :nickname
def name
year = model.start_date.blank? ? "" : model.start_date.strftime("%Y")
[year, country].join(" ").strip
end
def destination
[model.city, country].reject{ |v| v.blank? }.join(", ").strip
end
def ... |
class FontXkcdScript < Formula
head "https://github.com/ipython/xkcd-font/raw/master/xkcd-script/font/xkcd-script.ttf"
desc "xkcd-script"
homepage "https://github.com/ipython/xkcd-font"
def install
(share/"fonts").install "xkcd-script.ttf"
end
test do
end
end
|
BINARY_GAP_RGX = /1(0+)(?=1)/
def binary_gap(num)
matches = num.to_i.to_s(2).scan(BINARY_GAP_RGX)
longest_gap = matches.map(&:first).max_by(&:size)
longest_gap ? longest_gap.size : 0
end
|
# encoding: utf-8
d 'Add a new text file to the project'
arg_name "file_name"
command :add do |c|
c.action do |global_options,options,args|
exit_now! "Please specify a file name.", -20 if args.blank?
Glyph.run 'project:add', args[0]
end
end
|
class Developer < ActiveRecord::Base
has_attached_file :picture, default_url: ""
validates_attachment_content_type :picture, :content_type => %w(image/jpeg image/jpg image/png)
end
|
class Company < Customer
validates :cnpj, presence: true
def self.model_name
Customer.model_name
end
end
|
#!/usr/bin/env ruby
# frozen_string_literal: true
require 'bundler/setup'
Bundler.require(:default)
class Float
def c_to_f
9.0 * self / 5.0 + 32.0
end
end
class Nest < RecorderBotBase
BASE_NEST_URL = 'https://smartdevicemanagement.googleapis.com/v1/'
no_commands do
def refresh_access_token
cre... |
# frozen_string_literal: true
class InvoicesController < ApplicationController
before_action :find_one, except: %i[create index]
def index
render json: invoices, status: :ok
end
def show
render json: @invoice, status: :ok
end
def update
if @invoice.update(invoice_params)
render json: @... |
module Bitstamp
class API
# https://www.bitstamp.net/api/
DOMAIN = "www.bitstamp.net"
def api_methods
self.class.instance_methods(false)
end
end
end
|
Rails.application.routes.draw do
root 'hotels#index'
get 'suggestions', to: 'hotels#suggestions'
resources :hotels
end
|
module BlacklightSolrplugins
# FacetItem subclass to provide access to custom facet payloads.
# The accessor methods handle both cross-ref and doc-centric
# payload formats; we could create separate subclasses, but there's
# not much gain since we can't use them generically anyway.
class FacetItem < Blacklig... |
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :token_authenticatable, :confirmable,
# :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
has_many :blogs
after_... |
class RemoveAndAddSomeColumnsToWineries < ActiveRecord::Migration
def up
add_column :wineries, :logo, :string, :limit => 100
add_column :wineries, :address, :string, :limit => 100
add_column :wineries, :official_site, :string, :limit => 100
add_column :wineries, :email, :string, :limit => 50
add_c... |
class TransactionsController < ApplicationController
belongs_to :user
belongs_to :coin
end
|
class AddInReplyToStatusToTweet < ActiveRecord::Migration
def change
add_column :tweets, :in_reply_to_status_str, :string
add_index :tweets, :in_reply_to_status_str
end
end
|
require 'rails_helper'
RSpec.describe CampaignsController, type: :controller do
let(:user) { create(:user) }
let(:user_1) { create(:user, email: 'n@mail.com') }
let(:user_2) { create(:user, email: 'm@mail.com') }
let(:campaign) { create(:campaign) }
describe 'GET #view_feedbacks' do
it 'should return us... |
feature "Portal - Edit" do
context 'Visitor' do
scenario "Access invalid" do
portal = create :portal
visit edit_portal_path portal
expect(current_path).to eq new_session_path
end
end
context 'Admin' do
let(:user) { create :user}
backgrou... |
class AddPhoneNoToStudents < ActiveRecord::Migration[5.0]
def change
add_column :students, :phoneno, :bigint
end
end
|
# frozen_string_literal: true
class CatsController < ApplicationController
before_action :authenticate_user!, except: %i[index show]
before_action :set_cat, only: %i[show edit update destroy]
before_action :user_id_verification, only: %i[edit update destroy]
def index
@photos = Photo.includes(:cats).order... |
RSpec::Matchers.define :have_principal do |parameters|
match do |key_type|
key_type.has_principal_with_permission?(parameters, @permission)
end
chain :with_permission do |permission|
@permission = permission
end
end
|
require 'spec_helper_acceptance'
hostname = default.node_name
describe 'managing java private keys' do
it 'creates a private key' do
pp = <<-EOS
class { 'java': }
java_ks { 'broker.example.com:/etc/private_key.ks':
ensure => latest,
certificate => "/etc/puppet/ssl/certs/#{host... |
#! /usr/bin/env ruby
require 'pg'
require 'io/console'
class ExpenseData
def initialize
@db = PG.connect dbname: 'expenses'
setup_schema
end
def add(amount, memo)
@db.exec_params "INSERT INTO expenses (amount, memo) VALUES ($1, $2)", [amount, memo]
end
def list
results = @db.exec "SELECT *... |
module Gsa18f
class ProcurementPolicy < ProposalPolicy
include GsaPolicy
def initialize(user, record)
super(user, record.proposal)
@procurement = record
end
def can_create!
super && gsa_if_restricted!
end
alias_method :can_new!, :can_create!
def can_cancel!
not_c... |
class RunTypesController < ApplicationController
before_filter :require_admin
# GET /run_types
# GET /run_types.json
def index
@run_types = RunType.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @run_types }
end
end
# GET /run_types/1
# G... |
module ApplicationHelper
# include TweetButton
def icon(name, content)
raw("<i class=\"icon-#{name}\"></i> ") + content
end
def is_active?(path)
"active" if current_page?(path)
end
def is_current?(path)
current_page?(path)
end
def content_tag_for(url, title, id)
content_tag... |
# frozen_string_literal: true
class UpdateGLYCMembers
def initialize(pdf)
@pdf = pdf.respond_to?(:tempfile) ? pdf.tempfile : pdf
end
def update
scan_for_emails
update_members
end
private
def reader
@reader ||= PDF::Reader.new(@pdf)
end
def scan_for_emails
@all_emails = []
rea... |
require 'spec_helper'
describe Admin::ReceptionsController do
describe 'GET new' do
it 'sets @reception'do
get :new
expect(assigns(:reception)).to be_instance_of(Reception)
end
end
describe 'POST create' do
let(:event) { Fabricate(:event) }
context 'with valid input' do
before... |
require File.expand_path('../lib/mysql-kissmetrics/version', __FILE__)
Gem::Specification.new do |gem|
gem.authors = ["Drew Gillson"]
gem.email = ["drew.gillson@gmail.com"]
gem.description = %q{Quickly load historic behavior from Magento into KISSMetrics}
gem.summary = %q{Integrate ... |
class SportsLeague < ActiveRecord::Base
has_many :fantasy_players, dependent: :destroy
validates :championship_date, presence: true
validates :name, presence: true
validates :trade_deadline, presence: true
validates :waiver_deadline, presence: true
def self.select_sports_league_columns
select("sports_... |
require 'spec_helper'
require 'cache_helper'
describe Irobot::Request do
before(:all) do
Irobot.configure do |c|
c.cache = RequestCacheTest.new
end
end
after(:all) do
Irobot.configure do |c|
c.delete(:cache)
end
end
context 'class methods' do
it 'will provide an allowed? met... |
require 'spec_helper'
describe 'puppetmaster::puppetboard' do
extra_facts = { ipv4_lo_addrs: '127.0.0.1',
ipv6_lo_addrs: '::1',
ipv4_pri_addrs: '10.50.0.1',
ipv6_pri_addrs: '::1' }
let(:node) { 'puppet.example.org' }
let(:params) do
{
timezone: ... |
module TypeOperations
module TypeConverter
private
def correct_data_type?(type_array, type)
return type_array.include? type.to_sym
end
def struct_to_string(struct)
result = ''
struct.to_h.each do |key, value|
if key == :col_name
result += "#{value.to_s} "
... |
class AddDefaultValuesForUser < ActiveRecord::Migration[5.1]
def change
change_column :users, :height, :integer, default: 0
change_column :users, :weight, :integer, default: 0
change_column :users, :regularity_id, :integer, default: 0
change_column :users, :goal_id, :integer, default: 0
end
end
|
require 'dm-core'
class Supplier
include DataMapper::Resource
property :id, Serial
property :name, String
property :address, String
end
|
class IssuesController < ApplicationController
before_action :select_issue, only: [:show, :edit, :update, :destroy]
before_filter :authorize
def index
@issues = Issue.open_issues && Issue.public_issues
end
def new
@issue = Issue.new
end
def create
@issue = Issue.new(issue_params)
@issue... |
# frozen_string_literal: true
require 'bigdecimal'
module FatCore
# Extensions to BigDecimal class
module BigDecimal
# Provide a human-readable display for BigDecimal. e.g., while debugging.
# The inspect method in BigDecimal is unreadable, as it exposes the
# underlying implementation, not the number... |
class UsersMovie < ApplicationRecord
belongs_to :user, dependent: :destroy
has_many :movies
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"
$docker = <<SCRIPT
sudo apt-get -y update
sudo apt-get install -y docker.io
sudo ln -sf /usr/bin/docker.io /usr/local/bin/docker
sudo sed -i '$acomplete -F _docker d... |
# verify ruby dependency
verify_ruby 'F5 Plugin'
# check required attributes
verify_attributes do
attributes [
'node[:newrelic][:license_key]',
'node[:newrelic][:f5][:agents]',
'node[:newrelic][:f5][:install_path]',
'node[:newrelic][:f5][:user]'
]
end
verify_license_key node[:newrelic][:license_k... |
class ChangeEventableNullTrueToMatches < ActiveRecord::Migration[6.1]
def change
change_column_null(:matches, :eventable_type, true)
change_column_null(:matches, :eventable_id, true)
end
end
|
class GetTimeSeriesRateService < FixerService
def initialize(start_date:, end_date:, base:, symbols:)
@start_date = start_date
@end_date = end_date
@base = base
@symbols = symbols
end
def call
cache = cache_service(key: "#{@start_date}#{@end_date}#{@base}#{@symbols}")
if cache.hit?
... |
class Actor
include Mongoid::Document
field :id, type: Integer
field :login, type: String
field :gravatar_id, type: String
field :url, type: String
field :avatar_url, type: String
embedded_in :event
end
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.