text stringlengths 10 2.61M |
|---|
Prz::Application.routes.draw do
root :to => 'people#index'
resources :members do
member do
get :admin
get :curator
end
end
resources :people do
resources :curations
resources :photos
resources :transactions
end
resources :posts do
collection do
get "person/:person_i... |
class ProjectEmployeesController < ApplicationController
before_action :set_project_employee, only: [:show, :edit, :update, :destroy]
before_action :set_project, only: [:new, :create, :destroy, :edit, :update]
# GET /project_employees
# GET /project_employees.json
def index
@project_employees = ProjectE... |
json.result do
json.messages "ok"
json.rstatus "1"
json.errorcode ""
end
json.data do
if @games.present?
json.array! @games.each do |game|
json.id game.id
json.name game.name
json.description game.description
json.interval_sec game.interval_sec
json.number_of_player game.num_of_p... |
# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
require "#{lib}/byte_buffer/version"
Gem::Specification.new do |spec|
spec.name = "byte_buffer"
spec.version = ByteBuffer::VERSION
spec.authors = ["Serge Balyuk"]
spec.email = ["sergeb@apptopia.com", "bgipsy@gmail.com"]
s... |
require 'test_helper'
class RiderTest < ActiveSupport::TestCase
def test_that_riders_swing
# Use your knowledge of factories to make the test pass!
# this time use create( ... ) instead of build
aegon = Rider.create(name: "Aegon", sword: "Blackfyre")
daenerys = Rider.create(name: "Daenerys", sword: ... |
require 'json'
require_relative './decryption_tools.rb'
class BotHelper
include DecryptionTools
HOME = '~/telegram-bot'
def extract_command(message, bot_name)
return '' unless message && message.split(' ').count > 0
command = message.split(' ')[0]
command.sub("@#{bot_name}", '')
end
def extra... |
require 'rails_helper'
RSpec.describe Service, type: :model do
it { is_expected.to have_many(:line_items) }
it { is_expected.to have_many(:pricing_maps) }
context 'class methods' do
describe '.default_scope' do
it 'should order services by name' do
orange_service = create(:service, name: "O... |
#
# Author:: Greg Fitzgerald <greg@gregf.org>
# Cookbook Name:: alternatives
# Provider:: alternatives
#
# Copyright 2013, Greg Fitzgerald
#
# 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
#
# ... |
require 'thor'
require_relative './encryptor'
class CLI < Thor
class_option :rotation, type: :numeric, aliases: '-r'
class_option :decrypt, type: :boolean, aliases: '-d'
desc 'text', 'Encrypt/decrypt supplied text'
def text(supplied_text)
puts convert(Array(supplied_text))
end
desc 'file', 'Encrypt/d... |
require 'spec_helper'
RSpec.describe do
let(:missing_fields) { [:api_key, :sort, :format_array] }
let(:missing_defaults) { [:sort, :format_array ] }
let(:expected_message) { "Missing required fields: #{missing_fields}" }
let!(:instance) { GetAddress::MissingFieldsError.new(missing_fields) }
def mis... |
require 'json'
require 'dry/transaction/operation'
module Hacefrio
module Requirements
module Operations
module Transforms
class DecodeJSON
include Dry::Transaction::Operation
def call(input)
blob = input.delete(:json)
begin
Success(input... |
class CreateSupportingCourses < ActiveRecord::Migration
def change
create_table :supporting_courses do |t|
t.string :title
t.references :category, index: true
t.references :user, index: true
t.string :tags, array: true
t.references :presentation, index: true
t.timestamps null:... |
require 'spec_helper'
describe Susanoo::PageContentsController do
shared_context "rubi_filter" do
context "content_type = 'text/html', cookie[:ruby] = 'on' の場合" do
before do
cookies[:ruby] = 'on'
end
it "ルビがふられたテキストが出力されること" do
subject
expect(response.body).to eq Browsi... |
require "spec_helper"
describe "FC009" do
context "on chef 14.2.0 with a cookbook that uses ifconfig attributes introduced in 14.0" do
foodcritic_command("--chef-version", "14.2.0", "--no-progress", ".")
recipe_file <<-EOH
ifconfig 'foo' do
family 'inet'
end
EOH
it { is_expected.n... |
class Info < ApplicationRecord
belongs_to :nanny
PROFESSIONAL = [:取得保母人員技術士證, "高級中等以上學校幼兒保育、家政、護理相關學程、科、系、所畢業","修畢托育人員(保母)專業訓練課程且領有結業證書"]
end
|
class Point < ApplicationRecord
FREE_COFFEE_IN_100_POINTS_EVERY_MONTH_REWARD = "Free Coffee reward in 100 points"
CASH_REBATE_REWARD = "5% Cash Rebate"
FREE_COFFEE_FOR_BIRTHDAY_MONTH_REWARD = "Free Coffee reward in birthday month"
FREE_MOVIE_TICKET_REWARD = "Free Movie Tickets"
AIRPORT_LOUNGE_REWAR... |
class Owner::AvailabilitiesController < ApplicationController
before_action :authenticate_user!
before_action :set_availability, only: [:show, :update, :destroy]
#GET availability
def index
@availabilities=Availability.where(court_id: params[:court_id])
json_response(@a... |
class User < ApplicationRecord
devise :database_authenticatable,
:registerable,
:jwt_authenticatable,
jwt_revocation_strategy: JwtDenylist
validates :email, presence: true, uniqueness: true, format: { with: /\A[^@\s]+@([^@\s]+\.)+[^@\s]+\z/, message: "is not a valid email" }
validat... |
class User < ActiveRecord::Base
has_many :friends
def self.from_omniauth(auth)
where(uid: auth.uid).first_or_initialize.tap do |user|
user.uid = auth.uid
user.name = auth.info.name
user.oauth_token = auth.credentials.token
user.oauth_expires_at = Time.at(auth.credentials.expires_at)
user.add_friends
... |
##
# Base Class for all main controllers in the post editor.
# Controllers should extend this class if we want the user to be authenticated
# before accessing an action in a controller
class BasePostEditorController < ApplicationController
before_action :check_user
private
##
# This method gets called befo... |
@a7 = Episode.create(
"title" => "Ep 7: Behind The Curtain",
"number" => 7,
"published_at" => "2013-08-05 12:00:00",
"media" => "http://resources.brickcaster.com/abstraction/007_behind_the_curtain.mp3",
"media_length" => 6385.920083333333,
"media_size" => 153355010,
"summary" => "Micah and Ryan bring back scholar-at-la... |
class FontBellefair < Formula
head "https://github.com/google/fonts/raw/main/ofl/bellefair/Bellefair-Regular.ttf", verified: "github.com/google/fonts/"
desc "Bellefair"
homepage "https://fonts.google.com/specimen/Bellefair"
def install
(share/"fonts").install "Bellefair-Regular.ttf"
end
test do
end
en... |
class Syncer
include Sidekiq::Worker
include Sidekiq::Status::Worker
sidekiq_options retry: 10
def perform(playlist_id)
playlist = PlaylistRepository.find(playlist_id)
client = playlist.auth.client
spotify = playlist.user.auth_for(:spotify).client
tracks = client.tracks(playlist)
spotify_... |
require 'rails_spec_helper'
require 'rails_template/home_controller'
RSpec.describe RailsTemplate::HomeController do
render_views
it 'renders ok"' do
get :index
expect(response.body).to include("OK")
end
end
|
class FolloweesController < ApplicationController
# GET /followees
# GET /followees.json
def index
@followees = Followee.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @followees }
end
end
# GET /followees/1
# GET /followees/1.json
def show
... |
class Api::V1::UsersController < ApplicationController
def index
users = User.all
render json: users
end
def show
user = User.find(params[:id])
render json: user
end
def create
user=User.create(
user_name: params[:user_name],
passwor... |
class Volume < ActiveRecord::Base
acts_as_authorizable
acts_as_audited
named_scope :def_scope
acts_as_reportable
acts_as_commentable
belongs_to :volume_server, :foreign_key => 'volume_server_id', :class_name => 'Node'
has_many :volume_drive_assignments, :dependent => :destroy
has_many :drives, ... |
# frozen_string_literal: true
class Request
SOURCE = ""
DEFAULT_TIMEOUT = 1
attr_reader :client, :headers
def initialize(params)
raise "Headers must be a Hash" unless params[:headers].is_a?(Hash)
@client = params[:client]
@headers = params[:headers] || {}
set_default_headers
end
def get... |
class Api::V1::PostsController < ApplicationController
before_filter :authenticate_user!
authorize_resource
# GET /api/v1/posts.json
def index
@posts = Post.all
end
# GET /api/v1/posts/:id.json
def show
unless @post = Post.find_by_uuid(params[:id])
render json: nil, status: 404
end
e... |
class ComplexTimesheet < ActiveRecord::Base
# Use for testing custom has_many :through
has_many :complex_billable_weeks, :foreign_key => :id_complex_timesheet
has_many :workers, :through => :complex_billable_weeks, :source => :slave
end |
require 'spec_helper'
describe Puppet::Type.type(:nexus_repository_target) do
describe 'by default' do
let(:repository) { Puppet::Type.type(:nexus_repository_target).new(:name => 'default-target') }
it { expect(repository[:provider_type]).to eq(:maven2) }
it { expect(repository[:patterns]).to eq([]) }
... |
class CreateUsers < ActiveRecord::Migration
def change
create_table :users do |t|
t.string :uid
t.string :ip
t.boolean :online
t.datetime :last_load
t.string :last_page
t.text :site_style
t.integer :show_sidebar
t.boolean :show_postform
t.boolean :save_scroll
... |
class LegislatorsController < ApplicationController
data_table = GoogleVisualr::DataTable.new
def your_legislators
# quick and dirty validation for zipcode validation (need to replace with real validation)
if params[:search] && params[:search] != '' && params[:search].match(/^\d{5}(?:[-\s]\d{4})?$/)
# ... |
namespace :db do
desc "Fill database with sample data"
task populate: :environment do
make_users
end
end
def make_users
admin = User.create!(name: "admin",
email: "a@q.com",
password: "asdfasdf",
password_confirmation: "asdfasdf",
admin: true... |
# Multiply All Pairs
=begin
(Understand the Problem)
Problem:
Write a method that takes two Array arguments in which each Array contains a list of numbers,
and returns a new Array that contains the product of every pair of numbers that can be formed
between the elements of the two Arrays. The results sho... |
#!/usr/bin/env ruby
# ^ Syntax hint
desc 'Setup script related functionality'
namespace :setup_script do
desc 'Run setup scripts'
task :run do
Hem.ui.title 'Running setup scripts'
run_command 'bin/magento setup:upgrade', realtime: true, indent: 2
Hem.ui.success('Setup scripts finished')
end
end
|
class TransactionsController < ApplicationController
before_action :set_transaction, only: %i[show edit update destroy]
# GET /transactions
# GET /transactions.json
def index
@transactions =
Transaction.where(user: current_user).or(Transaction.where(transaction_with: current_user))
end
# GET /tr... |
require 'rails/generators'
module Enjoy::News::Models
class AllGenerator < Rails::Generators::Base
source_root File.expand_path('../templates', __FILE__)
argument :class_name, type: :string
argument :category_class_name_arg, type: :string, default: ""
argument :image_class_name_arg, type: :string, de... |
# @author Kris Luminar
class CsvFilter
# @param file_path the full path to a file
def initialize file_path, separator = "\t"
STDOUT.flush
@file = File.open(file_path, 'r')
@separator = separator
@num_columns = count_columns
@header = {}
grab_header
end
# grab the first row of the inpute... |
class ChangeReturnedType < ActiveRecord::Migration[5.1]
def change
change_column :injuries, :returned?, :string
end
end
|
module Kaseya::BMS
class Client
Dir[File.expand_path('../client/*.rb', __FILE__)].each { |f| require f }
attr_reader :connection
def initialize(connection)
@connection = connection
end
def accounts
@accounts ||= Client::Accounts.new(@connection)
end
def activities
@ac... |
require 'alimento'
Node = Struct.new(:value, :next, :prev)
class Lista
include Enumerable
# Recorre los elementos de una lista y ejecuta acciones sobre el valor del elemento evaluado en ese momento
#
def each
aux = @head
while (aux != nil) do
yield aux["value"]
aux = aux["next"]
end
end
$eficienci... |
class ScenariosController < ApplicationController
before_action :set_scenario, only: [:show, :update, :destroy]
# GET /scenarios
def index
@scenarios = Scenario.all
render json: @scenarios, include: [:questions]
end
# GET /scenarios/1
def show
@scenario = Scenario.find(params[:id])
render... |
class AddLevelToAvLink < ActiveRecord::Migration
def change
add_column :av_links, :level, :integer
end
end
|
class CreateVariables < ActiveRecord::Migration
def change
create_table :variables do |t|
t.string :key
t.string :value
t.boolean :active, default: true
t.timestamps null: false
end
end
def unchange
drop_table :variables
end
end
|
require 'rails_helper'
RSpec.describe Service, type: :model do
subject { FactoryGirl.create :service }
it { expect(subject).to be_valid }
end
|
class User < ActiveRecord::Base
has_many :microposts, dependent: :destroy
attr_accessible :email, :name, :password, :password_confirmation, :remember_token
validates :name, presence: true, length: { maximum: 50 }
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
validates :email, presence: true, forma... |
module Refinery
module Products
class Product < Refinery::Core::BaseModel
self.table_name = 'refinery_products'
attr_accessible :name, :description, :position
validates :name, :presence => true, :uniqueness => true
end
end
end
|
module ScriptNotifier
module Services
module Base
attr_reader :site_name, :script_name, :script_steps, :script_id, :success,
:failure_message, :failure_step_id, :failure_attempts,
:notification, :payload
def initialize(script_data, notification)
@script_da... |
require 'rails_helper'
RSpec.describe "entries/show", :type => :request do
it "show entry by id" do
entry = Entry.create(title: "First entry", body: "Bla bla bla", author: "LM")
get entry_path(entry)
assert_select "h1", :text => entry.title
assert_select "p", :text => entry.body
assert_select "p"... |
# -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require "backbone_ext/version"
Gem::Specification.new do |s|
s.name = "backbone_ext"
s.version = BackboneExt::VERSION
s.authors = ["jcredding"]
s.email = ["TempestTTU@gmail.com"]
s.homepage = ""
s.summary = %... |
# This code is free software; you can redistribute it and/or modify it under
# the terms of the new BSD License.
#
# Copyright (c) 2011-2013, Sebastian Staudt
unless IO.method_defined? :readbyte
def IO.readbyte
read(1)[0].ord
end
end
|
require 'test_helper'
class MessageTest < ActiveSupport::TestCase
def setup
@message = Message.new(name: "Example", number: "4105551234", content: "sample content", from: "4105554321")
end
test "should be valid" do
assert @message.valid?
end
test "name should have a maximum length" do
@message.... |
Given /^I do not have any historical data for the symbol "([^\"]*)"$/ do |scrip_symbol|
@history = nil
end
When /^I get historical data for "([^\"]*)"$/ do |arg1|
@history = YahooStock::History.new(:stock_symbol => 'msft',
:start_date => Date.today-10,
... |
class Staff < ActiveRecord::Base
has_many :book, dependent: :nullify
has_many :comment, dependent: :nullify
has_many :order
before_save { self.email = email.downcase }
validates :user, :name, presence: true, length: { maximum: 50 }
validates :user, uniqueness: { case_sensitive: false }
... |
class UsersController < ApplicationController
before_filter :require_login, :except => [:login, :logout, :oauth_callback]
def login
request_token = get_consumer.get_request_token
session[:oauth_token] = request_token.token
session[:oauth_secret] = request_token.secret
redirect_to request_token.auth... |
class AddDefaults < ActiveRecord::Migration
def change
change_column_default(:items, :missed, false)
change_column_default(:items, :done, false)
end
end
|
module CDI
module V1
module PageStructure
class LearningTrackPagePresenter < BasePresenter
attr_reader :learning_track, :questions_templates, :categories, :skills
def initialize
@learning_track = ::LearningTrack.new
@questions_templates = ::QuestionTemplate.questio... |
module Authentication
extend ActiveSupport::Concern
included do
helper_method(:current_user)
end
def current_user
cache = session[:user]
@current_user ||= if cache
User.new(cache)
else
NullUser.new
end
end
private
def logged_in?
current_user.logged_in?
end
def... |
require 'nil/serialise'
require 'nil/console'
require_relative 'PlayerResult'
class RatingStatistics
attr_reader :range, :wins, :losses, :count
def initialize(range)
@range = range
@wins = 0
@losses = 0
@count = 0
end
def process(player)
@wins += player.wins
@losses += player.losses
... |
require 'test/test_helper'
require 'given'
class SetupTest < GivenTestCase
def test_given_setup_is_run
assert_all_pass do
Given(:a_number) do
Then { @number == 10 }
end
def a_number
@number = 10
end
end
end
def test_multiple_setups_are_run
assert_all_pass do
... |
class ChestItemsController < ApplicationController
def create
@chest = current_chest
@chest_item = @chest.chest_items.new(chest_item_params)
@chest.save
session[:chest_id] = @chest.id
end
def update
@chest = current_chest
@chest_item = @chest.chest_items.find(params[:id])
@chest_item... |
class CartItemsController < ApplicationController
def create
cart = Cart.where(user_id: current_user.id).last
cart_item = cart.cart_items.find_by(product_id: params[:cart_id])
if cart_item.nil?
cart_item = CartItem.new
cart_item.cart_id = cart.id
cart_item.product_id = params[:cart_id]
... |
class River
def initialize(fish)
@population = fish
end
def fish_taken_from_river(bear)
if @population.count < 1
return bear.roar
else
bear.tummy << @population.pop.fish_name
return bear.tummy
end
end
end
#Tks Seumus, clarified method |
#!/usr/bin/env ruby
require 'socket'
require 'json'
require 'fcntl'
class MultiBinderServer
def initialize(control_file)
@control_file = control_file
@sockets = {}
end
def handle_client(s)
loop do
msg, _, _, _ = s.recvmsg
break if msg.empty?
request = JSON.parse(msg)
puts "R... |
class CreateClassNotificationEmails < ActiveRecord::Migration
def self.up
create_table :class_notification_emails do |t|
t.integer :class_id
t.string :recipients
t.string :subject
t.text :body
t.timestamps
end
add_index :class_notification_emails, :class_id
end
def... |
require 'walkon/device'
require 'walkon/hci_tool'
# The process which listens for new Devices to come on the network, then
# immediately plays their entrance music and adds them to the collection
# so they won't be triggered again.
#
# A cron job restarts the daemon every night at 3:00am so the devices
# collection is... |
module Portalgun
class Portal
class Machine
attr_accessor :name
attr_accessor :machine_type
attr_accessor :cluster
attr_accessor :operating_system
attr_accessor :qmp
attr_accessor :cpu
attr_accessor :memory
attr_accessor :maximum_memory
attr_accessor :devices... |
module Web
module V1
class Menu < Grape::API
#路径添加版本号
version 'v1', using: :path
resources :menus do
get "list" do
menus = ::Menu.select(:id, :name, :url, :usable).map { |menu| {
id: menu.id,
name: menu.name,
url: menu.url,
usable: menu.usable
} }
{success: true... |
class Favourites
include PageObject
# Div
div(:showNotification, :css => '.show-notification')
# Link
link(:favouritesTab, :xpath => '//li[3]/a/span/span')
link(:fragrancePDP, :xpath => '//article[@id="content"]/div/div/div/ul[2]/li/ul/li/a/div[2]')
link(:previewFavourites, :css => '.js-favourites-su... |
# -*- encoding : utf-8 -*-
class AddAttributeTextToRecommendations < ActiveRecord::Migration
def change
add_column :recommendations, :text, :string
end
end
|
# frozen_string_literal: true
require 'field_serializer'
class String
def tidy
gsub(/[[:space:]]+/, ' ').strip
end
end
class Member
include FieldSerializer
def initialize(member)
@member = member
end
field :id do
member[:id]
end
field :name do
names.first.tidy
end
field :alter... |
class WordCloud
def initialize text
@text = text
end
def sort
@word_sort = { large: [], medium: [], small: [] }
word_freq.each { |word,count| set_freq word, count }
@word_sort
end
private
def set_freq word, count
@word_sort[:large] << word if count >= 3
@word_sort[:medium] << wor... |
class AddVisibilityOnPosts < ActiveRecord::Migration
def change
add_column :posts, :visibility_type, :string, index: true, null: false
add_column :posts, :visibility_id, :integer, index: true, null: true
end
end
|
class OrderProductsController < ApplicationController
before_filter :require_user
def update
@order_product = OrderProduct.find(params[:id])
if params[:reassign]
@order_product.product_location = nil
end
respond_to do |format|
if @order_product.update_attributes(params[:order_produ... |
class ShuvosController < ApplicationController
before_action :set_shuvo, only: [:show, :edit, :update, :destroy]
# GET /shuvos
# GET /shuvos.json
def index
@shuvos = Shuvo.all
end
# GET /shuvos/1
# GET /shuvos/1.json
def show
end
# GET /shuvos/new
def new
@shuvo = Shuvo.new
end
# G... |
module Spec
module Example
# Lightweight representation of an example group. This is the object
# that is passed to Spec::Runner::Formatter::BaseFormatter#add_example_group
class ExampleGroupProxy
def initialize(example_group) # :nodoc:
@description = example_group.description... |
Puppet::Type.type(:exec).provide :shell, :parent => :posix do
include Puppet::Util::Execution
confine :feature => :posix
desc "Execute external binaries directly, on POSIX systems.
passing through a shell so that shell built ins are available."
def run(command, check = false)
command = %Q{/bin/sh -c "#{c... |
module Spree::BaseHelper
def layout_partial
if devise_controller?
'spree/base/devise'
else
'spree/base/application'
end
end
def link_to_cart(text = nil)
text = text ? h(text) : t('spree.cart')
css_class = nil
if current_order.nil? || current_order.item_count.zer... |
Rails.application.routes.draw do
get 'admin/index'
get 'password_reset/new'
get 'password_reset/edit'
get 'shared/about'
get 'shared/terms_of_service'
get 'shared/privacy_policy'
get 'shared/site_map'
get 'shared/contact_us'
get 'shared/faq'
get 'teen_job_detail/show'
get 'employer_job_... |
require 'csv'
require 'pry'
class EventReporter
attr_accessor :queue, :file
#-------------------------------
# Test Section
def new_csv
queue = @queue
print "ID\tFirst Name\tLast Name\n"
queue.each do |entry|
print "#{entry[:id]}\t#{entry[:first_name]}\t#{entry[:last_name]}"
end
# :write_headers=> true,
... |
class AddDescriptionSizeDigestToArchives < ActiveRecord::Migration
def change
add_column :archives, :digest, :string, :null => false, :default => '', :after => :name
add_column :archives, :size, 'int unsigned', :null => false, :default => 0, :after => :name
add_column :archives, :description, :string, :nu... |
# Allow the metal piece to run in isolation
require(File.dirname(__FILE__) + "/../../config/environment") unless defined?(Rails)
class PaperclipAttachment
def self.call(env)
begin
paperclip_attachment = is_paperclip_attachment_request(env["PATH_INFO"])
if paperclip_attachment
paperclip_attachm... |
class Product < ActiveRecord::Base
attr_accessible :description, :name, :price, :stock_quantity, :image_filename, :catagory_id
validates :description, :name, :price, :stock_quantity, presence: true
has_many :lineitems
has_many :orders, through: :lineitems
belongs_to :catagory
end
|
class User < ApplicationRecord
attr_accessor :login
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
validates :username, presence: true, uniqueness: {case_sensitive: false}, format: {with: /\A[a-zA-Z0-9 _\.]*\z/}
# Team association
belongs... |
Rails.application.routes.draw do
root 'welcome#index'
# Users
get '/join', to: 'users#new', as: :new_user
post '/join', to: 'users#create'
get '/profile/edit', to: 'users#edit', as: :edit_user
get '/profile', to: 'users#show', as: :user
patch '/profile', to: 'users#update'
put '/profile... |
class AddRunNow < ActiveRecord::Migration
def self.up
add_column :rg_tasks, :run_now, :string
end
def self.down
remove_column :rg_tasks, :run_now
end
end
|
# prereqs: iterators, hashes, conditional logic
# Given a hash with numeric values, return the key for the smallest value
def key_for_min_value(hash)
value_only_array = []
hash.each_pair do |key, value|
value_only_array << value
end
value_only_array.sort!
hash.key(value_only_array[0])
end |
COMMANDS =
{ open: {
command: lambda { |target, value| "visit '#{target}'" },
sentence: lambda { |target, value| "When I visit '#{target.gsub('/','\\\\/')}'" }
},
click: {
command: lambda { |target, value| "click_on('#{target}')" },
sentence: lambda { |target, value| "When I click on... |
# must be first file included
require_relative 'spec_helper.rb'
require_relative '../library/global.rb'
require_relative '../library/cmd/help.rb'
describe "simple crew commands" do
before(:all) do
environment_init
ndk_init
end
before(:each) do
environment_init
repository_init
repository_clo... |
class CreateStocks < ActiveRecord::Migration[6.0]
def change
create_table :stocks do |t|
t.string :name, comment: '品名'
t.string :color_number, comment: '色番号'
t.integer :quantity, comme... |
class Post < ActiveRecord::Base
validates :title, presence: true, allow_blank: false
validates :content, length: {minimum: 100}
validates :category, inclusion: {in: %w(Fiction Non-Fiction)}
end
|
module Trie
class Collector
attr :tree
def initialize(tree)
@tree = tree
end
def traverse_fragment(prefix='')
# Terminating condition for recursion.
return {"#{prefix} " => tree.count} if tree.value == "\n"
# Otherwise, continue traversing the tree and append characters as
... |
class CreateStudentAttachments < ActiveRecord::Migration
def self.up
create_table :student_attachments do |t|
t.integer :batch_id
t.integer :student_id
t.integer :uploader_id
t.string :attachment_name
t.timestamps
end
end
def self.down
drop_table :student_attachments
... |
# -*- mode: ruby -*-
# vi: set ft=ruby :
require "yaml"
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
vagrantfile_path = File.expand_path(File.dirname(__FILE__))
env_definition_path = File.join(... |
json.array!(@quizzes) do |quiz|
json.extract! quiz, :id, :possible_date, :idea, :possible_places, :max_assistance, :min_assistance, :max_cost, :min_cost
json.url quiz_url(quiz, format: :json)
end
|
class User < ApplicationRecord
has_secure_password
has_many :favorites
has_many :reviews
validates_presence_of :username, :email
validates_uniqueness_of :username, :email
end
|
require File.dirname(__FILE__) + '/../spec_helper'
describe SerieCronologicasController do
describe "handling GET /serie_cronologicas" do
before(:each) do
@serie_cronologica = mock_model(SerieCronologica)
SerieCronologica.stub!(:find).and_return([@serie_cronologica])
end
def do_get
... |
# == Schema Information
#
# Table name: challenges
#
# id :integer not null, primary key
# name :string
# description :text
# start_at :datetime
# end_at :datetime
# meta :text
# created_at :datetime not null
# updated_at ... |
class SessionsController < ApplicationController
def new
end
def create
user = User.find_by_email(params[:email])
# Nested 'if' statements used for invalid login handling
if verify_recaptcha(model: @session, message: "Invalid CAPTCHA" )
if user && user.authenticate(params[:password])
session[:user_id... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.