text stringlengths 10 2.61M |
|---|
class CreateHomes < ActiveRecord::Migration[6.0]
def change
create_table :homes do |t|
t.string :address, null: false
t.integer :city_id, null: false
t.string :municipality, null: false
t.string :street, null: false
t.string :tell_number, null: false
t.string :b... |
class Owner < ActiveRecord::Base
attr_accessible :name
validates :name, :presence => true
has_many :tasks, :inverse_of => :owner
attr_accessible :tasks_attributes
accepts_nested_attributes_for :tasks
end
|
class Job < ActiveRecord::Base
attr_accessible :description, :enddate, :provider, :specialization, :startdate, :location
validates :provider, :startdate, :enddate, :specialization, :description, :location, presence: true
validates_date :startdate, :after => Date.today
validate :enddate_must_not_be_before_star... |
require "./item.rb"
module Factory
module Link
include Item
def Link(caption:, url:)
super(caption)
@url = url
end
private
attr_accessor :url
end
end
|
class FavoritesController < ApplicationController
def create
@post = Post.find(params[:post_id])
favorite = current_user.favorites.build(post: @post)
authorize favorite
if favorite.save
flash[:notice] = "Favorite was successfully added"
redirect_to [@post.topic, @post]
else
flas... |
require 'spec_helper'
describe Puppet::Type.type(:nexus_application_server_settings) do
before :each do
@provider_class = described_class.provide(:simple) do
mk_resource_methods
def flush; end
def self.instances; []; end
end
described_class.stubs(:defaultprovider).returns @provider_clas... |
require File.dirname(__FILE__) + '/../lib/cotta'
require File.dirname(__FILE__) + '/cotta/physical_system_stub'
require 'spec'
module Cotta
module TempDirs
def setup_tmp
root = current(__FILE__).parent {|dir| dir.name == 'buildmaster' and dir.dir('bin').exists?}
output = root.dir('tmp')
output.... |
class UserCategory < ApplicationRecord
has_many :users, dependent: :nullify
#User categories will be: general volunteer, team lead, admin (and guest for unapproved users
#who signed up for at least one event?)
end
|
Greenskin::Application.routes.draw do
resources :projects do
resources :stories do
resources :comments
end
end
devise_for :accounts
root to: "pages#splash"
end
|
# Rock, Paper, Scissors, Spock, Lizard
def prompt(msg, new_line = false)
head = new_line ? "\n" : ""
puts "#{head}=> #{msg}"
end
def display_choices(arr)
count = 1
arr.each do |word|
prompt " #{count}. #{word}"
count += 1
end
end
def win?(first, second)
WINNING_PATHS[first].include?(second)
end... |
class Review < ApplicationRecord
belongs_to :book
belongs_to :user
has_many :comments
scope :review_by, ->field_name, value {where("? LIKE ?", field_name, value)}
class << self
def search(search)
if search
@reviews = Review.review_by("content", "%" + search + "%")
else
@review... |
require 'spec_helper'
describe "raw_motion_data/edit" do
before(:each) do
@raw_motion_datum = assign(:raw_motion_datum, stub_model(RawMotionDatum,
:pitch => 1.5,
:quaternion_w => 1.5,
:quaternion_x => 1.5,
:quaternion_y => 1.5,
:quaternion_z => 1.5,
:roll => 1.5,
:rotati... |
class AddWikititleIndexToPages < ActiveRecord::Migration
def change
add_index :pages, :wikititle
end
end
|
module RandomData
module AcademicPaper
adjective_list = %w(Modern Global Discursive Rural Representational Credit Affective Domestic Transnational Nuclear Colonial Saharan Queer Fordist Contemporary Socialist Socioeconomic Marxist Buddhist Kinky Forgotten Ghandian Conservative)
prefix_list = %w(Pre Po... |
Rails.application.routes.draw do
namespace :api do
namespace :v1 do
resources :users, param: :_username
namespace :auth do
post '/login', to: 'authentication#login'
end
end
end
get '/*a', to: 'application#not_found'
end
|
class Player
attr_accessor :lives
attr_reader :name
def initialize(name)
@name = name
@lives = 3
end
def answer
print "> "
$stdin.gets.chomp
end
def react(isCorrect)
if isCorrect
puts 'YES! You are correct!'
else
pu... |
require 'logger'
class KyanTriceratopsPlayer
# Returns this players name.
def name
"Kyan Triceratops Player"
end
# Prepares for a new game. Creates an array of letters that can be used to guess.
def new_game(dictionary)
@dictionary = dictionary.map { |w| w.chomp }
@played_letters = []
@letters = ('a'..'z'... |
# frozen_string_literal: true
module Qdc
class ChapterPresenter < BasePresenter
attr_reader :locale
def initialize(params, locale)
super(params)
@locale = locale
end
def chapters
finder.all_with_eager_load(locale: locale)
end
def chapter
strong_memoize :chapter do
... |
# == NoteEvent role
#
# Extends Event model functionality by providing extra methods related to comment events
#
# Used by Event
#
module NoteEvent
def note_commit_id
target.commit_id
end
def note_short_commit_id
note_commit_id[0..8]
end
def note_commit?
target.noteable_type == "Commit"
end
... |
ActiveSupport::Inflector.inflections(:en) do |inflect|
inflect.acronym 'API'
inflect.acronym 'GraphQL'
inflect.acronym 'SQL'
inflect.acronym 'UUID'
end
|
module BookKeeping
VERSION = 1
end
class Sieve
def initialize(number)
@number = number
end
def primes_hash
primes = []
number_hash = Hash[(2..@number).to_a.collect { |v| [v, true] }]
number_hash.each do |num, is_prime|
break if Math.sqrt(@number) < num
next unless is_prime ... |
class User < ApplicationRecord
has_many :invites
has_many :events, through: :invites
has_many :hosted_events, foreign_key: "user_id", class_name: "Event"
has_many :followed_users, foreign_key: :follower_id, class_name: 'Friendship'
has_many :followees, through: :followed_users
has_many :follo... |
require_relative "card"
require_relative 'computer_player'
class Board
attr_accessor :grid
attr_reader :stack
def initialize(size=4)
@grid = Array.new(size){Array.new(size)}
@stack = []
end
def generate_cards
2.times {(1..8).each {|num| @stack << Card.new(num)}}
end
def populate
shuff... |
# Problem 15: Lattice paths
# http://projecteuler.net/problem=15
# Starting in the top left corner of a 2×2 grid, and only being able to move to the right and down, there are exactly 6 routes to the bottom right corner.
#
# http://projecteuler.net/project/images/p_015.gif
# How many such routes are there through a 2... |
class Ability
include CanCan::Ability
def initialize(user)
return unless user
if user.admin?
can :manage, :all
else
can [:index, :show, :learn], Course
can [:index], Learning
end
end
end
|
class Meppe < ActiveRecord::Base
belongs_to :category
has_many :points
scope :with_points_count, -> { joins(:points).group('meppes.id').select("meppes.*, count(points.id) as points_count") }
end
|
class ChangeParticipantMrnToString < ActiveRecord::Migration
def up
change_column :participants, :mrn, :string
end
def down
change_column :participants, :mrn, :integer
end
end
|
require 'tvfeed/source'
require 'uri'
class TVFeedSource::EZTV < TVFeedSource
SOURCE_NAME = 'eztv'
def initialize(config)
super
@search_url = "https://eztv.ag/search/"
@search_method = 'POST'
@post_params = {
"SearchString1" => '{{query}}',
"SearchString" => "",
"search" => "Sear... |
class Admin::PaymentsController < Admin::AdminController
def index
@payments = Payment.order(created_at: :desc).paginate(:per_page => 15, :page => params[:page])
end
def transfer
require 'json'
render status: 400 if params['from_user_id'].blank? || params['to_user_id'].blank? || params['amount'].blan... |
#Building Class
class Building
attr_accessor :name, :address, :apartments
#hint apartments should be an array i.e @apartments = []
def initialize(name, address)
@name = name
@address = address
@apartments = []
end
def view_apartments
puts "-----------Highrise Luxury Apartment List-----------"
... |
class TrackersController < ApplicationController
before_action :authenticate_user!
before_filter :get_tracker, only: [:update, :destroy]
respond_to :html, :json
def index
@trackers = current_user.trackers
respond_with @trackers
end
def new
@tracker = current_user.trackers.new
end
def cr... |
module AuthenticationMacros
def sign_out!
visit '/'
return unless controller.signed_in?
click_link 'Sign Out'
end
def sign_in_as(user, provider = :any)
visit '/'
return if controller.signed_in?
if provider == :any
if user.credentials.any?
controller.current_user = user
... |
class ChangeTimesToIntegers < ActiveRecord::Migration[5.2]
def change
change_column :events, :start_time, 'SMALLINT USING EXTRACT(EPOCH FROM start_time)/60::SMALLINT'
change_column :events, :end_time, 'SMALLINT USING EXTRACT(EPOCH FROM end_time)/60::SMALLINT'
end
end
|
module RenderingHelper
def page_title(title, &block)
content_tag(:section, :class => 'page-title') do
o = content_tag(:h1, title)
o += capture(&block) if block_given?
o.html_safe
end
end
def data_table(collection, partial = nil)
content_tag(:section, :class => 'data-table') do
... |
class ArtikelsController < ApplicationController
before_action :set_artikel, only: [:show, :edit, :update, :destroy]
before_action :authenticate_user!, except: [:index,:show]
before_action :correct_user, only: [:edit, :update, :destroy]
# GET /artikels
# GET /artikels.json
def index
@artikels = Artikel... |
class TwitterAccount < ApplicationRecord
belongs_to :user
has_many :tweets, dependent: :destroy
has_many :automated_tweets, dependent: :destroy
validates :username, uniqueness: true
def client
client = Twitter::REST::Client.new do |config|
config.consumer_key = ENV["CONSUMER_KEY"]
conf... |
def even_fibonacci_sum(limit)
collect = [1, 2]
while true
break if collect[-1] + collect[-2] >= limit
collect << collect[-1] + collect[-2]
end
sum = 0
collect.each {|num| sum += num if num.even?}
return sum
end |
class Tournament < ActiveRecord::Base
has_many :players, through: :registration
end
|
require 'rails_helper'
describe Store do
describe "multitenancy" do
it "should create a tenant when a new store is created" do
store1 = Store.create(
name: "shop1",
email: "samsarge@hotmail.co.uk",
password: "12345678",
domain: "testshop")
Apartment::Tenant.switch("testshop")
Item.creat... |
# == Schema Information
#
# Table name: statistics
#
# id :integer not null, primary key
# games :integer
# goals :integer
# assists :integer
# points :integer
# plus_minus :integer
# atoi :float
# pims :integer
# wins :integer
# losses :integer
# gaa ... |
require 'rails_helper'
RSpec.describe "CreatingCategories", type: :system do
before do
driven_by(:rack_test)
end
User.destroy_all
Category.destroy_all
before :each do
# Devise gem rspec helper
user = User.create(:email => 'test123@example.com', :password => 'f4k3p455w0rd')
login_as(user, :s... |
module BotMethods
def send_message bot, message
bot.api.send_message message
end
def get_message chat_id, text_message
{chat_id: chat_id, text: text_message}
end
def add_markup response, markup
response[:reply_markup] = markup
end
def make_keyboard *buttons
buttons.map! { |button_name| ... |
require 'net/http'
require 'yaml'
require_relative 'config_file'
class RemoteFile < ConfigFile
attr_reader :src, :name
def initialize(file)
remote_files = YAML.load_file('remote_files.yml')
@src = remote_files[file]
@name = remote_files[file]
super
end
def src_content
@src_content ||= Net... |
class AddUserToRevisions < ActiveRecord::Migration
def change
add_reference :revisions, :user, index: true
remove_column :revisions, :posted_by, :integer
end
end
|
require './config/environment'
class ApplicationController < Sinatra::Base
configure do
set :public_folder, 'public'
set :views, 'app/views'
enable :sessions
set :session_secret, "P.=]8pTbS+76Hpw*"
register Sinatra::Flash
end
#this is the initial corneal welcome page - just wanted to keep i... |
class PostsController < ApplicationController
def index
@posts = Post.all;
end
def edit
@post = Post.find(params[:id])
end
def new
@post = Post.new;
@category = Category.all;
end
def create
@post = Post.create(post_params)
if @post.save
redirect_to posts_path, :notice => " post has bee... |
# frozen_string_literal: true
require "dry/monads/do"
RSpec.describe(Dry::Monads::Do) do
result_mixin = Dry::Monads::Result::Mixin
include result_mixin
describe ".for" do
let(:input_value) { 10 }
let(:mixin) { Dry::Monads::Do.for(:answer, :square, :double) }
let(:klass) do
spec = self
k... |
class Admin::PagesController < ApplicationController
include TheSortableTreeController::Rebuild
def index
@pages = Admin::Page.nested_set.select('id, title, content, parent_id, ancestry').limit(15)
end
def manage
@pages = Admin::Page.nested_set.select('id, title, content, parent_id, ancestry').limit(1... |
# classic
def fib(num)
if num <= 1
return 1
else
return fib(num-1) + fib(num-2)
end
end
## Another way
def fib(n)
return n if n < 2
fib(n-1) + fib(n-2)
end
# iterative
def nFib(n)
x, y, sum = 0, 1, 1
for i in 2..n
sum = x + y
x = y
y = sum
end
n === 0 ? 0 : sum
end
def nth... |
class Project
attr_accessor :title
@@all = []
def initialize(title)
@title = title
@@all << self
end
def add_backer(backer)
ProjectBacker.new(self,backer)
end
def self.all
@@all
end
def backers
ProjectBacker.all.select{|project_backer|... |
class StudentsController < ApplicationController
before_action :set_student, only: [:show, :edit, :update, :destroy]
def index
@students = Student.all
end
def show
@student = Student.find{params[:id]}
end
def index
@students = Student.all
end
def new
@student = Student.new
end
... |
require 'pry'
require_relative 'golf_scorecard.rb'
require_relative 'hole_layout.rb'
class PrintScores
attr_accessor :layout_par, :hole_score, :hole
def initialize(layout_par, hole_score, hole)
@layout_par = layout_par
@hole_score = hole_score
@hole = hole
end
def find_stroke(strokes)
case strokes
whe... |
require 'strscan'
# expr = term expr-op ;
# expr-op = '+' expr
# | '-' expr
# | () ;
#
# term = factor term-op ;
# term-op = '*' term
# | '/' term
# | () ;
#
# factor = number
# | '(' expr ')'
# | '-' factor ;
class Calc
class BinaryExpr < Struct.new(:left, :op, :... |
#
# User Stories:
# To start shopping easily,
# guest user wants to add items to shopping cart without signing up
#
#
# Code Explanation:
# - a guest_user is created when new user arrives to your website, so that he could have his own shopping cart, and adding items to shopping cart.
# - when the guest_user sig... |
class Lifter
attr_reader :name, :lift_total
@@all = []
def initialize(name, lift_total)
@name = name
@lift_total = lift_total
@@all << self
end
def self.all
@@all
end
def memberships
Membership.all.select {|membership| membership.lifter == self}
end
def gyms
memberships.... |
source 'https://rubygems.org'
ruby '2.1.4'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.12'
# Use sqlite3 as the database for Active Record
gem 'sqlite3', group: :development
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.0'
# Use Uglifier as compressor for JavaScript asse... |
class Karma
include Mongoid::Document
include Mongoid::Timestamps
belongs_to :karma_type
belongs_to :from, :class_name => 'User'
belongs_to :to, :class_name => 'User'
validates_presence_of :karma_type, :from, :to
end
|
require 'facets/array/recurse'
require 'facets/hash/deep_rekey'
module ConceptQL
class FakeAnnotater
attr :statement
DOMAINS = {
# Conditions
condition: :condition_occurrence,
primary_diagnosis: :condition_occurrence,
icd9: :condition_occurrence,
icd10: :condition_occurrence,
... |
require File.dirname(__FILE__) + '/setup'
require 'javaclass/classpath/maven_classpath'
module TestJavaClass
module TestClasspath
class TestMavenClasspath < Test::Unit::TestCase
def setup
@cpe = JavaClass::Classpath::MavenClasspath.new("#{TEST_DATA_PATH}/maven_classpath")
end
def ... |
Rails.application.routes.draw do
devise_for :users
root 'home#index'
resources :books
resources :lists
get '/lists/:id/subscribe', to: 'subscriptions#create', as: 'subscription'
get '/subscriptions', to: 'subscriptions#index', as: 'subscriptions'
delete '/subscriptions/:id', to: 'subscriptio... |
class Movie
module RoleTypeExtensions
include RoleTypeAssociationExtensions
def update(role_type, people_ids_or_role_attributes)
# people_ids_or_role_attributes == [{attributes}|person_id, ...]
# people_ids_and_role_attributes == [[person_id, attributes], ...]
# obsolete == [role, ...]... |
class UsersController < ApplicationController
before_action :draw_user, only: [ :show, :edit ]
# before_action :set_current_user, only: [ :update ]
def index
authorize User
@users = !!params[:search] ? User.search_includes(params[:search]) : User.all_includes
@users = User.filter_with(@users, param... |
# frozen_string_literal: true
require "spec_helper"
require "generators/graphql/enum_generator"
class GraphQLGeneratorsEnumGeneratorTest < BaseGeneratorTest
tests Graphql::Generators::EnumGenerator
test "it generate enums with values" do
expected_content = <<-RUBY
# frozen_string_literal: true
module Types
... |
# Problem 392: Enmeshed unit circle
# http://projecteuler.net/problem=392
#
# A rectilinear grid is an orthogonal grid where the spacing between the gridlines does not have to be equidistant.
# An example of such grid is logarithmic graph paper.
#
#
# Consider rectilinear grids in the Cartesian coordinate system wi... |
########################################################
# Defines the main methods that are necessary to filter out reads from bad tiles
########################################################
class PluginFilterBadTiles < Plugin
#Returns an array with the errors due to parameters are missing
def check_params
... |
require 'rails_helper'
RSpec.describe Spectacle, type: :model do
let(:spectacle) {build :spectacle}
let(:another_spectacle) {build :spectacle}
it 'has a valid factory' do
expect(spectacle).to be_valid
end
it 'do not save twice the same spectacle' do
spectacle.save
another_spectacle.key... |
class RegistrationsController < Devise::RegistrationsController
def create
user = User.new(sign_up_params)
if user.save
redirect_to new_user_session_path
else
render :new, locals: { resource: user }
end
end
def update
# For Rails 4
account_update_params = devise_parameter_sanitiz... |
require "rails_helper"
RSpec.describe "routing to Articles::CommentsController", type: :routing do
it "routes articles/{:article_id}/comments to Articles::CommentsController#index" do
expect(get: "/articles/100/comments").to route_to(
controller: "articles/comments",
action: "index",
article_id... |
class Activity < ActiveRecord::Base
# relations
belongs_to :user
has_many :orders
# validations
validates_presence_of :title, :description, :user
# scopes
scope :has_tickets_left, -> { where("participants < max_participants") }
scope :order_by_date, -> { order(:date)}
def amount_of_tic... |
class FontNotoNaskhArabic < Formula
head "https://noto-website-2.storage.googleapis.com/pkgs/NotoNaskhArabic-unhinted.zip", verified: "noto-website-2.storage.googleapis.com/"
desc "Noto Naskh Arabic"
homepage "https://www.google.com/get/noto/#naskh-arab"
def install
(share/"fonts").install "NotoNaskhArabic-... |
require_relative "hero"
class HolyKnight < Hero
# 新的職業:神聖武士 HolyKnight
# HolyKnight 是繼承 Hero 的 class
# 他已經具備 Hero 本身的 attributes 與 methods
# 在這裡我們把他的 attack method 修改,讓威力更大!
def attack(enemy)
# 新的職業:神聖武士 Holy Knight
# 攻擊能力:聖光,傷害會隨機取攻擊力(AP)至兩倍 AP 中的數字
damage = rand(@ap..@ap*2)
enemy.hp = e... |
Rails.application.routes.draw do
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
root "users#index"
resources :users do
collection do
get :logout
post :login
end
end
resources :passwords, :except => [:show] do
collection do
... |
json.array! @flavors do |flavor|
json.partial! '/api/flavors/flavor', flavor: flavor
end |
class PickUp < ActiveRecord::Base
include ArelHelpers::ArelTable
include ArelHelpers::JoinAssociation
enum subscription: [:no, :daily, :weekly, :monthly] # will remove
as_enum :frequency, [:no, :daily, :weekly, :monthly], prefix: true, source: 'frequency'
STATUSES = {
pending: 'pending',
accepted: 'ac... |
RSpec.shared_examples 'an endpoint with appropriate CORS headers' do
it 'has appropriate CORS headers' do
subject
expect(last_response.headers['Access-Control-Allow-Methods']).to eq 'HEAD,GET,PUT,POST,DELETE,OPTIONS'
expect(last_response.headers['Access-Control-Allow-Origin']).to eq '*'
expect(last_re... |
require 'time'
class Merchant
attr_reader :id,
:created_at
attr_accessor :updated_at,
:name
def initialize(hash)
@id = hash[:id].to_i
@name = hash[:name].to_s
@created_at = Time.parse(hash[:created_at].to_s)
@updated_at = Time.parse(hash[:upd... |
# type Query {
# hero: Character
# human(id: String!): Human
# droid(id: String!): Droid
# }
QueryType = GraphQL::ObjectType.define do
name "Query"
description "The query root for this schema"
interfaces [GraphQL::Relay::Node.interface]
field :node, GraphQL::Relay::Node.field
field :viewer, ViewerType ... |
#Fedena
#Copyright 2011 Foradian Technologies Private Limited
#
#This product includes software developed at
#Project Fedena - http://www.projectfedena.org/
#
#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 ... |
module Veda
module AdverseAction
class CourtAction < Base
def setup
self.section = 'Court Action'
self.type = self.xml.attributes['type'].underscore.humanize
self.court_type = find_first('court-type').content
self.sub_type = find_first('cou... |
FactoryGirl.define do
factory :comment do
sequence(:content) { Faker::Hacker.say_something_smart }
association :commentable, factory: :question
user
trait :with_wrong_attributes do
content nil
end
end
end
|
# frozen_string_literal: true
RSpec.describe Api::V1::ConfirmEmail::CreateAction do
let(:action) { described_class.new }
describe '#call' do
subject(:call) do
action.call(input)
end
let!(:user) { create(:user, :unconfirmed) }
let(:input) do
jsonapi_params(
attributes: {
... |
require 'rails_helper'
feature 'Best answer', %q{
To show whose answer helped me
As an author of answer
I want to be able to choose the best answer
} do
given!(:author) { create :user }
given!(:user) { create :user }
given!(:question) { create :question, user: author, answers: create_list(:answer, 2) }
... |
class Currency < ApplicationRecord
has_many :pools
has_many :transactions
has_many :accounts
end
|
require File.dirname(__FILE__) + '/../spec_helper'
describe AssetsController do
it "should render dynamic javascript" do
Assetify.should_receive(:js_dynamic_source).with("accounts", "index").and_return("lol")
get :dynamic, {:cont => "accounts", :act => "index", :format => "js"}
response.should be_success... |
module RewriteInheritResources
extend ActiveSupport::Concern
def new
build_resource
form_info
end
alias new! new
def edit
form_info
end
alias edit! edit
private
def collection
get_collection_ivar || begin
@search = end_of_association_chain.search(search_q)
@search.sorts = d... |
# frozen_string_literal: true
class OnlineContentBadge
include ActionView::Helpers::OutputSafetyHelper
include ActionView::Helpers::TagHelper
attr_reader :document, :icon_only
def initialize(document, icon_only: false)
@document = document
@icon_only = icon_only
end
def render
return unless d... |
FactoryBot.define do
factory :repository do
workspace { Faker::Team.name }
repository_name { Faker::App.name }
branch { 'mster' }
end
end
|
require 'scrape_driver'
class ReadingScraper
attr_reader :twine
TEMP_SELECTOR = ".temperature-value"
def initialize(twine)
@twine = twine
end
def get_reading
temp = get_temp_from_supermechanical
make_and_return_reading_from_temp(temp)
end
private
def get_temp_from_supermechanical
... |
require "json"
require_relative "../lib/input_parser"
filepath = ARGV[0]
raise "No filepath was given to the script" if filepath.nil?
raise "File #{filepath} doesn't exists" if !File.exists?(filepath)
modification_repository = InputParser.new(filepath).modifications
modifications = modification_repository.all.map d... |
class AddColumnsToUsers < ActiveRecord::Migration
def change
add_column('users','uid',:string)
add_column(:users,'provider',:string)
add_column(:users,'isDriver',:boolean)
add_column(:users,'imgPath',:string)
end
end
|
class AddStatusToAttendeeShift < ActiveRecord::Migration[6.0]
def change
add_column :attendee_shifts, :status, :integer, null: false, default: 0
end
end
|
require 'hashie/dash'
module SipDigestAuth
class Session < ::Hashie::Dash
# Realm *must* be set, and is the only required field when creating a session for the first time
property :realm, required: true
# The nonce should stay the same for a single session, and will be generated if not provided on
#... |
class CreateStudents < ActiveRecord::Migration[6.1]
def change
create_table :students, {:id => false} do |t|
t.integer :student_id, primary_key: true, null: false
t.string :english_name
t.string :urdu_name
t.datetime :date_of_birth
t.string :contact_number
t.string :fathers_eng... |
#!/usr/bin/env ruby
require_relative '../../../framework/Feature'
require_relative '../../classes/ERSSafePlace'
class InformSafePlaces
@@name = :inform_safe_places
@@feature = Feature.new(@@name)
@@feature.add_alteration(
:instance_method,
:ERS,
:inform,
lambda do
... |
if (node[:ec2] && `mount|grep #{node[:redis][:ec2_path]}`.chomp.empty?)
service "redis" do
action :stop
end
if ! FileTest.directory?(node[:redis][:ec2_path])
execute "install-redis" do
command "mv #{node[:redis][:datadir]} #{node[:redis][:ec2_path]}"
not_if do FileTest.directory?(node[:redis... |
require_relative "calculadora"
describe Calculadora do
#cenario de teste com numeros positivos
it "Soma de 20 mais 20 deve ser 40" do
calculo = Calculadora.new()
# Act
resultado = calculo.adicao(20, 20)
# Assert
expect(resultado).to eq(40)
end
#cenario de teste com numeros po... |
module GoldPoints
module V1
class AccountStatementsAPI < Grape::API
desc 'List records grouped by date'
get '/account_statements' do
result = AccountStatements::List.call(user: current_user)
present :account_statements, result.account_statements, with: ::AccountStatementEntity
e... |
class AddOverallQualityToCourseReview < ActiveRecord::Migration
def change
add_column :course_reviews, :average_quality, :float
add_column :course_reviews, :average_difficulty, :float
add_column :instructor_reviews, :average_quality, :float
end
end
|
# frozen_string_literal: true
require 'json'
require 'logger'
module Yake
module Logger
attr_accessor :logger
def logger
@logger ||= Yake.logger
end
class << self
def new(logdev = $stdout, **params)
::Logger.new(logdev, formatter: Formatter.new, **params)
end
end
... |
require_relative '../../lib/tutsplus/team.rb'
describe Team do
it "has a name" do
Team.new("Random name").should respond_to :name
end
it "has a list of players" do
Team.new("Random name").players.should be_kind_of Array
end
it "is favored if it has a celebrity on it" do
Team.new("Random name... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.