text stringlengths 10 2.61M |
|---|
class FontJimNightshade < Formula
head "https://github.com/google/fonts/raw/main/ofl/jimnightshade/JimNightshade-Regular.ttf", verified: "github.com/google/fonts/"
desc "Jim Nightshade"
homepage "https://fonts.google.com/specimen/Jim+Nightshade"
def install
(share/"fonts").install "JimNightshade-Regular.ttf... |
require 'rails_helper'
RSpec.describe FacilitiesManagement::Admin::SuppliersFrameworkDataController do
login_fm_admin
describe 'GET #index' do
it 'returns http success' do
get :index
expect(response).to have_http_status(:ok)
end
context 'when not an fm admin' do
login_fm_buyer
... |
class AudioFile < ActiveRecord::Base
self.table_name = 'audio_files'
belongs_to :qari, primary_key: :qari_id
belongs_to :surah, foreign_key: :sura_number
end
|
require 'csv'
class DocumentExport < ActiveRecord::Base
EXPORT_TYPES = %w[csv]
belongs_to :repository
validates :repository, presence: true
validates :export_type, presence: true, inclusion: EXPORT_TYPES
def export
documents = repository.documents
if filtered_ids.present? && filtered_ids.any?
... |
require_relative 'boot'
require 'rails/all'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
module GraphTest
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails... |
# frozen_string_literal: true
require 'rails_helper'
RSpec.feature 'Subscriptions', type: :feature do
let(:customer) do
Stripe::Customer.create(
source: {
object: 'card',
number: '4242424242424242',
exp_month: Time.now.month,
exp_year: Time.now.year + 1,
cvc: '123'
... |
class Score
# Take a list of ids (a cluster) and assign a score based on how much their values have in common.
# Examples in comments below.
@@debug = false;
def Score.set_debug (bool)
@@debug = bool;
end
def Score.cluster (ids, doc_attr_vals)
# Assume in this example that:
# * ids is a... |
module Argyle
class Engine < ::Rails::Engine
initializer 'argyle.helper' do
ActionView::Base.send :include, ArgyleHelper
end
config.generators do |g|
g.test_framework :rspec
end
end
end
|
require "fog/core/collection"
require "fog/brkt/models/compute/load_balancer_template_listener"
module Fog
module Compute
class Brkt
class LoadBalancerTemplateListeners < Fog::Collection
model Fog::Compute::Brkt::LoadBalancerTemplateListener
# @return [LoadBalancerTemplate]
attr_ac... |
module Process::Naf::DataMigration
class BackfillApplicationScheduleRunInterval < ::Process::Naf::Application
opt :update, 'update run interval styles id'
opt :rollback, 'rollback changes'
opt_select :update_or_rollback, one_of: [:update, :rollback]
attr_reader :run_interval_styles
def work
... |
class SubServiceRequest < ActiveRecord::Base
include SparcShard
has_one :protocol
has_one :subsidy, :dependent => :destroy
belongs_to :owner, class_name: 'Identity'
belongs_to :organization
belongs_to :service_request
delegate :service_requester, to: :service_request
end
|
# A method named `binary_to_decimal` that receives as input an array of size 8.
# The array is randomly filled with 0’s and 1’s.
# The most significant bit is at index 0.
# The least significant bit is at index 7.
# Calculate and return the decimal value for this binary number using
# the algorithm you devised in clas... |
class Property < ApplicationRecord
validates :name, :color_set_id, :buy_price, presence: true
belongs_to :color_set
def is_property?
true
end
def deed_for(game)
game.deeds.find_by(property_id: id)
end
end
|
require_relative '../acceptance_helper'
feature 'Questions list' do
given(:question) { create(:question) }
it 'User can see a list of questions' do
question
visit questions_path
expect(page).to have_link question.title
end
end
|
class VenuesController < ApplicationController
before_action :admin_user, only: [:index, :new, :edit, :update, :destroy]
before_action :set_venue, only: [:show, :edit, :update, :destroy]
def search
if !params['venue_name'].nil? && params['venue_name'].length > 0
# search is coming from the 'name' s... |
class StuffedAnimals
attr_reader :type, :color,
def initialize(attributes_hash)
@type = attributes_hash[:type]
@color = attributes_hash[:color]
@price = attributes_hash[:price]
end
end
pig = StuffedAnimals.new({type: "pig", color: "white and pink", price: 50})
p pig.type
p pig.color
p pig.price |
class CreateDishesIngredients < ActiveRecord::Migration[6.0]
def change
create_table :dishes_ingredients do |t|
t.belongs_to :user_dish, foreign_key: true
t.belongs_to :ingredient, foreign_key: true
end
end
end
|
class Film < ActiveRecord::Base
has_many :locations
has_many :characters
has_many :species, through: :characters
def print_film
puts " * Title: #{self.title}"
puts " * Description: #{self.description}"
puts " * Director: #{self.director}"
puts " * Producer: #{self.produc... |
=begin
#qTest Manager API Version 8.6 - 9.1
#qTest Manager API Version 8.6 - 9.1
OpenAPI spec version: 8.6 - 9.1
Generated by: https://github.com/swagger-api/swagger-codegen.git
=end
require "uri"
module SwaggerClient
class AutomationjobApi
attr_accessor :api_client
def initialize(api_... |
class CreateFacilityDivisionData < ActiveRecord::Migration[5.2]
def change
create_table :facility_division_data do |t|
t.integer :division_id
t.integer :detail
t.integer :major
t.timestamps
end
end
end
|
require 'spec_helper'
describe OnTheWay::Point do
include Rack::Test::Methods
describe "a new point" do
subject { described_class.new(params) }
let (:params) { 'locator' }
it "responds to latitude, longitude" do
Geocoder.stub(:search) do
foo = OpenStruct.new({data: {'geometry' => {'lo... |
# frozen_string_literal: true
require 'timeout'
require_relative 'openshift_kind'
require_relative 'replication_controller'
module RbShift
# Representation of OpenShift deployment config
class DeploymentConfig < OpenshiftKind
def scale(replicas, block: false, timeout: 60, polling: 5)
log.info "Scaling ... |
# frozen_string_literal: true
module ANSIColor
ESCAPE = "\e["
RESET = '0m'
CODES = {
black: '30',
red: '31',
green: '32',
yellow: '33',
blue: '34',
magenta: '35',
cyan: '36'
}.freeze
CODES.each do |color, code|
define_method(color) do |string, bold: false|
attributes = ... |
class MangaSerializer < ActiveModel::Serializer
attributes :id, :name, :image_url, :synopsis, :score, :date_start, :date_end, :listed
has_many :genres
has_many :reviews
end |
RSpec.configure do |config|
if LOLITA_ORM == :active_record
config.use_transactional_fixtures = false
end
DatabaseCleaner.strategy = :truncation
config.around(:each) do |example|
DatabaseCleaner.start
example.run
DatabaseCleaner.clean
end
end
|
# using a pattern of an initializer calling a library file explained here
# http://www.strictlyuntyped.com/2008/06/rails-where-to-put-other-files.html
require 'monkey_patches/ar_schema_dumper_table'
require 'monkey_patches/ar_base_extensions' |
class CreateSheetData < ActiveRecord::Migration[5.1]
def change
create_table :sheet_data do |t|
t.string :sheet_name
t.integer :last_processed_index
t.timestamps
end
end
end
|
class Post
include Mongoid::Document
## Fields
field :title, type: String
## Associations
belongs_to :user
has_many :contents, dependent: :delete
end
|
class Good < ActiveRecord::Base
require 'digest/md5'
include ModelParanoia
# associations
has_many :items, dependent: :destroy
belongs_to :nutrition
belongs_to :recipe
# validations
validates :good_type_id, presence: true
validates :good_subtype_id, presence: true,
if: "good_type_id == 2 || good... |
class KlassSerializer < ActiveModel::Serializer
attributes :id, :name, :subject
end
|
class RemoveArtistFromPosts < ActiveRecord::Migration
def change
remove_column :posts, :artist, :string
end
end
|
module ApplicationHelper
def current_user_owns?(project)
return false unless user_signed_in?
current_user.owns?(project)
end
def title
key = "#{params[:controller].underscore.gsub('/', '.')}.#{params[:action]}"
case key
when "projects.show", "pages.show"
@project.title
else
t... |
class AddMovieRefToStreams < ActiveRecord::Migration
def change
add_reference :streams, :movie, index: true
end
end
|
require "xml/builder/version"
module Xml
module Builder
# Your code goes here...
def method_missing(name, *args, &block)
define_singleton_method(name) do |*as, &bs|
@_str ||= ''
@_str += "<#{name}"
args = as[0]
args.each do |k, v|
@_str += " #{k}=\"#{v}\""
... |
class QAQuiz
attr_accessor :questions_answers, :dictionary_file, :questions_file, :answers_file
def initialize
@questions_answers = Hash.new{|h,k| h[k] = []}
end
def process
@dictionary_file = File.open(ARGV.shift, "r")
@questions_file = File.open("#{Dir.pwd}/questions.txt","w")
@answers_file ... |
class ChangeRequestConfirmedToString < ActiveRecord::Migration
def change
change_column :requests, :confirmed, :string
end
end
|
module Api
class AlbumsController < ApiController
def index
@albums = current_user.albums.joins(:photos).group('albums.id').having('count(*) > 0')
end
def create
@album = current_user.albums.new(album_params)
if @album.save
render json: @album
else
render json: @... |
require File.expand_path('../boot', __FILE__)
require 'rails/all'
Bundler.require(:default, Rails.env) if defined?(Bundler)
RAILS_ROOT = ::Rails.root.to_s
RAILS_ENV = ::Rails.env
module Mamashai
class Application < Rails::Application
config.autoload_paths += [config.root.join('lib')]
config.encoding = 'ut... |
require "pry"
class Backer
attr_reader :name, :backer
@@all = []
def initialize(name)
@name = name
end
def self.all
@@all
end
def back_project(project)
ProjectBacker.new(project, self)
end
def backed_projects
b_projects = ProjectBacker.all.select {|... |
Rails.application.routes.draw do
# resources :shopping_carts
devise_for :users, controllers: { registrations: 'registrations' }
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
root 'admin/produtos#index'
namespace :admin do
resources :users
resource... |
# To use an static method in an ruby is very simple, its only use `self.<method-name>` see:
class Printer
def self.regular_print
"Pipp.. An regular print.."
end
end
puts Printer.regular_print |
# require 'test_helper'
# class UpdateTicketTest < ActiveSupport::TestCase
#
# setup do
# @existing_ticket = create(:ticket_customer).as_json.symbolize_keys!.merge(title: 'New Name')
# end
#
# teardown do
# Ticket.destroy_all
# end
#
# test 'Update Ticket interactor exists' do
# class_exists?(Upda... |
# frozen_string_literal: true
module Might
# Sort scope using ransack gem
#
class SortMiddleware
# @param app [#call]
#
def initialize(app)
@app = app
end
attr_reader :app
# @param [Array(ActiveRecord::Relation, Hash)] env
# First argument is a ActiveRecord relation which must ... |
module FipeApi
class Ano
include ObjetoComConstrutor
attr_accessor :id_marca, :id_modelo, :tipo_do_veiculo, :nome, :codigo
def initialize(tipo_do_veiculo, id_marca, id_modelo, opts = {})
self.tipo_do_veiculo = tipo_do_veiculo
self.id_marca = id_marca
self.id_modelo = id_modelo
s... |
class RegistrationPage < GenericBasePage
include DataHelper
#class HeaderPage < GenericBasePage
element(:registrationValidation) {|b| b.link(xpath: "//li[@id='registration_registration_validation_registration_validations_path']/a")}
element(:forcedRegistrations) {|b| b.link(xpath: "//li[@id='registration_force... |
module BackpackTF
module Price
# Access the IGetPrices interface
class Interface < BackpackTF::Interface
class << self
attr_reader :raw, :since
end
@name = :IGetPrices
@version = 4
def self.defaults(options)
@raw = options[:raw] || nil
@since = options[:... |
#!/usr/bin/env ruby
# encoding: utf-8
# SeqTrimBB: Next generation sequencing preprocessor
# Copyright (C) <2017>
# Authors: Rafael Nuñez Serrano, Diego Dario Guerrero
# Fernandez
# email: soporte@scbi.uma.es - http://www.scbi.uma.es
#####################################################... |
require 'gosu'
# throws exceptions to current thread even different thread has that exception
Thread.abort_on_exception = true
Thread.report_on_exception = false
# define contants
WINDOW_WIDTH = 1100
WINDOW_HEIGHT = 650
DEFAULT_FONT = 'Arial'
# constants in multiplayer part
VIEW_BOARD_MARGIN = 20 # other player... |
class OrderHasMealsController < ApplicationController
before_action :set_current_order
def destroy
@order_has_meal.destroy
redirect_to order_path
end
def update
@order_has_meal = OrderHasMeal.find_by(meal_id: @meal_id, order_id: @order_id)
@order_has_meal.quantity = :quantity
if @order_has_meal.save
... |
class Post < ApplicationRecord
belongs_to :user
has_many :comments, -> { ordering }, dependent: :destroy
has_many :likes, -> { ordering }, dependent: :destroy
scope :ordering, -> { order(created_at: :desc) }
scope :full, -> { includes(:user, :likes) }
validates :title, presence: true, length: {in: 2..255}... |
Rails.application.routes.draw do
root 'main#home'
get '/todo/:id' => 'main#show'
get '/error/:error' => 'main#error'
get '*unmatched_route', to: 'main#not_found'
delete '/todo/:id' => 'main#delete'
post '/' => 'main#add'
# For details on the DSL available within this file, see http://guides.rubyonrails.o... |
class Admin::UsersController <ApplicationController
before_filter :is_admin?
#getting form for creating new user in admin/users/new.html.erb. Instance object before saving.
def new
@user = User.new
end
def show
@user = User.find(params[:id])
end
def create
@user = User.new(admin_user_params)
if @user.save
... |
class Course < ActiveRecord::Base
belongs_to :profile
has_many :assignments
end
|
require 'chat-adapter'
class HerokuSlackAdapter < ChatAdapter::Slack
def initialize(options)
super(nick: options.fetch(:nick),
webhook_token: ENV['SLACK_WEBHOOK_TOKEN'],
api_token: ENV['SLACK_API_TOKEN'],
icon_emoji: options.fetch(:icon_emoji))
end
end |
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :comment do
transient do
body "Yo."
user_login "myusername"
commit nil
end
sequence(:github_id)
sequence(:commit_sha) { |n| commit ? commit.sha : "aaf#{n}" }
author { build(:auth... |
# Let's call a method, and pass both a string and an array as
# parameters and see how even though they are treated int
# he same way by Ruby, the results can be different.
# Study the following code and state what will be printed...and why:
def tricky_method(a_string_param, an_array_param)
a_string_param += "rutab... |
describe TabularData::ContainerConfig do
describe "#settings" do
it "returns config for client" do
stub_const("TabularData::ContainerConfig::CONFIG_FILE_PATH", "#{Rails.root}/spec/support/fixtures/")
config = TabularData::ContainerConfig.new("container_config", "generic_client").settings
expect... |
require '../lib/magic_server'
require 'test/unit'
class ServerTest < Test::Unit::TestCase
def test_parse_heading
heading = "erbtest?boo=hello\n"
method = 'GET'
parsed_heading = MagicServer::parse_heading(heading,method)
assert_equal parsed_heading[:route], 'erbtest'
assert_equal parse... |
desc 'Generate new packs for any users that need them'
task :generate_packs do
User.needs_new_pack.find_each do |user|
Packs::Generate.call(user: user)
end
end
|
class UsersController < ApplicationController
before_filter :authenticate_user!
before_filter :check_access_control
access_control :allow_access?, :filter => false do
allow "Managers"
allow "Instructional Designers"
end
def index
@users = current_user.organization.users.find(:all)
end
... |
class ToDo < ApplicationRecord
before_save :update_complete
validates :text, presence: true
private
def update_complete
self.completed_date = self.complete ? Date.today : nil
end
end
|
# frozen_string_literal: true
require 'rails_helper'
RSpec.feature 'Property Management', js: true do
let!(:contact1) { FactoryBot.create(:contact) }
let!(:contact2) { FactoryBot.create(:contact) }
let!(:property) { FactoryBot.build(:property, owner: contact2) }
let!(:existing_property) { FactoryBot.create(:p... |
require 'openssl'
require 'sidekiq'
module Endpoints
class Dropbox < Base
get '/dropbox/hook' do
params[:challenge]
end
post '/dropbox/hook' do
body = request.body.read
signature = request.env['HTTP_X_DROPBOX_SIGNATURE']
request_id = request.env['REQUEST_ID']
if signature ... |
# frozen_string_literal: true
## --- BEGIN LICENSE BLOCK ---
# Original work Copyright (c) 2015-present the fastlane authors
# Modified work Copyright 2016-present WeWantToKnow AS
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the... |
class DealStepTypesController < ApplicationController
# GET /deal_step_types
# GET /deal_step_types.xml
def index
@deal_step_types = DealStepType.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @deal_step_types }
end
end
# GET /deal_step_types/1
... |
class Share < ActiveRecord::Base
belongs_to :user
belongs_to :like, :counter_cache => true
belongs_to :clip, :counter_cache => true
belongs_to :quote, :counter_cache => true
scope :popular_clips, where("clip_id IS NOT NULL")
end
|
module Api
class ResumeController < ApplicationController
def show
@resume = Resume.includes(
:resume_educations,
:resume_positions,
:resume_projects,
{resume_projects: :project_source},
).first
respond_to do |format|
format.json { render json: @resume.to_... |
# encoding: utf-8
source 'https://rubygems.org'
ruby '2.2.3'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.4'
# Use sqlite3 as the database for Active Record
gem 'pg'
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use Coff... |
# frozen_string_literal: true
require './app/null_objects/guest'
require 'rails_helper'
describe NullObjects::Guest do
context '#name' do
it 'returns Guest' do
guest = NullObjects::Guest.new
expect(guest.name).to eq('Guest')
end
end
end
|
class SubjectCompetenciesController < ApplicationController
# GET /subject_competencies
# GET /subject_competencies.json
def index
@subject_competencies = SubjectCompetency.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @subject_competencies }
end
end... |
require 'pry'
class Api::BackgroundsController < ApplicationController
def index
background = Background.all
render json: background
end
def create
# binding.pry
background = Background.new(background_params)
if background.save
render json: background
else
render json: { err... |
class Pangram
VERSION = 1
def self.is_pangram?(str)
str.downcase.chars.uniq.map { |c| ('a'..'z').include?(c) ? c : nil }.compact.count == 26
end
end
|
# The main class for the WalkMyDog apply route
# rubocop:disable ClassLength
class KWApi < Sinatra::Base
# This happens if a user applies as a dogwalker
post '/walkmydog/users/apply/?' do
if params[:payload].nil?
apply_error_json_hash = {
message: 'The JSON payload is missing some elements which m... |
module Api::V1
class Customers::PaymentsController < ApiController
include Serializable
skip_before_action :disable_access_by_tk, only: [:received, :update, :add_card_mobile]
def index
ccs = current_user.credit_cards.not_deleted
set_response(200, 'Tarjetas Listadas', serialize_payment(ccs))
... |
class CreateJoinTableEventAttrUser < ActiveRecord::Migration[5.2]
def change
create_join_table :event_attrs, :users do |t|
t.index [:event_attr_id, :user_id], unique: true
# t.index [:user_id, :event_attr_id]
end
end
end
|
class TimeCardController < ApplicationController
layout 'time_card'
skip_before_action :authenticate_user!
def new
# sub_domain = request.domain.scan(/\w+/)[0]
@gym = Gym.find_by(subdomain: params[:gym])
@employees = @gym.users.where(employee: true).order(last_name: :asc)
@clients = @gym.users.whe... |
require "spec_helper"
RSpec.describe "Day 3: Crossed Wires" do
let(:runner) { Runner.new("2019/03") }
describe "Part One" do
it "finds the closest intersection" do
expect(runner.execute!(<<~TXT, part: 1)).to eq(6)
R8,U5,L5,D3
U7,R6,D4,L4
TXT
expect(runner.execute!(<<~TXT, par... |
class Bill < ActiveRecord::Base
STATUSES = %w(payed unpayed)
PAYMENT_STATUSES = %w(payed overdue due_soon due_later)
BILL_TYPES = %w(parking_ticket water_bill vehicle_ticket)
validates_inclusion_of :payment_status, in: PAYMENT_STATUSES
validates_inclusion_of :status, in: STATUSES
validates_inclusion_of :b... |
require File.dirname(__FILE__) + '/../../lib/dvorak'
require 'fileutils'
require 'pdf/reader'
require 'pry'
Given(/^I create a new deck named "(.*?)"$/) do |deck_name|
@deck_name = deck_name
Dvorak::CLI.source_root(File.expand_path('../../../templates', __FILE__))
FileUtils.rm_r(@deck_name) if Dir.exist?(@deck_n... |
# Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.
class ApplicationController < ActionController::Base
helper :all # include all helpers, all the time
protect_from_forgery # See ActionController::RequestForgeryPr... |
# encoding: UTF-8
module Providers
class Zenitbet < Base
module Snooker
def parse(page)
page.search("div.b-league[id^=lid]").each do |league_node|
title_node = league_node.at('div.b-league-name span.b-league-name-label')
sport_name, league_name = title_node.content.split(/\.\s*/... |
class AddContractIdToRider < ActiveRecord::Migration
def change
add_column :riders, :contract_id, :integer
add_column :riders, :master_rider_id, :integer
end
end
|
require 'rails_helper'
include AdminHelpers
RSpec.feature 'Deleting performance' do
before do
@hr = create(:hr)
assign_permission(@hr, :read, Performance)
assign_permission(@hr, :destroy, Performance)
login_as(@hr, scope: :hr)
@performance = create(:performance)
visit admin_employee_performan... |
require_relative './bakery_service'
module Service
class Cashier < BakeryService
attr_accessor :total
def initialize(cart)
@cart = cart
@total = 0.00
end
def call
# Print out label for orders
puts "\nORDERS:"
# Loop through the orders on the cart
@cart.orders.ea... |
require 'rubygems'
require 'bundler/setup'
require 'yaml'
require 'fileutils'
require 'haml'
require 'tilt'
Tilt.register Tilt::HamlTemplate, 'hatl'
DIRECTORIES = []
DIRECTORIES << RSWG_DIR = "./.rswg"
DIRECTORIES << SITE_DIR = File.join(RSWG_DIR, "site")
DIRECTORIES << SOURCE_DIR = "./src"
DIRECT... |
class UserInput < SimpleForm::Inputs::Base
enable :placeholder
def input
input_html_options['data-source'] = '/mdb/users.json' # mdb_users_path(format: :json)
add_on = '<span class="add-on"><i class="icon-user"></i></span>'
control = "#{add_on}#{@builder.text_field(attribute_name, input_html_opt... |
#!/usr/bin/env ruby -S rspec
require 'spec_helper'
require 'semantic_puppet'
require 'puppet/pops/lookup/context'
require 'yaml'
require 'fileutils'
puppetver = SemanticPuppet::Version.parse(Puppet.version)
requiredver = SemanticPuppet::Version.parse("4.10.0")
describe 'lookup' do
# Generate a fake module with dum... |
# frozen_string_literal = true
class OperationPolicy
ALL = 'all'
attr_reader :model, :model_names
def initialize(model, model_names = [])
@model = model
@model_names = model_names
end
def valid_model?
model.underscore.in?(model_names)
end
def all_model?
model == ALL
end
end
|
class CarsController < ApplicationController
include ApplicationHelper
before_action :set_car, only: [:show, :edit, :update, :destroy]
# GET /cars
# GET /cars.json
def index
@cars = Car.all
end
# GET /cars/1
# GET /cars/1.json
def show
end
# GET /cars/new
def new
@car = Car.new
end... |
# frozen_string_literal: true
# this is the model
# that takes care of all actions related to teams table
class Team < ApplicationRecord
validates :name, presence: true, uniqueness: true
before_create :add_abbreviation_from_name!
has_one :manager, dependent: :destroy
accepts_nested_attributes_for :manager
h... |
class Skill < ActiveRecord::Base
belongs_to :skill_proficiency
end
|
module Oshpark
module Stateful
def self.included base
base.const_get(:STATES).each do |_state|
define_method "#{_state.downcase}?" do
state == _state
end
end
end
end
end
|
require 'rails_helper'
require 'csv'
RSpec.describe 'import' do
describe 'file parser' do
let(:raw_text) { file_fixture('test.txt').read }
let(:date) { raw_text[1..8] }
it 'should read the file' do
expect(raw_text[1..8]).to eq('20160403')
end
it 'should parse the correct year' do
exp... |
# frozen_string_literal: true
class WeekTime < WeekdayTime
class << self
def on(day, hour)
new(day * 24 * 60 + hour * 60)
end
end
def hour
super % 24
end
def weekday_index
total_minutes / (60 * 24) % 7
end
end
|
class AddLevelToEventVolunteer < ActiveRecord::Migration
def change
add_column :event_volunteers, :level, :integer
end
end
|
FactoryBot.define do
factory :post do
association :user
title { 'これはテストです' }
budget_id { 1 }
prefecture_id { 1 }
transportation_id { 1 }
explain { 'これは説明文です' }
place { 'これは場所の説明です' }
after(:build) do |post|
post.image.attach(io: File.open('public/images/test_image.png'), filename... |
class AddTellToNumber < ActiveRecord::Migration[5.2]
def change
add_column :numbers, :tell, :string
end
end
|
#
# on/off code for GPIO.
#
ON = 1
OFF = 0
MASTER_POWER_GPIO_PIN = 7
class Circuit < ActiveRecord::Base
# before_update CircuitCallbacks.new
# after_update CircuitCallbacks.new
has_many :sprinkles
# short hand for "EventManager.singleton.event_logger"
def logger
EventManager.singleton.event_logger
e... |
class Sign < ApplicationRecord
validates :nome, presence: true
mount_uploader :imagem, ImageUploader
end
|
Pod::Spec.new do |s|
s.name = 'GMGridView-CSFork'
s.version = '0.0.1'
s.platform = :ios
s.license = 'Apache License, Version 2.0'
s.homepage = 'https://github.com/111minutes/GMGridView-CSFork'
s.author = 'CrowdSyncTeam'
s.source = { :git => 'git://github.com/111minutes/GMGridView-CSFork.git' ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.