text stringlengths 10 2.61M |
|---|
class Dev
def hello
'Hello dev'
end
end
class User
def initialize
@name = 'Den'
end
def hello
"Hello, #{@name}"
end
end
|
class CreateFooterSites < ActiveRecord::Migration
def self.up
create_table :footer_sites do |t|
t.string :name
t.string :legend
t.string :destination
t.string :link_target
t.string :image_file_name
t.string :image_content_type
t.integer :image_file_size
t.datetime :... |
class Pv < Formula
homepage "http://www.ivarch.com/programs/pv.shtml"
url "http://www.ivarch.com/programs/sources/pv-1.5.7.tar.bz2"
sha1 "173d87d11d02a524037228f6495c46cad3214b7d"
bottle do
revision 1
sha1 "0c77b97448d2705d9e9f5a63ceafa42e483a21d9" => :yosemite
sha1 "a49bcc1abe924b622d06fb15eb01141... |
# -*- encoding : utf-8 -*-
require 'httparty'
require 'json'
module Prosper
module Api
class Conta
include HTTParty
base_uri ::Prosper::Api.config.url
attr_accessor :attributes
attr_accessor :errors
def initialize(attributes = {})
self.attributes = attributes
end
... |
module Api
module V2
class Api::V2::PlayersController < ApplicationController
def index
players = Player.all
authorize! :read, players
render json: players
end
end
end
end
|
class Pangram
ALPHABET = %w(a b c d e f g h i j k l m n o p q r s t u v w x y z)
def self.pangram?(sentence)
(ALPHABET - sentence.downcase.split('')).empty?
end
end
|
# class Person
# # attr_reader :name, :age # with this we dont need getter methods
# # attr_writer :name, :age # with this we dont need setter methods
# attr_accessor :name, :age # with this we dont need the reader or writer. depends on what you want to use.
# def initialize(name, age)
# @name = name
# @age = a... |
require 'open-uri'
module Calculators
class JsonBasedCalculator
MIN_ARRAY_LENGTH = 10
def price(data)
json = JSON.load(data)
arrays_count = count_arrays_number json, 10
arrays_count
end
def count_arrays_number(element, limit)
result = 0
element.each_value do |value... |
class BooksController < ApplicationController
before_action :set_book, only: [:show, :edit, :update, :destroy]
# GET /books
def index
@books = Book.all
end
# GET /books/1
def show
end
# GET /books/new
def new
@book = Book.new
end
# GET /books/1/edit
def edit
end
# book /books
... |
require 'gladiator'
class Arena
def initialize(name)
@name = name.capitalize
@gladiators = []
end
def name
@name
end
def gladiators
@gladiators
end
def clear
@gladiators = []
end
def remove_gladiator(gladiator_name)
@gladiators.delete_if { |gladiator| gladiator.name == gl... |
class Activity < ActiveRecord::Base
validates :kind, :points, :action, presence: true
def to_sentence
"#{action} #{kind}"
end
end
|
class CreateProfiles < ActiveRecord::Migration
def change
create_table :profiles do |t|
t.string :image_1, null: false, default: "default.jpg"
t.string :image_2
t.string :image_3
t.string :image_4
t.string :image_5
t.text :fav_characters
t.text :fav_spots
t.text :fa... |
require 'net/http'
require 'net/https'
require 'uri'
require 'nokogiri'
module GoogleAnalytics
AUTH_URL = 'https://www.google.com/accounts/ClientLogin'
BASE_URL = 'https://www.google.com/analytics'
class NotAuthorized < StandardError; end
class ResponseError < StandardError; end
class Client
... |
class Product < ApplicationRecord
has_many :order_products
has_many :orders, through: :order_products
def status
if is_alive?
"在庫中"
else
"已售完"
end
end
def sell
self.count = self.count - 1
end
def sold_out
self.is_alive = false if self.count == 0
end
end
|
module API
module Ver1
class Candidate < Grape::API
format :json
formatter :json, Grape::Formatter::Jbuilder
resource :provision do
route_param :provision_id do
resource :candidate do
# GET /api/ver1/candidate
desc 'Return all candidates depends on specif... |
require "matrix"
class InputParser
class << self
def call(raw_input, task_number)
draw = raw_input[0].split(",")
boards = parse_raw_boards_input(raw_input[1..-1], task_number)
[draw, boards]
end
private
# This parser is shared among solutions to part 1 and part 2 and the output... |
Rails.application.routes.draw do
# root to: 'visitors#index'
devise_for :users
resources :users
resources :posts do
member do
put "like", to: "posts#upvote"
end
end
root to: 'posts#index'
end
|
class Phrase
attr_accessor :words
def initialize(words)
self.words = words.gsub(/[,.!&@$%^&:(\n)]/, ' ').gsub(/ '|' /, ' ').downcase
end
def word_count
counts = Hash.new(0)
words.split.each do |word|
counts[word] += 1
end
counts
end
end
|
# frozen_string_literal: true
# The UnderlyingLegInstrumentParser is responsible for the <Undly> mapping. This tag is one of many tags inside
# a FIXML message. To see a complete FIXML message there are many examples inside of spec/datafiles.
#
# Relevant FIXML Slice:
#
# <Undlys>
# <Undly Exch="NYMEX" MMY="201508" ... |
require 'test_helper'
# Tests for Client summarization, UserFeat top_feats, UserBadge top_badges
class SummarizationTest < ActiveSupport::TestCase
self.use_instantiated_fixtures = true
fixtures :clients
fixtures :users
def setup
# clear all data
UserBadge.delete_all
UserFeat.delete_all
ClientS... |
class AddDescripcionToNoticiaEscuela < ActiveRecord::Migration[5.1]
def change
add_column :noticia_escuelas, :descripcion, :string
end
end
|
class AddToRecord < ActiveRecord::Migration[5.1]
def change
add_column :records, :school_year, :integer
add_column :records, :teacher_name, :string
add_column :records, :position, :string
add_column :records, :phone, :string
add_column :records, :teacher_email, :string
end
end
|
class GuideController < ApplicationController
skip_before_filter :authorize
def index
@restaurants = Restaurant.order(:Name)
@list = current_list
end
end
|
class RemoveProjectSocialStateFromProject < ActiveRecord::Migration
def change
remove_column :projects, :project_social_state
end
end
|
@boards.each do |board|
json.set! board.id do
json.extract! board, :id, :title
end
end
|
# frozen_string_literal: true
# Helper methods for the advanced search form
module AdvancedHelper
include BlacklightAdvancedSearch::AdvancedHelperBehavior
# Overrides method in BlacklightAdvancedSearch::AdvancedHelperBehavior in order to include
# Aria describedby on select tag
def select_menu_for_field_operato... |
FactoryBot.define do
sequence :email do |n|
"email@domain#{n}.com"
end
sequence :first_name do |n|
"FirstName #{n}"
end
sequence :last_sign_in_at do |n|
DateTime.now
end
sequence :url_slug do |n|
"url-slug-#{n}"
end
sequence :average_rating do
rand(1..5)
end
sequence :ratin... |
FactoryBot.define do
factory :order_street do
postal_code { "123-4567" }
delivery_area_id { 2 }
municipality { "横浜市美浜区" }
address { "青山1-1-1" }
building { "柳ビル" }
phone_number ... |
# frozen_string_literal: true
require "#{Rails.root}/lib/next_question_fetcher"
module Api
module V1
class QuestionsController < ApiController
include QuestionConcern
before_action :set_question, only: %i(preview)
def preview
preview_question = {}
details = question_details(@que... |
module DataPlugins::Facet
class FacetItem < ApplicationRecord
include Jsonable
include DataPlugins::Facet::Concerns::ActsAsFacetItem
include Translatable
include FapiCacheable
# ASSOCIATIONS
belongs_to :facet
belongs_to :parent, class_name: FacetItem
has_many :sub_items, class_name: F... |
require 'helper'
require 'sumologic/kubernetes/reader.rb'
require 'fluent/test/log'
class ReaderTest < Test::Unit::TestCase
include SumoLogic::Kubernetes::Connector
include SumoLogic::Kubernetes::Reader
def setup
# runs before each test
stub_apis
connect_kubernetes
end
def teardown
# runs a... |
require 'console_creep/stores/store'
module ConsoleCreep
module Stores
class DatabaseStore < Store
def store(user, command, result, error)
ActiveRecord::Base.logger.silence do
record = { user: user, command: command, result: result, error: error }
record.delete_if { |k, _v| exce... |
class CreateThingCategoryRelation < ActiveRecord::Migration
def change
create_table :thing_category_relations do |t|
t.references :category, index: true
t.references :catable, polymorphic: true, index: true
t.boolean :primary
t.timestamps null: false
end
end
end
|
class PaginaPrincipalAdministradorController < ApplicationController
before_action :authenticate_administrator!
def index
@administrator=current_administrator
end
end
|
require "rubygems/test"
require "rubygems/collection"
require "rubygems/info"
class TestGemCollection < Gem::Test
def test_by
a = entry "foo", "1.0.0"
b = entry "foo", "2.0.0"
c = filter a, b
expected = { "foo" => [a, b] }
assert_equal expected, c.by(:name)
end
def test_empty?
assert fi... |
Adela::Application.routes.draw do
localized do
devise_for :users
as :user do
get 'users/edit' => 'devise/registrations#edit', as: 'edit_user_registration'
patch 'users/:id' => 'devise/registrations#update', as: 'user_registration'
end
get '/:slug/catalogo' => 'organizations#catalog', as:... |
module Emarsys
module Broadcast
class TransactionalXmlBuilder < BaseXmlBuilder
def build_xml(transactional)
Nokogiri::XML::Builder.new do |xml|
xml.mailing do
xml.name transactional.name
xml.properties { shared_properties(xml, transactional) }
xml.recipi... |
VALID_CHOICES = %w(rock paper scissors).freeze
# def test_method(something)
# prompt("#{something}")
# end
def win?(first, second)
(first == 'rock' && second == 'scissors') ||
(first == 'scissors' && second == 'paper') ||
(first == 'paper' && second == 'rock')
end
def display_results(player, computer)
... |
# frozen_string_literal: true
module Sourcescrub
# Utils
module Utils
# Veriables
module Veriables
# Description of operators
PEOPLE_ROLES = {
'founder' => 'Founder',
'employee' => 'Employee',
'board_member' => 'Board Member',
'advisor' => 'Advisor'
}.freez... |
#!/usr/bin/env ruby
=begin
author: Yuya Nishida <yuya@j96.org>
licence: X11
id: $Id: amrit,v 1.3 2002/12/04 04:05:53 yuya Exp $
amrit commands
=end
module Amrit
autoload :VERSION, "amrit/version"
def self.run(args)
sleep_time = 1
trap(:TERM) do
exit(1)
end
trap(:USR1) do
STDERR.puts(... |
require 'will_paginate/view_helpers/base'
require 'will_paginate/view_helpers/link_renderer'
# Merb gives you a Merb::Plugins.config hash...feel free to put your stuff in your piece of it
Merb::Plugins.config[:paging] = {
:class => 'pagination',
:previous_label => '« Previous',
:next_label => ... |
def line(arr)
if arr.length == 0
puts "The line is currently empty."
else
new_arr = []
arr.each.with_index(1) do |name, i|
new_arr << " #{i}. #{name}"
end
puts "The line is currently:#{new_arr.join}"
end
end
def take_a_number(arr,name)
puts "Welcome, #{name}. You are number #{arr.le... |
class CreateBrandCategories < ActiveRecord::Migration
def self.up
create_table :brand_categories do |t|
t.string :name
end
BrandCategory.create(:name => "Fortune 1000 Company")
end
def self.down
drop_table :brand_categories
end
end
|
class Condition < Base
attr_accessor :treatments
self.query = <<-EOL
PREFIX foaf: <http://xmlns.com/foaf/0.1>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX stories: <http://purl.org/ontology/stories/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX xsd: ... |
include Java
import java.awt.BasicStroke
module ScorchedEarth
module Renders
class Mouse
attr_reader :mouse, :player
def initialize(mouse, player)
@mouse = mouse
@player = player
end
def call(graphics, color_palette)
return unless mouse.x && mouse.y
co... |
class Producer < ActiveRecord::Base
has_and_belongs_to_many :users
has_many :webhooks, :through => :consumers
has_many :consumers, :dependent => :destroy
validates_presence_of :owner_id
validates_presence_of :name
before_create :make_admin_user
def make_admin_user
user = User.find( self.owner_id )
... |
# 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... |
module BoatsHelper
def boat_title(boat)
"#{boat.manufacturer_model} for sale"
end
def boat_length(boat, unit = nil)
return nil if !boat.length_m || boat.length_m <= 0
unit ||= try(:current_length_unit) || 'm'
length = unit == 'ft' ? boat.length_ft.round : boat.length_m.round
"#{length} #... |
class ProductReviewsController < ApplicationController
before_filter :login_required
# GET /product_reviews
# GET /product_reviews.xml
def index
@product_reviews = ProductReview.find(:all)
respond_to do |format|
format.html # index.rhtml
format.xml { render :xml => @product_reviews.to_xml ... |
class AlphaSmsStatusJob
include Sidekiq::Worker
include Sidekiq::Throttled::Worker
sidekiq_options queue: :default
sidekiq_options retry: 3
sidekiq_throttle(
threshold: {limit: 250, period: 1.minute}
)
def perform(request_id)
detailable = AlphaSmsDeliveryDetail.find_by!(request_id: request_id)
... |
# -*- mode: ruby -*-
# vi: set ft=ruby :
# user configurable settings
require './settings'
Vagrant.configure("2") do |config|
# use ubuntu precise pangolin 32 bit
config.vm.box = VAGRANT_BOX
# use SYNCED_DIRS in `settings.rb' to mirror directories on the host system to
# the vm filesystem
SYNCED_DIRS.each... |
module Configuration
class Invalid < RuntimeError
def initialize(message)
super(message + " for environment #{ENV['RACK_ENV']}")
end
end
def after_config_loaded(method_name=nil, &block)
after_config_loaded_callbacks.push(block || -> { send(method_name) })
end
def config=(config)
@conf... |
# require "rubygems"
# require "bundler"
require 'pry'
# Bundler.require :default, :test
include Rake::DSL
prompt = "irb"
cfg = YAML.load_file File.expand_path("../config/application.yml", __FILE__)
if defined? pry
prompt = "pry"
end
def relative_dir path
File.expand_path "../#{path}", __FILE__
end
task defau... |
class CreateApps < ActiveRecord::Migration
def up
create_table :apps do |t|
t.string 'uuid', :null => false
t.string 'appname', :null => false
t.string 'apptype', :null => false
t.string 'consumer_key', :null => false
t.string 'consumer_secret', :null => false
t.string 'user_id... |
#!/usr/bin/env ruby
# frozen_string_literal: true
# rubocop:disable all
require 'diplomatic_bag'
require 'optparse'
require 'diplomat/version'
def syntax
printf "USAGE: #{$PROGRAM_NAME} [[action]] [[options]]\n\n" \
"\t#{$PROGRAM_NAME} services list [options]\n" \
"\t#{$PROGRAM_NAME} service sta... |
class CreateTransferRequest
def initialize(participant:, receiver:)
@participant = participant
@receiver = receiver
end
def call
transfer_request = TransferRequest.new(
participant: participant,
receiver: receiver,
contact: receiver_contact
)
if transfer_request.save
... |
#--
# 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 to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell ... |
require './car.rb'
require './parkinglot.rb'
describe ParkingLot do
let(:parking_lot) { ParkingLot.new(6) }
it 'should accept slots in parking lot' do
expect(parking_lot.counter).to eq(6)
end
describe '.full' do
it 'should return false if the counter is not null or 0' do
expect(parking_lot.full... |
module BookKeeping
VERSION = 2
end
class FoodChain
FIRST_SENTENCE = "I know an old lady who swallowed a ".freeze
FORE_LAST_SENTENCE = "\nI don't know why she swallowed the fly. Perhaps she'll die.\n\n".freeze
LAST_SENTENCE = "I know an old lady who swallowed a horse.\nShe's dead, of course!\n"
COMMENTS = [
... |
require "./spec/spec_helper"
describe "EntityDefinition" do
before do
@subject = CDM::EntityDefinition
end
it "exists" do
@subject.should be
end
describe ".create_entity" do
before do
@dummy = @subject.new
end
context "when adding the :foo entity with no attributes" do
befo... |
class RemoveShowCoursesFromSurvey < ActiveRecord::Migration
def change
remove_column :surveys, :show_courses
end
end
|
module Validation
def self.included(receiver)
receiver.extend ClassMethods
receiver.send :include, InstanceMethods
end
module ClassMethods
attr_reader :validators
def validate(attribute, *params)
@validators ||= []
@validators << { attribute => params }
end
end
modul... |
class CreateTooms < ActiveRecord::Migration[6.0]
def change
create_table :tooms do |t|
t.timestamps
end
end
end
|
require 'rails_helper'
feature "regular user updates registration" do
context "they change their name and email" do
before(:each) do
regular_user = FactoryBot.create(:user)
sign_in regular_user
visit root_path
click_on "edit account"
fill_in "Name", with: "somebody else"
... |
class AddRoleToMembershipAndRemoveGroupCreatorAndGroupAdmin < ActiveRecord::Migration
def self.up
add_column :memberships, :role, :string, :default => "member"
remove_column :memberships, :group_creator
remove_column :memberships, :group_admin
end
def self.down
remove_column :memberships, :role
... |
class AddTextAndPagesToDocuments < ActiveRecord::Migration
def change
add_column :documents, :text, :text
add_column :documents, :pages, :json
end
end
|
module SyntaxHighlighting
# A child object to `Pattern`; repesenting a captures from a tmLanguage file.
#
class Captures
def initialize(contents)
@store = {}
contents.each do |number_identifier, values|
raise UnhandledCapturesError if values["name"].nil?
@store[number_identifier.t... |
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Brcobranca::CalculoData do
it 'Calcula o fator de vencimento' do
expect((Date.parse '2008-02-01').fator_vencimento).to eq('3769')
expect((Date.parse '2008-02-02').fator_vencimento).to eq('3770')
expect((Date.parse '2008-02-06').fator_ven... |
class CreateCategoria < ActiveRecord::Migration[6.1]
def change
create_table :categoria do |t|
t.string :nombre
t.string :descripcion
t.string :img
t.timestamps
t.column :deleted_at, :datetime, :limit => 6
end
end
end
|
module Recliner
class ViewDocument < Recliner::Document
property :language, String, :default => 'javascript'
property :views, Map(String => View)
def update_views(new_views)
self.views = views.dup.replace(new_views)
save! if changed?
end
def invoke(view, *args)
views[vi... |
class Course < ActiveRecord::Base
attr_accessible :name
# a student can e on many courses, a course can have many students
has_and_belongs_to_many :students
end
|
# == Schema Information
#
# Table name: calendar_dates
#
# id :integer not null, primary key
# calendar_id :integer
# date_fr :datetime
# date_to :datetime
# created_at :datetime not null
# updated_at :datetime not null
#
class CalendarDate < ActiveRecord::Base
attr_... |
module Hydramata
module Works
module DatastreamParsers
# Responsible for parsing a very simplistic XML document.
module SimpleXmlParser
module_function
def match?(options = {})
datastream = options[:datastream]
return false unless datastream
if datastream.... |
#!/usr/bin/ruby
require 'nventory'
nvclient = NVentory::Client.new
subnet_results = nvclient.get_objects('subnets', {}, {})
if subnet_results.nil? || subnet_results.empty?
abort "Failed to get subnet data from nVentory"
end
subnet_results.each_value do |subnet|
if subnet['network'] && subnet['netmask']
@contents... |
class Person < ActiveRecord::Base
has_many :addresses, dependent: :destroy
has_one :profile, dependent: :destroy
accepts_nested_attributes_for :addresses
validates :name, :lastname, presence: {message: "No debe estar vacio"}
validates :ci, numericality: {only_integer: true,
greater_than: 99999, less_t... |
##########################################################################
# Copyright 2017 ThoughtWorks, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/li... |
class SessionsController < ApplicationController
def new
@title = "Sign in"
end
def create
user= User.authenticate(params[:session][:email],
params[:session][:password])
if user.nil?
flash.now[:error] = "Invalid email/password combination."
@title="Sign in"
... |
class AddApplicantorIdToPaymentLogs < ActiveRecord::Migration
def change
add_column :payment_logs, :applicantor_id, :integer
end
end
|
require 'test_helper'
class BudgetpostTest < ActiveSupport::TestCase
def setup
@user = users(:michael)
# This code is not idiomatically correct.
@budgetpost = @user.budgetposts.build(content: "Lorem ipsum")
end
test "should be valid" do
assert @budgetpost.valid?
end
test "user id should be... |
class CommitmentsController < ApplicationController
load_and_authorize_resource
def create
@commitment = Commitment.new(commitment_params)
# We can grab user_id and event_id because we passed them into the params
# in the new commitment form (in the event show page).
@event = Event.find(params[:e... |
class User < ActiveRecord::Base
has_many :posts
has_many :comments, through: :posts
has_many :photos
end
class Post < ActiveRecord::Base
validates_length_of :body, maximum: 150
belongs_to :user
has_many :comments
end
class Comment < ActiveRecord::Base
belongs_to :user
belongs_to :post
end
class Photo < Act... |
class Shop < ActiveRecord::Base
attr_accessible :name
has_many :owners
has_many :repairs, :through => :owners
end
|
class Ray
attr_accessor :origin, :destination
def initialize(origin = Vector3.new(0, 0, 0), destination = Vector3.new(0, 0 ,0))
@origin, @destination = origin, destination
end
def collision_line_segment?(a, b, o, p)
ab = Vector3.new(b.x - a.x, b.y - a.y)
ap = Vector3.new(p.x - a.x, p.y - a.y)
ao = Vector3.... |
require 'rails_helper'
RSpec.feature "User/Visitor navigates to Art home page", type: :feature, js: true do
before :each do
@user = User.create! username:"Test User", password: "Password"
@user.arts.create!(
name: "In Thought",
image: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRxAKQ_Wafp303Z... |
class Api::BikesController < ApplicationController
def index
@bikes = Bike.all
render json: @bikes
end
def show
@bike = Bike.find(params['id'])
render :show
end
def search
@bikes = filter_bikes(filter_options)
render json: @bikes
end
private
def bike_params
params.require... |
class HomeController < ApplicationController
def index
if current_user
@posts = Post.all
else
@posts = Post.where(:active => true)
end
end
end
|
class AddPushedOutToWorkorders < ActiveRecord::Migration
def change
add_column :workorders, :showappointment, :boolean
end
end
|
class Greeter
def initialize(phrase, enabled = true)
@phrase = phrase
@enabled = enabled
end
def say_hello(name)
"#{@phrase} #{name}" if @enabled
end
end
|
module Neo4j
module Migrations
module Schema
class << self
def fetch_schema_data(session)
{constraints: fetch_constraint_descriptions(session).sort,
indexes: fetch_index_descriptions(session).sort}
end
def synchronize_schema_data(session, schema_data, remove_mis... |
require 'test_helper'
class Sampling::ProgramTest < ActiveSupport::TestCase
fixtures :zip_codes
test "participant export to csv" do
participant_count = 3
program = create_sampling_program('Export Program', participant_count, true)
Reputable::Badging.stub!(:best_for, :return => Reputable::Badge... |
class Country < ApplicationRecord
has_many :states, dependent: :destroy
#validations
validates_presence_of :name, :country_code
end
|
class Admin::CategoriesController < ApplicationController
http_basic_authenticate_with name: "jungle", password: "book"
def index
@categories = Category.order(id: :desc).all
end
def new
@category = Category.new
end
def create
@category = Category.new(category_params)
if @category.save
redirect_to [:... |
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
has_many :stuffs , dependent: :destroy
has_many :ta... |
# frozen_string_literal: true
module Dynflow
module Semaphores
class Abstract
# Tries to get ticket from the semaphore
# Returns true if thing got a ticket
# Rturns false otherwise and puts the thing into the semaphore's queue
def wait(thing)
raise NotImplementedError
end
... |
require 'test_helper'
class TestRescues < Test::Unit::TestCase
def setup
@client = MockMogileFsClient.new
end
def test_debug_mode
app_with :path => %r{^/assets/*}, :debug => true
assert_raises(MogileFS::UnreachableBackendError) do
get '/assets/unreachable.txt'
end
end
def test_unreach... |
require File.join(File.dirname(__FILE__), 'spec_helper')
require 'schematron-nokogiri'
describe SchematronNokogiri::Schema do
it "should load a schema from a libxml document" do
file = File.join "spec", "schema", "pim.sch"
doc = Nokogiri::XML(File.open(file))
lambda { SchematronNokogiri::Schema.new doc ... |
module Carbide
class Builder
attr_reader :manager
def initialize(manager)
@manager = manager
end
def build_task(name, context, &block)
task = manager[name]
if task.nil?
task = Task.new(manager, name)
manager.register(task)
end
if block_given?
ac... |
class Train
attr_accessor :wagons_count, :speed, :route
attr_reader :type
def initialize(train_number, type, wagons_count)
@train_number = train_number
@type = type
@wagons_count = wagons_count
@speed = 0
end
def move(speed)
self.speed = speed
end
def stop
self.speed = 0
end
... |
#==============================================================================
# ** Game_ActionResult
#------------------------------------------------------------------------------
# This class handles the results of battle actions. It is used internally for
# the Game_Battler class.
#====================... |
class Comment < ActiveRecord::Base
belongs_to :post
belongs_to :account
validates_presence_of :comment, :length=>{:maximum=>140 }
sifter :or_comment do |string|
comment.matches("%#{string}%")
end
before_save :make_slug
def to_param
slug
end
def slug
if comment.length <= 24
slug ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.