text stringlengths 10 2.61M |
|---|
def consolidate_cart(cart)
# code here
new_obj = {}
cart.each do |item|
item.each do |food, info|
new_obj[food] ||= {}
new_obj[food] = info
# bang operator here to see if there is a "count" key in the obj. If there isn't we give it a count key with an intial value of 1.
if !new_obj[foo... |
class Oystercard
LIMIT = 90
MINIMUM = 1
MINIMUM_CHARGE = 4
attr_reader :balance
attr_reader :entry_station
def initialize
@balance = 0
@in_journey = false
end
def top_up(money)
fail "Maximum balance of #{LIMIT} exceeded" if @balance + money > LIMIT
@balance += money
end
def touch... |
class User < ApplicationRecord
include Clearance::User
validates :email, :full_name, :age, presence: :true
end
|
class AuthController < ApplicationController
def auth
username = params[:username]
password = params[:password]
creds = {
'admin' => 'admin',
'userName' => 'password',
}
if creds[username] == password && !password.nil?
render status: :ok, json: {notice: 'Login OK'}
else
... |
require 'rails_helper'
feature 'Only author can delete the answer', %q{
In order to remove my incorrect or not smart answers
As an author of the answer
I'd like to be able to delete my answer
} do
given(:answer) { create(:answer) }
describe 'An authenticated user'do
given(:user) { create(:user) }
... |
# -*- coding: utf-8 -*-
require 'logger'
module Fluent
class NonBufferedTagFileOutput < Output
Fluent::Plugin.register_output('nonbuffered_tagfile', self)
config_param :dir_root, :string
config_param :format, :string
def configure(conf)
super
@loggers = {}
end
def shutdown
... |
class Bullet < Sprite
BULLET_SPEED = 6.0
attr_reader :source_id, :bound_count
def initialize(x, y, image, source_id, radian)
@bound_count = 2
@source_id = source_id
@velocity_x = Math.cos(radian) * BULLET_SPEED
@velocity_y = Math.sin(radian) * BULLET_SPEED
... |
# 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... |
require 'gosu'
# Player car
class Car
WIDTH = 32
LENGTH = 64
MASS = 10
MOMENT_OF_INERTIA = 5000
LINEAR_ACCELERATION = 5400
REVERSE_ACCELERATION = LINEAR_ACCELERATION / 3
ANGULAR_ACCELERATION = 0.1
ANGULAR_FRICTION = 0.9
attr_reader :rigid_body, :collision_shape
attr_reader :angular_velocity
a... |
module Api
class ReelsController < ApiController
def create
@reel = current_user.reels.new(reel_params)
if @reel.save
render json: @reel
else
render json: @reel.errors.full_messages, status: :unprocessable_entity
end
end
def update
@reel = Reel.find(params[... |
class SpirvCross < Formula
desc "Tool for parsing and converting SPIR-V to other shader language"
homepage "https://github.com/KhronosGroup/SPIRV-Cross"
url "https://github.com/KhronosGroup/SPIRV-Cross.git", :commit => "a029d3faa12082bb4fac78351701d832716759df"
version "2019-02-20"
revision 1
head "https://... |
#
# Copyright 2009 Huygens Instituut for the History of the Netherlands, Den Haag, The Netherlands.
#
# This file is part of New Women Writers.
#
# New Women Writers is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundat... |
require_relative 'game_vector'
require_relative 'player'
class GameState
attr_accessor :started
attr_accessor :score
attr_accessor :alive
attr_accessor :scroll_x
attr_accessor :player_pos
attr_accessor :player_vel
attr_accessor :player_rotation
attr_accessor :obstacles
attr_accessor :obstacle_countdo... |
class DinersGroup < ApplicationRecord
belongs_to :diner
belongs_to :group
end
|
class Product < ApplicationRecord
has_many :user_products
has_many :users, through: :user_products
end
|
class DsrMailer < ActionMailer::Base
default from: "from@example.com"
# Subject can be set in your I18n file at config/locales/en.yml
# with the following lookup:
#
# en.dsr_mailer.send_dsr.subject
#
def send_dsr
@tasks = {}
Employee.all.each do |employee|
@tasks[employee] = Task.where(e... |
class League
class Roster
class TransferRequest < ApplicationRecord
belongs_to :roster
belongs_to :leaving_roster, class_name: 'Roster', optional: true
belongs_to :user
belongs_to :created_by, class_name: 'User'
belongs_to :approved_by, class_name: 'User', optional: true
belo... |
module SynchroConsumer
class StorageProcessor
def initialize(host: 'localhost', port: 6379)
@host, @port = host, port
puts ">>>>>> StorageProcessor initialized"
connect
end
def queue_message(message)
puts ">>>>>> StorageProcessor.queue_message"
@redis.lpush 'Synchro:messages... |
require "rails_helper"
RSpec.describe MessageSearch, :search do
describe "#search" do
it "searches on message body" do
user = create(:user)
conversation = create(:conversation, user: user)
message = create(:incoming_message, body: "Test message", conversation: conversation)
reindex_search... |
class Graph < Array
attr_reader :edges
def initialize(links, station_time=1, transfer_time=1)
@station_time, @transfer_time = station_time, transfer_time
@edges = []
@neighbors = {}
@vertices = links.nodes
links.each do |link|
connect_mutually(link.node1, link.node2)
end
@dist... |
module ActiveRecord
module Snapshot
class Logger
def self.call(*args, &block)
new(*args).call(&block)
end
def initialize(step)
@step = step
end
def call
start
yield.tap do |success|
success ? finish : failed
end
end
def... |
class AddMyRecipeIngredientLinkToMyRecipe < ActiveRecord::Migration[5.2]
def change
add_reference :my_recipes, :my_recipe_ingredient_link, foreign_key: true, index: {unique: true}
end
end
|
=begin
The Command class is subclassed to allow
for plugin commands.
=end
require 'lib/help'
class Command < HelpTopic
@commands = []
class << self
attr_accessor :commands
#Loads all commands from file
def load
Dir["plugins/*.rb"].each do |f|
require f
end
end
#Allows us to traverse ... |
# frozen_string_literal: true
module Simulation
module GnuplotHelper
def set_title
@title ? "set title '#{@title}'" : 'set notitle'
end
def columns_string
"($#{@columns.join('):($')})"
end
def plot_files
strings = plots.map { |plot| file_line(plot) }
"plot #{strings.joi... |
class EmailDigest < ActiveRecord::Base
validates_format_of :email, :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i
validates :first_name, :presence => {:message => 'Please fill out your first name.'}
validates :last_name, :presence => {:message => 'Please fill out your last name.'}
def self.send_email_... |
require './game_board'
class Game
attr_reader :game_board
attr_reader :number_set
def initialize
@number_set = [*(0..9)]
end
def load_board(*params)
@game_board = GameBoard.new(*params)
end
def solve
solve_game(game_board.board)
game_board
end
private
def solve_game(board)
if ... |
class Book
BOOKS = [
"Potter1",
"Potter2",
"Potter3",
"Potter4",
"Potter5"
]
attr_accessor :quantity
attr_reader :title
def initialize(title,quantity)
@title = title
@quantity = quantity
end
end |
class AddPasswordExpiredAtToMatches < ActiveRecord::Migration
def change
add_column :matches, :password_expired_at, :datetime, after: :password
end
end
|
# Title: Return Value of while
# Using the ruby documentation, determine what value a while loop returns.
# According to the documentation: The result of a while loop is nil unless break is used to supply a value.
|
Pod::Spec.new do |s|
s.name = "LAbstractViewController"
s.version = "1.0"
s.platform = :ios, '6.0'
s.source = { :git => 'https://github.com/lukagabric/LAbstractViewController'}
s.source_files = "LAbstractViewController/Classes/Core/LAbstractViewController/*.{h,m}"
s.framework = 'Co... |
RSpec.feature 'User can click on a username and be directed to user wall', type: :feature do
scenario 'User clicks on a username' do
visit '/'
click_on 'Signup'
fill_in('user[username]', with: 'user1')
fill_in 'user[email]', with: 'test@test.com'
fill_in 'user[password]', with: 'password'
page... |
$LOAD_PATH.unshift(File.expand_path("../../lib", __FILE__))
require 'benchmark'
require 'rspec/mocks'
Benchmark.bm do |bm|
bm.report("fetching a proxy") do
RSpec::Mocks.with_temporary_scope do
o = Object.new
100_000.times {
RSpec::Mocks.space.proxy_for(o)
}
end
end
end
# Without... |
class Api::V1::ArtistsController < ApplicationController
# before_action :set_artist, only: [:show, :edit, :update, :destroy]
# GET /artists
# GET /artists.json
def index
@artists = Artist.all
render :json =>@artists.as_json(methods: :image_url)
end
# GET /artists/1
# GET /artists/1.json
def s... |
require "spec_helper"
describe Bijou::Request do
describe "#initialize" do
it "Expects one argument to be passed in" do
expect{ Bijou::Request.new }.to raise_error ArgumentError
end
it "Returns a new Rack Request instance when an argument is passed in" do
expect(Bijou::Request.new(ENV).vars)... |
$LOAD_PATH.push File.expand_path("lib", __dir__)
# Maintain your gem's version:
require "timely_scopes/version"
# Describe your gem and declare its dependencies:
Gem::Specification.new do |spec|
spec.name = "timely_scopes"
spec.version = TimelyScopes::VERSION
spec.authors = ["Alex Cruice"]
spec... |
require 'systemu'
module Traut
def self.spawn(params, &block)
uid = params[:user].nil? ? Process::UID.eid : Etc::getpwnam(params[:user])[:uid]
gid = params[:group].nil? ? Process::GID.eid : Etc::getgrnam(params[:group])[:gid]
command = params[:command] || require('parameter :command is required')
pay... |
require 'rails_helper'
RSpec.describe ChargesController, type: :controller do
describe "#downgrade" do
context "current user role is premium" do
let(:user) do
User.create!(
role: :premium,
email: 'email@email.com',
password: 'password'
)
end
before... |
# frozen_string_literal: true
RSpec.shared_examples 'same task' do
it 'returns the same name, description, number of comments' do
subject
create_list(:comment, 3, task: task, user: user)
expect(assigns(:task)).to eq task
expect(assigns(:task).name).to match task.name
expect(assigns(:task).descrip... |
module IControl::LocalLB
##
# The ProfileIIOP interface enables you to manipulate a local load balancer's IIOP
# profile.
class ProfileIIOP < IControl::Base
set_id_name "profile_names"
class ProfileIIOPStatisticEntry < IControl::Base::Struct; end
class ProfileIIOPStatistics < IControl::Base::Struc... |
class AddUrlDescriptionToTrail < ActiveRecord::Migration[5.0]
def change
add_column :trails, :url, :string
add_column :trails, :description, :text
end
end
|
template "/etc/rc.local" do
source "rc.local.erb"
mode "0766"
end
execute "set-hostname" do
command "/root/set-hostname.sh"
action :nothing
end
template "/root/set-hostname.sh" do
source "set-hostname.sh.erb"
mode "0700"
variables hostname: node[:hostname]
notifies :run, resources(execute: "set-hostna... |
require "test_helper"
describe Product do
describe "validations" do
it "can be valid" do
new_product = products(:p1)
assert( new_product )
end
it "is invalid if name is blank" do
new_product = products(:p1)
new_product.name = nil
expect(new_product.valid?).must_equal fa... |
RSpec.describe Player do
let(:config) do
{
name: "test",
position: Vector[0,0],
}
end
subject { Player.new(config) }
it "has the expected initial values" do
expect(subject.name).to eq("test")
expect(subject.position).to eq(Vector[0,0])
end
context "the config is empty" do
l... |
class PlayersController < ApplicationController
before_filter :get_players, only: [:index]
def index
end
def new
@player = Player.new
end
def create
@player = Player.new(player_params)
if @player.save
flash[:success] = "#{@player.first_name} #{@player.last_name} has been created"
... |
RSpec.feature "BEIS users can view other organisations" do
context "when the user is not logged in" do
before do
logout
end
it "redirects the user to the root path" do
visit organisations_path
expect(current_path).to eq(root_path)
end
end
RSpec.shared_examples "lists partner or... |
class AddUniqueIdToEvent < ActiveRecord::Migration
def change
add_column :events, :unique_id, :string
add_index :events, :unique_id
end
end
|
require 'spec_helper'
describe Project do
it "should add the user that creates the project as your owner" do
project = Factory.create(:project)
user = project.owner
user.has_role?(:owner, project).should == true
end
end
|
require "httparty"
require File.expand_path(File.dirname(__FILE__) + "/periplus/bing_response")
require File.expand_path(File.dirname(__FILE__) + "/periplus/request")
require File.expand_path(File.dirname(__FILE__) + "/periplus/route")
require File.expand_path(File.dirname(__FILE__) + "/periplus/location")
module Peri... |
require File.expand_path('../helper', __FILE__)
Citrus.load(File.expand_path('../_files/super', __FILE__))
Citrus.load(File.expand_path('../_files/super2', __FILE__))
class SuperTest < Test::Unit::TestCase
def test_terminal?
rule = Super.new
assert_equal(false, rule.terminal?)
end
def test_match
g... |
# Write a method that takes an Array of integers as input, multiplies all the
# numbers together, divides the result by the number of entries in the Array,
# and then prints the result rounded to 3 decimal places. Assume the array is
# non-empty.
def show_multiplicative_average(arr)
count = 0
total = 1.to_f
l... |
Gem::Specification.new do |s|
s.name = "makura"
s.version = "2009.03.21"
s.summary = "Ruby wrapper around the CouchDB REST API."
s.description = "Ruby wrapper around the CouchDB REST API."
s.platform = "ruby"
s.has_rdoc = true
s.author = "Michael 'manveru' Fellinger"
s.email = "m.fellinger@gmail.com"
... |
#!/usr/bin/env ruby
# Generated by the protocol buffer compiler. DO NOT EDIT!
require 'protocol_buffers'
module RailsPipeline
# forward declarations
class EncryptedMessage < ::ProtocolBuffers::Message; end
class EncryptedMessage < ::ProtocolBuffers::Message
# forward declarations
# enums
module Ev... |
class PlusganttHookListener < Redmine::Hook::ViewListener
include PlusganttUtilsHelper
render_on :view_issues_sidebar_issues_bottom, :partial => "plusgantt/issues_sidebar"
render_on :view_projects_show_right, :partial => "plusgantt/project_show_right"
def controller_issues_new_after_save(context={})... |
require 'cgi'
require 'open-uri'
require 'nokogiri'
require 'terminal-table/import'
require 'active_support'
require 'friendly_id/slug_string'
require 'rbosa'
require 'pp'
require 'commander/user_interaction'
require 'singleton'
require 'imp3/config'
require 'imp3/cache'
require 'imp3/commands'
OSA.utf8_strings = true... |
module UserPhotoHelper
def user_review_thumb(review, extra_style=nil, extra_class=nil, only_path=false, reputation_flyover_id=nil)
user_photo_thumb(review.user, extra_style, extra_class, only_path, reputation_flyover_id)
end
def user_review_mini(review, extra_style=nil, extra_class=nil)
user_phot... |
class Quote < ApplicationRecord
belongs_to :author
belongs_to :theme
validates :content, presence: true, length: {maximum: 200}
def self.get_random_by_theme(theme)
themeID = Theme.get_theme_by_name(theme).id
return Quote.where('theme_id = ?', themeID).sample
end
end
|
# frozen_string_literal: true
require 'test_helper'
# FIXME(uwe): Remove and use IntegrationTest instead
class ActionController::TestCase
teardown { clear_user }
def login(login = :uwe)
self.current_user = users(login)
end
def assert_logged_in(user = :uwe)
user = users(user) if user.is_a? Symbol
... |
class Outfit < ActiveRecord::Base
has_many :groupings
belongs_to :user
end |
require 'spec_helper'
describe Bitcourier::Protocol::Message::Hello do
before do
@hello = Bitcourier::Protocol::Message::Hello.new
@hello_bytes = "{\x00\x11\x00\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF".force_encoding(Encoding::BINARY)
end
it 'initiates with default version number' do
@hello.protocol_v... |
class RemoveDealsUserName < ActiveRecord::Migration
def change
remove_column:deals,:user_name,:string
end
end
|
class SendRecoverLink
require 'mailgun'
def self.call(user)
new.call(user)
end
def call(user)
mailer.send_message("sandbox_domain_name_for_your_account.mailgun.org", {from: "bookmarkmanager@mail.com",
to: user.email,
subject: "reset your password",
text: "click here to reset yo... |
class Database
def self.conn
@conn ||= ConnectionPool.new(size: 1, timeout: 5) { Sequel.connect(Application.database_config) }
end
end |
require 'grit'
class SidekiqTask
include Sidekiq::Worker
class GitTask < SidekiqTask
sidekiq_options queue: :git
AUTHORIZED_KEYS = File.expand_path YamlConfig['git.authorized_keys']
FileUtils.mkdir_p GitRepo::DIRECTORY unless File.directory? GitRepo::DIRECTORY
class InitRepository < GitTask
def perform... |
class Api::V1::TransactionsController < Api::V1::BaseController
def object_type
Transaction
end
def invoice
respond_with current_transaction.invoice
end
private
def current_transaction
Transaction.find_by(id: params[:id])
end
def finder_params
params.permit(:id,
... |
require 'addressable'
module Fog
module Storage
class GoogleJSON
module Utils
def http_url(params, expires)
"http://" << host_path_query(params, expires)
end
def https_url(params, expires)
"https://" << host_path_query(params, expires)
end
def u... |
# frozen_string_literal: true
require 'message'
describe Message do
describe '.all' do
it 'returns a list of all messages' do
message = Message.all('1')
expect(message.first).to be_a Message
expect(message.first.message).to eq 'Your house is a lot nicer than mine'
end
end
describe '.... |
# frozen_string_literal: true
require 'test/unit'
class Egzaminas
def pazymys(x)
if x > 10
'Per didelis skaicius'
elsif x <= 0
'Per mazas skaicius'
elsif x >= 5
'islakytas'
else
'neislaikytas'
end
end
end
puts 'iveskite pazymi: '
x = gets.to_i
puts Egzaminas.new.pazymy... |
class Admin::NotificationRecipientsController < Admin::ApplicationController
before_filter { authorize! :manage, :notifications }
def create
@notification = Notification.find(params[:notification_id])
@notification.recipients.where(user_id: params[:user_id]).first_or_create!
redirect_to [:admin, @notif... |
#!/usr/bin/env ruby
require_relative 'simulator'
if ARGV.length > 0
puts File.read(File.dirname(__FILE__) + '/../README.md')
exit
end
simulator = Simulator.new
command = STDIN.gets
while command
output = simulator.execute(command)
puts output if output
command = STDIN.gets
end |
require File.expand_path('../../../spec_helper', __FILE__)
require 'aethon'
describe Aethon::Client do
def subject; Aethon::Client.new(@connection, @query_options, @options); end
before do
@connection = Object.new
@query_options = {}
@options = {}
end
it 'sets #connection' do
subject... |
require 'yelp'
require 'json'
class YelpClient
# initialize
def initialize
@client = Yelp::Client.new(
{
# consumer_key: ENV['YELP_CONSUMER_KEY'],
# consumer_secret: ENV['YELP_CONSUMER_SECRET'],
# token: ENV['YELP_TOKEN'],
# token_secret: ENV['YELP_TOKEN_SECRET']
con... |
class Rename < ActiveRecord::Migration
def up
rename_column :events, :startsAt, :starts_at
rename_column :events, :endsAt, :ends_at
end
def down
end
end
|
module MultiInfo
# This module provides the core implementation of the Clickatell
# HTTP service.
class API
# Defaults for config file location
DEFAULT_CONFIG_PATH = File.join(ENV['HOME'], 'multiinfo')
DEFAULT_CONFIG_FILE = 'multiinfo.yml'
attr_accessor :auth_options
class << self ... |
Rails.application.routes.draw do
resources :feedbacks
resources :chassis
resources :wheelbases
resources :subitems
resources :subitem_categories
resources :subitem_fields
resources :shipment_informations
resources :category_field_values
resources :items
resources :category_fields
resources :fiel... |
class Post < ApplicationRecord
belongs_to :user
has_many :comments, dependent: :destroy
has_many :likes, dependent: :destroy
has_many :members, dependent: :destroy
mount_uploader :image, FileUploader
def like_for(user)
likes.find_by_user_id user
end
def member_for(user)
members.find_by_use... |
class Points::ManageUserController < ModuleController
include ActiveTable::Controller
permit 'points_manage'
component_info 'Points'
def self.members_view_handler_info
{
:name => 'Points',
:controller => '/points/manage_user',
:action => 'view'
}
end
# need to include
activ... |
# Copyright 2011 (c) MaestroDev. All rights reserved.
require 'childprocess'
require 'tempfile'
require 'rbconfig'
module Maestro
module Util
class Shell
attr_reader :script_file
attr_reader :output_file
attr_reader :shell
attr_reader :exit_code
class ExitCode
attr_reade... |
# frozen_string_literal: true
require_relative 'utils'
require_relative '../filter'
module Mastodon
module REST
module Filters
include Mastodon::REST::Utils
# Create a new filter
# @param options [Hash]
# @option options :phrase [String]
# @option options :context [Array<String>]
... |
module Api
module V2
class ActivePlayersController < ApplicationController
before_action :load_table
before_action :load_player, only: [:create, :destroy]
def index
render json: @table.active_players
end
def create
@player.update!(active: true)
render json: ... |
require "gds_api/test_helpers/search"
require_relative "../../test/support/rummager_helpers"
module TopicHelper
include GdsApi::TestHelpers::Search
include RummagerHelpers
def stub_topic_lookups
rummager_has_documents_for_subtopic(
"content-id-for-fields-and-wells",
%w[
what-is-oil
... |
class GameController < Controller
def sign_in
name = params['username']
username = params['username'].strip[0..12].downcase
log "sign_in 1"
if username.size < 3
return { result: 'error', message: "username is too short" }.to_json
end
user = User.first(username: username)
if user
... |
class SingleFeatureRequirements < ActiveRecord::Migration
def change
add_reference :requirements, :feature, index: true
add_column :requirements, :position, :integer
end
end
|
module Api
module V1
# Releases controller that loads releases by a selected artist
class ReleasesController < ApplicationController
def index
releases = Release.all
render json: releases
end
def create
new_release = Release.create(create_release_params)
rend... |
# EDIT:
get '/channel/:channel_id/subscriptions/:id/edit' do
authorize!
@channel = Channel.find(params[:channel_id])
@subscription = @channel.subscriptions.find(params[:id])
erb :'subscriptions/edit'
end
# EDIT2:
get '/entries/:id/edit' do
@entry = Entry.find(params[:id])
if current_user.id == @entry.user... |
class Team
attr_accessor :name, :motto
TEAMS = []
def initialize(team_params)
@name = team_params[:name]
@motto = team_params[:motto]
TEAMS << self
end
def self.all
TEAMS
end
end |
class Company < ApplicationRecord
has_many :branches, dependent: :destroy
has_many :regions, through: :branches
has_many :services, through: :branches
validates :name, uniqueness: true
validate :can_be_disabled, if: :disabled?
scope :with_avg_service_price, -> do
select('*, avg_service.price AS avg_pr... |
# frozen_string_literal: true
RSpec.describe Brained::Name do
context "wash" do
it "concantenates strings longer than 12 characters" do
name = Brained::Name.new("по́мнюизвчера́шнегодня")
expect(name.to_s).to eq("pómnüizwche")
end
end
context "initialize" do
it "should convert Cyrillic c... |
class Appointment < ActiveRecord::Base
include Timeable
validates :begin_date, :begin_time, :external_participant_salutation, :external_participant_name, presence: true
validates :external_participant_title, length: { maximum: 10 }
validates :external_participant_name, :external_participant_company, :clear_grou... |
require './lib/kernel_functions/kernel_function'
class SignumKernelFunction < KernelFunction
def self.function(x)
x > 0 ? 1 : 0
end
def self.derivation(x)
raise 'Derivation doesn`t exists.'
end
end |
require_relative 'hand'
require 'colorize'
class Player
attr_reader :hand,:pot
def initialize(pot = 100)
@hand = Hand.new
@pot = pot
end
def hand_empty?
@hand.empty?
end
def hand_full?
@hand.full?
end
def to_s
@hand.to_s
end
def earn... |
Pod::Spec.new do |s|
s.name = "DB5-Swift"
s.version = "0.0.1"
s.source = { :git => "https://github.com/babbage/DB5-Swift.git" }
s.platform = :ios, '9.0'
s.requires_arc = true
s.source_files = 'Pod/Classes'
s.resources = 'Pod/Assets/*'
s.module_name = 'DB5-Swift'
end... |
require "test_helper"
class PowerSupplyTest < MiniTest::Test
def test_positive_lead_provides_positive_charge
power_supply = ElectricMotor::PowerSupply.new
assert_equal :positive, power_supply.positive_lead.charge
end
def test_negative_lead_provides_negative_charge
power_supply = ElectricMotor::Powe... |
class ApplicationController < ActionController::Base
before_action :authenticate_user
helper_method :current_user
private
def authenticate_user
redirect_to log_in_path unless current_user
end
def current_user
User.find_by(id: session[:user_id]) if session[:user_id]
end
end
|
class Company
attr_reader :name
attr_accessor :employees
#This represents a company in which people work
def initialize(name = "Michael's", employees = [])
@name = name
@employees = employees
end
def company_info
puts "#{@name} employees"
@employees.each{ |emplo... |
class PostsController < ApplicationController
respond_to :json
before_filter :auth_user
before_filter :group_member, only: [:create, :user_posts_in_one_group, :group_posts]
before_filter :referred_user_is_group_member, only: [:user_posts_in_one_group]
before_filter :authorized_member, ... |
class RemoveClolumnTagsImageFromIdeas < ActiveRecord::Migration[5.2]
def change
remove_column :ideas, :tag_image, :text
end
end
|
require 'image'
describe 'Image#colour_pixel' do
let(:image){Image.new(columns:2, rows:2)}
it 'should colour a pixel' do
expect{image.colour_pixel(column:0,
row:0,
colour: :C)}
.to change{image.to_s}
.from("OO\nOO")
.to("CO\nOO")
end
... |
# frozen_string_literal: true
# rubocop:todo all
# Copyright (C) 2014-2020 MongoDB Inc.
#
# 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
#
# U... |
class Event < ApplicationRecord
has_many :participations
has_many :event_items
accepts_nested_attributes_for :participations
end
|
require "digest"
require_relative 'manticore_helper'
class ManticoreExtraRc < Formula
desc "Manticore meta package to install manticore-executor and manticore-columnar-lib dependencies"
homepage "https://manticoresearch.com"
url "file://" + File.expand_path(__FILE__)
sha256 Digest::SHA256.file(File.expand_path... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.