text stringlengths 10 2.61M |
|---|
class FontTradeWinds < Formula
head "https://github.com/google/fonts/raw/main/ofl/tradewinds/TradeWinds-Regular.ttf", verified: "github.com/google/fonts/"
desc "Trade Winds"
homepage "https://fonts.google.com/specimen/Trade+Winds"
def install
(share/"fonts").install "TradeWinds-Regular.ttf"
end
test do
... |
class Customer < User
belongs_to :manager
has_one :profile, class_name: CustomerProfile
accepts_nested_attributes_for :profile, update_only: true
attr_accessible :profile, :profile_attributes
extend Enumerize
delegate :company_name, :dba, :first_name, :company_address, to: :profile, allow_nil: true
ha... |
# Account Balance, Debugging, Ruby Basics, Exercises
# Financially, you started the year with a clean slate.
balance = 0
# Here's what you earned and spent during the first three months.
january = {
income: [ 1200, 75 ],
expenses: [ 650, 140, 33.2, 100, 26.9, 78 ]
}
february = {
income: [ 1200 ],
expenses:... |
apt_package 'fontconfig'
directory '/usr/share/fonts' do
owner 'root'
group 'root'
mode '0755'
action :create
end
execute "download font" do
command 'wget https://s3.amazonaws.com/oliver-dev/fonts/zawgyi.ttf'
user "root"
cwd '/usr/share/fonts/'
not_if { ::File.exists?('/usr/share/fonts/zawgyi.ttf') }
... |
class AddColumnsToProjectStatusMaster < ActiveRecord::Migration
def change
add_column :project_status_masters, :active, :integer
add_column :project_status_masters, :user_id, :integer
end
end
|
class Speaker < ActiveRecord::Base
SPEAKER_GENDERS = [:male, :female]
LEARNING_METHODS = [:acad, :nat]
enum gender: SPEAKER_GENDERS
enum learning_method: LEARNING_METHODS
belongs_to :city
belongs_to :state
belongs_to :country
belongs_to :native_language
belongs_to :english_country_residence
validat... |
class CreateReports < ActiveRecord::Migration[5.0]
def change
create_table :reports do |t|
t.integer :generate_by
t.datetime :begin_dt
t.datetime :end_dt
t.boolean :unit
t.boolean :state
t.boolean :kind
t.boolean :onu
t.boolean :blend
t.boolean :code
t.b... |
class Subforum < ActiveRecord::Base
belongs_to :forum
has_many :posts, :dependent => :destroy
delegate :forumname, :to => :forum, :prefix => false
def most_recent_post
Post.where('subforum_id = ?', self.id).last
end
def self.find_by_name(forumname)
Subforum.where('forumname = ?', forumname)
end... |
require 'omf_base/lobject'
require 'rack'
require 'omf-web/session_store'
require 'omf-web/widget'
require 'omf-web/theme'
OMF::Web::Theme.require 'widget_page'
module OMF::Web::Rack
class WidgetMapper < OMF::Base::LObject
def initialize(opts = {})
@opts = opts
@tabs = {}
end
def call(en... |
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe Message, type: :model do
let(:user) { create(:user) }
let(:room) { create(:room) }
let(:message) { create(:message, user: user, room: room) }
it 'message ใไฝๆใงใใ' do
expect(message).to be_valid
end
it 'room ใใชใใจไฝๆใงใใชใ' do
message... |
#
# @author Kristian Mandrup
#
# Single role base storage (common, reusable functionality)
#
module Trole::Storage
class BaseOne < Troles::Common::Storage
# constructor
# @param [Symbol] the role subject
def initialize role_subject
super
end
# get Role instance by name
# @p... |
require 'rails_helper'
class Mutations::CreateUserTest < ActiveSupport::TestCase
describe 'GraphQL User mutations' do
def perform_superuser(venue: nil, **args)
Mutations::CreateVenue.new(object: nil, context: {current_user:{role: 3}}).resolve(args)
end
def perform_other_user(venue: nil, **args)
... |
class QuasiStatsController < ApplicationController
before_action :set_quasi_stat, only: [:show, :edit, :update, :destroy]
# GET /quasi_stats
# GET /quasi_stats.json
def index
@quasi_stats = QuasiStat.all
end
# GET /quasi_stats/1
# GET /quasi_stats/1.json
def show
end
# GET /quasi_stats/new
... |
# frozen_string_literal: true
module Complicode
module Generators
class Base64Data
BASE64 = %w[
0 1 2 3 4 5 6 7 8 9 A B C D E F G H I J K L M N O P Q R S T U V
W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z + /
].freeze
# @param ascii_sums [Struct]
# @param p... |
Truestack::Application.routes.draw do
resources :subscriptions
match "/director" => "director#index"
constraints(:subdomain => 'director') do
match "/" => "director#index"
end
devise_for :users, path_names: { sign_in: 'login', sign_out: 'logout' }
get "about" => "static#about"
get "mongo" => "stat... |
class Ember::VisualisationsController < ApplicationController
before_action :authenticate
skip_before_filter :verify_authenticity_token
include CrudActionsMixin
self.responder = ApplicationResponder
respond_to :json
def namespace
'Ember::'
end
def show
@item = Visualisation.find(params[:id])... |
class Goal < ApplicationRecord
enum kind: [:general, :penalty, :autogoal]
belongs_to :player
belongs_to :match
belongs_to :team
end
|
class AddColumnNumRhymesToTweet < ActiveRecord::Migration
def change
add_column :tweets, :num_rhymes, :integer
add_index :tweets, :num_rhymes
add_index :tweets, :num_syllables
end
end
|
class CreateTasksTable < ActiveRecord::Migration
def change
create_table :tasks do |t|
t.string :name
t.string :exc_path
t.datetime :start_datetime
t.datetime :end_datetime
t.text :exc_days # serialized by rails to array
t.string :server_key
# add timestamps
t.timestamps
... |
require 'yajl'
require 'sinatra/base'
require 'sinatra/respond_with'
require 'sinatra/redis'
require 'readers/filesystem'
require 'readers/redis'
require 'helpers/input_parser'
require 'helpers/graph'
module StatsdServer
class Dash < Sinatra::Base
configure do
set :haml, :format => :html5
helpers S... |
class Article < ApplicationRecord
belongs_to :period, inverse_of: :articles
has_many :comments, dependent: :destroy
validates :title, presence: true,
length: { minimum: 5 }
validates :text, presence: true,
length: {minimum: 10 }
end
|
require 'logger'
require 'optparse'
module Bowler
class CLI
def self.start(args)
options = {
without: []
}
OptionParser.new {|opts|
opts.banner = "Usage: bowl [options] <process>..."
opts.on('-w', '--without <process>', 'Exclude a process from being launched') do |proc... |
class Medication < ActiveRecord::Base
self.table_name = 'medication_orders'
validates_presence_of :admission, :order_frequency, :name, :dosage, :necessity
belongs_to :order_frequency
belongs_to :admission
enum route: {'PO' => 0, 'IM' => 1, 'SC' => 2}
enum unit: {mg: 0}
end |
class TallyLedger < ActiveRecord::Base
has_many :finance_transaction_categories
belongs_to :tally_company
belongs_to :tally_voucher_type
belongs_to :tally_account
delegate :company_name, :to => :tally_company
delegate :voucher_name, :to => :tally_voucher_type
delegate :account_name, :to => :tally_account... |
$:.push File.expand_path("../lib", __FILE__)
# Maintain your gem's version:
require "translation_center/version"
# Describe your gem and declare its dependencies:
Gem::Specification.new do |s|
s.name = "translation_center"
s.version = TranslationCenter::VERSION
s.authors = ["BadrIT", "Mahmoud Kha... |
class Assign < ActiveRecord::Base
default_scope { where(is_delete: 0) }
end
|
require 'belafonte/errors'
module Belafonte
class Argument
module ARGVProcessor
class Processor
attr_reader :occurrences, :arguments
def initialize(occurrences, arguments)
@occurrences, @arguments = occurrences, arguments
end
def processed
validate_argu... |
# Copyright (c) 2015 Lamont Granquist
# Copyright (c) 2015 Chef Software, Inc.
#
# 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... |
#!/usr/bin/env ruby
# OpsWorks provisioner for Vagrant
# --------------------------------
# Copyright (c) 2016 PixelCog Inc.
# Licensed under MIT (see LICENSE)
require 'date'
require 'json'
require 'tmpdir'
require 'fileutils'
module OpsWorks
class OpsWorksError < StandardError; end
DNA_BASE = {
"ssh_users... |
# Write a method that returns true if its integer argument is palindromic, false otherwise. A palindromic number reads the same forwards and backwards.
def palindromic_number?(number)
number.to_s == number.to_s.reverse
end
palindromic_number?(34543) == true
palindromic_number?(123210) == false
palindromic_number?(2... |
class PhotosController < ApplicationController
before_action :authenticate_usermodel!
def create
@stay = Stay.find(params[:stay_id])
@stay.photos.create(photo_params)
redirect_to stay_path(@stay)
end
private
def photo_params
params.require(:photo).permit(:caption, :picture, :usermodel_id)
end
end
|
require "rails_helper"
require "helpers/tournament_helper"
describe "tournament test" do
include TournamentHelper
it "์ต์์ธ์๋ณด๋ค ๋ฏธ๋ฌ์ผ ๋ ํ ๋๋จผํธ ์์ ์คํจ" do
users_count = 7
create_tournament({ register: users_count })
expect_all_memberships_count users_count
start_tournament
expect_status "canceled"
... |
class OrderedKeyVal
attr_accessor :keys, :values
def initialize
@keys = []
@values = []
end
def max
@keys[-1]
end
def min
@keys[0]
end
def delete_min
@keys.shift
@values.shift
end
def ceiling(key)
i = insertion_index(key)
if i == @keys.length
return nil
else
... |
module OrientdbBinary
module BaseProtocol
class RecordCreate < BinData::Record
include OrientdbBinary::BaseProtocol::Base
endian :big
int8 :operation, value: OrientdbBinary::OperationTypes::REQUEST_RECORD_CREATE
int32 :session
int32 :datasegment_id
int16 :cluster_id
p... |
# Write a method that takes a positive integer as an argument and returns that number with its digits reversed.
# Don't worry about arguments with leading zeros - Ruby sees those as octal numbers, which will cause confusing results. For similar reasons, the return value for our fourth example doesn't have any leading ... |
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Ch... |
require 'sumac'
# make sure it exists
describe Sumac::Messages::CallRequest do
# should be a subclass of Message
example do
expect(Sumac::Messages::CallRequest < Sumac::Messages::Message).to be(true)
end
# ::build, #properties, #to_json
example do
object = instance_double('Sumac::Objects::Referenc... |
module GameOfLife
class Board
attr_reader :grid
def initialize(rows, columns, state = nil)
@rows = rows
@columns = columns
@grid = Array.new(rows) { Array.new(columns, StateMachine::DEAD) }
if state
initialize_state(state)
... |
# An EXAMPLE Basic Model for Assets that conform to Hydra commonMetadata cModel and have basic MODS metadata (currently "Article" is the MODS exemplar)
class ModsAsset < ActiveFedora::Base
extend Deprecation
def initialize(*)
Deprecation.warn(ModsAsset, "ModsAsset is deprecated and will be removed in hydra-h... |
# frozen_string_literal: true
class User
module Register
def register
@event = Event.find_by(id: clean_params[:id])
return if no_member_registrations? || no_registrations?
register_for_event!
if @registration.valid?
successfully_registered
else
unable_to_register
... |
class Spot < ApplicationRecord
validates :name, presence:true, length:{ in: 1..32 }, uniqueness: { scope: :address }
validates :address, presence: true, uniqueness: true, length:{ maximum: 140 }, uniqueness: { scope: :name }
validates :spot_time, length:{ maximum: 10 }
validates :price, length:{ maximum: 99999 ... |
require 'rails_helper'
feature "Sign in" do
scenario "Article displays on show" do
Article.create!(
headline: "Test article",
body: "Test",
image: nil,
date_field: "2015-12-31",
category: "testcategory",
source: "testsource"
)
visit root_path
fill_in "search articles", wit... |
module Nitron
module Data
class Relation < NSFetchRequest
module CoreData
def inspect
to_a
end
def to_a
error_ptr = Pointer.new(:object)
context.executeFetchRequest(self, error:error_ptr)
end
private
def conte... |
class ChangeTemplatesToPolymorphic < ActiveRecord::Migration
def up
change_table :templates do |t|
t.references :templable, :polymorphic => true
end
remove_column :templates, :subject_id
end
def down
change_table :templates do |t|
t.remove_references :templable, :polymorphic => true
... |
class UsersController < ApplicationController
before_action :authenticate_user!, only: [:index, :following, :followers]
before_action :currect_user, only: [:edit, :update]
before_action :admin_user, only: :destroy
def index
@users = User.paginate(page: params[:page], :per_page => 10)
end
def show
... |
# frozen_string_literal: true
require 'date'
module Jiji::Utils
class TimeSource
KEY = :jiji_time_source__now
def now
Thread.current[KEY] || Time.now
end
def set(time)
Thread.current[KEY] = time || Time.now
end
def reset
Thread.current[KEY] = nil
end
end
end
|
Spree::Admin::TaxonsController.class_eval do
def update
Spree::Taxon::LANG.each do |locale|
I18n.locale = locale
@taxonomy = Spree::Taxonomy.find(params[:taxonomy_id])
@taxon = @taxonomy.taxons.find(params[:id])
parent_id = params[:taxon][:parent_id]
new_position = params[:taxon][:p... |
require 'spec_helper'
describe Susanoo::PageView do
let!(:top_genre) { create(:top_genre) }
describe "#initialize" do
context "pathใ'/'ใฎๅ ดๅ" do
let(:path) { '/' }
context "ๅ
ฌ้ใใผใธใ็กใๅ ดๅ" do
before do
@page_view = Susanoo::PageView.new(path)
end
it "@dirใซๆญฃใใๅคใ่จญๅฎใใฆใใใ... |
# encoding: utf-8
class User < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
has_many :readings
has_one :twine... |
class Function < ActiveRecord::Base
#ไปฅไธไธบๅปบ็ซๅ่ฝ็น->่ง่ฒ->็จๆท็ๅค้ m:n ๅ
ณ่ๅ
ณ็ณป
has_many :role_functions
has_many :roles , through: :role_functions, inverse_of: :functions
has_many :role_users, through: :roles
has_many :users , through: :role_users
default_scope {order(:controller, :action)}
end
|
Rails.application.routes.draw do
root 'questions#index'
devise_for :users
resources :questions
resources :answers, only: [:new, :create, :index, :show, :update]
end
|
class UsersController < ApplicationController
before_action :set_user, only: [:show, :edit, :update, :destroy]
before_action :require_login, except: [:new, :create]
before_action :require_correct_user, only: [:show, :edit, :update, :destroy]
def index
if current_user
redirect_to "/users/#{current_user... |
#!/usr/bin/env ruby -S rspec
require 'spec_helper'
require 'semantic_puppet'
require 'puppet/pops/lookup/context'
require 'yaml'
require 'fileutils'
puppetver = SemanticPuppet::Version.parse(Puppet.version)
requiredver = SemanticPuppet::Version.parse("4.10.0")
describe 'lookup' do
# Generate a fake module with dum... |
class CreateTrips < ActiveRecord::Migration
def change
create_table :trips do |t|
t.string :title
t.text :description
t.float :start_latitude
t.float :start_longitude
t.float :end_latitude
t.float :end_longitude
t.timestamp :start_time
t.timestamp :end_time
t.... |
require 'spec_helper'
describe Elaios, integration: true do
before(:each) do
@port = random_port
end
around(:each) do |example|
Timeout::timeout(5) do
example.run
end
end
it 'works when used with a threaded server' do
done = false
requests = []
responses = []
# TCP server... |
class Hadupils::RunnersTest < Test::Unit::TestCase
include Hadupils::Extensions::Runners
context Hadupils::Runners::Base do
setup do
@runner = Hadupils::Runners::Base.new(@params = mock())
end
should 'expose initialization params as attr' do
assert_equal @params, @runner.params
end
... |
class Passport < ActiveRecord::Base
belongs_to :company
validates :title, :company, presence: true
has_attached_file :file
#validates_attachment_presence :file
validates_attachment_size :file, less_than: 2.megabytes
validates_attachment :file, content_type: { content_type: "application/pdf" }
end
|
class Comment < ApplicationRecord
belongs_to :user
belongs_to :gossip
validates :content, presence:true
end
|
module Susanoo
module Assets
class HelpAttachmentFile < Base
attr_accessor :help_content_id
has_attached_file :data,
url: ':help_content_data/:basename.:extension',
path: ':rails_root/files/help/:rails_env/:help_content_id/:basename.:extension'
Paperclip.interpolates :help_... |
class DropEmployeeMachinesTable < ActiveRecord::Migration
def change
drop_table :employee_machines
end
end
|
class Santa
attr_reader :ethnicity
attr_accessor :gender, :age
def initialize(gender, ethnicity)
p "Initializing Santa instance ..."
@gender = gender
@ethnicity = ethnicity
@reindeer_ranking = reindeer_ranking
end
def speak
puts "Ho, ho, ho! Haaaappy holidays!"
end
def eat_milk_and_cookies(cookie_t... |
class AddAddressIdToDamage < ActiveRecord::Migration[5.2]
def change
add_column :damages, :address_id, :integer
end
end
|
require 'test/unit'
module Given
def self.assertion_failed_exception
Test::Unit::AssertionFailedError
end
module TestUnit
module Adapter
def given_failure(message, code=nil)
if code
message = "\n#{code.file_line} #{message}\n"
end
raise Test::Unit::AssertionFailed... |
require "rake"
require "pathname"
desc "Install the dotfiles"
task :default do
FileLinker.link_files
puts "\n xoxo\n"
end
class FileLinker
DOTFILES_PATH = Pathname.new(Dir.pwd)
LINK_PATH = DOTFILES_PATH.join("link")
HOME_PATH = Pathname.new(ENV["HOME"])
attr_reader :source_path
def initialize(source... |
require 'nokogiri'
require 'open-uri'
class Parser
private
def parse(arg = nil)
Nokogiri::HTML(URI.open(@url)) if arg.nil?
rescue OpenURI::HTTPError => e
raise e unless e.message == 'Error 404 Not Found'
end
end
|
class Ship
attr_accessor :name, :type, :booty
@@ships = []
def initialize(attributes)
attributes.each do |k, v|
send("#{k}=", v)
end
self.class.all << self
end
def self.all
@@ships
end
def self.clear
all.clear
end
end |
class ClientsController < ApplicationController
include TenantScopedController
load_and_authorize_resource
before_action :set_model
def upload_staff
@upload_model = ClientStaffList.new
end
def do_upload_staff
d = SimpleXlsxReader.open(params['user']['file'].open)
hash = d.to_hash
columns... |
require 'spec_helper'
describe Url do
describe ".scrape_matches" do
it "returns the page title" do
report = Report.create(:name => "Test Report", :useragent => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.117 Safari/537.36")
url = Url.create(:report... |
require 'rubygems/package'
require 'zlib'
require 'json'
require 'nokogiri'
require 'distro-package.rb'
module PackageUpdater
class Updater
def self.friendly_name
name.gsub(/^PackageUpdater::/,"").gsub("::","_").downcase.to_sym
end
def self.log
Log
end
def self.http_agent
... |
require 'watirspec_helper'
describe WatirCss do
before do
browser.goto(WatirSpec.url_for("non_control_elements.html"))
end
it "returns true if the element exists" do
xpath_class = Watir::Locators::Element::SelectorBuilder::XPath
expect_any_instance_of(xpath_class).to_not receive(:build)
expect(... |
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :invoice_detail do
invoice nil
employee nil
service_item nil
new_price "9.99"
discount_type "MyString"
discount_value "9.99"
end
end
|
Gem::Specification.new do |s|
s.name = 'rake_routes_raw'
s.version = '0.0.1'
s.platform = Gem::Platform::RUBY
s.summary = "Provides rake_routes_raw.rake task for use in rails project.
rake routes:raw command appends a commented/formatted list of all of apps routes to the config/routes file.
It also prov... |
require 'rails_helper'
context 'logged out' do
it 'should take us to a sign up page' do
visit '/restaurants'
click_link 'Add a restaurant'
expect(page).to have_content 'Sign up'
end
end
context 'logged in' do
before do
nikesh = User.create(email: 'n@n.com', password: '12345678', password_confirmation: '... |
class PlayersController < ApplicationController
before_action :set_tournament
before_action :set_admin, only: [:edit, :update, :destroy]
before_action :authenticate_user!, only: [:new, :create, :edit, :update, :destroy]
def index
@players = @tournament.players.all
end
def show
@player = Player.fin... |
class Hash
# Dig a value of hash, by a series of keys
#
# info = {
# order: {
# customer: {
# name: "Tom",
# email: "tom@mail.com"
# },
# total: 100
# }
# }
#
# puts info.dig :order, :customer
# # => {name: "T... |
require 'test_helper'
class PlayAgentsSearchTest < ActiveSupport::TestCase
test "Search agent query empty" do
user = users(:admin)
s = PlayAgentsSearch.new(user)
assert_equal "", s.options[:query]
assert_equal user.id, s.options[:user_id]
end
test "Search agent by name" do
user = users(:ad... |
# -*- coding: utf-8 -*-
=begin
Faรงa um programa que carregue uma lista com os modelos de cinco carros
(exemplo de modelos: FUSCA, GOL, VECTRA etc). Carregue uma outra lista
com o consumo desses carros, isto รฉ, quantos quilรดmetros cada um desses carros
faz com um litro de combustรญvel. Calcule e mostre:
a. O modelo do ... |
class AddLatitudeAndLongitudeToCrime< ActiveRecord::Migration
def change
add_column :crimes, :latitude, :float
add_column :crimes, :longitude, :float
end
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... |
class AddOneTimeFeeToService < ActiveRecord::Migration
def change
add_column :services, :one_time_fee, :boolean
end
end
|
class StaticPagesController < ApplicationController
def index
@header = true
@nowrap = true
end
def show
render template: "static_pages/#{params[:page]}"
end
end
|
require "rails_helper"
describe "Cart Items" do
it "can't have a negative quantity" do
cart_item = CartItem.new(1, -5)
expect(cart_item.quantity).to be >= 0
end
end
|
# Numbers to Commas Solo Challenge
# I spent 2.5 hours on this challenge.
# Complete each step below according to the challenge directions and
# include it in this file. Also make sure everything that isn't code
# is commented in the file.
# 0. Pseudocode
# What is the input?
# A positive integer
# What is the outp... |
class IncomingWebhooksController < ApplicationController
skip_before_action :authenticate
before_action :set_integration
before_action :set_app
before_action :set_user
def invoke
case params[:command]
when 'update_app_configs'
update_configs('App', @app.id, params[:configs].permit!.to_h)
wh... |
# represent skill
class SkillLancer
include Mongoid::Document
include Mongoid::Timestamps
store_in database: 'sribulancer_development', collection: 'skills'
include Elasticsearch::Model
field :name
validates :name, presence: true, :uniqueness => {:scope => :online_group_category_id}
validates :online_g... |
RSpec.describe Hash do
# subject { {} } = let(:subject) { {} }
# Whatever returns from the block becomes the subject
subject(:subject_hash) do
{a: 1, b: 2}
end
it 'has 2 keyvalue pairs' do
expect(subject.length).to eq(2)
expect(subject_hash.length).to eq(2)
end
context 'nested' do
subjec... |
class Asteroids::BulletComponent
include Gamey::Component
attr_accessor :timer
def initialize
@timer = Gamey::Timer.new
end
end |
require 'rspec/core/formatters/progress_formatter'
require 'redis'
require 'json'
module RSpecPubsub
class Formatter < RSpec::Core::Formatters::ProgressFormatter
attr_reader :channel
def initialize(output)
super
@channel = Channel.new
end
def start(example_count)
super
publi... |
require 'rubygems'
require 'sinatra'
require 'pry'
set :sessions, true
BLACKJACK_AMOUNT = 21
DEALER_MIN_HIT = 17
INITIAL_BET_AMOUNT = 500
helpers do
def get_total(hand)
total = 0
arr = hand.map{|element| element[1]}
arr.each do |value|
if value == 'ace'
total < 11 ? total += 11 : total +=... |
FactoryGirl.define do
factory :location do |f|
library_system_id LibrarySystem::MINUTEMAN.id
sequence(:name) {|n| "location #{n}"}
end
end
|
require 'rails'
module SimpleCalendar
class Calendar
delegate :capture, :concat, :content_tag, :link_to, :params, :raw, :safe_join, to: :view_context
attr_reader :block, :events, :options, :view_context, :timezone
def initialize(view_context, opts={})
@view_context = view_context
@events ... |
Rails.application.routes.draw do
resources :cards
root 'cards#index'
end
|
require 'rspec'
require_relative '../lib/ruby_js_html_wrapper/html_document'
require_relative '../lib/ruby_js_html_wrapper/bar_chart'
describe 'Bar Chart' do
let(:file) do
File.join('barcharttest.html')
end
let(:barchart) do
arr = [ {:name=> 'Rcompute', :data => [360] } , {:name => 'CPPcompute', :dat... |
#!/usr/bin/ruby
require 'json'
require 'lib/homologenie/species_gene'
module HomoloGenie
class SpeciesPair
# TODO initialize MUST be SpeciesGene object???
#parameters must be SpeciesGene object????
attr_reader :score
#attr_reader :pair
def initialize(species_a, species_b... |
class EvalNginxModule < Formula
desc "Evaluate memcached/proxy response into vars"
homepage "https://github.com/vkholodkov/nginx-eval-module"
url "https://github.com/vkholodkov/nginx-eval-module/archive/1.0.3.tar.gz"
sha256 "849381433a9020ee1162fa6211b047369fde38dc1a8b5de79f03f8fff2407fe2"
bottle :unneeded
... |
# Be sure to restart your server when you modify this file.
#
# Points are a simple integer value which are given to "meritable" resources
# according to rules in +app/models/merit/point_rules.rb+. They are given on
# actions-triggered, either to the action user or to the method (or array of
# methods) defined in the +... |
require 'sumac'
# make sure it exists
describe Sumac::Messenger do
def build_messenger
connection = instance_double('Sumac::Connection')
messenger = Sumac::Messenger.new(connection)
end
# ::new
example do
connection = instance_double('Sumac::Connection')
messenger = Sumac::Messenger.new(conne... |
class VenuesController < ApplicationController
respond_to :js, :json, :html
def index
respond_with(@venues = Venue.includes(:options).all)
end
def show
@venue = Venue.includes(:options).find(params[:id])
build_option
respond_with(@venue)
end
alias :edit :show
def create
respond_with... |
# encoding: UTF-8
require 'helper'
class TestTranslation < Test::Unit::TestCase
def test_any_i18n_chronic_errors_message_with_interpolation
key = "a key"
string = I18n.t(:not_valid_key, key: key, scope: 'chronic.errors')
assert_equal string, "a key is not a valid option key."
end
def test_a_i18n_ch... |
module Types
class AreaType < LocationType
field :path, String, null: false, method: :map_path
field :url, String, null: false, method: :map_url
field :radius, Float, null: false
field :region, Types::RegionType, null: false
field :country, Types::CountryType, null: false
field :events,... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.