text stringlengths 10 2.61M |
|---|
require 'rails_helper'
RSpec.feature 'Editing section' do
before do
@admin = create(:admin)
login_as(@admin, scope: :admin)
@section = create(:section)
visit edit_admin_section_path(@section)
end
scenario 'with valid data' do
fill_in 'Name', with: 'Software Development'
click_link 'Add m... |
module Beats
# This class is used to transform a Song object into an equivalent Song object whose
# sample data will be generated faster by the audio engine.
#
# The primary method is optimize(). Currently, it performs two optimizations:
#
# 1.) Breaks patterns into shorter patterns. Generating one long P... |
require 'test_helper'
class CommentsControllerTest < ActionController::TestCase
def login
session[:login] = @user
end
setup do
@user = users(:one)
login
end
test "should create comment" do
assert_difference('Comment.count') do
post :create, event_id: events(:one).id, comment: { conten... |
class NonCampusStateTotalsController < ApplicationController
before_action :set_non_campus_state_total, only: [:show, :edit, :update, :destroy]
# GET /non_campus_state_totals
# GET /non_campus_state_totals.json
def index
@non_campus_state_totals = NonCampusStateTotal.all
end
# GET /non_campus_state_to... |
# order.rb
require 'json'
require 'bundler/setup'
require 'rdkafka'
module GoCLI
# Order class
class Order
attr_accessor :timestamp, :origin, :destination, :est_price
attr_accessor :type, :discount
def initialize(opts = {})
@timestamp = opts[:timestamp] || Time.now
@origin = opts[:origin]
... |
class Privacy < ActiveRecord::Migration
def change
add_column :photos, :private, :boolean
Photo.update_all(private: false)
end
end
|
require 'nokogiri'
class UserController < ApplicationController
include HTTParty
debug_output $stderr
CLIENT_ID = Rails.application.credentials[Rails.env.to_sym][:github][:client_id]
CLIENT_SECRET = Rails.application.credentials[Rails.env.to_sym][:github][:client_secret]
GITHUB_USER = 'unt8'
REPO_PATH = ... |
require 'pp'
require_relative "./board_helper"
require_relative "twitter_translate"
class Board
include TwitterTranslate
include BoardHelper
attr_reader :grid
def initialize(grid = Array.new(6) {Array.new(7) {""}})
@grid = grid
@lines_to_check = rows + columns + diagonals
end
def get_cell(row, co... |
class CreateCars < ActiveRecord::Migration[5.0]
def change
create_table :cars do |t|
t.string :zip_code
t.integer :year
t.string :make
t.string :model
t.string :color
t.string :vin
t.integer :mileage
t.float :price
t.string :days_to_sell
t.string :seat_n... |
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Ch... |
require 'test_helper'
class CassandraObject::Types::StringTypeTest < CassandraObject::Types::TestCase
test 'encode' do
assert_equal 'abc', coder.encode('abc')
assert_raise ArgumentError do
coder.encode(123)
end
end
test 'encode as utf' do
assert_equal(
'123'.force_encoding('UTF-8').... |
module EditI18nDatabaseTranslations
require 'edit_i18n_database_translations/config.rb'
def config
@config ||= Config.new
end
module_function :config
def configure(&block)
yield config
end
module_function :configure
require 'edit_i18n_database_translations/helper.rb'
require 'edit_i18n_datab... |
require 'net/smtp'
module Smtp
class Ninja
def initialize(server, port, username, password)
@server = server
@port = port
@username = username
@password = password
end
def send_mail(email)
authenticate { |conn| email.send_via(conn) }
end
private
def authentica... |
class AddCountOnHandToF2Rii < ActiveRecord::Migration
def change
add_column :f2r_hotel_inventory_items, :count_on_hand, :integer
end
end
|
class Evaluation < ApplicationRecord
belongs_to :student
validates :rating, presence: true
validates :remark, presence: true
validates :date, presence: true
#default_scope {order(date: :desc)}
def self.order_by_date
order(:date)
end
def self.avg_rating
average(:rating)
end
end
|
class CreateCards < ActiveRecord::Migration
def change
create_table :cards do |t|
t.string :card_name
t.string :card_class
t.string :card_set
t.text :card_text
t.string :card_race
t.string :card_rarity
t.string :card_type
t.string :card_artist
t.integer :card_... |
#!/usr/bin/env ruby
require_relative '../lib/tuple'
require_relative '../lib/canvas'
Projectile = Struct.new(:position, :velocity)
Environment = Struct.new(:gravity, :wind)
def tick(projectile, environment)
new_position = projectile.position + projectile.velocity
new_velocity = projectile.velocity + environment.g... |
module Chrono
class Schedule
attr_reader :source
def initialize(source)
@source = source
end
def minutes
Fields::Minute.new(fields[0]).to_a
end
def hours
Fields::Hour.new(fields[1]).to_a
end
def days
Fields::Day.new(fields[2]).to_a
end
def months
... |
## Module to Interface with Feed Mapping Rake Task that Lets an User to Map Nodes Using
## XSLT (through web forms) and Attributes of a database object.
require 'open-uri'
require 'net/http'
module FeedHelper
include Magick
@logger = Logger.new(STDOUT)
@logger.level = Logger::DEBUG
# Open File from Loca... |
class Customer < ActiveRecord::Base
has_one :cart, dependent: :destroy
has_many :wishlists
has_many :sales
end |
require 'rails_helper'
describe PasswordResetsController do
describe "create" do
it "works" do
user = create(:user)
sign_in user
post :create, email: user.email
user.reload
expect(user.password_reset_sent_at).to be_present
expect(user.password_reset_token).to be_present
... |
class CreateGameTrueFalses < ActiveRecord::Migration
def change
create_table :game_true_false do |t|
t.references :user, index: true
t.integer :questions_count
t.string :status
t.datetime :status_changed_at
t.timestamps null: false
end
add_index :game_true_false, :status
... |
class Transaction
attr_reader :id, :invoice_id, :credit_card_number, :credit_card_expiration, :result, :created_at, :updated_at, :repo
def initialize(row, repo)
@id = row[:id].to_i
@invoice_id = row[:invoice_id].to_i
@credit_card_number = row[:credit_card_number].to_i
@credit_card_ex... |
# frozen_string_literal: true
class InterestsController < ApplicationController
def create
interest = Interest.new(interest_params)
if interest.valid?
interest.save
render json: { message: 'Interest added!' }, status: :ok
else
render json: { errors: interest.errors.messages }, status: ... |
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe Solrizer::Fedora::Solrizer do
before(:each) do
@solrizer = Solrizer::Fedora::Solrizer.new
end
describe "solrize" do
it "should trigger the indexer for the provided object" do
sample_obj = ActiveFedora::Base.new
... |
class Node
attr_accessor :value, :next
def initialize(value = nil, next_node = nil)
@value = value
@next = next_node
end
end
class LinkedList
# a linked list starts with a single node with no next_node
# save head to an instance variable to use with the rest of the class methods.
def initialize(v... |
class CreateTableTaxonProducts < ActiveRecord::Migration[5.0]
def change
create_table :taxon_products do |t|
t.integer :product_id, :index => true
t.integer :taxon_id, :index => true
end
end
end
|
require "spec_helper"
describe Envconfig::Root do
let(:env) { {} }
subject(:root) { Envconfig::Root.new(env) }
context "with nothing in ENV" do
service_methods = [
:database,
:memcached,
:mongodb,
:redis,
:smtp,
]
service_methods.each do |service_method|
predic... |
module DynamodbClient
module_function
def create_user_table
params = {
table_name: 'users', # required
key_schema: [ # required
{
attribute_name: 'email', # required
key_type: 'HASH', # required, accepts HASH, RANGE
... |
require 'rails_helper'
RSpec.describe AppointmentService::List, type: :model do
fp_id = 'fp_1'
client_id = 'client_1'
from = Time.current.change(day: 12, month: 10, year: 2020, hour: 10, min: 0)
to = from.change(hour: 17, min: 30)
before do
AvailabilityService::Create.new(fp_id: fp_id, from: from).execu... |
FlailWeb::Application.routes.draw do
root :to => 'flail_exceptions#index'
post '/swing' => 'flail_exceptions#create'
resources :flail_exceptions
resources :digests
resources :web_hooks do
collection do
post :test
end
end
resources :filters
end
|
class Employee < ActiveRecord::Base
include Gravtastic
gravtastic
has_secure_password
has_many :alerts, dependent: :destroy
belongs_to :organization
has_many :beacons, through: :alerts
# has_many :organizations, through: :alerts
before_validation :ensure_auth_token
validates_presence_of :username, ... |
class ReportJob < ActiveJob::Base
queue_as :reports
before_enqueue do
find_or_create_document_root_path
end
def perform(document, params)
document_name = document.title
report = document.report_type.classify.constantize.new(params)
report.generate(document)
FayeJob.perform_later ... |
class Cat
include Comparable
@@all = []
@@uniques = [:name]
@@last_id = 1
attr_accessor :name, :age
attr_reader :id
def initialize attrs
attrs.each {|k,v| self.instance_variable_set("@#{k}", v) }
end
def self.create attrs
c = self.new attrs
c.save
end
def save
if @id.nil?
... |
require 'frank-cucumber/console'
require 'frank-cucumber/frank_helper'
require 'screen'
require 'selector_builder'
require 'multi_json'
class Worm
include Frank::Cucumber::FrankHelper
def initialize
Frank::Cucumber::FrankHelper.use_shelley_from_now_on
end
def use_physical
Frank::Cucumber::FrankHelper... |
class CalendarioNombreExistenteError < StandardError
def initialize(msg="Ya existe un calendario con el nombre ingresado")
super
end
end |
class UserForm < Reform::Form
properties :name, :email, :password, :password_confirmation
property :auth_token, :readable => false
validates :name, :email, :presence => true
validates :password,
:presence => true,
:length => {:in => 8..72}
validates_uniqueness_of :email
validate :password_confirme... |
FactoryGirl.define do
factory :customerx_customer, class: 'Customerx::Customer' do
name "MyString"
short_name "MyString"
since_date "2013-01-12"
contact_info "MyText"
address "MyText"
shipping_address "MyText"
zone_id 1
customer_status_category_id 1
phone "1234"
fax ... |
maintainer "Vasiliy Tolstov"
maintainer_email "v.tolstov@selfip.ru"
license "Apache 2.0"
description "Installs/Configures joomla"
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version "0.8.4"
recipe "joomla", "Installs and configures joomla on a single system"
%... |
elasticsearch = "elasticsearch-#{node.elasticsearch[:version]}"
# Include the `curl` recipe, needed by `service status`
#
include_recipe "elasticsearch::curl"
# Increase open file limits
#
bash "enable user limits" do
user 'root'
code <<-END.gsub(/^ /, '')
echo 'session required pam_limits.so' >> /et... |
# frozen_string_literal: true
# Here we have all of the basic helper functions
module ApplicationHelper
def timed_greeting
case Time.now.hour
when 0..3 then 'Ya vete a dormir'
when 4..6 then 'Buenas madrugadas'
when 7..11 then 'Buenos dรญas'
when 12..19 then 'Buenas tardes'
else 'Buenas noches... |
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Ch... |
class Article < ApplicationRecord
has_many(:comments, {:dependent => :destroy})
validates :title, presence: true, length: { minimum: 3 }
end
|
Pod::Spec.new do |s|
# โโโ Spec Metadata โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ #
s.name = "VGDropDown"
s.version = "0.0.1"
s.summary = "VGDropDown lets a user to create simple button with drop down list menu."
# This description is used to generate tags and improve... |
class ChatsController < ApplicationController
before_action :set_app
before_action :set_app_chats, only: [:show, :update, :destroy]
# GET /apps/:app_token/chats
def index
@chats = @app.chats.map do |hash|
{
number: hash[:number],
app_token: hash[:app_token],
created_at: hash[:... |
require "minitest_helper"
describe UsersController do
before do
@user = users(:one)
end
it "must get index" do
get :index
assert_response :success
assert_not_nil assigns(:users)
end
it "must get new" do
get :new
assert_response :success
end
it "must create user" do
assert_... |
WIN_COMBINATIONS = [ [0,1,2],[3,4,5],[6,7,8],[0,3,6],[1,4,7],[2,5,8],[0,4,8],[2,4,6] ]
board = [" "," "," "," "," "," "," "," "," "]
def display_board(board)
puts" #{board[0]} | #{board[1]} | #{board[2]} \n-----------\n #{board[3]} | #{board[4]} | #{board[5]} \n-----------\n #{board[6]} | #{board[7]} | #{board[8]... |
class Search < ActiveRecord::Base
def search_patients
patients = Patient.all
patients = patients.where(["name LIKE ?","%#{keywords}%"]) if keywords.present?
# patients = patients.where(["date LIKE ?",date_of_birth]) if date_of_birth.present?
patients = patients.where(["address LIKE ?",address]) if a... |
require 'spec_helper'
require 'fileutils'
require 'active_support'
require 'active_support/core_ext'
describe Swift::Pyrite do
before do
FileUtils.mkdir_p(File.dirname(output_path))
FileUtils.rm_f(output_path)
FileUtils.touch(expected_path)
end
let(:output_path) { File.join(File.dirname(__FILE__), "... |
# -*- coding: utf-8 -*-
require 'spec_helper'
describe Api::PinController do
before do
@member = FactoryBot.create(:member, password: 'mala', password_confirmation: 'mala')
end
let(:error) do
{ 'isSuccess' => false, 'ErrorCode' => 1 }.to_json
end
describe 'POST /all' do
it 'renders json' do
... |
class TrashesController < ApplicationController
before_action :set_trash, only: [:show, :edit, :update, :destroy]
before_action :set_team
before_filter :authenticate_team!, only: [:new, :create, :edit, :update]
def create
@trash = @team.trashes.create(trash_params)
@trash.team_id = current_team.id
... |
class Article < ActiveRecord::Base
scope :alphabetical, order('title')
end
|
# frozen_string_literal: true
require 'jiji/configurations/mongoid_configuration'
require 'jiji/utils/value_object'
require 'jiji/web/transport/transportable'
module Jiji::Model::Trading
# ใฌใผใๆ
ๅ ฑ
class Tick
include Enumerable
include Jiji::Utils::ValueObject
include Jiji::Errors
# ้่ฒจใใขใใญใผใจใใ Tick... |
require 'puppet/util/execution'
Puppet::Type.type(:php_version).provide :php_homebrew do
include Puppet::Util::Execution
desc "Provides PHP versions compiled with homebrew-php"
def self.home
Facter.value(:homebrew_root)
end
def self.cache
if boxen_home = Facter.value(:boxen_home)
"#{boxen_hom... |
# U2.W5: The Bakery Challenge (GPS 2.1)
# Your Names
# 1) Steven Leu
# 2) Brian Junio
# This is the file you should end up editing.
# define method bakery_num accepting two arguments "number of people" and "favorite food"
def bakery_num(num_of_people, fav_food)
# create hash of foods (keys: food, values: n... |
class Song
attr_accessor :name, :artist
def initialize(name, artist = nil)
self.name = name
self.artist = Artist.find_or_create_by_name(artist)
end
def self.new_by_filename(filename)
song = self.new(filename.split(" - ")[1].gsub(".mp3", ""), filename.split(" - ")[0])
song.artist.add_song(song.... |
# frozen_string_literal: true
module CalendarHelper
def render_calendar(calendar_data = ENV['CALENDARS'])
@calendar_data = calendar_data
"https://calendar.google.com/calendar/b/2/embed?#{calendar_options}&#{calendars}"
end
private
def calendar_options
{
showTitle: 0,
showPrint: 0,
... |
require "rails_helper"
RSpec.describe "/rooms", type: :request do
let(:login_info) do
{
name: "kohei",
email: "kohei@example.com",
password: "password-00"
}
end
before do
room_a = create(:room, name: "room_a")
room_b = create(:room, name: "room_b")
@user = User.register(
... |
require_relative 'tmdb_id_request'
module BatShoes
module Tmdb
class GetSomeContent
def initialize
end
def tmdb_request(payload_parameters)
tmdb_request_response = TmdbIdRequest.new(payload_parameters).call
tmdb_request_response
end
private
end
end
end
|
class Album < ActiveRecord::Base
has_many :pictures
belongs_to :user
validates_presence_of :name, :message => '็ธๅๅ็งฐไธ่ฝไธบ็ฉบ'
validates_presence_of :access, :message => '่ฎฟ้ฎๆ้ไธ่ฝไธบ็ฉบ'
#named_scope :public,:conditions => ['access = ?', 'public']
named_scope :except_private,:conditions => ['access != ?', 'private']
... |
require 'rails_helper'
RSpec.describe "Users", type: :request do
describe "GET /users" do
it "HTTP response 200" do
get users_path
expect(response).to have_http_status(200)
end
end
describe "GET /users/new" do
it "HTTP response 200" do
get new_user_path
expect(response).to ha... |
class CreatePlantsActions < ActiveRecord::Migration[5.2]
def change
create_table :plants_actions do |t|
t.date :action_date
t.integer :plant_id
t.integer :action_id
t.timestamps
end
end
end
|
require 'rspec'
require_relative 'tax'
describe TaxCalculator do
# let defines method person
let(:person) do
p = Person.new
p.age = 21
p.children_count = 0
p.married = false
p.handicap = false
p.income = 10_000
p
end
describe 'basic example' do
it 'calculates no tax' do
... |
# frozen_string_literal: true
module Vedeu
module Editor
# Fetches an item from a collection.
#
# @api private
#
class Item
# @param (see #initialize)
# @return (see #by_index)
def self.by_index(collection, index = nil)
new(collection, index).by_index
end
... |
class ResourceNotifierJob < ApplicationJob
queue_as :default
def perform(resource)
url = Rails.application.credentials.dig(:webhooks, :keybase, :new_resource)
if url
resource_url = Rails.application.routes.url_helpers.edit_admin_resource_url(resource.id)
RestClient.get(url, params: {
... |
class Api::WeightRatesController < ApplicationController
before_filter :get_weight_rate, except: [:show, :update, :destroy]
def index
weight_rate = WeightRate.select('MAX(rate) as rate, MAX(updated_at) as updated_at').group("date(updated_at)").last(7)
return render :json => {:data => weight_rate.collect(&:... |
require 'optparse'
require 'strscan'
require 'fileutils'
module Deadpool
module Generator
class DeadpoolConfig
attr :active
alias active? active
def initialize
@active = false
@config_dir = Deadpool::ScriptOption.new('deadpool_config', '/etc/deadpool')
end
# :ree... |
require 'rails_helper'
require_relative '../support/import_form'
RSpec.feature 'Importing data' do
let(:bad_import_form) { ImportForm.new }
scenario "without uploading a file fails" do
expect(bad_import_form.visit_page.submit).to have_content('There was an error processing the uploaded file.')
end
end |
class AI
def initialize(board_id)
@board_id = board_id
end
# ็ธๆใฎๆใๆใฎๅ
จไฝใ่ฉไพกใใฆใ
# ็ธๆใฎ็นๆฐใไธ็ชไฝใๆใ้ธๆใใ
# ่ชๅใฎๆใฎ่ฏใๆชใ๏ผๆๆฐใไฝๆๅขใใใใ่งใใจใใใ๏ผใฏ
# ็พ็ถใง่ๆ
ฎใใฆใใชใ
def move
moves = board.moves
return nil if moves.empty?
evaluated = {}
moves.each do |index, reversibles|
evaluated[index] = evaluate_oppo... |
# Copyright 2007-2014 Greg Hurrell. All rights reserved.
# Licensed under the terms of the BSD 2-clause license.
require 'walrat'
module Walrat
# Simple wrapper for MatchData objects that implements length, to_s and
# to_str methods.
#
# By implementing to_str, MatchDataWrappers can be directly compared with
... |
# Copyright 2007-2014 Greg Hurrell. All rights reserved.
# Licensed under the terms of the BSD 2-clause license.
require 'walrat'
class Symbol
include Walrat::ParsletCombining
# Returns a SymbolParslet based on the receiver.
# Symbols can be used in Grammars when specifying rules and productions to
# refer t... |
require 'rails_helper'
RSpec.describe User, type: :model do
it {should have_one :user_profile}
it {should have_one :house}
it {should have_many :requests}
it {should have_many :requested_houses}
it {should have_many :comments}
it 'should create a user_profile when a new user is created' do
FactoryGirl.creat... |
class EventPostsController < ApplicationController
before_action :deny_access_for_non_admins, except: [:index, :show]
def index
@event_posts = EventPost.all #variables with an @ are instance variables
end
def show
#uses the params hash to get the key (id for news_post)
@event_post = EventPost.find(p... |
module Api
module V1
class InsuredUsersController < ApplicationController
include DeviseTokenAuth::Concerns::SetUserByToken
respond_to :json
before_action :authenticate_user!
before_action :set_insured_user, only: [:show, :edit, :update, :destroy, :create_parent]
# GET /insur... |
# encoding: utf-8
group :development do
gem 'rake', '~> 10.1.0'
gem 'rspec', '~> 2.14.1'
gem 'yard', '~> 0.8.7'
end
group :yard do
gem 'kramdown', '~> 1.2.0'
end
group :guard do
gem 'guard', '~> 1.8.1'
gem 'guard-bundler', '~> 1.0.0'
gem 'guard-rspec', '~> 3.0.2'
gem 'guard-rubocop', '~> ... |
# encoding: utf-8
require 'strscan'
module Libgeo
class Formatter
##
# Class: template compiler
#
# Tooks the sprintf-like pattern string
# and compiles it to the ruby code
#
# Example:
#
# Compiler.new('%d:%2m').compile
#
class Compiler
##
# Constant: s... |
class MomentumCms::BaseController < ApplicationController
rescue_from MomentumCms::RecordNotFound, with: :error_render_method
rescue_from MomentumCms::SiteNotFound, with: :error_render_method
before_action :load_site
include MomentumCms::I18nLocale
private
def load_site
@momentum_cms_site = if reques... |
class Grad < ActiveRecord::Base
validates_presence_of :first_name, :last_name, :student_num, :email, :graduation_date
def full_name
first_name + " " + last_name
end
end
|
# == Schema Information
#
# Table name: technologies
#
# id :integer not null, primary key
# name :string(255)
# created_at :datetime
# updated_at :datetime
#
class Technology < ActiveRecord::Base
validates :name, :presence => true, :uniqueness => true
has_and_belongs_to_many :projects
e... |
require 'spec_helper'
require 'cancan/matchers'
require 'spree/testing_support/ability_helpers'
describe Spree::Ability, type: :model do
let(:user) { FactoryBot.build(:user) }
let(:ability) { Spree::Ability.new(user) }
let(:token) { nil }
after do
Spree::Ability.abilities = Set.new
end
context 'for g... |
# encoding: utf-8
# Author: Richard Nixon
# Copyright: 2018, The Authors
module Jungle
class Animals
# The Fake API client
class Client
# Return a fake data set
def describe_monkey(name)
monkeys = {
'bobo' => { favourite_food: 'bananas', nickname: 'the clown' },
'... |
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../dummy/config/environment', __FILE__)
require 'spec_helper'
require 'rspec/rails'
require 'excon'
require 'pry'
RSpec.configure do |config|
config.use_transactional_fixtures = false
config.infer_spec_type_from_file_location!
config.filter_rails_from_backtr... |
require "fandango/version"
require 'feedzirra'
require 'fandango/parser'
module Fandango
class << self
def movies_near(postal_code)
raise ArgumentError, "postal code cannot be blank" if postal_code.nil? || postal_code == ''
feed = fetch_and_parse(postal_code)
feed.entries.map do |entry|
... |
require 'test_helper'
class Commissioners::QuotationControllerTest < ActionDispatch::IntegrationTest
include Devise::Test::IntegrationHelpers
test "should show all commissioner quotations" do
commissioner = users(:commissioner)
sign_in(commissioner)
get commissioner_quotations_url(commissioner_id: co... |
namespace :trello do
desc "Deletes all highlights and then reports cards closed within last day on Trello"
task :report => :environment do
TitanDispatcher.delete_all!
Reporter.new.titan_report(since: 1.day.ago, before: Time.now)
end
end
|
def log(description, &block)
puts "Beginning \"#{description}\"..."
response = block.call
puts "...\"#{description}\" finished, returning: #{response}"
end
log('outer block') do
log('some little block') do
5
end
log('yet another block') do
'I like Thai food!'
end
false
end |
VetClinic::Application.routes.draw do
resources :appointments
resources :pets
devise_for :users
namespace :admin do
resources :users
end
root 'appointments#index'
end
|
# frozen_string_literal: true
module Compli
VERSION = "0.1.0"
end
|
class Deduction < ApplicationRecord
belongs_to :deduction_detail, foreign_key: "deduction_id"
belongs_to :salary
end
|
class AddRegionIdToShop < ActiveRecord::Migration
def change
add_column :shops, :region_id, :string
end
end
|
require 'rails_helper'
require 'capybara/rspec'
require 'capybara/rails'
module LoginHelper
def create_roles
Role.create(name: "registered_user")
Role.create(name: "company_admin")
Role.create(name: "platform_admin")
end
def create_account
visit root_path
click_link "Create Account"
fi... |
class AddGivenNameAndFamilyNameToUsers < ActiveRecord::Migration
def change
add_column :users, :given_name, :string
add_column :users, :family_name, :string
add_index :users, :family_name
end
end
|
# Implement an algorithm to print all valid (e.g., properly opened and closed) combinations
# of n pairs of parentheses
# EXAMPLE
# Input: 3
# Output: ((())), (()()), (())(), ()()(), ()()
# EXAMPLE
# Input: 2
# Output: (()), ()()
def parens(num_parens)
return ["()"] if num_parens == 1
result = []
parens(num_pa... |
module LDAP
class Wrapper
class << self
def wrap(method)
define_method method do |*args|
response = @cnx.send(method, *args)
result = @cnx.get_operation_result
if result.code > 0
raise "ldap error: #{result.message}: #{result.error_message}"
end
... |
class CreateSites < ActiveRecord::Migration
def change
create_table :sites do |t|
t.string :title
t.string :slug
t.text :description
t.string :icon_uid
t.string :icon_name
t.string :status
t.timestamps
end
end
end
|
class DropPreyTable < ActiveRecord::Migration
def change
drop_table :prey
end
end
|
require 'spec_helper'
describe 'postfix::flatten_host' do
it { is_expected.to run.with_params('2001:db8::1').and_return('[2001:db8::1]') }
it { is_expected.to run.with_params('192.0.2.1').and_return('192.0.2.1') }
it { is_expected.to run.with_params(['2001:db8::1', 389]).and_return('[2001:db8::1]:389') }
it { ... |
class VideoPreview < ActiveRecord::Base
# Associations
belongs_to :previewable, polymorphic: true
end
|
require 'chemistry/element'
Chemistry::Element.define "Californium" do
symbol "Cf"
atomic_number 98
atomic_weight 251
melting_point '1173K'
end
|
# frozen_string_literal: true
require "cell/partial"
module Decidim
module Opinions
# This cell renders the tags for a opinion.
class OpinionTagsCell < Decidim::ViewModel
include OpinionCellsHelper
property :category
property :previous_category
property :scope
property :previo... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.