text stringlengths 10 2.61M |
|---|
# This file is part of the sinatra-sse ruby gem.
#
# Copyright (c) 2011, 2012 @radiospiel
# Distributed under the terms of the modified BSD license, see LICENSE.BSD
source "http://rubygems.org"
gem "thin"
gem "sinatra-sse"
|
#!/usr/bin/env ruby
require "net/http"
require "json"
require "uri"
GITHUB_API_URL = "https://api.github.com/graphql"
def run_query(params)
repo_name = params.fetch(:repo_name)
token = params.fetch(:token)
json = {query: latest_release_query(repo_name)}.to_json
headers = {"Authorization" => "bearer #{token}... |
class RomanNumerals
ROMAN_NUMERALS = {1000 => "M", 900 => "CM",500 => "D",
400 => "CD",100 => "C",90 => "XC",
50 => "L",40 => "XL",10 => "X",
9 => "IX", 5 => "V",4 => "IV", 1 => "I"}
#setting the constant ROMAN_NUMERALS allows you to
#call it in the method,... |
class AddRefPhaseToWorkCertificate < ActiveRecord::Migration
def change
add_column :work_certificates, :phase_id, :integer
end
end
|
require "helper"
# Make sure that exit codes of tests are propagated properly when using
# simplecov. See github issue #5
class TestReturnCodes < Minitest::Test
def self.test_order
:alpha
end
context "Inside fixtures/frameworks" do
setup do
@current_dir = Dir.getwd
Dir.chdir(File.join(File.d... |
require_dependency "buginabox/application_controller"
module Buginabox
class BugsController < ApplicationController
before_action :set_bug, except: [:index,:new,:create]
# GET /bugs
def index
if current_user
if current_user.is_a_bug_manager?
@bugs = Bug.order('created_at DESC'... |
#!/usr/bin/env ruby
require 'yaml'
require 'nexpose_ticketing'
# Path to ServiceNow configuration file
SERVICEDESK_CONFIG_PATH = File.join(File.dirname(__FILE__),
'../lib/nexpose_ticketing/config/servicedesk.config')
# Read in ServiceDesk options from servicenow.config
servicedesk_o... |
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe BilgeFile do
let(:bilge) { create(:bilge_file, year: 2017, month: 9, file: File.open(test_image(200, 500), 'r')) }
it 'has the correct number of issues' do
expect(described_class.issues.count).to be(11)
end
describe 'issues' do
it '... |
class ProductCategory < ApplicationRecord
has_many :products
belongs_to :restaurant
validates_associated :restaurant
validates :title, presence: true
end
|
# Write a method that takes a string as an argument, and returns an Array that
# contains every word from the string, to which you have appended a space and
# the word length.
# You may assume that words in the string are separated by exactly one space,
# and that any substring of non-space characters is a word.
# Ps... |
class Report < ApplicationRecord
belongs_to :department
validates :department, presence: true
validates :email, presence: true
def users
department.users.active
end
end
|
require "spec_helper"
RSpec.describe "HTTP Private Api" do
before do
BitflyerApi.configure do |config|
config.key = "dummy_key"
config.secret = "dummy_secret"
end
@client = BitflyerApi.client
end
it "GET my_addresses" do
VCR.use_cassette("get_my_addresses") do
response = @c... |
class HashSet
attr_reader :count
def initialize(num_buckets = 8)
@store = Array.new(num_buckets) { Array.new }
@count = 0
end
def insert(key)
if count >= num_buckets
resize!
end
bucket_idx = key.hash % num_buckets
if !@store[bucket_idx].include?(key.hash)
@store[bucke... |
class AddDeletableFlagToGalleries < ActiveRecord::Migration
def change
add_column :galleries, :deletable, :boolean
end
end
|
require "spec_helper"
RSpec.describe Endpoints::Versions do
include Committee::Test::Methods
include Rack::Test::Methods
def app
Routes
end
def schema_path
"./schema/schema.json"
end
before do
@version = Version.create({
number: '1.0.0',
platform: 'ios',
expiry: DateTime.... |
class Country < ApplicationRecord
acts_as_paranoid
has_many :artists
has_many :bargains
has_many :cities
validates_presence_of :country_symbol, :in_use, :name
validates_uniqueness_of :country_symbol, case_sensitive: false
validates_uniqueness_of :name, case_sensitive: false
end
|
Rails.application.routes.draw do
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
get '/challenges', to: 'challenges#index'
get '/projects/:id', to: 'projects#show'
get '/contestants', to: 'contestant_project#index'
end
|
class ListingsController < ApplicationController
before_action :set_listing, only: [:show, :edit, :update]
def index
params[:search] ||= {}
@listings = Listing.where.not(latitude: nil, longitude: nil)
@listings = @listings.where(city: params[:search][:city]) if params[:search][:city].present?
@list... |
#!/usr/bin/ruby
# unused_role_check.rb: Searches for nodes in your chef server running each role in the roles
# directory. Prints the count of the number of nodes
require 'rubygems'
require 'trollop'
$opts = Trollop::options do
opt :roles, "Path to the roles folder", :default => "~/chef-repo/roles"
e... |
###################################################################################
unless Rails.env.production? # don't allow this to run in production environment!!!
###################################################################################
desc 'replace certain fields with fake data'
task :obfuscate_da... |
class PendencyMailer < ApplicationMailer
def send_new_pendency_email(user)
@user = user
mail(to: @user.email, subject: "Mensalidade atrasada")
end
def send_multiple_pendencies_email(user)
@user = user
mail(to: @user.email, subject: "Atenção às suas mensalidades atrasadas")
end
end
|
class User < ActiveRecord::Base
attr_accessible :user_id
has_many :videos, :dependent => :destroy
has_many :group_members
has_many :groups, :through => :group_members
validates :user_id, :uniqueness => true
def self.getUser(userId)
return where(:user_id => userId).first()
end
end
|
# == Schema Information
#
# Table name: products
#
# id :integer not null, primary key
# title :string(255)
# description :text
# price :float
# created_at :datetime
# updated_at :datetime
# category_id :integer
# user_id :integer
#
class Product < ActiveRecord::Base
belon... |
# frozen_string_literal: true
require 'fake_server'
require 'fake_token_provider'
describe Kafka::SaslAuthenticator do
let(:logger) { LOGGER }
let(:host) { "127.0.0.1" }
let(:server) { TCPServer.new(host, 0) }
let(:port) { server.addr[1] }
let(:connection) {
Kafka::Connection.new(
host: host,
... |
require_relative "pages/roombooking_mainpage.rb"
module Roombookingsite
def homepage
RoombookingMainpage.new
end
end
|
require 'selenium-webdriver'
require 'rspec'
require 'json'
OS = {}
BROWSERS = {}
def set_capabilities
@caps_file = File.expand_path(File.dirname(__FILE__) + '/Capabilities.json')
@parsed_caps = JSON.parse(File.read(@caps_file))
@username = @parsed_caps['user']; @key = @parsed_caps['key']; @server = @parsed_cap... |
# frozen_string_literal: true
require 'rails_helper'
RSpec.feature 'Courses search' do
scenario 'user can search the courses by name' do
FactoryGirl.create(:course, name: 'Foocourse')
FactoryGirl.create(:course, name: 'Barcourse')
visit root_path
click_link I18n.t('layout.nav.courses')
fill_in ... |
require 'csv'
class ImportsCSV
def import
data = []
CSV.foreach('data.csv', headers: true) do |line|
contact = Contact.new
# 1. map the data column to our attr_accessor name
# -- "Name".downcase
# 2. call the attr_accessor and set the value
# attrs = ["Name", "Company", "Ad... |
require './lib/jungle_beat.rb'
require 'minitest/autorun'
require 'minitest/pride'
require 'pry'
class JungleBeatTest < Minitest::Test
def test_can_creat_a_new_test
jb = JungleBeat.new
assert_equal JungleBeat, jb.class
end
def test_if_junglebeat_has_a_linkedlist
jb = JungleBeat.new
assert_equa... |
class Product
include Mongoid::Document
include Mongoid::Timestamps
field :name, type: String
field :price, type: Integer
field :stock, type: Boolean
field :details, type: String
field :description, type: String
has_and_belongs_to_many :tags
end
|
# Write a method that takes a string, and returns a new string in which every consonant character is doubled. Vowels (a,e,i,o,u), digits, punctuation, and whitespace should not be doubled.
def double_consonants(str)
out_str = ''
consonants = %w(b c d f g h j k l m n p q r s t v w x y z)
str.each_char do |c|
... |
require 'rails_helper'
require 'faker'
RSpec.describe Item, type: :model do
let(:my_user) { User.create!(user_name: "User", email:"user@example.io", password: "helloworld") }
let(:my_item) { Item.create!(name: Faker::Hacker.say_something_smart, user: my_user) }
describe "attributes" do
context "valid entry" do
... |
class YellowPages
require 'audible'; include Audible
def search(opts ={})
limit = opts[:limit] || 50
source = YellowPagesSource.new :query => opts[:query] || fail("You must supply :query")
pager = Internal::Pager.new source
source.results = pager
relay source, :result
relay source, ... |
require 'deck.rb'
class Hand
HAND_TYPE = {
:straight_flush => 8,
:four_of_a_kind => 7,
:full_house => 6,
:flush => 5,
:straight => 4,
:three_of_a_kind => 3,
:two_pair => 2,
:pair => 1,
:high_card => 0
}
def initialize(array_of_cards)
@cards = array_of_cards
end
def... |
class BookingsController < ApplicationController
before_action :set_user, only: [:create, :index]
def index
@bookings = Booking.includes(:room)
end
def show
@booking = Booking.find(params[:id])
end
def new
@booking = Booking.new
end
def create
rooms = Room.available_by_date(booking_p... |
require_relative 'editor_command'
require 'topicz/defaults'
require 'json'
require 'fileutils'
require 'zaru'
module Topicz::Commands
class NoteCommand < EditorCommand
def initialize(config_file = nil, arguments = [], kernel = Kernel)
super(config_file)
@kernel = kernel
@strict = false
... |
require 'pry'
class Song
attr_accessor :name, :artist, :genre
@@count = 0
@@genres = []
@@artists = []
def initialize(name, artist, genre)
@name = name
@artist = artist
@genre = genre
@@count += 1
@@genres << genre
@@artists << artist
end
def self.count
@@count
end
def... |
class Outpost::PostsController < Outpost::ResourceController
outpost_controller
define_list do |l|
l.default_order_attribute = "updated_at"
l.default_order_direction = DESCENDING
l.column :title
l.column :post_type,
:header => "Type",
:display => ->(r) { Post::POST_TYPES_TEXT[r.... |
class CreateSpendenWeihnachtsmarkts < ActiveRecord::Migration[6.0]
def change
create_table :spenden_weihnachtsmarkts do |t|
t.string :vorname
t.string :nachname
t.string :iban
t.decimal :summe
t.timestamps
end
end
end
|
require 'rails_helper'
module ChefHelper
RSpec.describe ElasticsearchRoleAttributesGenerator do
before(:each) do
@infrastructure = create(:infrastructure, cluster_name: 'test')
@consul_component = create(:infrastructure_component,
infrastructure: @infrastructure,
hostname: 'tes... |
class MusicFile < ActiveRecord::Base
belongs_to :main_file, :foreign_key => 'link_id', :class_name => "Link"
def type
main_file.category
end
end
|
class User < ApplicationRecord
has_secure_password
belongs_to :city
# has_many :gossips
has_many :gossips
#has_many :comments
validates :first_name, presence: true
validates :last_name,presence: true
validates :email, presence: true
validates :description, presence: true
validates :age, presenc... |
class AddPlayerIdToStartAppearances < ActiveRecord::Migration[5.1]
def change
add_column :start_appearances, :player_id, :integer
add_column :start_appearances, :match_id, :integer
add_column :start_appearances, :opponent_team_id, :integer
end
end
|
require 'set'
# Audit saves the changes to ActiveRecord models. It has the following attributes:
#
# * <tt>auditable</tt>: the ActiveRecord model that was changed
# * <tt>user</tt>: the user that performed the change; a string or an ActiveRecord model
# * <tt>action</tt>: one of create, update, or delete
# * <tt>chan... |
require 'net/http'
require 'digest/sha1'
require 'cgi'
require 'forwardable'
require 'fileutils'
require 'thread'
require 'logger'
module KTorrent
extend self
def log(message)
@log_file ||= Logger.new('log.txt')
@log_file.info(message)
end
def debug(message)
@log_file ||= Logger.new('log.txt')
... |
# -*- encoding : utf-8 -*-
class JobApplicationsController < ApplicationController
layout "admissions"
filter_access_to [:index]
filter_access_to [:update, :destroy, :up, :down], attribute_check: true
def index
@admissions = @current_user.job_applications.group_by { |job_application| job_application.job.ad... |
class AddBuyerAndSellerToOrders < ActiveRecord::Migration
def change
add_column :orders, :buyer, :integer
add_column :orders, :seller, :integer
end
end
|
require 'spec_helper'
describe 'DiagnosticoCovidController' do
let(:plan) do
Plan.new(nombre: 'Neo',
costo: 1000,
cobertura_visitas: CoberturaVisita.new(0, 0),
cobertura_medicamentos: CoberturaMedicamentos.new(0),
cantidad_hijos_maxima: 1,
conyuge:... |
cask :v1 => 'aviator' do
version :latest
sha256 :no_check
url 'https://updates.aviatorbrowser.com/Aviator.dmg'
name 'WhiteHat Aviator'
homepage 'https://www.whitehatsec.com/aviator/'
license :oss
app 'Aviator.app'
end
|
FactoryGirl.define do
factory :spree_shipping_category, class: Spree::ShippingCategory do
sequence(:name) { |n| "Shipping Category #{n}" }
end
end
|
require 'pokereval'
describe PokerEval do
pe = PokerEval.new
it "Can abbreviate hands" do
pe.str_to_abbr('TcJc').should eq('JTs')
pe.str_to_abbr('TcJh').should eq('JTo')
pe.str_to_abbr('TcTh').should eq('TT')
pe.str_to_abbr('2hAh').should eq('A2s')
end
it "Can get Sklansky groups" do
pe.hand_to_sklansky... |
class ProposalStep < ApplicationRecord
INITIATED = "Initiated"
SCHEDULED = "Scheduled"
ONSITE_COMPLETED = "Onsite Completed"
PROPOSAL_PRESENTED = "Proposal Presented"
CLOSED_NOT_SELECTED = "Closed, Not Selected"
SELECTED = "Selected"
belongs_to :proposal
validates :name, presence: true
end
|
# frozen_string_literal: true
module RunningCount
VERSION = "0.2.9"
end
|
class SugarBeansController < ApplicationController
# This controller provides a generic interface to SugarCRM. It expects
# a module name to be passed as an argument
def list
@sugar_module = params[:module]
begin
@beans = class_for(params[:module]).all(:limit => 10)
rescue NameError
@suga... |
require 'spec_helper'
describe Post do
let(:user) { create(:user) }
let(:post) { user.posts.create(content: "This is the content of the post") }
it "should be valid" do
expect(post).to be_valid
end
it "should be associated with a user" do
post.user_id = nil
expect(post).to_not be_valid
end
... |
require 'bcrypt'
class User < ActiveRecord::Base
has_many :saved_tests
validates :email, presence: true, uniqueness: true
validates :hash_password, presence: true
include BCrypt
def password
@password ||= Password.new(hash_password)
end
def password=(new_password)
@password = Password.create... |
# frozen_string_literal: true
# Query objects for cases
class CaseQuery
def initialize(scope = Case.all)
@scope = scope
end
# Get the most recent cases as of a date, where most recent is occurring
# within 30 days of the date
def most_recent_as_of(date:)
period_begin = date - 30.days
created_by(... |
class CookbooksController < ApplicationController
def list
@cookbooks = Cookbook.where("user_id = '#{ current_user.id }'")
end
def show
@cookbook = Cookbook.find(params[:id])
cookbook_entries = @cookbook.cookbook_entries
recipes = cookbook_entries.collect &:recipe
@content = []
rec... |
# This file is to be loaded _before_ any RubyGems are loaded. This file
# initializes the Bundler context so that Vagrant and its associated plugins
# can load properly, and then execs out into Vagrant again.
if defined?(Bundler)
require "bundler/shared_helpers"
if Bundler::SharedHelpers.in_bundle?
puts "Vagra... |
class AddUnaccessedDocumentsCountToProtocol < ActiveRecord::Migration
def change
add_column :protocols, :unaccessed_documents_count, :integer, default: 0
end
end
|
resource_name 'sumologic_syslog_rsyslog'
property :cookbook, String, default: 'sumologic-syslog'
property :deployment, String, default: 'eu'
property :port, String, default: '6514'
property :token, String
property :rsyslog_action, Symbol, default: :restart
default_action :create
action :create do
include_recipe 'r... |
require 'gosu'
require './zorder'
require './settings'
require './player'
require './star'
class Tutorial < Gosu::Window
def initialize()
super(Settings::WINDOW_WIDTH, Settings::WINDOW_HEIGHT)
self.caption = Settings::CAPTION
@background_image = Gosu::Image.new("media/space.png", tileable:... |
class AddSpecialofferimageToSpecialoffer < ActiveRecord::Migration
def up
add_attachment :specialoffers, :specialofferimage
end
def down
remove_attachment :specialoffers, :specialofferimage
end
end
|
require 'rails_helper'
RSpec.describe '/companies endpoints', type: :request do
describe 'GET /companies' do
let!(:company) { FactoryBot.create(:company) }
it 'returns a conversation' do
get companies_url
expect(response.body).to include(company.to_json)
end
end
describe 'GET /companie... |
#!/usr/bin/env ruby
require 'rubygems'
require 'mysql2'
#m = Mysql2::Client.new(:host => 'localhost', :username => '', :password => '...')
m = Mysql2::Client.new(:database => 'test')
def suspicious?(rows)
max = max_touched_rows(rows)
return max && max > 10
end
def max_touched_rows(rows)
max = nil
rows.each do |r... |
class CreateReviewHouses < ActiveRecord::Migration
def change
create_table :review_houses do |t|
t.integer :user_id, null: false
t.string :title, null: false
t.string :address, null: false
t.datetime :start_time, null: false
t.datetime :end_time, null: false
t.integer :price_sa... |
##
# Creates a new media based on a given url
#
# The url is visited, parsed and the data found is used to create a media
# and its attributes.
#
# The data can be obtained by +API+ or parsing directly the +HTML+.
#
# To avoid the duplication of media for the same url, it tries to find the
# canonical url and normalize... |
class Product < ActiveRecord::Base
validates :title, length: { in: 3..50 }
validates :price, numericality: { greater_than: 0 }
validates :description, length: { minimum: 2 }, allow_blank: true
end
|
#
# Cookbook Name:: rsyslog-wrapper
# Recipe:: default
#
# Copyright 2014, Naoya Nakazawa
#
# All rights reserved - Do Not Redistribute
#
case node['platform_family']
when 'rhel'
if node['platform_version'].to_i == 5
node.override['rsyslog']['preserve_fqdn'] = false
node.override['rsyslog-wrapper']['syslogd_... |
require 'rubygems'
require 'bundler/setup'
require 'rspec'
require 'capybara/rspec'
require "selenium/webdriver"
# This file was generated by the `rspec --init` command. Conventionally, all specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
# The generated `.rspec` file contains `--require spec... |
module VehicleCertificatesHelper
def fetch_path(certificate)
certificate.new_record? ? vehicle_vehicle_certificates_path : vehicle_vehicle_certificate_path
end
def fetch_method(certificate)
certificate.new_record? ? :post : :put
end
end
|
require "rails_helper"
RSpec.describe "When I visit a bachelorette/contestants index" do
before :each do
@bach1 = Bachelorette.create!(
name: "Amy",
season_number: 10
)
@man1 = @bach1.contestants.create!(
name: "Donald",
age: 34,
hometown: "Miami"
)
@man2 = @bach1.co... |
require File.dirname(__FILE__) + '/../spec_helper'
describe Riopro::KillBill::Return::Itau do
describe "Sample file test" do
before(:each) do
@return_file = Riopro::KillBill::Return::Itau.new('./spec/return/../../examples/sample_data/retorno_itau_teste.ret', true)
end
describe "header" d... |
# U3.W8-9: Triangle Debugger
# I worked on this challenge [by myself].
# 1. Original Solution
=begin
def valid_triangle?(a, b, c)
sum = a+b+c
if a != 0 && b != 0 && c != 0
if a >= b
largest = a
sum += b
else
largest = b
sum += a
end
if c > largest
... |
class LinksController < ApplicationController
before_action :set_user
# TODO: get this flash message working and tested
def create
@link = @user.links.create(link_params)
if @link.save
else
flash[:notice] = "Invalid url, please try a valid web address"
end
redirect_to links_path
end
... |
class Author < ApplicationRecord
validates :first_name, presence: true
validates :last_name, presence: true
validates :age, presence: true, numericality: true
has_many :authorships
has_many :books, through: :authorships
end
|
class InvitationsController < Devise::InvitationsController
before_action :authenticate_user!
before_action :require_admin, only: [:new, :create]
before_action :update_sanitized_params, only: :update
protected
def after_invite_path_for(current_user)
new_user_invitation_path
end
def after_accept_pat... |
require 'migration_helper'
class CreateEventAttendances < ActiveRecord::Migration
extend MigrationHelper
def self.up
create_table :event_attendance_statuses do |t|
t.string :name, :null => false
t.string :description, :null => false
end
EventAttendanceStatus.new(:name => EventAttendanceStat... |
#! /usr/bin/env ruby
require 'net/http'
require 'json'
def help
puts "Some required config options have not been setup, please contact the repo admin"
exit
end
# The following options are required:
# git config hooks.upsource.url 'https://upsource-url.com'
# git config hooks.upsource.project-id 'upsour... |
class TreeNode
attr_accessor :term, :children, :parent
def initialize(term)
@term = term
@children = []
@parent = nil
end
def clear!
@children = []
end
# TODO: remerge divergent paths.
def find_by_term(str)
idx = @children.map(&:term).index(str)
return nil if idx.nil?
@ch... |
class RenameEndColumnToEvents < ActiveRecord::Migration
def change
rename_column :events, :start, :actual_start
rename_column :events, :end, :actual_end
end
end
|
class RemoveIndexOfRepos < ActiveRecord::Migration[5.2]
def change
remove_index :repos, :url
remove_index :repos, :user_id
end
end
|
require 'push_builder/version'
require 'push_builder/payload'
require 'push_builder/aps'
require 'push_builder/compiler'
require 'push_builder/string_cropper'
module PushBuilder
TypeError = Class.new(StandardError)
def self.build(args={})
Payload.new.tap do |payload|
args.each { |k, v| payload.aps.send(... |
require 'deck'
require 'rspec'
describe Deck do
#all elements are instances of Card.
#deck size of 52
#all different cards
subject(:deck) { Deck.new }
describe "#initialize" do
it "contains only instances of Card" do
expect(deck.cards.all? { |c| c.class == Card }).to be true
end
it "cont... |
# frozen_string_literal: true
module GraphQL
module Tracing
# This is the base class for a `trace` instance whose methods are called during query execution.
# "Trace modes" are subclasses of this with custom tracing modules mixed in.
#
# A trace module may implement any of the methods on `Trace`, bein... |
require 'active_model'
require 'colorable'
module ToyRobotSimulator
# A Board that a Robot can roam around on
class Board
include ActiveModel::Validations
include Colorable
attr_reader :left_boundary, :right_boundary,
:top_boundary, :bottom_boundary
attr_accessor :occupied_posit... |
require 'rspec'
require 'date'
require_relative '../model/calendario'
require_relative '../model/persistor'
require_relative '../model/GeneralError'
require_relative '../model/evento_diario'
require_relative '../model/evento_semanal'
require_relative '../model/actualizador_evento'
require_relative '../model/recurrenci... |
# encoding: UTF-8
class Requirement < ActiveRecord::Base
before_create :set_initial_status, :set_generation_date, :set_user_responsible
after_create :send_email
after_update :send_update_email
attr_accessible :type_requirement_id, :registry, :name, :course, :generation_date, :closing_date, :status, :value, :pa... |
class AttachmentMailerPreview < ActionMailer::Preview
include MailerPreviewHelpers
def new_attachment_notification
AttachmentMailer.new_attachment_notification(new_user, proposal, attachment)
end
private
def attachment
Attachment.last
end
end
|
class CreateOrders < ActiveRecord::Migration[6.1]
def change
create_table :orders do |t|
t.references :customer
# t.references :merchant
t.float :total_price
t.timestamps
end
add_index :orders, [:customer_id, :created_at]
add_index :orders, [:merchant_id, :created_at]
add_... |
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel... |
module Geopath
module Insights
class Inventory < Geopath::Client
class << self
def search(query = {})
options = merge_headers({ body: query.to_json })
results = post('/inventory/search', options)
results = Geopath::Insights::Models::Inventory::Search.new(results['inven... |
class AddColumnToUsers < ActiveRecord::Migration[5.1]
def change
add_column :users, :first_name, :string
add_column :users, :last_name, :string
add_column :users, :sex, :string
add_column :users, :phone, :string
add_column :users, :address, :string
add_column :users, :zipcode, :string
add_... |
class AnswersController < ApplicationController
def create
@question = Question.find(params[:question_id])
@answer = @question.answers.new(answers_params)
@answer.user = current_user
@answer.save
redirect_to question_path(@question)
end
def update
# should a user be able to update an an... |
#encoding: utf-8
require_relative "tipo_casilla"
module ModeloQytetet
class Casilla
attr_reader :coste, :tipo
attr_accessor :numHoteles, :numCasas, :titulo, :numeroCasilla, :numeroCasilla
def initialize(nCasilla, c, t)
@numeroCasilla = nCasilla
@coste = c
@tipo = t
end
... |
class Refund < ActiveRecord::Base
# -------------- SECTION FOR ASSOCIATIONS --------------------
# -------------------------------------------------------------
belongs_to :user
belongs_to :subscription
belongs_to :order
# -------------- SECTION FOR SCOPES --------------------
# -----------------------... |
class QuestionPolicy
attr_reader :user, :record
def initialize(user, record)
@user = user
@record = record
end
def index?
@user.roles.each do |u|
if u.title == "Administrator"
return true
end
end
return false
end
class Scope
attr_reader :user, :scope
def i... |
class SymptomGroup < ApplicationRecord
has_many :symptoms
validates :name, presence: true
enum icon: %i(happy sad angry confused thoughtful caring)
enum category: %i(physical mood)
class << self
def normalize_categories(categories)
return SymptomGroup.categories.values unless categories.present?
... |
require 'rails_helper'
def create_website(url)
website = Website.create(account: Account.new, name: 'Test Site', domain_url: url, theme: 'basic')
return website
end
RSpec.describe Block, type: :model do
it "returns correct blocks_splice_calc" do
website = Website.create(account: Account.new, name: 'Test Sit... |
Pod::Spec.new do |s|
s.name = "AnnotationInject"
s.version = "0.5.1"
s.source = { :git => "https://github.com/akane/AnnotationInject.git",
:tag => s.version.to_s }
s.summary = "Swift dependency injection with an... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.