text stringlengths 10 2.61M |
|---|
# This will guess the User class
FactoryBot.define do
factory :thermostat do
household_token { Faker::Lorem.characters(14) }
location { Faker::Address.full_address }
uuid { SecureRandom.uuid }
end
end
|
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
require 'readline'
require './src/monsters'
require './src/techniques'
def get_random_monster
return ALL_MONSTERS[rand(ALL_MONSTERS.size)]
end
def one_turn(master, enemy, technique_ind=nil, io=$stdout)
technique = master.techniques[technique_ind]
if master.attackable... |
class Autotile
attr_reader :render, :position
attr_accessor :tiles
#--------------------------------------------------------------------------------------------------------------------------------
# NEW
#-----------------------------------------------------------------------------------------------------------... |
# Attributes:
# * id [integer, primary, not null, limit=4] - primary key
# * created_at [datetime, not null] - creation time
# * description [text] - TODO: document me
# * title [string]
# * updated_at [datetime, not null] - last update time
# * winery_id [integer, limit=4] - belongs to Winery
class InfoItem < ActiveRe... |
class Admin < ActiveRecord::Base
# csv lib
require 'csv'
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable, :recoverable, :rememberable, :registerable,
devise :database_authenticatable,:trackable, :validatable
has_many :work_certificates
... |
class LoginController < ApplicationController
def logout
session.clear
flash[:notification] = ["Logged out"]
redirect_to "/"
end
def create
@user = User.find_by(username: params[:username])
if @user && @user.authenticate(params[:password])
session[:user_... |
# frozen_string_literal: true
module PdfFill
module Forms
class Va281900 < FormBase
include FormHelper
ITERATOR = PdfFill::HashConverter::ITERATOR
KEY = {
'veteran_information' => {
'full_name' => {
'first' => {
key: 'VBA281900[0].#subform[0].Vetera... |
# frozen_string_literal: true
require 'integration/spec_helper'
describe Bosh::AzureCloud::Cloud do
before(:all) do
@additional_resource_group_name = ENV.fetch('BOSH_AZURE_ADDITIONAL_RESOURCE_GROUP_NAME')
end
let(:network_spec) do
{
'network_a' => {
'type' => 'dynamic',
'cloud_pro... |
class Quession < ActiveRecord::Base
belongs_to :lession
# has_many :sentences, dependent: :destroy
validates :lession, presence: true
validates :content, presence: true
has_many :answers , dependent: :destroy
accepts_nested_attributes_for :answers, allow_destroy: true
# validates_associated :answers
v... |
class SimpleJsonapi::Definition::ErrorSource < SimpleJsonapi::Definition::Base
# @visibility private
attr_reader :member_definitions
def initialize(&block)
super
@member_definitions = {}
instance_eval(&block) if block_given?
end
private def initialize_dup(new_def)
super
new_def.instance_... |
# frozen_string_literal: true
FactoryBot.define do
factory :organization do
name { Faker::Lorem.words(3).join }
end
end
|
start = Time.now
input = File.read("input").split("\n\n")
rules = input.shift.split("\n").map{ |r|
c = r.match(/^(\d+): (.*)$/).captures
w = c.last.match(/"([\w])"/)
w ? [c.first.to_i, w.captures.first] : [c.first.to_i, c.last.split(' | ').map{ |a| a.split(' ').map(&:to_i) } ]
}.to_h
messages = input.shift.spli... |
# == Schema Information
#
# Table name: favorites
#
# id :integer not null, primary key
# author_id :integer
# project_id :integer
# created_at :datetime not null
# updated_at :datetime not null
#
class Favorite < ApplicationRecord
belongs_to :author,
class_name: 'User',
... |
class SignUpPage < BasePage
SIGN_UP_FORM ||= {:css => "form[action$='/saveprofile']"}
USERNAME_FIELD ||= {:name => 'uid'}
PASSWORD_FIELD ||= {:name => 'pw'}
CREATE_ACCT_BUTTON ||= {:css => "[value='Create account']"}
SUCCESS_MESSAGE ||= {:css => '.message'}
def initialize(driver)
super
@driver =... |
class CreateRestaurantFoodTypes < ActiveRecord::Migration[5.1]
def change
create_table :restaurant_food_types do |t|
t.belongs_to :restaurant, null: false
t.belongs_to :food_type, null: false
t.timestamps
end
end
end
|
class Category < ApplicationRecord
include SharedFunctions
has_many :workouts
belongs_to :gym
validates :name, presence: true
enum style_tags: { 1 => { 'background-color' => 'bg-light', 'border' => 'border-light', 'text-color' => 'text-light',
'thead-color' => 'bg-light', 'style' ... |
# my_min
def my_min(array) # time complexity => O(n^2), space complexity = O(n)
not_shortest = true
array.each.with_index do |el1, i1|
not_shortest = false
array.each.with_index do |el2, i2|
if i1 == i2
next
elsif el1 > el2
not_shortest ... |
require 'rails_helper'
feature 'User can delete answer', %q{
As an authenticated user
I'd like to be able to delete my answer
And no one except me can delete my answer
} do
given(:user) {create(:user)}
given!(:question) {create(:question, user: user)}
given!(:answer) {create(:answer, question: question, u... |
class Event < ActiveRecord::Base
belongs_to :org
scope :last_n, -> (org, n) { where(org_id: org.id).order("ts DESC").limit(n) }
scope :last_n_for_host, -> (org, n, host) { where(org_id: org.id).where(hostname: host).order("ts DESC").limit(n) }
end
|
module FileMover
module Handlers
def handle handlers, opts
handlers = [handlers].flatten
handlers.each do |handler|
case handler
when Proc
if block = opts[:proc]
logger.debug{"#{self}: handling proc #{handler}"}
block.call handler
end
... |
class Node
attr_accessor :value, :next
def initialize(value, pointer = nil)
@value = value
@next = pointer
end
def to_s
"Node with value #{value}"
end
end
|
FactoryBot.define do
factory :room_type do
name {Faker::Name.name}
description {Faker::Lorem.sentence}
bed_num {1}
cost {100}
end
end
|
require 'test_helper'
class UserTest < ActiveSupport::TestCase
def setup
@user = User.new(name: "ExampleUser")
end
test "should be valid" do
assert @user.valid?
end
test "name should be present" do
@user.name = " "
assert_not @user.valid?
end
test "name should not contain whitespac... |
class SpecialAbility < ApplicationRecord
validates_presence_of :name
has_and_belongs_to_many :monsters
end
|
require 'rails_helper'
RSpec.describe PaymentForm, type: :model do
it 'has a valid factory' do
expect(create :payment_form).to be_valid
end
end
|
class PriceInput < Formtastic::Inputs::StringInput
def input_html_options
super.merge class: 'price-input'
end
def to_html
input_wrapping do
label_html <<
builder.text_field(method, input_html_options)
end
end
end
|
require_relative 'test_helper'
begin
require 'tilt/asciidoc'
describe 'tilt/asciidoctor' do
html5_output = "<div class=\"sect1\"><h2 id=\"_hello_world\">Hello World!</h2><div class=\"sectionbody\"></div></div>"
docbook5_output = "<section xml:id=\"_hello_world\"><title>Hello World!</title></section>"
... |
class ContactsController < ApplicationController
def new #отображение сираницы т.е GET
end
def create #отправка страницы т.е POST
@contact = Contact.new(contact_params)
if @contact.valid?
@contact.save
else
render action: 'new'
end
end
private
#разрешение на передачу параметров
def contact_params
... |
Gem::Specification.new do |s|
s.name = "jobs-dependency"
s.version = "0.0.1"
s.default_executable = "jobs-dependency"
s.authors = ["Shawn Wang"]
s.date = %q{2012-07-27}
s.description = %q{A Ruby Test}
s.email = %q{shawn.wang.uk@gmail.com}
s.require_paths = ["lib"]
s.rubygems_... |
namespace :hosting do
desc 'Prepare oriented.net Hosting for deployment.'
task :setup do
info 'Setup ssh-keys for passwordless login'
role_properties(:app) do |hostname, role, props|
system "ssh-copy-id #{fetch(:mb_privileged_user)}@#{hostname} -p #{props[:port]}"
end
on roles(:app) do
... |
require File.dirname(__FILE__) + '/setup'
require 'javaclass/classpath/convention_classpath'
module TestJavaClass
module TestClasspath
class TestConventionClasspath < Test::Unit::TestCase
def setup
@folder = "#{TEST_DATA_PATH}/eclipse_classpath"
@cpe = JavaClass::Classpath::ConventionClas... |
class CreateSimulations < ActiveRecord::Migration[5.2]
def change
create_table :simulations do |t|
t.references :strategy, foreign_key: true
t.integer :unit_cost
t.integer :bankroll_start
t.integer :current_bankroll
t.integer :number_of_decks_in_shoe, default: 6
t.string :aasm... |
require File.dirname(__FILE__) + '/spec_helper'
describe PhantomStatic::Runner do
describe "when running" do
it "should dump to png with as_file" do
file = PhantomStatic::Runner.as_file "http://google.com"
file.size.should > 0
File.extname(file.path).should == ".png"
end
it "shoul... |
# 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... |
# frozen_string_literal: true
module ApplicationHelper
def render_notices
render partial: 'partials/notices'
end
def candle_latest_time(candle)
candle ? candle.time : '(No data)'
end
def check_icon(boolean)
icon = boolean ? 'fa-check-square' : 'fa-square'
tag.span class: ['far', icon]
end... |
class Game < ActiveRecord::Base
has_many :user_games
has_many :answers
has_many :rounds
end
|
class CreateGeoscoisGeosmaps < ActiveRecord::Migration
def self.up
create_table :geoscois_geosmaps, :id => false do |t|
t.references :geoscoi
t.references :geosmap
end
end
def self.down
drop_table :geoscois_geosmaps
end
end
|
class UserSerializer < ActiveModel::Serializer
attributes :id, :username, :email, :password_digest, :image
has_many :scores
has_many :tests, through: :scores
end
|
class Dog
# this makes a method name= & a getter 'name' method
# attr_accessor :name # can include :breed, etc
#
# will allow access with Dog.name
# def initialize
# @name = name
# end
def name=(dogs_name)
@this_dogs_name = dogs_name
end
def name
@this_dogs_name
end
end
lassie = Dog.... |
class AdCategory < ActiveRecord::Base
has_many :ad_results
end
|
# Custom Json response until I find a way to only parse the body once in
# the OAuth2 retry case
#
module Podio
module Middleware
class JsonResponse < Faraday::Response::Middleware
require 'multi_json'
def self.register_on_complete(env)
env[:response].on_complete do |finished_env|
i... |
LunchTracker::Application.routes.draw do
root :to => 'home#index'
get '/login' => 'session#new'
post '/login' => 'session#create'
delete '/login' => 'session#destroy'
resources :restaurants do
collection do
get 'search'
get 'validate_address'
get 'filter/:tag_id', :action => :filter, :... |
require 'user'
module GrapeWarden
class API < Grape::API
use Rack::Session::Cookie, :secret => "replace this with some secret key"
use Warden::Manager do |manager|
manager.default_strategies :password
manager.failure_app = GrapeWarden::API
end
format :json
get "ping" do
... |
# Vagrant for nargun
Vagrant.configure("2") do |config|
# bareminimum archlinux build on daily basis
config.vm.box = "archlinux/archlinux"
config.vm.hostname = "nargun"
config.ssh.forward_x11 = true
config.vm.network "forwarded_port", guest: 5900, host:5900,
auto_correct: true # VNC port forwarding
# ... |
module Fizzbuzz
module CLI
def self.run(argv, output: $stdout)
unless argv.size == 1
output.puts "数値を1つ渡してください\n"
return 1
end
n = argv.first.to_i
output.puts Fizzbuzz.fizzbuzz(n)
return 0
end
end
end |
#
# Author:: Celso Fernandes (<fernandes@zertico.com>)
# © Copyright IBM Corporation 2014.
#
# LICENSE: MIT (http://opensource.org/licenses/MIT)
#
require 'fog/core/model'
require 'fog/softlayer/models/dns/records'
module Fog
module DNS
class Softlayer
class Domain < Fog::Model
identity :id, ... |
class CreatePublishers < ActiveRecord::Migration
def self.up
create_table :publishers do |t|
t.string :first_name
t.string :last_name
t.string :email
t.text :address
t.boolean :approved
# Devise-specific
t.database_authenticatable
t.confirmable
t.recov... |
class Post < ApplicationRecord
mount_uploader :voice_uploade_file, VoiceFileUploader
mount_uploader :thumnail_image, ImageUploader
belongs_to :bulletin
belongs_to :user
searchable do
text :title, :content
end
#게시글이 삭제되도 DB에는 원본 기록이 남아있음.
acts_as_paranoid
#... |
class DocumentImportRow < ActiveRecord::Base
belongs_to :document_import
def parse_csv_content(row)
self.content = {
id: prepare_content(row['id']),
title: prepare_content(row['title']),
description: prepare_content(row['description']),
grades: parse_arra... |
xml.rss(RSS_SPEC) do
xml.channel do
xml.title "Blog: #{@blog.name} | 89.3 KPCC"
xml.link blog_url(@blog.slug)
xml.atom :link, href: blog_url(@blog.slug, format: :xml), rel: "self", type: "application/rss+xml"
xml.description strip_tags(@blog.description)
xml << render_content(@scop... |
require 'rails_helper'
describe ProductsController, type: :controller do
describe 'GET #index' do
it "populates an array of products ordered by all" do
products = create_list(:product, 3)
get :index
expect(assigns(:products)).to match(products)
end
it "renders the :index template" do
... |
class Invoice < ApplicationRecord
has_many :invoice_items, dependent: :destroy
has_many :items, through: :invoice_items
has_many :transactions
belongs_to :customer
belongs_to :merchant
validates :customer_id, presence: true
validates :merchant_id, presence: true
validates :status, presence: true
def... |
class Event
attr_reader :name, :food_trucks, :list
def initialize(name)
@name = name
@food_trucks = []
@list = []
end
def add_food_truck(food_truck)
@food_trucks << food_truck
end
def food_truck_names
@food_trucks.map do |food_truck|
food_truck.name
end
end
def food_truc... |
class LoginsController < Roda
route do |r|
r.get "sign_in" do
view('logins/sign_in')
end
r.post "authenticate" do
params = login_params(r)
user = User.find_by(
"LOWER(?) IN (LOWER(name), LOWER(email))",
params["email"]
)
if user && user.authenticate(params["... |
# encoding: utf-8
require 'spec_helper'
describe TTY::Terminal::Pager, '#page' do
let(:text) { "a\n" }
let(:shell) { TTY.shell }
let(:system) { TTY::System }
let(:pager) { double(:pager, :page => nil) }
let(:basic_pager) { TTY::Terminal::BasicPager }
let(:system_pager) { TTY::Terminal::SystemPager }
... |
require 'spec_helper'
describe 'docker::devicemapper' do
let(:chef_run) do
ChefSpec::SoloRunner.new.converge(described_recipe)
end
it 'includes the device-mapper recipe' do
expect(chef_run).to include_recipe('device-mapper')
end
end
|
require 'spec_helper'
describe "devise/registrations/new" do
before do
view.should_receive(:resource).at_least(1).times.and_return(User.new)
view.should_receive(:resource_name).at_least(1).times.and_return("user")
end
it "renders default look for completely new user" do
render
view.should ren... |
require_relative 'container'
require_relative 'user_greeter'
require_relative 'widget_selector'
module Widgets
# Component-level widgets reused by multiple page widgets.
module Page
# Widget for a Bootstrap fixed top navbar. Accepts parameters to specify
# branding and menu items.
class FullNavbar < V... |
require 'spec_helper'
module ChefSpec
module Matchers
describe :ruby_block do
context 'with String expectations' do
let(:matcher) { execute_ruby_block('sample') }
it "shouldn't match when no resources exists" do
matcher.matches?({:resources => []}).should be false
end
... |
# TODO
#
# * Lockeo de pedidos — Según sesión.
#
# * Continuar respondiendo — Cargar nueva respuesta
# en lugar de cargar la página principal.
#
# * Autocompletar el correo — Cargar nuevo
# pedido/respuesta manteniendo el correo ingresado.
#
# * Ordenar también por reputación del usuario.
#
# * Borrar un pedido au... |
class Email < ActiveRecord::Base
belongs_to :contact
belongs_to :institution
validate :address, :email_is_valid
private
def email_is_valid
if !self.address.blank?
regex = /\A[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]+\z/
if !(self.address =~ regex)
self.errors.add(:address, 'E-mail i... |
require 'thomas'
class ControlOutputter < Thomas::Thing
def initialize(tb, id)
super([[Thomas::Space.new('')]])
@inputtable = true
@text = tb
@id = id
end
def handle_input(char, metadata)
char = 'UP' if char == Thomas::Util::KEY_UP_ARROW
char = 'DOWN' if char == Thomas::Util::KEY_DOWN_A... |
class RecipesController < ApplicationController
def index
@recipes = Recipe.all
end
def new
@recipe = Recipe.new
end
def create
@recipe = Recipe.new(recipe_params)
if @recipe.save
redirect_to root_path
end
end
private
def recipe_params
params.require(:recipe).permit(:title)
end
end |
require './test/test_helper'
require 'minitest/autorun'
require 'minitest/pride'
require './lib/key_generator'
require 'mocha/minitest'
class KeyGeneratorTest < Minitest::Test
def test_it_exists
key_gen = KeyGenerator.new
assert_instance_of KeyGenerator, key_gen
end
def test_it_has_attributes
key_g... |
class ItemsController < ApplicationController
before_action :set_item, only: [:show, :update, :destroy]
# GET /items
def index
@items = Item.all
json_response(@items)
end
# POST /items
def create
@item = Item.create!(item_params)
json_response(@item, :created)
end
# GET /items/:id... |
class UnidadChoferesController < AuthorizedController
# GET /unidades/:unidad_id/choferes/new
def new
unidad = Unidad.find(params[:unidad_id])
@unidad_chofer = unidad.unidad_choferes.build
respond_to do |format|
format.html
end
end
# POST /unidades/:unidad_id/choferes
def create
... |
class AddMetaDataToLayers < ActiveRecord::Migration
def change
add_column :layers, :meta_data, :text
end
end
|
require 'spec_helper'
describe Aws::Broker do
let(:topic) { 'topic' }
let(:queue) { 'queue' }
let(:message) {
{
id: 0,
event: 'event'
}
}
let(:publisher) { described_class::Publisher }
let(:subscriber) { described_class::Subscriber }
before { Aws::Broker.config.enabled = false }... |
class CreateUserDefaultsJob < ApplicationJob
queue_as :default
PROJECT_STATUSES = [
{ slug: 'active', name: 'Active' },
{ slug: 'inactive', name: 'Inactive' },
{ slug: 'canceled', name: 'Canceled' },
{ slug: 'on-hold', name: 'On Hold' }
].freeze
SKILL_CATEGORIES = [
{ name: 'Languages' },
... |
module CassandraObject
class RecordInvalid < StandardError
attr_reader :record
def initialize(record)
@record = record
super("Invalid record: #{@record.errors.full_messages.to_sentence}")
end
end
module Validations
extend ActiveSupport::Concern
include ActiveModel::Validations
... |
class SelloutsController < ApplicationController
before_action :set_sellout, only: [:show, :update]
before_action :auth_token
# GET /sellouts
# GET /sellouts.json
def index
@sellouts = Sellout.all
end
# GET /sellouts/1
# GET /sellouts/1.json
def show
end
# POST /sellouts
# POST /sellouts... |
require 'rails_helper'
def stub_omniauth
OmniAuth.config.test_mode = true
OmniAuth.config.mock_auth[:github] = OmniAuth::AuthHash.new({
provider: 'github',
extra: {
raw_info: {
uid: "1234",
name: "Garrett Smestad",
screen_name: "GSmes"
}
},
... |
# frozen_string_literal: true
class NipposController < PrivateController
include NippoHandleable
def new
@nippo = Nippo.new(
body: current_user.template.body,
reported_for: Nippo.default_report_date,
)
end
def create
if @nippo.save
send_nippo
else
flash.now[:alert] = @n... |
# coding: utf-8
require_relative '../uploaders/project_pictures_uploader'
require_relative '../uploaders/pdf_uploader'
class ProjectValidator < ActiveModel::Validator
def validate(record)
if record.project_pictures.size > 10
record.errors.add(:project_pictures, "maximo de 10 fotos")
end
unless rec... |
class Occasion < ActiveRecord::Base
has_many :birthday_deals
end |
class AddFieldsToCategories < ActiveRecord::Migration[6.0]
def change
add_column :categories, :name, :string
add_reference :categories, :droid, null: false, foreign_key: true
end
end
|
require 'spec_helper'
describe Invite do
let(:game) { FactoryGirl.create(:game)}
let(:organizer) { FactoryGirl.create(:user) }
let(:guest) { FactoryGirl.create(:user) }
before do
@event = organizer.hosted_events.build(game: game, fromtime: 2.hours.from_now, totime: 3.hours.from_now)
@event.save
... |
# frozen_string_literal: true
require 'rails_helper'
include Warden::Test::Helpers
RSpec.feature 'Create an OSHU ETD', :clean, js: true do
let(:admin) { FactoryBot.create(:admin) }
let(:user) { FactoryBot.create(:user) }
let(:etd) do
FactoryBot.attributes_for(
:moomins_thesis,
user: admin,
... |
require_relative 'cell'
class Grid
attr_accessor :cells
def initialize(puzzle)
@cells = puzzle.chars.map.with_index{|cell, index|
Cell.new(cell.to_i, index)
};
end
def boxes
@cells.group_by{|cell| cell.box}
end
def rows
@cells.group_by{|cell| cell.row}
end
... |
require_relative '../lib/zellers_congruence'
RSpec.describe ZellersCongruence do
context ".calculate" do
it "returns day of the week for 0" do
ZellersCongruence.calculate(2014, 7, 5).should == 7
end
end
context ".calculate" do
it "returns day of the week for 0 in February" do
ZellersCong... |
class AdmincaipinsController < ApplicationController
before_action :set_caipin, only: [:show, :edit, :update, :destroy]
def index
@caipins = Caipin.all
@caipinclas = Caipincla.all
end
def show
@caipintype = Caipincla.all
end
# GET /tests/new
def new
@admincaipin = Caipin.new
@c... |
class Serializer
def initialize(object, keys=[])
@object = object
@keys = keys
end
def render
if @keys.empty?
@object.to_json
else
@object.to_json include: @keys
end
end
end
|
require 'rails_helper'
test_data = {
empty_request: '',
good_request: '8 Market Place Baltimore MD 21202',
garbage_request: '\asdfaewrves5hw4aergqqv3 \!@%#',
blank_request: ' '
}
# rubocop:disable Metrics/BlockLength
describe Geocoder, type: :model do
describe 'search' do
context "when given a empty req... |
module BrewSparkling
module Recipe
class Builder
class << self
def inherited(klass)
(@all ||= []) << klass
end
def all
@all
end
def github(path, branch: 'master')
url "https://github.com/#{path}/archive/#{branch}.tar.gz"
end
... |
class CreateStartSignals < ActiveRecord::Migration
def change
create_table :start_signals do |t|
t.integer :user_id
t.integer :location_id
t.datetime :start_time
t.timestamps
end
add_index :start_signals, :user_id
add_index :start_signals, :location_id
end
end
|
class Story < ActiveRecord::Base
validates :title, presence: true #must have title & description
validates :link, length: {minimum:5} #description must be min. 10 chars
validates :category, length: {minimum: 3}
validates :upvotes, numericality: {greater_than_or_equal_to: 0}
def self.search_for (query)
self.where... |
require 'rails_helper'
RSpec.describe Message, type: :model do
context 'validation' do
after(:each) do
Message.destroy_all
end
after(:all) do
Chatroom.destroy_all
end
let(:chatroom) { Chatroom.new(name: 'chatroom-test') }
it 'should validate author presence' do
message =... |
class Map < ActiveRecord::Base
attr_accessible :date, :description, :latitude, :longitude
validates_presence_of:description
validates_presence_of:latitude
validates_presence_of:longitude
end |
require 'get_address/version'
require 'get_address/missing_fields_error'
require 'get_address/configuration'
require 'get_address/url_generator'
require 'get_address/request'
require 'get_address/response'
module GetAddress
BASE_URL = 'https://api.getAddress.io/find/'
class << self
def configure
@@confi... |
#searches all files in models directory and creates notation suitable for http://yuml.me/
class Uml
def self.create_yuml_output
Dir.glob('./models/*.rb') do |rb_file|
text=File.open(rb_file).read
text.gsub!(/\r\n?/, "\n")
klass = ""
text.each_line do |line|
if match = line.match(/... |
class Deal < ApplicationRecord
acts_as_paranoid
has_one :quotation
has_one :discount, dependent: :destroy
has_many :job_requests, dependent: :destroy
has_many :packing_lists, dependent: :destroy
has_many :packing_list_items, through: :packing_lists
has_many :deadlines, dependent: :destroy
has_many :tran... |
class Task < ApplicationRecord
belongs_to :gym
has_many :time_cards
def calculate_time(time_card)
time_card.end_time.nil? ? 0 : ((time_card.end_time - time_card.start_time) / 60).round
end
end
|
Create an array of the numbers 1 though 100 (i.e. [1, 2, 3, ..., 99, 100]).
# ==================================
numbers = [1, 2, 3, 4]
Sum all the elements in the numbers array.
# ==================================
What is the sum of all the numbers between 0 and 100 that are divisible by both 3 and 5?
# (0..100... |
require 'rails_helper'
RSpec.describe "EditingCategoryTasks", type: :system do
before do
driven_by(:rack_test)
end
User.destroy_all
before :each do
# Devise gem rspec helper
@user = User.create(:email => 'test123@example.com', :password => 'f4k3p455w0rd')
login_as(@user, :scope => :user)
@... |
class AddCountStatisticToPreachmentInfos < ActiveRecord::Migration
def change
add_column :preachment_infos, :listen_count, :integer, default: 0
add_column :preachment_infos, :downloaded_count, :integer, default: 0
end
end
|
class ItemsController < ApplicationController
before_filter :login_required
load_and_authorize_resource :board
load_and_authorize_resource :through => :board, :shallow => true
# GET /items
# GET /items.json
def index
# @items = Item.all
store_location
@items = @items.page(params[:page])
resp... |
require 'rails_helper'
RSpec.describe 'ユーザー認証機能', type: :system do
it 'ログインしていなければログイン画面へ遷移すること' do
visit root_path
expect(page).to have_current_path new_user_session_path
end
it 'ログインとログアウトする' do
visit new_user_session_path
click_on 'signin-link'
expect(page).to have_content 'Google アカウント... |
puts "Hello World!"
puts "Hello Again"
puts "I like typing this."
puts "This is fun."
puts "Yay! printing."
puts "I'd much rather you 'not'."
puts 'I "said" do not touch this.'
puts "\n"
#1
puts "Hello World!"
puts "Hello Again"
puts "I like typing this."
puts "This is fun."
puts "Yay! printing."
puts "... |
class Comment < ActiveRecord::Base
has_many :comments
belongs_to :post
belongs_to :user
end
|
module Fastlane
module Actions
class MailgunAction < Action
def self.is_supported?(platform)
true
end
def self.run(options)
require 'rest_client'
handle_exceptions(options)
mailgunit(options[:mailgun_apikey],
options[:mailgun_sandbox_domain],... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.