text stringlengths 10 2.61M |
|---|
#!/usr/bin/env ruby
#
# Copyright (c) 2014, 2015, 2016 Matt Behrens.
# Copyright (c) 2018 Alexander Regueiro.
#
# 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
... |
# Problem 96: Su Doku
# http://projecteuler.net/problem=96
# Su Doku (Japanese meaning number place) is the name given to a popular puzzle concept. Its origin is unclear, but credit must be attributed to Leonhard Euler who invented a similar, and much more difficult, puzzle idea called Latin Squares. The objective of ... |
require 'shorturl'
module Twitterscrobble
class StatusLine
TWITTER_MAX_MSG_LEN = 140
def initialize(track)
@track = track
end
# TODO
# The algorithm to use the maximum number of characters is not the best yet.
# We should also try to cut down single fie... |
class SessionsController < ApplicationController
def create
@user = User.find_by(username: params[:userDetails][:username])
if @user && @user.authenticate(params[:userDetails][:password])
render json: @user, status: 200
else
render json: {message: "Unable to login with that username and passw... |
=begin
You will need to have separate methods for each of the following use cases:
Create a new list:
- Create hash
Create a method add_items:
- input: item, quantity
- key: item - string, value: quantity - integer
- update hash created above with key value pair
- output: updated hash with item & quantit... |
# This file was generated by GoReleaser. DO NOT EDIT.
class Kamino < Formula
desc "Development database content bootstraper"
homepage ""
version "1.5.0"
bottle :unneeded
if OS.mac?
url "https://github.com/marema31/kamino/releases/download/v1.5.0/kamino_1.5.0_Darwin_x86_64.tar.gz"
sha256 "589d2df6a5e0... |
class BadCode
attr_reader :id
def initialize(id); @id = id end
def hello(); puts "hi" end
end
|
FactoryGirl.define do
factory :project do
user
name {"#{ Faker::Company.name } - #{ Faker::Company.bs }"}
state "draft"
settings {}
trait :published do
total_duration_in_ms { 88900 }
after(:create) do |object|
upload = object.uploads.create(filename:"filename",s3_url:"https://... |
class RemoveColumnsFromDrinks < ActiveRecord::Migration
def change
remove_column :drinks, :created_at, :timestamp
remove_column :drinks, :updated_at, :timestamp
remove_column :drinks, :image_url, :string
end
end
|
module ApplicationHelper
def data_source(klass)
klass.pluck(:id, :name).map do |row|
{ value: row.first.to_s, text: row.last }
end.to_json
end
end
|
class Comment
include Mongoid::Document
include Mongoid::Timestamps
field :body
embedded_in :commentable, polymorphic: true
embeds_many :comments, as: :commentable
belongs_to :user, index: true
validates_presence_of :body
scope :with_user, -> { includes(:user) }
def comment_on(commentable: nil, u... |
class Achievement < ApplicationRecord
has_many :progressions
has_many :users, through: :progressions
end
|
require 'spec_helper'
require 'easy/reference_data/refresh'
RSpec.describe Easy::ReferenceData do
describe ".update_or_create" do
context "with a single unique attribute" do
context "and an existing record" do
it "does not change the record" do
user = User.create(system_code: 1)
... |
namespace :ccss do
desc 'Load CCSS standards'
task :load => :environment do
CcssTasks.load
end
end
|
class FontCica < Formula
version "5.0.3"
sha256 "cbd1bcf1f3fd1ddbffe444369c76e42529add8538b25aeb75ab682d398b0506f"
url "https://github.com/miiton/Cica/releases/download/v#{version}/Cica_v#{version}.zip"
desc "Cica"
homepage "https://github.com/miiton/Cica"
def install
(share/"fonts").install "Cica-Bold.... |
class Teller
attr_reader :name
attr_accessor :no_transactions
def initialize(name,minutes)
@name = name
@minutes = minutes
@no_transactions = 0
end
def calculate_time
@minutes*@no_transactions
end
def to_s
"Teller #{@name} completed #{no_transactions} transactions in #{calculate_ti... |
require 'pry'
require 'watir'
require "json"
# le townhalls_adders_to_db permet de recuperer tous les twitter handles des villes listees dans le json townhalls_contact
# methode qui etait le json des villes dans un hash
class Adder
def extract_json
@contacts = {}
json = File.read('db/townhalls_con... |
# frozen_string_literal: true
Then('I should see {string}') do |content|
expect(page).to have_content content
end
Then('I should not see {string}') do |content|
expect(page).not_to have_content content
end
Then('I should be on the admin page') do
expect(page).to have_current_path(admin_root_path)
end
Then("I ... |
class AccessController < ApplicationController
before_action :check_login, except: [:logout]
layout 'login'
def login
end
def attempt_login
if params[:password].present? and params[:email].present?
found_user = AdminUser.where(email: params[:email]).first
if found_user
authorized... |
require_relative '../excel'
class AstExpandArrayFormulae
def map(ast)
return ast unless ast.is_a?(Array)
operator = ast[0]
if respond_to?(operator)
send(operator,*ast[1..-1])
else
[operator,*ast[1..-1].map {|a| map(a) }]
end
end
def arithmetic(left,operator,right)
left =... |
class WorkoutSet < ActiveRecord::Base
attr_accessible :grip, :reps, :exercise_id, :weight, :weight_type, :workout_id
belongs_to :workout
validates :workout_id, presence: true
end
|
require 'starfish/base_app'
require 'starfish/channel_app'
require 'starfish/pipeline_app'
require 'starfish/build_app'
module Starfish
class ProjectApp < BaseApp
get '/' do
@project = @projects.first
redirect @project ? project_path(@project) : setup_path
end
namespace '/:project' do
... |
require 'rails_helper'
RSpec.describe IdentityOrganizations do
describe '#fulfillment_organizations_with_protocols' do
context "Identity is super user at provider level" do
context "Identity is clinical_provider at institution level" do
it "should return organizations for super_users and clinical_... |
# -*- coding: utf-8 -*-
require 'test_helper'
class DirectorCell < Cell::Rails
attr_reader :count
def initialize(*)
super
@count = 0
end
cache :tock
def tock
@count += 1
render :text => @count
end
cache :utf8
def utf8
render :text => "æøå" # or any other UTF-8 string
end
end
c... |
class CreateLikeOp < Backend::Op
field :content_id,
:content_type
validates :content_id,
:content_type, presence: true
attr_reader :content
protected
def perform
like = build_like
like.save!
@content = like.content
true
end
def build_like
Like.new.tap do... |
class User < ActiveRecord::Base
EMAIL_REGEXP = /\A[a-zA-Z0-9\.\-\_]+@gmail.com\z/
validates :email, email: true, format: {with: EMAIL_REGEXP}
end
|
# 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 rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel... |
# Members and Lords
class Person
LORD_REMOVALS = %w{lord baroness earl}
REMOVALS = %w{mrs mr ms sir}
attr_accessor :name
def initialize(name)
@name = name
# True if person is a lord rather than an MP
@lord = LORD_REMOVALS.include? @name.split.first.downcase
# TWFY API doesn't work if Lord or Mr... |
require 'test_helper'
class TbpostsControllerTest < ActionDispatch::IntegrationTest
def setup
@tbpost = tbposts(:orange)
end
test "should redirect create when not logged in" do
assert_no_difference 'Tbpost.count' do
post tbposts_path, params: { tbpost: { content: "Lorem ipsum" } }
end
ass... |
require "test_helper"
require "loyalty_connect"
module LoyaltyConnect
module Model
describe CreateUserResult do
it "succeeds if no errors" do
json = { 'consumer' => { 'url' => "someplace" } }
result = CreateUserResult.from_json_hash(json)
result.success?.must_equal true
end
... |
require_relative 'aliasing'
require_relative 'helpers/bootstrap'
module BootstrapForm
class FormBuilder < ActionView::Helpers::FormBuilder
extend BootstrapForm::Aliasing
include BootstrapForm::Helpers::Bootstrap
attr_reader :layout, :label_col, :control_col, :has_error, :inline_errors, :label_errors, :a... |
class EditJobs < ActiveRecord::Migration[6.0]
def change
remove_column :jobs, :steps, :string
remove_column :jobs, :source, :string
add_column :jobs, :company, :string
add_column :jobs, :responsibilities, :string
end
end
|
class CreatesProject
attr_accessor :name, :project
def initialize(name:"")
@name=name
end
def build
self.project=Project.new(name: name)
end
end |
def print_usage
program_name = File.basename($0, File.extname($0))
puts <<-ENDMSG
#{program_name} <options> <token>
options:
--dry-run (Prints the files in their updated state instead of writing them)
usage:
#{program_name} --dry-run abcdefg
ENDMSG
end
dry_run = ARGV[0] == '--dry-run'
ARGV.shift if dry... |
# frozen_string_literal: true
require 'rails_helper'
require 'claims_api/special_issue_mapper'
describe ClaimsApi::SpecialIssueMapper do
it 'returns correct code for name' do
expect(ClaimsApi::SpecialIssueMapper.new.code_from_name('Character of Discharge')).to eq('CD')
end
it 'returns correct name for code... |
module Puppet::Parser::Functions
newfunction(:array_search, :type => :rvalue, :doc => "Search the array and returns the index.") do |arguments|
raise(Puppet::ParseError, "array_search(): Wrong number of arguments") if arguments.size != 2
raise(Puppet::ParseError, "array_search(): Not an array") if !argume... |
require 'rails_helper'
RSpec.describe 'Authorization DSL' do
let(:described_class) do |example|
Class.new(ApplicationController) do
include Authegy::Authorization::Helpers
end
end
it 'responds to .authorize_access_for' do
expect(described_class).to respond_to :authorize_access_for
end
... |
require 'spec_helper'
RSpec.describe ShopifyImport::Creators::ProductCreator, type: :service do
subject { described_class.new(product_data_feed) }
before { authenticate_with_shopify }
describe '#save!' do
context 'with base product data feed', vcr: { cassette_name: 'shopify/base_product' } do
let(:sh... |
require_relative './constants.rb'
require 'json'
require 'fileutils'
class FileHandler
def initialize(hash, file_name)
@hash = hash
@file_name = file_name
end
def teams_to_json
dir_maker(TEAM_DIR)
File.write("#{TEAM_DIR}#{@file_name}.json", JSON.pretty_generate(@hash))
end
def players_to_jso... |
#!/usr/bin/env ruby
# encoding: UTF-8
#
require './error'
class Piece
attr_accessor :player, :board, :is_king
SLIDE_DELTAS = [ [[ 1, 1], [ 1, -1]], # Moving down
[[-1, 1], [-1, -1]] ] # Moving up
def initialize(player, board)
@is_king = false
@player = player
@board = board
end
... |
class Category < ApplicationRecord
has_many :products
validates(:name, { presence: { message: 'must be provided' },
uniqueness: true
})
end
|
class AnswerSerializer < ActiveModel::Serializer
include ActionView::Helpers::DateHelper
attributes :id, :response, :accepted, :cached_votes_up, :cached_votes_down, :cached_votes_score, :created_at, :votes_for, :user, :comments
def created_at
time_ago_in_words(object.created_at)
end
end
|
require 'java'
java_import 'java.util.concurrent.Semaphore'
def rand_sleep
sleep(rand(10) / 1000.0)
end
class Semaphore
def signal(n = 1)
release(n)
end
def wait
acquire
end
end
|
require_relative 'day09'
describe 'decompressed_length' do
it "returns decompressed length" do
input = "ADVENT"
expect(decompressed_length input).to eq 6
end
it "returns decompressed length" do
input = "A(1x5)BC"
expect(decompressed_length input).to eq 7
end
it "returns decompressed length"... |
class CalendarAdv < ActiveRecord::Base
validate :logo_presence
validate :end_date_validate
upload_column :logo, :versions=>{:thumb280=>"c640x280"}
named_scope :normal,:conditions=>"status = 'online'",:order=>'status desc, position, id desc'
has_one :pk
after_save :upload_to_aliyun
default_value_for :manually,... |
class Source < ActiveRecord::Base
has_many :evidences
after_create :get_wot
require 'open_uri_redirections'
require 'httparty'
@@base_trust = 70
# Use web of trust (wot) api to get trust and confidence scores for domain
def get_wot
response = HTTParty.get("http://api.mywot.com/0.4/public_link_json... |
class RemoveWorkoutDateFromWorkoutDetail < ActiveRecord::Migration[5.2]
def change
remove_column :workout_details, :workout_date
end
end
|
require './test/test_helper'
require './lib/decryptor'
class DecryptorTest < Minitest::Test
def setup
@decryptor = Decryptor.new
end
def test_it_exists
assert_instance_of Decryptor, @decryptor
end
def test_initialize
assert_equal 180919, @decryptor.current_date
end
def test_character_set
... |
class ChangePictureColumnName < ActiveRecord::Migration[6.0]
def change
rename_column :hikes, :picture_id, :pictures
end
end
|
class MenuBarFilter < Cask
url 'https://github.com/downloads/wez/MenuBarFilter/MenuBarFilter_1.2.2.zip'
homepage 'http://wez.github.com/MenuBarFilter/'
version '1.2.2'
sha1 'aecadf43bdba901e254012cc21e746f39f244bd8'
end
|
require 'test_helper'
require 'telApp'
class TelAppTest < Test::Unit::TestCase
def test_supprimer_supprime_un_contact_affiche_nouvelle_liste
contact = Contact.new("moussa","balla","123456998")
TelApp.supprimer()
assert_equal(TelApp.supprimer().nom,contact.nom)
end
def test_modifier_modifie_un_con... |
require 'rails_helper'
describe RuleDefinition do
describe 'name attribute' do
it 'is required' do
expect(RuleDefinition).to require_presence_of :name
end
end
describe 'definition_data attribute' do
it 'is required' do
expect(RuleDefinition).to require_presence_of :definition_data
en... |
class CreateGenres < ActiveRecord::Migration[5.2]
def change
create_table :genres, &:timestamps
reversible do |dir|
dir.up do
Genre.create_translation_table! title: :string
end
dir.down do
Genre.drop_translation_table!
end
end
end
end
|
# == Schema Information
#
# Table name: trips
#
# id :integer not null, primary key
# guest_id :integer not null
# lair_id :integer not null
# check_in_date :date not null
# check_out_date :date not null
# num_guests :integer ... |
# U2.W6: Testing Assert Statements
# I worked on this challenge [by myself].
# 2. Review the simple assert statement
=begin
def assert
puts "Processing..."
raise "Assertion failed!" unless yield
puts "True!"
end
name = "bettysue"
assert { name == "bettysue" }
assert { name == "billybob" }
=end
# 2. Pseudo... |
require "pry"
class Player
attr_accessor :name, :life_points #10points pour tout le M
# @@all_users = []
def initialize(name)
@name = name
@life_points = 10
# @@all_users << self
end
def show_state
puts "#{self.name} a #{self.life_points} points de vie"
end
def gets_damage(damage_received)
@life_... |
class Admins::VariablesController < Admins::BaseController
before_action :set_parents
rescue_from ActiveRecord::RecordInvalid, with: :raise_validates_errors
def show
end
def new
@promotions = Promotion.find(:all, from: :active, params: query_params)
render :new, layout: false
end
def new_pro... |
class MessageGroup < ApplicationRecord
belongs_to :inbox
has_many :messages
validates :subject, presence: true
end
|
class RetiredsController < ApplicationController
before_action :set_retired, only: [:show, :edit, :update, :destroy]
# GET /retireds
# GET /retireds.json
def index
@retireds = Retired.all
end
# GET /retireds/1
# GET /retireds/1.json
def show
end
# GET /retireds/new
def new
@retired = Re... |
class ExpandForeignKeys < ActiveRecord::Migration[5.0]
def change
change_column :shipping_addresses, :order_id, :integer, limit: 8
change_column :line_items, :order_id, :integer, limit: 8
end
end
|
class Task < ActiveRecord::Base
belongs_to :project
has_many :logs, dependent: :destroy
default_scope {order(:done, :created_at=> :desc)}
validates :name, presence: {message: 'Please provide a name'}
validates_presence_of :project
def work?
!longs.empty? && !logs.first.stop
end
def logged
... |
module OrganizationCustomerServiceWorkflowHelper
#为机构员工的社保和公积金服务提供工作流相关的公共功能集
extend ActiveSupport::Concern
include PagerHelper
included do
#使用状态机管理机构员工客户服务状态
workflow do
state :new do #新建
event :finish_apply_start, :transitions_to => :serving
end
state :serving do #服务中
... |
# frozen_string_literal: true
FactoryBot.define do
factory :dish do
name { 'ハンバーグ' }
genre_id { 2 }
ready_id { 2 }
price { Faker::Number.between(from: 100, to: 999_999) }
association :chef
after(:build) do |dish|
dish.image.attach(io: Fil... |
require 'rails_helper'
RSpec.describe LocationsController, type: :controller do
describe "GET #index" do
it "returns http success" do
get :index
expect(response).to have_http_status(302)
end
end
describe "GET #show" do
it "renders the show template with correct id" do
location = L... |
class PromotionsParser
def initialize promotions
@promotions = promotions
end
def value_rules
parse_json[:value_rules]
end
def volume_rules
parse_json[:volume_rules]
end
private
def parse_json
JSON.parse @promotions, symbolize_names: true
end
end |
module DomainRouting
class Config
class << self
attr_accessor :act_as_ssl
def main_domains
@main_domains || []
end
def invalid_subdomains
@invalid_subdomains || []
end
def main_domains=(*values)
@main_domains = values.flatten.map(&:downcase)
end... |
class GithubImporter
attr_accessor :backfill_for
def initialize
@backfill_for = 1.day
end
def run!
import_commits
end
private
def github
Github.new(oauth_token: Thread.current[:github_token])
end
def all_repos
repos = github.repos.list org: ENV['DEFAULT_GITHUB_ORG'], auto_paginat... |
require 'pry'
require 'colorize'
class ProductHunt
def initialize
@products = {"Test1" => 5, "Test2" =>4}
@comments = {"Test1" => {"My comment1 abc" => "Person1", "My comment1 xyz" => "Person2"},
"Test2" => {"My comment2 AAA" => "Person1"}
}
@users = {
"P... |
class FFProbe
class StreamInfo < Entity
attr_accessor :codec_name, :decoder_time_base, :codec_type,
:r_frame_rate, :r_frame_rate_num, :r_frame_rate_den,
:width, :height, :gop_size, :has_b_frames, :sample_aspect_ratio,
:display_aspect_ratio, :pix_fmt, :ind... |
require 'rack/mock'
require_relative '../../spec_helper'
require './lib/sinatra/auth'
def author
(@@author = Sinatra::Auth::Author.new)
end
describe Sinatra::Auth::Author, "#new_token_id" do
it "should generate a new token id" do
s = author.new_token_id
s.should_not == author.new_token_id
end
end
descr... |
class StatusLancer
# Job / Service
REJECTED = 'rejected'
REQUESTED = 'requested'
APPROVED = 'approved'
CLOSED = 'closed'
DELETED = 'deleted'
NO_HIRED = 'no_hired'
HIRED = 'hired'
DRAFT = 'draft'
# Payout Method
SUBMITTED = 'submitted'
VALIDATED = 'validated'
FAVOURITED = 'favourited'
ELIM... |
# As a Maker
# So that I can avoid others posting messages on Chitter as me
# I want to log out of Chitter
feature 'User logs out' do
scenario 'successfully and sees a goodbye message' do
sign_up
log_in
click_button('Log out')
expect(page).to have_content('Goodbye!')
end
end
|
#
# Author:: Jörgen Brandt <joergen.brandt@onlinehome.de>
# Cookbook:: chef-cuneiform
# Recipe:: cuneiform
#
# Copyright:: 2015-2018 Jörgen Brandt
#
# 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 ... |
=begin
#===============================================================================
** Effect: Recoil Damage
Author: Hime
Date: Sep 12, 2013
--------------------------------------------------------------------------------
** Change log
Sep 12, 2013
- added element type for recoil damage
Aug 28, 2013
- a... |
class ApplicationMailer < ActionMailer::Base
default from: "contact@pwintogram.com"
layout 'mailer'
end
|
require 'rails_helper'
describe Recipe, focus: true do
it "has a valid factory in recipes" do
expect(build(:recipe)).to be_valid
end
let(:recipe) { build(:recipe) }
describe "ActiveModel validations" do
it { should validate_presence_of(:title) }
it { should validate_length_of(:title).is_at... |
json.array!(@custom_fields) do |custom_field|
json.extract! custom_field, :id, :field, :field_type, :usr_id
json.url custom_field_url(custom_field, format: :json)
end
|
require_relative "boot"
require "rails"
require "action_controller/railtie"
require "action_view/railtie"
require "graphql/client/railtie"
require "graphql/client/http"
Bundler.require(*Rails.groups)
module RadioFranceScan
class Application < Rails::Application; end
radio_france_url = 'https://openapi.radiofranc... |
class DealsController < ApplicationController
def index
@deals = Deal.all
render json: @deals
end
def create
Deal.create(deal_params)
end
private
def deal_params
params.require(:deal).permit(:image, :description)
end
end
|
require 'test_helper'
class UsersControllerTest < ActionController::TestCase
setup do
@user = users(:dragon)
setup_json_api
end
test "new" do
get :new
assert_response :success
assert assigns(:user)
end
test "create" do
assert_difference('User.count') do
post :create,
... |
VOWELS = ["a", "e", "i", "o", "u"]
class Word
def initialize(original_word)
@original_word = original_word
end
def piglatinize
VOWELS.each do |vowel|
if vowel == @original_word.chars[0]
return @original_word + "way"
end
end
VOWELS.each do |vowel|
if vowel == @original_word.chars[1]... |
class Api::V1::MessagesController < ApplicationController
def index
messages = Message.all
render json: MessageSerializer.new(messages).serialized_json
end
def create
message = Message.create(message_params)
ticket = Ticket.find(message_params[:ticket_id])
options = {
... |
# This is a Chefspec test. It doesn't require spinning up Test Kitchen.
# This makes it a lot faster and more suitable to unit tests.
# See https://github.com/sethvargo/chefspec
require_relative '../spec_helper'
describe_recipe 'demo::default' do
cached(:chef_run) { ChefSpec::SoloRunner.converge(described_recipe) }... |
class Client < ActiveRecord::Base
has_many :projects
validates_presence_of :name, :mobile, :email, :website
validates_length_of :mobile, is:10
validates_format_of :email, :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i
end
|
class RemoveVisibilityColumnsFromPosts < ActiveRecord::Migration
def change
remove_column :posts, :visibility_type
remove_column :posts, :visibility_id
end
end
|
class AddAuthTokenToChambers < ActiveRecord::Migration[5.0]
def change
add_column :chambers, :token, :string
add_index :chambers, :token, unique: true
end
end
|
include_recipe "gcc"
include_recipe "git"
include_recipe "icu4c"
include_recipe "memcached"
include_recipe "mysql"
include_recipe "node"
include_recipe "phantomjs"
include_recipe "pow"
include_recipe "python"
include_recipe "qt"
include_recipe "rbenv"
include_recipe "redis"
# Only define directory resource once
begin
... |
# frozen_string_literal: true
class TemporaryManager < ApplicationRecord
belongs_to :user
belongs_to :event
validates :user, uniqueness: {
scope: :event_id,
message: lambda do |object, _data|
"#{object.user_identifier} is already a temporary manager"
end
}
validate :validates_external_bran... |
require 'test_helper'
class ReminderTest < ActiveSupport::TestCase
setup do
@reminder = reminders(:tylenol)
end
test "sendable?" do
assert @reminder.sendable?
end
test "not sendable if just delivered" do
@reminder.last_delivered_at = 1.minute.ago
assert_equal false, @reminder.sendable?
... |
class NewOffer < ActiveRecord::Base
validates_presence_of :name
##defining constants
ACTIVE="ACTIVE"
INACTIVE="INACTIVE"
DELAY="DELAY"
belongs_to :account
scope :active, -> { where("status == ?", NewOffer::ACTIVE) }
scope :inactive, -> { where("status == ?", NewOffer::INACTIVE) }
scope :delay, -> { where("... |
require 'test_helper'
class HatchetRunnerTest < Test::Unit::TestCase
def setup
@default = ENV['HATCHET_DEPLOY_STRATEGY']
end
def teardown
ENV['HATCHET_DEPLOY_STRATEGY'] = @default
Hatchet.set_deploy_strategy!
end
def test_defaults
assert_equal nil, ENV['HATCHET_DEPLOY_STRATEGY']
assert... |
class AnimalMonster
PERKS = {
attack: 1
}
@instance = new
private_class_method :new
def self.instance
@instance
end
def status(attributes)
return attributes
end
def apply_perks(attributes)
PERKS.each do |perk, v|
attributes[perk] += v
end
end
def name
return 'Ani... |
class TentHouse
def initialize
@items = {
1 => { :name => 'Plastic Chairs' , :quantity=>10000 , :booked=>0 } ,
2 => { :name => 'Tiffany Chairs' , :quantity=>5000 , :booked=>0 } ,
3 => { :name => 'Bridal Chair' , :quantity=>10 , :booked=>0 } ,
... |
class ProfileController < UICollectionViewController
attr_accessor :person
SELFIE_CELL_ID = "SelfieCell"
def self.new(args = {})
# Set layout
# layout = UICollectionViewFlowLayout.alloc.init
layout = SelfieLayout.alloc.init
s = self.alloc.initWithCollectionViewLayout(layout)
s.person = args[:... |
require 'rails_helper'
RSpec.describe "the dish show page" do
it "I see list of ingredients and chef name" do
bobby = Chef.create(name: "Bobby Flay")
cat = Chef.create(name: "Cat Cora")
tots = bobby.dishes.create(name:"Chili Lime Tots", description: "Spicy and delish")
hot_pocket = bobby.dishes.crea... |
require 'spec_helper'
describe Providers::Ovirt::OvirtProvider do
it "indicates invalid credentials" do
with_provider 'test_ovirt' do |provider|
credentials = {:username => "admin", :password => "password"}
provider.valid_credentials?(credentials).should be_false
end
end
end
|
require 'thor' unless defined?(Thor)
module XMLPipes #:nodoc:
class Cli < Thor
include Thor::Actions
def initialize(*args, &block)
super; apply_configuration
end
class_option :quiet , :type => :boolean , :aliases => '-q', :desc => 'run command quietly.'
class_option :environment ... |
class QuestionFollower
def self.find_by_id(id)
q_follower_hash = $db.execute(<<-SQL, :q_follower_id => id).first
SELECT
question_followers.*
FROM
question_followers
WHERE
question_followers.id = :q_follower_id
SQL
QuestionFollower.new(q_follower_hash)
end
de... |
class CreateAuctions < ActiveRecord::Migration[5.1]
def change
create_table :auctions do |t|
t.string :name_of_event
t.string :organization
t.text :image_data
t.string :date
t.string :start_time
t.string :duration
t.string :description
t.timestamps
end
end
en... |
#require 'gravtastic'
class User < ActiveRecord::Base
# include Gravtastic
# is_gravtastic!
#acts_as_taggable #this is for user tag browsing
validate :check_beta_code, :on => 'create'
has_and_belongs_to_many :roles
has_many :comments
has_many :received_messages, :class_name => 'Message', :foreign_key =>... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.