text stringlengths 10 2.61M |
|---|
module Vanity
class Metric
# Use Google Analytics metric. Note: you must +require "garb"+ before
# vanity.
#
# @example Page views
# metric "Page views" do
# google_analytics "UA-1828623-6"
# end
# @example Visits
# metric "Visits" do
# google_analytics "UA-182862... |
require 'spec_helper'
describe Newly::PageCrawler do
let(:selector) { Nokogiri::HTML }
let(:host) { 'http://atualidadesweb.com.br' }
let(:subject) { Newly::PageCrawler.new(host, parse('spec/html/page_spec.html')) }
describe "#text" do
context "when is valid input" do
it { expect(subject.text(".a")).t... |
# Encrypt Method ----
# Encrypts password by changing every character to the next letter in the alphabet
def encrypt(stg)
index = 0
while index < stg.length
if stg[index] == "z"
stg[index] = "a"
else
stg[index] = stg[index].next
end
index += 1
end
p stg
end
# ---- End Encrypt Meth... |
# -*- encoding : utf-8 -*-
class AcademicWorksController < ApplicationController
# GET /academic_works
# GET /academic_works.json
before_filter :check_auth
def index
@academic_works = AcademicWork.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @... |
module Spree::ProductsHelper
include TaxonsHelper
def in_special_offer_for_search_result?(product, taxons_in_search_result)
taxons_in_search_result.each do |taxon|
cls = in_special_offer_for_taxon?(product, taxon)
return cls if cls
end
return false
end
end |
class LinksController < ApplicationController
respond_to :json
rescue_from ActiveRecord::RecordNotFound, :with => :not_found
api_controller
def index
if params[:licked]
@links = current_user.licked_links
elsif params[:all]
@links = Link.all
else
ids = current_user.licks.empty? ? -... |
require 'rails_helper'
RSpec.describe Restaurant, type: :model do
it "should be able to create a Restaurant object which has the correct methods on it" do
r = Restaurant.create!(name: "Hamilton Royal India Grill", url: "http://hamiltonroyalindiagrill.com/", address: "6 Broad Street Hamilton, NY 13346" , cuisine:... |
#
# Class Controller héritée par tous les contrôleurs
#
class Controller
@@before_filters = nil # Liste Array des filtres-avant
@@after_filters = nil # Liste Array des filtres-après
# => Charge le modèle et le contrôleur spécifié
#
# @param ary_or_str Soit le nom du modèle (String) soit u... |
require 'rails_helper'
feature 'User creates a task' do
scenario 'successfully with valid data' do
visit root_path
expect do
fill_in 'Description', with: 'Buy eggs'
click_button 'Add task'
end.to change(Task, :count).by(1)
task = Task.last
expect(task).to_not be_nil
expect(task.... |
ActiveAdmin.register Admin::Feedback, as: 'Feedback' do
permit_params :customer_name, :customer_email, :project_name, :feature_name, :rate, :details
actions :index, :show, :edit, :update, :destroy
index do
selectable_column
id_column
column :customer_name
column :customer_email
column :projec... |
# ApplicationMailer is a rails default class for sending emails.
class ApplicationMailer < ActionMailer::Base
default from: 'from@example.com'
layout 'mailer'
end
|
class PaginationDetailLinkRenderer < WillPaginate::ViewHelpers::LinkRenderer
protected
def url_for(page)
controller_name = @template.controller_name
action_name = @template.action_name
params = @template.request.params
if contoller_name == "homes" #到了我们要自定义的actio... |
class CreatePackages < ActiveRecord::Migration[5.0]
def change
create_table :packages do |t|
t.string :name
t.integer :bsize
t.integer :multiplier
t.string :type
t.boolean :tubo
t.references :vitola, foreign_key: true
t.timestamps
end
end
end
|
Rails.application.routes.draw do
get '/featured_researchers/feature_none', to: 'featured_researchers#feature_none'
get '/researcher_spotlights', to: 'featured_researchers#index'
resources :featured_researchers do
member do
get 'preview'
get 'feature'
end
end
get '/datasets/download_cit... |
class Showtime < ApplicationRecord
has_many :tickets
belongs_to :movie, optional: true
belongs_to :theater, optional: true
end
|
# THIS FILE IS CENTRALLY MANAGED BY sync_spec.rb!
# DO NOT EDIT IT HERE!
require 'spec_helper'
require 'json'
require 'erb'
metadata = JSON.parse(File.read('metadata.json'))
fm_version = metadata['version']
fw_version = metadata['dependencies'][0]['version_requirement']
# https://unix.stackexchange.com/a/283489/2315... |
# frozen_string_literal: true
# Note this file includes very few 'requires' because it expects to be used from the CLI.
require 'optparse'
module Bolt
class BoltOptionParser < OptionParser
OPTIONS = { inventory: %w[targets query rerun description],
authentication: %w[user password password-prom... |
class Tweet < ApplicationRecord
belongs_to :user
belongs_to :in_reply_to_tweet, class_name: 'Tweet', required: false
has_one :reply, foreign_key: :in_reply_to_tweet_id, class_name: 'Tweet'
has_one :tweet_review
validates :tweet_id, uniqueness: true
default_scope -> { order(tweeted_at: :desc) }
def repl... |
class Zone < ApplicationRecord
has_many :countries
has_many :regions
has_many :centers
has_many :locations
end
|
require 'rails_helper'
RSpec.describe Api::V1::Agents::JobsController, type: :controller do
let(:agent) { FactoryBot.create(:agent) }
let(:job) { FactoryBot.create(:job) }
describe 'GET #index' do
it 'return 200 with message' do
agent.acquire_access_token!
@request.env['HTTP_AUTHORIZATION'] = "To... |
# frozen_string_literal: true
class Wegift::Product < Wegift::Response
PATH = '/products'
# request/payload
attr_accessor :product_code
# response/success
attr_accessor :code, :name, :description, :currency_code, :availability,
:denomination_type, :minimum_value, :maximum_value,
... |
# frozen_string_literal: true
class UniformNotifier
class AirbrakeNotifier < Base
class << self
def active?
!!UniformNotifier.airbrake
end
protected
def _out_of_channel_notify(data)
message = data.values.compact.join("\n")
opt = {}
opt = UniformNotifier.... |
class Usage < ActiveRecord::Base
has_one :price, dependent: :destroy
has_many :monthly_project_savings, dependent: :destroy
has_many :projects, through: :monthly_project_savings
after_update :update_savings
after_create :create_savings
accepts_nested_attributes_for :price
def update_savings
MonthlyProjectSa... |
class SubforumsController < ApplicationController
before_action :logged_in_user, except: [:index]
before_action :admin_user, only: [:new, :edit, :destroy, :create, :update]
before_filter :get_forum, only: [:new, :index]
def new
@subforum = Subforum.new
end
def show
@subforum = Subforum... |
require 'rails_helper'
RSpec.describe Auditor do
describe '.user_signed_in' do
it 'posts a sign in event to the API' do
stub_request(:post, api_url('events/user_signed_in'))
.with(query: hash_including(user_id: /.+/))
.to_return(status: 201)
Auditor.new.user_signed_in(user_id: '1234'... |
class User
include Mongoid::Document
field :provider, type: String
field :uid, type: String
field :name, type: String
field :oauth_token, type: String
field :oauth_expires_at, type: Time
has_many :posts
has_one :image
def self.from_omniauth(auth)
user = self.where(auth.slice(:provider, :uid)).fi... |
require 'em-xmpp/jid'
require 'em-xmpp/namespaces'
require 'em-xmpp/xml_builder'
require 'fiber'
module EM::Xmpp
class Entity
include Namespaces
include XmlBuilder
attr_reader :jid, :connection
def initialize(connection, jid)
@connection = connection
@jid = JID.parse jid.to_s
... |
class RenamePlacelistIndexOnPlacestoTravelist < ActiveRecord::Migration[5.0]
def change
rename_index :places, "index_places_on_placelist_id", "index_places_on_travelist_id"
end
end
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe UniformNotifier::CustomizedLogger do
it 'should not notify to customized logger' do
expect(UniformNotifier::CustomizedLogger.out_of_channel_notify(title: 'notify rails logger')).to be_nil
end
it 'should notify to customized logger' do
l... |
class FontOldStandardTt < Formula
head "https://github.com/google/fonts.git", verified: "github.com/google/fonts", branch: "main", only_path: "ofl/oldstandardtt"
desc "Old Standard TT"
homepage "https://fonts.google.com/specimen/Old+Standard+TT"
def install
(share/"fonts").install "OldStandard-Bold.ttf"
... |
require 'rails_helper'
feature 'Removing a Status', js: true do
context "User removes an appointment status" do
scenario 'and sees the appointment status is destroyed' do
given_i_select_an_appointment
when_i_deselect_an_appointment_status
then_the_appointment_status_should_be_destroyed_for_tha... |
class Playlist < ActiveRecord::Base
belongs_to :user
has_many :followers
has_many :playlist_tracks
has_many :tracks, :through => :playlist_tracks
end |
# Build a simple guessing game
# I worked on this challenge [by myself].
# I spent [#] hours on this challenge.
# Pseudocode
# Input: The input to initialize should be an integer, but a method guess should be created with another integer as an input
# Output: The output (when using the method guess) should be :high... |
# Write a method most_vowels that takes in a sentence string and returns
# the word of the sentence that contains the most vowels.
def most_vowels(sentence)
vowels = "aeiou"
result = Hash.new(0)
words = sentence.split(" ")
words.each do |word|
word.each_char do |c|
if vowels.include?(c)
... |
# Euler Problem 40
# Solution by Alexander Leishman and Kyle Owen
# June 2013
# URL: http://projecteuler.net/problem=40
# PROBLEM TEXT:
# An irrational decimal fraction is created by concatenating the positive integers:
# 0.123456789101112131415161718192021...
# It can be seen that the 12th digit of the fractional par... |
# encoding: utf-8
module Rapidshare
# Contains utility methods which can be called both as class and instance methods
#
module Utils
# Provides interface for GET requests
#
# PS: previously url.request_uri was escaped by URI::escape method,
# but with params for url filtered by to_query method... |
# -*- coding: utf-8 -*-
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "procedural/version"
Gem::Specification.new do |gem|
gem.version = Procedural::VERSION
gem.name = "procedural"
gem.authors = ["Andrew Timberlake"]
gem.email = ... |
#!/usr/bin/ruby
require 'rubygems'
require 'json'
require 'pp'
require 'erb'
# Read JSON from a file
file = File.read('rosters.json')
data_hash = JSON.parse(file)
#generating proper english based on event given
def player_action(input)
if input == "Released from team"
return input.insert(0, 'was ').downcase
e... |
require 'rails_helper'
describe UrlHelper do
describe '#helper_most_popular_word' do
before(:all) do
@url_with_popularities = FactoryGirl.create(:url_with_popularities)
end
let(:data){ helper_most_popular_word(@url_with_popularities) }
it 'returns a hash' do
expect(data).to be_a(Ha... |
puts __ENCODING__
puts __LINE__
puts __FILE__
BEGIN {
puts 'This shoul be printed first'
}
END {
puts 'This shoul be printed last'
}
|
# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'tiny_sweeper/version'
require 'date'
Gem::Specification.new do |s|
s.name = 'tiny_sweeper'
s.version = TinySweeper::VERSION
s.date = Date.today.to_s
s.summary = "A ... |
class CreateLinks < ActiveRecord::Migration
def self.up
create_table :links do |t|
t.string :link_url #链接地址
t.string :name #名称
t.integer :sort, :default => 0 #排序
t.timestamps
end
names = "爱美网,娃娃会,39育儿,倍儿亲育儿网,幼教网,伊顿国际幼儿园,木蚂蚁安卓市场,人民邮电出版社,新浪微博,起跑线儿歌视频大全,Hers女性网,小学作文网,爱败妈妈网"
... |
# Copyright (c) 2008 Abhishek Parolkar , Parolkar.com
#
# 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 to use,
# copy, modify,... |
# == Schema Information
# Schema version: 20090906124258
#
# Table name: users
#
# id :integer not null, primary key
# login :string(255)
# name :string(255)
# created_at :datetime
# updated_at :datetime
#
class User < ActiveRecord::Base
attr_accessible :name
has_one :team, :class_... |
require_relative '../action'
class Screenplay
module Actions
# @todo Add group: param
class Directory < Screenplay::Action
def initialize(
path: path,
state: :exists,
owner: nil,
mode: nil,
sudo: false,
on_fail: nil
)
@on_fail = on_fail
... |
class BillSerializer < ActiveModel::Serializer
attributes :id, :name, :total, :category, :due_date, :owner_id, :owner_name
has_many :payer_bills, serializer: OwnedPayerBillsSerializer
def owner_name
object.owner.name
end
end
|
require 'rails_helper'
RSpec.describe 'Register a new user', type: :request do
let(:new_user_request) { { user: LauraSpecHelper.valid_user_params } }
context 'First step' do
it 'First step' do
post '/users/registrations', new_user_request, LauraSpecHelper.ios_device
response_hash = JSON.parse(re... |
require 'test_helper'
class BundleTest < ActiveSupport::TestCase
should validate_presence_of(:charity_id)
context "a bundle" do
setup do
@bundle = bundles(:boys_and_girls_of_alameda_with_no_offers)
end
should "be valid" do
assert @bundle.valid?
end
should "be invalid without a do... |
class AddYoutubeUrlToWorkshops < ActiveRecord::Migration[6.0]
def change
add_column :workshops, :youtube_url, :string
end
end
|
FactoryBot.define do
factory :charge do
amount { Faker::Number.number(10) }
payment_type { ['card', 'oxxo', 'spei'].sample }
end
end |
class ReadingsController < ApplicationController
before_action :authenticate, only: :create
before_action :find_next_reading_number, only: :create
before_action :set_reading, only: [:show]
# GET /readings/1
def show
return render json: @reading if @reading
render json: {error: "reading with the id ... |
require 'rails_helper'
RSpec.describe FetchReadingsOfASingleThermostatFromQueue, type: :interactor do
subject(:result) do
FetchReadingsOfASingleThermostatFromQueue.call(
queue: 'testing', thermostat_id: thermostat.id
)
end
describe '.call' do
let(:thermostat) { create(:thermostat) }
let(:r... |
# == Schema Information
#
# Table name: users
#
# id :integer not null, primary key
# email :string default(""), not null
# encrypted_password :string default(""), not null
# reset_password_token :string
# reset_password_sent_at :datetime
# r... |
require ('pg')
require_relative('./albums.rb')
class Artists
attr_reader :id
attr_accessor :name
def initialize(options)
@id = options['id'].to_i if options['id']
@name = options['name']
end
def save()
db = PG.connect({dbname: 'music_colection', host: 'localhost'})
sql = "INSERT INTO artists (
name
... |
class CreateContractResponsibles < ActiveRecord::Migration
def change
create_table :contract_responsibles do |t|
t.references :contract, index: true, foreign_key: true
t.string :name
t.string :office
t.string :department
t.string :whatsapp
t.string :skype
t.timestamps null: false
end
end
... |
#
# NFS client support for Windows in Vagrant
#
# @author Luke Carrier <luke@carrier.im>
# @copyright 2015 Luke Carrier
# @licence GPL v3
#
module VagrantPlugins
module WinNfs
VERSION = "0.1.0"
end
end
|
require_relative '../animal'
require_relative '../animal classes/mammals'
# We will now create a template for a dog and a dog will inherit the traits from the animal class
class Dog < Animal
include Mammals
def alive
self.class.alive # Dog.alive works too.
end
def speak
puts 'Woof'
end
def number_of_legs... |
class SessionsController < ApplicationController
def index
if session[:user_id]
session.delete(:user_id)
end
end
def create
user = AdminUser.find_by(email: params[:sessions][:email].downcase)
if session[:ser_id]
session.delete(:user_id)
end
if user && user.authenticate(param... |
class ClaimantsDetailsController < ApplicationController
def edit
@claimants_detail ||= ClaimantsDetail.new(current_store.hash_store.fetch(:claimants_detail_answers, {}))
end
def update
@claimants_detail = ClaimantsDetail.new(claimants_detail_params)
if @claimants_detail.valid?
current_store.ha... |
class RemoveDeletedAtFromPosts < ActiveRecord::Migration[5.2]
def change
remove_column :texts, :deleted_at
end
end
|
module IpRestriction
module Configuration
DEFAULT_FILE_PATH = 'config/ip_restriction.yml'
attr_accessor :file_path
def configure
yield self
end
def file_path
@file_path || DEFAULT_FILE_PATH
end
end
end
|
class MazesController < ApplicationController
def index
@mazes = Maze.all
render json: @mazes
end
def show
@maze = Maze.find(params[:id])
render json: @maze
end
def create
@maze = Maze.create(maze_params)
if @maze.valid?
... |
require_relative '../acceptance_helper'
feature 'User can Logout', %q{
authenticated user can logout} do
given(:user) { create(:user) }
scenario 'authenticated user can logout' do
sign_in(user)
expect(page).to have_content 'Sign Out'
click_on 'Sign Out'
expect(page).to have_content 'Signed out s... |
class User < ActiveRecord::Base
acts_as_authentic
validates_presence_of :first_name, :last_name, :email, :username
validates_format_of :username, :with => /^[A-Za-z0-9-]+$/, :message => 'The User Name can only contain alphanumeric characters and dashes.'
end
|
module Core
module Helpers
module Exposures
def respond_to_missing?(m, include_all)
action_exposures.key?(m) || @options.key?(m)
end
protected
def action_exposures
@action_exposures ||= (::RequestStore.store[:action_exposures]||{})
end
def method_missing(m, ... |
# Utilizando uma collection do tipo Array, escreva um programa que receba 3 números e no final
# exiba o resultado de cada um deles elevado a segunda potência.
array = []
i = 1
1..3.times do
print "Digite o #{i}º número: "
array.push gets.chomp.to_i
i += 1
end
array.each do |a|
result... |
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe Ann::Responders::JsonResponder do
DummyResponder = Class.new { include Ann::Responders::JsonResponder }
subject(:responder) { DummyResponder.new }
describe '#has_view_rendering?' do
it 'disables view rendering so it don\'t try to respond... |
require "angular-leaflet-rails/version"
require "angularjs-rails"
require "leaflet-rails"
module AngularLeaflet
module Rails
class Engine < ::Rails::Engine
# Rails -> use vendor directory.
end
end
end
|
class HomeController < ApplicationController
before_action :authenticate_user!
skip_before_action :verify_authenticity_token
def index
# Harcoded assesor for demo
@assesor = User.first
@students = User.where(assesor: false)
end
def verify
end
def resend
end
def show_verify
return r... |
class CreateBaseRooms < ActiveRecord::Migration[5.1]
def change
enable_uuid!
create_table :base_rooms, id: :uuid do |t|
t.string :number, null: false, default: ''
t.string :name, null: false, default: ''
t.float :square
t.string :type, default: 'BaseRoom', null: false
t.boo... |
class CreateTaxRates < ActiveRecord::Migration
def change
create_table :tax_rates do |t|
t.string :state
t.decimal :rate, precision: 5, scale: 2
t.timestamps null: false
end
create_join_table :categories, :tax_rates do |t|
t.index :category_id
t.index :tax_rate_id
end
... |
require 'auto_emote/helpers'
module AutoEmote
VERSION = '0.0.1'
class Railtie < ::Rails::Railtie
initializer 'auto_emote' do |app|
ActiveSupport.on_load(:action_view) do
require 'auto_emote/helpers'
end
end
end
end
|
FactoryBot.define do
factory :currency, class: Currency do
code { 'USD' }
symbol { '$' }
name { 'Dollar' }
country { 'United States' }
factory :currency_ballast do
default { true }
end
factory :currency_crypto_coin do
code { 'BTC' }
symbol { 'bitcoin' }
name { 'Bi... |
module Services
class UpdateServiceTransaction < ::BaseTransaction
map :update_service
check :successfull_update?
private
def update_service(id:, service:)
rom_env
.relations[:services]
.by_pk(id)
.changeset(:update, service)
.commit
end
def successfull... |
class AddBrakeTypeToBikes < ActiveRecord::Migration[5.0]
def change
add_column :bikes, :brake_type, :integer
end
end
|
class Status < ApplicationRecord
belongs_to :user
validates :automation, numericality: { only_integer: true, greater_than_or_equal_to: 0 }
validates :imagination, numericality: { only_integer: true, greater_than_or_equal_to: 0 }
validates :humor, numericality: { only_integer: true, greater_than_or_eq... |
require 'rails_helper'
require './app/services/transaction_import.rb'
RSpec.describe TransferIn, type: :model do
let(:transfer_in) { create(:bank) }
let(:bank) { {created_at: "201708010100"} }
it { should validate_presence_of(:source_id) }
it { should validate_presence_of(:source_name) }
it { should validat... |
require 'card'
describe Card do
let(:card) { Card.new(:H, 2) }
it "returns suit" do
expect(card.suit).to eq(:H)
end
it "returns value" do
expect(card.value).to eq(2)
end
it "returns a great looking card" do
expect(card.to_s).to eq(" #{"\u2665".encode("utf-8")} 2 ".colorize(:color => :red, :b... |
# == Schema Information
#
# Table name: services
#
# id :integer not null, primary key
# description :text
# description_two :text
# image_one_url :string(255)
# image_two_url :string(255)
# image_url :string(255)
# name :string(255)
# r... |
class UserExam < ApplicationRecord
belongs_to :user
belongs_to :exam
validates_presence_of :fecha, :puntaje
end
|
class Question
def initialize()
@num1 = rand(1..20)
@num2 = rand(1..20)
end
def generateQuestion
"What does #{@num1} + #{@num2} equal?"
end
def isAnswerRight?(user_answer)
user_answer.to_i == @num1 + @num2
end
end |
class CreatePromotions < ActiveRecord::Migration[5.1]
def change
create_table :promotions do |t|
t.string :name, null: false
t.string :slug, null: false
t.string :company_name
t.string :company_number
t.string :address_ln_1
t.string :address_ln_2
t.string :city
t.st... |
require 'active_support/concern'
module Inertiable
extend ActiveSupport::Concern
included do
before_action :set_csrf_cookies
inertia_share errors: -> {
session.delete(:errors) || []
}
inertia_share flash: -> {
{
success: flash.notice,
alert: flash.alert
}
}
... |
class AddIndexs < ActiveRecord::Migration
def change
add_index :companies, :employees_number
add_index :briefing_sessions, :location
add_index :briefing_sessions, :bs_date
end
end
|
class Movie
attr_reader :name, :year, :age
def initialize(name, year)
@name = name
@year = year
@age = 18
end
end |
class XmlContactImporter < ContactImporter
def import
contacts_hash = Hash.from_xml @content
if contacts_hash['contacts'] and contacts_hash['contacts']['contact']
contacts = contacts_hash['contacts']['contact']
@total = contacts.size
contacts.each do |contact_hash|
contact_hash['las... |
# config valid only for current version of Capistrano
lock '3.4.0'
# Change these
# server '104.236.109.35', port: 22, roles: [:web, :app, :db], primary: true
set :repo_url, 'git@github.com:alexandrule/social-stream.git'
# set :application, 'setphrase'
set :user, 'root'
# set :puma_threads, [... |
class Dogsister < ApplicationRecord
belongs_to :city
has_many :dogs, through: :stroll
has_many :strolls
end
|
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'Comments', type: :system do
let!(:me) { create(:user) }
let!(:others) { create(:user) }
let!(:avatar) { create(:avatar, user: others, public: true) }
let!(:my_comment) { create(:comment, avatar: avatar, user: me, content: 'my comment') }
l... |
class S3
class Bucket
# This is a fake library for the purpose of the workshop.
# Please consider that this is an external library: do not change this file.
def initialize(name)
@name = name
end
def create_file(file_name, contents)
S3::File.create(bucket_name: @name, file_name: file_... |
require 'turing/machine/configuration'
module Turing
class Machine
# The ConfigurationList holds the list of configurations for the machine.
# This list, combined with the current configuration and current tape
# position, represents the "complete configuration" of the machine.
class ConfigurationLis... |
require File.join(File.dirname(__FILE__), "/../spec_helper")
module YahooStock
describe Quote do
describe "initialize" do
it "should raise error when no parameter is passed" do
lambda { YahooStock::Quote.new }.should raise_error
end
it "should raise QuoteException err... |
# convert the DiP XML format into our JSON representation:
# - text objects -> string literals (i.e., terminal symbols)
# - elements -> hashes (i.e., non-terminal syms)
# - <p> -> "box"
# - <ref> -> "category"
# - <xref> -> "substitution"
# - <choice> -> "choice"
# - <grammar> -> "grammar"
requ... |
require 'rails'
require 'rails/generators/active_record'
module Coalla
module Cms
module Image
class MountGenerator < ActiveRecord::Generators::Base
argument :name, type: :string
argument :field, type: :string
class_option :prefixed, type: :boolean, default: false
source_ro... |
class AddressRelationships < ActiveRecord::Migration[5.2]
def change
remove_column :users, :address_id
add_reference :addresses, :addressable, polymorphic: true, index: true
end
end
|
require 'serverspec'
include Serverspec::Helper::Exec
include Serverspec::Helper::DetectOS
RSpec.configure do |c|
c.before :all do
c.path = '/usr/bin'
end
end
describe 'Salt Key Exchange' do
describe command('salt-key --list=pre') do
its(:stdout) { should match /default-/ }
end
end
describe 'Salt ... |
class UsersController < ApplicationController
def users
@users = User.order(lastName: :asc).all
end
def edit
@user = User.find(params[:id])
end
def create
User.create(user_params)
redirect_to root_path
end
def update
@user = User.find(params[:id])
if @user.update(user_params)
... |
class Patient < ActiveRecord::Base
has_paper_trail
has_many :prescriptions, dependent: :destroy
has_many :adherences, :dependent => :destroy
has_many :messages, :through => :adherences
belongs_to :pharmacy
attr_accessible :first_name, :last_name, :phone_number, :pharmacy_id
crypt_keeper :last_name, :encry... |
# Print all odd numbers from 1 to 99, inclusive. All numbers should be printed on separate lines.
# (1..99).each {|i| puts i if i.odd?}
# puts (1..99).select {|i| i.odd?}
# 1.upto(99) {|i| puts i if i.odd?}
# 100.times {|i| puts i if i % 2 == 1}
# ------------
# value = 1
# while value <= 99
# puts value
# va... |
# CLI Controller
class VevoTrending::CLI
def call
trending_videos
main_menu
end
def trending_videos
puts "Today's Trending Videos on Vevo:"
@trending = VevoTrending::Trending.today
(0..9).each.with_index(1) do |i|
puts "#{i + 1}. #{@trending[i].title} - #{@trending[i].name}"
end... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.