text stringlengths 10 2.61M |
|---|
module Tubular
REQUEST_LENGTH = 2 ** 14
# Number of peers to connect to
PEER_COUNT = 5
end
|
class FontNotoSansCherokee < Formula
head "https://noto-website-2.storage.googleapis.com/pkgs/NotoSansCherokee-unhinted.zip", verified: "noto-website-2.storage.googleapis.com/"
desc "Noto Sans Cherokee"
homepage "https://www.google.com/get/noto/#sans-cher"
def install
(share/"fonts").install "NotoSansCherok... |
require "rails_helper"
require "spec_helper"
feature "viewing tickets" do
scenario "all tickets" do
user = FactoryGirl.create(:user)
project = FactoryGirl.create(:project)
ticket = FactoryGirl.create(:ticket, project: project)
ticket.update(user: user)
visit "/"
click_link project.name
within("li") do... |
require 'test_helper'
class AutomotorasControllerTest < ActionController::TestCase
setup do
@automotora = automotoras(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:automotoras)
end
test "should get new" do
get :new
assert_response :... |
module Shoperb module Theme module Editor
module Mounter
module Model
class Currency < Sequel::Model
extend Base::SequelClass
include Base::Sequel
fields :id, :name, :code, :symbol, :rate, :date
def self.primary_key
:id
end
end
end
end
end end... |
class Album < ActiveRecord::Base
belongs_to :person
has_many :images, as: :imagable
end
|
# == Schema Information
#
# Table name: account_requests
#
# id :bigint not null, primary key
# email :string not null
# organization_name :string not null
# organization_website :string
# request_details :text not null
# created_a... |
feature 'viewing website' do
scenario 'can see main page content' do
visit '/'
expect(page).to have_content "Welcome to chitter!"
end
end
feature 'website shows peeps' do
scenario 'you can see all of the peeps' do
Peep.create(content: "Well its friday!")
Peep.create(content: "Ready for the weeke... |
module TableViewBuilder
end
module TableViewBuilder::KeyboardScrolling
def init
Notification.subscribe UIKeyboardWillShowNotification, action:"decreaseTableViewFrame", observer:self
Notification.subscribe UIKeyboardWillHideNotification, action:"increaseTableViewFrame", observer:self
super
... |
require './config/environment'
class Item < ActiveRecord::Base
belongs_to :user
belongs_to :category
has_many :item_categories
has_many :categories, through: :item_categories
validates_presence_of :name, :quantity, :condition, :price, :category_id, message: "fields cannot be blank."
end |
class UsersController < ApplicationController
Characterize.standard_features = Characterize.builtin_standard_features + [StandardCharacter]
characterize :user,
default: [SpecialCharacter, UserCharacter],
edit: [EditUserCharacter]
characterize :widget, default: [SpecialCharacter, WidgetCharacter] do
... |
class Api::V1::VideosController < ApplicationController
def index
render json: VideoPresenter.json_list(Video.all)
end
def create
@_video = Video.create(video_params)
if video.persisted?
head :ok
else
render json: { errors: video.errors }, status: :unprocessable_entity
end
end
... |
module Task::Cmd
def self.exec(cmd, opts = {}, chdir = Rails.root)
opts[:env] = {} if opts[:env].nil?
data = [] if opts[:capture_output]
Open3.popen2e(opts[:env], cmd, chdir: chdir) do |stdin, stdout_and_stderr, wait_thr|
if opts[:capture_output]
stdout_and_stderr.each { |line| data << lin... |
require 'rspec'
require './lib/bnfkr.rb'
describe Parser do
before(:all) do
@parser = Parser.new
end
describe "#read" do
it "should strip out any non-bf instructions" do
@parser.read("abcdefghijklmnopqrstuvwxyz 123456789").should eq []
@parser.read("a+ b- c> d< e[ f] g. i, ").should eq %w(+ ... |
class VendingMachine
require './lib/stock.rb'
require './lib/finder.rb'
include Finder
attr_reader :stock, :cashier,:balance, :sales
MONEY = [10, 50, 100, 500, 1000].freeze
def initialize
@stock = Stock.new
@sales = 0
@balance = 0
end
def available_products
stock.products.select { |p... |
require 'rails_helper'
describe API::V1::Searches do
describe 'GET /api/v1/searches' do
before(:each) do
10.times { FactoryGirl.create :search }
get '/api/v1/searches'
end
it { expect(response.status).to eq(200) }
it { expect(JSON.parse(response.body).size).to eq(10) }
end
describe ... |
module InsteddAppHelper
def flash_message
res = nil
keys = { :notice => 'flash_notice', :error => 'flash_error', :alert => 'flash_error' }
keys.each do |key, value|
if flash[key]
res = content_tag :div, :class => "flash #{value}" do
content_tag :div do
flash[k... |
# frozen_string_literal: true
require 'rails_helper'
describe 'As a guest on the registration path who fills in all fields' do
describe 'I click submit and am redirected to the dashboard path' do
scenario 'I see a message that says logged in and email needs activated' do
visit root_path
click_on 'R... |
module Auth::Model::Account::EmailAccount
extend ActiveSupport::Concern
included do
has_many :check_tokens, class_name: 'EmailToken', foreign_key: :identity, primary_key: :identity, inverse_of: :account, dependent: :delete_all
end
def reset_notice
UserMailer.password_reset(self).deliver_later
end
... |
require 'caboose'
require 'fileutils'
require 'uri'
##
# Looted from the Rails spider_test plugin.
module Caboose::SpiderIntegrator
# Begin spidering your application.
# +body+:: the HTML request.body from a page in your app
# +uri+:: the URL which generated the request.body. This is used in stack traces (fo... |
require 'andand'
module Lita
module Handlers
class GamedevStore < Handler
route(/^!set game\s+(.+)/, :game_set,
help: {
'!set game Retro Pixel Castles - http://retropixelcastles.com/ - http://store.steampowered.com/app/328080/' =>
'sets your game spiel to "Retro P... |
#setting varianble for my number set
fizzbuzz = 1..100
#for each number in my variable run the following if else statments.
fizzbuzz.each do |num|
if num % 3 == 0 && num % 5 == 0
puts "Fizz Buzz"
elsif num % 3 == 0
puts "Fizz"
elsif num % 5 == 0
puts "Buzz"
else
puts num
end
end
#in order to... |
require File.dirname(__FILE__) + '/../test_helper'
require 'rack_node_assignments_controller'
# Re-raise errors caught by the controller.
class RackNodeAssignmentsController; def rescue_action(e) raise e end; end
class RackNodeAssignmentsControllerTest < Test::Unit::TestCase
def setup
@controller = RackNodeAss... |
# frozen_string_literal: true
# User model
class User < ApplicationRecord
# Include default devise modules. Others available are:
# :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable, :confirmable
has_many :... |
require 'rails_helper'
RSpec.describe User do
describe 'validations' do
it {should validate_presence_of :email}
it {should validate_uniqueness_of :email}
it {should validate_presence_of :password_digest}
end
describe 'relationships' do
it {should have_many :friendships}
it {should have_ma... |
FactoryGirl.define do
salt = 'pU_5Yr__gS4m4_BrajJ3'
password = 'password'
factory :user do
email 'test@example.com'
username 'test_user'
salt salt
password password
password_confirmation password
crypted_password Sorcery::CryptoProviders::BCrypt.encrypt(password, salt)
end
end
|
class FavoritesController < ApplicationController
def create
review = Review.find(params[:review_id])
favorite = current_user.favorites.new(review_id: review.id)
favorite.save
redirect_to request.referrer
end
def destroy
review = Review.find(params[:review_id])
favorite = current_user... |
module FixMyTags::Music
class Basic
attr_reader :name, :artist, :title, :filetype
def initialize file
@name = file.match(/[^\/]*$/).to_s
@artist = (@name.match /^[^-]*/ || "").to_s.strip
@title = (@name.match( /-([^\.]*)/)[1] ).to_s.strip
@filetype = (@name.match( /[\.]([^\... |
# frozen_string_literal: true
# rubocop:disable Metrics/BlockLength
require 'human_size'
RSpec.describe HumanSize do
it 'has a version number' do
expect(HumanSize::VERSION).not_to be nil
end
context 'Class Accessor Method' do
before(:each) do
@hs = HumanSize::Size
end... |
class A173902Builder
def self.sequence(target_length = 100)
a173902 = []
i = 1
while a173902.length < target_length
a173902 << i if member?(i)
i += 1
end
a173902
end
def self.each_digit_cubed(n)
"#{n}".split("").uniq.each { |i| yield (i.to_i**3) }
end
def self.member?(n)... |
require "vitae/delegators"
require "yaml"
class CV
extend Vitae::Delegators
attr_reader :file_name
class << self
def all
raise "Vitae::project_root is not set" unless Vitae::project_root
cvs = Dir.glob(File.join(Vitae::project_root, "cvs/*.yaml"))
cvs.map do |cv|
CV.new(cv)
... |
require 'couchrest'
module CipherMyUrl
module MyDB
module Adapters
# This module-adapter loads at run-time by MyDB module. See db.rb.
#
# Instead of deleting slots we mark them as 'deleted', see #del.
module Couchdb
extend self
DEL_MUTEX = Mutex.new
def getValue... |
class CreateShares < ActiveRecord::Migration
def change
create_table :shares do |t|
t.integer :recipient_id
t.string :recipient_type, :default => '', :null => false
t.integer :shareable_id
t.string :shareable_type, :default => '', :null => false
t.column :can_create, 'tinyint(1) u... |
class Admin::CommentsController < ApplicationController
cache_sweeper :comment_sweeper, :only => [:create, :update, :destroy]
layout 'admin'
before_filter :login_required
# GET /admin/users/1/comments
# GET /admin/users/1/comments.xml
# GET /admin/blogs/1/comments
# GET /admin/blogs/1/comments.xml
# ... |
require "vws/version"
require 'rubygems'
require 'rest_client'
require 'digest/md5'
require 'time'
require 'openssl'
require 'base64'
require 'json'
module Vws
#constants for end point interface links
BASE_URL = "https://vws.vuforia.com"
TARGETS_URL = BASE_URL + "/targets"
SUMMARY_URL = BASE_URL + "/summar... |
module CurrentOrder
extend ActiveSupport::Concern
private
def set_order
if user_signed_in? && @order = current_user.active_order
logger.debug("LOGGER >> #SET_ORDER >> User signed_in and has a order.")
session[:order_id] = nil
elsif user_signed_in?
if session[:order_id].... |
require "spec_helper"
describe "/examinations requests" do
before :each do
@admin = FactoryGirl.create :admin_user
# sign in as admin user
post sessions_path, { :session => { :email => @admin.lead.lead_contact.email, :password => @admin.password } }
end
describe "Review examination" do
before ... |
statement = "The Flintstones Rock"
# create a hash that expresses the frequency
# with which each letter occurs in the string
statement.split.join.chars.each_with_object({}) do |letter, object|
object[letter] = statement.count(letter)
end
|
module OpenAssets
module MethodFilter
module Filters
def before_filter(method, options = {})
@before_filters ||= {}
@before_filters[method] = options
end
def filtered_method?(method, options)
if options.has_key? :include
return true if options[:include].inclu... |
require 'spec_helper'
describe "validate_includes_matcher" do
before :all do
define_model :item do
plugin :validation_helpers
def validate
validates_includes ["Joseph", "Jonathan"], :name, :allow_nil => true
end
end
end
subject{ Item }
it "should require an attribute" do
... |
Pod::Spec.new do |s|
s.name = "MMBGoogleLocationPicker"
s.version = "0.0.5"
s.summary = "A ready for use and fully customizable location picker for your app."
s.homepage = "https://github.com/MahmoudMMB/MMBGoogleLocationPicker"
s.screenshots = "https://raw.githubuse... |
class Mailer < ActionMailer::Base
default from: "membership@artscouncilnv.org"
end
|
# -*- encoding : utf-8 -*-
class ImagesController < ApplicationController
has_control_panel_applet :admin_applet,
if: -> { permitted_to? :edit, :images }
def index
@images = Image.paginate(page: params[:page], per_page: 10)
render layout: false if request.xhr?
end
def new
... |
module CDI
module V1
module Users
class FacebookLinkService < BaseActionService
include V1::ServiceConcerns::OauthParams
attr_reader :user
action_name :facebook_link_account
def initialize(user, options = {})
@user = user
super(options)
end
... |
require_relative 'contact'
require 'sinatra'
get '/' do
erb :index
end
get '/contacts' do
@contacts = Contact.all
erb :contacts
end
get '/about' do
erb :about
end
get '/contacts/new' do
erb :new_contact
end
get '/contacts/:id' do
@contact = Contact.find(params[:id].to_i) #params[:id] contains the id f... |
class User < ApplicationRecord
# nameカラムに関するバリデーションを作成してください
validates :name, {presence: true}
# emailカラムに関するバリデーションを作成してください
validates :email, {presence: true, uniqueness: true}
# passwordカラムにバリデーションを設定
validates :password, {presence: true}
# インスタンスメソッドpostsを定義
def posts
return Post.where(user_i... |
Gem::Specification.new do |s|
s.name = "melon"
s.version = "0.1"
s.date = Time.today.strftime("%Y-%m-%d")
s.authors = ["cloudhead"]
s.email = "biopunk@gmail.com"
s.summary = "json blog engine"
s.homepage = "http://github.com/cloudhead/melon"
s.description = "mi... |
class ChangeColumnToPlays < ActiveRecord::Migration
def up
change_column :plays, :room_no, :string, :null => false
remove_column :plays, :turn_count
add_column :plays, :turn_count, :integer, :null => false, default: 1
change_column :plays, :first_player, :integer, :null => true
change_column :play... |
require 'spec_helper'
describe User do
describe 'methods' do
describe '.find_or_build_with_omniauth' do
it 'creates a user when email is not present' do
info = double(name: 'adrian', nickname: 'hola', email: 'myemail@hola.com')
user = User.find_or_build_with_omniauth(info)
expect(u... |
class Api::V1::BaseController < ActionController::API
self.responder = ApplicationResponder
respond_to :json
before_action :authenticate_user!
rescue_from ActiveRecord::RecordNotFound do |exception|
render json: { error: 'Record not found' }, status: :not_found
end
end
|
class CreateUtilizationMetricsByNodeGroups < ActiveRecord::Migration
def self.up
create_table :utilization_metrics_by_node_groups do |t|
t.column :utilization_metric_name_id, :integer
t.column :node_group_id, :integer
t.column :value, :string
t.column :assigned_at, :datetime
t.... |
class ToolsController < ApplicationController
def index
@tools = Tool.sorted_by_published_date.
page(params[:page]).
per(10)
end
end
|
#!/usr/bin/env ruby
# 82 ms
# @param (Integer[]) digits
# @return (Integer[])
def plus_one(digits)
one = 1
results = []
digits.reverse_each do |digit|
sum = digit + one
one = sum / 10
results << sum % 10
end
results << one if one > 0
results.reverse
end
|
module ApplicationHelper
def zero_blank(number)
number == 0 ? '' : number_to_human(number)
end
def render_flash_message(message)
return if message.blank?
if message.is_a?(Array)
content_tag(:ul) do
message.each do |m|
concat content_tag(:li, m)
end
end
... |
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the 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... |
class User < ApplicationRecord
enum course: { "理系": 0, "文系": 1, "coins": 2 }
has_secure_password
has_many :events#, dependent: :destroy
has_many :active_relationships, class_name: "Relationship",
foreign_key: "follower_id",
dependent: :destroy
has_many :following, t... |
FactoryGirl.define do
factory :review do
description { Faker::Hipster.paragraph(2) }
rating { rand(6) }
end
end
|
class Paper < ActiveRecord::Base
validates_presence_of :test_name
validates_uniqueness_of :test_name
has_many :exams
has_and_belongs_to_many :exams
has_and_belongs_to_many :performances
has_and_belongs_to_many :users
end
|
class Page < ActiveRecord::Base
scope :menu_published, -> { where(status: 'PUBLIC').where.not(position: nil) }
scope :menu, -> { where(status: ['PUBLIC','DRAFT']).where.not(position: nil) }
scope :nav, -> { where(status: ['PUBLIC','DRAFT'], parent_id: nil).where.not(position: nil).order("position ASC") }
scope ... |
class StaticPagesController < ApplicationController
def home
if current_user
redirect_to profile_path
else
render layout: false
end
end
def privacy
end
end
|
require 'test_helper'
class StreamTest < ActiveSupport::TestCase
setup do
setup_default_profiles
@profile = @dragon
end
test "permanent scope" do
assert_equal 20, Stream.permanent.count
assert_equal 5, @lion.streams.permanent.count
end
test "public scope" do
streams = @profile.streams.... |
=begin
Formulaire pour s'inscrire
=end
titre = locale('ui.page.title.signin').as_h(1, :id => 'titre_page')
# Checkboxes
cb_pat_court = "M'afficher avec un patronyme court (p.e. « Philippe P. »)".
as_checkbox(:name => "user[patronyme_court]").
as_div(:id => 'cb_patronyme_court')
ordr... |
class BookingRequestRoom < ApplicationRecord
belongs_to :booking_request
belongs_to :guest1, class_name:'User', foreign_key: 'guest1_id', optional: true
belongs_to :guest2, class_name:'User', foreign_key: 'guest2_id', optional: true
has_one :booking_request_room
has_many :guest_rooms
after_save :update_... |
require 'spec_helper'
describe ApplicationController do
fixtures :users
before(:each) do
@user = User.all[0]
end
describe 'GET #index' do
it 'should respond successfully with a HTTP 200 status code' do
get :index
expect(response).to be_success
expect(response.status).to eq(200)
... |
class Logman
class Log
attr_accessor :message
attr_accessor :log_type
attr_accessor :data
attr_accessor :datetime
attr_accessor :data_type
attr_accessor :sources
def initialize
@data_type = 'rails.exception'
@log_type = 1 #error
@datetime = Time.now.utc
@sources = []
@sources << Log.... |
require 'spec_helper'
feature 'Task deletion', :acceptance do
before(:all) { create_test_user }
scenario 'Deleting single task' do
visit tasks_page
task_id = create_task :type => :action, :objective => 'Test task'
task_selector = "[record=task][record-id='#{task_id}']"
visit tasks_page
tasks ... |
require 'rails_helper'
describe Category, type: :model do
context '#valid?' do
context 'with an used name' do
it 'is invalid' do
category = create(:category)
other = build(:category, name: category.name)
expect(other).to be_invalid
end
end
end
end
|
module LoggerModule
def logger
Rails.logger
end
end |
class BreadcrumbBuilder < BreadcrumbsOnRails::Breadcrumbs::Builder
def render
"<ul>#{@elements.map{|e| "<li>#{item e}</li>"}.join}</ul>"
end
def item element
@context.link_to_unless_current(compute_name(element), compute_path(element))
end
end |
module VendorsHelper
def resource_name
:vendor
end
def resource
@resource ||= Vendor.new
end
def devise_mapping
@devise_mapping ||= Devise.mappings[:vendor]
end
end
|
FactoryBot.define do
factory :customer do
email { Faker::Internet.free_email }
password { Faker::Internet.password }
last_name { Gimei.last.kanji }
first_name { Gimei.first.kanji }
last_name_kana { Gimei.last.katakana }
first_name_kana { Gimei.first.katakana }
postcode { Faker::Address.pos... |
# tictactoe.rb
# my version
require 'pry'
BOARD_COORD_VALS =
{ r1c1: 1, r1c2: 2, r1c3: 4, r2c1: 8, r2c2: 16,
r2c3: 32, r3c1: 64, r3c2: 128, r3c3: 256 }.freeze
PLAYER_SYSTEM = 'S'.freeze
PLAYER_PERSON = 'P'.freeze
def prompt(string)
puts "==>> #{string}"
end
def log_game_action(string, game_action_log)
g... |
# -*- encoding : utf-8 -*-
class ExplanatoryNot < ActiveRecord::Base
belongs_to :aspirant
attr_accessible :aspirant_id, :content
end
|
# frozen_string_literal: true
module Types
module Home
class HomeData < Types::BaseObject
field :cases, ::Types::Home::Cases.connection_type, null: false
end
end
end
|
class NewAnswerNoticeJob < ApplicationJob
queue_as :default
def perform(answer)
NewAnswerNoticeService.new.send_notice(answer)
end
end
|
FactoryBot.define do
factory :use do
quantity { 1 }
measure { "MyString" }
step { nil }
ingredient { nil }
end
end
|
# encoding: UTF-8
module API
module Helpers
module V1
module LearningDeliveriesHelpers
extend Grape::API::Helpers
def serialized_learning_delivery(learning_delivery, options = {})
options = { serializer: :learning_delivery }.merge(options)
serialized_object(learning_de... |
# Set of methods allowing to audit experiment.
#
# It is required to deliver method `id` in order to make auditable
# method works.
module Hypgen
module Auditable
# Log information with experiment id and current time before code
# defined in block is executed. After it is finised another log is created
# ... |
require_relative "../scraper"
# write how many tests I want for the fetch_movie_urls method.
describe "#fetch_movie_urls" do
# name the test (when you rake it's going to be red or green)
it "returns an array of movies" do
# create a variable to store all the urls returned from the method
urls = fetch_mo... |
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe Staff::Api::V1::OrganizationsController, type: :controller do
let(:staff) { create(:staff) }
before { sign_in_as(staff) }
describe 'POST #create' do
context 'with valid attributes' do
let(:options) { { organization: attributes_for(:... |
require 'absolute_renamer/interpreters/base'
module AbsoluteRenamer
module Interpreters
class FilenamePartsInterpreter < Base
def search_and_replace(part_name, new_value, path_handler)
current_value = path_handler.send(part_name)
new_value.gsub pattern do
start = $~[:start].to_i... |
class Model::Section::SecondaryNavigationMenu < SitePrism::Section
element :parent, "h2 a"
elements :children, "ul li a"
end |
return unless platform?("ubuntu")
unless node["chef-devstax"]["giteye"]["url"]
Chef::Application.fatal! "chef-devstax.giteye.url attribute cannot be nil. Please populate that attribute."
end
unless node["chef-devstax"]["giteye"]["version"]
Chef::Application.fatal! "chef-devstax.giteye.version attribute cannot be nil... |
class ReportCard
def initialize(student)
@student = student
end
def show_grades
all_grades = GradeBook.sort_grades(@student)
max_length = all_grades.max_by { |row| row.subject.length }.subject.length + 3
all_grades.map { |row| "#{row.subject.ljust(max_length, '.')}#{row.grade}" }
end
def sho... |
class AddIsExceptionToLogs < ActiveRecord::Migration
def change
add_column :logs, :is_exception, :boolean
end
end
|
class AddReviewTextColum < ActiveRecord::Migration[5.1]
def change
add_column :reviews, :review_text, :text
end
end
|
module Search
module Client
def self.included(base)
base.class_eval do
def self.client
@client ||= begin
url = ENV.fetch('ELASTICSEARCH_URL', 'http://localhost:9200')
log = Rails.env.test? ? false : Rails.logger
Elasticsearch::Client.new(url: url, log:... |
class CommentsController < ApplicationController
before_action :set_movie, only: [:create, :edit, :update]
def create
@comment = @movie.comments.build(comment_params)
@comment.user = current_user
respond_to do |format|
if @comment.save
format.js { render :index }
flash.now[:no... |
class BoardInstancesController < ApplicationController
def index
#Filter board instances to only show those the client has access to
if params[:board_type_id]
@boardtype = BoardType.find(params[:board_type_id])
@boardinstances = @boardtype.board_instances.find_all_by_client_id(current_user.client_id)
else
... |
require 'test_helper'
class PasswordJsonRetrievalTest < ActionDispatch::IntegrationTest
def test_view_expiration
post passwords_path(format: :json), params: { :password => { payload: "testpw", expire_after_views: 2 }}
assert_response :success
# Push a password with two views
res = JSON.parse(@respon... |
# frozen_string_literal: true
require_relative "../../shared/predicate"
RSpec.describe "predicates" do
let(:input) { described_class }
describe :key? do
let(:expression) { ->(*) { key?(:speed) } }
describe "success" do
let(:output) { true }
describe({speed: 100}) do
it_behaves_like ... |
#### 1. Use Ruby to loop over this array, multiplying each element by 2.
tempArray = [1, 2, 6, 9, 3, 21]
newArray = []
tempArray.each {|item| newArray << (item * 2) }
p newArray
#### 2. From all the built in Ruby methods we've seen in class this week, choose three that you think are particularly helpful and create... |
# frozen_string_literal: true
require 'spec_helper'
require 'bolt/puppetdb/config'
require 'bolt/util'
describe Bolt::PuppetDB::Config do
context "with boltdir available" do
let(:cacert) { File.expand_path('relative/to/cacert') }
let(:token) { File.expand_path('relative/to/token') }
let(:boltdir) { '~/d... |
class AddActionToBadges < ActiveRecord::Migration
def change
add_column :badges, :action, :text
add_index :badges, :action, unique: true
end
end
|
class OrganizationSerializer
include FastJsonapi::ObjectSerializer
attributes :name, :street_1, :city, :state, :zip, :short_name
attribute :active_teams do |object|
if object.teams.active.empty?
"No active teams currently!"
else
object.teams.active.map do |team|
TeamSerializer.new(t... |
# https://github.com/rails/rails/pull/9705
module ActiveRecord
module Associations
class CollectionProxy
def respond_to?(name, include_private = false)
if super
true
elsif [:marshal_dump, :_dump].include?(name)
false
else
(load_target && target.respond_t... |
class SlocationsController < ApplicationController
before_action :set_slocation, only: [:show, :edit, :update, :destroy]
# GET /locations
# GET /locations.json
def index
@slocations = Slocation.all.order("ascii(name)")
end
# GET /locations/1
# GET /locations/1.json
def show
end
# GET /locatio... |
class LabelsController < ApplicationController
def create
@label = Label.new(label_params)
respond_to do |format|
format.json do
if @label.save
task = Task.find_by_id(params[:task_id])
task.labels << @label
render :json => task.labels
else
render ... |
require_relative('../db/sql_runner')
require_relative('./transaction.rb')
class Merchant
attr_reader :id
attr_accessor :name, :logo, :active
def initialize(options)
@id = options['id'].to_i if options['id']
@name = options['name']
@logo = options['logo'] if options['logo']
@active = options['ac... |
class TransactionReview < ApplicationRecord
belongs_to :reviewer, class_name: 'User'
belongs_to :target, class_name: 'User'
end
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.