text
stringlengths
10
2.61M
# frozen_string_literal: true module GraphQL module Pagination # A schema-level connection wrapper manager. # # Attach as a plugin. # # @example Adding a custom wrapper # class MySchema < GraphQL::Schema # connections.add(MyApp::SearchResults, MyApp::SearchResultsConnection) # ...
# 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 AddCanceledByAdminToPickUps < ActiveRecord::Migration def change add_column :pick_ups, :canceled_by_admin, :boolean, default: false end end
module CamaleonCms class UserRole < CamaleonCms::TermTaxonomy after_destroy :set_users_as_cilent default_scope { where(taxonomy: :user_roles) } belongs_to :site, class_name: 'CamaleonCms::Site', foreign_key: :parent_id, required: false def roles_post_type get_meta('_post_type') end d...
require File.join(File.expand_path(File.dirname(__FILE__)), '..', 'test_helper') class MediasHelperTest < ActionView::TestCase def setup super @request = ActionController::TestRequest.new @request.host = 'foo.bar' @request end test "should get embed URL" do @request.path = '/api/medias.html...
require "rails_helper" RSpec.describe WasteExemptionsShared::OrganisationType::Individual, type: :model do describe "#name" do context "when fields_being_updated does not contain :name" do it { is_expected.to_not validate_presence_of(:name) } end context "when fields_being_updated contains :name" d...
require 'active_support' require 'active_support/core_ext' class Medjool::Parser attr_reader :context def initialize(context = {}) @context = context end def is_date_range?(text) Medjool::DATE_RANGE_MATCHER.match(text.strip).present? end def parse_date_range(text) if bits = Medjool::DATE_RA...
Rails.application.routes.draw do devise_for :users # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html resources :users resources :posts do resources :comments, :chars end get '/' => "posts#index" end
class Stages < ActiveRecord::Migration def change create_table :stages do |t| t.integer :game_id t.integer :stage_num t.string :status t.string :map t.string :theme t.integer :clear_time t.integer :clear_step t.integer :score t.timestamps null: false end ...
=begin #V4 Online API #No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) OpenAPI spec version: v4 Generated by: https://github.com/swagger-api/swagger-codegen.git Swagger Codegen version: 2.4.15 =end require 'uri' module RentCentric class LocationApi attr_...
class RemovePostIdFromTags < ActiveRecord::Migration[6.0] def change remove_index :tags, :post_id remove_column :tags, :post_id, :string end end
class Image < ActiveRecord::Base attr_accessible :url, :remote_url_url belongs_to :imageable, polymorphic: true mount_uploader :url, PostImagesUploader end
class AddProfileTypeToProfiles < ActiveRecord::Migration[5.1] def change remove_column :profiles, :type, :string add_column :profiles, :profile_type, :string end end
class RemoveDriverFromUsers < ActiveRecord::Migration def change remove_column :users, :driver, :boolean end end
Pod::Spec.new do |s| s.name = 'BothamUI' s.version = '2.0.0' s.license = 'Apache V2' s.summary = 'Model View Presenter Framework written in Swift' s.homepage = 'https://github.com/Karumi/BothamUI' s.social_media_url = 'http://twitter.com/goKarumi' s.authors = {'Karumi' => 'hello@karumi.com' ...
module RepresentativeImageHelper require 'net/http' # Generates HTML for either a cover image or format # icon, based on the requested side and identifiers from # the Solr document def display_representative_image(document, full_size=false ) unless representative_image_path(document, 'L').ni...
require "application_system_test_case" class GenresSongsTest < ApplicationSystemTestCase setup do @genres_song = genres_songs(:one) end test "visiting the index" do visit genres_songs_url assert_selector "h1", text: "Genres Songs" end test "creating a Genres songs" do visit genres_songs_url...
class Action < ActiveRecord::Base attr_accessor :automatic_modification belongs_to :user enum action_type: { standard: 0, notifier: 1 } validate do |action| if computed_feed_ids.empty? && self.automatic_modification.blank? self.errors[:base] << "Please select at least one feed or tag" end end...
class AddColumngIDtogallery < ActiveRecord::Migration def change add_column :galleries, :gid, :integer end end
class User < ActiveRecord::Base before_save :generate_token self.include_root_in_json = true has_many :events, dependent: :destroy has_many :relationships, foreign_key: "follower_id", dependent: :destroy has_many :followed_events, through: :relationships, source: :being_followed #has_many :user_relationships,...
require "bundler/setup" require 'podio' require 'basecamp' require 'state_machine' module Sherpa class << self def setup(basecamp, podio) Sherpa.setup_basecamp(basecamp[:url], basecamp[:token]) Sherpa.setup_podio(podio) end def setup_basecamp(url, token) Basecamp. establish_con...
class DeleteProfileColumnMobilePhoneUnique < ActiveRecord::Migration[5.0] def change remove_index(:profiles, :mobile_phone) end end
require "uri" module Guisso def self.trusted_resource(url, user_email) TrustedResource.new(url, user_email) end def self.oauth_client guisso_uri = Guisso.uri Rack::OAuth2::Client.new( identifier: Guisso.client_id, secret: Guisso.client_secret, host: guisso_uri.host, port: gu...
class Pet < ApplicationRecord belongs_to :localization belongs_to :user validates :name, presence: true validates :breed, presence: true validates :gender, presence: true validates :description, presence: true validates :avatar, presence: true end
#encoding: utf-8 class Setting < Settingslogic source "#{Rails.root}/config/config.yml" namespace Rails.env load! if Rails.env.development? CACHE_PREFIX = 'rq_' def cache_get(key) Redis::Objects.redis.get(CACHE_PREFIX + key) end def cache_set(key, value, expire) Redis::Objects.redis.set(CACHE_PR...
#Blackjack! ##Objective #Practice contional logic including nested conditionals. #Use methods to keep our code DRY. ##Instructions #We are going to build a command line blackjack game. A player gets dealt two cards which have values between 1-11. After they get dealt two cards you should show them the total score ...
class ScheduledRidesController < ApplicationController before_action :authenticate_user! def new #show scheduled ride form end def create scheduled_ride = current_user.scheduled_rides.create!(scheduled_rides_params) PropagateRidesJob.perform_later(scheduled_ride) render json: { message: 'sched...
################################################################################ require('minitest/autorun') ################################################################################ module ExceptionBasics; end ################################################################################ class ExceptionBasi...
FactoryGirl.define do factory :task, :class => Task do name {"This is a factoried task."} factory :completed_task, :class => Task do ignore do completed_at Time.now end end end end
class CreateDocumentGrades < ActiveRecord::Migration def change create_table :document_grades do |t| t.references :document, index: true, foreign_key: true, null: false t.references :grade, index: true, foreign_key: true, null: false t.timestamps null: false end add_index :document_grad...
class FontGlowSansTcCondensed < Formula version "0.93" sha256 "3ebe0b46abecd7a0f8d6232dd310205c38ab3d30ab624bdba18fae591bfd5d50" url "https://github.com/welai/glow-sans/releases/download/v#{version}/GlowSansTC-Condensed-v#{version}.zip" desc "Glow Sans TC Condensed" homepage "https://github.com/welai/glow-san...
class CreateLeaveGroupEmployees < ActiveRecord::Migration def self.up create_table :leave_group_employees do |t| t.references :leave_group t.references :employee t.string :employee_type t.timestamps end add_index :leave_group_employees, [:leave_group_id] add_index :leave_group...
module Rool class Blank < Basic def process(dataset) super # Optional method to return blank if value is nothing but white space if dataset[@data_key].is_a?(String) if dataset[@data_key].strip == '' self.instance_variable_set(:@result, true) return true end end if d...
require 'rails_helper' describe CamaleonCms::UploaderHelper do init_site before do @path = "#{CAMALEON_CMS_ROOT}/spec/support/fixtures/rails_tmp.png" FileUtils.cp("#{CAMALEON_CMS_ROOT}/spec/support/fixtures/rails.png", @path) end it 'upload a local file' do expect(upload_file(File.open(@path)).key...
# == Schema Information # # Table name: games # # id :bigint(8) not null, primary key # player :string(255) # over :boolean default(FALSE) # won :boolean default(FALSE) # created_at :datetime not null # updated_at :datetime not null # class GameSe...
# 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 rake db:seed (or created alongside the db with db:setup). # # Examples: # # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) # Mayor.create(name: 'Emanuel...
class AddColumnTflIdToEmployee < ActiveRecord::Migration def change add_column :employees, :tfl_id, :integer add_index :employees, :tfl_id end end
require 'spec_helper' describe Elaios do it 'has a version number' do expect(Elaios::VERSION).not_to be nil end end
module JotForm class APIMethod attr_reader :api class << self # Usage: # # class Form < APIMethod # has :title # has :align # has :uglyName, alias: :cool_name # # # ... # end # # Form.new.title #=> ... # ...
require 'rails_helper' RSpec.describe 'Projects API', type: :request do let(:user) { create(:user) } let!(:projects) { create_list(:project, 10, user_id: user.id) } let(:user_id) { user.id } let(:id) { projects.first.id } describe 'GET /api/v1/users/:user_id/projects' do before { get "/api/v1/users/#{us...
require 'spec_helper' require 'open3' require 'pry' require 'yaml' require 'fileutils' CMD = "ruby lib/make_dir.rb".freeze ROOT_PATH = "test" STATE_DIR_INFO = "install/.flow/state-dir.yml" def set_cmd(file) cmd = "#{CMD} #{ROOT_PATH} #{file}" _,err,status = Open3.capture3(cmd) end def get_dirs chk_dirs = YAML....
class CreateListComments < ActiveRecord::Migration def change create_table :list_comments do |t| t.references :comment t.text :content t.text :link t.timestamps end add_index :list_comments, :comment_id end end
require "spec_helper" RSpec.feature 'Rate calculator system', type: feature do let(:path) { File.dirname(__FILE__) } let(:market_data) do File.join(path, "../support/fixtures/market_data.csv") end let(:invalid_data) do File.join(path, "../support/fixtures/invalid_data.csv") end let(:invalid_heade...
require 'rails_helper' RSpec.describe Amount, type: :model do context "when instantiating" do it "is valid with a properly formed value" do amount = Amount.new(value: 123.00) expect(amount).to be_valid end it "is valid with a value equal to 999999.99" do amount = Amount.new(value: 99...
ResumeTracker::Application.routes.draw do resources :users do resources :candidates, only: :index end resources :statuses do resources :candidates, only: :index end resources :sources resources :candidates root :to => 'candidates#index' end
Rails.application.routes.draw do root 'admin_panel#index' resources :admin_panel, only: [:index] resources :products resources :categories do collection do get 'report' end end end
# frozen_string_literal: true module GraphQL module Tracing module ScoutTrace include PlatformTrace INSTRUMENT_OPTS = { scope: true } # @param set_transaction_name [Boolean] If true, the GraphQL operation name will be used as the transaction name. # This is not advised if you run more...
# frozen_string_literal: true module WhatsupGithub VERSION = '0.4.2' end
require_relative '../lib/app' include Pdfsp describe App do let(:app) do result = App.new(settings: settings, options: options) allow(result).to receive(:pdftk_present?).and_return(true) result end describe '#destdir' do context 'when options contains cloudfile' do let(:options) { {cloudfile: nil} } ...
#! /usr/bin/ruby # # sampleRead.rb # # Copyright (c) 2016 - Ryo Kanno # # This software is released under the MIT License. # http://opensource.org/licenses/mit-license.php # require_relative "SAMReader.rb" require "optparse" Version="1.0.1" banner = "Usage: sampleRead.rb [option] <input SAM file>\n+Sample read for te...
class CreateCategoriesItems < ActiveRecord::Migration def change create_table :categories_items do |t| t.integer :category_id, :item_id t.timestamps null: false end add_index :categories_items, [:category_id, :item_id] end end
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:= # Extended Random Encounters (ERE) # Author: Kread-EX # Version 1.0 #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:= #----------------------------------------------------------------------------------------...
require 'spec_helper' describe Api::V1::MoviesController do describe "GET 'index'" do subject { get :index, params.merge(format: :json) } before { Tmdb::Movie.stub(:find) { movies } } let(:movies) { FactoryGirl.build_list(:tmdb_movie, 2) } let(:params) { { } } it_behaves_like "an endpoing requir...
class CharactersController < ApplicationController get '/characters/new' do if !Helper.logged_in?(session) redirect '/' end erb :"characters/new" end get '/characters/:id' do if !Helper.logged_in?(session) redirect '/' end @character = Character.find_by_id(params[:id]) @ow...
class RenameMenuCategoryIdToBranchMenuCategory < ActiveRecord::Migration def change rename_column :menu_categories_menu_items, :menu_category_id, :branch_menu_category_id end end
require 'pry'; module TeamStatistics def create_team_hash(team) {"team_id" => team.team_id, "franchise_id" => team.franchiseid, "team_name" => team.teamname, "abbreviation" => team.abbreviation, "link" => team.link} end def find_team(team_id) teams.find { |team| team....
class Show < ActiveRecord::Base has_many :reviews, foreign_key: :movie_id def rating rating = Review.where(movie_id: self.id).where('rating is not null').average(:rating) if !rating.nil? return rating.round(2) else return 'No ratings yet' end end end
class Department < ActiveRecord::Base # has_many :students # has_many :faculties end
# # Model komentarzy # # Komentarz posiada klucz obcy do zdjęcia, którego dotoczy. # Akceptowane są tylko pola :author i :content. # # Wymagane pola: author, content, photo # # class Comment < ActiveRecord::Base belongs_to :photo attr_accessible :author, :content validates_presence_of :author, :message => 'Auth...
Rails.application.routes.draw do post '/auth/login', to: 'authentication#login' get '/students/:id/services', to: 'students#services' get '/payroll', to: 'payroll#index' resources :admins resources :employees do resources :absences, module: :employees, only: :create end resources :holders do reso...
class ApplicationController < ActionController::Base protect_from_forgery with: :exception before_action :authenticate_user!, except: :home def home redirect_to emails_path if user_signed_in? end end
################################################################################ require('minitest/autorun') require('yaml') ################################################################################ module Structuring ############################################################################## module Sim...
class PlacesController < ApplicationController before_action :logged_in_user before_action :correct_user, only: [:destroy, :toggle_visited] before_action :admin_user, only: [:index] def index @places = Place.all end def create @travelist = Travelist.find(params[:travelist_id]) @place = @travelist.pl...
# frozen_string_literal: true module GraphQL class Schema # Subclasses of this can influence how {GraphQL::Execution::Interpreter} runs queries. # # - {.include?}: if it returns `false`, the field or fragment will be skipped altogether, as if it were absent # - {.resolve}: Wraps field resolution (so ...
class Cart < ActiveRecord::Base belongs_to :user belongs_to :billing_address, :class_name => 'Address', :foreign_key => :billing_address_id accepts_nested_attributes_for :billing_address belongs_to :shipping_address, :class_name => 'Address', :foreign_key => :shipping_address_id accepts_nested_attributes_...
class User < ActiveRecord::Base # Include default devise modules. Others available are: # :confirmable, :lockable, :timeoutable and :omniauthable devise :database_authenticatable, :registerable, :confirmable, :recoverable, :rememberable, :trackable, :validatable has_many :articles, dependent: :destroy...
class AddDateToBirthdayParty < ActiveRecord::Migration def change add_column :birthday_parties, :date, :date add_index :birthday_parties, [:user_id, :date], unique: true end end
class EmployeeDetail < ApplicationRecord audited acts_as_paranoid belongs_to :employee belongs_to :field validates_presence_of :field_id, :value scope :show_on_profile, -> { joins(:field).merge(Field.show_on_profile) } scope :editable, -> { joins(:field).merge(Field.editable) } end
require 'qiniu' require 'qiniu/http' require 'qiniu/config' module Qiniu class << self def list_prefix bucket, prefix, marker, limit uri = get_prefix_uri bucket, prefix, marker, limit HTTP.management_post(uri) end def get_prefix_uri bucket, prefix = nil, marker = nil, limit = nil uri = ...
require 'colorize' @life_1 = 3 @life_2 = 3 puts "Enter name for player 1" student_1_name = gets.chomp puts "Enter name for player 2" student_2_name = gets.chomp @player_count = 0 @num_1 = 0 @num_2 = 0 @operation = 0 @answer = "yes" def generate_question @operation = rand(3) @num_1 = rand(20) + 1 ...
Pod::Spec.new do |s| s.name = 'aircast' s.version = '1.0.2' s.summary = 'airplay mirroring and airplay casting' s.homepage = 'https://github.com/AirCastLab' s.author = { 'LianXiang Liu' => 'leeoxiang@gmail.com' } s.source = { :git => 'https://github.com/AirCastLab/ai...
RSpec::Matchers.define :have_delete_table_permission do match do |glue| glue.has_delete_table_permission?(database: @database, table: @table) end chain :on_database do |database| @database = database end chain :for_table do |table| @table = table end end
require 'spec_helper' describe StoriesController do let(:user) { FactoryGirl.create(:user) } before {sign_in user} describe "GET #index" do let(:story) { FactoryGirl.create(:story, user: user) } it "can GET 'index'" do get :index response.should be_success end it "populates an ar...
class AddStartsDefaultAgainToDeals < ActiveRecord::Migration def change change_column :deals, :starts, :datetime end end
class CreateSchedules < ActiveRecord::Migration[5.2] def change create_table :schedules do |t| t.string :day t.time :start_time t.time :end_time t.string :location t.boolean :open t.references :truck, foreign_key: true t.timestamps end end end
# frozen_string_literal: true module FuelSurcharge VERSION = "1.2.3" end
# frozen_string_literal: true # This is the base class for the separate controllers for each category: # Events::EventsController # Events::CoursesController # Events::SeminarsController # # No route should point to this controller directly. Security is handled by each # sub-controller, as appropriate. class EventCont...
class AddDadToMicroposts < ActiveRecord::Migration def change add_column :microposts, :dad, :integer, :default => 0 end end
class Offer < ActiveRecord::Base # relationships belongs_to :branch end
class InnerGroup < ApplicationRecord belongs_to :model belongs_to :parts_group has_many :parts end
class SitesController < ApplicationController def index @recommend_products = Product.recommend.limit(8) end end
Rails.application.routes.draw do # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html root to: 'home#index' devise_for :users, skip: :registrations devise_scope :user do resource :registration, only: [:new, :create], path: 'users', path_names...
=begin #Further Exploration =end class Pet attr_reader :name def initialize(name) @name = name.to_s end def to_s "My name is #{@name.upcase}." end end name = 42 fluffy = Pet.new(name) name += 1 puts fluffy.name puts fluffy puts fluffy.name puts name # Instance variable @name is pointing to a Stri...
# frozen_string_literal: true require 'json' module Readapt module Adapter # @!parse include Backport::Adapter @@debugger = nil def self.host debugger @@debugger = debugger end def format result write_line result.to_protocol.to_json end def opening @@debugger.add_ob...
class AddGmapColToMarket < ActiveRecord::Migration def change add_column :markets, :gmaps, :boolean end end
class Appointment attr_accessor :date, :patient, :doctor @@all = [] #knows about all appointments that have been created def initialize(date, patient, doctor) #initializes with a date, patient, and doctor @date = date @patient = patient #belongs to a patient @doctor = doctor #belo...
module UserConcerns module MultiplierLearningTracks extend ActiveSupport::Concern included do has_many :learning_cycles has_many :learning_tracks, through: :learning_cycles alias :cycles :learning_cycles alias :tracks :learning_tracks has_and_belongs_to_many :moderate_learnin...
# frozen_string_literal: true Given(/^I am on the Product Page$/) do @driver.get 'http://www.saucedemo.com/v1/inventory.html' end When(/^I add (.*) items$/) do |number| number.to_i.times { @driver.find_element(class: 'btn_primary').click } end Then(/^I should see (.*) items? in the cart$/) do |number| expect(@...
class AddColumnSkipAccessibilityCheckToSections < ActiveRecord::Migration def change add_column :sections, :skip_accessibility_check, :boolean, default: false end end
require_relative '../../../../spec_helper' describe "govuk_rbenv::install_ruby_version", :type => :define do let(:title) { '2.5.1' } it { is_expected.to contain_rbenv__version(title) } context "when with_foreman is true" do let(:params) { { :with_foreman => true } } it do is_expected.to contain_...
class AdminsController < ApplicationController before_action :set_advisor_user, only: [:show, :edit, :update, :destroy, :editlogin, :changelogin, :changepassword, :editpassword] def index @admin = Admin.all end def new @admin = Admin.new end def show end def edit end # redirects to admins...
require_relative 'AiModel' require_relative 'AiSimulation' require_relative 'CasinoEngine' require_relative 'PokerCard' require_relative 'PokerDeck' require_relative 'PokerHandEvaluator' def testEvaluatingHands handEvaluator = PokerHandEvaluator.new for i in 0...10 deck = PokerDeck.new hand = deck.dealHand(5) ...
module ConvertProcessStatus STARTING = 'Iniciando' RUNNING = 'Executando' CANCELED = 'Cancelado' FINISHED = 'Finalizado' ERROR = 'Erro' ALL = [STARTING, RUNNING, CANCELED, FINISHED, ERROR] end
class AddInventoryToTools < ActiveRecord::Migration[5.0] def change add_column :tools, :inventory, :integer, default: 1 end end
class PlexMediaServer < Cask url 'http://plex.r.worldssl.net/PlexMediaServer/0.9.7.9.375-d056f10/PlexMediaServer-0.9.7.9.375-d056f10-OSX.dmg' homepage 'http://plexapp.com' version '0.9.7.9.375' sha1 'c62657773f71203e64d92cb951f4d5825286d360' end
class LevelGoalsController < ApplicationController # GET /level_goals # GET /level_goals.json def index @level_goals = LevelGoal.all respond_to do |format| format.html # index.html.erb format.json { render json: @level_goals } end end # GET /level_goals/1 # GET /level_goals/1.json ...
# frozen_string_literal: true # Write a string to a file. Puppet::Functions.create_function(:'file::write') do # @param filename Absolute path. # @param content File content to write. # @example Write a file to disk # file::write('C:/Users/me/report', $apply_result.first.report) dispatch :write do requ...
# == Schema Information # # Table name: users # # id :integer not null, primary key # email :string(255) default(""), not null # encrypted_password :string(255) default(""), not null # reset_password_token :string(255) # reset_password_sent_at :datetime...
class Work::DiseasesController < Admin::BaseController before_action :set_disease, only: [:show, :edit, :update, :destroy] # GET /diseases # GET /diseases.json def index @q = SearchParams.new(params[:search_params] || {}) search_params = @q.attributes(self) @diseases = Disease.default_where(search_...
Rails.application.routes.draw do # Redirects incoming requests to "controllers" and "actions". # Defines the "actions" available in the app and the type of "action" (e.g. "get"), # which are defined as "methods" in the "Controller" class, # as well as the "routes" for these "actions". get 'recipes/index' ...