text stringlengths 10 2.61M |
|---|
class User < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :validatable#, :confirmable
attr_accessor :current_password
# 8~... |
require 'json'
class ListsController < ApplicationController
def index
@public_lists = policy_scope(List.where(public: true))
authorize @public_lists
end
def show
@list = List.friendly.find(params[:id])
end
def new
@list = List.new
authorize @list
end
def create
@list = List.ne... |
class Question < ApplicationRecord
has_many :responses
belongs_to :user
belongs_to :topic, class_name: "Auth::Topic"
attachment :project_files
include Commentable
def has_topic(topic)
topic.each do |t|
if t == topic
return true
end
end
return false
end
end
|
require 'rails_helper'
RSpec.describe 'User updates Protocol in SPARC', type: :request, enqueue: false do
describe 'full lifecycle' do
it 'should update the Protocol', sparc_api: :get_protocol_1 do
protocol = create(:protocol, sparc_id: 1, sponsor_name: "Original sponsor name")
user_updates_protoc... |
class MealType < ActiveRecord::Base
acts_as_content_block({:versioned => false})
attr_accessible :name, :from, :to, :is_active, :from_display, :to_display, :first_slot, :second_slot, :third_slot
attr_accessor :skip_callbacks
validates :name, :from, :to, :from_display, :to_display, presence: true
validat... |
# -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require "blinky_billd/version"
Gem::Specification.new do |s|
s.name = "blinky_billd"
s.version = BlinkyBilld::VERSION
s.authors = ["James Ottaway"]
s.email = ["james@ottaway.mp"]
s.homepage = ""
s.summary = %... |
class Owner < ApplicationRecord
has_and_belongs_to_many :clubs
has_many :players, -> {distinct}, through: :clubs
end
|
# DO NOT CHANGE ANYTHING IN THIS FILE!
require "test/unit"
require_relative "./romanconvertor"
class TestRomanConvertor < Test::Unit::TestCase
@@randomValues = {
15 => "XV",
6 => "VI",
78 => "LXXVIII",
103 => "CIII"
}
@@specialValues = {
1 => "I",
5 => "V"... |
require_relative 'book'
module Contacts
class Manager
def initialize(book)
@book = book
end
def run
list
@running = true
prompt while @running
end
private
def list
puts "\n== Book =="
@book.list
end
def prompt
print "\n(L)ist, ... |
class StatusManager < ApplicationRecord
belongs_to :course, optional: true
belongs_to :project, optional: true
belongs_to :user, optional: true
belongs_to :article, optional: true
belongs_to :status, optional: true
end
|
RSpec.configure do |config|
config.include FactoryGirl::Syntax::Methods
# See lib/tasks/factory_girl.rake for FactoryGirl.lint task
end
|
#encoding: utf-8
module ActiveAdmin::ViewHelpers
def link_to_add_fields(name, f, association)
new_object = f.object.class.reflect_on_association(association).klass.new
fields = f.fields_for(association, new_object, :child_index => "new_#{association}") do |builder|
render("update_#{association.to_s}", :... |
module Elements
class EssenceResource < Essence
belongs_to :value, :class_name => '::Resource'
def serializable_hash(options=nil)
if value.present?
hash = value.serializable_hash
hash['href'] = value.url
hash['html'] = "#{value.title} (#{value.file_name})"
hash
el... |
class Crime < ApplicationRecord
has_many_attached :images
has_many_attached :files
has_one_attached :clip
has_many :messages
validate :check_past_date
def check_past_date
errors.add(:fecha, "debe ser en el pasado") unless fecha < DateTime.now
end
end
|
# -*- encoding : utf-8 -*-
require 'rails_helper'
RSpec.describe Comment, type: :model do
it 'has a valid factory' do
expect(create(:comment)).to be_valid
end
end
|
module CamaleonCms
module Metas
extend ActiveSupport::Concern
included do
# options and metas auto save support
attr_accessor :data_options
attr_accessor :data_metas
after_create :save_metas_options, unless: :save_metas_options_skip
before_update :fix_save_metas_options_no_cha... |
class User < ApplicationRecord
has_one :author
has_many :reviews
has_many :books, through: :reviews
has_secure_password
validates :agreement, acceptance: {on: :create}
validates :email, confirmation: true
end
|
class User < ActiveRecord::Base
validates :username, uniqueness: true
validates :username, :password, presence: true
def token
Digest::MD5.new.update(self.username + '%' + self.password).to_s
end
end
|
# You can have Landlord route to the appropriate Tenant by adding some Rack middleware.
# Landlord can support many different "Elevators" that can take care of this routing to your data.
# Require whichever Elevator you're using below or none if you have a custom one.
#
# require 'landlord/elevators/generic'
# require ... |
require 'submarine'
describe Submarine do
let(:sub){Submarine.new 'A2', :north}
let(:sub_north){Submarine.new 'B2', :north}
let(:sub_east){Submarine.new 'B2', :east}
let(:sub_south){Submarine.new 'B2', :south}
let(:sub_west){Submarine.new 'B2', :west}
it 'has size 2' do
expect(sub.size).to eq 2
end... |
class Item < ActiveRecord::Base
attr_accessible :name, :price, :sub_category_id
has_many :photos
has_many :reservations
belongs_to :sub_category
def primary_photo
self.photos.first
end
class << self
def new_arrivals
Item.where("created_at > ?", 3.days.ago).order("CREATED_AT DESC").limit(... |
class Site < ActiveRecord::Base
# has_many :site_inventories
has_many :items
has_many :line_items
has_many :invoices, through: :line_items
default_scope {where(:deleted => nil)}
end
|
class Cat < ApplicationRecord
COLORS = [
"red",
"blue",
"yellow",
"green",
"purple"
].freeze
validates :birth_date, :name, :description, presence: true
validates :sex, presence: true, inclusion: { in: %w(M F) }
validates :color, presence: true, inclusion: COLORS
def age
Date.tod... |
# frozen_string_literal: false
module AsciiPngfy
module Settings
# Reponsibilities
# - Keeps track of the text and replacement_text setting
# - Replaces unsupported text characters with replacement text
# - Validates text and replacement_text
# rubocop: disable Metrics/ClassLength
class... |
class AddAasmStateToSharedLists < ActiveRecord::Migration[6.0]
def change
add_column :shared_lists, :aasm_state, :string
end
end
|
require_relative "modules"
module Lib
class Book
include Jsonable
attr_reader :title, :author, :times_taken, :id
def initialize(title, author, id)
raise TypeError, 'Title must be a strings' unless title.is_a?(String)
raise TypeError, 'Author must be an author' unless author.is_a?(Author)
... |
require "nokogiri"
def parse_xml(xml_file)
array = Array.new
hash = Hash.new
doc = Nokogiri::XML(open(xml_file).read)
doc.search("note").map do |note|
array.push(note.name.downcase)
end
new_hash = doc.root.element_children.each_with_object(Hash.new) do |element, hash|
hash[element.name.to_sym] =... |
require 'spec_helper'
describe BackpackTF::Price::Response do
let(:response) do
{
'raw_usd_value' => 'raw_usd_value',
'usd_currency' => 'usd_currency',
'usd_currency_index' => 'usd_currency_index'
}
end
context 'reader methods' do
before(:each) do
described_class.response = r... |
require 'date'
require 'redcarpet'
require 'json'
require 'nokogiri'
require 'aws-sdk-s3'
require 'dimensions'
require 'safe_yaml'
require 'soffes/blog/markdown_renderer'
require 'soffes/blog/redis'
require 'soffes/blog/posts_controller'
module Soffes
module Blog
class Importer
BLOG_GIT_URL = 'https://gith... |
class Mechanic
attr_reader :name, :specialty
@@all = []
def initialize(name, specialty)
@name = name
@specialty = specialty
@@all << self
end
def self.all
@@all
end
def cars_i_fix
Car.all.select {|car| car.mechanic == self}
end
def my_customers
self.cars_i_fix.map {|car| ca... |
require 'csv'
class Employee
attr_reader :name, :email, :phone
attr_accessor :review, :salary, :satisfactory_performance, :department
def initialize(name, email, phone="", salary=nil, review = "", satisfactory_performance = true)
@name = name
@email = email
@phone = phone
@salary = salary
... |
json.job do |json|
json.id @job.id
json.title @job.title
json.description @job.description
json.location @job.location
json.industry @job.industry
json.gender @job.gender
json.created_at @job.created_at
json.slug @job.slug
json.user_id @job.creator.id
json.education_attainment @... |
require "rspec"
require "hanoi"
describe TowersofHanoi do
subject(:towers) {TowersofHanoi.new}
describe "#initialize" do
it "creates three stacks" do
expect(towers.stacks).to eq([[3, 2, 1], [], []])
end
end
describe "#move" do
it "can't choose an empty stack to move from" do
erro... |
CheckoutController.class_eval do
include GoogleMaps
before_filter :check_delivery_distance
private
def check_delivery_distance
if params[:state] == "address" && params[:order]
get_distance
if @distance.kind_of?(Float) && @distance > Spree::Config[:delivery_distance].to_f
flash[:error]... |
class ApplicationController < ActionController::Base
include Slimmer::Template
include Slimmer::GovukComponents
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
rescue_from GdsApi::HTTPNotFound, with: :error_not_fo... |
# -*- mode: ruby -*-
# vi: set ft=ruby :
vagrant_dir = File.join(File.expand_path(File.dirname(__FILE__)), 'vagrant')
unless Vagrant.has_plugin?("vagrant-docker-compose")
system("vagrant plugin install vagrant-docker-compose")
puts "Dependencies installed, please try the command again."
exit
end
# @param swap_... |
class AlterProjectsAddNoteIdColumn < ActiveRecord::Migration[5.0]
def change
add_column :projects, :note_id, :integer
add_index :projects, :note_id
end
end
|
module SupplyTeachers::Admin::UploadsHelper
def css_classes_for_file_upload(journey, attribute, extra_classes = [])
error = journey.errors[attribute].first
css_classes = ['govuk-file-upload'] + extra_classes
css_classes += %w[govuk-input--error govuk-input] if error.present?
css_classes
end
def ... |
# class Compliance
module Compliance
# module CodeReview Extension
module CodeReview
extend ActiveSupport::Concern
included do
def code_review
session[:prev_page] = request.env['HTTP_REFERER']
flash[:notice] = nil
@headers = @encounter.prepare_header_data
@encounter.ge... |
class Game
attr_reader :player1, :player2, :turn
def self.create(player1, player2)
@game = Game.new(player1, player2)
end
def self.instance
@game
end
def initialize(player1, player2, turn = [true,false].sample)
@player1 = player1
@player2 = player2
@turn = turn
end
def attack
... |
class Subscription < ActiveRecord::Base
attr_accessible :active, :user_id, :workshop_id
# Relationships
belongs_to :workshop
belongs_to :user
end
|
class CreateVideoPreviews < ActiveRecord::Migration
def up
create_table :video_previews do |t|
t.belongs_to :previewable, polymorphic: true
t.text :stream_url
t.timestamps null: false
end
add_index :video_previews, [:previewable_id, :previewable_type]
end
def down
drop_table :... |
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Sidekiq::Instrumental do
it 'has a version number' do
expect(described_class::VERSION).not_to be nil
end
describe '::config' do
describe '::config' do
it 'should return a Configuration object' do
expect(described_class.con... |
class Word < ActiveRecord::Base
belongs_to :category
before_create :check_translation
before_update :track_changes
validates :name, presence: true, uniqueness: true, allow_blank: false
def self.search(query)
if query
where("name like ?", "%#{query}%")
else
all
end
e... |
#!/usr/bin/env ruby
# encoding: utf-8
# from http://amqp.rubyforge.org/classes/MQ/Exchange.html
require "bundler"
Bundler.setup
require "amqp"
EventMachine.run do
AMQP.start do |connection|
channel = AMQP::Channel.new(connection)
exchange = channel.topic("stocks")
keys = ["stock.us.aapl", "stock.de.... |
class Fabric < ActiveRecord::Base
belongs_to :supplier
mount_uploader :image, ImageUploader
validates :name, :price, presence: true
end
|
class Amazon
def initialize
@request = Vacuum.new
@request.configure(
aws_access_key_id:"#{ENV['AK']}",
aws_secret_access_key: "#{ENV['SAK']}",
associate_tag: 'bioim-20'
)
end
def itemresponse(pin)
params = {'ItemId' => "#{pin}",
'ResponseGroup' => "ItemAttributes, Images, Offe... |
class PricesController < ApplicationController
def create
@price = Price.new(price_params)
respond_to do |format|
if @price.save
@price.ingredient.price = @price.price
@price.ingredient.save
format.html { redirect_to ingredient_path(@price.ingredient), notice: 'Precio actual... |
class ForecastDisplay
include Observer, DisplayElement
attr_reader :current_pressure, :last_pressure
def initialize(weather_data)
@current_pressure = 29.92
@weather_data = weather_data
@weather_data.register_observer(self)
end
def update(temperature, humidity, pressure)
@last_pressure = cu... |
require 'spec_helper'
require 'digest/md5'
describe 'db.rake' do
let(:dummy_env) { 'dummy_env' }
let(:dummy_db_name) { "db_#{dummy_env}" }
after :each do
FileUtils.rm(dummy_db_name) if File.exists?(dummy_db_name)
end
describe 'db:drop' do
context 'database exists' do
before :each do
w... |
class Game
attr_reader :towers
def initialize(towers = [[3,2,1], [], []])
@towers = towers
end
def won?
return true if @towers[1] == [3,2,1] || @towers[2] == [3,2,1]
false
end
#[[3,2,1], [], []]) move(0, 1) [[3,2], [1], []])
def move(start_pos, end_pos)
if v... |
require "spec_helper"
RSpec.describe OmniAuth::Strategies::Ibmid do
subject { OmniAuth::Strategies::Ibmid.new({}) }
context "client options" do
it "should have correct site" do
expect(subject.options.client_options.site).to eq(
"https://login.ibm.com"
)
end
it "should have correct... |
require 'bundler'
Bundler.require
# $: << '/git/spdy/lib'
#
# require 'ffi-rzmq'
# require 'spdy'
class Worker
def initialize(opts = {})
@worker_identity = opts[:identity]
ctx = ZMQ::Context.new(1)
@conn = ctx.socket(ZMQ::XREP)
@conn.setsockopt(ZMQ::IDENTITY, opts[:identity])
@conn.connect(opts... |
module Sequel
module Extensions
module Honeycomb
class << self
attr_accessor :client
attr_reader :builder
attr_accessor :logger
def included(klazz)
@logger ||= ::Honeycomb.logger if defined?(::Honeycomb.logger)
if @client
debug "initialized w... |
class ChangeEntryAmountToDecimal < ActiveRecord::Migration[5.2]
def change
remove_column :entries, :amount, :string
add_column :entries, :amount, :decimal, precision: 8, scale: 2
end
end
|
require 'open-uri'
module CoinBuilder
class Runner
def self.run!
new.run!
end
attr_reader :coin_hash
def initialize
@coin_hash = {}.with_indifferent_access
end
def run!
load_data
@coin_hash.each do |symbol, data|
puts "Adding #{symbol}, data: #{data}"
... |
require 'simplepay/support/interval'
module Simplepay
module Support
class SubscriptionPeriod < Interval
ALLOWED_INTERVALS = Simplepay::Intervals + ['forever']
# Limited to 3 digits.
ALLOWED_QUANTITY_RANGE = (1...1000)
##
# See Simplepay::Support::Interval.... |
class HolidaySpirit
attr_reader :christmas
def initialize(christmas)
@christmas = christmas
end
def tree
"A Big bushy #{christmas.xmas_tree}, "
end
def drinks
"The smells of #{christmas.xmas_food} around the house fills your"
end
def spirit
"#{christmas.xmas_spirit} with Christmas Joy!!"
end
en... |
require 'abstract_unit'
class ReloaderTests < ActiveSupport::TestCase
Reloader = ActionController::Reloader
Dispatcher = ActionController::Dispatcher
class MyBody < Array
def initialize(&block)
@on_close = block
end
def foo
"foo"
end
def bar
"bar"
end
def close... |
require 'yaml'
require 'set'
require 'find'
require 'net/ssh'
require 'net/scp'
require 'net/sftp'
require_relative 'target'
require_relative 'remote'
require_relative 'msg'
module Chamois
class Application
private
def files
Dir.glob('**/{*,.*}').reject { |f| File.directory? f }
end
def read... |
require 'pry'
class Genre
attr_accessor :name
@@all = []
def initialize(name)
@name = name
@@all << self
end
def self.all
@@all
end
# iterates through all songs and finds the songs that belong
# to that genre
def songs
Song.all.select do |song|
... |
# Simple Role Syntax
# ==================
# Supports bulk-adding hosts to roles, the primary server in each group
# is considered to be the first unless any hosts have the primary
# property set. Don't declare `role :all`, it's a meta role.
set :deploy_to, '/var/www/sos'
set :rails_env, 'production'
set :unicorn_path,... |
FactoryBot.define do
factory :currency do
trait :gbp do
code { "GBP" }
end
trait :eur do
code { "EUR" }
end
end
end
|
class PhoneNumber
def initialize(number)
@number = number
end
def number
number_1 = @number.delete "("
number_2 = number_1.delete ")"
number_3 = number_2.delete " "
number_4 = number_3.delete "."
number_5 = number_4.delete "-"
if number_5.chars.any? {|n| n.include? "a"}
'0000... |
require 'test_helper'
module KindleHighlightsAPI
class BookTest < MiniTest::Unit::TestCase
def test_from_page_creates_a_book_from_the_page
expectation = {
title: "Drawing on the Right Side of the Brain: The Definitive, 4th Edition",
highlight: "learning to draw, without doubt, causes new co... |
module APHT
def APHT::content_type(path)
ext = File.extname(path).split(".").last
CONTENT_TYPE_MAPPING.fetch(ext, DEFAULT_CONTENT_TYPE)
end
def APHT::securePath(request)
path = URI.unescape(URI(request).path)
clean = []
path.split("/").each do |part|
next if part.empty? || part == '.'
part == '..'... |
require 'faraday'
require 'faraday_middleware'
require 'hashie/mash'
require 'cortex/faraday_middleware/response_failures'
require 'cortex/faraday_middleware/normalize_uri_path'
module Cortex
module Connection
def connection
options = {
:headers => {
:user_agent => "cortex-client-ruby ... |
require 'rails_helper'
feature 'user', type: :feature do
feature 'ユーザー登録前' do
scenario '会員情報入力ができるか' do
visit new_user_registration_path
fill_in "user_nickname",with: "メルカリさん"
fill_in "user_email",with: "email@gmail.com"
fill_in "user_password",with: "abc1234"
fill_in "user_password... |
# frozen_string_literal: true
module Files
class OauthRedirect
attr_reader :options, :attributes
def initialize(attributes = {}, options = {})
@attributes = attributes || {}
@options = options || {}
end
# string - Redirect URL
def redirect_uri
@attributes[:redirect_uri]
en... |
class AddHoursToLogEntries < ActiveRecord::Migration
def change
add_column :log_entries, :hours, :float
end
end
|
require 'rails_helper'
RSpec.describe Reservation, type: :model do
let(:reservation_instance) { build(:reservation) }
it "has a valid factory" do
expect(reservation_instance).to respond_to(:order)
expect(reservation_instance).to respond_to(:pickup_time)
end
it "reservation validates attributes" do
... |
require 'rails_helper'
RSpec.describe Project, type: :model do
it { is_expected.to validate_presence_of(:name) }
it { is_expected.to have_many(:member_projects) }
it { is_expected.to have_many(:members).through(:member_projects) }
end
|
module GodaddyApi
class KeyMapping
include Kartograph::DSL
kartograph do
mapping Key
root_key plural: 'results', scopes: [:read]
property :keyId, :name, :key, scopes: [:read]
property :key, :name, scopes: [:create]
end
end
end
|
require 'command_line_reporter'
class HelloSignDownloader
class Reporter
include CommandLineReporter
def initialize(documents)
@documents = documents
end
def run
table :border => true do
row do
column 'Document ID', width: 40, bold: true, align: 'center'
colu... |
class EmployeePlannedHoliday < ApplicationRecord
belongs_to :employee
validates :holiday_date, presence: true
end
|
class ConsoleOwnershipController < ApplicationController
before_action :signed_in_user
before_action :correct_user, only: [:edit, :update, :destroy, :show]
def show
@console = ConsoleOwnership.find_by(id: params[:id])
@user = User.find_by(remember_token: cookies[:remember_token])
end
def new
@o... |
# == Schema Information
#
# Table name: restaurants
#
# id :integer not null, primary key
# name :string(255)
# address :string(255)
# cuisine :string(255)
# thumbs_down :boolean default(FALSE)
# lat :float
# long :float
# value_rating :integer
#
... |
MiEdificioServer::App.controllers :users, parent: :buildings do
get :index, provides: [:json] do
params_keys = [:building_id]
@building_users = BuildingUser.where(params.slice(*params_keys))
jbuilder 'building_users/index'
end
get :show, '', with: :id, provides: [:json] do
params_keys = [:buil... |
module Measurable
module ClassMethods
def define_measureable_methods(metrics, cycles, measurements)
metric_cycle_measures(metrics, cycles, measurements)
reading_nested_arrays(measurements)
measurement_nested_arrays(measurements)
measurement_hashes(measurements)
measurement_methods... |
# First file to be loaded when the gem is invoked.
# Need to require everything here
# Fetch all the configuration values here
require "koduc_express_paypal/version"
require "koduc_express_paypal/koduc_check_environment"
require "koduc_express_paypal/koduc_request"
require "koduc_express_paypal/koduc_validation"
requi... |
# encoding: utf-8
#
# © Copyright 2013 Hewlett-Packard Development Company, L.P.
# 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 limitation the rights
#... |
require 'spec_helper'
describe Haystack::Rack::JSExceptionCatcher do
let(:app) { double(:call => true) }
let(:options) { double }
let(:active) { true }
let(:config_options) { {:enable_frontend_error_catching => true} }
let(:config) { project_fixture_config('production', conf... |
class CreateMatches < ActiveRecord::Migration[6.0]
def change
create_table :matches do |t|
t.integer :user_id
t.string :place_id
t.float :place_lat
t.float :place_lng
t.text :place_name
t.boolean :favorite, default: false
t.timestamps
end
end
end
|
require_relative 'middleware_base'
module BME
class BasicAuth < MiddlewareBase
def initialize(app)
$stdout.puts "BME::BasicAuth"
@settings = YAML.load_file('config/config.yml')
@app = app
end
def call(env)
begin
path = env["PATH_INFO"]
$stdout.puts "BME::BasicAuth"... |
# frozen_string_literal: true
require "spec_helper"
describe GraphQL::Schema::RelayClassicMutation do
describe ".input_object_class" do
it "is inherited, with a default" do
custom_input = Class.new(GraphQL::Schema::InputObject)
mutation_base_class = Class.new(GraphQL::Schema::RelayClassicMutation) do... |
require_relative 'find_by'
require_relative 'errors'
require 'csv'
class Udacidata
@@data_path = File.dirname(__FILE__)+"/../data/data.csv"
# adds new records
def self.create(attributes={})
new_item = self.new(attributes)
CSV.open(@@data_path, "a+") do |csv|
csv << [new_item.id, new_item.brand, new_... |
require 'spec_helper'
describe Bumpy do
describe ".bump_version" do
def bump(v)
subject.bump_version(v)
end
TEST_DATA = [
['1.0.0', '1.0.1'],
['1.0.9', '1.0.10'],
['1.0.5.pre9', '1.0.5.pre10'],
['12.0', '12.1'],
['1.2.3.dev.9', '1.2.3.dev.10']
]
TEST_DATA.eac... |
class AddCouncilIdToProperty < ActiveRecord::Migration
def change
add_column :properties, :council_id, :integer
end
end
|
require "digest"
class User < ActiveRecord::Base
attr_accessor :password
attr_accessible :name, :email, :password, :password_confirmation
#Microposts association
has_many :microposts, :dependent => :destroy
#users who he follows
has_many :relationships, :foreign_key => "follower_id", :dependent => :destroy
ha... |
require 'spec_helper'
describe Author do
let(:invalid_names) {['', nil, '12ab34', 'ab12cd']}
let(:invalid_emails) {['blah.com', '@blah.com', '@@.com', 'blah@.com', 'blah', '@@blah.com', 'com', '.com']}
it {should have_valid(:first_name).when('Austin')}
it {should_not have_valid(:first_name).when(*invalid_name... |
require "alimento/version"
require "alimento/lista"
require "alimento/IG_fun"
require "alimento/ordenar"
require "benchmark"
module Alimento
class Alimento
attr_reader :nombre, :prt, :gluc, :lip
include Comparable
def <=>(another)
kcal <=> another.kcal
end
de... |
require 'spec_helper'
describe 'nfs::server::stunnel' do
on_supported_os.each do |os, facts|
context "on #{os}" do
let(:pre_condition) { 'class { "nfs": is_server => true }' }
let(:facts) { facts }
it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_class('nfs::server... |
require 'optparse'
module NamecheapZoneImporter
# Parse command line arguments into a zone.
class FromCommandLine
def self.parse!(argv)
options = {}
OptionParser.new do |opts|
opts.banner = "Usage: #{$PROGRAM_NAME} -f [zone file] -u [namecheap username] -k [namecheap api key]"
opt... |
class AddMembershipIdToClients < ActiveRecord::Migration
def change
add_reference :clients, :membership, index: true, foreign_key: true
end
end
|
require 'promotions_parser'
RSpec.describe PromotionsParser do
let(:promotion_parser) { described_class.new promo_rules_json }
describe '#value_rules' do
subject { promotion_parser.value_rules.first }
it 'returns value rules from promotions' do
expect(subject).to have_key(:minimum_value)
expe... |
# 1. print the menu and ask the user what to do
# 2. read the input and save it into a variable
# 3. do what the user has asked
# 4. repeat from step 1
@students = []#this @students[] is now global and accessible to all methods
def interactive_menu
loop do
print_menu
process(gets.chomp)#can send the... |
class PicturesController < AuthenticatedController
def new
if current_user.galleries.length == 0
@gallery = current_user.galleries.build(:title => I18n.t('pictures.default_gallery'))
else
@gallery = current_user.galleries.first
end
@picture = @gallery.pictures.build
end
def create... |
require 'aws-sdk'
require 'yaml'
require 'hashie'
module SportNginAwsAuditor
class AwsConfig < Hash
include Hashie::Extensions::IndifferentAccess
end
class AWSSDK
def self.authenticate(environment)
shared_credentials = Aws::SharedCredentials.new(profile_name: environment)
Aws.config.update({... |
class CreatePouches < ActiveRecord::Migration[5.1]
def change
create_table :pouches do |t|
t.string :name
t.string :rarity
t.string :category
t.string :location
t.string :duration
t.string :first_effect, array: true
t.string :second_effect, array: true
t.string :thi... |
class FontRokkitt < Formula
head "https://github.com/google/fonts.git", verified: "github.com/google/fonts", branch: "main", only_path: "ofl/rokkitt"
desc "Rokkitt"
desc "Slab Serif font family"
homepage "https://fonts.google.com/specimen/Rokkitt"
def install
(share/"fonts").install "Rokkitt-Italic[wght].... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.