text stringlengths 10 2.61M |
|---|
## -*- Ruby -*-
## XML::ParserNS
## namespaces-aware version of XML::Parser (experimental)
## 2002 by yoshidam
require 'xml/parser'
module XML
class InternalParserNS < Parser
XMLNS = 'http://www.w3.org/XML/1998/namespace'
attr_reader :ns
def self.new(parserNS, *args)
nssep = nil
if args.len... |
maintainer "Christian Berkhoff"
maintainer_email "christian.berkhoff@gmail.com"
license "Apache 2.0"
description "Installs Leiningen"
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version "0.1"
|
FactoryGirl.define do
factory :search_result, class: 'SitescanCommon::SearchResult' do
title "MyString"
link "MyString"
# display_link "MyString"
# snippet "MyString"
end
end
|
# frozen_string_literal: true
class TeamsApplicationsController < ApplicationController
before_action :authenticate_user!
load_and_authorize_resource
def index
@event = Event.find(params[:event_id])
@users = User.all
@teams = @event.teams
if @current_user.is? :admin
@teams_applications = @... |
require 'csv'
class ImportDhcpLeasesJob < ApplicationJob
def perform()
leases = {}
leases_file.each do |row|
next unless target_ids.include?(row['subnet_id'].to_i)
leases[row.fetch('hwaddr')] = row.fetch('address')
end
changed_machines = []
ApplicationRecord.transaction do
Machi... |
require 'httparty'
class TestParty
include HTTParty
base_uri 'http://localhost:5000'
end
RSpec.describe 'API TEST - POST' do
it 'Should create a new employee' do
data = {
'name' => 'TestRamiloNeves',
'nif' => 291765022,
'address' => 'Vila Nova de Gaia'
}
begin
response = Tes... |
json.forums @forums do |forum|
json.id forum.id
json.name forum.name
json.thumbnail "https://upload.wikimedia.org/wikipedia/commons/e/e5/Post-it-note-transparent.png"
#json.artist_id album.artist ? album.artist.id : nil
end |
class ChangeTypeNull < ActiveRecord::Migration[6.1]
def change
change_column :categories, :subcategory_id, :bigint, null: true
end
end
|
EmberDataExample::Application.routes.draw do
resources :contacts
root :to => 'contacts#index'
match "/*path" => "contacts#index"
end
|
class OrderItem < ApplicationRecord
belongs_to :order
belongs_to :product
validates_presence_of :order_id
validates_presence_of :product_id
validates_numericality_of :quantity, integer: true, greater_than: 0
def subtotal
product.price * quantity
end
end
|
class Workout < ActiveRecord::Base
def self.search(search)
where(
'exercise_name LIKE :search
OR category LIKE :search
OR workouts.force LIKE :search
OR workouts.level LIKE :search
OR main_muscle_worked LIKE :search
OR other_muscles LIKE :search
OR mechanics... |
require 'rails_helper'
describe 'viewing the rankings index' do
before do
visit new_user_session_path
@user = User.create(
email: 'user@example.com',
password: 'password',
other_residents: 2
)
@total_residents = @user.other_residents + 1
fill_in 'Email', with: 'user@example.com'... |
require File.dirname(__FILE__) + '/../../test_helper'
class Reputable::BadgeTest < ActiveSupport::TestCase
context "a Reputable::Badge" do
test "should be created if listed in App.reputable_badges" do
badge_name = "awesome badge"
Reputable::Badge::BADGES << badge_name
badge = Reputable... |
class DNA
attr_reader :dna_sequence
def initialize(dna)
@dna_sequence = dna
end
def hamming_distance(other_genetic_makeup)
index = 0
hamming_distance = 0
dna_length = dna_sequence.length
other_genetic_makeup[0, dna_length].chars.each do |nucleobase|
hamming_distance += 1 unless dna_... |
require 'features_helper'
feature 'Show calculation results for steam vent replacement', :js, :real_measure do
include Features::CommonSupport
let!(:user) { create(:user) }
let!(:steam_vent) do
StructureType.create!(
name: 'Steam vent',
api_name: 'distribution_system',
genus_api_name: 'dis... |
Rails.application.routes.draw do
root to: "songs#index"
resources :songs, only: [:index] do
get "search", on: :collection
end
end
|
# # 这个脚本基本没有了
# 只是当时用一回吧
# 先保留着
# ----
require 'csv'
# 1. 转二期双语的信息表文件到csv
# 2. 并生成二期文件的id,中文书名,英文书名csv
BOOK_INFO = 'db/xin-book-info-category.tsv'
BOOK_INFO_CSV = 'db/xin-book-info.csv'
XIN_BOOK_TITLES = 'db/xin-book-titles.csv'
s = File.readlines BOOK_INFO
arr = s.map { |l| l.chomp.split(/\t/) }
csv = arr.map { |l|... |
require 'spec_helper'
feature 'Starting a new game' do
context 'when on new game screen' do
scenario 'user is asked to enter name' do
visit '/new_game'
expect(page).to have_field("name")
end
end
context 'when user enters name' do
scenario 'user is taken to the game page' do
vi... |
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :null_session, if: Proc.new { |c| c.request.format == 'application/json' }
before_action :configure_permitted_parameters, if: :d... |
# only admin access of categories
# add, edit and delete.
class Category < ActiveRecord::Base
validates :name, presence: true
has_many :events
end |
require "formula"
require "language/haskell"
class Mighttpd2 < Formula
include Language::Haskell::Cabal
homepage "http://mew.org/~kazu/proj/mighttpd/en/"
url "http://hackage.haskell.org/package/mighttpd2-3.2.0/mighttpd2-3.2.0.tar.gz"
sha1 "878a9e03ad3a62221dab22cb6412ae446368e1bd"
bottle do
sha1 "3bcfd... |
class UsersController < ApplicationController
check_authorization
load_and_authorize_resource
before_action :authenticate_user!
before_action :load_organizations, only: [:new, :create, :edit, :update]
def index
if current_user.admin?
if params[:q]
@persons = User
.where.not(role... |
module Ultimaker
class Printer
class System
attr_reader :country
end
end
end
|
module Shipit
module StacksHelper
COMMIT_TITLE_LENGTH = 79
def redeploy_button(commit)
url = new_stack_deploy_path(@stack, sha: commit.sha)
classes = %W(btn btn--primary deploy-action #{commit.state})
unless commit.stack.deployable?
classes.push(ignore_lock? ? 'btn--warning' : 'btn... |
feature 'Attack_Player' do
scenario "Attacks player_2 and gets confirmation" do
sign_in_and_play
click_button "Attack"
expect(page).to have_content("Florence attacked Emma")
end
scenario "The attack reduces player_2's health points by 10" do
sign_in_and_play
click_button "Attack"
expect(p... |
class Task < ApplicationRecord
belongs_to :project
scope :sort_by_priority, -> { order(priority: :asc) }
end
|
namespace :rails do
desc "Tail Rails remote log"
task :log do
on roles(:app) do
execute "tail -f #{shared_path}/log/#{fetch(:rails_env)}.log"
end
end
end
|
class Api::Admin::AdminUsersController < Api::Admin::ApiController
rescue_from StandardError, with: :show_errors
def index
@admin_users = AdminUser.all.order_by_recent
render json: @admin_users.map { |admin_user| filter_returned_parameters(admin_user) }
end
private
def fetch_admin_user
@admin_... |
include_recipe '::install_requirements'
if node['certie']['email'].nil?
raise 'Email attribute can not be nil'
end
if node['certie']['organization'].nil?
raise 'Organization attribute can not be nil'
end
if node['certie']['domains'].empty?
raise 'Domain names are not configured'
end
directory node['certie']['... |
### WHEN ###
When /^I go to (.+)$/ do |page|
visit path_to(page)
end
### THEN ###
Then /^I should be on (.+)$/ do |_expected_page|
current_path.should == path_to(_expected_page)
end
Then /^I should be redirected to (.+)$/ do |_expected_page|
current_path.should == path_to(_expected_page)
end
|
# == Schema Information
#
# Table name: faq_audiences
#
# id :integer not null, primary key
# faq_id :integer not null
# audience_id :integer not null
# created_at :datetime not null
# updated_at :datetime not null
#
class FaqAudience < ActiveRecord::Base
# ... |
module ApplicationHelper
def request_url
"#{request.protocol}#{request.host_with_port}#{request.fullpath}"
end
def add_breadcrumb_for_category(category)
add_breadcrumb_for_category category.parent_category if !category.parent_category.nil?
add_breadcrumb category.name, category_path(category)
end
e... |
class CreateSpSkillSets < ActiveRecord::Migration
def change
create_table :sp_skill_sets do |t|
t.integer :service_provider_id
t.integer :skill_id
t.boolean :primary
t.timestamps null: false
end
end
end
|
module Util
class FieldComposer
def self.compose(types)
ret = types.reduce({}) do |acc, type|
acc.merge(type.fields)
end
ret
end
end
end |
Given(/^I am logged in$/) do
@user = FactoryGirl.create(:user)
visit new_user_session_path
fill_in :user_email, with: @user.email
fill_in :user_password, with: @user.password
click_on 'Log in'
expect(current_path).to eq(gift_ideas_path)
end
When(/^I visit the "(.*?)" page$/) do |page|
path = nil
if page == 'c... |
require 'test_helper'
class HomeControllerTest < ActionDispatch::IntegrationTest
test "should get index" do
get root_url
assert_response :success
end
test "should get callback" do
Rails.application.env_config["omniauth.auth"] = OmniAuth.config.mock_auth[:twitter]
mock_spotify_user = Minitest::Mo... |
class PersonAttrType < ActiveRecord::Base
attr_accessible :name, :sort
belongs_to :person
has_many :property_contacts
def self.find_owner
PersonAttrType.find(:first, :conditions => ["name = lower(?)", "Owner"])
end
end
|
Rails.application.routes.draw do
resources :enroll_studies, only: [:create, :destroy]
resources :programs
resources :users, only: [:show] do
# nested resource for people
resources :people, only: [:show, :index, :create, :destroy, :update] do
resources :enroll_studies
end
end
post "/signup"... |
Rails.application.routes.draw do
get 'tasks/index'
get 'tasks/update'
get 'tasks/destroy'
get 'tasks/create'
get 'categories/index'
get 'categories/update'
get 'categories/destroy'
get 'categories/create'
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routi... |
module Zenform
module Param
class Trigger < Base
FIELDS = %w{title position conditions actions}
FIELDS.each { |field| attr_reader field }
attr_reader :ticket_fields, :ticket_forms
def initialize(content, ticket_fields: {}, ticket_forms: {}, **_params)
super
@ticket_fields ... |
class Vehicle < ApplicationRecord
has_many :orders, dependent: :destroy
validates :name, presence: true
validates :detail, presence: true
validates :price, presence: true
validates :location, presence: true
end
|
require 'spec_helper'
describe GapIntelligence::InStoreImage do
include_examples 'Record'
describe 'attributes' do
subject(:in_store_image) { described_class.new build(:in_store_image) }
it 'has category version id' do
expect(subject).to respond_to(:category_version_id)
end
it 'has merchan... |
# encoding: utf-8
#
# Cargo culted from: https://gist.github.com/pasela/9392115
require "timeout"
# Capture the standard output and the standard error of a command.
# Almost same as Open3.capture3 method except for timeout handling and return value.
# See Open3.capture3.
#
# result = capture3_with_timeout([env,] cm... |
# -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require "subcheat/version"
Gem::Specification.new do |s|
s.name = 'subcheat'
s.version = Subcheat::VERSION
s.authors = ['Arjan van der Gaag']
s.email = ['arjan@arjanvandergaag.nl']
s.homepage = 'http://github.com/a... |
#!/usr/bin/env ruby
# encoding : utf-8
require "shellwords"
require 'fileutils'
# Given an mkd file, will create the matching epub file
if `which ebook-convert` == ''
puts "Unable to find ebook-convert, please install calibre"
exit
end
ARGV.each do |file|
mkdFile = File.expand_path(file)
ext = File.extname(file)... |
class Planet
attr_reader :name, :color, :mass_kg, :distance_from_sun_km, :fun_fact
def initialize(name, color, mass_kg, distance_from_sun_km, fun_fact)
raise ArgumentError.new("Mass(kg) should be a number that greater than zero: #{ mass_kg }") if !(mass_kg.to_f > 0)
@mass_kg = mass_kg.to_f
raise... |
class ContactForm < Noodall::Component
key :form_id, String
has_one :form, :class => Noodall::Form
module ClassMethods
def form_options
lists = Noodall::Form.all(:fields => [:id, :title], :order => 'title ASC')
lists.collect{|l| [l.title, l.id.to_s]}
end
end
extend ClassMethods
end
|
Redmine::Plugin.register :redmine_bulk_ticket do
name 'Redmine Bulk Ticket plugin'
author 'Kunihiko Miyanaga'
description 'Supports bulk ticketing.'
version '0.0.1'
url 'https://github.com/miyanaga/redmine-bulk-ticket'
author_url 'http://www.ideamans.com/'
project_module :bulk_ticket do
permission :b... |
describe Messages do
describe '.create' do
it 'creates a new peep' do
message = Messages.create(username: 'leoncross', name: 'leon', message: 'My very first peep!!!')
expect(message).to be_a Messages
expect(message.username).to eq 'leoncross'
expect(message.name).to eq 'leon'
expect(... |
require 'spec_helper'
describe "languages/show" do
before(:each) do
@language = assign(:language, stub_model(Language,
:title => "Title",
:reading => "Reading",
:writting => "Writting",
:perception => "Perception",
:conversation => "Conversation",
:teacher_id => 1
))
end... |
class Team < ApplicationRecord
has_many :projects, dependent: :destroy
has_many :users
accepts_nested_attributes_for :users, allow_destroy: true
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 rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel... |
require 'test_helper'
module DataPlugins::Annotation
class HasAnnotationsTest < ActiveSupport::TestCase
setup do
@annotation_category = AnnotationCategory.create(title: 'Kategorie1')
end
[:orga, :event, :offer].each do |entry_factory|
should "deliver annotations for #{entry_factory}" do
... |
class Member < ApplicationRecord
has_many :designation_profiles, dependent: :destroy
has_many :designation_accounts, through: :designation_profiles
has_many :donations, through: :designation_accounts
has_many :donor_accounts, through: :donations
validates :name, :email, :access_token, presence: true
before_... |
require 'rails_helper'
RSpec.describe TutorialVideo, :type => :model do
xdescribe 'allow mass assignment of' do
it { is_expected.to allow_mass_assignment_of(:title) }
it { is_expected.to allow_mass_assignment_of(:url) }
end
end
|
class BookSubject < ActiveRecord::Base
before_validation on: [:create, :update] do
self.created_at = Date.today
end
attr_accessible :book_id, :subject_id
end
|
class AddNewFabricColumns < ActiveRecord::Migration
def change
add_column :fabrics, :meters_sold, :decimal, null: false, default: 0
add_column :fabrics, :rolls_sold, :integer, null: false, default: 0
add_column :fabrics, :total_profit, :decimal, null: false, default: 0
end
end |
require "formula"
class Nlopt < Formula
homepage "http://ab-initio.mit.edu/nlopt/"
url "http://ab-initio.mit.edu/nlopt/nlopt-2.4.1.tar.gz"
sha1 "181181a3f7dd052e0740771994eb107bd59886ad"
def install
ENV.deparallelize
system "./configure", "--with-cxx",
"--prefix=#{prefix}"
... |
class AddNumberToGotFixedIssue < ActiveRecord::Migration
def change
add_column :got_fixed_issues, :number, :integer
add_column :got_fixed_issues, :vendor_id, :string
end
end
|
# Copyright (c) 2015 - 2020 Ana-Cristina Turlea <turleaana@gmail.com>
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS... |
# frozen_string_literal: true
module Timer
class TimerJob
def initialize(interval, base)
@interval = interval
@base = base
@mtime = Time.now
trigger
end
def mtime
@mtime
end
def result
@mtime
end
def trigger
now = Time.now
next_trigger = ... |
require 'benchmark'
require 'prime'
# This is the largest valid bound for the prime pandigital because
# every other pandigital number bounds is divisible by 3, save for
# this and 4321.
LARGEST_PANDIGITAL = 7654321
# Returns true if an n-digit number has digits [1, n] appear
# at most once.
def pandigital?(n)
digi... |
class FeedsController < ApplicationController
before_action :set_feed, only: [:show, :edit, :update, :destroy]
# GET /feeds
# GET /feeds.json
def index
@feeds = Feed.all
end
# GET /feeds/1
# GET /feeds/1.json
def show
end
# GET /feeds/new
def new
@feed = Feed.new
end
# GET /feeds/1... |
# MatchDueOn
#
# spot - the date which something became due
# show - the date we display as the date it became due - when the spot date
# is not acceptable.
#
MatchedDueOn = Struct.new(:spot, :show) do
def <=> other
return nil unless other.is_a?(self.class)
[spot, show] <=> [other.spot, other.show]
... |
# Preview all emails at http://localhost:3000/rails/mailers/notification_mailer
class NotificationMailerPreview < ActionMailer::Preview
# Preview this email at http://localhost:3000/rails/mailers/notification_mailer/post_create_email
def post_create_email
NotificationMailer.post_create_email('default@email.com... |
class CreatePrivilegesUsers < ActiveRecord::Migration[5.0]
def up
create_table :privileges_users do |t|
t.integer :privilege_id
t.integer :user_id
t.timestamps
end
add_index(:privileges_users,[:privilege_id,:user_id])
end
def down
drop_table :privileges_users
end
end
|
class WeightsController < ApplicationController
before_filter :authenticate_user!
def show
@weight = Weight.find(params[:id])
respond_to do |format|
format.html # show.html.erb
end
end
def new
@weight = Weight.new
respond_to do |format|
format.html # new.html.erb
end
end... |
require 'miq_tempfile'
require_relative 'MiqOpenStackCommon'
#
# TODO: Create common base class for MiqOpenStackInstance and MiqOpenStackImage
# and factor out common code. Also, refactor MiqVm so it can be a proper super class.
#
class MiqOpenStackInstance
include MiqOpenStackCommon
attr_reader :vmConfigFile
... |
module Report
module InspectionDataPageWritable
include DataPageWritable
private
def date_key
:inspection_date
end
def technician_key
:inspected_by
end
end
end |
require "webrat/selenium/application_servers/base"
module Webrat
module Selenium
module ApplicationServers
class Jetty < Webrat::Selenium::ApplicationServers::Base
def start
system start_command
end
def stop
silence_stream(STDOUT) do
system stop_com... |
class AddPairToRooms < ActiveRecord::Migration[5.2]
def change
add_column :rooms, :follower_id, :integer
add_column :rooms, :followable_id, :integer
end
end
|
# == Schema Information
#
# Table name: site_types
#
# id :bigint not null, primary key
# description :text
# name :string
# superseded_by :integer
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# index_site_types_on_name ... |
Vagrant.configure("2") do |config|
config.vm.hostname = "api-runemadsen-com"
config.vm.box = "opscode-ubuntu-12.04"
config.vm.box_url = "https://opscode-vm.s3.amazonaws.com/vagrant/opscode_ubuntu-12.04_provisionerless.box"
config.vm.network :forwarded_port, guest: 3000, host: 3001
config.vm.network :forwar... |
class World < ApplicationRecord
belongs_to :world_config
belongs_to :map
def self.get_joinable_world
open_worlds = World.get_open_list
# open_worlds = JSON.parse(open_worlds)
if !open_worlds.blank?
last_open_world = open_worlds.to_a.last
joinable = World.check_joinable(last_open_world[0], last_open_worl... |
class EmbedUrlFetcher < ApplicationJob
def perform(link_id)
@link = Link.find(link_id)
get_xnxx_data
get_pornhub_data
get_youtube_url
get_xvideos_data
get_xhamster_data
@link.source_url
end
def get_youtube_url
host = URI.parse(@link.url.chomp).host
if host.include? 'youtube.'
... |
Rails.application.routes.draw do
resources :users
resource :registrations, only: [:new, :create]
resource :sessions, only: [:new, :create, :destroy]
resource :settings, only: [:edit, :update]
resources :users, only: [:index, :show] do
resource :follows, only: [:create, :destroy]
get :favorites, on:... |
class Home::StoresController < ApplicationController
# GET /home/stores
# GET /home/stores.json
def index
@home_stores = Home::Store.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @home_stores }
end
end
# GET /home/stores/1
# GET /home/stores/1.j... |
class AddMatchedPartsToSentence < ActiveRecord::Migration
def change
add_column :sentences, :matched_parts, :string
end
end
|
module Linux
module Lxc
class Index
attr_reader :files
def initialize
@key_index = {}
@dirs = {}
@files = {}
end
def add_line(key, line)
@key_index[key] ||= Lines.new
@key_index[key].add(line)
end
def get_key(key)
@key_index[ke... |
# encoding: UTF-8
require_relative '../../lib/error'
require_relative 'event2task/objective/objectives'
require_relative 'event2task/visit/visits'
require_relative 'event2task/statistic/statistic'
require_relative 'event2task/statistic/chosens'
require_relative 'event2task/statistic/default'
require_relative 'event2ta... |
require 'httparty'
class PixelPeeper
include HTTParty
base_uri 'www.pixel-peeper.com'
default_timeout 1 # hard timeout after 1 second
def api_key
ENV['PIXELPEEPER_API_KEY']
end
def base_path
"/rest/?method=list_photos&api_key=#{ api_key }"
end
def handle_timeouts
begin
yield
re... |
class User
include DataMapper::Resource
property :id, String, :key => true, :nullable => false
property :username, String, :nullable => false
property :password, String, :nullable => false
end
|
class AddRejectedFieldToModerableTexts < ActiveRecord::Migration
def change
add_column :moderable_texts, :rejected, :boolean, default: false
end
end
|
module Yara
class UserData < FFI::Struct
layout :number, :int32
end
end
|
class CommentsController < ApplicationController
def index
@comments = Comment.all
end
def new
@page_title = 'Add New Comment'
@comment = Comment.new
end
def create
@comment = Comment.new(comment_params)
@comment.user_id = current_user.id
@id = params[:stamp_id]
if @comment.save
... |
require_relative 'test_helper'
require './lib/display_board'
require './lib/game_board'
require './lib/shots_fired'
require './lib/user_interaction'
class DisplayBoardTest < Minitest::Test
def test_it_exists_and_initializes_with_board_and_labels_and_layout_and_coordinates
board = GameBoard.new
display = Dis... |
class Feedback < ActiveRecord::Base
include Concerns::Cacheable
include Concerns::ReactJson
belongs_to :schedule
belongs_to :mit_class
validates :positive, inclusion: [true, false]
validates :schedule, presence: true
validates :mit_class, presence: true, uniqueness: { scope: [:schedule] }
def feature... |
class NavbarConfig
include Singleton
PROPERTIES = [
:user,
:new_class_button,
:back_link,
:needs_menu_dropdown,
:wide_search,
:profile_page
]
PROPERTIES.each do |property|
attr_accessor property
end
def clear
PROPERTIES.each do |property|
send "#{property}=", nil
... |
class ApplicationController < ActionController::Base
include SessionsHelper
private
def verify_admin
return if logged_in? && is_admin?
flash[:danger] = t "permission"
redirect_to root_url
end
def verify_login
return if logged_in?
flash[:danger] = t "please_login"
redirect_to login_u... |
class Teacher < ActiveRecord::Base
#ASSOCIATIONS
# has_many :students
# has_and_belongs_to_many :students
has_many :subjects
has_many :students, through: :subjects
#VALIDATIONS
validates_presence_of :name
validates_length_of :name, maximum: 10
validates :name, uniqueness: :true
end
|
class Stuff
attr_accessor :number1, :string1, :truthy, :falsy, :floaty, :array1, :array2, :hash1, :otherstuff
def initialize
self.number1 = 1
self.string1 = "Test1"
self.truthy = true
self.falsy = false
self.floaty = 3.14
self.array1 = Array.new
self.array1 << 1
sel... |
class ScholarshipApplication < ApplicationRecord
validates :user_id, uniqueness: {scope: :scholarship_id}
belongs_to :user
belongs_to :scholarship
delegate :name, to: :user, prefix: true
delegate :email, to: :user, prefix: true
end
|
module Domotics::Core
class Dimmer < Element
DEFAULT_LEVEL = 0
MIN_LEVEL = 0
MAX_LEVEL = 255
MAX_STEPS = 128
STEP_DELAY = 1.0 / MAX_STEPS
STEP_SIZE = ((MAX_LEVEL + 1) / MAX_STEPS.to_f).round
def initialize(args = {})
@type = args[:type] || :dimmer
@fade_lock = Mutex.new
... |
class Card
class Civil
class Technology
class Urban < Technology
def available_actions(type, phase, gc = nil)
options = super
if type == GameCard::PlayerCard && phase == Game::Civilization::Phase::ACTIONS
options[:build] = PlayerAction::Civil::Build::Building... |
class Activity < ActiveRecord::Base
belongs_to :location
belongs_to :sport
belongs_to :group
belongs_to :captain, class_name: 'User', foreign_key: 'captain_id'
has_many :bookings, dependent: :destroy
has_many :users
has_many :comments, through: :bookings
validates :name, :number_of_players, :date, :sp... |
class TableDrawer
CELL_LENGTH = 20
ROW_LENGTH = 63
attr_reader :headers, :rows, :total, :discount
def initialize(headers, rows, total, discount)
@headers = headers
@rows = rows
@total = total
@discount = discount
end
def call
output = "\n"
output << render_break
output << rend... |
ENV['RAILS_ENV'] ||= 'test'
require_relative '../config/environment'
require 'rails/test_help'
class ActiveSupport::TestCase
# Run tests in parallel with specified workers
parallelize(workers: :number_of_processors)
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
fixtures :all... |
class PasswordsController < ApplicationController
layout 'basic'
# GET /accounts/password/new
def new
render cell(Password::Cell::New, Account.new)
end
# POST /accounts/password
def create
run Password::SendResetInstructions do
flash[:notice] = I18n.t("devise.passwords.send_instructions")
... |
require 'spec_helper'
describe "edicts/show" do
before(:each) do
@edict = assign(:edict, stub_model(Edict,
:keys => "",
:kanji => "",
:kana => "",
:defs => "",
:edict_id => "MyText"
))
end
it "renders attributes in <p>" do
render
# Run the generator again with the -... |
require "spec_helper"
describe MysticsController do
describe "routing" do
it "routes to #index" do
get("/mystics").should route_to("mystics#index")
end
it "routes to #new" do
get("/mystics/new").should route_to("mystics#new")
end
it "routes to #show" do
get("/mystics/1").shou... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.