text stringlengths 10 2.61M |
|---|
module DraftTaxonHelper
def draft_taxons
@draft_taxons ||= all_draft_taxons
end
def all_draft_taxons
taxons = []
draft_taxon_files.each do |file|
taxons.push(*JSON.parse(File.read(file)))
end
taxons
end
def draft_taxon_files
Dir.glob("#{file_location}/*")
end
def file_loca... |
class TrelloHooks
def boards
get('/organizations/assembly4/boards')
end
def subscribe_webhooks(board_names:)
boards = self.boards.select{ |board| board_names.include?(board.fetch('name')) }
boards.each do |board|
puts "subscribing to #{board.fetch('name')}"
post({
description: "#... |
# frozen_string_literal: true
FactoryBot.define do
factory :address, class: Preneeds::Address do
sequence(:street) { generate(:street) }
sequence(:street2) { generate(:street2) }
city 'NY'
state 'NY'
country 'USA'
postal_code '10000'
end
end
|
class CreateTicketComments < ActiveRecord::Migration
def change
create_table :ticket_comments do |t|
t.belongs_to :ticket, null: false
t.integer :author_id, null: false
t.string :body, null: false
t.boolean :public, default: true
t.timestamps
end
add_index :ticket_... |
require_relative 'boot'
require 'rails'
# Pick the frameworks you want:
require 'active_model/railtie'
require 'active_job/railtie'
require 'active_record/railtie'
require 'action_controller/railtie'
require 'action_mailer/railtie'
require 'action_view/railtie'
require 'action_cable/engine'
require 'sprockets/railtie'... |
class AddResultsAndCprToAccountInsights < ActiveRecord::Migration
def change
add_column :account_insights, :results, :float
add_column :account_insights, :cpr, :float
end
end
|
class CreateSalaryWorkingDays < ActiveRecord::Migration
def self.up
create_table :salary_working_days do |t|
t.integer :payment_period
t.integer :working_days
t.timestamps
end
end
def self.down
drop_table :salary_working_days
end
end
|
Puppet::Type.newtype(:nexus_ldap_settings) do
@doc = 'Manage the Nexus OSS LDAP connection settings.'
def pre_run_check
if self[:ldap_groups_as_roles]
raise ArgumentError, "group_base_dn must not be empty when using ldap_groups_as_roles" if self[:group_base_dn].nil? or self[:group_base_dn].to_s.empty?
... |
class ActivitiesController < ApplicationController
before_action :authenticate_user!, except: [:index]
before_action :set_activity, only: [:show, :update, :destroy]
# get activities index (/activities)
def index
@activities = Activity.all
render json: @activities
end
# get single activity (/activi... |
require 'lita/handlers/enhance/node_index'
module Lita
module Handlers
class Enhance
class MacAddressEnhancer < Enhancer
# TODO: enhance unknown MAC address with OUI names http://standards.ieee.org/develop/regauth/oui/oui.txt
MAC_ADDRESS_REGEX = /([0-9a-f]{2}:){5}[0-9a-f]{2}/i
def... |
class ProjectMailer < ApplicationMailer
def changelogs_email(changelog_ids)
@changelogs = Changelog.where(:id => changelog_ids).order('last_commit_date DESC')
return unless @changelogs.any?
generate_subject
@changelogs.first.project_emails_for_reports.each do |email|
mail(:to => email, :subje... |
require File.dirname(__FILE__) + '/../../spec_helper'
describe 'S3.delete_bucket' do
before(:all) do
@s3 = Fog::AWS::S3.gen
@s3.put_bucket('fogdeletebucket')
end
it 'should return proper attributes' do
actual = @s3.delete_bucket('fogdeletebucket')
actual.status.should == 204
end
it 'should... |
package "httpd" do
action :install
end
service "httpd" do
action [:enable, :start]
end
node["wp-stack"]["sites"].each do |sitename, data|
document_root = "/var/www/html/#{sitename}"
directory document_root do
mode "0755"
recursive true
end
ruby_block "install_wordpress" do
block do
req... |
key = ActiveSupport::KeyGenerator.new('secret_string').generate_key('salt')
# "\xB2\xB8F}$\xCE\xFC\x13\xB3\xEA\x84\x1C\xEF\xA5\x04\xA5\xEC\xB4\xBA\xA2\xB7\x15\xCB\e`\x13w\xBAb\x84\x8D\x1A\x81\xAAp\xF4\xE1\xB3\x10\xD4\xBA\xE3\xBA>\xA0E\x89\xAA\xF2\xCDl\xF6-\x04?^\xB0\az\x1DH\xB9\xCE\xFC"
crypt = ActiveSupport::MessageEn... |
FactoryBot.define do
sequence :string do |n|
"string#{n}"
end
sequence :email do |n|
"person#{n}@example.com"
end
sequence :date do |n|
Time.current.to_date + n.days
end
end
|
class RemoveColumnsFromSection < ActiveRecord::Migration
def change
remove_column :sections, :upload_file_name
remove_column :sections, :upload_file
end
end
|
class Product < ActiveRecord::Base
include Attachments
acts_as_voteable
belongs_to :vendor
has_many :transactions
has_many :users, through: :transactions
validates :name, :credits, :amount_available, :vendor_id, presence: true
validates :credits, :amount_available, numericality: { only_integer: true ... |
require 'rails_helper'
RSpec.feature 'SignInProcesses', type: :feature do
before(:each) do
User.create(name: 'user')
end
it 'Sign existing user in' do
visit '/sign-in'
fill_in 'session_name', with: 'user'
click_button 'Sign in'
expect(page).to have_content('Signed in successfully')
end
... |
class CreateFolders < ActiveRecord::Migration
def self.up
create_table :folders do |t|
t.integer :member_id, default: 0, null: false
t.string :name, null: false
t.datetime :created_on, null: false
t.datetime :updated_on, null: false
end
add_index :folders, [:member_id, :name], uniq... |
# -*- mode: ruby -*-
# vi: set ft=ruby :
# 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|
config.vm.box = "ubuntu/trusty64"
config.vm.hostname = "project-server"
config.vm.network :forwarded_port, ... |
class Topic < ActiveRecord::Base
has_many :posts, -> { order(:created_at) }, :as => :postable, :dependent => :destroy
has_many :users, :through => :posts
validates_presence_of :title
accepts_nested_attributes_for :posts, :allow_destroy => true
before_create :set_permalink
default_scope { order(last_post_dat... |
json.array!(@submissions) do |submission|
json.extract! submission, :id, :languageUsed, :dateTimeOfSubmission, :timeTaken, :memoryUsed, :submissionFile, :status, :user_id, :problem_id, :contest_id
json.url submission_url(submission, format: :json)
end
|
require 'concurrent_iterable/config'
require 'concurrent_iterable/iterator'
require 'concurrent_iterable/version'
module ConcurrentIterable
class << self
def configure
yield config
end
def config
@config ||= Config.new
end
end
end
|
namespace :scala do
desc "Compile Scala models"
task :compile do
Dir["app/models/*.scala"].each do |file|
sh "scalac-2.8 #{file}"
end
end
end |
component 'rubygem-addressable' do |pkg, _settings, _platform|
pkg.version '2.5.2'
pkg.md5sum 'b469195cee7d4ebcd492cf7c514a5ad8'
instance_eval File.read('configs/components/_base-rubygem.rb')
end
|
require "dock"
describe DockingStation do
let(:bike) {Bike.new}
let(:station) {DockingStation.new(:capacity => 20)}
def fill_station
20.times {station.dock(Bike.new)}
end
it "should be able to accept bikes" do
expect(station.bike_count).to eq(0)
station.dock(bike)
expect(station.bike_count).to eq(1)
... |
require 'rails_helper'
RSpec.feature 'Mobile data privacy notice page redirects to general privacy notice', type: :feature do
scenario 'visiting original location' do
visit '/increasing-mobile-data/privacy-notice'
expect(page).to have_selector 'h1', text: I18n.t('page_titles.general_privacy_notice')
end
... |
class Reminder < ActiveRecord::Base
require 'rufus-scheduler'
enum recurrence: [:no_recurrence, :hourly, :daily, :every_other_day, :weekly, :monthly, :yearly]
belongs_to :to_do
belongs_to :subscription
#validates_presence_of :to_do, :next_reminder_time
after_create :schedule_reminder
before_destroy :un... |
module Slickr
# Provides a central repository for storing and querying for Entities
# that exhibit some behavior.
#
# Each scene of your game will probably have many entities. When you
# instantiate one of those Entities, it's automatically registered
# to the +EntityManager+, with the behaviors it impleme... |
require 'spec_helper'
require 'shopify_api'
describe ShopifyClient do
let(:oauth_token) { 'oauth_token' }
let(:oauth_uid) { 'oauth_uid' }
subject { ShopifyClient.new oauth_uid, oauth_token}
it 'oauth_uid getter is working' do
expect(subject.oauth_uid).to be(oauth_uid)
end
it 'oauth_token getter is w... |
module DebitSharedContexts
shared_context "with unaccounted debit" do
let!(:debit) { FactoryGirl.create(:debit, :amount => BigDecimal.new("100")) }
def add_entry(credit = nil, amount = BigDecimal.new("0"))
if debit.nil?
entry = FactoryGirl.create(:entry, :debit => debit, :amount => amount)
... |
# -*- coding: utf-8 -*-
class ProjectsController < ApplicationController
layout "streets"
# GET /projects
# GET /projects.xml
def index
@projects = Project.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @projects }
end
end
# GET /projects/1
... |
module RunPal
class Circle < Entity
attr_accessor :id, :name, :admin_id, :member_ids, :max_members, :latitude, :longitude, :description, :level
# member_ids: array -> CircleUsers table
validates_presence_of :name, :admin_id, :max_members, :latitude, :longitude, :description, :level
def initialize(att... |
class TalentJob < ApplicationRecord
belongs_to :talent
belongs_to :job, optional: true
# before_validation :set_year
# before_save :set_position
validates_presence_of :year, message: "L'année doit être remplie"
# validates_presence_of :job_id, message: "Le métier doit être rempli"
# attr_accessor :ski... |
class Interest < ApplicationRecord
has_and_belongs_to_many :profiles
end |
# frozen_string_literal: true
# Transposition
# A Transposition Error is when two letters are swapped, such as in "hte" instead of "the", or "rign" instead of "ring".
# Given a string of characters, can you fix every place where "gn" appears so it becomes "ng" instead? If there are multiple "g"s in a row, the "n" sh... |
module Bitfinex
module Configurable
def self.included(base)
base.extend(ClassMethods)
end
def config
self.class.config
end
module ClassMethods
def configure
yield config
end
def config
@configuration ||= Configuration.new
end
end
end
... |
class ChallengeMailer < ActionMailer::Base
helper :application
default from: ENV['MAILER_DEFAULT_FROM']
def welcome(email, collaboration)
challenge = collaboration.challenge
@org = challenge.organization
@member = collaboration.member
# Email
subject = challenge.welcome_mail[:subject]
@b... |
class ShopsController < ApplicationController
def index
if params[:query].present?
@query = params[:query]
@shops = Shop.where("name LIKE ?","%#{params[:query]}%")
# Preventing SQL Injection and Database error for
# unknown characters
else
@shops = Shop.all
end
end
def ... |
# frozen_string_literal: true
class Brewery < ApplicationRecord
# Brewery model
include RatingAverage
has_many :beers, dependent: :destroy
has_many :ratings, through: :beers
validates :name, presence: true
validate :validate_year
scope :active, -> { where active: true }
scope :retired, -> { where ac... |
module CrudActionsMixin
extend ActiveSupport::Concern
include Pundit
included do
#before_action :set_item, only: [:show, :update, :destroy]
end
def index
# authorize(resource_class)
@items = searcher.search(search_options)
yield(@items) if block_given?
respond_with(@items,
... |
require 'open3'
require 'nkf'
# Any2Text provides a simple API to obtain and store plain text from other
# document formats by utilizing common utilities like antiword, html2text,
# odt2txt or pdftotext.
#
# It is easily extendable for other formats and does some sanity checking on
# the process, like making sure the ... |
class Round < ActiveRecord::Base
belongs_to :tournament
validates :number, numericality: { only_integer: true, greater_than_or_equal_to: 1 }
end
|
json.array!(@video_submissions) do |video_submission|
json.extract! video_submission, :id, :trail_id, :demo_link, :about
json.url video_submission_url(video_submission, format: :json)
end
|
class User < ApplicationRecord
rolify
attr_accessor :category
after_create :assign_role
# Associations
has_many :authorizations, dependent: :destroy
devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable, :omniauthable
devise :database_authenticatable, :v... |
class PlansController < ApplicationController
before_action :access_controll
before_action :find_catagory
def index
@plans = @catagory.plans
@photos = @catagory.photos
end
def new
@plan = Plan.new
render 'new', layout: false
end
def edit
@plan = Plan.find(params[:id])
render 'edi... |
require 'spec_helper'
RSpec.describe BinanceAPI::Brokerage, :vcr do
subject(:brokerage) { BinanceAPI::Brokerage.new }
describe '.create_subaccount' do
context 'when success response' do
it 'returns result with created subaccount id' do
result = brokerage.create_subaccount
expect(result.... |
def fresh_board
board = [["[ ]", "[ ]", "[ ]"], ["[ ]", "[ ]", "[ ]"], ["[ ]", "[ ]", "[ ]"]]
end
def print_board(board)
# Print column letters
puts " A B C "
# Print board
board.each.with_index(1) do |row, index|
print "#{index.to_s}: "
row.each do |space|
print s... |
class AddExpediaToTransactions < ActiveRecord::Migration[5.0]
def change
add_column :transactions, :expedia, :boolean
end
end
|
class Api::V1::PeopleController < ApplicationController
def index
@people = Person.all
render 'index.json.jbuilder'
end
def create
@person = Person.new(
name: params[:name],
bio: params[:bio]
)
if @person.save
render 'show.json.jbuilder'
else
render json:{errors: @persons.errors_ful_message}, st... |
class DashboardController < ApplicationController
before_filter :authenticate_user!
before_filter :check_if_user_is_admin!
layout "dashboard"
def show
@user = current_user
end
def grid
if current_user.type == "Customer"
@areas = current_user.events.past.map(&:area).uniq
elsif params[:are... |
class ContaCorrente
attr_accessor :saldo, :mensagem
def initialize (saldo)
self.saldo= saldo
end
def saca(valor)
if (valor > self.saldo)
self.mensagem = 'Saldo insuficiente para saque :('
elsif (valor > 700)
self.mensagem = 'O Limite máximo d... |
require 'spec_helper'
describe 'Country Commercial Guide API V2', type: :request do
include_context 'V2 headers'
before(:all) do
CountryCommercialGuide.recreate_index
CountryCommercialGuideData.new(
"#{Rails.root}/spec/fixtures/country_commercial_guides").import
@all_possible_full_results =
... |
ActiveAdmin.register Report do
index do
column :id
column :name
column :date_from
column :date_to
column do |resource|
links = link_to I18n.t('active_admin.view'), resource_path(resource), :class => "member_link view_link"
links += link_to I18n.t('active_admin.edit'), edit_resource_pa... |
class Node
attr_accessor :value, :right, :left, :parent
def initialize(value = nil, parent = nil, right = nil, left = nil)
@value = value
@right = right
@left = left
@parent = nil
end
end
class BinarySearchTree
attr_accessor :root
def initialize(root = nil)
@root = root
end
def ... |
class User < ActiveRecord::Base
has_one :location, -> { order('id DESC').limit(1) }
def self.from_omniauth(auth)
User.find_or_initialize_by(uid: auth.uid).tap do |u|
u.provider = auth.provider
u.name = auth.info.name
u.email = auth.info.email
u.image = auth.info.image
u.oauth_toke... |
class NvsMigProcess < ActiveRecord::Base
attr_accessible :description, :name, :nvs_action, :nvs_action_sequence, :nvs_main_process, :nvs_mig_status_id, :nvs_process_sequence, :target_env_c, :target_env_p, :target_env_t
as_enum :actiontype, {JCL: 1, KSH: 2, CMD: 3, MAN: 4}, :prefix => 'actiontype'
belongs_to :n... |
# -*- encoding: utf-8 -*-
# stub: unidecoder 1.1.2 ruby lib
Gem::Specification.new do |s|
s.name = "unidecoder".freeze
s.version = "1.1.2"
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
s.require_paths = ["lib".freeze]
s.authors = ["Russell Nor... |
class NodeTypes::PortsController < ApplicationController
layout 'buttoned'
before_action :must_admin!
include NodeTypesHelper
before_action :get_node_type
def new
@port = NtPort.new
@tcp_options = _tcp_items
render 'new'
end
def create
@tcp_options = _tcp_items
@port = NtPort.new p... |
require 'bundler'
Bundler.require(:default, :development)
require 'rubocop/rake_task'
require 'rspec/core/rake_task'
require 'http_server_manager/rake/task_generators'
require_relative 'lib/producer_example/server'
desc "Removes generated artefacts"
task :clobber do
%w{ pkg tmp }.each { |dir| rm_rf dir }
rm Dir.... |
# encoding: UTF-8
# vim: set fdm=marker tw=80 sw=2:
module Linguistics
module Latin
module Verb
module TenseDefinitions
##
#
# Tense-forming methods that do not vary between the verb types
#
##
module Invariant
##
#
# === GRAMMA... |
FactoryBot.define do
factory :person do
name { Faker::Name.name }
email { Faker::Internet.email }
cpf { CPF.generate }
rg { Faker::Number.number(10) }
member false
occupation { Faker::Job.title }
transient do
phones nil
address nil
end
after(:build) do |person, evalua... |
# frozen_string_literal: true
require 'jiji/test/test_configuration'
require 'jiji/test/data_builder'
describe Jiji::Utils::ValueObject do
class ClassA
include Jiji::Utils::ValueObject
attr_writer :string, :number, :object, :array, :hash
def initialize(string, number, object, array, hash)
@stri... |
module DataPalettesHelper
def include_i18n_calendar_javascript
cur_lang = I18n.locale.to_s
loc_path = "#{RAILS_ROOT}/public/javascripts/jquery_datepicker/locale/#{cur_lang}.js"
if File.exist?(loc_path)
content_for :head do
javascript_include_tag "jquery_datepicker/locale/#{cur_lang}.js"
... |
class HomeController < ApplicationController
before_filter :set_return_to, only: [:index]
def index
@events = Event.published.active(Time.zone.now).reverse
if current_user
@active_attended_events = current_user.attended_events.delete_if{ |e| e.start <= Time.zone.now }.sort_by(&:start)
end
end
e... |
def caesar_cipher(string, number)
alphabet = ('a'..'z').to_a
cipher_string = String.new
string.each_char do |char|
if alphabet.include?(char.downcase)
index = alphabet.index(char.downcase)
if char == char.upcase
cipher_string += alphabet.rotate(number)[index].upcase
else
cip... |
require 'spreadsheet'
require './helpers'
require 'csv'
require 'optparse'
def mysql_query(connection,query)
begin
rs = connection.query(query)
rescue Exception => e
raise e
raise e if /Mysql::Error: Duplicate entry/.match(e.to_s)
end
end
options = {}
OptionParser.new do |opts|
opts.on("-f", "... |
class Course < ApplicationRecord
validates :slug, uniqueness: true, presence: true
before_validation :generate_slug
# after_save :update_slug
# user
belongs_to :user
has_many :freeitems, dependent: :destroy
# category
belongs_to :category
def self.search(params)
if params[:search].present? ... |
require 'rails_helper'
RSpec.describe UsersController, type: :controller do
describe "users#new" do
it "renders template new" do
get :new
expect(response).to render_template(:new)
end
it "instantiate @var as a new User" do
get :new
expect(assigns(:user)).to be_a_new(User)
end... |
class AddGroupToMicropost < ActiveRecord::Migration[5.1]
def change
def change
add_column :microposts, :social_group_id, :integer
end
end
end
|
require_relative '../view'
module ExerciseRecords
class New < Fitter::View
def form
form_for :exercise_record, "/exercise_types/#{exercise_type_id}/new_record" do
div class: 'form-group row' do
div class: 'col-sm-2' do
label :date, class: 'col-form-label'
date_fie... |
# RSPEC SNIPPETS (DOES NOT INCLUDE CAPYBARA)
# credit to: https://www.udemy.com/course/testing-ruby-with-rspec
# Initialize RSpect (should create .rspect and spec/rspec_helper.rb)
rspect --init
# Command to run rspect test
rspec spec/card_spec.rb
# describe: group of examples (tests), can have argument or no argument... |
source 'https://rubygems.org'
gem 'rails', '~> 5.0.0', '>= 5.0.0.1'
gem 'puma', '~> 3.0'
gem 'pg', group: :production # Heroku deploy
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.2'
gem 'jquery-rails'
gem 'jbuilder', '~> 2.5'
# A set of Rails responders to dry up your application
gem 'responders', '~> 2.3' # ... |
require 'sinatra/base'
require 'rest_client'
require 'uuidtools'
module Sinatra
# A Sinatra module to seamlessly integrate OpenCaptcha
# to Sinatra applications.
# See: http://www.opencaptcha.com
#
module OpenCaptcha
@@default_opts = {
:width => 110,
:height => 50,
... |
require 'rails_helper'
describe 'Dashboard API' do
describe 'PUT /api/v1/dashboards/:id/' do
let!(:city) { create(:city) }
let!(:dashboard) { create(:dashboard ) }
let!(:dashboard_city) { create(:dashboard_city, dashboard: dashboard, city: city) }
it 'returns 304 status code' do
put "/api/v1/... |
require 'spec_helper'
describe Api::FacebookPay::StudiosController do
def stub_request_facebook_graph_info_to_include(data)
controller.stub_chain(:facebook, :data).and_return(data)
end
def set_request_order_info_for_credits_data_to(order_json)
@credits_data['credits']['order_info'] = order_json
end... |
require 'hoze/source_factory'
module Hoze
def self.worker
Hoze::Worker.new
end
class Worker
attr_accessor :source_factory
def initialize
@source_config = Hoze::Configuration.new
@source_factory = Hoze::SourceFactory.new
end
def listen_to &block
yield @source_config
... |
class FixTypeColumn < ActiveRecord::Migration
def up
rename_column :resources, :type, :medium
end
def down
end
end
|
class CommentsController < ApplicationController
before_filter :require_sign_in
def notify
href = params[:href]
params[:comment_id]
params[:parent_comment_id]
message = params[:message]
notify_user = nil
item = nil
if href =~ /\/rankings\/(\d+)$/
ranking_id = $1
it... |
require 'spec_helper'
describe MessagesController do
describe "trying to access protected resources when not logged in" do
it "should not give access to inbox" do
get :inbox, :format => :json
response.response_code.should == 403
end
end
describe "accessing messages as a signed in user" do... |
require 'theater_dates'
class Screening < ApplicationRecord
belongs_to :movie
scope :week, ->(weeks_from_now = 0) {
where(date: TheaterDates.week(weeks_from_now))
}
scope :current_week, ->{ week() }
scope :next_week, ->{ week(+1) }
end
|
class CreateEmployeeLeaveBalances < ActiveRecord::Migration
def self.up
create_table :employee_leave_balances do |t|
t.references :employee
t.references :employee_leave_type
t.decimal :leave_balance ,:precision => 5, :scale => 1, :default => 0
t.date :reset_date
t.decimal ... |
class Board
DEFAULT_DIMENSION=4
def initialize (x = DEFAULT_DIMENSION, y = DEFAULT_DIMENSION)
x < 0 ? @x_border = DEFAULT_DIMENSION : @x_border = x
y < 0 ? @y_border = DEFAULT_DIMENSION : @y_border = y
end
def x_border
@x_border
end
def x_border=(new_x_border)
@x_border = new_x_border
... |
module Jsonapi
class BaseController < ActionController::Base
before_action :set_current_user
# TODO: Add before_action :authenticate_request to any places we intend to authenticate
helper_method :current_user
attr_reader :current_user
def authenticate_request
return if @current_user
... |
# frozen_string_literal: true
# rubocop:disable Naming/ConstantName
# rubocop:disable Style/MutableConstant
module Dry
module Monads
to_list = List::Validated.method(:pure)
id = -> x { x }
# List of default traverse functions for types.
# It is implicitly used by List#traverse for
# making com... |
require_relative "./consola"
require_relative "./chequeador"
require_relative "./tablero"
require_relative "./constantes"
class Controlador
include Constantes
TURNO_INICIAL = 1
FILA = 0
COLUMNA = 1
def initialize()
@victoria = false
end
def jugar()
juego = Tablero.new
consola ... |
module Susanoo
module Accessibility
class Alt < Base
def validate(doc)
selector = settings.target.css
doc.css("#{selector} img").each_with_index do |e, i|
alt = e['alt']
if alt.blank? || alt.gsub(/(\s| )+/, '').length == 0
error('E_2_1', e)
elsif alt... |
# frozen_string_literal: true
class HomeMaintenance
# Given a task, figure out if it what whether it's in a given time frame
class TimeFramer
# name => [day, month]
SEASON_START_MAP = {
spring: [20, 3],
summer: [20, 6],
fall: [22, 9],
winter: [21, 12]
}.freeze
def initializ... |
require_relative "../repository"
require_relative "../models/invoice_item"
class InvoiceItemRepository < Repository
def file_name
"invoice_items.csv"
end
def model
InvoiceItem
end
def find_by_id(id)
indices["id"][id].first
end
def find_by_item_id(id)
indices["item_id"][id].first
end
... |
require "spec_helper"
describe MoviesController do
describe "show" do
it "should retrieve movie ID from URI route" do
post :show, {:id => 1}
end
it "should call the method which performs movie search by id" do
end
it "should select show template for rendering" do
end
i... |
require 'application_system_test_case'
class CreatePlaybackTest < ApplicationSystemTestCase
setup do
@user = create(:user)
end
test 'create playback' do
visit new_playback_path
sign_in
fill_in(:playback_organisation_name, with: 'ACME')
fill_in(:playback_email, with: 'test@wearecast.co.uk')
... |
class UsernameFormatValidator < ActiveModel::EachValidator
def validate_each(object, attribute, value)
# Check to see if it has one character
if value == nil
object.errors[attribute] << (options[:message] || "must not be blank.")
else
unless value =~ /[a-zA-Z]/
object.errors[att... |
module WebiniusCms
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception, prepend: true
before_action :set_locale
def set_locale
if params[:locale].present?
lang = Language.where(code: params[:locale]).first
I18n.locale = lang.present? ? params[... |
require 'spec_helper'
describe ApplicationHelper do
describe '#nav_link' do
it 'has the "selected" class if the passed-in key matches @nav_highlight' do
@nav_highlight = "bender"
link = helper.nav_link("Bite", "/my/shiny/metal", key: "bender")
link.should match /selected/
end
it "doesn... |
require './lib/docking_station'
describe DockingStation do
let(:station){DockingStation.new(:capacity => 123)}
let(:bike){Bike.new}
let(:van){Van.new}
it "should allow setting default capacity on initialising" do
expect(station.capacity).to eq(123)
end
it "should accept working bikes from a van" do
van.d... |
class TransactionsController < ApplicationController
def index
@transactions = Transaction.all
respond_to do |format|
format.json { render json: { transactions: @transactions }, status: :ok }
format.html
end
end
def show
respond_to do |format|
begin
@transaction = Transa... |
class Review < ActiveRecord::Base
attr_accessible :rating, :restaurant_id, :user_id, :text
validates_presence_of :user, :restaurant, :rating, :text
belongs_to :restaurant
belongs_to :user
end
|
ActiveAdmin.register ReportingRelationship, as: 'Client Relationships' do
menu priority: 3, label: 'Clients'
permit_params :first_name, :last_name, :phone_number, :notes, :active, :client_status_id, user_ids: []
index do
selectable_column
column :full_name, sortable: 'clients.last_name' do |rr|
rr... |
class MonthlyFInvestment < ActiveRecord::Base
attr_accessible :investment_amount, :is_active, :is_deleted, :m_director_id, :partner_id,
:invested_in
belongs_to :m_director
belongs_to :partner
has_many :transactions
has_many :mi_transactions
has_many :df_transactions
has_many :di_transactions
... |
# frozen_string_literal: false
# Where players and bots choose their options
module GameInput
VALID_COLORS = %w[R G O B M C].freeze
def request(force, message, empty_input_msg = nil)
puts message
response = gets.chomp
while force && response.empty?
puts empty_input_msg
response = gets.chomp... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.