text stringlengths 10 2.61M |
|---|
#--
# mysql.rb
#
# Copyright (C) 2009 GemStone Systems, Inc. All rights reserved.
#
#++
# = Overview
#
# This script shows basic usage of the MySQL driver provided with MagLev.
#
# To run the script, ensure you have MySQL running, and edit the variables
# for your configuration.
require 'ruby-mysql/mysql'
# CONFIGU... |
class RaidStopSaga < Saga
def start(disk_number, context)
@context = context
@disk_number = disk_number
Log4r::Logger['agent'].info "stoping /dev/md#{disk_number} [#{id}]"
handle()
end
def handle(message = nil)
case @state
when STATE_START
raid_state = Raid::check_raid(@disk_... |
# Preview all emails at http://localhost:3000/rails/mailers/company_lead_mailer
class CompanyLeadMailerPreview < ActionMailer::Preview
def welcome_email
company_lead = CompanyLead.last
CompanyLeadMailer.welcome_email(company_lead)
end
end
|
require_relative 'portfolio'
class Client
attr_accessor :name, :balance, :my_portfolios
def initialize (name, balance)
@name = name.downcase
@balance = balance.to_f
@my_portfolios = {}
end
#Allow creation of new portfolio with ID for seperation
def create_portfolio(p_id)
# portfolio = Portf... |
class ProductsController < ApplicationController
load_resource :user, find_by: :slug, id_param: :profile_id, only: [:index, :new]
load_and_authorize_resource :product, find_by: :slug, shallow: true, except: [:index, :by_category, :update, :create, :destroy]
load_and_authorize_resource :product, find_by: :id, sha... |
class RemoveApiAuthtokenToUsers < ActiveRecord::Migration
def change
remove_column :users, :api_authtoken, :string
end
end
|
require "stringio"
if ARGV.length != 2
# TODO: allow for I/O via standard I/O (pipes)
puts "usage: ruby dynare_fixer.rb INPUT_FILE OUTPUT_FILE"
exit
end
# replaces a function with the arguments passed in
# - command: the command to do the substitution in
# - name: the name of the function
# - args: the argum... |
require 'pry'
VERSION = 1
class Hamming
def self.compute(a, b)
raise ArgumentError, "Distance between both strands are different." unless a.length == b.length
a.chars.zip(b.chars).count{|x,y| x != y}
end
end
|
class AddCurrencyAndCountryColumns < ActiveRecord::Migration
def change
add_column :users, :country, :string, :after => :email
add_column :payments, :currency, :string, :after => :wepay_credit_card_id
end
end
|
module Visualization
class Month < Range
def self.between(start_date, end_date)
[].tap do |months|
(start_date.year..end_date.year).each do |y|
(starting_month(start_date, y)..ending_month(end_date, y)).each do |m|
months << new(y,m)
end
end
end
end
... |
require 'spec_helper'
describe "Replies" do
subject { page }
let(:user) { FactoryGirl.create(:user) }
let(:another_user) { FactoryGirl.create(:user) }
before do
user.activate!
another_user.activate!
valid_signin user
add_micropost('Lorem ipsum')
click_link "Sign out"
end
describe ... |
require 'redis'
module Cache
class << self
def client
return @redis if @redis
@redis = connect
end
private
def connect
@redis = Redis.new
@redis
end
end
end |
class AddPloneFieldsToUser < ActiveRecord::Migration
def self.up
add_column :users, :plone_password, :string, :limit => 40
add_column :users, :tmp_password, :string, :limit => 40
end
def self.down
remove_column :users, :plone_password
remove_column :users, :tmp_password
end
end
|
class AgendaMailer < ApplicationMailer
def agenda_mail(agenda)
@agenda = agenda
@members = @agenda.team.members
mail to:@members.map(&:email).join(","), subject: "アジェンダ削除の通知メール"
end
end
|
module GitP4Sync
class Sync
attr_accessor :git_path, :p4_path, :branch, :simulate, :submit, :show, :ignore, :ignore_list, :diff_files, :timestamp, :current_branch
def initialize
self.git_path = "./"
self.show = false
self.submit = false
self.simulate = false
self.ignore = nil
... |
# Change request helpers
module ChangeRequestsHelper
def change_request_class(status)
case status
when 'pending'
'danger'
when 'accepted'
'success'
else
''
end
end
end
|
def consolidate_cart(cart)
new_cart = {}
cart.each do |items_array|
items_array.each do |item, attribute_hash|
new_cart[item] ||= attribute_hash
new_cart[item][:count] ? new_cart[item][:count] += 1 :
new_cart[item][:count] = 1
end
end
new_cart
end
def apply_coupons(cart, coupons)
hash = ... |
class CreateGoods < ActiveRecord::Migration
def change
create_table :goods do |t|
t.integer :creator_id, null: false
t.integer :buyer_id, null: false, default: 0
t.integer :producer_id, null: false, default: 0
t.references :market, null: false
t.refe... |
Redis::Objects.redis = ConnectionPool.new(size: 5, timeout: 5) { Redis.new(host: SIDEKIQ_CONFIG[:redis_host], port: SIDEKIQ_CONFIG[:redis_port], db: SIDEKIQ_CONFIG[:redis_database]) } if defined?(SIDEKIQ_CONFIG)
class CheckStateMachine
include Redis::Objects
include AASM
value :state
value :message
def ini... |
module Codegrade
module Grader
class Grader
attr_reader :commit
def initialize(commit)
@commit = commit
end
def grade
offenses = []
commit_message = CommitMessage.new(@commit.message)
commit_message.grade
offenses.concat(commit_message.offenses)
... |
require 'spec_helper'
module DmtdVbmappData
describe Guide do
it 'can be created' do
client = Client.new(date_of_birth: Date.today, gender: DmtdVbmappData::GENDER_FEMALE)
expect(Guide.new(client: client)).to_not be nil
end
it 'can provide chapters' do
prev_chapters = nil
AVAIL... |
# Public: Takes an array and returns the last element.
#
# arr - The Array the gives the output.
#
# Examples
#
# last_of(1337, 2, -1)
# # => -1
#
# Returns the last element in the array.
def last_of(arr)
return arr[arr.length-1]
end |
# -*- coding: utf-8 -*-
module Smshelper
module Api
class Base
include APISmith::Client
attr_reader :sent_message_ids, :sent_message_statuses
attr_accessor :extra_options
def initialize(*args)
@sent_message_ids, @sent_message_statuses = Array.new, Hash.new
@response_code =... |
require 'rails_helper'
RSpec.describe "project_reports/show", type: :view do
before(:each) do
@project_report = assign(:project_report, ProjectReport.create!(
:project_id => "",
:status_cd => "MyText"
))
end
it "renders attributes in <p>" do
render
expect(rendered).to match(//)
e... |
class App < ActiveRecord::Base
has_many :nav_nodes, :dependent => :delete_all
def self.authenticate(code, secret)
where("code = ? AND secret = ?", code, secret).first
end
end
|
require 'thor'
class DeliveryCenter::Cli < Thor
require 'delivery_center/cli/database'
require 'delivery_center/cli/revision'
require 'delivery_center/cli/application'
desc 'db SUBCOMMAND ...ARGS', 'manage db'
subcommand 'db', DeliveryCenter::Cli::Database
desc 'revision SUBCOMMAND ...ARGS', 'manage db'
... |
require_relative '../solver'
require 'test/unit'
class TestSolver < Test::Unit::TestCase
def test_most_present_value
grid = Grid.new(4)
solver = Solver.new(grid)
assert_equal(1, solver.most_present_value)
grid[0, 0].value = 1
assert_equal(1, solver.most_present_value)
grid[0, 1].value = 1
assert_equ... |
require_relative '../test_helper'
class TaskManagerTest < Minitest::Test
####Change tests so they are not dependent on the ID
##So instead of using TaskManager.create, use Task.new and store the task
def create_tasks(num)
num.times do |x|
TaskManager.create({ :title => "task#{x+1}",
... |
require 'base64'
require_relative '../spec_helper'
require_relative '../../helpers/auth'
require_relative '../../helpers/logger'
describe 'Auth Helper' do
include Auth
include MagicLogger
attr_reader :slack_dummy, :email_dummy
def invite_to_slack(*args)
@slack_dummy.invite_to_slack(*args)
end
def em... |
class Api::V1::RegistrationsController < Devise::RegistrationsController
require 'json_web_token'
skip_before_action :verify_authenticity_token
respond_to :json
def create
user = User.new(user_params)
if user.save
# auth_token = jwt_token(user)
... |
#!/usr/bin/env ruby
###############################################################################
#
# Core Libraries
# version 1.1
#
# Written By: Ari Mizrahi
#
# Core libraries for Dvash Defense
#
###############################################################################
def random_string
# generate a buc... |
require 'rails_helper'
RSpec.describe Invite, :type => :model do
describe '#memorials' do
it 'should show me the memorial it belongs to' do
@memorial = Memorial.create(deceased_name: "John Jacob")
@invite = Invite.create(email: "ev@example.com", memorial: @memorial)
expect(@invite.memorial).to ... |
class PostsController < InheritedResources::Base
private
def post_params
params.require(:post).permit(:image, :title, :description, :date, :author)
end
end
|
class AddResourcesToMessages < ActiveRecord::Migration[5.2]
def change
add_reference :messages, :resource, polymorphic: true, index: true
end
end
|
#
# Copyright 2011 National Institute of Informatics.
#
#
# 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
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required ... |
require 'rpcoder/param'
require 'camelizer'
module RPCoder
class Type
attr_accessor :name, :description, :array_type
def fields
@fields ||= []
end
def add_field(name, type, options = {})
options[:array_type] = @array_type if options[:array_type] == nil
fields << Fiel... |
# frozen_string_literal: true
module Admin
# TemplateService
class TemplateService
def initialize(file)
@file = file
end
def name(file)
"#{file.to_s.split('/').last.split('.').first.capitalize} Template"
end
def install
clear_template
unzip_template
install_tem... |
require_relative 'test_helper'
require 'blue_hawaii/rental_unit'
require 'json'
require 'pp'
require 'bigdecimal'
describe RentalUnit do
include TestHelper
describe "#initialize" do
describe "with simple rental" do
before do
@rental_json = JSON.parse simple_rental_json
@rental_unit = R... |
# Be sure to restart your server when you modify this file.
#
# This file contains settings for ActionController::ParamsWrapper which
# is enabled by default.
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
ActiveSupport.on_load(:action_controller) do
wrap_parameters ... |
class Genre < ActiveRecord::Base
include Slugifiable::InstanceMethods
has_many :song_genres
has_many :songs, through: :song_genres
has_many :artists, through: :songs
end
|
class AddIndexToSuggestionsTable < ActiveRecord::Migration
def change
#Adding the index can massively speed up join tables.
add_index(:suggestions, [:subchapter_id, :profile_id], :unique => true)
end
end |
class Venue < ActiveRecord::Base
belongs_to :region
validates_uniqueness_of :name
validates :full_address, :region_id, presence: true
end
|
# frozen_string_literal: true
class ApplicationPlanDecorator < ApplicationDecorator
def link_to_edit(**options)
h.link_to(name, h.edit_admin_application_plan_path(self), options)
end
def link_to_applications(**options)
live_applications = cinstances.live
text = h.pluralize(live_applications.size, '... |
class RenameIcecastTitle < ActiveRecord::Migration
def self.up
rename_column :display_infos, :icecast_display, :icecast_title
end
def self.down
rename_column :display_infos, :icecast_title, :icecast_display
end
end
|
require 'test_helper'
class SessionsControllerTest < ActionController::TestCase
test "logs user in using omniauth credentials" do
@controller.env['omniauth.auth'] = OmniAuth::auth_hash
get :create
user = assigns(:user)
assert_equal '1', user.uid
assert_equal 'Ritter', user.provider
assert_r... |
module Gollum
class Site
def self.default_layout_dir()
::File.join(::File.dirname(::File.expand_path(__FILE__)), "layout")
end
attr_reader :output_path
attr_reader :layouts
attr_reader :pages
def initialize(path, options = {})
@wiki = Gollum::Wiki.new(path, {
... |
require 'rbbt/rest/common/users'
require 'rbbt/rest/common/table'
module RbbtRESTHelpers
def escape_url(url)
base, _sep, query = url.partition("?")
base = base.split("/").collect{|p| CGI.escape(p) }* "/"
if query && ! query.empty?
query = query.split("&").collect{|e| e.split("=").collect{|pe| CGI... |
Contextually.define do
roles :admin, :user, :visitor
group :admin, :user, :as => :member
before :user do
controller.stub!(:current_user).and_return(:user)
end
before :visitor do
controller.stub!(:current_user).and_return(nil)
end
before :admin do
controller.stub!(:current_user).and_ret... |
require 'rails_helper'
# Specs in this file have access to a helper object that includes
# the ReviewsHelper. For example:
#
# describe ReviewsHelper do
# describe "string concat" do
# it "concats two strings with spaces" do
# expect(helper.concat_strings("this","that")).to eq("this that")
# end
# en... |
require 'spec_helper'
describe 'pcmk_nodes_added' do
context 'interface' do
it { is_expected.not_to eq(nil) }
it { is_expected.to run.with_params(1).and_raise_error(Puppet::Error, /Got unsupported nodes input data/) }
it { is_expected.to run.with_params('foo', []).and_raise_error(Puppet::Error, /Got unsu... |
class Note < ActiveRecord::Base
attr_accessible :note, :page, :book, :user
scope :of_user, lambda { |user_id| where("user_id = ?", user_id) }
default_scope order('page, created_at')
belongs_to :book
belongs_to :user
end
|
class TagGroup < ActiveRecord::Base
validates_presence_of :name
validates_uniqueness_of :name
has_many :company_tag_groups
has_many :companies, :through => :company_tag_groups, :after_add => :after_add_company, :after_remove => :after_remove_company
named_sco... |
# Method to create a list
# input: string of items separated by spaces (example: "carrots apples cereal pizza")
# steps:
# Create a hash with items and associated quantities.
# set default quantity
# print the list to the console using print method
# output: hash
def create_a_list(items)
item_array = items.s... |
# frozen_string_literal: true
require 'spec_helper'
describe PagerdutyRestApi::HttpTransport do
describe '#get' do
let(:faraday) { instance_double(Faraday::Connection).as_null_object }
before do
allow(Faraday).to receive(:new).with(url: 'https://api.pagerduty.com')
.and_yield(faraday)
... |
class ChangeJobsV2 < ActiveRecord::Migration[5.0]
def change
change_column :jobs, :description, :text, default: nil
change_column :jobs, :field, :integer, default: 0
end
end
|
require_relative '../spec_helper'
require "./app/services/text_sampler"
describe TextSampler, type: :service do
sampler = TextSampler.new
it 'sample a random file' do
expect(sampler.randomize_file.file).not_to be_nil
expect(sampler.randomize_file.file.class).to eql File
expect(sampler.randomize_file.... |
require "spec_helper"
describe M::Either do
it_behaves_like "a monad"
describe "shortcut methods" do
it "Right() is a shortcut to Right.return" do
expect(Right(1)).to eq Right.return(1)
expect(Right("1")).to eq Right.return("1")
expect(Right(nil)).to eq Right.return(nil)
end
it "L... |
user = node['ubuntu_i3-gaps_workstation']['user']
i3_repo_path = "#{node['ubuntu_i3-gaps_workstation']['tmp_dir']}/i3-gaps"
# Install required packages listed here: https://github.com/Airblader/i3/wiki/Compiling-&-Installing#1610-
%w[
libxcb1-dev
libxcb-keysyms1-dev
libpango1.0-dev
libxcb-util0-dev
libxcb-ic... |
class User < ApplicationRecord
include Name
require 'open-uri'
belongs_to :host, -> {where(visible: true)}, counter_cache: true, optional: true
belongs_to :seat, optional:true
belongs_to :game, optional: true
belongs_to :mod, optional: true
has_many :api_keys
has_many :identities, -> {where(enabled: tr... |
class AddLocationToTapiocas < ActiveRecord::Migration
def change
change_table :tapiocas do |t|
t.string :location
end
end
end
|
module CheckArchivedFlags
class FlagCodes
def self.archived_codes
{
"NONE" => NONE,
"TRASHED" => TRASHED,
"UNCONFIRMED" => UNCONFIRMED,
"PENDING_SIMILARITY_ANALYSIS" => PENDING_SIMILARITY_ANALYSIS,
"SPAM" => SPAM
}
end
NONE = 0 # Default, means that the ... |
class CreateReadingWorker
include Sidekiq::Worker
sidekiq_options queue: 'critical'
def perform(thermostat_id, household_token, reading_params = {})
reading_params = eval(reading_params)
reading = Reading.create(reading_params.merge(thermostat_id: thermostat_id))
if !reading.blank? && !household_to... |
class CreateEasySettings < ActiveRecord::Migration
def self.up
create_table :easy_settings do |t|
t.string :name
t.text :value
t.integer :project_id
end
end
def self.down
drop_table :easy_settings
end
end |
require "minitest_helper"
feature "Create list" do
scenario "adding a new list" do
# Given
visit lists_path
click_on "New List"
fill_in "List name", with: "Personal To Do List"
# When
click_on "Create List"
# Then
page.text.must_include "List was successfully created"
page.text.mu... |
class Discussion < ActiveRecord::Base
validates :summary, presence: true
validates :article, presence: true
belongs_to :article, inverse_of: :discussions
belongs_to(
:source_discussion,
class_name: "Discussion",
primary_key: :id,
foreign_key: :branched_from_discussion_id,
inverse_of: :bran... |
require 'rails_helper'
RSpec.describe QuestionsController, type: :controller do
describe 'GET #index' do
let(:questions){FactoryGirl.create_list(:question,2)}
before { get :index }
it 'populates array of all Q' do
expect(assigns(:questions)).to match_array(questions)
end
it 'renders ... |
Rails.application.routes.draw do
devise_for :users
root 'shows#index'
resource :shows
patch 'shows/edit'
end
|
apiconfig = YAML.load(File.open(Rails.root.to_s + "/config/apiconfig.yml"))
TweetStream.configure do |config|
config.consumer_key = apiconfig["twitter"]["citore"]["consumer_key"]
config.consumer_secret = apiconfig["twitter"]["citore"]["consumer_secret"]
config.oauth_token = apiconfig["twitter"]["c... |
require 'rails_helper'
RSpec.describe "contents/new", type: :view do
before(:each) do
assign(:content, Content.new(
:userid => 1,
:post => "MyText"
))
end
it "renders new content form" do
render
assert_select "form[action=?][method=?]", contents_path, "post" do
assert_select ... |
module ProjectRazor
module PolicyTemplate
# ProjectRazor Policy Default class
# Used for default booting of Razor MK
class BootMK < ProjectRazor::PolicyTemplate::Base
include(ProjectRazor::Logging)
# @param hash [Hash]
def initialize(hash)
super(nil)
@hidden = :true
... |
# encoding: utf-8
class SessionsController < ApplicationController
skip_before_filter :check_login
before_filter :filter_login
def new
@hide_footer = true
end
def create
@hide_footer = true
auth = request.env["omniauth.auth"]
if (User.find_by_provider_and_uid(auth["provider"], auth["uid"]))... |
require 'rails_helper'
RSpec.describe User, type: :model do
it "is valid with a name, email, password and admin" do
user= User.new(name: "name", email: "test@e.mail", password: "password", admin: false)
expect(user).to be_valid
end
it "is invalid without a name" do
user= User.new(email: "test@e.mail... |
class Machine < ApplicationRecord
has_one :desk, dependent: :nullify
has_many :assignment_histories, class_name: 'DeskAssignmentHistory', dependent: :nullify
validates :mac, presence: true
def mac=(value)
write_attribute(:mac, normalize_mac(value))
end
def normalize_mac(value)
value.gsub(/:/, '')... |
require 'fileutils'
module ActiveFile
def save
@new_record = false
File.open("db/revistas/#{@id}.yml", "w") do |file|
file.puts serialize
end
end
def destroy
unless @destroy or @new_record
@destroyed = true
FileUtils.rm "db/revistas/#{@id}.yml"
end
end
module ClassMethods
def find(id)
ra... |
class NotHexError < StandardError
def initialize(msg="Please input a valid hexadecimal value. Value should be between 3-6 digits.")
super(msg)
end
end
|
module Sandra
class SuperColumnValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
if record.attributes[attribute.to_s].nil?
record.errors[attribute] << "#{attribute.to_s} cannot be nil."
else
record.errors[attribute] << "#{record.send(attribute.to_s)} has been taken u... |
class Valllnparam < ApplicationRecord
belongs_to :mpoint, inverse_of: :valllnparams
belongs_to :line, inverse_of: :valllnparams
end
|
require_relative 'spec_helper'
describe 'API Spec' do
subject(:api) {
Hyperclient.new(api_root)
}
it 'return a HAL API description' do
expect(api._response.status).to eql(HTTP_OK)
expect(api._response[:content_type]).to eql(HAL)
end
it 'does not contain embedded entities' do
expect... |
class ParticipantsController < ApplicationController
before_action :authenticate_user!
def index
@people = Participant.all
@search = Participant.search(params[:q])
@participants = @search.result.page(params[:page])
@search.build_condition
# if @search.nil?
# respond_to do |format|
# format.htm... |
class AddServiceToShippingMethods < ActiveRecord::Migration
def change
add_column :shipping_methods, :service, :string
end
end
|
require 'ecraft/extensions/mixins/hashable'
module Ecraft
module Extensions
module Mixins
describe Hashable do
let(:klass) {
Class.new do
include Hashable
end
}
subject do
klass.new
end
let(:array_test_data) {
[''... |
class Account < ApplicationRecord
belongs_to :account_type
belongs_to :account_sheet
end
|
require 'rubygems'
require 'bundler'
begin
Bundler.setup(:default, :development)
rescue Bundler::BundlerError => e
$stderr.puts e.message
$stderr.puts "Run `bundle install` to install missing gems"
exit e.status_code
end
require 'rack'
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec) do |spec|... |
dir = File.dirname(__FILE__)
require "#{dir}/../spec_helper"
describe Gallery::Generator do
attr_reader :generator
before do
fixtures_path = "#{dir}/../fixtures"
@generator = Gallery::Generator.new(fixtures_path)
end
describe "#generate" do
it "takes a recipe and returns an index page based on... |
first_name = "Romeo"
last_name = "Enso"
#string interpolation
puts "My name is #{first_name} #{last_name}"
#escaping single quites
puts 'Hey Romeo, Joy said \'How are you doing?\''
puts first_name.length
#get input from user in terminal
puts "Enter your first name: "
first_name = gets.chomp
puts "Enter your last ... |
NUMBER_OF_ALLELES = 100
NUMBER_OF_PHYSICAL_GENES = 7
NUMBER_OF_ANIMALS = 100
NUMBER_OF_SPECIES = 3
NUMBER_OF_GENERATIONS = 5
GENERATION_DURATION = 3
STARTING_PLANTS = 1000
STARTING_INSECTS = 1000
STARTING_FISH = 1000
|
# frozen_string_literal: true
class ReactionsController < ApplicationController
layout 'internal'
before_action :authenticate_user!
before_action :block_crossprofile_access
before_action :recover_profile
def index
@reactions = @profile.reactions
end
def new; end
def edit
@reaction = React... |
# -*- encoding: utf-8 -*-
# stub: nakayoshi_fork 0.0.4 ruby lib
Gem::Specification.new do |s|
s.name = "nakayoshi_fork".freeze
s.version = "0.0.4"
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
s.require_paths = ["lib".freeze]
s.authors = ["Koi... |
FactoryGirl.define do
factory :user do
name 'anonmimous' # default values
email 'unkown@xyz.com'
#release_date { 10. years.ago }
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).
# # #
# # # Account roles
Role.create(:role_name => 'Administrator') #role_ids: 1
Role.create(:role_nam... |
class DiariesController < ApplicationController
def index
@user = User.find(current_user)
@diaries = current_user.diaries.order(id: :desc)
end
def new
@user = User.find(current_user.id)
@diary = Diary.new
end
def create
@diary = Diary.new(diary_params)
if @diary.save
redirect_t... |
# frozen_string_literal: true
# Configure Rails Envinronment
ENV['RAILS_ENV'] = 'test'
CI_ORM = (ENV['CI_ORM'] || :active_record).to_sym
CI_TARGET_ORMS = %i[active_record mongoid].freeze
PK_COLUMN = {active_record: :id, mongoid: :_id}[CI_ORM]
if RUBY_ENGINE == 'jruby'
# Workaround for JRuby CI failure https://githu... |
# frozen_string_literal: true
module EventRegistrationHelper
def event_registration_link(event)
event.registration_url.presence || new_event_registration_path(event_invitee: { event_id: event.id })
end
def event_registration_target(event)
"event_#{event.id}" if event.registration_url
end
end
|
require 'spec_helper'
require_relative '../monad_axioms'
include Deterministic
describe Deterministic::Success do
it_behaves_like 'a Monad' do
let(:monad) { described_class }
end
subject { described_class.new(1) }
specify { expect(subject).to be_an_instance_of described_class }
specify { expect(subj... |
Factory.define :admin_image, :class => Admin::Image do |f|
f.image_file_name "featured-contributor.png"
f.image_content_type "image/png"
f.image_file_size 64.kilobytes
f.cobrand { Cobrand.root }
end
Factory.define :question do |f|
f.asking_text "this is the question asking text"
end
Factory.defin... |
module Extensions
module Parameterizable
def with(*fields)
define_getters_for fields
define_initializer_for fields
block_child_initializers
end
private
def define_getters_for(fields)
self.class_eval do
attr_reader *Array(fields)
end
end
def define_initia... |
FactoryGirl.define do
factory :collage_image, class: CollageImage do
association :collage, factory: :collage
# picture "picture"
picture_file_name 'picture.jpg'
picture_content_type 'image/jpeg'
picture_file_size 1.megabyte
order 1
end
end
|
require 'flex_trans/mapper'
RSpec.describe FlexTrans::Mapper do
it 'has the mapping attributes' do
mapper = FlexTrans::Mapper.mapping_attributes(:id, :name, :price)
expect(mapper.current_mapping_attributes).to eq [:id, :name, :price]
end
it 'has the mapping type' do
Product = Struct.new(:id, :name, ... |
class Load
class << self
attr_accessor :item_storage
end
self.item_storage = []
def self.start
puts "*loading files..."; puts ""
require_relative "load"
require_relative "conv/array"
require_relative "app/item"
require_relative "app/cart"
require_relative "app/order"
require_relative "app/menu"
... |
#!/opt/local/bin/ruby
require 'find'
require 'fileutils'
$invalid_characters = "[]{}()=+-',"
def has_invalid_chacters(path)
if path.index(' ') != nil
return true
end
$invalid_characters.each_byte do |c|
if path.index(c.chr) != nil
return true
end
end
return ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.