text
stringlengths
10
2.61M
class FontMuktaMalar < Formula head "https://github.com/google/fonts.git", verified: "github.com/google/fonts", branch: "main", only_path: "ofl/muktamalar" desc "Mukta Malar" homepage "https://fonts.google.com/specimen/Mukta+Malar" def install (share/"fonts").install "MuktaMalar-Bold.ttf" (share/"fonts"...
require 'context-io/error' module ContextIO # Raised when Context.IO returns a 4xx HTTP status code # # @api public class Error::ClientError < ContextIO::Error end end
class AddGalleryIdIndexToPictures < ActiveRecord::Migration[5.0] def change add_index :pictures, :gallery_id end end
# frozen_string_literal: true require "active_support/core_ext/object/blank" require "spec_helper" require "mindbody/configuration" RSpec.describe Mindbody::Configuration do describe "#site_ids" do it "is an empty Array by default" do config = described_class.new expect(config.site_ids).to eq [] ...
class TLD class PseudoTld < TLD def type :pseudo end class BITNET < PseudoTld #:nodoc: self.tld = %q{bitnet} end class CSNET < PseudoTld #:nodoc: self.tld = %q{csnet} end class LOCAL < PseudoTld #:nodoc: self.tld = %q{local} end class ROOT < PseudoTld #:nodo...
class AddIndexToDice < ActiveRecord::Migration[5.2] def change add_index :dices, [:e_no, :result_no, :generate_no], :unique => false, :name => 'resultno_and_e_no' add_index :dices, :number add_index :dices, :dice add_index :dices, :use_item end end
class Book < ActiveRecord::Base belongs_to :reviewer has_many :notes end
# == Schema Information # # Table name: pictures # # id :integer not null, primary key # name :string(255) # animal_id :integer # created_at :datetime # updated_at :datetime # image_uid :string(255) # image_name :string(255) # external_url :string(255) # class Picture < A...
# Copyright 2018 Akamai Technologies http://developer.akamai.com. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # http://www.apache.org/licenses/LICENSE-2.0 # Unless required by applic...
# frozen_string_literal: true RSpec::Matchers.define :have_cell do |value: nil, match: nil, column:, record:| include ActionView::RecordIdentifier match do |table| return error('The :have_cell matcher requires a RemoteDatatables as object') unless table.is_a? RemoteDatatable record_id = dom_id(record) ...
class ImageValidator < ActiveModel::Validator def validate(record) record.errors.add(:base, "Deal must have atleast one image.") if record.deal_images.blank? end end
class ItemsController < ApplicationController before_action :authenticate_user! before_action :authorize_user def create @item = @list.items.build(item_params) @item.user = @list.user if @item.save flash[:notice] = "New item created" redirect_to user_list_path(@list.user, @list) ...
module ScriptNotifier module Services class Sms attr_reader :address include Services::Base def deliver! @address = payload[:address] begin if success message = "StillAlive PASS: Your script #{script_name} for site #{site_name} is now passing" e...
class AddColumnStatusToDriver < ActiveRecord::Migration[5.1] def change add_column(:drivers, :available, :boolean,{null: true, default: true}) end end
class Author attr_accessor :name def initialize @name = "Hillary" end end
#!/usr/bin/env ruby -wKU class Pixel attr_accessor :r, :g, :b, :o HexBase = 16 def initialize r=0, g=0, b=0, o=0 @r = r @g = g @b = b @o = o end def self.createFromMagickPixel pixel Pixel.new pixel.red, pixel.green, pixel.blue, pixel.opacity end def self.colour_hex tone=0 ...
module BuildKit module Utilities module Assertions def self.assert_files_exist files files.each do |file| BuildKit::Utilities::Console.terminate_with_err "Missing File: #{file} does not exist" unless File.exists? file end end def self.assert_required_config req_key...
class ApplicationController < ActionController::Base before_action :validate_headers! before_action :authenticate! def validate_headers! respond_with_error I18n.t('user.errors.invalid_headers') unless device_id end def authenticate! render text: '', status: 401 and return unless current_user end ...
require 'sinatra' require 'json' # From https://12factor.net/ $rules = [ "Codebase: One codebase tracked in revision control, many deploys", "Dependencies: Explicitly declare and isolate dependencies", "Config: Store config in the environment", "Backing Services: Treat backing services as attached resources",...
class DeleteColumnsFromUsers < ActiveRecord::Migration[5.2] def change remove_column :users, :password remove_column :users, :image_path end end
require 'rubygems' require 'puppetlabs_spec_helper/rake_tasks' require 'puppet-lint/tasks/puppet-lint' require 'puppet-syntax/tasks/puppet-syntax' require 'pathname' # require 'ci/reporter/rake/rspec' require 'puppet_blacksmith/rake_tasks' require 'yard' desc "Run the tests" RSpec::Core::RakeTask.new(:test) do |t| t...
require 'rails_helper' RSpec.describe 'Books API', type: :request do let!(:publisher) { create(:publisher) } let!(:book) { create(:book, publisher: publisher) } let!(:shop) { create(:shop) } describe 'PATCH /api/v1/shops/:shop_id/books/:id' do let(:patch_attributes) { { book: { copies: 2 } } } contex...
require 'rails_helper' RSpec.describe Api::V1::ContractsController, type: :controller do render_views include_context "shared parties" describe '#create' do it 'render json with code 200' do post :create, { contract: valid_attributes }.to_json, access_token: user.token expect...
class AircraftClassesController < ApplicationController before_filter :authenticate # GET /aircraft_classes # GET /aircraft_classes.xml def index @aircraft_classes = AircraftClass.all respond_to do |format| format.html # index.html.erb format.xml { render :xml => @aircraft_classes } en...
# Choder - TCP Chat Server # # 20150511 - ThothLogos # require 'socket' class Server def initialize(address, port) @server = TCPServer.open(address, port) @connections = Hash.new @rooms = Hash.new @clients = Hash.new @connections[:server] = @server @connections[:rooms] = @rooms @connect...
# 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 Artist < ActiveRecord::Base has_many :created_activities, class_name: 'Activity', foreign_key: :creator_id, inverse_of: :creator has_many :received_activities, class_name: 'Activity', foreign_key: :receiver_id, inverse_of: :receiver end
require 'spec_helper' describe Record do let(:flat_file) { Flat::File } describe Record::Definition do before do flat_file.reset_file_data end it 'creates a new instance' do record = Record::Definition.new flat_file, {}, 12 expect( record.line_number ).to eq( 12 ) expect( rec...
class Product < ActiveRecord::Base validates :description, :name, :presence => true validates :price_in_pence, :numericality => { :only_integer => true } has_many :reviews has_many :users, :through => :reviews def formatted_price price_in_pounds = price_in_pence.to_f / 100 sprintf...
Rails.application.routes.draw do root 'books#index' resources :books do get 'search' end end
class Event < ActiveRecord::Base has_many :plate_editions has_many :plates, :through => :plate_editions validates_presence_of :name, :start_time, :end_time validate :end_time_cannot_be_earlier_than_start_time after_save :set_plate_edition_times, :clear_cache include StartsAndEndsByDateHour class << s...
class AddReferenceToZillowReportHomeValuationFromHouse < ActiveRecord::Migration[5.2] def change add_column :zillow_report_home_valuations, :zpid, :string add_index :zillow_report_home_valuations, :zpid end end
class MomentumCms::Admin::BaseController < ApplicationController layout 'momentum_cms/admin/application' include MomentumCms::I18nLocale include MomentumCms.configuration.admin_authentication.to_s.constantize before_action :authenticate, :load_sites, :load_site, ...
module Substation # The environment holding all registered {Chain} processors class Environment include Equalizer.new(:registry) include Adamantium::Flat # Build a new {Environment} instance # # @param [Proc] block # a block to be instance_eval'ed with {DSL} # # @return [Environ...
class CreateManagedFiles < ActiveRecord::Migration class << self def up create_table :managed_files, :force => true do |t| t.column "content_type", :string t.column "filename", :string t.column "size", :integer t.column "db_file_id", :integer # only for db files (optiona...
class RankingUser < ApplicationRecord validates :name, :points, presence: true scope :sorted, -> { order(points: :desc) } end
# frozen_string_literal: true module Requests module JsonHelpers def json_data response_body['data'] end def json_attributes response_body['data']['attributes'] end def pagination_links response_body['links'] end private def response_body JSON.parse(response...
class Watch attr_accessor :profile, :created_at, :watched_profile def initialize(options = {}) @profile = options.delete(:profile) @created_at = options.delete(:created_at) @watched_profile = options.delete(:watched_profile) end end
CkContact::Application.routes.draw do namespace :settings do get "profile", :to => "profile#edit" put "profile", :to => "profile#update" get "account", :to => "account#edit" put "account", :to => "account#update" get "avatar", :to => "avatar#edit" put "avatar", :to => "avatar#update" end ...
require_relative '../action' class Screenplay module Actions class Subversion < Screenplay::Action def initialize( repository: repository, destination: destination, binary: '/usr/bin/env svn', on_fail: nil ) @destination = destination @on_fail = on_fai...
require 'test_helper' class EpropsControllerTest < ActionController::TestCase setup do @eprop = eprops(:one) end test "should get index" do get :index assert_response :success assert_not_nil assigns(:eprops) end test "should get new" do get :new assert_response :success end tes...
ActiveAdmin.register Concert do index do selectable_column column :id column "Picture" do |concert| link_to image_tag(concert.picture.url(:thumb)), admin_concert_posts_path(concert) end column :title column :date column :venue ...
require "spec_helper" describe SessionsController do let(:user_params) do { name: 'foo', email: 'foo@bar.com', org: 'foo inc', password: 'foo', password_confirmation: 'foo' } end let(:session_params) do { email: 'foo@bar.com', password: 'foo' } end d...
class AddNatureToInterpretationAliases < ActiveRecord::Migration[5.1] def change add_column :interpretation_aliases, :nature, :integer, default: 0 end end
require 'rails_helper' describe LearnerDictionaryController, type: :controller do render_views describe 'GET index' do it 'has a 200 status code' do get :index expect(response.status).to eq 200 end it 'includes the user language setting' do get :index, 'HTTP_ACCEPT...
#! /usr/bin/ruby # # calc_coverage.rb # # Copyright (c) 2016 - Ryo Kanno # # This software is released under the MIT License. # http://opensource.org/licenses/mit-license.php # require "optparse" Version="1.1.2" banner = "Usage: calcCoverage.rb [option] <input BED file> <original BAM file>\n+calculate coverage at eac...
class AddWxExpiredAtToRedpack < ActiveRecord::Migration def change add_column :redpacks, :wx_expired_at, :date end end
class Item < ActiveRecord::Base belongs_to :user has_one :order mount_uploader :image, ImagesUploader end
module ModelSharedExamples # Objects & Errors #---------------------------------------------------------------------------- shared_examples_for "valid record" do |factory| describe "on build", :build => true do it "builds valid object" do object = FactoryGirl.build(factory).should be_valid ...
module Radriar module API module Context def context OpenStruct.new(current_user: current_user) end def id params[:id] end def create_params [permitted_params, create_handlers] end def create_handlers @create_handlers ||= { suc...
# -*- coding:binary -*- require 'spec_helper' require 'rex/image_source/disk' RSpec.describe Rex::ImageSource::Disk do let(:path) do File.join(FIXTURE_PATH, "templates", "template_x86_windows_old.exe") end let(:file) do File.new(path) end subject do described_class.new(file) end it_shoul...
require 'require_relative' if RUBY_VERSION[0,3] == '1.8' require_relative 'acceptance_helper' describe "user search" do include AcceptanceHelper before do zebra = Fabricate(:user, :username => "zebra") end it "can search for users" do visit "/users" fill_in "search", :with => "zebra" click_bu...
require 'spec_helper' # mesos master service describe 'mesos master service' do it 'should be running' do case RSpec.configuration.os when 'Debian' expect(service('mesos-master')).to be_running end end end describe port(5050) do it { should be_listening } end describe command('curl -sD - http...
Then /^All text fields are empty for the form with selector "(.*)"$/ do |form_selector| within(form_selector) do all("input[type=text]").each do |text_field| text_field.value.should be_empty end all("textarea").each do |textarea| textarea.value.should be_empty end end end Then /^I should have filled in...
=begin #=============================================================================== ** Player Manager Author: Hime Date: Aug 18, 2013 -------------------------------------------------------------------------------- ** Change log Aug 18, 2013 - initial release ------------------------------------------------...
class CreateStations < ActiveRecord::Migration[5.1] def change create_table :stations do |t| t.string :code t.string :business_name t.string :address_street t.string :address_number t.references :commune, foreign_key: true t.references :distributor, foreign_key: true t.st...
class RemoveSubbedTournamentsFromDevice < ActiveRecord::Migration def change remove_column :gcm_devices, :subbedTournaments end end
require 'rubygems' require 'twitter' class TweetFetcher def get_tweet Twitter::Search.new.hashtag(get_term).no_retweets.per_page(1).page(rand(100)).fetch.first end def get_term terms = ["juay", "juayderito"] terms[rand(terms.length)] end end
class User < ApplicationRecord has_secure_password has_many :details validates :name, presence: true validates :email, presence: true, :uniqueness => {:case_sensitive => false} # `:if => :password` - skips checking if the password is not being set; # allows easier patch/put of user informa...
require 'test_helper' class PullrequestControllerTest < ActionController::TestCase def setup @params = { channel: '@slackbot', actor: FactoryGirl.attributes_for(:user), pullrequest: FactoryGirl.attributes_for(:pullrequest), repository: FactoryGirl.attributes_for(:repository) } end ...
# welcome_stranger.rb # Create a method that takes 2 arguments, an array and a hash. The array will # contain 2 or more elements that, when combined with adjoining spaces, will # produce a person's name. The hash will contain two keys, `:title` and # `:occupation`, and the appropriate values. Your method should return ...
# Surf Forcaster by Max Helmetag # Take user input and returns the current surf info from Surfline.com require 'rubygems' require 'mechanize' require 'action_mailer' require 'pony' require 'sms_fu' def remove_html_tags(string) # Regex for stripping html from Xpath retrieved info re = /<("[^"]*"|'[^']*'|[^'">])*>/...
require 'backpack_tf/market_price/interface' require 'backpack_tf/market_price/response' module BackpackTF # Ruby representations of a JSON response to IGetMarketPrices class MarketPrice include Helpers attr_reader :last_updated attr_reader :quantity attr_reader :value # @param name [String] ...
class SpecialTotalRule def initialize(total, discount) @total = total @discount = discount end def apply(total) total > @total ? total - @discount : total end end
class DealerportalController < ApplicationController before_filter :authenticate_dealer! def new @payroll = Payroll.new end def create @payroll = Payroll.new(pay_params) if @payroll.save flash[:success] = "Payroll Created" redirect_to portal_dealers_path else render "new" end end def i...
class RemoveDefaultAvatarFromChatRooms < ActiveRecord::Migration[5.1] def change change_column :chat_rooms, :name, :string end end
class UserSession < Authlogic::Session::Base # validate :check_if_awesome # # private # def check_if_awesome # errors.add(:email, "must contain awesome") if email && !email.include?("awesome") # errors.add(:base, "You must be awesome to log in") unless attempted_record.awesome? # end end
class Milestone < ActiveRecord::Base belongs_to :project validates :project_id, presence: true validates :name, presence: true default_scope -> {order(start_day: :asc)} def self.now(project_id) binds = {project_id: project_id, today: Time.now} self.where( "project_id = :project_id AND ...
class ChangeDefaultStatusOfMerchants < ActiveRecord::Migration def up change_column_default :merchants, :status, "created" add_index :merchants, :status end def down change_column_default :merchants, :status, "pending" remove_index :merchants, :status end end
class Account < UserAccountDB include ObserveAttr # non rails conform table :/ set_table_name "map" belongs_to :user attr_readonly :barcode attr_accessible :account, :locked, :color, :barcode #validate :valid_account validates_presence_of :barcode validates_length_of :account, :maximum=>30 ...
module SupplyTeachers class Journey::FTAToPermFixedTermFee include Steppable include Dateable attribute :fixed_term_fee attribute :contract_start_date_day attribute :contract_start_date_month attribute :contract_start_date_year attribute :contract_end_date_day attribute :contract_end_...
require 'rails_helper' RSpec.describe OrderForm, type: :model do describe '商品購入機能' do before do @order_form = FactoryBot.build(:order_form) end describe '商品購入' do context '商品購入できる' do it '必須情報が全てあるとき' do expect(@order_form).to be_valid end end context '商...
module Idv class ProfileMaker attr_reader :pii_attributes def initialize(applicant:, user:, normalized_applicant:, phone_confirmed:) self.pii_attributes = pii_from_applicant(applicant, normalized_applicant) self.user = user self.phone_confirmed = phone_confirmed end def save_profil...
class OrderItem < ApplicationRecord belongs_to :product belongs_to :order end
Pod::Spec.new do |s| s.name = "U-Push-None_IDFA" s.version = "1.5.0" s.author = { "Ryan" => "253781200@qq.com" } s.summary = "UMessage Push None_IDFA." s.homepage = "http://dev.umeng.com/message/ios/sdk-download" s.ios.deployment_target = '4.3' s.source = { :git => "https...
# frozen_string_literal: true begin require "statsd" rescue LoadError $stderr.puts "In order to report Kafka client metrics to Statsd you need to install the `statsd-ruby` gem." raise end require "active_support/subscriber" module Kafka # Reports operational metrics to a Statsd agent. # # require "ka...
class Record < ApplicationRecord as_enum :group, { income: 1, expense: -1 }, source: :group monetize :amount_cents, numericality: { greater_than: 0 } belongs_to :user validates :user_id, presence: true validates :group, presence: true validates :points, presence: true validates :country_code, presence:...
class UsersController < ApplicationController helper_method :follow before_action :set_user, only: [:follow, :show] before_action :disabled, only: [:edit, :update, :destroy] def index @users = User.all end def show end def follow if @user == current_user flash[:warning] = "You cannot fol...
class CreateSubscriptionDetails < ActiveRecord::Migration[5.2] def change create_table :subscription_details do |t| t.references :subscription t.integer :units t.datetime :last_dispatched_at t.datetime :last_delivered_at t.datetime :last_payment_received_at t.decimal :last_pay...
# # Cookbook Name:: JobQueue # Recipe:: default # require 'etc' if ['solo','app_master','app'].include?(node[:instance_role]) # Install the JobQueue monit file. run_for_app('cocodot') do ey_cloud_report "JobQueue" do message "Installing JobQueue Monit Config" end template '/etc/monit.d/jobqu...
class EntriesController < ApplicationController def index @entries=Entry.all end def show @entry = Entry.find(params["id"]) end def create entry_params = params["entry"].permit("title", "contents") entry = Entry.create(entry_params) redirect_to(entry_path(entry)) end end
require 'paysafe/result' module Paysafe class SingleUseToken < Result attributes :id, :payment_token, :time_to_live_seconds, :customer_id, :status, :single_use_customer_token, :locale object_attribute :Card, :card object_attribute :Address, :billing_address end end
# frozen_string_literal: true FactoryBot.define do factory :legacy_datum do user character name { SecureRandom.uuid } xp { rand(0..999) } home_game_count { rand(0..99) } events do [ '{"event_name":" - Migration","xp_earned":3,"xp_purchased":0,"xp_converted":0,"xp_referral":0,"xp...
Rails.application.routes.draw do # For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html get 'weather', to: 'weather#index' post 'weather', to: 'weather#create' get 'weather/:id', to: 'weather#show' end
require 'rspec' require 'request' require 'Space' describe Request do describe '.accept' do it 'accept request' do space = Space.create(name: 'Shed', owner: 'Joe', availability: true, description: 'Lots of spiders', date: '2020-11-10', price: 2) accepted = Request.accept(id: space.id) expect(accepted.ava...
require 'json' config_file File.join(File.dirname(__FILE__), '.', 'omnivore_config.yml') configure do REDIS = Redis.new TIME_TO_LIVE = settings.time_to_live end get '/' do File.read(File.join('public', 'index.html')) end get '/configs' do content_type :json { "Cached item time to live" => "#{TIME_TO_LIVE.t...
# frozen_string_literal: true class PublicationStatusRenderer < Hyrax::Renderers::AttributeRenderer include DogBiscuitsHelper private def li_value(value) link_to(ERB::Util.h(publication_status_label(value)), search_path(value)) end def search_path(value) Rails.application.rout...
STATUS= { open: 0, closed: 1, active: 2 }.freeze
class AddLongitubeToProfiles < ActiveRecord::Migration[5.1] def change add_column :profiles, :longitude, :decimal end end
class User < ActiveRecord::Base #attr_accessor :name, :email, :password, :password_confirmation has_secure_password before_save {self.email.downcase!} before_save :create_remember_token validates :name, presence: true, length: {maximum: 50} VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i validates ...
class CreateArchivedEmployeeSalaryStructureComponents < ActiveRecord::Migration def self.up create_table :archived_employee_salary_structure_components do |t| t.references :archived_employee_salary_structure t.references :payroll_category t.string :amount t.timestamps end end def ...
# Generated via # `rails generate hyrax:work GenericWork` module Hyrax # Generated form for GenericWork class GenericWorkForm < Hyrax::Forms::WorkForm self.model_class = ::GenericWork self.terms = [:title, :creator, :contributor, :description, :resource_type, :keyword, :based_near, :...
class ChangeColumnName < ActiveRecord::Migration[5.0] def change rename_column :users, :name, :fullname end end
module Shared::PaymentStateMachineHandler extend ActiveSupport::Concern included do state_machine :state, initial: :pending do state :pending state :waiting_confirmation state :confirmed state :canceled state :refunded state :requested_refund state :refunded_and_cancel...
module Auditlog class Tracker def self.track_changes(model, options) meta = options[:meta] column_names = model.class.column_names.collect { |col| col.to_sym } only = options[:only] || column_names notify = options[:notify] || {} except = [:id, :updated_at, :created_at] + (options[:e...
# Organizations can remind Partners when their deadlines are for putting in their requests class AddReminderDateAndDeadlineDateToOrganizations < ActiveRecord::Migration[5.2] def change add_column :organizations, :reminder_days_before_deadline, :integer add_column :organizations, :deadline_date, :integer end...
require 'Set' class Knight < Piece def possible_moves moves = Set.new file = Piece::HOR_POS.index(self.position[0]) + 1 rank = self.position[1].to_i moves.add("#{Piece::HOR_POS[(file + 2) - 1]}#{rank + 1}") unless invalid_file?((file + 2) - 1) moves.add("#{Piece::HOR_POS[(file + 2) - 1]}#{rank -...
class CreateTestcases < ActiveRecord::Migration[5.0] def change create_table :testcases do |t| t.string :description t.string :ebarcode t.string :mediaformat t.string :priority t.string :externalid t.string :requestorid t.string :startdate t.string :duedate t....
class Item < ApplicationRecord belongs_to :list validates_presence_of :item_name # excluding description & priority because user has the option to edit the item and add description and/or priority if user chooses to end
class FontInfini < Formula version "1.003" url "http://www.cnap.graphismeenfrance.fr/infini/en/download/Infini-cnap-engl_fonts-specimen-v2.zip" desc "Infini" homepage "http://www.cnap.graphismeenfrance.fr/infini/en/" def install parent = File.dirname(Dir.pwd) != (ENV['HOMEBREW_TEMP'] || '/tmp') ? '../' :...