text stringlengths 10 2.61M |
|---|
require 'rails_helper'
RSpec.describe "Healths", type: :request do
describe "GET /index" do
it "returns http success" do
# this will perform a GET request to the /health/index route
get "/health/index"
# 'response' is a special object which contain HTTP response received after a request ... |
require 'csv'
require 'bigdecimal'
require_relative '../lib/invoice'
require_relative '../lib/modules/findable'
require_relative '../lib/modules/crudable'
class InvoiceRepository
include Findable
include Crudable
attr_reader :all
def initialize(path)
@all = []
create_objects(path)
end
def crea... |
require 'test/unit'
require File.dirname(__FILE__) + '/../lib/string'
class StringTest < Test::Unit::TestCase
def test_interpolate_with_string
orig = "Hello! My name is ?"
interpolated = orig.interpolate("Nathan Hopkins")
expected = "Hello! My name is Nathan Hopkins"
assert_not_equal orig, interpola... |
# Topic.where(name: 'aortic root')[0].id
FactoryBot.define do
factory :heart_measurement do
patient
time_ago 1
time_ago_scale 'years'
test_amount 3.3
test_unit_of_meas 'cm'
descriptors 'general anesthesia'
topic_id 100
end
end
|
# frozen_string_literal: true
module Structures
# +DynamicArray+ holds data and doubles it's size when limit is reached
class DynamicArray
attr_reader :capacity, :size
def initialize(initial_size = 16)
raise "Illegal capacity: #{initial_size}" if initial_size.negative?
@capacity = initial_siz... |
class ApplicationController < ActionController::Base
protect_from_forgery
helper_method :current_user
helper_method :current_cart
def redirect_to_back_or_root(options={})
if request.referer
redirect_to :back, options
else
redirect_to root_path, options
end
end
protected
def f... |
require 'spec_helper'
require 'pry-byebug'
describe ListMore::Repositories::UsersRepo do
let(:dbhelper) { ListMore::Repositories::DBHelper.new 'listmore_test' }
let(:user_1) { ListMore::Entities::User.new({:username => "Ramses", :password_digest => "pitbull"})}
let(:user_2) { ListMore::Entities::User.new({:user... |
class Curator
attr_reader :artists,
:photographs
def initialize
@artists = []
@photographs = []
end
def add_photograph(photo)
photographs << photo
end
def add_artist(artist)
artists << artist
end
def find_artist_by_id(id)
artists.find do |artist|
artist.id ==... |
# frozen_string_literal: true
class PagesController < ApplicationController
def create
work = Work.find(params[:work_id])
page = Page.new(
work: work
)
page.save!
work.stages.each do |stage|
Progress.create(work: work, stage: stage, page: page)
end
redirect_to work,
noti... |
module WastebitsClient
class ForgotPassword < Base
attr_accessor :email, :url
def access_token
# NOOP
end
def send_instructions
return self.class.post(nil, '/users/forgot-password', :body => {
:email => @email,
:password_reset_url => @url
}, :headers => { 'Authoriz... |
require 'json'
# 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 Ri... |
require 'spec_helper'
require 'helpers/unit_spec_helper'
describe Puppet::Type.type(:clc_server) do
let(:create_params) {
{
:name => 'name',
:group_id => 'group-id',
:source_server_id => 'server-id',
:cpu => 1,
:memory => 1,
}
}
[:... |
class Book < ActiveRecord::Base
validates :title, presence: true
validates :authorname, presence: true
validates :authorsurname, presence: true
end
|
require 'rails_helper'
RSpec.describe Micropost, type: :model do
context 'associations' do
it { is_expected.to belong_to(:user) }
it { is_expected.to belong_to(:source) }
it { is_expected.to have_many(:media) }
it { is_expected.to have_many(:targets) }
it { is_expected.to have_many(:trollers) }
... |
class Api::V1::SongsController < Api::ApiController
def index
singer_id = params[:singer_id]
@songs = Song.includes(:singer).where("singer_id = #{singer_id}").select("id,name,album_id,singer_id").order("id desc").paginate(:page => params[:page], :per_page => 30)
# render :json => @songs
end
def sh... |
#require_dependency "web_user"
module AuthSystem
include AuthHelper
# store current uri in the ccokies
# we can return to this location by calling return_location
def store_location
cookies[:return_to] = {:value => request.request_uri, :expires => nil }
end
protected
def del_location... |
class Users::ChangeEmailsController < ApplicationController
before_action :correct_user, only: [:change_emails, :update]
def change_emails
@user = User.find_by(id: params[:id])
end
def update
@user = User.find(params[:id])
if user_params_change_email[:email_confirmation] == user_params_change_em... |
class Bin < ActiveRecord::Base
belongs_to :event
has_many :documents
has_many :labels
validates_presence_of :event_id
validates_presence_of :title
end |
# -*- encoding: utf-8 -*-
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'boss-protocol/version'
Gem::Specification.new do |gem|
gem.name = "boss-protocol"
gem.version = Boss::VERSION
gem.authors = ["sergeych"]
gem.email =... |
require 'rails_helper'
feature 'User remove recipe' do
scenario 'successfully' do
# create data
user = create(:user)
cuisine = create(:cuisine, name: 'Paulista')
recipe_type = create(:recipe_type, name: 'Massa')
recipe = create(:recipe, title: 'Miojo', recipe_type: recipe_type,
... |
require 'spec_helper'
describe Story do
it "should be valid" do
p = Story.make!
p.should be_valid
end
it "should be invalid without a category" do
e = Story.make(:category => nil)
e.should have(1).errors_on(:category)
end
end
|
require 'rails_helper'
describe 'Munchie' do
it 'exists and has attributes' do
city = "boulder,co"
distance = {
:route=>{
:hasTollRoad=>false,
:hasBridge=>true,
:boundingBox=>{:lr=>{:lng=>-104.605087, :lat=>38.265427}, :ul=>{:lng=>-104.98761, :lat=>39.738453}},
:distance=... |
class RegisteredTeachersController < ApplicationController
before_action :require_student
before_action :remove_null_registered_teachers, only: [:register]
before_action :registered_teacher_rank_adjust, only: [:register]
def index
@q = Teacher.all.ransack(params[:q])
@teachers = @q.result(distinct: true)... |
Gl2::Application.routes.draw do
# The priority is based upon order of creation:
# first created -> highest priority.
root :to=>"home#index"
#for user_sessions
get "sign_in" => "user_sessions#new"
post "sign_in" => "user_sessions#create"
match "sign_out" => "user_sessions#destroy"
get "a... |
class AddUserFields < ActiveRecord::Migration
def self.up
add_column :users, :name_title, :string
add_column :users, :language_id, :integer
add_column :users, :user_type_id, :integer
add_column :users, :country_name, :string
add_column :users, :skype, :string
# Paperclip
add_column :users,... |
require 'spec_helper'
require 'endpointer/response'
require 'rack/test'
describe Endpointer::AppCreator do
include Rack::Test::Methods
let(:url1) { "http://example.com/foo" }
let(:url2) { "http://example.com/bar" }
let(:invalidate) { true }
let(:resource1) { Endpointer::Resource.new("resource1", :get, url1, ... |
class Product < ActiveRecord::Base
validates :description,:name,:presence =>true
validates :price_in_cents,:numericality => {:only_integer=>true}
end
|
module GraphQL::Rails::ActiveReflection
class ValidationResult
@schema_name = "ActiveReflectionValidation"
attr_reader :valid
attr_reader :errors
def initialize(valid, errors)
@valid = valid
@errors = errors
end
class << self
attr_accessor :schema_name
end
end
end
|
class CreateVeranstaltungsart < ActiveRecord::Migration
def self.up
create_table(:Veranstaltungsart, :primary_key => :id) do |t|
# Veranstaltungsart-id PS
t.integer :id, :null => false, :uniqueness => true, :limit => 2
# VABezeichnung
t.string :vaBezeichnung, :limit => 30, :default => nil
... |
require 'priority_queue'
require 'benchmark'
require './cartesian_points_helper'
class ClosestPair2D
include CartesianPointsHelper
attr_accessor :points
FIXNUM_MAX = (2**(0.size * 8 -2) -1)
def initialize
setup
end
def re_setup
setup
end
def brute_force
brute_force_sub_routine(points)
... |
class Voucher
def self.all
vouchers = []
vouchers << Voucher.new(:id => 1, :name => "one", :amount => 1)
vouchers << Voucher.new(:id => 2, :name => "two", :amount => 2)
vouchers << Voucher.new(:id => 3, :name => "three", :amount => 3)
vouchers
end
def self.find(id)
Voucher.new(:id => id,... |
# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'colorbug/version'
Gem::Specification.new do |spec|
spec.name = "colorbug"
spec.version = Colorbug::VERSION
spec.authors = ["Michael Angelo"]
spec.email = ["ya... |
json.array! @shops do |shop|
json.partial! 'api/shops/shop', shop: shop
end |
# encoding: utf-8
begin
require 'bones'
rescue LoadError
abort '### Please install the "bones" gem ###'
end
ensure_in_path 'lib'
proj = 'thumbo'
require "#{proj}/version"
Bones{
version Thumbo::VERSION
# ruby_opts [''] # silence warning, too many in addressable and/or dm-core
depend_on 'rmagick', :version... |
# class Types::QueryType < Types::BaseObject
# graphql_name 'Query'
# ### TODO LIST QUERY
# field :todo_lists, [Types::TodoListType], null: true do
# description 'returns all todo lists'
# end
# field :todo_list, Types::TodoListType, null: true do
# description 'returns the queried todo list'
# ... |
require 'active_support/concern'
module Returning
module ActiveRecord
module Returning
def save(options = {})
if r = options[:returning]
begin
old_returning, @_returning = @_returning, r
super
ensure
@_returning = old_returning
end
... |
# frozen_string_literal: true
class UsersController < ApplicationController
PER_PAGE = 10
def index
@users = User.page(params[:page]).per(PER_PAGE)
end
def show
@user = User.find(params[:id])
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 Lead < ActiveRecord::Base
validates_presence_of :name, :tel, :email, :obs
def self.search(search)
if search
where('name LIKE ?', "%#{search}%")
else
scoped
end
end
end
|
class Anagram
attr_reader :word
def initialize(word)
@word = word.downcase
end
def match(possibles)
possibles.filter do |possible|
possible.downcase != word &&
possible.downcase.chars.sort == word.chars.sort
end
end
end
|
# frozen_string_literal: true
require_relative '../lib/rmk.rb'
require_relative '../plugins/github-release.rb'
include GithubRelease
describe GithubRelease do
around(:each) do |example|
EventMachine.run do
Fiber.new do
example.run
EventMachine.stop
end.resume
end
end
it 're... |
class CreaturesController < ApplicationController
before_action :set_creature, only: [:show, :edit, :update, :destroy]
before_action :is_admin, only: [:edit, :update, :destroy]
def search_config
@search_config ||= {
path: "/creatures/search",
placeholder: "Search Creatures"
}
end
# GET /... |
class ChangeUserFullnameToFullName < ActiveRecord::Migration[6.1]
def change
rename_column :users, :fullname, :full_name
end
end
|
csc <<-EOL
public interface IDoFoo {
int Foo(string str);
int Foo(int i);
int Foo(string str, int i);
}
public interface IDoStuff {
int StuffFoo(int foo);
string StuffBar(int bar);
}
public class ConsumeIDoFoo {
public static int ConsumeFoo1(IDoFoo foo) {
return foo.Foo("he... |
class TestSensuBase < TestCase
def test_read_config_files
base = Sensu::Base.new(@options)
settings = base.settings
assert(settings.mutator_exists?(:tag))
assert(settings.handler_exists?(:stdout))
assert(settings.check_exists?(:standalone))
done
end
def test_config_snippets
new_handle... |
module AuthHelpers
def current_user #=> User instance || nil
# Memoization
if @current_user
@current_user
else
@current_user = User.find_by(id: session[:user_id])
end
end
def is_logged_in?
if current_user
true
else
false
end
end
end
# class Auth
#
# def c... |
module Skiima
module Dependency
class Reader
attr_accessor :scripts
attr_accessor :dependencies, :adapter, :version
def initialize(dependencies, adapter, opts = {})
@dependencies, @adapter = dependencies, adapter.to_sym
@version = opts[:version] || :current
end
def... |
class ProjectSolutionsController < ApplicationController
before_action :private_access
before_action :paid_access
before_action :set_project
# GET /subjects/:subject_id/projects/:project_id/project_solutions/:id
def show
@project_solution = ProjectSolution.find(params[:id])
if !current_user.is_admin?... |
# This is the animal Class from classes 13 and 14
# The animal class takes in a name and a color, with the Zebra class creating a specific method for stripes and the Tiger class having a specific method for speaking that overrides the generic speak method in Animal
class Animal
attr_accessor :color, :name
def in... |
require 'spec_helper'
describe "opendata_licenses", type: :feature, dbscope: :example do
let(:site) { cms_site }
let(:node) { create_once :opendata_node_dataset, name: "opendata_dataset" }
let(:index_path) { opendata_licenses_path site.host, node }
let(:new_path) { new_opendata_license_path site.host, node }
... |
class RenameAddressBookTable < ActiveRecord::Migration[5.1]
def change
rename_table :address_books, :addresses
end
end
|
require 'sinatra/base'
require_relative 'redis_cache.rb'
module Sinatra
module FixerApi
API_URL = "http://data.fixer.io/api/".freeze
def get_exchange_rate(date, base_currency)
redis_key = date.to_s + base_currency
result_from_redis = RedisCache.execute_cache(redis_key) do
uri = URI("#{A... |
# top-reference
class AddStatusToEstimationSession < ActiveRecord::Migration[5.0]
def change
add_column :estimation_sessions, :status, :string
end
end
|
class RenameOperationalFiledToOperationalFieldActors < ActiveRecord::Migration
def change
rename_column :actors, :operational_filed, :operational_field
end
end
|
class User < ActiveRecord::Base
#before_create :set_default_roles
#before_update :set_default_roles
rolify
delegate :can?, :cannot?, :to => :ability
has_and_belongs_to_many :roles, :join_table => :users_roles
# Include default devise modules. Others available are:
# :token_authenticatable, :confirmable... |
#extra features
# Clear Board
def start_game
# Create initial conditions for while loop
game_over = false
#Create Board
board = [nil] * 9
#Assign Player value
player = "X"
while game_over != true
# run through all the steps in the game loop
#Print board
# To call function in the while lo... |
class ReassociateSiteTypeWithSite < ActiveRecord::Migration[6.1]
def change
# Change site type from a many-to-one association with context (formerly
# site_phase) to a many-to-many association with site.
create_table :sites_site_types, id: false do |t|
t.belongs_to :site
t.belongs_to :site_t... |
class PropertyVideo < ActiveRecord::Base
attr_accessible :name, :youtube, :property_id
belongs_to :property
end
|
#!/usr/bin/env ruby
def create_machines_hash
return {} unless File.exist? '/etc/facter/facts.d/aws_environment.txt'
machines_names_hash = Hash.new
`/usr/local/bin/govuk_node_list --with-puppet-class`.each_line do |machine|
hostname, name = machine.chomp.split(":")
machines_names_hash[hostname] = name
... |
source 'https://rubygems.org'
gemspec
rails_version = ENV['RAILS_VERSION'] || 'default'
rails = case rails_version
when 'default'
'4.2.1'
when '4.0'
{ github: 'rails/rails', branch: '4-0-stable' }
when '4.1'
{ github: 'rails/rails', branch: '4-1-stable' }
... |
require 'Foursquare'
class Attraction < ActiveRecord::Base
has_many :pictures
has_many :votes
validates :name, presence: true
def self.import_foursquare_attractions(city, num_attractions = 50, trip_id = nil)
begin
response = JSON.parse(Foursquare.import_attractions(city, num_attractions))
att... |
class Location < ActiveRecord::Base
include Coded
serialize :options
belongs_to :area
has_one :map, as: :parent
has_many :exits
has_many :actions, as: :actionable
def self.game_start
Location.lookup 'bar/common'
end
# === Location Seed ===
def self.manufacture_each data
data.flatten.ea... |
class SchoolClassesController < ApplicationController
def index
@school_classes = SchoolClass.all
end
def new
@school_class = SchoolClass.new
end
def create
@school_class = SchoolClass.create(school_class_params)
redirect_to school_class_path(@school_class)
end
def show
@school_clas... |
# -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require "ecology/version"
Gem::Specification.new do |s|
s.name = "ecology"
s.version = Ecology::VERSION
s.platform = Gem::Platform::RUBY
s.authors = ["Noah Gibbs"]
s.email = ["noah@ooyala.com"]
s.homepage = "... |
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable, and :registerable
devise :database_authenticatable, :recoverable, :rememberable, :trackable, :validatable
attr_accessible :email, :password, :... |
require 'csv'
# Строка данных для импорта
class ImportItem < ActiveRecord::Base
CSV_ATTRIBUTES = [ :fio, :email, :organization_name, :project_name, :group,
:login, :phone, :jsoned_directions, :jsoned_technologies, :jsoned_areas,
:jsoned_keys ]
belongs_to :cluster
validates :first_name, :last_name, ... |
# @param {Integer} n
# @return {Integer}
def fib(n)
if n == 0
return 0
elsif n == 1
return 1
end
fib(n-1)+fib(n-2)
end
# @param {Integer[]} candies
# @return {Integer}
def distribute_candies(candies)
num_candies = candies.size
num_uniq_candies = 0
candies_set =... |
class SidebarsController < InheritedResources::Base
layout 'manager_cms'
def update
update! {edit_sidebar_path(@sidebar)}
end
def sort
@sidebar = @current_account.sidebars.find(params[:id])
unless params[:widget].blank?
@sidebar.widget_placements.delete_all
params[:widget].eac... |
class CreateAccountEmails < ActiveRecord::Migration
def change
create_table :account_emails do |t|
t.references :account
t.string :stripped_email
t.timestamps
end
add_index :account_emails, :account_id
end
end
|
require 'test_helper'
class CarTest < ActiveSupport::TestCase
test "closest_n returns results ordered closest first" do
results = Car.closest_n(2, [-36.849700, 174.776066])
assert_equal results.first.id, cars(:one).id
end
test "closest_n returns no more than n results" do
results = Car.closest_n(1, ... |
require_relative('language_error')
class IdEvalAtCompilationError < LanguageError
def initialize(id)
super("Cannot eval identifier '#{id}' at compilation time")
end
end |
module Diffity
class RunDetails
class Jenkins
def branch
ENV.fetch('GIT_BRANCH').split('/').last
end
def author
'Jenkins'.freeze
end
end
class Travis
def branch
ENV.fetch('TRAVIS_BRANCH')
end
def author
'Travis'.freeze
end
... |
class AddForeingKeyDepartaments < ActiveRecord::Migration
def change
add_column :mytickets, :customers_id, :integer
add_column :mytickets, :departaments_id, :integer
add_column :mytickets, :categories_id, :integer
end
end
|
class User < ActiveRecord::Base
def name
self.first_name + " " + self.last_name
end
def lifetime_value
# Calculation of lifetime value will depend on your transactional logic
# Adopting a pattern of a User having a Subscription and a Subscription
# having many Transactions, an example of thi... |
require 'rails_helper'
RSpec.describe 'PostDecorator' do
let(:post) { Post.new(title: 'Hello World') }
it 'does not have a name method' do
expect { post.name }.to raise_error(NoMethodError)
end
it 'does not have a hello method' do
expect { Post.hello }.to raise_error(NoMethodError)
end
end
|
require 'cells_helper'
RSpec.describe SpendingInfo::Cell::Table do
let(:account) { Account.new(monthly_spending_usd: 1000) }
let(:person) { Person.new(account: account) }
let(:info) do
person.build_spending_info(
credit_score: 350,
will_apply_for_loan: wafl,
business_spending_u... |
class Watcher
class << self
attr_accessor :stop
end
def self.run
Thread.new do
while !stop
while Player.playing?
sleep 0.1
end
next_track = Playlist.pop
next_track.play if next_track
sleep 0.1
end
end
end
end
|
require 'station'
describe Station do
it "expects station to hold print out name of a station" do
station = Station.new(:name, :zone)
expect(station.name).to eq(:name)
end
it "expects station to hold print out zone of a station" do
station = Station.new(:name, :zone)
expect(station.zone).to eq ... |
require "application_system_test_case"
class UsedUrlsTest < ApplicationSystemTestCase
setup do
@used_url = used_urls(:one)
end
test "visiting the index" do
visit used_urls_url
assert_selector "h1", text: "Used Urls"
end
test "creating a Used url" do
visit used_urls_url
click_on "New Use... |
class RemoveCategoryFromRecruitmentCategories < ActiveRecord::Migration[5.2]
def change
remove_reference :recruitment_categories, :category, index: true, foreign_key: true
end
end
|
class Hamming
def self.compute(first_strand, second_strand)
raise ArgumentError if first_strand.length != second_strand.length
first_strand.each_char.with_index.count do |nucleotide, i|
second_strand[i] != nucleotide
end
end
end
|
module Sluggable extend ActiveSupport::Concern
included do
acts_as_url :name, :sync_url => true, url_attribute: :url
end
def to_param
"#{id}-#{url}"
end
end |
class PushNotificationWorker
include Sidekiq::Worker
sidekiq_options queue: 'notification'
def perform(school_class_id, activity_name)
puts '***************************************'
puts "School class id: #{school_class_id}"
puts "activity name: #{activity_name}"
school_class = SchoolClass.find(... |
namespace :server do
desc "Restart mod_rails server"
task :restart do
`touch tmp/restart.txt`
end
end |
class ArticlesController < ApplicationController
def index
#show a list of record
@articles = Article.all.order("created_at DESC")
end
def show
# show a record
@article = Article.find(params[:id])
end
def new
# form to create
@article = Article.new
end
def create
# action fo... |
class Car
attr_reader :make,
:model,
:monthly_payment,
:loan_length,
:color
def initialize(type, monthly_payment, loan_length)
@make = type.split(" ").first
@model = type.split(" ").last
@monthly_payment = monthly_payment
... |
module JsonStructure
class Array < Type
def initialize(elem_type = nil)
@elem_type = elem_type
end
def ===(value)
return false unless value.is_a?(::Array)
if @elem_type
return value.all? { |v| @elem_type === v }
end
true
end
end
end
|
class User < ActiveRecord::Base
has_secure_password
validates :name, :password, :email, :description, presence:true
validates_length_of :password, minimum: 8
validates_confirmation_of :password, message: "must match Password"
validates :email.downcase, uniqueness:true
validates_format_of :email, :with => /\... |
class AddFieldToDeployment < ActiveRecord::Migration
def up
add_column :deployments, :description, :string
add_column :tasks, :description, :string
end
def down
add_column :deployments, :description
dd_column :tasks, :description
end
end
|
module Auth
extend ActiveSupport::Concern
included do
before_action :authenticate, only: [:create, :update, :destroy]
end
def authenticate
authenticate_or_request_with_http_basic do |user, pass|
user.present? && pass.present?
end
end
end |
class Idea < ApplicationRecord
belongs_to :user, dependent: :destroy
has_many :idea_images
has_many :images, through: :idea_images
belongs_to :category
end
|
class Board
attr_accessor :cups
def initialize(name1, name2)
@name1=name1
@name2=name2
@cups=Array.new(14){Array.new}
place_stones
end
def place_stones
# helper method to #initialize every non-store cup with four stones each
# (0..5).each do |i|
# @cups[i] = :stone
# end
... |
# frozen_string_literal: true
require_relative "active_record_compat"
require_relative "exceptions"
module ActiveRecordWhereAssoc
module CoreLogic
# Arel table used for aliasing when handling recursive associations (such as parent/children)
ALIAS_TABLE = Arel::Table.new("_ar_where_assoc_alias_")
# Retu... |
class LeadTimesCounter
def generate_counts(cfd_data) # { dates: [...], started: [...], accepted: [...]}
return {} if cfd_data.blank?
result = {}
result[:dates] = cfd_data[:dates]
result[:accepted] = []
result[:itb] = []
result[:crt] = []
result[:accepted] = build_lead_times(data_field: ... |
class CategoryAttributeGrouping < ActiveRecord::Base
####
# MODEL ANNOTATIONS
####
####
# RELATIONSHIPS
####
belongs_to :category
has_many :attr_types, :class_name => 'CategoryAttribute'
####
# CONSTANTS
####
NAME_MIN_LENGTH = 1
NAME_MAX_LENGTH = 64
####
# VALIDA... |
require "tasks/scripts/move_facility_data"
require "tasks/scripts/discard_invalid_appointments"
namespace :data_fixes do
desc "Move all data from a source facility to a destination facility"
task :move_data_from_source_to_destination_facility, [:source_facility_id, :destination_facility_id] => :environment do |_t,... |
require 'xirgo/device'
class Xirgo::CommandRequest < ActiveRecord::Base
establish_connection "gateway_xirgo_#{RAILS_ENV}"
set_table_name "configuration_requests"
belongs_to :device
def outbound_response
not_found_msg = "Unknown error (last_command_id=#{last_command_id.inspect})"
if last_command_id
... |
# frozen_string_literal: true
require_relative 'matrix_common'
require_relative 'matrix_exceptions'
require_relative 'tridiagonal_iterator'
# Tridiagonal Sparse Matrix
class TriDiagonalMatrix
include MatrixCommon
attr_reader(:rows, :cols)
def initialize(rows, cols: rows, val: 0)
raise NonSquareException un... |
require_relative 'train'
class CargoTrain < Train
def initialize (number)
super(number, "cargo")
validate!
end
end |
module Tinify
class Result < ResultMeta
attr_reader :data
def initialize(meta, data)
@meta, @data = meta.freeze, data.freeze
end
def to_file(path)
File.open(path, "wb") { |file| file.write(data) }
end
alias_method :to_buffer, :data
def size
@meta["Content-Length"].to_... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.