text stringlengths 10 2.61M |
|---|
namespace :daily_tasks do
desc "take snapshot of membership data"
task :take_snapshot => :environment do
Snapshot.take_snapshot
end
desc "send email to shoutout committee of people absent for over 3 weeks"
task :send_absence_email => :environment do
absent_members = Member.members_absent(3)
unless abs... |
class Position
attr_accessor :x, :y
def initialize x=0, y=0
@x = x
@y = y
end
def ==(otherPos)
[self.x, self.y] == [otherPos.x, otherPos.y]
end
def eql?(otherPos)
(self.class == otherPos.class) and self == otherPos
end
#distance from origin
def magnitude
Math.sqrt(x**2 + ... |
module BabySqueel
module Operators
module ArelAliasing
# Allows the creation of shorthands for Arel methods.
#
# ==== Arguments
#
# * +operator+ - A custom operator.
# * +arel_name+ - The name of the Arel method you want to alias.
#
# ==== Example
# BabySqu... |
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
# protect_from_forgery with: :exception
# Run all reqeusts through CORS filter
before_action :cors
# Overwrite 404
def not_found
raise ActionCon... |
Rails.application.routes.draw do
require 'sidekiq/web'
mount Sidekiq::Web => '/sidekiq'
resources :candidates
resources :jobs
get '/search', to: 'searches#new', as: 'search'
get '/unsubscribe/:token', to: 'candidates#unsubscribe', as: 'unsubscribe'
get '/remove_account/:token', to: 'candidates#destroy'... |
class TelegramWebhooksController < Telegram::Bot::UpdatesController
include Telegram::Bot::UpdatesController::MessageContext
context_to_action!
def start(*)
respond_with :message, text: t('.content')
end
def help(*)
respond_with :message, text: t('.content')
end
def newtag(tag = nil, *)
unl... |
class RestaurantsController < ApplicationController
before_action :set_restaurant, only: [:show, :edit, :update, :destroy]
def yelp_search
# params below sent from form via ajax
type = "restaurants"
sort = params[:sort]
# highest rated or closest as designated on form
lat = params[:lat]
lon... |
require 'spec_helper'
feature 'associate building with owner', %q{
As a real estate associate
I want to correlate an owner with buildings
So that I can refer back to pertinent information
} do
# Acceptance Criteria:
# When recording a building, I want to optionally associate the building with its rightful ... |
class MicropostsController < ApplicationController
def index
user = User.find(params[:user_id])
# paginate
@microposts = paginate(user.microposts)
# add paginate meta
render json: @microposts, meta: paginate_meta(@microposts)
end
end
|
# frozen_string_literal: true
module ApplicationHelpers
def respond_with_object(response, object)
response.write(JSON.generate(object))
end
def error(response, message, status = 400)
response.status = status
response.write("ERROR: #{message}")
end
def missing(response)
response.status = 404... |
require_relative '../lib/modules/timeable'
class Transaction
include Timeable
attr_reader :id,
:invoice_id,
:credit_card_number,
:credit_card_expiration_date,
:result,
:created_at,
:updated_at
def initialize(data)
@id ... |
Shindo.tests("Fog::Compute[:ovirt] | vm_update request", ["ovirt"]) do
compute = Fog::Compute[:ovirt]
compute.create_vm(:name => "fog-" + Time.now.to_i.to_s, :cluster_name => "Default") if compute.servers.all(:search => "fog-*").empty?
vm = compute.servers.all(:search => "fog-*").last
tests("The response shoul... |
#!/bin/env ruby
# encoding: utf-8
#
namespace :onetime do
desc 'Arnav : Usage -> rake RAILS_ENV=development onetime:populate_shaadi_types'
task :populate_categories => :environment do
type_theme = {1 => ['Punjabi', 'Marathi', 'Marwadi', 'South Indian']}
type_theme.each do |name|
ShaadiType.create!(:... |
# This rake file is for items that we need to run once as a part of a build,
# but will probably never run again.Please label the purpose and date of each
# task so that we can periodically delete out old tasks.
namespace :run_once do
namespace :overstock do
# Leave this task in this file and configure it fo... |
class ExpenseCategory < ActiveRecord::Base
has_many :expense_types
end
|
# frozen_string_literal: true
class BookValidator
attr_accessor :matching_api_items
def initialize(book)
@book = book
end
def validate
if !@book.catalog_choice.nil? && !@book.catalog_choice.empty?
nil
elsif @book.details_url.nil?
self.matching_api_items = @book.matching_api_item... |
class PostsController < ApplicationController
respond_to :html, :xml
def index
@posts = Post.posted.select([:title, :published_on, :id]).order('published_on DESC')
@first_post = first_post
respond_with @posts, @first_post
end
def show
@post = Post.posted.find(params[:id])
respond_with @p... |
module EngagementServices
module Generic
class Search
attr_accessor :object, :relation
def initialize(object:, relation:)
@attributes = {}
@object = object
@relation = relation
end
def method_missing(name, *ar... |
# frozen_string_literal: true
module Dynflow
module Testing
class DummyExecutor
attr_reader :world, :events_to_process
def initialize(world)
@world = world
@events_to_process = []
end
def event(execution_plan_id, step_id, event, future = Concurrent::Promises.r... |
class AddCollectionUuidToFileGroups < ActiveRecord::Migration[5.2]
def change
add_column :file_groups, :collection_uuid, :string
FileGroup.all.find_each do |file_group|
file_group.update_attribute(:collection_uuid, file_group.collection.uuid)
end
end
end
|
class Performance
attr_reader :date, :musical, :theater
@@all = []
def initialize(date_string, musical_instance, theater_instance)
@date = date_string
@musical = musical_instance
@theater = theater_instance
@@all << self
end
def self.all
@@all
end
def self.all_strings
@@all.eac... |
require 'rails_helper'
feature 'user is given error messages when inputing car incorrectly', %Q(
As a Car dealer
I want to know why my car listing did not save
so that I can feel bad about myself.
) do
scenario 'user adds a new car incorrectly' do
car = FactoryGirl.build(:car)
manufacturer = FactoryG... |
require_relative "./lib/xml_loader"
# автоматически понимаешь преобразователь в чиселки пусть будет
# но это похоже только для аттрибутов
# todo вытащить все из xml_loader, надо тут свое иметь все
#NUMS
module XmlNums
def parsetext(t)
#STDERR.puts "parsetext: t=#{t}"
if t =~ /\A(0|[1-9][0-9]*)\z/
retur... |
class WorkOfArt < ApplicationRecord
acts_as_favoritable
belongs_to :user
belongs_to :collab, optional: true
# has_many :work_of_arts_favorites, dependent: :destroy
has_one_attached :photo
validates :name, presence: true
end
|
# Library: a collection of shelves
class Library < ActiveRecord::Base
has_many :shelves, order: 'updated_at DESC'
has_many :references
belongs_to :user
has_many :versions
include HasMembers
extend FriendlyId
friendly_id :slug
LTYPES = ['camping', 'guides', 'publisher']
validates_presence_of :user_i... |
module GeoFoo
SRID = 4326 # WGS-84
EarthRadius = 6370986.0 # meters (as used by postgis' ST_Distance_Sphere())
# return a postgis string representation of the given coordinates
def self.as_point lat, lon
# Intentionally use (lat,lon) and not (lon,lat), because latitude is the
# 'horizontal' coordi... |
def hunt_around_for_search_button
candidate = find("div.contentText").all("input")[6]
suchen_button = candidate if candidate["value"] == "Suchen"
if suchen_button.nil?
raise "Can't find the damn search button."
else
return suchen_button
end
end |
#!/usr/bin/env ruby
CORRECT_MARK = 'P'
INCORRECT_MARK = '-'
TIMEOUT_MARK = 'T'
RUN_ERROR_MARK = 'x'
def log(str='')
if ENV['TALKATIVE']!=nil
puts str
end
if ENV['GRADER_LOGGING']!=nil
log_fname = ENV['GRADER_LOGGING']
fp = File.open(log_fname,"a")
fp.puts("grade: #{Time.new.strftime("%H:%M")} #{... |
require_relative "parser"
require_relative "logging"
module PuppetDBQuery
# convert puppetdb query into mongodb query
class ToMongo
include Logging
def query(string)
logger.info "transfer following string into mongo query:"
logger.info(string)
mongo_query = nil
unless string.nil? |... |
#
# 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 by applicable law or agreed to in writing, software
# distributed under ... |
module OmniAuth
module Strategies
class Password
include OmniAuth::Strategy
option :user_model, nil # default set to 'User' below
option :login_field, :email
def request_phase
redirect "/session/new"
end
def callback_phase
return fail!(:invalid_credentials) u... |
class TwilioController < ApplicationController
include Webhookable
after_filter :set_header
skip_before_action :verify_authenticity_token
def text
alphabet = ('a'..'z').to_a.zip(0..25).to_h
@user = User.find_by_email(params[:From])
data = params[:Body].split
poll = Poll.find_by_id(data[0].to_... |
desc "Display the latest version (from history.rdoc)"
task :"rake_rack:version" do
puts "Latest version is #{RakeRack::Version.latest_version}"
end
namespace :rake_rack do
namespace :version do
desc "Increment the major version in history.rdoc (eg 1.2.3 => 2.0.0)"
task :major do
new_version = RakeRac... |
require 'spec_helper'
describe 'have_method' do
let(:contents) { "class SomeClass\n def some_method\n puts 'Hello world!'\n end\nend" }
subject { '/some/file/path' }
before { allow(File).to receive(:read).with('/some/file/path').and_return(contents) }
it { is_expected.to have_method(:some_method) }
it... |
# @private
module BetterErrors
class RaisedException
attr_reader :exception, :backtrace
def initialize(exception)
@exception = exception
setup_backtrace
end
def syntax_error?
syntax_error_classes.any? { |klass| is_a?(klass) }
end
private
def syntax_error_classes
#... |
class Follower
attr_accessor :user_nick, :follower_nick
def initialize(user_nick,follower_nick)
@user_nick = user_nick
@follower_nick = follower_nick
end
def ==(follower)
self.follower_nick == follower.follower_nick
end
end
|
# Discounts come from shop
#
# Schema:
# t.string "slug"
# t.string "name", null: false
# t.string "url"
#
class Shop < ActiveRecord::Base
has_many :discount_types, dependent: :destroy
validates :slug, presence: true, uniqueness: true
validates :name, presence: true
end
|
class EnrollRequestsController < ApplicationController
load_and_authorize_resource :course
load_and_authorize_resource :enroll_request, through: :course
before_filter :load_general_course_data, only: [:index, :new]
def index
# only staff should be able to access this page
# here staff can approve stud... |
require_relative '../../domain/modules/common/invariant'
require_relative '../../domain/modules/common/schedulable_tasks'
require_relative '../edge_collection'
require_relative '../node_collection'
class Diagram
include Invariant
include SchedulableTasks
attr_accessor :name, :max_iterations, :nodes, :edges
... |
# frozen_string_literal: true
RSpec.describe SC::Billing::Stripe::Webhooks::Customers::Sources::CreateOperation, :stripe do
subject(:result) do
described_class.new.call(event)
end
let(:event) { StripeMock.mock_webhook_event('customer.source.created') }
context 'when customer exists' do
before do
... |
Then /^I should see the "(.*?)" list item$/ do |list_item|
on(MainMenuScreen).should have_text list_item
end
When /^I press the "(.*?)" list item$/ do |list_item|
on(MainMenuScreen).send "#{list_item}_list_item_text"
end
When /^I press the Back button$/ do
on(MainMenuScreen) do |screen|
screen.wait_for_text... |
class YoutubeUrlFormatValidator < ActiveModel::EachValidator
def validate_each(object, attribute, value)
unless value.blank?
uri = URI.parse(value)
if %(www.youtube.com m.youtube.com youtube.com youtu.be).include? uri.host
unless uri.host == "youtu.be"
object.errors.add(attribute, "m... |
class StoriesFeedsController < ApplicationController
before_action :load_stories_feed, only: :show
def show
render_json @stories_feed.paginate_messages(message_pagination_params)
end
private
def load_stories_feed
@stories_feed = StoriesFeed.new(user_id: current_user.id)
if @stories_feed.attr... |
module KMP3D
class CKPT < GroupType
def initialize
@name = "Checkpoints"
@external_settings = [Settings.new(:text, :bytes, "Next Group(s)", "0")]
@settings = [
Settings.new(:text, :byte, "Respawn ID", "0"),
Settings.new(:text, :byte, "Type", "-1")
]
@groups = []
... |
# Given an array, move all zeros to the end.
# The order of non-zero elements does not matter.
# Algorithm should be O(n); use O(1) extra space
# Example input/output
# > move_zeros([1, 2, 0, 3, 4, 0, 5, 6, 0])
# return [1, 2, 6, 3, 4, 5, 0, 0, 0]
def move_zeros(array)
i = 0
j = array.size-1
while i < j
... |
class Story < ActiveRecord::Base
has_many :comments
validates :title, presence: true
validates :image, presence: true
validates :intro, presence: true, length: { minimum: 5, maximum: 15}
end
|
def negative_or_empty?(num)
num.to_f < 0 || num.empty? || num.to_i == 0
end
loan_amount = ''
loop do
puts "What is the loan amount?"
loan_amount = gets.chomp.gsub(/([$,])/, '') # removes the '$' and ','' symbols
if negative_or_empty?(loan_amount)
puts "Please enter a number greater than zero."
else
b... |
class CreateComboItemItems < ActiveRecord::Migration
def change
create_table :combo_item_items do |t|
t.integer :combo_item_id
t.integer :item_id
t.timestamps
end
end
end
|
class Ps4Worker
include Sidekiq::Worker
def perform intern_id
use_proxy = Setting.get("use_proxy","false")
if use_proxy == "true"
@proxy = Proxy.all.order("RAND()").limit(1).first
ENV['http_proxy'] = "http://#{@proxy.ip}:#{@proxy.port}"
end
@player = Player.where(player_id:intern_id,pl... |
# Inheritance.rb
# Inheritance -- when a class inherits behavior from another class.
# good_dog_class.rb
class Animal
def speak # class behavior aka method
"Hello!"
end
end
class GoodDog < Animal # we are inheriting from class Animal, and are not able
end # to use Animal behaviors in ou... |
require 'spec_helper'
describe UsersController do
describe "GET root" do
before do
xhr :get, :index
end
it "should be success" do
response.should be_success
end
end
describe "POST 'users/create'" do
before do
xhr :post, :create, iidxid: "1111-1111", djname: "test"
end
... |
#!/usr/bin/env ruby
$LOAD_PATH << File.expand_path("../lib", __FILE__)
require 'helpers'
usage "The 'help' hook helps you find help about things: help <hookname>"
if ARGV[0]
script = File.expand_path("../#{ARGV[0]}", __FILE__)
if script["strobot/hooks/"] and File.executable?(script) and not File.directory?(sc... |
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
def home
# keys = []
# Redis.current.scan_each{ |key| keys << key }
# js keys: keys
end
end
|
module Fluent
class SndacsOutput < Fluent::TimeSlicedOutput
Fluent::Plugin.register_output('sndacs', self)
def initialize
super
require 'tempfile'
require 'zlib'
#A quick fix for the encoding problem
#see https://github.com/fluent/fluentd/issues/76
encoding = Encoding.def... |
class PairingsController < ApplicationController
respond_to :html
def show
@user = User.find(params[:user_id])
@pairs = @user.pairs
end
end
|
class HomeController < ApplicationController
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
def home
#logger.tagged("HomeController") {logger.info(HTTP.get("https://www.pagepluscellular.com/login/").to_s)}
... |
packages = [
"gcc", "autoconf", "bison", "flex", "libtool", "make", "libboost-all-dev", "libcurl4-openssl-dev", "curl",
"libevent-dev", "memcached", "uuid-dev", "libtokyocabinet-dev", "libtokyocabinet*", "gperf", "libcloog-ppl0"
]
packages.each do |p|
package p do
action :install
end
end
release = node[... |
require 'active_support/core_ext/class/attribute_accessors'
require 'action_view/helpers/asset_tag_helper' if defined? Rails
# I18n support for "translating" assets e.g. images/css files etc.
# with Globalize2's fallback support.
module I18n
module AssetTranslate
if defined? ActionView::Helpers::AssetTagHelper... |
class AddWebsiteToRestaurant < ActiveRecord::Migration
def change
add_column :restaurants, :website, :string
add_column :restaurants, :halal_status, :text
end
end
|
require './lib/card'
require './lib/deck'
require './lib/player'
require './lib/turn'
class Game
attr_reader :standard_deck, :deck1, :deck2, :player1, :player2, :turn
def start
p "Welcome to War! (or Peace) This game will be played with 52 cards."
p "The players today are Megan and Aurora"
p "Type 'GO... |
class ItemsTestSheet < ActiveRecord::Base
attr_accessible :item_id, :test_sheet_id
belongs_to :item
belongs_to :test_sheet
validates :item_id, presence: true
validates :test_sheet_id, presence: true
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 rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Ch... |
class Navigator < ActiveRecord::Base
belongs_to :navigatable, polymorphic: true
belongs_to :block, touch: true
validates_presence_of :name, :block_id, :navigatable_id, :navigatable_type
def self.list(block_id)
includes(:navigatable).where(block_id: block_id).order("position")
end
end
|
class HospitalDirectorController < ApplicationController
def facility
@facility = "Kamuzu Central Hospital"
@centers = ["Total Attendance"]
@readings = Hash.new()
@ranges = {}
today = 0
this_month = 0
this_year = 0
day_figures = AttendanceFigure.find(:all, :conditions => ["atten... |
# Almost copypaste from order_contents_decorator
module AddItemDecorator
prepend Spree::ServiceModule::Base
private
def add_to_line_item(order:, variant:, quantity: nil, options: {})
options ||= {}
quantity ||= 1
options.permit(ad_hoc_option_values: [], product_customizations: [], ad_hoc_option_val... |
class Campaign < ApplicationRecord
has_one :campaign_change
has_many :payments
belongs_to :organization
has_many :payments
has_many :status_updates
has_attached_file :image, :styles=> {:large => "1000x700>", :thumb => "450x300="},
:default_url => "default.png"
validates_attachment :image, :content_type ... |
types_of_people = 10 #Variable 'types_of_people' assigned the value 10
x = "There are #{types_of_people} types of people in this world."
# Creating the string x and assigning the variable types_of_people inside the string
binary = "binary" #string binary assigned to the word binary
do_not = "don't" #string do_not assi... |
# # Part 1
# As a member of the public
# So I can return bikes I’ve hired
# I want to dock my bike at the docking station
# Part 2
# As a member of the public,
# So that I am not confused and charged unnecessarily,
# I’d like docking stations not to release bikes when there are none available.
#
# As a system mainta... |
# == Schema Information
#
# Table name: rates
#
# id :integer not null, primary key
# single_rec :string
#
class Rate < ActiveRecord::Base
attr_accessor :representative_number, :policy_number, :manual_class_payroll, :manual_number
scope :by_policy_number, -> (policy_number) { where("cast_to_int... |
require 'deviantart/user'
require 'deviantart/user/update_profile'
require 'deviantart/user/profile'
require 'deviantart/user/friends'
require 'deviantart/user/friends/search'
require 'deviantart/user/whois'
require 'deviantart/user/statuses'
require 'deviantart/user/watchers'
require 'deviantart/user/friends/watching'... |
class Location < ActiveRecord::Base
# SCOPES
default_scope { order('votes_cache DESC') }
scope :done, -> { where(done: true) }
scope :suggested, (lambda do
includes(:state, :experiences).where('experiences_count > ?', 0)
end)
# ASSOCIATIONS
belongs_to :state
has_many :experiences
has_many :users,... |
name = "splam"
Gem::Specification.new name, "0.3.0" do |s|
s.summary = "Test comments and users for spam signifiers and score"
s.authors = ["ENTP"]
s.email = "courtenay@entp.com"
s.homepage = "http://github.com/courtenay/splam"
s.files = `git ls-files`.split("\n")
s.license = "MIT"
s.add_runtime_dependen... |
class CreateCsmInfos < ActiveRecord::Migration[5.1]
def change
create_table :csm_infos do |t|
t.string :email
t.string :name
t.timestamps
end
end
end
|
# -*- encoding: utf-8 -*-
require File.expand_path('../lib/smarter_csv/version', __FILE__)
Gem::Specification.new do |gem|
gem.authors = ["Tilo Sloboda\n"]
gem.email = ["tilo.sloboda@gmail.com\n"]
gem.description = %q{Ruby Gem for smarter importing of CSV Files as Array(s) of Hashes, with optiona... |
#!/usr/bin/env ruby
# frozen_string_literal: true
# Released under the MIT License.
# Copyright, 2022-2023, by Samuel Williams.
# Run this using `systemd-cat bundle exec ./integration.rb`
# This will send logs to datadog using the standard systemd journal.
ENV['TRACES_BACKEND'] ||= 'traces/backend/datadog'
ENV['CONS... |
module EadIndexer::Behaviors
module Dates
DATE_RANGES = [
{ display: "1101-1200", start_date: 1101, end_date: 1200 },
{ display: "1201-1300", start_date: 1201, end_date: 1300 },
{ display: "1301-1400", start_date: 1301, end_date: 1400 },
{ display: "1401-1500", start_date: 1401, end_date:... |
require 'rubygems'
require 'httparty'
require 'uri'
require 'json'
require 'net/http'
class EdutechionalResty
include HTTParty
base_uri "api.github.com"
def posts
uri = URI.parse("api.github.com")
header = {'Content-Type': 'text/json'}
user = {user: {
username: 'ravimathya',
password... |
class GonzoController < ApplicationController
def index
@gonzos = Gonzo.all
end
def show
@gonzo = Gonzo.find(params[:id])
end
def new
@gonzo = Gonzo.new
end
def gonzos_params
params.require(:gonzo).permit(:title, :body)
end
def create
@gonzo = Gonzo.new(gonzos_params)
if @gonzo.save
redi... |
#!/usr/bin/env ruby
#
# Summation of primes
# http://projecteuler.net/problem=10
#
# The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.
#
# Find the sum of all the primes below two million.
#
class Integer
def primes
candidates = [nil, nil, *(2..self)]
(2..self**0.5).each {|x| (x**2..self).step(x) {|y| ca... |
module Collins
class CollinsError < StandardError; end
class ExpectationFailedError < CollinsError; end
class UnexpectedResponseError < CollinsError; end
class RequestError < CollinsError
attr_accessor :code, :uri
def initialize message, code
super(message)
@code = code.to_i
end
def... |
# Normally when we want to talk about a string, we will just call it a string.
# However, we could also call it a string object. Sometimes programmers might call
# it an instance of the class String, but it’s just another way of saying string.
# An instance of a class is just an object of that class.
# So, instan... |
class Account < ApplicationRecord
self.inheritance_column = nil
belongs_to :user
has_many :transactions,
primary_key: :uid, foreign_key: :account_uid
validates :user, :uid, :type, :name, :currency, :balance, presence: true
validates :uid, uniqueness: true
def default?
return false unless p... |
module Paperclip
class HttpUrlProxyAdapter < UriAdapter
def self.register
Paperclip.io_adapters.register self do |target|
String === target && target =~ REGEXP
end
end
REGEXP = /\Ahttps?:\/\//.freeze
def initialize(target, options = {})
escaped = Paperclip::UrlGenerator.esc... |
class CommentsController < ApplicationController
before_action :find_comment, only: [:edit, :update, :destroy]
before_action :comment_auth, only: [:edit, :update]
def new
@comment = Comment.new
end
def show
comment = Comment.find_by(user: current_user, recipe: find_by_recipe_id)
end
def create... |
module JRubyFX
# Current gem version. Used in rake task.
VERSION='1.0.0'
end
|
class AddSubtaskConfirmationToSubtasks < ActiveRecord::Migration
def change
add_column :subtasks, :subtask_confirmation, :string
end
end
|
require 'rails_helper'
RSpec.describe Customer do
describe "relationships" do
it { should have_many :invoices }
end
describe "customer model methods" do
before(:each) do
@merchant_1 = create(:merchant)
customer_1 = create(:customer)
@customer_2 = create(:customer)
customer_3 = create(:cus... |
# frozen_string_literal: true
class GasSimulationsController < ApplicationController
before_action :authenticate_user!
before_action :user_signed_in?
before_action :not_other_users_gas_simulations, only: [:show]
def show
@gas_sim = GasSimulation.find(params[:id])
table_attributes = @gas_sim.print_repo... |
class AddCarIdToComponents < ActiveRecord::Migration
def change
add_column :components, :car_id, :integer
add_index :components, :car_id
end
end
|
class Customers::HomeController < ApplicationController
before_filter :authenticate_customer!
def index
@customer_dashboard_props = {
sidebarNavItems: [
{
itemString: 'Home',
itemUrl: '#'
},
{
itemString: 'Notifications',
itemUrl: '#',
... |
Pod::Spec.new do |s|
s.name = "LZPickerView"
s.version = "0.1.3.4"
s.summary = "LZPickerView"
s.description = <<-DESC
Easy to use a PickerView like WeChat.
DESC
s.homepage = "https://github.com/KKKGit/LZPickerView"
s.license = { :t... |
feature "Posting a new reply to a thread" do
given(:message) { lorem_ipsum(64) }
given(:captcha) { "GOODCAPTCHA" }
given(:thread_id) do
page.current_path.match(/\/index.php\/corn\/t\/(\d+)/)[1]
end
background do
visit "/index.php/corn/"
first(".thread a.post-id").click
within("#new-post") do
... |
begin
require 'jeweler'
Jeweler::Tasks.new do |gemspec|
gemspec.name = "caller_name"
gemspec.summary = "get the caller method name from ruby context"
gemspec.description = "get the caller method name from ruby context"
gemspec.email = "tim.rubist@gmail.com"
gemspec.homepage = "http://github.com/... |
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable, :omniauthable
validates_presence_of :name, message: "Campo ... |
class Meeting < ApplicationRecord
has_many :meeting_speakers
has_many :speakers, through: :meeting_speakers
validate :title, presence: true
validate :agenda, presence: true
validate :location, presence: true
validate :time, time: time.now #need to sort out if this is correct
# message: "Please fill out a... |
feature 'Features - Battle' do
scenario 'players enter their names' do
sign_in_and_play
expect(page).to have_content('Hagrid', 'Dumbledore')
end
scenario 'See player 2 hit points' do
sign_in_and_play
expect(page).to have_content('Dumbledore: 60HP')
end
scenario 'See player 1 hit points' do
... |
class PasswordResetController < ApplicationController
before_filter :require_no_user
def new
@page_title = 'Olvidó su contraseña'
end
def create
@user = User.find_by email: params[:email]
if @user
@user.reset_perishable_token!
Notifier.password_reset_instructions(@user).deliver_now
flash[:notice] =... |
# Making Ruby Class more secure
# public and private methods
class Gadget
# attr_writer :password
attr_reader :production_number
attr_accessor :username, :password
def initialize(username, password)
@username = username
@password = password
@production_number = generate_production_number
end
... |
#!/usr/bin/env ruby
# -*- encoding: utf-8 -*-
# This gemspec has been crafted by hand - do not overwrite with Jeweler!
# See http://yehudakatz.com/2010/12/16/clarifying-the-roles-of-the-gemspec-and-gemfile/
# See http://yehudakatz.com/2010/04/02/using-gemspecs-as-intended/
# for more information on bundler and gems.
r... |
Given(/^I am on the homepage$/) do
visit '/'
end
When(/^I follow "([^"]*)"$/) do |arg1|
click_link arg1
end
Then(/^I should see "([^"]*)"$/) do |arg1|
expect(page).to have_content arg1
end
Given(/^I'm on the registration$/) do
visit '/registration'
end
When(/^I click "([^"]*)"$/) do |arg1|
click_button ar... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.