text stringlengths 10 2.61M |
|---|
module Donut
class CollectionIndexer < Hyrax::CollectionWithBasicMetadataIndexer
def generate_solr_document
super.tap do |solr_doc|
if object.thumbnail_id.present?
solr_doc['thumbnail_iiif_url_ss'] = thumbnail_iiif_url
end
end
end
private
def thumbnail_iiif_ur... |
#
# Copyright (c) 2017 joshua stein <jcs@jcs.org>
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DIS... |
class Cart < ApplicationRecord
belongs_to :item
belongs_to :customer
end
|
require 'test_helper'
class AliasedInterpretationsControllerTest < ActionDispatch::IntegrationTest
test 'index from interpretations for edit access' do
referer_index = user_agent_interpretations_url(
users(:admin), agents(:terminator)
)
referer_show = user_agent_interpretation_path(
users(:a... |
class Api::V1:: ConversationsController < BaseController
before_action :find_user, only: [:create]
def index
conversation_ids = current_user.conversation_users.where(is_deleted: false).pluck(:conversation_id)
@conversations = Conversation.where(id: conversation_ids)
render :index
end
def create
... |
#--
# Copyright (c) 2010-2017 David Kellum
#
# Licensed under the Apache License, Version 2.0 (the "License"); you
# may not use this file except in compliance with the License. You
# may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed t... |
# -*- coding: utf-8 -*-
# ArcRectangle クラスのソースファイル
# Author:: maki-tetsu
# Date:: 2011/10/10
# Copyright:: Copyright (c) 2011 maki-tetsu
require File.join(File.dirname(__FILE__), "drawable")
require File.join(File.dirname(__FILE__), "color")
require File.join(File.dirname(__FILE__), "region")
require File.join(File.di... |
class DressmakerProfilesController < ApplicationController
skip_before_action :authenticate_user!, only: %i[index show]
before_action :set_dressmaker, only: %i[show edit update]
def index
# for dropdown filter
@specialities = Speciality.all
if params[:query].present?
@dressmakers = policy_scop... |
class Dataset < ApplicationRecord
attr_accessor :blob
attr_accessor :user_file_path
before_save :save_file
before_destroy :remove_file
has_many :experiments
private
def save_file
if self.blob.present?
old_file = Rails.root.join('public', 'uploads', 'datasets', self.blob.original_filename)
F... |
Gem::Specification.new do |s|
s.name = "worm"
s.version = "0.0.2"
s.authors = ["Jeremy Stewart"]
s.date = '2013-06-11'
s.description = %q{An irb driver for Frankified iOS apps}
s.email = %q{jlstewart379@gmail.com}
s.files = ["lib/worm.rb", "lib/selector_builder.rb", "lib/screen.rb"]
s.test_files = ["spe... |
require File.join(File.dirname(__FILE__), 'gilded_rose')
describe GildedRose do
describe '#update_quality with a standard item' do
let!(:item) { Item.new('foo', 7, 5) }
let!(:items) { [item] }
before(:each) { GildedRose.new(items).update_quality }
it 'does not change the name' do
expect(items[... |
class LikeSerializer < ActiveModel::Serializer
attributes :id
has_one :poem
end
|
ActiveAdmin.register Order do
# Strong parameters trong Rails
# cho phép Rails controllers nhận giá trị truyền từ views
# Cho các thuộc tính được khai báo dưới đây
permit_params :name, :image
index do
selectable_column
id_column
column :transaction_id
column :product_id
column :qty
column :amount
c... |
require 'constant'
require 'redis_utils'
class MetricJob < ApplicationJob
=begin
In this class , I start to iterate over the redis increment key as reverse sorted.
In Metrics Controller class, I kept until the 'Constant::REDIS_INC_MOD'
By doing a reverse order, I start to process the data I hold in Redis.
I... |
class Document < ApplicationRecord
attr_writer(:locale)
# It stores sv and en file in same folder, going to update.
mount_uploader(:file_sv, FaultyDocumentUploader)
mount_uploader(:file_en, FaultyDocumentUploader)
belongs_to(:meeting, optional: true) # Revisioned at meeting
has_many(:meeting_documents)
h... |
require 'rails_helper'
RSpec.describe Balances::List, type: :api do
describe 'Behavior' do
let(:user_a) { create(:user) }
let(:user_b) { create(:user) }
let!(:record_a) { create(:record, group: :income, user: user_a) }
let!(:record_b) { create(:record, group: :income, user: user_b) }
it 'lists b... |
class AddFieldsToPlayer < ActiveRecord::Migration
def self.up
add_column :players, :birth_city, :string
add_column :players, :birth_nation, :string
add_column :players, :height, :integer
end
def self.down
remove_column :players, :height
remove_column :players, :birth_nation
remove_column ... |
module KnapsackPro
class QueueAllocator
def initialize(args)
@all_test_files_to_run = args.fetch(:all_test_files_to_run)
@ci_node_total = args.fetch(:ci_node_total)
@ci_node_index = args.fetch(:ci_node_index)
@ci_node_build_id = args.fetch(:ci_node_build_id)
@repository_adapter = arg... |
class CreateSlogs < ActiveRecord::Migration
def change
create_table :slogs do |t|
t.string :description
t.string :poster
t.date :departure_date
t.references :user, index: true
t.timestamps
end
add_index :slogs, [:user_id, :created_at]
end
end
|
def resource_status_tag(resource)
if resource.respond_to?(:unconfirmed?) && resource.unconfirmed?
status_tag(resource.aasm_human_state, :warning)
elsif resource.respond_to?(:pending?) && resource.pending?
status_tag(resource.aasm_human_state, :warning)
elsif resource.respond_to?(:active?) && resource.acti... |
class Admin::DancesController < Admin::ApplicationController
before_action :set_event
before_action :set_reception
before_action :set_dance, only: [:edit, :update, :destroy]
def new
@dance = Dance.new
end
def create
@dance = Dance.new(dance_params)
if @dance.save
@dance.reception_id = @... |
class Unit
TEAMS = {elf: "E", goblin: "G"}.freeze
attr_reader :team, :attack
attr_accessor :hp, :position
def initialize(team, position)
@team = team
@position = position
@hp = 200
@attack = 3
end
def dead?
@hp <= 0
end
end
class Map
def initialize(map)
@map = map
end
de... |
require 'rails_helper'
RSpec.describe 'users API', type: :request do
# initialize test data
# let(:user) { create(:user) }
let!(:users) { create_list(:user, 10) }
# let!(:created_user) { build(:userasd) }
let(:user) { users.first }
let(:user_id) { users.first.id }
let(:headers) { valid_headers }
# ... |
# encoding: utf-8
# Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
module MobileCenterApi
module Models
#
# Model object.
#
#
class Event
# @return [String]
attr_accessor :id
... |
namespace :user do
desc "check users status"
task role_check: :environment do
puts "Users count: #{ User.count }"
paid, dropped, expiring = 0, 0, 0
developers_ids = [2, 85, 1136, 61, 56, 108, 118, 22, 1053] #[2, 56, 61, 85, 1136]
User.where.not(id: developers_ids).each do |user|
next until use... |
module Accountable
module Accounts
class UsersController < AccountableController
load_and_authorize_resource
before_filter :is_confirmed?, :only => [:confirm]
before_filter :have_confirmation_code?, :only => [:confirm]
before_filter :set_body_id
before_filter :set_profile_field_na... |
module ConnectionHelper
def self.connection_for(dbname)
require "pg"
options = {
:host => ENV["PGHOST"],
:user => ENV.fetch("PGUSER", "root"),
:password => ENV.fetch("PGPASSWORD", "smartvm"),
:dbname => dbname
}.compact
PG::Connection.new(options)
end
end
|
class CreatePlayerGoals < ActiveRecord::Migration
def change
create_table :player_goals do |t|
t.references :show
t.timestamps
end
end
end
|
class Post < ActiveRecord::Base
attr_accessible :body, :approved, :likes, :dislikes
validates_presence_of :body
end
|
class Weight < ApplicationRecord
belongs_to :user
validates :weight,presence: true
end
|
require "./person.rb"
require "./politician.rb"
describe Politician do
it "Reports a politician" do
person = Politician.new("jo Doe", "Dem")
expect(person).to be_a(Politician)
end
it "Name reported" do
person = Politician.new("Jo Doe", "Dem")
expect(person.name).to eq("Jo Doe... |
class Main < ActiveRecord::Base
has_many :subs
validates :title, presence: { message: "スレッドタイトルが入力されていません"}
end
|
# frozen_string_literal: true
require_relative '../modules/draw'
# Class that handles the common logic for all game pieces
class GamePiece
attr_accessor :position, :board, :object_array
# Draw module displays a given array to the tetris window
include Draw
def initialize(board, window)
@board = board
... |
class AddColumnsToCoverage < ActiveRecord::Migration
def change
add_column :coverages, :abbr, :string
add_column :coverages, :premium_amount, :float
add_column :coverages, :premium_unit, :string
add_column :coverages, :coverage_unit, :string
add_column :coverages, :coverage_end_at, :stri... |
require 'spec/spec_helper'
class GroupedJob
include Mongoid::Document
include JobGroups
field :repository
job_group{ |simple_job| simple_job.repository }
def perform
puts "running grouped job"
end
end
class SimpleJob
include Mongoid::Document
include JobGroups
def perform
puts "... |
class UserCoreOccupation < ApplicationRecord
belongs_to :user
belongs_to :core
belongs_to :occupation
end
|
# 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... |
Sequel.migration do
change do
create_table :config do
primary_key :id
String :key
String :value
end
end
end
|
require 'padrino-helpers'
module Helpers
def renderer
@renderer ||= Class.new do
include Padrino::Helpers::OutputHelpers
include BootstrapNavbar::Helpers
end.new
end
def with_all_2_dot_x_versions(&block)
with_versions '2'...'3', &block
end
def with_all_3_dot_x_versions(&block)
w... |
class Api::WorkspacesController < ApplicationController
def create
@workspace = Workspace.new(workspace_params)
if @workspace.save
#create workspace membership when current user creates a new workspace
WorkspaceMembership.create(member_id: current_user.id, workspace_id: @work... |
require 'rails_helper'
describe Denormalizers::Email::Received do
let(:uid) { Time.current.strftime("%H%M%S%L#{SecureRandom.random_number(100)}") }
describe '#perform' do
context 'when success' do
it 'creates email record' do
payload = {
"event_id" => "5a71ff1d-b6f1-4edb-986d-7eae0d3f5... |
class CreateResourceRoomBookings < ActiveRecord::Migration
def self.up
create_table :resource_room_bookings do |t|
t.references :sub_category
t.references :resource
t.references :agency_store
t.references :user
t.references :department
t.string :requested_from_date
t.stri... |
#
# these tests taken from the HTML5 sanitization project and modified for use with Loofah
# see the original here: http://code.google.com/p/html5lib/source/browse/ruby/test/test_sanitizer.rb
#
# license text at the bottom of this file
#
require "helper"
class Html5TestSanitizer < Loofah::TestCase
include Loofah
... |
require 'spec_helper'
describe 'CSVBankData' do
before(:all) do
@transaction = Model::Transaction.new()
end
describe BankStatements::InMemoryQuery::QueryDateMatcher do
describe 'start and end dates are nil' do
it 'permits all dates' do
date_query_matcher = BankStatements::InMemoryQuery::Qu... |
require 'rails_helper'
RSpec.describe User, type: :model do
it 'has_many' do
should have_many :posts
end
it 'full name' do
user = User.new(first_name: "Ivan", last_name: "Ivanov")
expect(user.full_name).to eq "Ivan Ivanov"
end
end |
module JobsCrawler
class Indexers::EmploiSenegal
include Wombat::Crawler
base_url 'https://www.emploisenegal.com'
path '/recherche-jobs-senegal'
¬
links 'css=.search-results .job-description-wrapper', :iterator do
url({ xpath: ".//@data-href" })
titre({ xpath: ".//text()" })
... |
# frozen_string_literal: true
# 专栏文章称为 article ,model 层继续用 topic
class ArticlesController < TopicsController
before_action :set_article, only: [:show, :ban, :append, :edit, :update, :destroy, :follow,
:unfollow, :action, :down]
def index
@articles = Article.all
end
de... |
class CreateAlbumService
def self.call data
data[:artist] = Artist.find_or_create_by name: data[:artist].titleize
data[:genre] = Genre.find_or_create_by name: data[:genre].titleize
album = Album.create data
AlbumSerializer.new(album)
end
end
|
class ChangesController < ApplicationController
before_filter :setup_ingredient
def setup_ingredient
@ingredient = Ingredient.find(params[:ingredient_id])
end
def new
@ingredient =Ingredient.find(params[:ingredient_id])
@change=Change.new
end
def create
@ingredient =Ingredient.find(params[:ingredient_id... |
# -*- encoding : utf-8 -*-
module SessionsHelper
# 判断用户登陆后使用.
# 用户登陆, 分永久登陆与浏览器有效期登陆
def sign_in(user, permanent=false)
if permanent
session.delete(:remember_token)
cookies.permanent[:remember_token] = user.remember_token
else
session[:remember_token] = user.remember_token
end
s... |
module Apprenticeships
class SessionsController < Base::SessionsController
protected
def challenge_path
apprenticeships_users_challenge_path(challenge_name: @result.challenge_name, session: @result.session, username: @result.cognito_uuid)
end
def after_sign_in_path_for(resource)
stored_l... |
class FontLangdon < Formula
head "https://www.ffonts.net/Langdon.font.zip"
desc "Langdon"
homepage "https://www.ffonts.net/Langdon.font"
def install
(share/"fonts").install "Langdon.otf"
end
test do
end
end
|
class AddDatesToExaminations < ActiveRecord::Migration
def change
add_column :examinations, :last_date, :datetime
add_column :examinations, :exam_date, :datetime
end
end
|
class CreateTweets < ActiveRecord::Migration
def change
create_table :tweets do |t|
t.references :twitter_account, null: false, index: true
t.text :text, null: false
t.string :status_id, null: false
t.datetime :published_at, null: false
t.timestamps null: false
end
end
end
|
module CategoriesHelper
def nested_categories(categories)
categories.map do |category, sub_category|
render(category) + nested_categories(sub_category)
end.join.html_safe
end
def nested_categories_tree(categories)
categories.map do |category, sub_category|
c =("--"*3*category.depth)
c << "<abbr titl... |
class CommentsController < ApplicationController
def create
@comment = Comment.new(post_params)
if @comment.save
flash[:notice] = 'コメントしました'
else
flash[:error] = 'コメントを入力してください'
end
redirect_to :root
end
protected
def post_params
params.require(:comment).permit(:body, :post... |
require 'card'
class Hand
attr_reader :cards
attr_accessor :rank, :tiebreakers
def initialize(cards)
@cards = cards
@rank = nil
@tiebreakers = nil
end
def straight_flush?
values = get_values
if straight? && flush?
@rank = 1
@tiebreakers = [values.last]
true
else
... |
class RemoveCirconscriptionRefFromRepresentatives < ActiveRecord::Migration[6.0]
def change
remove_column :representatives, :circonscription_ref, :string
end
end
|
# TODO: Figure out what can be language agnostic and what can't
# TODO: Currently we assume correct code, but we realistically we need error detection too
# TODO: Law of Demeter
def generate_program(function)
File.write("submit.rb", generate_program_submit(function))
File.write("consumer_progenitor.rb", generate_q... |
class CreateAmounts < ActiveRecord::Migration
def change
create_table :amounts do |t|
t.integer :account_id, null: false
t.string :type, null: false
t.decimal :value, null: false, precision: 8, scale: 2
t.timestamps null: false
end
add_index :amounts, [:account_id, :type, :value],... |
require 'spec_helper'
describe 'Sharepoint Trade Article API V2', type: :request do
include_context 'V2 headers'
fixtures_files_dir = "#{Rails.root}/spec/fixtures/sharepoint_trade_articles"
before(:all) do
fixtures_files = Dir["#{fixtures_files_dir}/articles/*"].map { |file| open(file).read }
s3 = stubb... |
require "rails_helper"
feature "Homepage" do
let!(:article) { create :article }
scenario "Someone visits homepage" do
visit "/"
expect(page).to have_content(article.title)
expect(page).to have_content(article.content)
end
end
|
#
# Be sure to run `pod lib lint JSONRenderSwift.podspec' to ensure this is a
# valid spec before submitting.
#
# Any lines starting with a # are optional, but their use is encouraged
# To learn more about a Podspec see https://guides.cocoapods.org/syntax/podspec.html
#
Pod::Spec.new do |s|
s.name = 'JSO... |
require 'app/constants.rb'
require 'app/rect.rb'
require 'app/tile.rb'
def tick args
tick_game args
end
def tick_game args
# setup defaults
args.state.grid.padding = 100
args.state.grid.size = 512
args.state.map.tiles ||= []
args.state.map.rooms ||= []
args.state.player.direction ||= 1
args.state.play... |
class AddJobToUsers < ActiveRecord::Migration[6.0]
def change
add_column :users, :job, :string, default: "None"
end
end
|
class Review < ApplicationRecord
belongs_to :booking
has_one :bathroom
validates :content, :rating, presence: true
end
|
require "rails_helper"
RSpec.describe CommentsController, type: :routing do
describe "routing" do
it "routes to #index" do
expect(:get => "/posts/1/comments").to route_to({
"controller" => "comments",
"action" => "index",
"post_id" => "1"
})
end
it "routes to #creat... |
Rails.application.routes.draw do
devise_for :users
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
root 'top#index'
resources :micro_bit
resources :lessons do
resources :comments, only: [:create]
resources :likes
end
resources :users
resources ... |
Devise.setup do |config|
config.mailer_sender = "Stoffi <noreply@stoffiplayer.com>"
require 'devise/orm/active_record'
config.case_insensitive_keys = [ :email ]
config.strip_whitespace_keys = [ :email ]
config.paranoid = true
config.stretches = Rails.env.test? ? 1 : 10
config.remember_for = 2.weeks
config.passw... |
class AddAgrupamentoToAtividades < ActiveRecord::Migration
def change
add_column :atividades, :agrupamento, :string
add_column :atividades, :show_contratos, :boolean, :default => true
end
end
|
class Admin::UsersController < ApplicationController
before_filter :authorized
def show
end
def messages
@messages = Contact.all
end
def comments
end
def new_article
@blog = Blog.new
end
def create_article
@article = Blog.new(article_params)
@article.post_by = current_admin.name
i... |
require './lib/book'
class Author
attr_reader :books, :first_name, :last_name
def initialize(author_deets)
@books = []
@first_name = author_deets[:first_name]
@last_name = author_deets[:last_name]
end
def name
@first_name + " " + @last_name
end
def write(title, publication_date)
boo... |
require 'test_cases/tiger'
describe Tiger, "inherited from Cat" do
subject(:tiger) { @tiger = Tiger.new("Shere Khan", "stripped" ) }
it "should also as Cat play after eat" do
tiger.eat
tiger.method_calls[:eat].should_not be nil
tiger.method_calls[:play].should_not be nil
tiger.method_calls[:eat].s... |
class RemoveActsAsParanoid < ActiveRecord::Migration
require 'rexml/document'
require 'ftools'
@models = [ DatabaseInstance, DatabaseInstanceRelationship, Datacenter, HardwareProfile, IpAddress, NetworkInterface, NodeGroup, Node, OperatingSystem, Outlet, Status, Subnet, Vip, DatacenterRackAssignment, DatacenterVi... |
class Fruit < ActiveRecord::Base
validates :name, :variety, :color, presence: true
belongs_to :plantation
end
|
require 'spec_helper'
require 'alchemy/tasks/helpers'
module Alchemy
class Foo
extend Tasks::Helpers
end
describe "Tasks:Helpers" do
let(:config) do
{ 'test' => {
'adapter' => 'mysql2',
'username' => 'testuser',
'password' => '123456',
'host' => 'local... |
require "singleton"
require 'sqlite3'
class QuestionsDatabase < SQLite3::Database
include Singleton
def initialize
super('questions.db')
self.type_translation = true
self.results_as_hash = true
end
end
class Question
attr_accessor :id, :title, :body, :user_id
def self.all... |
# 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 User < ApplicationRecord
has_secure_password
validates :email, presence: true, uniqueness: true
has_many :received_messages, class_name: 'Message', foreign_key: 'recipient_id'
has_many :sent_messages, class_name: 'Message', foreign_key: 'sender_id'
has_many :friends, class_name: 'Friend', foreign_key: 'frien... |
require File.dirname(__FILE__) + '/../spec_helper.rb'
describe Bottle::Listener do
include EventedSpec::SpecHelper
em_before { AMQP.cleanup_state }
em_after { AMQP.cleanup_state }
before :each do
@amqptest = AmqpTest.new
@queue_name = "99.bottles"
end
describe "new" do
it "should initializ... |
module SitesHelper
def site_attributes(site)
site == @site ? { :id => 'current_site' } : {}
end
def new_site_content(&block)
if current_user.trial_period_expired?
render :partial => 'shared/trial_period_expired'
elsif current_user.can_add_site?
capture(&block)
else
render :parti... |
Pod::Spec.new do |s|
s.name = "PEFuelPurchase-Model"
s.version = "1.0.221"
s.license = "MIT"
s.summary = "An iOS static library representing the core logic of the Gas Jot application."
s.author = { "Paul Evans" => "evansp2@gmail.com" }
s.homepage = "https://github.com/evansp... |
module MRuby::Bindings
class RenderedText
attr_accessor :id, :body
def initialize(id, body)
@id = id
@body = body
end
end
end
|
# frozen_string_literal: true
require_relative 'movement.rb'
require_relative 'piece.rb'
class Pawn < Piece
include Movement::SingleStep
attr_writer :two_square_opening
def initialize(color, pos = nil)
super({ w: "\u2659", b: "\u265F" }, color, pos)
@baseline = @color == :w ? 1 : 6
@last_rank = @c... |
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
Role.all.each do |r|
define_method "verify_#{r.name}" do
unless current_user.present? && current_user.has_role?(r.name)
@role = r
render :missing_role
end
end
end
def admin_or_role(re... |
require 'test_helper'
class ExihibitionSessionsControllerTest < ActionController::TestCase
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:exihibition_sessions)
end
test "should get new" do
get :new
assert_response :success
end
test "should create ... |
require 'rails_helper'
feature 'User can vote for a question', %q{
In order to rate favorite question
user as an authenticated user can vote
} do
given(:user) { create(:user) }
given(:another_user) { create(:user) }
given(:question) { create(:question, user: user) }
describe 'Authenticated user (not autho... |
class AddColumnSyoji3 < ActiveRecord::Migration[5.1]
def change
add_column :syojis, :volume, :integer
end
end
|
module Elophant
class ElophantException < StandardError
def initialize(msg)
super(msg)
end
end
class Summoner
include HTTParty
base_uri 'http://api.elophant.com/v2'
default_params :output => 'json'
format :json
DEFAULT_OPTIONS = {key: Rails.configuration.elophant_key}
... |
require_relative 'node'
require 'pry'
class LinkedList
attr_accessor :head
def initialize
@head = nil
end
def append(data)
current = @head
if @head == nil
@head = Node.new(data)
else
until current.next_node == nil
current = current.next_node
end
current.next_nod... |
module Authlogic
module Session
# Think about financial websites, if you are inactive for a certain period
# of time you will be asked to log back in on your next request. You can do
# this with Authlogic easily, there are 2 parts to this:
#
# 1. Define the timeout threshold:
#
# acts_as... |
# 1) terminal rails g migration create_artists
# 2) fill out table columns below t.text :name
# 3) rake db:migrate
# 4) check if works run terminal: 'rails db' and '.schema'
class CreateArtists < ActiveRecord::Migration
def change
create_table :artists do |t|
t.text :name
t.text :nationality
t.... |
require 'spec_helper'
require 'rspec_api_documentation/dsl'
resource "Dispute" do
before(:all) do
@dispute = create(:dispute)
@user_1 = create(:user, dispute_id: @dispute.id)
@user_2 = create(:user, dispute_id: @dispute.id)
@show_attributes = ['items']
end
before(:each) { @dispute.reload }
... |
require 'ruby_units'
class FFProbe
class Unit < ::Unit
def to_i
scalar.to_i
end
def to_f
scalar.to_f
end
end
end |
class PlatesController < ApplicationController
before_action :set_plate, only: [:show, :edit, :update, :destroy]
# GET /plates/new
def new
@plate = Plate.new
@plate.state = "CA"
end
# GET /plates/1/edit
def edit
end
def lookup
@plate = Plate.new(:number => params[:number], :state => param... |
require 'rails_helper'
RSpec.describe CalculateAmortization do
describe "initialization" do
end
describe "calculating amortization" do
it "returns a hash of dates, not integers" do
pending("just change the specs")
end
it "calculates amortization for a 6 month loan with interest" do
cal... |
class Url < ApplicationRecord
URL_REGEX = %r(\A(?:https?://)?(?:\w+\.)(?:\.?\w{2,})+\z).freeze
DEFAULT_DOMAIN = 'http://localhost:3000/'.freeze
validates :original, presence: true, format: { with: URL_REGEX, message: 'please enter a correct url'}
validates :slug, uniqueness: true, allow_blank: false
def gen... |
dep 'lolcat' do
met? {
shell?('which lolcat')
}
meet do
log_shell('Installing lolcat', 'gem install lolcat')
end
end
|
# -*- mode: ruby -*-
# vi: set ft=ruby :
CENTOS = {
box: "opscode-centos-6.4",
url: "https://opscode-vm.s3.amazonaws.com/vagrant/opscode_centos-6.4_provisionerless.box"
}
UBUNTU = {
box: "opscode-ubuntu-12.04",
url: "https://opscode-vm.s3.amazonaws.com/vagrant/opscode_ubuntu-12.04_provisionerless.box"
}
NODES... |
# Logic for the TEM emission process.
#
# Author:: Victor Costan
# Copyright:: Copyright (C) 2009 Massachusetts Institute of Technology
# License:: MIT
# :nodoc: namespace
module Tem::Admin
# Logic for the TEM emission process.
module Emit
# The SEClosure that performs key generation for the TEM.
def self.emit_k... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.