text stringlengths 10 2.61M |
|---|
class AddHeadlinePointsToIntervention < ActiveRecord::Migration[5.2]
def change
add_column :interventions, :headline_points, :string, array: true, default: []
end
end
|
class AddColumnsToBeer < ActiveRecord::Migration[6.0]
def change
add_column :beers, :brewery, :string
add_column :beers, :origin, :string
add_column :beers, :style, :string
add_column :beers, :abv, :integer
end
end
|
class CreateMatches < ActiveRecord::Migration
def change
create_table :matches do |t|
t.integer :match_id # Match ID, primary key
t.integer :team_1 # ID of team 1, foreign key into the teams model.
t.integer :team_2 # ID of team 2, foreign key into the teams model.
t.integer :t... |
module ActiveStorage
# Extracts the following from a video blob:
#
# * Width (pixels)
# * Height (pixels)
# * Duration (seconds)
# * Aspect ratio
#
# Example:
#
# ActiveStorage::Analyzer::QiniuVideoAnalyzer.new(blob).metadata
# # => {:width=>240, :height=>240, :duration=>"2.000000", :aspect_ra... |
namespace :staticman do
desc "Write static page in public"
task :build => :environment do
require Rails.root.join('config/staticman')
pages = Staticman.config.static_pages
pages.each do |page|
proxy = Staticman::Performer.new
proxy.build page
end
end
desc "Destory static page in p... |
require "#{File.expand_path(File.dirname(__FILE__))}/helper.rb"
require "thread"
class TestThreads < Test::Unit::TestCase
def test_each_thread_gets_its_own_connection
threads = []
queue = Queue.new
2.times do
threads << Thread.new do
t = TestClass.new
t.retrieve :nothing => nil
... |
class Admin::RoomsController < AdminController
before_action :load_room_by_id, only: %i(destroy edit update)
before_action :load_type_view_room
load_and_authorize_resource
def index
@rooms = Room.all
if params[:filter].blank?
@rooms = @rooms.created_at
.page(params[:page])
... |
require 'json'
require 'eb_ruby_client/exceptions'
module EbRubyClient
class Connection
attr_reader :base_url, :auth_token
def initialize(configuration:)
@base_url = configuration.base_url
@auth_token = configuration.auth_token
end
def get(path)
send_request(full_path_for(path)) ... |
require 'stringio'
require './monkey'
require './util'
require './scripts'
TEXT_HTML = 'text/html; charset=utf-8'.fz
TEXT_PLAIN = 'text/plain; charset=utf-8'.fz
IDENTITY = 'identity'.fz
CHUNKED = 'chunked'.fz
module Page
def call env, **kwarg
log_self
body = []
length = 0
headers = {}
env[STA... |
require "./lib/checkout.rb"
describe Checkout do
describe "Check with both promos" do
subject(:co1) {Checkout.new({promos:{promo1:true,promo2:true}})}
subject(:co2) {Checkout.new({promos:{promo1:true,promo2:false}})}
subject(:co3) {Checkout.new({promos:{promo1:false,promo2:true}})}
s... |
module OpenAPIRest
###
# Api doc parser based on OpenAPI 2.0 specs
#
class ApiDocParser
attr_reader :method
attr_reader :document
def initialize(openapi_path)
@document = OpenAPIRest::ApiDoc.document
@route = openapi_path[:path]
@method = openapi_path[:method]
@method = 'pat... |
# frozen_string_literal: true
ActiveAdmin.register Printer do
permit_params :user_id, :printer_model_id, :name
form do |f|
f.inputs do
f.input :name
f.input :user
f.input :printer_model
end
f.actions
end
end
|
class PartnersController < ApplicationController
def index
@partners = Partner.visible.order("position ASC")
end
def show
partner = Partner.find(params[:id])
impressionist(partner)
redirect_to "http://#{partner.link}"
end
def body_class
"post-template"
end
end
|
class Profile < ActiveRecord::Base
attr_accessible :name, :logo, :link, :gender, :birthday
belongs_to :user
validates :name, presence: true
validates :link, presence: true
validates :birthday, presence: true
validates_date :birthday, before: lambda { 18.years.ago },
... |
module Api
module V1
class BeersController < ApplicationController
before_action :set_beer, only: [:show, :update, :destroy]
def index
@beers = Beer.all
render json: @beers
end
def show
render json: @beer
end
def create
@beer = Beer.new(beer_p... |
require 'spec_helper'
describe DataVeillance::Helpers::MoneyHelpers do
class TestClass
include DataVeillance::Helpers::MoneyHelpers
end
it 'should convert currency correctly' do
result = TestClass.new.to_money('6.123,45 €')
result.cents.should == 612345
result.currency.iso_code.should == 'EUR'
... |
IntoverseApp::Application.routes.draw do
# The priority is based upon order of creation:
# first created -> highest priority.
# Sample resource route (maps HTTP verbs to controller actions automatically):
# resources :products
root to: 'homepages#index'
match '/results' => 'homepages#results', :via => :get
... |
require_relative "../lib/calculator.rb"
describe Calculator do
before do
@calc = Calculator.new
end
describe "#add_number" do
it "should take two parameters and add them together" do
expect(@calc.add_number(1, 23)).to eql(24)
end
it "should add 4 + 4" do
expect(@calc.add_number(4,4... |
Given /^Sphinx is offline$/ do
::ThinkingSphinx::Test.stop
end
When /^I search for "([^"]*)"$/ do |query|
step %(I fill in "query" with "#{query}")
within(".operations") do
step %(I press "Search")
end
end
When /^I search for:$/ do |table|
within ".search" do
table.map_headers! {|header| header.pa... |
@user =nil
Given(/^I visit "(.*?)" page$/) do |arg1|
@user = FactoryGirl.create(:admin)
visit arg1
end
When(/^I enter "(.*?)" in the "(.*?)" field$/) do |arg1, arg2|
fill_in arg2, :with => arg1
end
When(/^I press the "(.*?)" button$/) do |arg1|
click_button arg1
end
Then(/^I should see the "(.*?)" page$/) do ... |
class ReleaserDemo < Formula
desc "Releaser Demo Application"
homepage "https://redislabs.com/releaser-demo"
version "0.0.2"
url "https://github.com/jruaux/releaser-demo/releases/download/v0.0.2/releaser-demo-0.0.2.zip"
sha256 "64b19cc203193fdfa23ae7635e1cc25ea7d1c2602154bbac23d822f0559765fe"
license "Apach... |
require 'spec_helper'
describe "LinkTests" do
describe "GET /sw_project_customer_qnax_link_tests" do
mini_btn = 'btn btn-mini '
ActionView::CompiledTemplates::BUTTONS_CLS =
{'default' => 'btn',
'mini-default' => mini_btn + 'btn',
'action' => 'btn btn-primary',
'mini-a... |
require 'rails_helper'
RSpec.describe Petition, type: :model do
it { should belong_to(:state) }
it { should have_many(:memberships) }
it { should have_many(:users) }
it { should validate_presence_of(:name) }
it { should validate_presence_of(:description) }
end
|
# encoding: utf-8
# (C) 2015 Muthiah Annamalai <ezhillang@gmail.com>
class AssertionError < RuntimeError
end
def assert &block
raise AssertionError unless yield
end
module Tamil
## constants
TA_ACCENT_LEN = 13 #12 + 1
TA_AYUDHA_LEN = 1
TA_UYIR_LEN = 12
TA_MEI_LEN = 18
TA_A... |
class AddDriverLocation < ActiveRecord::Migration[5.1]
def change
add_reference :fleets, :driver, foreign: true
add_column :drivers, :location, :string
end
end
|
Rails.application.routes.draw do
resources :comments
devise_for :users
root 'posts#index'
get 'unauthorized' => 'posts#unauthorized'
resources :posts
resources :users
end
|
class AddPaidAtToProducts < ActiveRecord::Migration
def change
add_column :products, :paid_at, :datetime
end
end
|
require File.expand_path(File.join(File.dirname(__FILE__), *%w[.. .. spec_helper]))
describe '/services/index' do
before :each do
assigns[:services] = @services = Array.new(3) { Service.generate! }
end
def do_render
render '/services/index'
end
it 'should show a summary for each service' do
@se... |
class Order < ActiveRecord::Base
belongs_to :user
has_many :order_items
has_many :items, through: :order_items
before_create :create_from_cart
enum status: %w(ordered paid cancelled completed)
attr_accessor :cart_data
def total
order_items.inject(0) do |subtotal, order_item|
subtotal + (orde... |
class UsersController < ApplicationController
before_filter :authenticate_user!, :search
def index
@users = User.order("email ASC")
end
def new
@user = User.new
end
def create
@user = User.new(params[:user])
if @user.save
redirect_to(users_path, notice: 'User was successfully created.')
else
r... |
helpers do
def username
session[ :identity ] ? 'Hello ' + session[ :identity ] : 'Hello stranger'
end
def simstate
'<a href="/simulation">' + simstate_text + '</a>'
end
def can_configure?
@snapshot.state.nil? || @snapshot.aborted?
end
def can_simulate?
@snapshot.created?
end
def can_simulate_pa... |
require "rspec/autorun"
TracePoint.new(:end) do |tp|
klass = tp.self
if defined?(Minitest) &&
defined?(Minitest::Test) &&
klass != Minitest::Test &&
klass.ancestors.include?(Minitest::Test)
klass.generate_rspec_tests
end
end.enable
module Assertions
def assert_equal(a, b)
expect(a).... |
class Candy
attr_reader :candy, :sugar_level
def initialize(candy, sugar_level = 0)
@candy = candy
@sugar_level = sugar_level
end
def type
candy
end
end
|
class Chapter
require 'redcarpet/render_strip'
attr_accessor :bid, :pid, :sid, :suid, :cid
include Mongoid::Document
include Mongoid::Slug
field :chap, as: :chapter
field :t, as: :title
field :alt, as: :alt_title
field :subt, as: :subtitle
field :desc, as: :description
field :no, type: Integer
f... |
require 'spec_helper'
describe "/notifiers/index.html.erb" do
include NotifiersHelper
before(:each) do
assigns[:notifiers] = [
stub_model(Notifier,
:url => "value for url"
),
stub_model(Notifier,
:url => "value for url"
)
]
end
it "renders a list of notifiers" ... |
class MicrocosmsController < ApplicationController
before_action :set_microcosm, only: [:show, :show_editors, :show_changesets, :show_organizers, :show_members, :edit, :update, :destroy, :welcome_editor, :welcome_editor_form]
before_action :set_microcosm_by_key, only: [:show_by_key]
before_action :authenticate, :... |
require 'zlib'
# @private Implements the +write+ method for strings, used with zlib to
# use GZStrings as the target for compression.
class GZString < String
alias write <<
end
|
require 'spec_helper'
class TestPageWithElement
extend SPV::Mixins::Element
class << self
def element(*); end
end
def test_el1; end
def test_el2
'original element'
end
link_vcr_with_element :test_el2
end
describe SPV::Mixins::Element do
describe '.element_with_vcr' do
subject do
T... |
class Comment < ApplicationRecord
belongs_to :gossip
belongs_to :user
validates :content, length: { minimum: 3 }
end
|
module Spider
class Proxy < Struct.new(:host, :port, :user, :password)
DEFAULT_PORT = 8080
def initialize(attributes={})
super(
attributes[:host],
attributes.fetch(:port,DEFAULT_PORT),
attributes[:user],
attributes[:password]
)
end... |
Types::VTDomainType = GraphQL::ObjectType.define do
name "VTDomain"
field :hostname, types.String, hash_key: 'hostname'
field :last_resolved, types.String, hash_key: 'last_resolved'
field :whois, types.String, hash_key: 'whois'
field :whois_timestamp, types.String, hash_key: 'whois_timestamp'
... |
require 'benchmark'
namespace :benchmark do
task :setup do
ENV['ITERATIONS'] ||= '100000'
end
desc 'Benchmark Yeah::Vector'
task :vector => :setup do |task|
require 'yeah/vector'
Benchmark.bm(10) do |bm|
iterations = ENV['ITERATIONS'].to_i
a = Yeah::Vector.new(10, 20, 30)
b = Ye... |
require 'spec_helper'
describe Subscription do
let(:plan) { FactoryGirl.create :volume_plan }
subject { Subscription.create account_id:10, plan_id: plan.id }
describe '#use' do
it 'updates the usage' do
# TODO: Not sure why the following is throwing an error
# expect { subject.use 10 }.to change... |
require 'test_helper'
class InvigilatorsControllerTest < ActionDispatch::IntegrationTest
setup do
@invigilator = invigilators(:one)
end
test "should get index" do
get invigilators_url
assert_response :success
end
test "should get new" do
get new_invigilator_url
assert_response :success
... |
class PharmItemsController < ApplicationController
before_action :set_pharm_item, only: [:show, :edit, :update, :destroy]
def index
@pharm_items = PharmItem.all
new
respond_to do |format|
format.html
format.xlsx
end
end
def new
@pharm_item = PharmItem.new
@pharm_i... |
# frozen_string_literal: true
# == Schema Information
#
# Table name: events
#
# attendance_limit :bigint(8)
# city :string(255) not null
# country :string(255) not null
# created_at :timestamptz not null
# days_to_charge ... |
class LatexResumeController < ApplicationController
@@source_tex_file = "config/resume.tex"
def index
end
def source
root_dir = 'public/tmp/src'
public_file = File.join( root_dir, 'resume_source' )
FileUtils.mkdir_p( root_dir )
FileUtils.cp( @@source_tex_file, public_file )
# dont need the 'public'... |
class RefreshStripeCacheJob < ApplicationJob
queue_as :default
def perform(user_id)
user = User.find_by(id: user_id)
if user
StripeCache.new(user).refresh
end
end
end
|
class Bear
attr_reader :name, :type
def initialize(name, type)
@name = name
@type = type
@stomach = []
end
def bear_name()
return @bear.name()
end
def bear_type()
return @bear.type()
end
def food_count()
@stomach.length()
end
def put_fish(fish_name)
@stomach.p... |
require 'rails_helper'
RSpec.describe Job, type: :model do
it {should belong_to :user}
it "creates a new job" do
user = FactoryGirl.create(:user)
job = FactoryGirl.create(:job)
expect(Job.all).to include job
end
end
|
require 'rails_helper'
describe Role do
describe 'associations' do
describe 'has_many association' do
it { should have_and_belong_to_many(:users) }
end
describe 'belongs_to' do
it { should belong_to(:resource) }
end
end
end
|
# encoding: UTF-8
# Plugin Definition file
# The purpose of this file is to declare to InSpec what plugin_types (capabilities)
# are included in this plugin, and provide hooks that will load them as needed.
# It is important that this file load successfully and *quickly*.
# Your plugin's functionality may never be us... |
class DashboardController < ApplicationController
def index
@filters = Rails.cache.fetch("/current_user/#{current_user.role.name}/filters", expires_in: 1.day) do
current_user.filters('dashboard')
end
end
end
|
class AddAssociationBetweenReportAndPlannedDisbursements < ActiveRecord::Migration[6.0]
def change
add_reference :planned_disbursements, :report, type: :uuid
end
end
|
class VarsController < ApplicationController
# GET /vars
# GET /vars.json
def index
@vars = Var.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @vars }
end
end
# GET /vars/1
# GET /vars/1.json
def show
@var = Var.find(params[:id])
respo... |
require 'rails_helper'
RSpec.describe CreateGameRoomService do
describe '.create_new_game_room_with_player' do
context 'if there was an error in the creation of the game room' do
it 'returns the appropriate error hash' do
GameRoom.create_game_room('house')
h = CreateGameRoomService.... |
# frozen_string_literal: true
require 'rails_helper'
require 'date'
RSpec.describe Pressure, type: :model do
describe 'Associations' do
it { should belong_to :profile }
end
describe 'Validations' do
before do
@existing_profile = FactoryBot.create :profile, email: 'joao@example.org'
end
i... |
class AnnotationsController < ApplicationController
respond_to :json
def create
a = Annotation.create(annotation_params)
respond_with a, status: :ok
end
private
def annotation_params
params.require(:annotation).permit(:name, :canonical_name, :role, :role_translation, :role_language, :commen... |
#!/usr/bin/env ruby
# frozen_string_literal: true
# Created by Paul A. Gureghian in May 2020. #
# This Ruby script demos control flow in Ruby. #
# Start of script. #
# Prompt for input. #
print "Integer please: \n"
user_num = Integer(gets.chomp)
if user_num < 0
puts 'Negative integer was inputed'
elsif user_num ... |
class AddCreatorIdToHats < ActiveRecord::Migration[5.2]
def change
add_column :hats, :creator_id, :integer
end
end
|
require 'drb'
module RestAssured
module Utils
module DrbSniffer
def running_in_spork?
defined?(Spork) && Spork.using_spork?
end
end
end
end
|
class RegistrationVC < UITableViewController
POSTMARK_API_KEY = "7d4a30d7-4ed1-4130-9b2b-8caa14831987"
Fields = [
[t("name_field"), t("name_placeholder"), :name],
[t("city_field"), t("city_placeholder"), :location],
[t("zip_field"), t("zip_placeholder"), :zipcode],
[t("email_field"), t("email... |
require_relative "piece.rb"
require_relative 'starting_pieces'
require 'colorize'
class Board
attr_reader :grid
def self.create_default_board
grid = Array.new(8) { Array.new(8) }
(0..7).each do |row|
(0..7).each do |col|
if BLACK_PIECES.key?([row, col])
current_piece = Piece.new(BLA... |
require 'rails_helper'
RSpec.describe ArticlePresenter do
describe '#title' do
context 'when article is sticky' do
let(:article) { FactoryBot.build(:article, is_sticky: true).presenter }
it 'includes "Sticky" in the beginning of title' do
expect(article.title).to match(/Sticky: /)
end
... |
class DocumentParanoid
include Mongoid::Document
# slug, then paranoia
include Mongoid::Slug
include Paranoid.new
field :title
slug :title
end
|
#!/usr/bin/env ruby
# Copyright (c) 2006-2007, The RubyCocoa Project.
# All Rights Reserved.
#
# RubyCocoa is free software, covered under either the Ruby's license or the
# LGPL. See the COPYRIGHT file for more information.
require 'rbconfig'
def show_options
puts "Usage:"
puts " #{__FILE__} build [options] <o... |
class CreateSoliderQueues < ActiveRecord::Migration
def change
create_table :solider_queues do |t|
t.integer :city_id
t.integer :solider_num
t.integer :solider_kind
t.integer :status, :default => 0
t.timestamps
end
end
end
|
# TODO: single, multi -> 引数で切り替え 、default value
# TODO: jws!
# TODO: sample web app making
# String extensions
module StringExtension
refine String do
# Combine strings by dot(.).
#
# @example
# "sample".dot("is_test") => "sample.is_test"
def dot(str)
self + "." + str
end
... |
describe "a position" do
class ::Object
def in?(collection)
collection.include? self
end
end
def next_state(opts)
if(opts[:neighbours].in? 2..3)
:alive
elsif(opts[:neighbours] == 1)
:dead
end
end
context "with 2 live neighbours" do
it "is alive in the next iterati... |
module Ruboty
module Handlers
class Gekiron < Base
on(
/topic|gekiron|激論/,
name: 'topic',
description: '激論しそうな話題を返します',
)
on(
/gekiron/,
name: 'topic',
description: '激論しそうな話題を返します',
all: true
)
def topic(message)
Rubot... |
# https://www.codewars.com/kata/541c8630095125aba6000c00
def digital_root(n)
loop do
n = n.to_s.chars.map(&:to_i).reduce(:+)
break n if n < 10
end
end
|
require 'spec_helper'
describe 'log in' do
before { visit root_path }
subject { page }
describe 'should be able to login' do
before do
user = FactoryGirl.create (:user)
fill_in 'username', with: user.username
fill_in 'password', with: user.password
click_on 'Login'
end
it { should have_link 'Lo... |
class Api::V1::RoadtripsController < ApplicationController
def new
if !params[:api_key] || User.find_by(api_key: params[:api_key]) == nil
render status: :unauthorized, body: 'Unauthorized'
else
facade = RoadtripFacade.new(params[:origin], params[:destination])
serialized = RoadtripSerialize... |
require 'spec_helper'
describe Pacer::YamlEncoder do
let(:original) do
{ :string => ' bob ',
:symbol => :abba,
:empty => '',
:integer => 121,
:float => 100.001,
:time => Time.utc(1999, 11, 9, 9, 9, 1),
:object => { :a => 1, 1 => :a },
:set => Set[1, 2, 3],
:nested_... |
#
# Cookbook Name:: wal-e
# Recipe:: default
include_recipe 'apt'
# install packages
unless node[:wal_e][:packages].nil?
node[:wal_e][:packages].each do |pkg|
package pkg
end
end
# install python modules with pip unless overriden
unless node[:wal_e][:pips].nil?
include_recipe "python::pip"
node[:wal_e][:... |
class DeckSerializer < ActiveModel::Serializer
attributes :id, :name,:description, :card_ids, :collection_id
end |
class Show < ActiveRecord::Base
require 'figaro'
has_many :trackings
has_many :users, through: :trackings
attr_accessible :title, :last_episode, :last_title, :last_airdate, :next_episode, :next_title, :next_airdate, :status, :airtime, :banner
scope :active?
def ended_statuses
["Ended", "Canceled/End... |
module Jshint
module Cli
def self.run(reporter_name = :Default, result_file = nil, config_path = nil)
linter = Jshint::Lint.new(config_path)
linter.lint
reporter = Jshint::Reporters.const_get(reporter_name).new(linter.errors)
printer = lambda do |stream|
stream.puts reporter.repor... |
require "spec_helper"
describe "vim for cython" do
before(:all) {
vim.command "new"
vim.command "set ft=cython"
vim.command("set indentexpr?").should include "GetPythonPEPIndent("
}
before(:each) {
# clear buffer
vim.normal 'gg"_dG'
# Insert two blank lines.
# The first line is a cor... |
class BlocksController < ApplicationController
before_action :set_block, only: [ :update, :destroy]
# POST /blocks
def create
@block = Block.new(block_params)
if @block.save
render json: @block, status: :created, location: @block
else
render json: @block.errors, status: :unprocessable_en... |
class CreateWebpages < ActiveRecord::Migration
def change
create_table :webpages do |t|
t.string :unid
t.string :url
t.string :content
t.timestamps
end
end
end
|
# frozen_string_literal: true
describe RegistrationPeriodsController, type: :controller do
context 'unauthenticated' do
describe 'GET #new' do
before { get :new, params: { event_id: 'foo' } }
it { expect(response).to redirect_to new_user_session_path }
end
describe 'POST #create' do
b... |
class MicropostsController < ApplicationController
def index_food
@food = Micropost.new
@foods = Micropost.where(category: "食事").order(id: :desc).page(params[:page]).per(5)
end
def index_live
@live = Micropost.new
@lives = Micropost.where(category: "棲み家").order(id: :desc).page(params[:page])... |
ActiveAdmin.register ApiKey do
# See permitted parameters documentation:
# https://github.com/activeadmin/activeadmin/blob/master/docs/2-resource-customization.md#setting-up-strong-parameters
#
# permit_params :list, :of, :attributes, :on, :model
#
# or
#
# permit_params do
# permitted = [:permitted... |
class ResourceCompletionController < ApplicationController
before_action :private_access
def create
@resource = Resource.friendly.find(params[:resource_id])
@subject = @resource.subject
if @resource.resource_completions.where(user: current_user).blank?
@resource.resource_completions.create(user_i... |
# method to check for equality
def assert_equal(expected, actual)
raise "Expected #{expected} to match #{actual}" unless expected == actual
end
# Write a program that prints the numbers from 1 to 100.
# But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”.
# For ... |
require 'objectively/message'
require 'objectively/edge'
module Objectively
class Diagram
def self.draw(output:, &block)
new
.trace(&block)
.draw(output: output)
end
def trace(&_block)
require 'binding_of_caller'
trace = TracePoint.trace(:call) do |tp|
messages ... |
#!/usr/bin/env ruby
require 'rexml/document'
class String
def uncapitalize
self[0, 1].downcase + self[1..-1]
end
end
class QualityGenerator
def initialize(doc)
@doc = doc
@qif = doc.elements['//QIFDocument']
@devices = {}
@product = nil
end
Device = Struct.new(:accuracy, :descript... |
#!/usr/bin/env ruby
#
# Vertically aligns multiple columns, which are
# delimited by a user-defined regular expression,
# that are present in the input given on STDIN.
#
# For example, the following input:
#
# short text = foo = hello
# really long text = bar = world
# wide operator <=> moz ... |
module Yt
module Associations
# @private
# Provides methods to access the analytics reports of a resource.
module HasReports
# @!macro [new] reports
# Returns the reports for the given metrics grouped by the given dimension.
# @!method reports(options = {})
# @param [Hash] op... |
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :invitable, :database_authenticatable, :registerable, :confirmable,
:recoverable, :rememberable, :trackable, :validatable
enum role: [:user, :worship_... |
module HelperMethods
def titleize(str)
strArr = str.downcase.split(" ") # split the string into an array containing each word. Now loop through array and Capitalize as necesary
arr = []
strArr.each do |word|
if ((word == "in") || (word == "the") || (word == "of") || (word == "and") || (word == "or"... |
class A2200
attr_reader :options, :name, :field_type, :node
def initialize
@name = "Previous Assessment Reference Date for Significant Correction (format = yyyymmdd) (A2200)"
@field_type = TEXT
@node = "A2200"
@options = []
@options << FieldOption.new("")
end
def set_values_for_type(kla... |
class CreateDeals < ActiveRecord::Migration[5.2]
def change
create_table :deals do |t|
t.date :deal_date
t.integer :deal_quantity
t.boolean :confirmation
t.references :brewery, foreign_key: true
t.references :client, foreign_key: true
t.timestamps
end
end
end
|
class FinancialStatementsAnalyzer
def initialize filedir
fs_directory = Dir.new(filedir)
financial_statements = fs_directory.entries.select { |e| e =~ /.*_[A-Z][A-Z]\.txt$/}
payments = fs_directory.entries.select { |e| e =~ /.*_PYMT\.txt$/}
@region = Hash.new
@apps = Hash.new
financial... |
Given /^the following couch time is in the database:$/ do |table|
table.hashes.each do |hash|
hash[:user] = User.find_by_name hash["user"]
couch_time = CouchTime.create!(hash)
end
end
When /^I fill in the creation form correctly with duration "([^"]*)"$/ do |duration|
f... |
require 'onesky'
module OneSky
class Client
attr_accessor :client, :project, :base_locale, :onesky_locales, :config
def initialize(config_hash)
unless valid_config?(config_hash)
fail ArgumentError, 'Invalid config. Please check if `api_key`, `api_secret` and `project_id` exist.'
end
... |
ActiveAdmin.register_page "Dashboard" do
menu priority: 1, label: proc{ I18n.t("active_admin.dashboard") }
content title: proc{ I18n.t("active_admin.dashboard") } do
columns do
column do
panel "Users" do
table_for User.order("created_at desc").limit(10) do
column :full_name... |
name 'ssh-auth'
maintainer 'phaninder [phaninder.com]'
maintainer_email 'pasupulaphani.gmail.com'
license 'Apache 2.0'
description 'Configures ssh'
long_description 'Configures ssh and provides some utils for auth keys'
version '0.1.4'
unless defined?(Chef::Cookbook::Metadata)
... |
class Creation < ActiveRecord::Base
belongs_to :user
validates_presence_of :author, :title, :work
validates_length_of :author, in: 1..100
validates_length_of :title, in: 1..100
validates_length_of :work, minimum: 1
end
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.