text stringlengths 10 2.61M |
|---|
require 'ansi/progressbar'
module StormFury::CLI
class ProgressReport
attr_reader :bar, :server
def self.run(server)
progress_report = new(server)
progress_report.run
end
def initialize(server)
@bar = ANSI::Progressbar.new(server.name, 100)
@server = server
end
d... |
#!/usr/bin/env ruby
# has to be fed in reverse order, from least to most
# 37396 is a magic number, if you spot it, the number of lines in the dump
require 'pry'
CUTOFF=3
def nuke(msg, idx, term)
STDERR.print ARGF.filename, ': ', msg, ': ', idx, '; ', "#{term}\n"
end
STOPWORDS=['edition', 'book', 'chapter', 'ade... |
# 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... |
require 'spotify_web/resource'
require 'spotify_web/album'
require 'spotify_web/artist'
require 'spotify_web/schema/bartender.pb'
require 'spotify_web/schema/metadata.pb'
module SpotifyWeb
# Represents a song on Spotify
class Song < Resource
self.metadata_schema = Schema::Metadata::Track
self.resource_name... |
#encoding: utf-8
class User < ActiveRecord::Base
belongs_to :person
has_secure_password
attr_accessible :password, :username, :password_confirmation, :person, :person_id
validates :username, :presence => true, :uniqueness => true
validates :utype, :presence => true,
:numericality => { :only... |
class BoatingTest
attr_reader :student, :instructor, :test_name
attr_accessor :status
@@all = []
###### Instance methods ######
#Works!
def initialize(student, instructor, test_name, status)
@student = student
@instructor = instructor
@test_name = test_name
@sta... |
# Define a method meal_choice that returns the meal_choice that was
# passed into it and defaults to meat.
def meal_choice(meal=nil)
if meal
"#{meal}"
else
"meat"
end
end |
json.array!(@documentos) do |documento|
json.extract! documento, :id, :tipo_documento, :fecha_ingreso, :observacion, :estudiante_id
json.url documento_url(documento, format: :json)
end
|
class DepositionsController < ApplicationController
def index
end
def new
session[:deposition_params] ||= {}
@deposition = Deposition.new
end
def create
session[:deposition_params].deep_merge!(deposition_params)
@deposition = Deposition.new(session[:deposition_params])
@deposition.curren... |
class AddFaviconUrlAndDescriptionToBookmark < ActiveRecord::Migration
def self.up
add_column :bookmarks, :favicon_url, :string
add_column :bookmarks, :description, :text
end
def self.down
remove_column :bookmarks, :description
remove_column :bookmarks, :favicon_url
end
end |
# == Schema Information
#
# Table name: release_order_results
#
# id :integer not null, primary key
# release_order_id :integer indexed, indexed => [env_id, application_id]
# env_id :integer indexed, indexed => [release_order_id, app... |
class WorkExperienceLookedHistory < ApplicationRecord
belongs_to :user
belongs_to :work_experience
scope :created_at_paging, -> { order(created_at: :desc) }
end
|
module HttpFetcher
class << self
def fetch(url)
response = HTTParty.get(url)
unless response.code == 200
raise Exceptions::HttpException.new("Requested resource returned HTTP status: #{response.code}", response.code)
end
response
rescue SocketError => e
raise Exceptions::... |
module XMLNBI
require 'net/http'
require 'open-uri'
require 'nokogiri'
class XmlSessionError < StandardError; end
class InvalidSessionId < XmlSessionError; end
class InvalidParameter < XmlSessionError; end
class InvalidXMLRequest < XmlSessionError; end
class XMLServer
@@port = "18080"
@@xml4lo... |
require "rails_helper"
RSpec.describe EmailAuthentication, type: :model do
let(:weak_password_error) { "Please choose a stronger password with at least 8 characters. Try a mix of letters, numbers, and symbols." }
describe "Associations" do
it { should have_one(:user_authentication) }
it { should have_one(... |
module Sudoku::Solver
class SudokuGrid
attr_reader :matrix
def initialize(matrix)
@matrix = matrix
end
def set_value_at(value, index_y, index_x)
@matrix[index_y][index_x] = value
end
def dup
dup = []
(0...9).each do |y|
(0...9).each do |x|
dup[y] ||... |
# encoding: UTF-8
class Film
class Statistiques
def nombre_personnages
@nombre_personnages ||= personnages.count
end
# Retourne un Array de personnages en fonction de
# leur présence, du plus présent au moins présent.
def personnages_par_temps_presence
@personnages_par_temps_presence ||= begin
... |
require 'test_helper'
describe 'PlayerLoader' do
describe '#load' do
it 'will generate identifier if none is passed' do
PlayerLoader.new(first_name: 'Bob', last_name: 'Ross', birth_year: 1942, identifier: nil).load
Player.count.must_equal 1
player = Player.first
player.identifier.must_equ... |
module Types
class ProviderType < Types::BaseEnum
value "heroku"
end
end
|
class Setlist < ActiveRecord::Base
belongs_to :gig
belongs_to :song
end
|
class AlbumImage < ActiveRecord::Base
attr_accessible :album_id, :image, :caption, :cover
validates :image_file_name, :presence => true
belongs_to :album
has_attached_file :image, :url => "/assets/album_images/:id/:style/:basename.:extension",
:path => ":rails_root/public/assets/album_images/:id/:style/:basen... |
module KMP3D
class GOBJ < GroupType
def initialize
@name = "Objects"
@external_settings = [
Settings.new(:text, :obj, "Object ID", "itembox"),
Settings.new(:path, :path, "Object Path", Data.load_obj("itembox"))
]
@settings = [
Settings.new(:text, :uint16, "Ref ID", ... |
module Forms
class Builder < ActionView::Helpers::FormBuilder
delegate :content_tag, to: :@template
def error_for(method, options = {})
return '' if @object.nil? || @object.errors[method].blank?
field_errors = @object.errors[method].join(', ')
field_errors = field_errors.humanize if field_e... |
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
include SessionsHelper
private
def require_user_logged_in
unless logged_in?
redirect_to homepages_url
end
end
def counts(user)
@count_reviews = user.reviews.count
@count_contents = user... |
# Assumptions:
# This method assumes the input array is comprised of elements of the same data type, which are already sorted
# Restrictions:
# This method cannot use any fancy built-in Ruby array methods, only 'Array#[]' and 'Array#length'
def binary_search(array, target, midpoint_index = array.length / 2)
ret... |
class AddCompanySettings < ActiveRecord::Migration
def self.up
add_column :companies, :show_wiki, :boolean, :default => true
add_column :companies, :show_forum, :boolean, :default => true
add_column :companies, :show_chat, :boolean, :default => true
end
def self.down
remove_column :companies, :sh... |
require 'test_helper'
class Buyers::ApplicationsTest < ActionDispatch::IntegrationTest
class MasterLoggedInTest < Buyers::ApplicationsTest
setup do
login! master_account
FactoryBot.create(:cinstance, service: master_account.default_service)
end
attr_reader :service
test 'index retrieves... |
module Mautic
# Represent received web hook
class WebHook
attr_reader :connection
# @param [Mautic::Connection] connection
# @param [ActionController::Parameters] params
def initialize(connection, params)
@connection = connection
@params = params
end
def form_submissions
@... |
class ProductsController < ApplicationController
before_action :require_login, only: [:new, :create, :edit, :update]
before_action :require_product_ownership, only: [:edit, :update]
def index
@products = Product.where(status: "Available")
@products_by_merchant = Product.by_merchant(params[:merchant... |
require "test_helper"
class WeekendTest < ActiveSupport::TestCase
def test_fixture_is_valid
assert FactoryBot.create(:weekend).valid?
end
def test_validations
weekend = FactoryBot.build(:weekend)
assert(weekend.valid?)
weekend = FactoryBot.build(:weekend, body: nil)
refute(weekend.valid?)
... |
module Ecology
module Test
def set_up_ecology(file_contents, filename = "some.ecology", options = {})
match = filename.match(/^(.*)\.erb$/)
if match
ENV["ECOLOGY_SPEC"] = match[1]
File.stubs(:exist?).with(match[1]).returns(false)
else
ENV["ECOLOGY_SPEC"] = filename
... |
class Order < ActiveRecord::Base
alias_attribute :parent_id, :state
mount_uploader :details_file, FileUploader
enum state: [:new_one, :handled]
has_many :order_items, -> { ordered }, dependent: :destroy
validates :name, :phone, :email, presence: true, if: -> x { x.real? }
def sum
order_items
... |
Rails.application.routes.draw do
devise_for :admin_users, ActiveAdmin::Devise.config
ActiveAdmin.routes(self)
root :to => "routes#index"
# Routes for the City resource:
# CREATE
get "/cities/new", :controller => "cities", :action => "new"
post "/create_city", :controller => "cities", :action => "create"
... |
# frozen_string_literal: true
RSpec.feature "Single Item Pagination", type: :system, clean: true, js: true do
before do
stub_request(:get, 'https://yul-dc-development-samples.s3.amazonaws.com/manifests/11/11/111.json')
.to_return(status: 200, body: File.open(File.join('spec', 'fixtures', '2041002.json')).re... |
RSpec.feature "Users can view an activity" do
context "when the user belongs to BEIS" do
let(:user) { create(:beis_user) }
before { authenticate!(user: user) }
after { logout }
context "and the activity is a fund" do
scenario "the child programme activities can be viewed" do
fund = cr... |
class Favorite < ActiveRecord::Base
belongs_to :user
belongs_to :hitorigochi
validates :user, presence: true
validates :user_id, uniqueness: { scope: :hitorigochi_id }
validates :hitorigochi, presence: true
end
|
class Agenda < ActiveRecord::Base
has_many :items, :class_name => "Item",
:foreign_key => "id_item";
has_many :users, :class_name => "User",
:foreign_key => "id_user";
end |
class Block < ApplicationRecord
belongs_to :floor
has_many :parking_slots, dependent: :destroy
accepts_nested_attributes_for :parking_slots, allow_destroy: true, reject_if: :all_blank
before_save :build_parking_slots
attr_accessor :slots
private
def build_parking_slots
if self.slots.present? && sel... |
require 'vanagon/engine/always_be_scheduling'
require 'vanagon/driver'
require 'vanagon/platform'
require 'logger'
require 'spec_helper'
class Vanagon
class Driver
@@logger = Logger.new('/dev/null')
end
end
describe 'Vanagon::Engine::AlwaysBeScheduling' do
let (:platform) {
plat = Vanagon::Platform::DSL... |
require 'spec_helper'
describe 'dns::zone' do
let(:pre_condition) { 'include dns::server::params' }
let(:title) { 'test.com' }
let(:facts) {{ :osfamily => 'Debian', :concat_basedir => '/mock_dir' }}
describe 'passing something other than an array to $allow_query ' do
let(:params) {{ :allow_query => '127... |
require 'rails_helper'
# As a visitor,
# When I visit an amusement park’s show page
# I see the name and price of admissions for that amusement park
# And I see the names of all the rides that are at that theme park listed in alphabetical order
# And I see the average thrill rating of this amusement park’s rides
desc... |
Gem::Specification.new do |s|
s.name = 'square.rb'
s.version = '31.0.0.20230816'
s.summary = 'square'
s.description = ''
s.authors = ['Square Developer Platform']
s.email = ['developers@squareup.com']
s.homepage = ''
s.licenses = ['Apache-2.0']
s.add_dependency('apimatic_core_interfaces', '~> 0.2.0')
... |
require 'spec_helper'
describe Task do
before(:each) do
@user = User.create(:login => 'username', :password => '123456', :password_confirmation => '123456')
@todo_tasks = [
Task.create(:title => 'Test', :description => 'Desc'),
Task.create(:title => 'Test', :description => 'Desc'),
]
@don... |
class AddSalaryToPostings < ActiveRecord::Migration[5.0]
def change
add_column :postings, :employer, :string
add_column :postings, :salary, :string
add_column :postings, :schedule, :string
add_column :postings, :date_to_remove, :datetime
add_column :postings, :date_posted, :datetime
add_column... |
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe RailsAdmin::Config::Fields::Types::BsonObjectId do
it_behaves_like 'a generic field type', :string_field, :bson_object_id
describe '#parse_value' do
let(:bson) { RailsAdmin::Adapters::Mongoid::Bson::OBJECT_ID.new }
let(:field) do
Ra... |
class Pub
attr_reader :name, :till, :stock
def initialize(name, till)
@name = name
@till = till
@stock = Hash.new(0)
end
def stock_level(drink)
return @stock[drink]
end
def add_drink(drink)
if @stock.include?(drink)
@stock[drink] += 1
else
@stock[drink] = 1
end
... |
class Pub < ApplicationRecord
DISTRICTS = [
"Brunswick",
"Carlton",
"Central Business District",
"Collingwood",
"Docklands",
"East Melbourne",
"Elwood",
"Fitzroy",
"Footscray",
"Northcote",
"Port Melbourne",
"Prahran",
"Richmond",
"South Melbourne",
"South Y... |
class Dispositivo < ActiveRecord::Base
has_many :puertos, :include => :endpoint, :dependent => :destroy
has_many :device_connections, :through => :puertos, :include => :dispositivo
has_and_belongs_to_many :practicas
scope :for_users, where('tipo <> ?','vlan')
scope :ok, where('estado = ?', 'ok')
#has_many... |
class DropAddRandomTable < ActiveRecord::Migration
def change
# drop_table(:randoms)
create_table(:random_events) do |t|
t.column(:change_happiness, :integer)
t.column(:change_energy, :integer)
t.column(:change_money, :float)
t.column(:description, :string)
end
end
end
|
require 'data_magic'
namespace :es do
desc "delete elasticsearch index (_all for all)"
task :delete, [:index_name] => :environment do |t, args|
DataMagic.client.indices.delete(index: args[:index_name])
end
desc "list elasticsearch indices"
task :list => :environment do |t, args|
result = DataMagic.c... |
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe StoreComment, "StoreCommentモデルのテスト", type: :model do
describe 'バリデーションのテスト' do
let!(:store_comment) { create(:store_comment) }
context '登録ができるか' do
it "全ての情報があれば登録できる" do
expect(store_comment).to be_valid
end
end
... |
class UsersController < ApplicationController
PER_PAGE = 8
# GET users
def index
unless current_user.can_manage_users?
return render_404
end
@site =
if params[:site]
Site.find_by_name(params[:site])
else
unless current_user.is_admin
current_user.site
else... |
class SecretsController < ApplicationController
before_action :require_login, only: [:index, :create, :destroy]
def index
@secrets = Secret.all
end
def create
flash[:messages] = []
@secret = current_user.secrets.new(secret_params)
if @secret.save
flash[:messages].push({ 'status' =... |
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
include SessionHelper
before_action :fetch_user
private
def fetch_user
@current_user = User.find_by :id => session[:user_id] if session[:user_id].present?
session[:user_id] = nil unless @current_user.present? #... |
class ApplicationController < ActionController::Base
delegate :current_user, :user_signed_in?, to: :user_session
protect_from_forgery with: :exception
helper_method :current_user, :user_signed_in?
def user_session
UserSession.new(session)
end
def require_authentication
unless user_signed_in?
redirect_to ... |
require "formula"
class Dtc < Formula
homepage "http://www.devicetree.org/"
url "http://ftp.debian.org/debian/pool/main/d/device-tree-compiler/device-tree-compiler_1.4.0+dfsg.orig.tar.gz"
sha1 "2f9697aa7dbc3036f43524a454bdf28bf7e0f701"
def install
system "make"
system "make", "DESTDIR=#{prefix}", "PRE... |
require 'rails_helper'
describe ContactForm do
it { should validate_presence_of :email }
it { should validate_presence_of :name }
it { should validate_presence_of :message }
it { should allow_value("person@example.com").for(:email) }
it { should_not allow_value("person_email").for(:email) }
end
|
# The Fibonacci sequence is defined by the recurrence relation:
#
# Fn = Fn1 + Fn2, where F1 = 1 and F2 = 1.
# Hence the first 12 terms will be:
#
# F1 = 1
# F2 = 1
# F3 = 2
# F4 = 3
# F5 = 5
# F6 = 8
# F7 = 13
# F8 = 21
# F9 = 34
# F10 = 55
# F11 = 89
# F12 = 144
# The 12th term, F12, is the first term to contain th... |
Rails.application.routes.draw do
resources :questions, only: [:index, :show]
root "questions#index"
end
|
require 'rails_helper'
RSpec.describe MediaType, type: :model do
before { @model = FactoryGirl.build(:media_type) }
subject { @model }
it { should respond_to(:name) }
it { should respond_to(:description) }
it { should be_valid }
it { should validate_uniqueness_of(:name) }
it { should validate_presence_... |
class RewardPoint < ActiveRecord::Base
# if we have a program other than Sears, this will need to be a config
MAX_POINTS_PER_MONTH = 25_000
belongs_to :user
belongs_to :badging, :class_name => 'Reputable::Badging'
belongs_to :badge, :class_name => 'Reputable::Badge'
named_scope :for, lambda {|... |
require 'rubygems'
require 'logger'
require "yaml"
require 'ftools'
require 'open3'
require 'thread'
module Castly
module Transcoding
class << self
attr_accessor :log, :config, :transfer_queue
def start(file_path, output, config = nil)
configure
Thread.new { start_indexer(output) }.ru... |
class ChangeShortUrl < ActiveRecord::Migration[5.1]
def change
add_index :short_urls, [:user_id,:short_url], unique: true
# add_index :short_urls
end
end |
class Contest < ActiveRecord::Base
belongs_to :order
belongs_to :account
validates_presence_of :name
def criteria
results = []
results << "Product Name: #{product_name}" if product_name.present?
results << "Start Date: #{I18n.l start_date.to_date, format: :short}" if start_date.present?
result... |
require 'rails_helper'
RSpec.describe User, type: :model do
describe 'user登録機能' do
context '全て入力してある場合' do
it "is valid with a name, email, password, rating" do
user = User.new(
name: 'rspec',
email: "rspec@test.com",
password: "password" )
expect(user).to be... |
#!/usr/bin/env ruby
#encoding: utf-8
require 'json'
require 'mechanize'
require 'highline/import'
backloggery_url = "http://backloggery.com"
if ARGV.length < 1 || ARGV.length > 2
puts "Usage: ./backloggery_steam.rb backloggery_username [steam_username]"
exit -1
end
backloggery_username = ARGV[0].downcase
if ARGV... |
######################################################################
# Copyright (c) 2008-2014, Alliance for Sustainable Energy.
# All rights reserved.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free... |
class Idea < ActiveRecord::Base
# == Vendor
acts_as_markup :description, :active_domains => Cobrand.active_domains
validates_markup :description, :minimum => 1
acts_as_fulltextable :title, :description
acts_as_profanity_filter :title, :description
include ActsAsHasPermalink
acts_as_has_perm... |
class ListingsController < ApplicationController
before_action :require_login, only: [:edit, :update]
def index
if params[:query].present?
@listings = Listing.search(params[:query], page:params[:page])
else
# @listings = Listing.all.page params[:page]
@listings = current_user.listings.al... |
class EasyPageUserTab < ActiveRecord::Base
belongs_to :page_definition, :class_name => "EasyPage", :foreign_key => 'page_id'
belongs_to :user
acts_as_list
scope :page_tabs, lambda { |page, user_id, entity_id| {
:conditions => EasyPageUserTab.tab_condition(page.id, user_id, entity_id),
:order => "#... |
require 'net/http'
require "csv"
class StooqApi
DATA_SOURCE_URL = 'https://stooq.pl/q/d/l/'
attr_reader :url
def initialize
@url = URI.parse(DATA_SOURCE_URL)
end
def get_data(stock_symbol:, period: 'd')
params = {
s: stock_symbol,
i: period
}
url.query = URI.encode_www_form(pa... |
require 'spec_helper'
feature "Signing in" do
background do
@user = FactoryGirl.create(:user)
end
scenario "Signing in with correct credentials" do
visit '/sessions/create'
within(".new_user") do
fill_in 'user[email]', :with => @user.email
fill_in 'user[password]', :with => @user.passwor... |
require 'test_helper'
class ActivationsControllerTest < ActionController::TestCase
setup :activate_authlogic
setup do
@user = FactoryGirl.create :user
@active_user = FactoryGirl.create :active_user
end
test "Activating User" do
@user.reset_perishable_token!
get :create, :activation_code=>@us... |
class NullifyInvalidMeasurements < ActiveRecord::Migration
def self.up
Measurement.find_each do |measurement|
unless measurement.valid?
measurement.attribute_names.each do |attribute|
unless measurement.errors[attribute].blank?
measurement.send("#{attribute}=",nil)
e... |
class IndianMusicEvaluationService < ExperimentService
class << self
SONG_SIZE = 10
def create(options)
DB.transaction do
exp = Experiment.create(
username: options['username'],
model: 'IndianMusicEvaluationEntry',
)
SONG_SIZE.times.to_a.shuffle.each do |i|
... |
# == Schema Information
#
# Table name: shop_types
#
# id :integer not null, primary key
# created_at :datetime not null
# updated_at :datetime not null
# i18n_name_id :integer
# i18n_description_id :integer
# shop_id :integer
#
class... |
class Locations
attr_reader :locations
def initialize
@locations = []
end
def add(location)
@locations.push(location)
end
end
|
class PatchArtistNames < Patch
def call
# Prevent slug conflicts
each_printing do |card|
unless card["artist"]
unless card["name"] == "Look at Me, I'm R&D"
warn "No artist for #{card["name"]} #{card["set_code"]} #{card["number"]}"
end
card["artist"] = "unknown"
en... |
# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'play_store_info/version'
# Describe your gem and declare its dependencies:
Gem::Specification.new do |spec|
spec.name = 'play_store_info'
spec.version = PlayStoreInfo::VERSION
s... |
# == Schema Information
#
# Table name: courses
#
# id :integer not null, primary key
# title :string(255)
# author :string(255)
# image :string(255)
# desc :text
# created_at :datetime not null
# updated_at :datetime not null
# user_id :in... |
class UserSkill < ApplicationRecord
belongs_to :user
belongs_to :skill
validates :user_id, presence: true
validates :skill_id, presence: true
mount_uploader :multimedia, SkillUploader
end
|
# frozen_string_literal: true
require "forwardable"
module IdNumberLatam
class Base
extend Forwardable
def_delegators :@dni_class, :format, :unformat, :valid?
attr_accessor :id_number, :unformatted_id_number, :country
def initialize(id_number, opts = {})
@id_number = id_number
@country... |
module LanguageHelpers
def check_language (var)
return current_lang.to_s.eql? var
end
def full_lang_name(lang)
case lang.to_s
when "pl"
"Polski"
when "en"
"English"
when "es"
"Español"
end
end
def current_lang
I18n.locale
end
def other_langs
langs - [I... |
class Review < ApplicationRecord
belongs_to :user_country
has_one :country, through: :user_country
has_one :user, through: :user_country
end
|
json.brand do
json.partial! "item", brand: @brand
end |
class Admin::Cms::GroupsController < Admin::Cms::BaseController
before_action :build_group, :only => [:new, :create]
before_action :load_group, :only => [:edit, :update, :destroy]
def files
mirrored_site_ids
@items = Cms::File.includes(:categories).for_category(params[:category]).where(['site_id IN (?)'... |
class RenameColumnt < ActiveRecord::Migration
def change
rename_column :program_sizes, :planed_added, :planned_added
end
end
|
class Contract < ActiveRecord::Base
has_many :stations, dependent: :destroy
has_many :weather_data_points, dependent: :destroy
end
|
class ExportJob < Struct.new(:export, :filename, :type, :base_uri)
def enqueue(job)
job.delayed_reference_id = export.id
job.delayed_reference_type = export.class.to_s
job.delayed_global_reference_id = export.to_global_id
job.save!
end
def perform
strio = StringIO.new
exporter = SkosEx... |
class BIDCustomPickerViewController < UIViewController
attr_accessor :picker, :winLabel, :column0, :column1, :column2, :column3, :column4, :column5, :button
def showButton
button.hidden = false
end
def playWinSound
path = NSBundle.mainBundle.pathForResource('win', ofType: 'wav')
soundID = Pointer... |
require 'rails_helper'
describe "When an order has been placed" do
before :each do
@user = User.create(name: 'Christopher', email: 'christopher@email.com', password: 'p@ssw0rd', role: 0)
allow_any_instance_of(ApplicationController).to receive(:current_user).and_return(@user)
@address = @user.addresses.cr... |
require 'spec_helper'
describe Prediction do
it { should belong_to(:forecast) }
describe "attributes" do
it { should respond_to(:game_id) }
it { should respond_to(:winning_team_id) }
it { should respond_to(:losing_team_id) }
it { should respond_to(:winning_team_score) }
it { should respond_t... |
name 'managed_directory'
maintainer 'Zachary Stevens'
maintainer_email 'zts@cryptocracy.com'
license 'Apache 2.0'
description 'Provides the managed_directory resource'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
source_url 'https://github.com/zts/chef-c... |
class Monsters
attr_accessor :name, :size, :type ,:alignment ,:armor_class ,:hit_points
@@all = []
def initialize
@@all << self
end
def self.all
@@all
end
end
|
# frozen_string_literal: true
class City < ApplicationRecord
has_many :users, dependent: :nullify
validates :zip_code,
presence: true,
format: { with: /\A(?:[0-8]\d|9[0-8])\d{3}\Z/ }
end
|
# Purty colours
require 'highline/import'
begin
require 'Win32/Console/ANSI' if RUBY_PLATFORM =~ /win32/
rescue LoadError
raise 'You must `gem install win32console` to use color on Windows'
end
def command_echoing_output(cmd)
escaped = cmd.gsub("'", "\\\\'")
say "<%=color('#{escaped}', RED)%>"
IO::popen(cmd)... |
require "overridden_helpers"
require "utilities"
module ApplicationHelper
include OverriddenHelpers
include Utilities
def relative_time_tag(to_time, start_caps = false)
format = relative_time(to_time)
format = format[0].upcase + format[1...format.size] if start_caps
time_tag to_time, to_time.strfti... |
# frozen_string_literal: true
require 'grpcs/grpcapi-go-server/article_pb'
class ArticleApi::Article::CreateService < ArticleApi::Article
def call(title)
req = Grpcs::GrpcapiGoServer::Article::CreateArticleRequest.new(title: title)
@service.create_article(req)
end
end
|
require 'rails_helper'
feature 'Editing audit details', :omniauth, :js do
let!(:user) { create(:user) }
let!(:audit) { create(:audit, name: 'My audit', user: user) }
let!(:audit_structure_type) { audit.audit_structure.audit_strc_type }
before do
signin_as user
visit audits_path
end
scenario 'for ... |
class Fluentd
module Setting
class FormatterLtsv
include Fluentd::Setting::Plugin
register_plugin("formatter", "ltsv")
def self.initial_params
{}
end
def common_options
[
:delimiter,
:label_delimiter,
:add_newline
]
end
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.