text stringlengths 10 2.61M |
|---|
class FontJunction < Formula
head "https://github.com/theleagueof/junction/archive/master.zip", verified: "github.com/theleagueof/junction/"
desc "Junction"
homepage "https://www.theleagueofmoveabletype.com/junction"
def install
parent = File.dirname(Dir.pwd) != (ENV['HOMEBREW_TEMP'] || '/tmp') ? '../' : '... |
module Daggregator::Model::Serialization
def to_node_for(type)
type = type.to_s
{
'identifier' => identifier_for(type),
'data' => node_data_for(type)
}
end
def to_flows_to_for(type)
type = type.to_s
flows = []
daggregator_options[type].flows_to.each_pair do |association_name, ... |
module Types
class MutationType < Types::BaseObject
field :create_user, mutation: Mutations::CreateUser
field :update_user, mutation: Mutations::UpdateUser
field :sign_in, mutation: Mutations::SignIn
field :create_student, mutation: Mutations::CreateStudent
field :create_venue, mutation: Mutations... |
require_relative 'spec_helper'
describe 'fivem::vrp' do
let(:subject) do
ChefSpec::SoloRunner.new do |node|
node.override['fivem']['prefix'] = '/server'
node.override['fivem']['vrp']['repository'] = 'https://my/host/vrp.git'
node.override['fivem']['vrp']['reference'] = 'dev'
node.override... |
class CommentSerializer < ActiveModel::Serializer
attributes :id, :content, :username, :commentdate, :user_id
has_one :user
has_one :post
end
|
evan_engram = PlayerCard.create do |card|
card.first_name = 'Evan'
card.last_name = 'Engram'
card.position = Position::TIGHT_END
card.team_chemistry_id = Chemistry.by_team_city(:new_york_1).first.id
card.program ... |
##
# This module requires Metasploit: http//metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##
require 'msf/core'
class Metasploit3 < Msf::Auxiliary
include Msf::Exploit::Remote::HttpServer::HTML
include Msf::Auxiliary::Report
def initialize(info = {})
super(update_info(info,
'N... |
module FacilityWizardForm
class UpdateShelfTraysForm
include ActiveModel::Model
include Mapper
ATTRS = [:facility_id,
:room_id,
:row_id,
:id, # shelf.id
:code, # shelf.code
:trays]
attr_accessor(*ATTRS)
attr_accessor :duplicate_t... |
class UIBarButtonItem
def setValue(value, forUndefinedKey:key)
if key == "outlet"
view.setValue(value, forUndefinedKey:key)
else
super
end
end
end
|
# frozen_string_literal: true
require_relative "observer"
require_relative "reference_range"
module Redox
module Models
class Observation < Redox::Model
redox_property :DateTime
redox_property :Value
redox_property :ValueType
redox_property :Units
redox_property :Code
redox_p... |
class AddPricePerNigthToRooms < ActiveRecord::Migration
def change
add_column :rooms, :price_per_nigth, :decimal
end
end
|
require_relative 'test_helper'
class ExpansionTests < SlightishTest
# Environmental variables
add_expand_test('bare env variable', '$PATH', ENV['PATH'])
add_expand_test('braced env variable', '${PATH}', ENV['PATH'])
add_expand_test('interpolated bare env variable', '/$HOME/nonsense', "/#{ENV['HOME']}/nonsens... |
desc "Create Plant Wastes"
task :create_wastes_plant => :environment do
facility_id = Facility.find_by(name: "DEMO F15")&.id
batches = Cultivation::Batch.where(status: "ACTIVE", facility_id: facility_id)
batches.map{|x| x.plants.update_all(wet_weight: nil, wet_waste_weight: nil, wet_weight_uom: nil, destr... |
require "rubygems"
require 'java'
require "rake/testtask"
require "rake/rdoctask"
require "jeweler"
task :default => :test
Rake::TestTask.new do |t|
t.libs << "test"
t.test_files = FileList['test/**/*_test.rb']
t.verbose = true
t.warning = true
end
Rake::TestTask.new("example") do |t|
t.libs << "example"
... |
class Department < ActiveRecord::Base
attr_accessible :name
belongs_to :hospital
has_many :subdivisions
end
|
class StandardEquipment < ActiveRecord::Base
attr_accessible :equipment_id, :standard_id
belongs_to :equipment
belongs_to :standard
delegate :name, to: :equipment
end
|
class PlayerSeasonsController < ApplicationController
before_action :set_player_season, only: [:show, :edit, :update, :destroy]
# GET /player_seasons
# GET /player_seasons.json
def index
@player_seasons = PlayerSeason.all
end
# GET /player_seasons/1
# GET /player_seasons/1.json
def show
end
#... |
require 'sinatra'
require_relative '../config/environments.rb'
module Sessions
class Server < Sinatra::Application
configure do
set :bind, '0.0.0.0'
enable :sessions
end
get '/' do
# session treated like a hash
if session[:user_id]
erb :index
else
redirect t... |
class Role < ActiveRecord::Base
belongs_to :user
belongs_to :project
def self.available_roles
%w(manager editor viewer)
end
end
|
class ContactsController < ApplicationController
include PublicActivity::StoreController
def new
@contact = Contact.new
end
def create
@contact = Contact.new(params.require(:contact).permit(:name, :mobile, :message))
if @contact.save
redirect_to root_url, notice: '申请提交成功, 请等待我们联系您!'
else... |
# Print KANBAN
module Printer
class P001<Base
HEAD=[:kanban_nr,:part_nr,:customer_nr,:wire_position,:card_number,:card_quantity,:print_date,:remark1,:remark2,:kanban_2dcode]
BODY=[:route_nr,:route_name,:route_desc,:work_time_of_route,:consume_date]
$ROUTE_PART_COUNT.times {|i|
BODY<<"wire_nr#{i+1}_... |
class AddWeaponIdToCharacter < ActiveRecord::Migration
def change
add_column :characters, :weapon_id, :integer
end
end
|
class Spell < ApplicationRecord
has_many :wizard_spells
has_many :wizards, through: :wizard_spells
end
|
=begin
#===============================================================================
Title: Enemy Levels
Author: Hime
Date: Nov 23, 2013
URL: http://himeworks.com/2013/11/16/enemy-levels/
--------------------------------------------------------------------------------
** Change log
Nov 23, 2013
- fixed bug... |
class RemoveOldPasswordFromUsers < ActiveRecord::Migration[5.2]
def up
remove_column :users, :password
end
def down
add_column :users, :password, :string
end
end
|
require 'rails_helper'
describe ReportsController, :type => :controller do
before do
@group = FactoryGirl.create(:group)
@user = FactoryGirl.create(:user, group: @group)
@email = FactoryGirl.create(:email, user: @user)
@user1 = FactoryGirl.create(:user, group: @group)
@email1 = FactoryGirl.create(... |
require 'spec_helper'
require 'web_mock'
require_relative '../app/covid/last_selection_question'
require File.dirname(__FILE__) + '/../app/bot_client'
describe 'BotClientCovidCommands' do
let(:token) { 'fake_token' }
it 'should get a /diagnostico covid message and respond with an inline keyboard' do
token =... |
class String #Redefinimos la clase string
def to_date #Los strings de input los queremos pasar a formato fecha para poder ordenar en base a las mismas
case self
when "today"
return Date.today
when "tomorrow"
return Date.today+1
when"yesterday"
return Date.today-1
end
... |
require 'test_helper'
class CassandraObject::CoreTest < CassandraObject::TestCase
test 'initialiaze' do
issue = Issue.new
assert issue.new_record?
assert !issue.destroyed?
end
test 'initialize yields self' do
issue = Issue.new { |i| i.description = 'bar' }
assert_equal 'bar', issue.descript... |
# Como manipular arquivos I/O (Input/Output)
somefile = File.open("sample.txt", "w") # Cria um arquivo e escreve hello text nele
somefile.puts "Hello file!"
somefile.close
# Tambem pode ser escrito com o block method
File.open("sample.txt", "w"){ |somefile| somefile.puts "Hello file!"} #Bem melhor :D
# Leitura de ar... |
require File.dirname(__FILE__) + '/test_helper'
require 'quantified/length'
class LengthTest < Test::Unit::TestCase
include Quantified
Length.numeric_methods :metres, :centimetres, :inches, :feet
def setup
@length = Length.new(5, :feet)
end
def test_inspect
assert_equal "#<Quantified::Length: 5 f... |
require 'spec_helper'
describe 'Commands' do
include_context 'users and tasks'
let(:users) { rom.relations.users }
before do
setup.relation(:users) do
def by_id(id)
restrict(id: id)
end
end
end
describe '.build_class' do
it 'creates a command class constant' do
klass ... |
Gem.loaded_specs['ouvrages_file_uploader'].dependencies.each do |dependency|
require dependency.name
end
require "ouvrages_file_uploader/engine"
if (::Rails.env.test? or ::Rails.env.development?) and ENV["FILEUPLOAD_HASH_SECRET"].nil?
ENV["FILEUPLOAD_HASH_SECRET"] = "secret"
end
module OuvragesFileUploader
mod... |
# Copyright 2019 The inspec-gcp-cis-benchmark Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law... |
class Author
# name, dob, books
attr_reader :name, :dob
def initialize(name, dob)
@name = name
@dob = dob
end
def books
# I want all of MY BOOKS
Book.all.select do |book|
book.author == self
end
end
# I have many genres THROUGH books
def genres
# [ #<B... |
# -*- encoding: utf-8 -*-
require File.expand_path('../lib/mars_rover/version', __FILE__)
Gem::Specification.new do |gem|
gem.authors = ["Jamie English"]
gem.email = ["jamienglish@gmail.com"]
gem.description = %q{Mars Rover Programming Problem}
gem.summary = %q{Programming problem from Th... |
require 'test_helper'
class PreviewsControllerTest < ActionController::TestCase
setup do
@preview = previews(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:previews)
end
test "should get new" do
get :new
assert_response :success
en... |
class AddFileSizeToRecitations < ActiveRecord::Migration[6.1]
def change
add_column :audio_recitations, :files_size, :integer
add_column :audio_recitations, :approved, :boolean, default: false
add_column :audio_recitations, :priority, :integer
add_index :audio_recitations, :priority
add_index :a... |
require 'smartsheet'
require 'prawn'
require 'date'
require 'time'
require 'pp'
class SSheet
def self.client
@Smartsheet_client ||= Smartsheet::Client.new(token: IO.read("key.txt"))
end
def sheets
@sheets ||= client.sheets.list
end
def client
SSheet.client
end
def initialize(name)
# Se... |
Rails.application.routes.draw do
get 'activities/index'
devise_for :users, controllers: { omniauth_callbacks: 'omniauth_callbacks'}
root to: 'pages#home'
namespace :api, defaults: { format: :json } do
namespace :v1 do
resources :activities, only: [:index, :update]
resources :users, only: [:in... |
# 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... |
Pod::Spec.new do |s|
s.name = "WindRoseView"
s.version = "1.0.0"
s.summary = "A marquee view used on iOS."
s.description = <<-DESC
It is a marquee view used on iOS, which implement by Objective-C.
DESC
s.homepage = "https://github.com/klz568/WindRoseView"
s.license = ... |
class CreateSchools < ActiveRecord::Migration
def change
create_table :schools do |t|
t.string :name
t.hstore :regestrar_details, default: { "first_name" => "", "last_name" => "", "email" => "", "phone" => "", "address" => "" }
t.references :school_controller, index: true
t.references :man... |
module Nessus
class Client
# @author Erran Carey <me@errancarey.com>
module Report2
# POST /report/ports
#
# @param [String] report unique identifier
# @param [String] hostname name of host to display open ports for
#
# @return an object containing a list of open ports on a... |
module Hatchet
# used for deploying a test app to heroku via git
class GitApp < App
HATCHET_BUILDPACK_BASE = (ENV['HATCHET_BUILDPACK_BASE'] || "https://github.com/heroku/heroku-buildpack-ruby.git")
HATCHET_BUILDPACK_BRANCH = -> { ENV['HATCHET_BUILDPACK_BRANCH'] || Hatchet.git_branch }
BUILDPACK_URL = ... |
module ApplicationHelper
def format( input )
unless input.nil?
input[:params].map!{|p| p.class == Array ? pluralize(*p) : p }
input[:message] % input[:params]
end
end
end
|
require_relative 'dijkstra'
input = File.readlines("input").map{ |l| l.strip.split(")") }
class SpaceObject
attr_reader :code
attr_reader :parent
attr_reader :orbitee
def initialize(code)
@code = code
@orbitee = []
end
def << (obj)
@orbitee << obj unless @orbitee.include?(obj)
end
def ... |
module Bitemporal
TIME_MIN = Time.utc(0)
TIME_MAX = Time.utc(9999)
def self.now=(time)
Thread.current[:now] = time
end
def self.now
Thread.current[:now] ||= Time.now
end
module Mongoid
autoload :Master, "bitemporal/mongoid/master"
autoload :Version, "bitemporal/mongoid/version"
autoloa... |
module DatabaseHelper
def row_name row
model = row.class
name_col = column_used_for_name(model)
return row["name"] if name_col == "name"
return "#{model.name}##{row["id"]}" if name_col == "id"
nil
end
def show_name_column? model
column_used_for_name(model) != nil
end
def name_colum... |
module Deadpool
module FailoverProtocol
class Base
attr_reader :logger
attr_reader :config
def initialize(config, failover_config, logger)
@state = Deadpool::State.new failover_config[:name], self.class.to_s
@config = config
@failover_config = failover_config
@l... |
module OverrideErrors
mattr_accessor :field_error_proc
@@field_error_proc = Proc.new do |html_tag, instance|
"<span class=\"fieldWithErrors\">#{html_tag} <div class=\"wrapper\"><div class=\"error-icon\"></div><div class=\"error-msg\"> #{Array[instance.error_message].join(",")}</div></div></span>".html_safe
... |
class GoogleService
attr_reader :service_object
def initialize(params)
if params[:service_name] == "read_emails"
client = Signet::OAuth2::Client.new(access_token: Token.last.fetch_access_token)
service = Google::Apis::GmailV1::GmailService.new
service.authorization = client
end
@servi... |
#!/usr/bin/env ruby
require_relative '../lib/cli'
cli = CommonCli.new({
# defaults
:maxflight => 200,
:timeout => 60,
:global_timeout => 0,
})
cli.extra_options = lambda do |parser, options|
parser.on('--noshell', "Don't invoke a shell. Args will be passed to exec verbatim ") do |arg|
options[:noshell]... |
class Agency
def initialize
@houses = []
end
def register house
@houses << house
end
def mediate_purchase house, buyer
if conditions_are_met? house, buyer
handle_money house, buyer
house.owner = buyer
end
end
private
def conditions_are_met? house, buyer
@houses.incl... |
class Tweets < ActiveRecord::Migration[5.0]
def change
create_table :tweets do |t|
t.string :tweet_id, null: false
t.string :screen_name, null: false
t.string :name, null: false
t.string :in_reply_to_status_id
t.string :profile_ima... |
class Pgw < ApplicationRecord
belongs_to :p_name, :foreign_key => [:e_no, :result_no, :generate_no], :primary_key => [:e_no, :result_no, :generate_no], :class_name => 'Name'
belongs_to :pgws_name, :foreign_key => :pgws_name_id, :primary_key => :proper_id, :class_name => 'ProperName'
scope :pgws_type,... |
require 'browser'
module Count
URL_PREFIX_LRM_DOWN = 'http://lrm/default.aspx?labrunid='
URL_PREFIX_LRM = 'http://lrm/default.aspx?_labrunId='
URL_PREFIX_LRM_RE = 'http://lrm/LabRunReport.aspx?labrunid='
URL_PREFIX_MULTIPLE = 'http://tfx/LabrunManager/default.aspx?_labrunId='
URL_P... |
class MirrorBodyPart < ActiveRecord::Migration
class BodyPart < ActiveRecord::Base
@@all_body_parts ||= all
belongs_to :mirror, :class_name => "BodyPart", :foreign_key => "mirror_id"
def old_mirror
all_body_parts.select{ |bp| (bp.name_en == name_en && bp.side != side) }.first
end
private
... |
class Lightning < ActiveRecord::Base
has_many :users
has_many :lightningdata
end
|
##
# $Id: java_ws_arginject_altvm.rb 9074 2010-04-14 21:45:23Z jduck $
##
##
# This file is part of the Metasploit Framework and may be subject to
# redistribution and commercial restrictions. Please see the Metasploit
# Framework web site for more information on licensing and terms of use.
# http://metasploit.com/fra... |
module CDI
module V1
module SurveyQuestions
class CreateService < BaseCreateService
include V1::ServiceConcerns::SurveyQuestionParams
record_type ::SurveyQuestion
def initialize(survey, user, options)
super user, options
@survey = survey
end
de... |
class CoursesController < ApplicationController
def new
@course=Course.new
end
def create
@course = Course.new(course_params)
if @course.save
redirect_to courses_path, flash: {success: "新课程申请成功"}
else
flash[:warning] = "信息填写有误,请重试"
render 'new'
end
end
def edit
@co... |
# frozen_string_literal: true
require 'sample_agent_test_configuration'
describe TrailingStopManager do
include_context 'use agent_setting'
let(:builder) { container.lookup(:position_builder) }
let(:repository) { container.lookup(:position_repository) }
let(:original) do
tick = Jiji::Model::Trading::T... |
class StarredRepositoriesAddIndexUserIdAndRepoId < ActiveRecord::Migration
self.disable_ddl_transaction!
def up
execute "CREATE UNIQUE INDEX index_starred_repositories_on_user_id_and_repo_id ON starred_repositories (user_id, repository_id)"
end
def down
execute "DROP INDEX index_starred_repositories_o... |
data = File.readlines("input")
class Track
attr_reader :carts
def initialize(data)
@data = data
@carts = []
@data.each_with_index do |l,y|
l.chars.each_with_index do |c,x|
d = "^>v<".index(c)
if !d.nil?
cart = Cart.new(x, y, d, self)
@carts << cart
... |
class Post < ActiveRecord::Base
extend FriendlyId
friendly_id :name, use: [:slugged, :history]
belongs_to :user
validates :user_id, :presence => true
validates :name, :presence => true
validates :title, :presence => true, :length => { :minimum => 5 }
has_many :comments, :dependent => :destroy
#def ... |
#Some thoughts for the design of 'methods' relationships
# The DockingStation 'rent_out' for the Person to 'rent'
# The Person 'return_rental' for the DockingStation to 'dock_bike'
# The Van 'replenish for the DockingStation to 're-stock'
# The DockingStation 'release' for the Van to 'take_away'
# The Van 'drop_off' fo... |
# Teskal
class Token < ActiveRecord::Base
belongs_to :user
@@validity_time = 1.day
def before_create
self.value = Token.generate_token_value
end
# Return true if token has expired
def expired?
return Time.now > self.created_on + @@validity_time
end
# Delete all exp... |
class ChangeNeighborhoodInUserType < ActiveRecord::Migration[5.2]
def change
change_column :users, :neighborhood_id, :integer
end
end
|
require 'yaml'
require 'figroll/util'
module Figroll
# A configuration object for Figroll
class Config
# A list of required environment variables defined by the configuration
# @return [Array<String>, nil]
# @api private
attr_reader :required
# The `FIGROLL_ENV` under which we're running
... |
require 'active_support/concern'
module Protobuf
module Optionable
extend ::ActiveSupport::Concern
module ClassMethods
def get_option(name)
@_optionable_options.try(:[], name)
end
def set_option(name, value = true)
@_optionable_options ||= {}
@_optionable_options[n... |
class Link < ActiveRecord::Base
has_many :comments
has_many :votes
belongs_to :user
belongs_to :board
def self.select_links
all.map { |link| [link.title, link.post, link.id] }
end
end
|
require "rails_helper"
feature "Dashboard" do
given(:user) { FactoryGirl.create(:user, :stockholder, first_name: "Steve", last_name: "Bloggs") }
scenario "User with no stock or sales" do
visit dashboard_path(as: user)
expect(page).to have_content("Welcome Steve")
expect(page).to have_content t("dashbo... |
############################################################
#
# Name: Sean Kanaley
# Assignment: Hash Assignment
# Date: 2/22/2017
# Class: CIS 282
# Description: Create a menu driven program to interact with a set of products
#
############################################################
product... |
class TokenController < ApplicationController
layout 'base_with_js'
before_filter :authenticate_user!
before_filter :load_user_auth_profiles
#before_filter :load_vip_client, :only => ['validate_otp']
def validate
unless current_user.auth_profiles.any?
# TODO この flash は redirect しているので、実は渡せない。。
... |
# First attempt
=begin
- Update solution to accept a low and high value when creating an instance of GuessingGame
- Change the number of guesses allowed so the user can always win if she uses a good strategy
=end
class GuessingGame
attr_accessor :player_guess, :total_guesses, :target_number, :min, :max
def ini... |
require File.dirname(__FILE__) + '/spec_helper.rb'
describe XPash::Base, "grep command" do
before do
@xpash = get_fixture
prepare_stdout
end
it "should show list of found elements by searching text node\n\s\s" +
"in current list. (Found elements should be represented\n\s\s" +
"with current que... |
class JobPost < ApplicationRecord
has_many :offers
has_many :appointments
belongs_to :client, foreign_key: :client_id , class_name: "User"
# belongs_to :job
end
|
FactoryGirl.define do
factory :book do
title "Book1"
details "testing of book1"
end
end
|
class RemoveAtToIndustry < ActiveRecord::Migration
def change
remove_column :sub_industries, :created_at, :string
remove_column :sub_industries, :updated_at, :string
remove_column :main_industries, :created_at, :string
remove_column :main_industries, :updated_at, :string
add_index :sub_industries,... |
require 'test_helper'
class TrademarkTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
test "Тест на провал сохранения торговой марки без названия" do
trademark = trademarks(:one)
trademark.name = " "
assert_not trademark.save, "Удалось сохранить торговую марку с пустым ... |
require_relative 'spec_helper'
describe "SD card image" do
it "exists" do
image_file = file(image_path)
expect(image_file).to exist
end
context "Partition table" do
let(:stdout) { run("list-filesystems").stdout }
it "has one partitions" do
partitions = stdout.split(/\r?\n/)
expect(p... |
require 'minitest/autorun'
require 'rack/test'
require_relative './mock-client'
require_relative './bot-api'
class BotApiSpec < MiniTest::Test
include Rack::Test::Methods
def setup
MockClient.requests = []
end
def test_send_message
BotApi.send_message chat_id: 1, text: 'chat'
url = String.new E... |
require 'spec_helper'
describe Mongoid::History::Trackable do
describe 'SingletonMethods' do
before :each do
class MyTrackableModel
include Mongoid::Document
include Mongoid::History::Trackable
field :foo
field :b, as: :bar
if Mongoid::Compatibility::Version.mongoi... |
class RecordLabelsController < ApplicationController
before_action :authenticate_user!, :except => [:index, :show]
def index
@record_labels = RecordLabel.all
end
def show
@record_label = set_record_label
end
def new
@record_label = RecordLabel.new
end
def create
@record_label = Reco... |
class ExpensesController < ApplicationController
before_action :authenticate_user!
def index
@expenses = Expense.where(user_id: current_user.id).order("date DESC")
if params[:concept].present?
@expenses = @expenses.where("concept = ? AND user_id = ?", params[:concept], current_user.id)
end
if... |
FactoryBot.define do
factory :market do
name Faker::Address.community
street_address Faker::Address.street_address
user
end
end |
# Preview all emails at http://localhost:3000/rails/mailers/first_notification_mailer
class FirstNotificationMailerPreview < ActionMailer::Preview
def first_notification_email_preview
FirstNotificationMailer.first_notification_email(Ticket.first)
end
end
|
class PhotosController < ApplicationController
before_action :check_page, only: [:index, :np]
before_action :set_photo, only: [:show, :edit, :update, :destroy]
before_action :get_gallery, only: [:index, :create]
skip_before_action :check_token, only: [:index, :show, :np]
def np
photos= Photo.all().order... |
class AddLocalregionIdToWines < ActiveRecord::Migration
def change
add_column :wines, :localregion_id, :integer, null: false
add_index :wines, :localregion_id
end
end
|
module ApplicationHelper
def current_country_cd
'USA'
end
def date_format
'%m/%d/%Y'
end
# Identifies if a user is currently logged in.
def logged_in?
!session[:user].nil?
end
end
|
class HomeSetupStatus
prepend SimpleCommand
def initialize(facility)
@facility = facility
end
def call
have_company = CompanyInfo.where({}).count > 0
if @facility.present?
have_mother_rooms = @facility.rooms.detect { |r| r.purpose == Constants::CONST_MOTHER }
have_strains = @facility.s... |
# frozen_string_literal: true
module Tikkie
module Api
module V1
module Responses
# Response when requesting an user.
class User < Base
def user_token
data[:userToken]
end
def name
data[:name]
end
# see UserStatus
... |
# frozen_string_literal: true
class AddMeasurmentsToDeals < ActiveRecord::Migration[5.2]
def change
add_column :deals, :h, :integer
add_column :deals, :w, :integer
add_column :deals, :l, :integer
add_column :deals, :weight, :integer
add_reference :deals, :package, foreign_key: true
end
end
|
module Sudoku
module Solver
# This solving technique also known as "singleton" or "lone number" is one of the simplest
# Sudoku solving techniques. Using this technique the candidate values of an empty cell are
# determined by examining the values of filled cells in the row, column and box to which the
... |
#!/usr/bin/ruby
# This example demonstrates the bridge pattern in the Ruby language.
class Abstraction
def initialize
@imp = Implementor.new
end
def operation
return @imp.operation_imp
end
end
class RefinedAbstraction < Abstraction
def initialize
@imp = ConcreteImplementorA.new
end
def... |
# frozen_string_literal: true
require 'rails_helper'
describe 'Books settings' do
before do
create(:book)
login_as(create(:user), scope: :user)
visit books_path
end
it 'must present' do
expect(page).to have_selector('#books > div:nth-child(2) > div > div:nth-child(1) > div.manip > div > button ... |
require 'rails_helper'
describe CloudFile do
describe 'relations' do
it { is_expected.to belong_to(:library) }
it { is_expected.to belong_to(:folder) }
end
end
|
class Account < ActiveRecord::Base
belongs_to :user
has_many :transactions, :dependent => :destroy
has_many :rules, :dependent => :destroy
validates :title, :length => { :minimum => 3, :maximum=>15 }, :uniqueness => true
validates_inclusion_of :currency, :in => ["AED", "ARS", "ATS", "AUD", "BEF", ... |
class Summary < ApplicationRecord
validates_presence_of :item_summary_name, :item_description
end |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.