text stringlengths 10 2.61M |
|---|
class Color < ApplicationRecord
has_many :shoe_model_colors
has_many :shoe_models, through: :shoe_model_colors
end
|
class ProjectInvitation < ActiveRecord::Base
include Datapimp
include Stateflow
belongs_to :project
belongs_to :recipient, :class_name => "User"
stateflow do
initial :created
state :created, :sent, :resent, :accepted, :rejected
event :send_invitation do
transitions :from => :created, :to ... |
module UserConcerns
module StudentClasses
extend ActiveSupport::Concern
included do
# teacher student classes
has_many :administered_student_classes,
class_name: 'StudentClass',
foreign_key: :admin_user_id
has_and_belongs_to_many :student_classes
has_ma... |
require './lib/response_codes'
class OutputView
include ResponseCodes
def initialize
@hello_count = 0
end
def generate_header(response, code)
["http/1.1 #{code}",
"date: #{Time.now.strftime('%a, %e %b %Y %H:%M:%S %z')}",
"server: ruby",
"content-type: text/html; charset=iso-8859-1",... |
# sequence_count.rb
# Create a method that takes two integers as arguments. The first argument is a
# count, and the second is the first number of a sequence that your method will
# create. The method should return an Array that contains the same number of
# elements as the count argument, while the values of each elem... |
class CategoriesController < ApplicationController
before_action :authenticate_user!, only: [:new, :create, :edit]
before_action :check_role, only: [:new, :create, :edit]
has_scope :by_title
def index
@categories = apply_scopes(Category).all
@categories = Kaminari.paginate_array(@categories).page(params[... |
# require 'minitest/spec'
# require 'minitest/autorun'
# describe OrientdbBinary::Parser do
# describe 'Deserializer' do
# before do
# @parser = OrientdbBinary::Parser::Deserializer.new
# end
# describe "parsing sets" do
# before do
# record = "DocWithSets@a_set:<\"one\",\"two\",3,#... |
class AddKindToLinks < ActiveRecord::Migration
def change
add_column :links, :kind , :string
Link.all.each do |link|
link.update_attributes(kind: link.hnscore > 80 ? 'top' : 'keyword' )
end
end
end
|
class TopicsController < ApplicationController
before_action :find_topic, only: [:edit, :update, :destroy]
def index
@topics = Topic.all
end
def new
@topic = Topic.new
end
def create
@topic = Topic.new(title: params[:topic][:title])
if @topic.save
flash[:success] = "Topic Created"
redirect_to top... |
require "comparable_solve"
class Solve < Struct.new(:time, :dnf)
include ComparableSolve # including <=> into ActiveRecord subclass messes with default equality operator -.-
def dnf?
!!dnf
end
end
describe ComparableSolve do
context "solved vs solved" do
it "sorts by time" do
expect(Solve.new(1... |
# require_relative 'seeds/users.rb'
require_relative 'seeds/cryptocurrencies.rb'
puts '-' * 32
puts 'Destroying all records'
Cryptocurrency.destroy_all
User.destroy_all
puts '-' * 32
CRYPTOCURRENCIES.each do |currency|
puts "Creating #{currency[:name]} currency..."
response = HTTParty.get("https://api.coingecko... |
require 'test_helper'
require 'video'
describe Video do
let(:name) { "Welcome to Tuts+" }
let(:description) { "In this lesson you'll learn about the proxy pattern." }
let(:video) { Video.new name, description }
it "shows the name" do
capture { video.play }.string.must_include name
end
it "shows the d... |
class Author < ActiveRecord::Base
has_many :books
has_and_belongs_to_many :books
end
|
require 'spec_helper'
require 'rails_helper'
describe V1::TokensController, type: :controller do
let!(:account) { create(:account) }
let!(:credentials) do
{ account: { email: account.email, password: account.password } }
end
describe '#create' do
it 'returns 201' do
post :create, credentials
... |
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
before_action :current_user
def is_authenticated
unless current_user
flash[:danger] = "Credentials Invalid!!"
redirect_to login_path
end
end
def current_user
@current_user ||= User.find_by_id(session... |
class AddColumnsToCharity < ActiveRecord::Migration
def change
add_column :charities, :geographic_region, :string
add_column :charities, :area_of_impact, :string
add_column :charities, :percent_of_overhead, :string
add_column :charities, :religious_affiliation, :string
add_column :charities, :how_... |
# spec/mixin_spec.rb
require 'spec_helper'
require 'mixin'
module Mithril
module Mock; end
end # module
describe Mixin do
before :each do
foo = Module.new
foo.send :extend, Mixin
foo.send :define_method, :foo do; end
Mithril::Mock.const_set :Foo, foo
foo_m = Module.new
foo_m.sen... |
MARKUP_RATES = { flat_markup: 0.05,
worker_markup: 0.012,
product_type_markup: { 'drugs': 0.075, 'food': 0.13, 'electronics': 0.02 }
}
class Order
attr_reader :base_price, :number_of_workers, :product_type, :total_price
def initialize(order_details = {})
base_pr... |
ActiveAdmin.register Job do
actions :all, :except => :destroy
permit_params :discount, :promotion_id, :property_id, :started_at, :status, :frequency, :agent_id, :source, job_details_attributes: [:id, :service_id, :value, :_destroy ]
csv do
column :id
column :duration
column :agent_id
column "Agen... |
class Crop < ApplicationRecord
belongs_to :user
belongs_to :plant
has_many :reminders
has_many :cycles, through: :crop_cycles
has_many :crop_cycles
def plant_name
if self.cycles.first
self.cycles.first.plant.name
else
"ascasfa"
end
end
def has_started?
self.crop_cycles.first.is_st... |
# # # 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: 'L... |
require 'nokogiri'
require 'open-uri'
require 'pry'
class Student
attr_accessor :name, :twitter, :linkedin, :facebook, :website
attr_reader :id
@@students = []
def initialize(hash = {})
@@students << self
@name = hash[:name]
@twitter = hash[:twitter]
@facebook = hash[:facebook]
@linke... |
module ApplicationHelper
def sanitized_object_name(object_name)
object_name.gsub(/\]\[|[^-a-zA-Z0-9:.]/,"_").sub(/_$/,"")
end
def sanitized_method_name(method_name)
method_name.sub(/\?$/, "")
end
def form_tag_id(object_name, method_name)
"##{sanitized_object_name(object_name.to_s)}_#{sanitized_method_na... |
OrderMailer.class_eval do
default :reply_to => Spree::Config[:reply_to_email_address]
def quote_email(order, resend=false)
@order = order
subject = (resend ? "[RESEND] " : "")
subject += "#{Spree::Config[:site_name]} Quote for Order ##{order.number}"
mail(:to => order.email, :subject => subject)
... |
module LoginMacros
#for controller spec
def log_in_as(user)
session[:user_id] = user.id
end
def fill_in_form_with(profile)
fill_in 'Name', with: profile.name
fill_in 'Email', with: profile.email
fill_in 'Password', with: profile.password
fill_in 'Confirmation', with: profile.password
end
def sign_up(... |
class User < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :validatable
mount_uploader :photo, PhotoUploader
has_many :sent_m... |
require_relative 'reservation'
module Hotel
class Room
attr_reader :room_number
attr_accessor :status
def initialize(room_number, status = :Available)
@room_number = room_number
@status = status
end
def self.create_rooms
@all_rooms = [ ]
room_number = 0
20.times do... |
class Match < ActiveRecord::Base
#habtm mapping
has_many :team_matches
has_many :player_stats
accepts_nested_attributes_for :team_matches
accepts_nested_attributes_for :player_stats
has_many :hero_bans
has_many :teams, through: :team_matches
has_many :players, through: :player_stats
belongs_to :win... |
class CreateLanguagesAndExtendWords < ActiveRecord::Migration
def self.up
create_table "languages" do |t|
t.column "display_name", :string
t.column "iso_code_2", :string
end
drop_table "words"
create_table "password_sets" do |t|
t.column "principal_type", :string
t.co... |
class RenameArtistidToArtistId < ActiveRecord::Migration
def self.up
rename_column :albums, :artistid, :artist_id
end
def self.down
rename_column :albums, :artist_id, :artistid
end
end
|
require "sheep-wall/parser"
require "base64"
require "json"
require "uri"
module SheepWall
class Parser
class HTTPParser < Parser
filter 'http.request'
field 'http.host'
field 'http.request.uri.query'
field 'http.authorization'
field 'http.content_type'
field 'http.cookie_pa... |
def my_method
puts "Welcome, to Jurrasic Park."
3.times {yield}
puts "Oh no, here comes the dinosaurs!"
end
my_method { puts "roar" }
capital_cities = ["Madison", 'Tallahassee', 'Springfield', 'Albany', 'Oklahoma City' ]
states = {
:Wisconsin => 'WI',
:Florida => 'FL',
:Illinois => 'IL',
... |
class AddMoveToTransfers < ActiveRecord::Migration
def change
add_column :transfers, :move, :boolean
end
end
|
# frozen_string_literal: true
class AddEadIdToXmlCache < ActiveRecord::Migration[5.2]
def change
add_column :xml_caches, :ead_id, :string
end
end
|
# -*- coding: utf-8 -*-
require 'json'
require 'hashie'
class ConfigLoader
class << self
def load
Hashie::Mash.new JSON.parse(open('config/config.json', 'r:utf-8').read)
end
end
end
|
# Method to create a list
# input: string of number then item separated by spaces (example: "carrots apples")
# Break apart string of items on the space
# steps:
# Create an empty item array to hold items for list
# Call each on the item array to turn each value into a key for the hash
# set default quantity to 1
# Us... |
# frozen_string_literal: true
require "test_prof"
require_relative "./before_all"
module TestProf
# Just like `let`, but persist the result for the whole group.
# NOTE: Experimental and magical, for more control use `before_all`.
module LetItBe
class << self
def module_for(group)
modules.fetch... |
class ShoeSerializer < ActiveModel::Serializer
attributes :id, :name, :description, :brand, :image_url, :release_year, :price
end
|
# frozen_string_literal: true
class BadgeCheckService
attr_reader :user, :passing_test
def initialize(user, passing_test)
@user = user
@passing_test = passing_test
end
def call
received_badges = []
Badge.all.each do |badge|
received_badges << badge if send("passed_#{badge.rule.kind}?", ... |
#require 'rubygems'
#require 'kramdown'
require 'bluecloth'
#require 'redcloth'
module Typedown
class Document < String
def initialize text = nil
super ""
self << text if text
end
def to_markdown
text = self
# Translate '! headings' to '# headings'
text.gsub!(/^! /, "# ")
... |
require 'tvdb_party'
require_dependency 'search_utils'
class CentralTVDatabase
def api
@api ||= TvdbParty::Search.new(APP_CONFIG[:tvdb_api_key])
end
def find_series_by_id(id)
api.get_series_by_id(id)
end
def find_series_by_name(name)
results = api.search(name)
results = api.search(SearchUti... |
class CreateVocabulary < ActiveRecord::Migration[5.2]
def change
add_column :profiles, :concepts_count, :integer
create_table :vocabulary_concepts, id: :uuid do |t|
t.references :profile, foreign_key: true, type: :uuid
t.references :source, foreign_key: {to_table: :vocabulary_concepts}, type: :uu... |
class Membercapability < ActiveRecord::Base
belongs_to :member
belongs_to :capability
end
|
class AddNoticesToPreferences < ActiveRecord::Migration
def self.up
add_column :preferences, :last_closed_notice_date, :datetime
end
def self.down
remove_column :preferences, :last_closed_notice_date, :datetime
end
end
|
class ShopsController < ApplicationController
before_action :set_shop, only: [ :show_by_name, :about, :update ]
before_action :set_theme
before_action :prepare_shop_views_path
before_action :shop_page_info, except: [ :update_name, :show ]
# caches_page :show, :show_by_name, :about
def show_by_name
set_... |
# frozen_string_literal: true
RSpec.shared_context 'with branch location' do
let(:branch) { build(:branch) }
let(:location) { build(:location) }
before do
branch.save!
location.save!
end
end
|
def prime_sieve_upto(n)
all_nums = (0..n).to_a
all_nums[0] = all_nums[1] = nil
all_nums.each do |p|
#jump over nils
next unless p
#stop if we're too high already
break if p * p > n
#kill all multiples of this number
(p*p).step(n, p){ |m| all_nums[m] = nil }
end
#remove unwanted nils
... |
module BitflyerApi::Methods::Private
module Trade
def my_send_child_order(product_code:, child_order_type:, side:, price: nil, size:,
minute_to_expire: 43200, time_in_force: "GTC")
body = "{
'product_code': \"#{product_code}\",
'child_order_type': \"#{child_order_type}\",
'sid... |
class Annoint::Application < Sinatra::Base
@@issue_cache = {}
get '/' do
call env.merge("PATH_INFO" => "/issue/#{Annoint::INDEX.keys.sort[0]}")
end
get '/issue/:year/:month/:day' do |year, month, day|
year = 1900+year.to_i if year.to_i < 100
@date = DateTime.new(year.to_i, month.to_i, day.t... |
require 'pry'
class String
def sentence?
self[-1] == "."
end
def question?
self[-1] == "?"
end
def exclamation?
self[-1] == "!"
end
def count_sentences
library = ("a".."z").to_a
count = 0
new_sentence = self.downcase.delete(",").chars
new_sentence.each_with_index {|char,... |
class CoursesController < ApplicationController
def index
end
def show
@courses = Course.all
end
def new
@course = Course.new
end
def create
@course = Course.new(user_params)
if @course.save
flash[:success] = "Account has been created"
... |
require File.dirname(__FILE__) + '/../lib/jstest'
namespace :test do
desc "Runs all the JavaScript unit tests and collects the results"
JavaScriptTestTask.new(:javascripts, 4711) do |t|
testcases = ENV['TESTCASES']
tests_to_run = ENV['TESTS'] && ENV['TESTS'].split(',')
browsers_to_test = ... |
require 'rails_helper'
describe "user can visit a single idea page" do
it "user can click on a single idea see the idea show page" do
user = create(:user)
idea1 = Idea.create!(name: "idea1", description: "read", user: user, category: build(:category))
idea2 = Idea.create!(name: "idea2", description: "lea... |
class AddBoargameGeekMissingAttributesToProducts < ActiveRecord::Migration[5.0]
def change
add_column :products, :bgg_id, :string
add_column :products, :publication_year, :integer
add_column :products, :image_url, :string
add_column :products, :versions, :jsonb, null: false, default: []
add_column... |
Rails.application.routes.draw do
root 'application#index'
resources :users
get '*paths', to: 'application#index'
end
|
# issute_templates テーブルの1レコードを保持する。
class IssueTemplate < ActiveRecord::Base
unloadable
belongs_to :project
# project_id, title, descriptionは必須
validates_presence_of :project_id, :title, :description
# titleは同じproject_idの範囲では一意
validates_uniqueness_of :title, :scope => :project_id
end
|
class BlogPost < ActiveRecord::Base
has_attached_file :image, :styles => {:thumb => "100x100>"}, :url => "/assets/blog/:style/:id.:extension", :path => ":rails_root/public/assets/blog/:style/:id.:extension", :default_url => "/assets/blog/:style/missing.png"
validates_attachment_content_type :image, :content_type =>... |
class Badging < ActiveRecord::Base
belongs_to :badge
belongs_to :subject, :polymorphic => true
scope :unseen, {:where => {:seen => false}}
def mark_as_seen
update_attributes(:seen => true)
end
end |
class AddPartyColumnToCaughtPokemons < ActiveRecord::Migration[6.0]
def change
add_column :caught_pokemons, :party, :boolean
end
end
|
# == Schema Information
#
# Table name: comments
#
# id :integer not null, primary key
# date :date
# content :text
# user_id :integer
# review_id :integer
#
require 'spec_helper'
describe Comment do
describe '.new' do
it 'creates an instance of Comment' do
comment = Comment.... |
# Represents application Member, currently only with :email and :name attributes
class Member < ApplicationRecord
has_many :invites, dependent: :destroy
validates :name, presence: true
validates :email, presence: true, uniqueness: true
end
|
require 'test_helper'
class MonitorTest < Test::Unit::TestCase
class Deadpool::Monitor::AllUp < Deadpool::Monitor::Base
def primary_ok?
true
end
def secondary_ok?
true
end
end
class Deadpool::Monitor::PrimaryDown < Deadpool::Monitor::Base
def primary_ok?
false
end
... |
class RenameColumn < ActiveRecord::Migration
def change
rename_column :chartboost_instances, :formato_click_timestamp, :format_click_timestamp
end
end
|
#
#
action :create do
Chef::Log.info("Creating nginx service #{new_resource.service_id}")
serviceRootFolder = "#{new_resource.prefix_folder}/front/#{new_resource.client_id}/#{new_resource.service_id}"
confDir = "#{serviceRootFolder}/conf"
logsDir = "#{serviceRootFolder}/logs"
docrootDir = "#{serviceRootFolder}/d... |
require 'spec_helper'
describe UsersController do
describe "routing" do
it "routes to sign_in" do
get("/accounts/sign_in").should route_to("devise/sessions#new")
end
it "routes to sign_in2" do
post("/accounts/sign_in").should route_to("devise/sessions#create")
end
it "routes to sig... |
require 'rails_helper'
describe Staff::Authenticator do
let!(:staff) { build(:staff_member) }
let!(:early_staff) { build(:staff_member, start_date: Date.tomorrow) }
let!(:expired_staff) { build(:staff_member, end_date: Date.yesterday) }
let!(:truthy_pass) { 'password' }
let!(:falsey_pass) { 'passwordhoge' }
... |
class BillType < ActiveRecord::Base
has_many :bills
has_paper_trail
validates :name, presence: true, uniqueness: { scope: :account_id }
scope :for_account, -> (account) { where(account_id: account.id) }
scope :default_order, -> { order :name }
end
|
class Story < ActiveRecord::Base
validates :editor_tagline, :presence => { :message => "EDITOR TAGLINE is required" }
validates :description, :presence => { :message => "DESCRIPTION is required" }
validates :title, :presence => { :message => "TITLE is required" }
attr_accessor :slocation_ids, :splace_category... |
class Ability
include CanCan::Ability
def initialize(user)
user ||= User.new # guest user
if user && user.admin?
can :access, :rails_admin
can :dashboard
if user.super_admin?
can :manage, :all
elsif user.adm... |
class AddFieldsForTesting < ActiveRecord::Migration
def change
add_column :products, :price, :decimal, precision: 8, scale: 2
create_table :transactions do |t|
t.belongs_to :user, index: true
t.belongs_to :product, index: true
end
end
end
|
# frozen_string_literal: true
module Vedeu
module Cells
# Provides the character/escape sequence to draw one cell of a
# with a custom value, colour and style.
#
# The Vedeu::Cells::Char object represents an alpha-numeric
# character.
#
# @api private
#
class Char < Vedeu::Cells... |
# -*- encoding : utf-8 -*-
module ViewMatchers
def have_link_to(path, optional_text = nil)
have_tag("a[href='#{path}']", optional_text)
end
end
|
class PranaCompPlan
COMPANY_PRANA = "PRANA"
QUICK_START = 4000.00
DEFERRED_QUICK_START = 2000.00
LEVEL_1 = 200.00
LEVEL_2 = 600.00
LEVEL_3 = 200.00
ACTIVE_DOWNLINES_FOR_QUICK_START = 3
MIN_VOLUME = 200
def self.calculate_quick_starts period_start, period_end, launch_event = false
users = Us... |
module Mplay
def self.options=(opts)
@@options=opts
end
def self.options
@@options
end
def self.run(program)
if old = ::Mplay.options[:old, nil, CONFIG[:VdExpire]]
Mplay.old(old)
end
if limit = ::Mplay.options[:limit, nil, CONFIG[:VdLimit]]
Mplay.limit(limit)
... |
# typed: true
class AddFields2ToWitAiParseModelExamples < ActiveRecord::Migration[6.0]
def change
add_column :wit_ai_parse_model_examples, :parsable_resource_entity_value_start_index, :integer
add_column :wit_ai_parse_model_examples, :parsable_resource_entity_value_end_index, :integer
end
end
|
require_relative './music_importer'
class Song
extend Concerns::Findable
extend Concerns::Memorable::ClassMethods
include Concerns::Memorable::InstanceMethods
attr_accessor :name, :artist, :genre
@@all = []
def initialize(name, artist=nil, genre=nil)
@name = name
self.artist = artist unless artis... |
def getCount(inputStr)
inputStr.count("/[aeiou]/")
end
=begin
Return the number (count) of vowels in the given string.
We will consider a, e, i, o, and u as vowels for this Kata.
|
class CollaborationsController < ApplicationController
before_action :authenticate_user!
before_action :load_user, only: [:create, :destroy]
def create
@collaboration = @user.collaborations
.build(:collaborator_id => params[:collaborator_id])
respond_to do |f|
f.js
f.html do
if... |
class ActivateBatchWorker
include Sidekiq::Worker
def perform(*args)
time_travel
@current_time = Time.current
Cultivation::ActivateBatch.call(@current_time)
time_travel_return
end
private
def time_travel
if ENV['ENABLE_TIME_TRAVEL'] == 'yes'
config = System::Configuration.first
... |
require 'spec_helper'
require 'kaede'
require 'kaede/database'
require 'kaede/recorder'
require 'kaede/updater'
describe Kaede::Recorder do
let(:notifier) { double('Notifier') }
let(:recorder) { described_class.new(notifier) }
let(:db) { Kaede::Database.new(DatabaseHelper.database_url) }
let(:job) { db.get_jo... |
module Sheets
module Parsers; end
module Renderers; end
class Utilities
def self.subclasses_in(klass)
klass.constants.collect {|constant_name| klass.const_get(constant_name) }
end
end
class UnsupportedSpreadsheetFormatError < StandardError; end
end
lib_path = File.expand_path(File.dirname(__F... |
require 'spec_helper'
describe ActionParamsPermitter::Builders::Resource do
subject(:resource_builder) { described_class.new(name, state) }
let(:name) { :tutorial }
context 'when state is hash' do
let(:state) { {} }
context 'and block passed' do
it 'builds properly' do
result = resource_... |
class AddSolutionToQuizSolutions < ActiveRecord::Migration[6.1]
def change
add_column :quiz_solutions, :solution, :string
end
end
|
class Blog < ActiveRecord::Base
validates :name, :description, :presence => true
has_many :posts
has_many :owners
has_many :users, through: :owners
end
|
module PriorityTest
module Core
# Remove dependency of Sequel so that it can move out of autoload
autoload :Test, 'priority_test/core/test'
autoload :TestResult, 'priority_test/core/test_result'
end
def self.configure
yield configuration if block_given?
end
def self.configuration
@config... |
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# ▼ Variable Cover Rates
# Author: Kread-EX
# Version 1.01
# Release date: 25/12/2012
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#-------------------------------------------------------------------... |
require 'spec_helper'
describe Chanko do
shared_examples_for 'helper' do
it 'should regist' do
Chanko::Helper.register('foo') do
def bar; 'bar'; end
end
Chanko::Helper.instance_methods(false).map(&:to_s).should be_include(Chanko::Unit.unit_method_name('foo', 'bar'))
end
it 'sho... |
# External Requirements
require 'resque'
require 'authify/core'
require 'authify/core/jobs/email'
module Authify
# The Authify::Worker module
module Worker
CONFIG = Core::CONFIG.merge(
db: {
url: ENV['AUTHIFY_DB_URL'] || 'mysql2://root@localhost:3306/authifydb'
},
redis: {
hos... |
# frozen_string_literal: true
class Shift < ApplicationRecord
belongs_to :event
enum kind: { casting: 0, cleanup: 1, special: 2 }
enum state: { enabled: 0, disabled: 1 }
has_many :attendee_shifts, dependent: :restrict_with_error
has_many :event_attendees, through: :attendee_shifts
def self.generate_shif... |
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
def sns_login
@user = User.find_userinfo(request.env['omniauth.auth'])
if @user.persisted?
flash[:notice] = t('devise.sessions.signed_in')
sign_in_and_redirect @user, event: :authentication
else
redirect_to ... |
require_relative 'board.rb'
class Game
def initialize(file = './puzzles/almost.txt')
@board = Board.from_file(file)
end
def get_move
puts 'Please enter a position and a value (space separated):'
print '>> '
pos_val = gets.chomp.split(" ").map(&:to_i)
pos = pos_val[0..1]
val = pos_val[2]
@board.update... |
class DashboardController < ApplicationController
def index
@jobs_by_location = Job.count_by_location
@companies_by_interest = Company.companies_by_interest
@count_by_interest = Job.count_by_interest
@header = 'Job Tracker Dashboard'
end
end
|
require 'spec_helper'
module Boilerpipe::SAX::TagActions
describe Chained do
let(:tag1) { double('tag1') }
let(:tag2) { double('tag2') }
let(:chainer) do
Chained.new(tag1, tag2)
end
describe '.new' do
it 'takes two other tag actions' do
tag1 = double('tag1')
tag2 = d... |
# frozen_string_literal: true
RSpec.describe 'Change password' do
resource 'Change password request' do
route '/api/v1/change_password', 'Change password' do
post 'Change password' do
with_options scope: %i[data attributes] do
parameter :token, required: true
parameter :password... |
# safely separates encoded message into texts of designated size
module SeparateIntoTexts
# returns encoded message as array of texts of proper char sizes
# do this because we don't want to split keys in wrong place
def self.separate(encodedMessage, textSize)
encodedChars = encodedMessage.split("")
sep... |
RSpec.describe DeallocateKitInventoryService, type: :service do
let(:organization) { create :organization }
let(:item1) { create(:item, name: "Item11", organization: organization, on_hand_minimum_quantity: 5) }
let(:item2) { create(:item, name: "Item 2", organization: organization, on_hand_minimum_quantity: 1) }
... |
require 'rails_helper'
describe MembershipsController do
describe '#index' do
it 'renders index if admin' do
admin = create_user(admin: true)
user = create_user
project = create_project
membership = create_membership(user_id: user.id, project_id: project.id)
session[:user_id] = ad... |
class AddEndedAtToRide < ActiveRecord::Migration
def change
add_column :rides, :ended_at, :datetime, :after => :deleted_at
end
end
|
include_recipe 'dmg'
dmg_package 'LibreOffice' do
volumes_dir "LibreOffice 3.3"
source node[:chimpstation_pkg][:libreoffice][:release_url]
checksum node[:chimpstation_pkg][:libreoffice][:checksum]
action :install
end
|
# encoding: utf-8
require 'spec_helper'
describe Libgeo::Coordinate do
let(:instance) do
described_class.new(
params[:hemi],
params[:degrees],
params[:minutes],
params[:seconds]
)
end
let(:second_instance) do
described_class.new(
second_params[:hemi],
second_para... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.