text stringlengths 10 2.61M |
|---|
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.box = "bugyt/archlinux"
# Create a private network, which allows host-only access to the machine
# using a specific IP.
config.vm.network "private_network", ip: "192.168.33.10"
config.vm.synced_folder "salt/", "/srv/salt"
... |
FactoryBot.define do
factory :access_token do
sequence(:token) {|n| "accesstoken#{n}" }
association :user
end
end
|
num = 0
case num
when 0
puts "Zero"
when 1
puts "One"
else
puts "Other value"
end |
#!/usr/bin/env ruby
# :title: PlanR::Application::ScriptManager
=begin rdoc
=PlanR ScriptManager
(c) Copyright 2016 Thoughtgang <http://www.thoughtgang.org>
=end
# WARNING: this code is under active development and highly subject to change
require 'thread'
require 'plan-r/document/script'
require 'plan-r/applicati... |
# encoding: utf-8
#
# © Copyright 2013 Hewlett-Packard Development Company, L.P.
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
#... |
module Concerns::Paginated
extend ActiveSupport::Concern
private
#
# GETパラメータから"page"を取得
#
def pager_param
page = 0
obj = params.permit(:page)
if obj[:page].present? and (obj[:page].is_a?(Integer) or obj[:page] =~ /\d+/)
page = obj[:page].to_i
end
return page
end
end
|
# frozen_string_literal: true
# Category model
class Category
include Mongoid::Document
include Mongoid::Timestamps
field :name, type: String
belongs_to :user
has_many :subcategories
has_many :transactions
validates :name, presence: true
validates :name, uniqueness: { scope: :user_id, case_sensitive... |
class AddLinkAddressToApartments < ActiveRecord::Migration[5.0]
def change
add_column :apartments, :link_address, :string
end
end
|
#!/usr/bin/env ruby
# Copyright 2015, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of... |
require 'cgi'
require 'aws/s3'
module S3backup
class S3Wrapper
attr_reader :bucket
DEFAULT_MAX_RETRY_COUNT = 30
def initialize(config,create_flg)
@bucket= nil
@s3objects =nil
#設定ファイルの内容をメンバ変数にセット
set_config(config)
#設定ファイルの内容をメンバ変数にセット
args = {
:access_key_id ... |
# Given an array of elements, return true if any element shows up three times in a row
#
# Examples:
# got_three? [1, 2, 2, 2, 3] # => true
# got_three? ['a', 'a', 'b'] # => false
# got_three? ['a', 'a', 'a'] # => true
# got_three? [1, 2, 1, 1] # => false
def got_three?(items)
items.each.with_index {|item, in... |
require "rails_helper"
RSpec.describe "GET /api/v1/on_duty_firm/:location_uid/:time" do
it_behaves_like "a protected endpoint", "/api/v1/on_duty_firm"
context "with an authorization token" do
include_context "valid client token"
let(:court_uid) { SecureRandom.uuid }
let(:procurement_area) {
cre... |
require 'termistat/config'
require 'termistat/tee_io'
require 'termistat/version'
begin
require 'ffi-ncurses'
rescue LoadError
require 'rubygems'
require 'ffi-ncurses'
end
#
# Termistat is a status bar for your terminal
#
# :title:Termistat
module Termistat
#
# The +status_bar+ instance method initializes ... |
require 'spec_helper'
describe Piece do
let(:board) { Board.new }
let(:piece) { Piece.new(board, :white, "a1") }
describe "#rank" do
it "returns the rank" do
expect(piece.rank).to eq(1)
end
end
describe "#file" do
it "returns the file" do
expect(piece.file).to eq("a")
end
end
... |
require 'spec_helper'
describe 'UserSessionPages' do
let(:user) { FG.build(:user) }
describe 'GET /users/sign_in' do
let(:submit) { 'ログイン' }
before(:each) do
visit user_session_path
end
it 'はログインの見出しを表示する' do
expect(page).to have_title('welcome to sul')
expect(page).to have_cont... |
require 'test_helper'
class TrainingSessionsControllerTest < ActionController::TestCase
setup do
@training_session = training_sessions(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:training_sessions)
end
test "should get new" do
get :ne... |
Rails.application.routes.draw do
devise_for :users
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
root 'pages#home'
get '/profile', to: 'profiles#show'
get '/profile/edit', to: 'profiles#edit'
post '/profile', to: 'profiles#create'
patch '/profile', ... |
module Vcloud
module Core
# Public interface to allow direct access to the API
# if functionality does not exist in Core
class ApiInterface
def fog_service_interface
@fog_service_interface ||= Vcloud::Core::Fog::ServiceInterface.new
end
def fog_model_interface
@fog_mod... |
class RenameIngredientIdToIngredientsId < ActiveRecord::Migration[5.0]
def change
rename_column :doses, :ingredient_id, :ingredients_id
end
end
|
ActiveAdmin.register Reward do
menu priority: 3
config.filters = false
config.per_page = 15
action_item :view_site do
link_to "Go to information page", "/informations", target: "_blank"
end
index do
selectable_column
column "Reward", sortable: :description do |reward|
link_to reward.desc... |
# frozen_string_literal: true
require 'encase'
require 'jiji/configurations/mongoid_configuration'
require 'jiji/model/settings/abstract_setting'
module Jiji::Model::Settings
class RMTSetting < AbstractSetting
include Encase
include Mongoid::Document
field :agent_setting, type: Array, default:... |
# frozen_string_literal: true
module Vedeu
module Templating
# Generic class to loading a template and parsing it via ERb.
#
# @api private
#
class Template
# @param (see #initialize)
# @return (see #parse)
def self.parse(object, path, options = {})
new(object, path, ... |
module Merchant
class SaleRule < ActiveRecord::Base
belongs_to :merchant_store
belongs_to :card_segment, :class_name => 'Bank::CardSegment'
validate :check_customer_rate
before_validation :calculate_customer_rate
after_save :update_customer_rate
after_destroy :update_customer_rate
private... |
require 'spec_helper'
describe CSVCoordinateAccessor do
it 'has a version number' do
expect(CSVCoordinateAccessor::VERSION).not_to be nil
end
let(:target) do
target = CSV.read(File.expand_path('../fixtures/sample.csv', __FILE__))
target.extend CSVCoordinateAccessor
target
end
describe '#get... |
class UploadproductActivityship < ActiveRecord::Base
attr_accessible :activity_id, :uploadproduct_id
belongs_to :activity
belongs_to :uploadproduct
end
|
class ChangeProblemsVisibilityToContestOnly < ActiveRecord::Migration
class Problem < ActiveRecord::Base
end
def change
add_column :problems, :contest_only, :boolean, :default => true
reversible do |dir|
dir.up do
Problem.reset_column_information
Problem.all.each do |problem|
... |
module XCB
class Screen < FFI::Struct
layout :root, :window,
:default_colormap, :colormap,
:white_pixel, :uint32,
:black_pixel, :uint32,
:current_input_masks, :uint32,
:width_in_pixels, :uint16,
:height_in_pixels, :uint16,
:width_in_mill... |
class AlterFilenameFromMoneyArrivalFiles < ActiveRecord::Migration
def change
remove_column :money_arrival_files, :filename, :string
add_column :money_arrival_files, :file_name, :string
end
end
|
require 'rankforce'
require 'rubygems'
require 'sequel'
module RankForce
class DB
def initialize
@config = RankForce.load('db')
@table = @config['tablename'].intern
dbconnect
end
def select
begin
return dataset
rescue => e
RankForce.error(e)
end
e... |
class ChangeTaskDeadlineOfTasks < ActiveRecord::Migration[6.1]
def change
change_column :tasks, :task_deadline, :datetime, default:-> { 'CURRENT_TIMESTAMP' }
end
end
|
require 'telegram/errors/common_error'
module Telegram
module Errors
module Renderer
class TemplateNotFoundError < Telegram::Errors::CommonError
def initialize view_name
super "Template not found for #{view_name}"
end
end
end
end
end
|
class Answer < ActiveRecord::Base
belongs_to :question, touch: true
belongs_to :user
validates :body, presence: true, length: {minimum: 3}
has_many :likes, as: :likable
has_many :likers, through: :likes, source: :user
end |
num_words = 4
if ARGV.length > 0
if ARGV.length > 1
print "Too many arguments"
exit
end
# from https://stackoverflow.com/questions/1235863/how-to-test-if-a-string-is-basically-an-integer-in-quotes-using-ruby
if /\A[-+]?\d+\z/ === ARGV[0]
if ARGV[0].to_i < 1
print "A... |
require 'test_helper'
class BranchInfosControllerTest < ActionController::TestCase
setup do
@branch_info = branch_infos(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:branch_infos)
end
test "should get new" do
get :new
assert_respons... |
class TicTacToe
def initialize
board = [" ", " ", " ", " ", " ", " ", " ", " ", " "]
@board = board
end
WIN_COMBINATIONS = [
[0, 1, 2],
[3, 4, 5],
[6, 7, 8],
[0, 4, 8],
[2, 4, 6],
[0, 3, 6],
[1, 4, 7],
[2, 5, 8]
]
def display_board
puts " #{@board[0]} | #{@board[1]} ... |
class ChangePopMilitaryToInt < ActiveRecord::Migration
def change
change_column :countries, :pop_military, :integer
end
end
|
# -*- coding: utf-8 -*-
#
# Author:: lnznt
# Copyright:: (C) 2011 lnznt.
# License:: Ruby's
#
require 'gmrw/ssh2/message/def_message'
module GMRW::SSH2::Message
disconnect_reason = proc do |tag|
{
}[tag] || tag
end
def_message :disconnect, [
[ :byte, :type ,1 ],
[... |
class SessionsController < ApplicationController
def new
render layout: 'login'
end
def create
user = User.find_by(name: params[:name])
if user && user.authenticate(params[:password])
set_user!(user)
redirect_to root_path, notice: t('login.successful_login', trainer: user.name)
else
... |
class AnnotationProcessor
@queue = :processing
class << self
def perform(job_id)
self.process_annotation(job_id)
end
def process_annotation(job_id)
if job = AnnotationJob.find(job_id)
job.update_attributes(started_at: Time.now)
ontology = Ontology.where(ncbo_id: job.ncbo_i... |
# frozen_string_literal: true
module Kafkat
module Command
class TopicVerify < Base
register_as 'topic_verify', deprecated: 'verify-replicas'
banner 'kafkat topic verify'
description 'Check if all partitions in a topic have same number of replicas.'
option :topics,
short: '-T',
... |
class CreateGouSites < ActiveRecord::Migration
def self.up
create_table :gou_sites do |t|
t.string :name
t.string :url
t.string :logo
t.timestamps
end
end
def self.down
drop_table :gou_sites
end
end |
module Admin
module Elements
class DocumentsController < Admin::BaseController
include Apotomo::Rails::ControllerMethods
has_widgets do |root|
root << widget('admin/elements/image_cropper', 'image_cropper')
end
crudify 'elements/document',
:conditions => nil,
... |
class AuditProblem::MissingTitle < AuditProblem::EntrySpecific
def self.run(options={})
problems = []
Entry.find_each(:conditions => "title IS NULL or title = ''") do |entry|
problems << build_from_entry(entry)
end
problems
end
end
|
class Task < PipelineRequest
def self.create(task_id)
new get_task(task_id)
end
def self.get_task(task_id)
get "/tasks/#{task_id}/"
end
def inputs_synced(recurse = false)
@inputs_synced ||= Hash[inputs.map do |input, input_id|
task = self.class.create(input_id)
task.sync_sub_tasks if... |
class WhaleSerializer < ActiveModel::Serializer
has_many :messages
has_many :chatrooms, through: :messages
attributes :id, :name, :weight
end
|
class CreatePosts < ActiveRecord::Migration[5.2]
def change
create_table :posts do |t|
t.string :title, comment: '标题'
t.text :desc, comment: '说明'
t.integer :user_id
t.bigint :created_user_id
t.bigint :updated_user_id
t.datetime :disabled_at
t.timestamps
end
end
en... |
class FontAboriginalSerif < Formula
head "https://www.languagegeek.com/font/AboriginalSerif.zip"
desc "Aboriginal Serif"
homepage "https://www.languagegeek.com/font/fontdownload.html"
def install
(share/"fonts").install "AboriginalSerifREGULAR.ttf"
(share/"fonts").install "AboriginalSerifBOLD.ttf"
(... |
require 'test_helper'
class WebmarksControllerTest < ActionController::TestCase
setup do
@webmark = webmarks(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:webmarks)
end
test "should get new" do
get :new
assert_response :success
en... |
class Technology < ApplicationRecord
has_many :project_tech
has_many :projects, through: :project_tech
end
|
require "spec_helper"
describe "Instantiate resources from xml" do
it "should instantiate the resource without HTTP calls" do
xml = %q{
<project>
<name>My cool project</name>
<link rel="tasks">
<tasks type="array">
<task>
<name>Start project</name>
... |
require './QuestionsDatabase.rb'
require './SaveModel.rb'
class QuestionLike
include SaveModel
def self.all
questions_likes = QuestionsDatabase.instance.execute('SELECT * FROM questions_likes')
questions_likes.map {|question_like| User.new(question_like)}
end
attr_reader :id
attr_acce... |
class CreateScheTs < ActiveRecord::Migration[5.1]
def change
create_table :sche_ts do |t|
t.datetime :schedule_at
t.string :name_sche
t.integer :sche_id
t.timestamps
end
end
end
|
Gem::Specification.new do |s|
s.name = 'idoklad'
s.version = '0.0.2'
s.date = '2017-08-07'
s.summary = "iDoklad"
s.description = "A ruby gem for iDoklad.cz api."
s.authors = ["Jiri Prochazka"]
s.email = 'prochazka@coderocket.co'
s.homepage = 'https://github.com/CodeRoc... |
class Transfer < ApplicationRecord
belongs_to :account
validates :account, presence: true
validates :amount, presence: true, numericality: true
validates :transaction_number, presence: true, uniqueness: true
validates_associated :account
accepts_nested_attributes_for :account
before_validation :load_de... |
# view.rb
class Interface
attr_accessor :J1, :J2, :params
def start
puts "quel est le prénom du joueur 1 ?"
player1_name = gets.chomp.to_s
puts "quel est le prénom du joueur 2 ?"
player2_name = gets.chomp.to_s
return @params = {
j1: "#{player1_name}",
j2: "#{player2_name}"
}
end
def show... |
class PositionsController < ApplicationController
before_filter :authenticate_user!, only: [:create, :destroy]
def create
@position = current_user.positions.new(
title: params["position"]["title"],
company: params["position"]["comp... |
# frozen_string_literal: true
require 'bolt/inventory'
require 'bolt/executor'
require 'bolt/module'
require 'bolt/pal'
require 'bolt/plugin/puppetdb'
module Bolt
class Plugin
KNOWN_HOOKS = %i[
puppet_library
resolve_reference
secret_encrypt
secret_decrypt
secret_createkeys
v... |
require 'spec_helper.rb'
describe Rack::OAuth2::Client::Grant::Password do
let(:grant) { Rack::OAuth2::Client::Grant::Password }
context 'when login is given' do
let :attributes do
{login: 'login'}
end
context 'when password is given' do
let :attributes do
{login: 'login', passwor... |
require 'spec_helper'
describe SearchDataFile do
let(:file) { SearchDataFile.new({ :tempfile => "#{settings.root}/spec/fixtures/files/sample.csv", :filename => "sample.csv" }) }
describe "#write" do
let(:filepath) { "#{settings.root}/processed_files/#{file.access_code}.csv" }
it "writes the proper data t... |
class CreateActions < ActiveRecord::Migration
def self.up
create_table :actions do |t|
t.integer :pawn_id
t.integer :queue_number
t.integer :type
t.string :params
t.timestamps
end
end
def self.down
drop_table :actions
end
end
|
module Rdomino
class Name
class << self
def abbreviated(s)
Rdomino.obj.Createname(s).abbreviated
end
def canonical(s)
Rdomino.obj.Createname(s).canonical
end
def common(s)
s =~ /(CN=)?([^\/]*)/
$2
end
end
end
end
|
# encoding: UTF-8
# Copyright 2012 Twitter, Inc
# http://www.apache.org/licenses/LICENSE-2.0
require 'singleton'
module TwitterCldr
module Segmentation
class KoreanBreakEngine < CjBreakEngine
include Singleton
def self.word_set
@word_set ||= begin
uset = TwitterCldr::Shared::Uni... |
module Terminal
class CreateCommand < BaseCommand
def run
puts "Command executing: #{name}..."
create_class = if options[:types].size > 1
puts 'Select type'
select_object(options[:types])
else
options[:types].fi... |
class Matrix
attr_accessor :subMatrix
def initialize(matrix)
@subMatrix = matrix
end
def move_leftmost_leading_one_to_first_row (subMatrix, column, row)
i = column + subMatrix[column..(subMatrix.length-1)].index { |ele| not ele[row] == 0 }
subMatrix[column], subMatrix[i] = subMatrix[i], subMa... |
class Character < ActiveRecord::Base
belongs_to :klass
belongs_to :user
has_many :character_spells
has_many :spells, through: :character_spells, inverse_of: :characters
validates_presence_of :name
def to_s
name
end
end
|
require 'cxbrank/const'
require 'cxbrank/master/playable'
require 'cxbrank/master/event_music'
module CxbRank
module Master
class Event < Playable
has_many :event_musics
def self.last_modified(text_id=nil, section=nil)
if text_id.present? and section.present?
event = self.find_by(:... |
require_relative '../automated_init'
context "Data Structure" do
context "Strictness" do
context "Hash with extra attributes" do
context "Not Strict (Default)" do
data = Schema::Controls::DataStructure::ExtraAttributes.data
data_structure = Schema::Controls::DataStructure::Example.build(dat... |
module Refinery
module Caststone
module Photos
include ActiveSupport::Configurable
config_accessor :defined_views, :embed_start_date, :filtering, :preferred_view
self.defined_views = %i[grid list]
self.embed_start_date = Date.strptime("20/09/2020", "%d/%m/%Y")
self.filtering = tru... |
class ChangeSessionRemindAtFromDateToTime < ActiveRecord::Migration
def change
change_column :goal_sessions, :remind_user_at, :time
end
end
|
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Ch... |
class CrimesController < ApplicationController
before_filter :authenticate_user!
before_action :set_crime, only: [:show, :edit, :update, :destroy]
respond_to :html
def index
if params[:tag]
@crimes= current_user.crimes.tagged_with(params[:tag])
else
@crimes= current_user.crimes.all
... |
namespace :db do
desc "create ratings to bump up number of ratings and fabricate feedback"
task :rating => :environment do
puts 'fake ratings make things fake shit real:)'
def fake_rating(num, case_id, parent_id, nanny_id, last_name)
nanny = Nanny.find(nanny_id)
num.times do
Rating.c... |
# encoding: utf-8
#
# © Copyright 2013 Hewlett-Packard Development Company, L.P.
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
#... |
load 'Case.rb'
load 'CaseClic.rb'
load 'CaseChiffre.rb'
load 'Plateau.rb'
load 'Jeu.rb'
load 'PileAction.rb'
load 'Etat.rb'
require 'fileutils'
# Ensemble de méthodes permettant la gestion des données sauvegardé
class Sauvegarde
# Classe qui permet de sauvegarder le jeu sans les boutons
# @... |
class TasksController < ApplicationController
before_action :set_task, only: [:show, :edit, :update, :destroy]
def index
@project = Project.find(params[:project_id])
@tasks = @project.tasks
if params[:filter_completed] == "true"
@tasks = @tasks.where(completed: false)
@active_link = "Inco... |
class Api::V1::SessionsController < Api::V1::BaseController
api :POST, '/sessions'
formats [ 'json' ]
param :email, String, required: true, desc: 'The email address of the user to authenticate'
param :password, String, required: true, desc: 'The password for the user'
error 401, 'The email address, password,... |
class CreateTradeTypes < ActiveRecord::Migration
def change
create_table :trade_types do |t|
t.integer :type_id
t.integer :group
t.string :symbol_name
t.string :description
t.string :deposit_description
t.string :withdrawal_description
t.timestamps
end
end
end
|
# frozen_string_literal: true
require 'caseflow/service'
module AppealsApi
class HealthChecker
SERVICES = %w[caseflow].freeze
def initialize
@caseflow_healthy = nil
end
def services_are_healthy?
caseflow_is_healthy?
end
def healthy_service?(service)
case service
wh... |
require 'open-uri'
require 'nokogiri'
require 'pry'
class Scraper
attr_accessor :name, :location, :profile_url
def self.scrape_index_page(index_url)
all_students = []
html = Nokogiri::HTML(open(index_url))
profiles = html.css(".student-card")
profiles.each do |profile|
student = {
... |
require_relative '../test_helper'
class SkillInventoryTest < Minitest::Test
include TestHelpers
def test_can_create_a_skill
create_skills(1)
skill = skill_inventory.all.first
assert skill.id
assert_equal "name1", skill.name
assert_equal "status1", skill.status
end
def test_can_return_al... |
require 'faraday'
require 'json'
RSpec.describe "Request Host:http://nginx" do
let(:target) { "http://nginx/" }
subject do
Faraday.get "#{target}"
end
context 'path:/example' do
let(:target) { "http://nginx/example" }
it 'returns status 301 http://example.local' do
expect(subject.status).to ... |
class Klin::Swap
attr_reader :pair, :gain
def initialize(pair, gain)
@pair = Array(pair)
@gain = gain
end
def eql?(other)
other.respond_to?(:pair) && @pair.eql?(other.pair) && @gain.eql?(other.gain)
end
alias_method :==, :eql?
def node_from_a
@pair.first
end
def node_from_b
@p... |
class AddLeagueIdToTips < ActiveRecord::Migration
def change
add_column :tips, :league_id, :integer
end
end
|
class CustomerMailer < ApplicationMailer
default from: 'autowerkstatt@web.de'
layout 'mailer'
def sendmail(customer) #Der Customer wird aus dem Controller in der Action Sendmail übergeben um im CustomerMailer damit zu arbeiten
@customer = customer
mail(to: @customer.email, subject:
"Die neue Saison steht... |
class TextMessenger
def self.build
new()
end
class << self
def send_otp(member)
# Find number
our_number = build.sender_number
client_number = member.phone_books.desc(:created_at).first.try(:msisdn)
raise if client_number.blank?
# Create otp and save digest to database
... |
# frozen_string_literal: true
module GraphQL
class RakeTask
extend Rake::DSL
desc "Get the checksum of a graphql-pro version and compare it to published versions on GitHub and graphql-ruby.org"
task "graphql:pro:validate", [:gem_version] do |t, args|
version = args[:gem_version]
if version.n... |
require 'rails_helper'
RSpec.describe Product, type: :model do
describe 'Validation' do
it "is valid" do
product = Product.new(
name: 'User_One_Computer',
price: 1_234.75,
quantity: 10,
category: Category.new(name: 'Electronics... |
module InquiryMailerHelper
# @example
# paragraph do
# "lorem ipsum etc"
# end
def paragraph
content_tag :p, :style => 'margin: 0; margin-bottom:10px; padding: 0; font-size: 12px; font-weight: normal; line-height: 20px; text-align: justify; color: #4D4D4D;' do
yield
end
end
# @exam... |
class CategoriesController < ApplicationController
def create
category = Category.new(cat_params)
if category.save
flash[:notice] = "#{category.name} added to category list."
redirect_to tasks_path
else
flash[:error] = "there was a problem...sorry."
redirect_to tasks_path
end
... |
module TaskHelpers
def rake_task
@rake_task ||= prepare_test
end
private
def prepare_test
require 'rake'
Rake::Task.define_task :environment
load rake_task_load_path
Rake::Task[task_name]
end
def rake_task_load_path
"#{_tasks_base_path}/#{_relative_task_file_path}"... |
# write a method that returns true if the string passed as an argument
# is a palindrome, false otherwise
# a palindrome reads the same forwards and backwards
# case mattersa as does punctuation and spaces
# examples:
#
# palindrome?('madam') == true
# palindrome?('Madam') == false # (case matters)
# palind... |
class CreateCordes < ActiveRecord::Migration[5.2]
def change
create_table :cordes do |t|
t.text :title
t.string :corde_image_id
t.text :caption
t.integer :user_id
t.timestamps
end
end
end
|
require_relative 'station'
class Journey
attr_reader :entry_station, :exit_station
def initialize
@entry_station = nil
@exit_station = nil
end
def start_journey(station)
@entry_station = station
end
def stop_journey(station)
@exit_station = station
end
def fare
return PENALTY_CH... |
require "rails_helper"
RSpec.describe Host, type: :model do
subject(:host) { build(:host) }
describe "validations" do
subject { create(:host) }
it { should validate_presence_of(:hostname) }
it { should validate_presence_of(:redirect_id) }
it { should validate_uniqueness_of(:hostname) }
it { s... |
# Copyright 2007-2014 Greg Hurrell. All rights reserved.
# Licensed under the terms of the BSD 2-clause license.
require 'spec_helper'
describe Walrat::Grammar do
describe '::rules' do
it 'complains if either parameter is nil' do
expect do
class AxeGrammar < Walrat::Grammar
rule nil, 'ex... |
class NotesController < InheritedResources::Base
def index
@notes = Note.where(user_id: current_user)
end
def create
@note = Note.new(note_params)
@note.user = current_user
respond_to do |format|
if @note.save
format.html { redirect_to notes_path, notice: 'Note was successfully c... |
# frozen_string_literal: true
module Kafkat
module Command
class TopicDescribe < Base
register_as 'topic_describe', deprecated: 'partitions'
banner 'kafkat topic describe TOPIC'
description 'Print information about the given topic.'
option :under_replicated,
description: "Print t... |
require 'csv'
require 'cgi'
require 'uri'
def escape(*args)
CGI::escapeHTML *args
end
def el(tag, value, **opts)
attributes = ""
unless opts.empty?
attributes = " " + opts
.map { |attr, attrval| "#{attr}=#{attrval.inspect}" }
.join(" ")
end
res = "<#{tag}#{attribute... |
BrowsingSupport::Engine.routes.draw do
root to: 'words#index'
resources :words
end
|
$:.unshift File.join(File.dirname(__FILE__),"..","lib")
$:.unshift File.join(File.dirname(__FILE__))
require 'minitest/autorun'
require 'rim/file_helper'
require 'fileutils'
require 'test_helper'
class FileHelperTest < Minitest::Test
include FileUtils
include TestHelper
def setup
@test_dir = empty_test_dir... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.