text stringlengths 10 2.61M |
|---|
#!/usr/bin/env ruby
$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/.."
require "gator"
require "sqlite3"
require "optparse"
OptionParser.new do |opts|
opts.banner = "Usage: #{__FILE__} [-d /path/to/database]\nAdd obsids to a database for downloading."
opts.on("-h", "--help", "Display this message.") {puts opts... |
require_relative 'my_stack'
require 'byebug'
class StackQueue
def initialize
@stack1 = MyStack.new
@stack2 = MyStack.new
@max_stack = MyStack.new
@min_stack = MyStack.new
@current_max = nil
@current_min = nil
end
def enqueue(value)
check_max(value)
check_min(value)
@stack1.pu... |
class Half < Formula
desc "Floating-point library for half-precision floats"
homepage "http://half.sourceforge.net/"
url "https://sourceforge.net/projects/half/files/half/2.1.0/half-2.1.0.zip"
sha256 "ad1788afe0300fa2b02b0d1df128d857f021f92ccf7c8bddd07812685fa07a25"
license "MIT"
depends_on "dos2unix" => :... |
require './concerns/findable.rb'
class Artist
extend Concerns::Findable
attr_accessor :name, :songs, :genres
@@all = []
def initialize(name)
@name = name
@songs = []
end
def self.all
@@all
end
def genres
self.songs.collect{|song| song.genre}.uniq
end
def self.destroy_all
all.clear
end
de... |
class Activity
attr_reader :name,
:participants
def initialize(name)
@name = name
@participants = Hash.new(0)
end
def add_participant(name, spent)
@participants[name] += spent
end
def total_cost
spent = participants.reduce(0) do |result, (participant, spent)|
result ... |
class Author < ApplicationRecord
validates :last_name, presence: true
def coordinates
[rand(50), rand(90)]
end
def publication_years
(1..rand(10)).to_a.map{1900+rand(100)}
end
end
|
class User < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :validatable
enum role: { student: 0, ta: 1 }
has_many :doubts
... |
class RenameFieldVFriend < ActiveRecord::Migration
def change
rename_column :v_friends, :current_volunteer_id, :volunteer_id
end
end
|
require 'spec_helper'
describe ContestRules do
before :all do
@before = ContestRules::CONTEST_OPENS - 1.day
@during = ContestRules::CONTEST_OPENS + 1.day
@after = ContestRules::CONTEST_CLOSES + 1.day
end
describe 'self.contest_open?' do
it 'is false before contest opens' do
expe... |
module ZanoxPublisher
# AdSpaces
#
# Access and modify your AdSpace information
#
# @attr [Integer] id The profileItem's identifer from Zanox
# @attr [String] name The name of your ad space
# @attr [String] url The url of your ad space
# @att... |
class DigitalprintsController < ApplicationController
before_action :confirm_logged_in
def new
if params[:account_id]
@account = Account.find_by(id: params[:account_id])
@digitalprint = @account.digitalprints.build
else
@digitalprint = Digitalprint.new
... |
module LessFactor
VERSION = "0.0.2"
HOMEPAGE_URL = "https://github.com/bwl21/lessfactor"
end
|
class CreateClients < ActiveRecord::Migration[5.2]
def change
create_table :clients do |t|
t.string :name
t.string :phone
t.timestamp :datestamp
t.string :barber
t.string :color
t.timestamps
end
end
end
|
Vagrant.configure('2') do |config|
config.vm.box = "bento/ubuntu-20.04"
config.vm.define "silverspoon"
config.vm.provider :virtualbox do |vb|
vb.customize ['modifyvm', :id,'--memory', '2048']
vb.name = "silverspoon"
end
config.vm.provision "shell" do |s|
s.inline = <<-SCRIPT
set -e
if [ -... |
class CaraokeBar
attr_reader :name, :till, :rooms
def initialize(name)
@name = name
@rooms = []
@till = 50 # Till starts with a £50 float each day
end
def count_rooms()
return @rooms.count
end
def add_room(room)
@rooms << (room)
end
de... |
class BooksController < ApplicationController
before_filter :require_login
# GET /books
# GET /books.xml
def index
@users = User.find(:all)
for user in @users
1.upto(Book::CATALOG) {|number| book = Book.new
book.user_id = user.id
book.order = number
if user.show?
... |
class AddIndex < ActiveRecord::Migration[5.2]
def change
add_index :relations, :follower_id
add_index :relations, :following_id
add_index :relations, [:follower_id, :following_id], unique: true
end
end
|
class CreateQuotationsCharacters < ActiveRecord::Migration[5.0]
def change
create_table :quotations_characters do |t|
t.belongs_to :character
t.belongs_to :quotation
t.timestamps
end
end
end
|
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :promo do
name "MyString"
description "MyText"
promo_from "2014-07-17 04:55:49"
promo_to "2014-07-17 04:55:49"
branch nil
end
end
|
class CreatePlayers < ActiveRecord::Migration
def change
create_table :players do |p|
p.string :initials, :uniqueness => true, :length => { :is => 3 }
end
end
end
|
class NotesController < ApplicationController
def new
@note = Note.new
end
def create
@note = Note.create(note_params)
@note.parent_id = current_parent.id
if @note.save
redirect_to sitters_path(@note.sitter_id)
else
redirect_to sitters_path(@note.sitter_id)
end
end
def d... |
# Require the dependencies file to load the vendor libraries
require File.expand_path(File.join(File.dirname(__FILE__), 'dependencies'))
class VmwareVsphereVirtualmachinePoweroffV1
# Include the necessary Java classes to be used for this handler
include_class java.net.URL
include_class com.vmware.vim25.mo.Folder... |
class CreateGifts < ActiveRecord::Migration
def change
create_table :gifts do |t|
t.references :item, index: true
t.integer :present_id, index: true
t.integer :quantity
t.integer :total
t.timestamps null: false
end
add_foreign_key :gifts, :items
end
end
|
class Placement < ApplicationRecord
validates :order_id, :user_id, presence: true
belongs_to :order
belongs_to :toy
end
|
class CreateDatTasks < ActiveRecord::Migration
def self.up
create_table :dat_tasks do |t|
t.integer "project_tree_id", :null => false
t.integer "priority_kbn", :default => 2, :null => false
t.float "plan_power", :default => 0.0, :null => false
t.flo... |
Rails.application.routes.draw do
resources :goals
post '/signin', to: 'users#signin'
get '/validate', to: 'users#validate'
# get '/users/:id/concerns', to: 'user_concerns#index'
get '/users/:id/concerns', to: 'users#concerns'
post '/users', to: 'users#signup'
get '/profile', to: 'users#show'
... |
# 8.3
# let us insert as many words in an array as we want (one word per line)
# end after nothing is inserted on an empty line (enter)
# sort inserted word alphabetically array.sort
puts "Give me a word: "
words = []
while true
word = gets.chomp
if word == '' # break if word.epmty?
break
end
words.pu... |
# frozen_string_literal: true
module Validators
module ChecklistsValidatorHelper
TICKET_NOT_PRESENT = I18n.t error.checklist.ticket.not_valid
TITLE_NOT_PRESENT = I18n.t error.checklist.title.not_valid
def validate_ticket_presence
list.errors[:base] << TICKET_NOT_PRESENT unless list.ticket
end
... |
# frozen_string_literal: true
require 'yaml'
# Load env vars if not yet loaded
APP_ENV = ENV.fetch("APP_ENV") do |el|
require 'dotenv'
env_file = ENV.key?('ENV') ? ".env.#{ENV['ENV']}" : ".env"
Dotenv.load(env_file)
ENV.fetch(el)
end
DB_CONFIG = YAML::load(
File.open('config/database.yml')
).fetch(APP_ENV)
... |
# 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... |
#
# fmw_rcu_repository
#
# Copyright 2015 Oracle. All Rights Reserved
#
Puppet::Type.type(:fmw_rcu_repository).provide(:posix) do
confine :kernel => ['Linux']
defaultfor :kernel => ['Linux']
def self.instances
[]
end
def install
user = resource[:os_user]
group ... |
class CreatePlanningConfirmationComments < ActiveRecord::Migration
def change
create_table :planning_confirmation_comments do |t|
t.references :planning_confirmation
t.text :comment
t.integer :user_id
t.integer :confirmation_type #0 - kgip, 1 - head
t.boolean :is_confirmation
t... |
class User < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
devise :database_authenticatable, :registerable, :confirmable, :trackable,
:recoverable, :rememberable, :validatable, :trackable #:omniauthable, :om... |
require 'test_helper'
class ProjectTest < ActiveSupport::TestCase
setup :activate_authlogic
setup :valid_project
def valid_project
@session = login_as users(:guy)
@person = Person.make :user => @session.user
@company = Company.make :person => @person
plan = Project.plan :company => @company
... |
[
{ file: 'ruby_questions.json', title: 'Ruby', color: '#ff0000' },
{ file: 'html_questions.json', title: 'HTML', color: '#00ff00' },
{ file: 'js_questions.json', title: 'JavaScript', color: '#0000ff' }
].each do |attributes|
category = Category.find_or_create_by! attributes.slice(:title, :color)
questions_h... |
require 'date'
require 'json'
class DayType
attr_accessor :characteristics
def initialize (chars = nil, origin = nil)
if chars.nil? then
@characteristics={}
unset_workday
unset_holiday
unset_work_at_home
unset_standby
else
@characteristics=chars
if origin == "json"
@characteristics['wo... |
class AddUserTypeToAchievements < ActiveRecord::Migration
def change
add_column :achievements, :user_type, :json, null: false
end
end
|
require 'rails_helper'
RSpec.describe ProjectStatus, type: :model do
before { ActsAsTenant.current_tenant = FactoryBot.create :user }
after { ActsAsTenant.current_tenant = nil }
it 'has a valid factory' do
expect(FactoryBot.create(:project_status)).to be_valid
end
it 'is invalid without a unique name' ... |
require 'sumac'
# make sure it exists
describe Sumac::Messages::Component::Map do
# should be a subclass of Base
example do
expect(Sumac::Messages::Component::Map < Sumac::Messages::Base).to be(true)
end
# ::from_object, #properties
example do
object = {'a' => 1, 2 => true}
component = Sumac::... |
class Movie < ActiveRecord::Base
belongs_to :genre
has_many :movie_users
has_many :users, through: :movie_users
end |
class CreateUses < ActiveRecord::Migration[5.2]
def change
create_table :uses do |t|
t.integer :quantity
t.string :measure
t.references :step, foreign_key: true
t.references :ingredient, foreign_key: true
t.index %i[step_id ingredient_id], unique: true
t.timestamps
end
e... |
def func(x)
if x > 0.0
Math.log(x) / Math.cos(x)**2 + x**3 - 5
else
'Invalid expression'
end
end
|
class Contributor
include Mongoid::Document
field :login, type: String
field :avatar_url, type: String
field :full_name, type: String
end |
class CreateAnimes < ActiveRecord::Migration[5.2]
def change
create_table :animes do |t|
t.string :ru_title
t.string :romaji_title
t.string :kanji_title
t.string :eng_title
t.text :description
t.string :type
t.integer :status
t.datetime :aired_from
t.datetime ... |
class FillerImage
IMAGES = [
{url: 'http://quotlr.com/images/quotes/4bb8b6be462911e39a1922000a9d0dee_8.jpg', caption: 'TRUST ME.'},
{url: 'http://www.trademarkia.com/logo-images/bg-wines-usa-llc/live-passionately-drink-responsibly-77001618.jpg', caption: 'Be safe.'},
{url: 'http://www.pomgen.gov.pg/wp-con... |
require 'spec_helper'
describe Feed do
describe 'validations' do
it 'is valid' do
expect(build(:twitter_feed)).to be_valid
end
it 'requires a uid' do
expect(build(:twitter_feed, uid: nil)).to be_invalid
end
it 'requires a type' do
expect(build(:twitter_feed, type: nil)).to ... |
class CreateBookings < ActiveRecord::Migration[5.2]
def change
create_table :bookings do |t|
t.datetime :start_time
t.datetime :end_time
t.date :booking_requested_date
t.date :booking_confirmed_date
t.date :booking_completed_date
t.date :booking_paid_out_date
t.integer... |
$memory = []
$pc = 0
$registers = Hash.new
$registers[:a] = 0
$registers[:b] = 0
class Instruction
attr_accessor :opcode
attr_accessor :register
attr_accessor :offset
def initialize(opcode, register: nil, offset: 0)
@opcode = opcode
@register = register
@offset = offset
end
def inspect
"#... |
class Currency < ApplicationRecord
belongs_to :user
validates :from, :to, presence: true
end
|
require 'rails_helper'
RSpec.describe ServerUser, type: :model do
subject { FactoryGirl.build :server_user}
describe 'validations' do
it { is_expected.to be_valid }
it { is_expected.to validate_presence_of(:name) }
it { is_expected.to validate_presence_of(:server) }
end
end
|
# frozen_string_literal: true
class PasswordResetSession < ApplicationRecord
HOURS_LIMIT = 2
attr_accessor :token
belongs_to :user
before_create :generate_token
def self.new_token
SecureRandom.hex(64)
end
def self.digest(string)
Digest::SHA256.hexdigest(string)
end
def available?
cr... |
module TeachersPet
class Cli
option :organization, required: true
option :repository, required: true
option :title, desc: "The title of the issue to be created"
option :body, banner: 'PATH', desc: "The path to the file containing the issue body (.txt or .md)"
option :labels, banner: 'LABEL1,LABEL... |
FactoryBot.define do
factory :category do
name 'Clothes'
end
factory :invalid_category, class: 'Category' do
name nil
end
factory :new_category, class: 'Category' do
name 'Toys'
end
end
|
class ServersController < ApplicationController
def show
@server = Server.new
end
end
|
class RemoveCommentsFromTicket < ActiveRecord::Migration
def change
remove_column :tickets, :comments, :string
end
end
|
require 'redis'
class Subscriber
def subscribe(channel)
Redis.current.subscribe(channel) do |on|
on.subscribe do |channel, _|
puts "subscribed to #{channel}"
end
on.message do |channel, message|
puts "#{channel} received #{message}"
end
end
end
end
|
module BtcExchangeInfo
class Bitoex < BaseClient
class << self
def btc(type)
response = download_ticker
return nil if response.nil?
response["#{type}"].to_f
end
def url
"https://www.bitoex.com"
end
private
def download_ticker
response ... |
class Location < ApplicationRecord
has_many :stories
has_many :users, through: :stories
end
|
class ListsController < ApplicationController
before_action :authenticate_user!
before_action :authorize_user
def new
@list = List.new
end
def create
@list = @user.lists.build(list_params)
if @list.save
flash[:notice] = "List added"
else
flash[:error] = "List creation fail... |
require "./Expiring.rb"
module StoreFront
class Groceries
include Expiring
attr_reader :type, :color, :price
attr_writer :price
def initialize(options)
@type = options[:type]
@color = options[:color]
@price = options[:price]
end
def info
puts "The #{type} is #{color} and costs #{price}."... |
# encoding: UTF-8
# Copyright 2012 Twitter, Inc
# http://www.apache.org/licenses/LICENSE-2.0
require 'set'
module TwitterCldr
module Shared
class PropertiesDatabase
include TwitterCldr::Utils
DEFAULT_ROOT_PATH = File.join(
TwitterCldr::RESOURCES_DIR, 'unicode_data', 'properties'
)
... |
# encoding: UTF-8
# Copyright 2012 Twitter, Inc
# http://www.apache.org/licenses/LICENSE-2.0
require 'spec_helper'
describe TwitterCldr::Shared::Hyphenator do
describe '.get' do
it 'retrieves the hyphenator for the given locale' do
hyphenator = described_class.get('en-US')
expect(hyphenator.locale)... |
# frozen_string_literal: true
module RuboCop
module Cop
module InSpecStyle
# @example EnforcedStyle: InSpecStyle (default)
# # windows_registry_key has been deprecated as a resource. Use registry_key instead
#
class WindowsRegistryKey < Cop
MSG = 'Use `registry_key` instead of `... |
require 'rails_helper'
RSpec.describe "requests/new", type: :view do
before(:each) do
assign(:request, FactoryGirl.build(:request))
end
it "should show workshop templates as a inspiration for the from below" do
render
expect(rendered).to have_text(I18n.t("requests.templates.headline"))
expect(re... |
require 'rails_helper'
feature "Sign in" do
scenario "can sign in with valid credentials" do
create :user, email: "user@example.com", password: "password"
sign_in_as "user@example.com", "password"
expect(page).to have_content "Signed in successfully"
end
end
|
class ChangeYearsInSubscription < ActiveRecord::Migration
def change
change_column :subscriptions, :sub_years, :integer, :default => 1
end
end
|
# encoding: utf-8
class SelecaoController < ApplicationController
def new_laudo
if !session[:voluntario].blank?
@visita = Visita.find_or_create_by_voluntario_id_and_numero(session[:voluntario], 1)
end
@laudo = @visita ? @visita.laudos.build : Laudo.new
params[:pagina] = request.fullpath
res... |
module ShopifyImport
module DataParsers
module LineItems
class BaseData
def initialize(shopify_line_item, shopify_order)
@shopify_line_item = shopify_line_item
@shopify_order = shopify_order
end
def line_item_attributes
{
quantity: @shopify_... |
module Locking
module PessimisticExtension
# Wraps the passed block in a transaction, locking the object
# before yielding. You can pass the SQL locking clause
# as argument (see <tt>lock!</tt>).
def with_lock(lock = true)
transaction do
lock!(lock)
yield
end
end
end
... |
class TweetsController < ApplicationController
before_action :authenticate_user!
before_action :get_tweet, only: [:show, :destroy]
def index
#@tweets = Tweet.where(user_id: current_user.id)
@tweets = Tweet.all
#@tweets = current_user.tweets
end
def show
end
def new... |
class AddFilePushToViews < ActiveRecord::Migration[7.0]
def change
add_column :views, :file_push_id, :integer, default: nil, index: true
end
end
|
# Strings
# use opposite versions of quotes
#'"Yesterday" has been covered >2,200 times'
# "I didn't know that!"
# careful with complicated sentences with multiple quotes
# use string interpolation
# worst_day = "Monday"
# "#{worst_day}s are the hardest."
# # => "Mondays are the hardest."
# MURDER = "redrum".reverse.... |
# encoding: UTF-8
require 'my-gem'
require 'spec_helper'
describe Test do
before :each do
@q1 = Test.new("Hola?", ["Si", "No", "Quizas", "Puede"], 3, 1)
@q2 = Test.new('¿Cual es la salida del siguiente codigo Ruby?' "\n" 'class Xyz' "\n"' def pots'" \n"' @nice'" \n"' end'" \n"' end '"\n\n"' xyz = Xyz.new... |
Rails.application.routes.draw do
resources :raids do
resources :attendances, only: [:create]
end
resources :users, only: [:new, :create]
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
get "/sign_up", to: "users#new", as: 'sign_up'
get "/login", to: ... |
class Link < ActiveRecord::Base
validates_presence_of(:url)
validates_presence_of(:name)
belongs_to :cluster
end
|
# ask user for 2 numbers
# ask for operation to perform
# perform the operation
# output the result
LANGUAGE = 'en'
require 'yaml'
MESSAGES = YAML.load_file('calculator_messages.yml')
def messages(message, lang='en')
MESSAGES[lang][message]
end
def prompt(key)
message = messages(key, LANGUAGE)
Kernel.puts("=... |
# frozen_string_literal: true
require './lib/sm/client_session'
FactoryBot.define do
factory :session, class: SM::ClientSession do
user_id 1234
token 'o7nsKRFVeijDG8u59/D6JOMrCmXMZO8p'
expires_at 'Thu, 26 Dec 2015 15:54:21 GMT'
trait :valid_user do
user_id '10616687'
token nil
exp... |
#--
# Cloud Foundry 2012.02.03 Beta
# Copyright (c) [2009-2012] VMware, Inc. All Rights Reserved.
#
# This product is licensed to you under the Apache License, Version 2.0 (the "License").
# You may not use this product except in compliance with the License.
#
# This product includes a number of subcomponents with
# se... |
# Write a method that rotates an array by moving the first element to the end of the array. The original array should not be modified.
# Do not use the method Array#rotate or Array#rotate! for your implementation.
def rotate_array(arr)
out_arr = []
index = 1
while index < arr.length
out_arr << arr[index]
... |
require 'spec_helper'
require 'app/models/config/base'
require 'app/models/config/go'
describe Config::Go do
describe '#content' do
it 'returns an empty string' do
hound_config = double('HoundConfig')
config = Config::Go.new(hound_config, 'go')
expect(config.content).to eq ''
end
end
end... |
module Api::V1
class TradesController < ApplicationController
before_action :authenticate_user ,only: :index
def index
trades = current_user.trades
render status: 200, json: {trades: trades}
end
end
end
|
require "yaml"
module Vanity
module SafeYAML
begin
YAML.safe_load("---", permitted_classes: [])
rescue ArgumentError
SUPPORTS_PERMITTED_CLASSES = false
else
SUPPORTS_PERMITTED_CLASSES = true
end
def self.load(payload)
if SUPPORTS_PERMITTED_CLASSES
YAML.safe_load(p... |
class FontAstloch < Formula
head "https://github.com/google/fonts.git", verified: "github.com/google/fonts", branch: "main", only_path: "ofl/astloch"
desc "Astloch"
homepage "https://fonts.google.com/specimen/Astloch"
def install
(share/"fonts").install "Astloch-Bold.ttf"
(share/"fonts").install "Astloc... |
class GroupUsersController < ApplicationController
def create
@group_user = GroupUser.new(group_user_params)
@group_user.save
redirect_to group_path(@group_user.group)
end
def destroy
@group_user = GroupUser.find(params[:id])
@group_user.destroy!
redirect_to group_path(@group_user.group)... |
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = 'fakes'
s.version = '1.1.6'
s.platform = Gem::Platform::RUBY
s.authors = ['Develop With Passion®']
s.email = ['open_source@developwithpassion.com']
s.homepage = 'http://www.developwithpassion.com'
s.summary = %... |
class FlowersController < ApplicationController
before_action :find_flower, only: [:show, :edit, :update, :destroy]
def index
@flowers = Flower.all
end
def show
end
def new
@flower = Flower.new
end
def create
@flower = Flower.new flower_params
if @flower.save
redirect_to flower... |
require 'spec_helper'
## パッケージ集
describe package('git') do
it { should be_installed }
end
describe package('nodejs') do
it { should be_installed }
end
describe package('gcc') do
it { should be_installed }
end
describe package('gcc-c++') do
it { should be_installed }
end
describe package('openssl') do
it { sh... |
module SmartLogParser
class LineByLineReader
def initialize(log_file)
@log_file = log_file
end
def read_lines
unless File.exists?(@log_file)
raise SmartLogParserException.new "File #{@log_file} does not exist."
end
File.foreach(@log_file) do |line|
yield line.spli... |
class AddCharacteristicsToSeeds < ActiveRecord::Migration
def change
add_column :seeds, :common_name, :string
add_column :seeds, :scientific_name, :string
add_column :seeds, :production_year, :integer
add_column :seeds, :location, :string
end
end
|
require 'spec_helper'
describe Honeybadger::Api::Comment do
describe "initializing a new comment" do
before :all do
@comment = FactoryGirl.build :comment
end
it "should have a identifier" do
@comment.id.should == 1
end
it "should have a fault identifier" do
@comment.fault_id... |
class CreateProdcutos < ActiveRecord::Migration
def change
create_table :prodcutos do |t|
t.string :codigo
t.string :nombre
t.date :fecha_vencimiento
t.integer :cantidad
t.timestamps null: false
end
end
end
|
module DisplayImpl
def raw_open
raise NotImplementedError.new("#{self.class}##{__method__}が実装されていません。")
end
def raw_print
raise NotImplementedError.new("#{self.class}##{__method__}が実装されていません。")
end
def raw_close
raise NotImplementedError.new("#{self.class}##{__method__}が実装されていません。")
end
end
|
class ProducersController < ApplicationController
before_action :authenticate_user!
def index
respond_with Producer.all
end
def create
respond_with Producer.create(post_params)
end
def show
respond_with Producer.find(params[:id])
end
end
|
class ObserverMailer < ApplicationMailer
def observer_added_notification(observation, reason)
@proposal = observation.proposal.decorate
@observation = observation
@reason = reason
@recipient = observation.user
add_proposal_attributes_icons(@proposal)
add_inline_attachment("icon-page-circle.png... |
require_relative "piece"
require_relative "stepable"
require_relative "../board"
class King < Piece
include Stepable
def symbol
if color == :b
"♚"
else
"♔"
end
end
protected
def move_diffs
[ [1, 1], [1, 0], [1, -1], [0, -1], [-1, -1], [-1, 0], [-1, 1], [0, 1] ]
end
end
if __F... |
##
# base class for exporters of contact information
module Graybook::Exporter
class Base
##
# Override this to convert +contacts+ (an array of hashes) to something more useful. Here, it
# just returns Graybook's internal format
def export( contacts )
contacts
end
Graybook.registe... |
require 'hand.rb'
describe Hand do
let(:high_straight_flush) do
Hand.new([Card.new(:ace, :spades), Card.new(:king, :spades),
Card.new(:queen, :spades), Card.new(:jack, :spades),
Card.new(:ten, :spades)])
end
let(:low_straight_flush) do
Hand.new([Card.new(:seven, :spades), Card.new(:six, :sp... |
class CreateBillInfos < ActiveRecord::Migration[5.0]
def change
create_table :bill_infos do |t|
t.text :remark
t.integer :dvi
t.integer :sluong
t.float :tpayment
t.float :discount
t.float :tpayout
t.references :order_map, foreign_key: true
t.timestamps
end
en... |
require_relative 'parser/filter'
require_relative 'parser/location'
require_relative 'parser/operation'
require_relative 'parser/property_type'
# frozen_string_literal: true
# Obtains location, operation_type, property_type and filters for a PI URL
class UrlAnalyzer
def self.run(url)
return {} unless url
ret... |
require 'rails_helper'
describe AuthenticateUser do
let!(:user) { create :user }
context '#call' do
context 'with valid credentials' do
it "should success" do
expect(AuthenticateUser.call(user.email, user.password)).to be_success
end
it "should regentate user token" do
expec... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.