hexsha stringlengths 40 40 | size int64 2 1.01M | content stringlengths 2 1.01M | avg_line_length float64 1.5 100 | max_line_length int64 2 1k | alphanum_fraction float64 0.25 1 |
|---|---|---|---|---|---|
33ef2c634965ea818a76e36036b0dedde4108faa | 1,564 | require_relative 'boot'
require "rails"
# Pick the frameworks you want:
require "active_model/railtie"
require "active_job/railtie"
require "active_record/railtie"
require "action_controller/railtie"
# require "action_mailer/railtie"
require "action_view/railtie"
# require "action_cable/engine"
require "sprockets/rail... | 31.918367 | 82 | 0.741688 |
f8470d058abce7026b22a3487b655fc4546e1812 | 163 | # frozen_string_literal: true
require 'rails_helper'
RSpec.describe AgendasTagging, type: :model do
pending "add some examples to (or delete) #{__FILE__}"
end
| 20.375 | 56 | 0.766871 |
6aede4d837511541138e97f9a5eee712696e3eb5 | 8,050 | =begin
#Ory Kratos API
#Documentation for all public and administrative Ory Kratos APIs. Public and administrative APIs are exposed on different ports. Public APIs can face the public internet without any protection while administrative APIs should never be exposed without prior authorization. To protect the administa... | 32.2 | 429 | 0.639503 |
ab9fa7ecd9f4567ff11f9fbd6142a8bd0536d5c2 | 379 | class SortedArray < Array
def initialize(*args, &sort_by)
@sort_by = sort_by || Proc.new { |x,y| x <=> y }
super(*args)
self.sort!() &sort_by
end
def insert(i, v)
insert_before = index(find { |x| @sort_by.call(x, v) == 1 })
super(insert_before ? insert_before : -1, v)
end
def <<(v)
i... | 18.047619 | 64 | 0.580475 |
1d758b55b97ae80496e4568072f71bc96121f93c | 2,357 | # encoding: utf-8
OS_PLATFORM = RbConfig::CONFIG["host_os"]
VENDOR_PATH = File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "vendor"))
#TODO: Figure out better means to keep this version in sync
if OS_PLATFORM == "linux"
FILEBEAT_URL = "https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-6.5.... | 35.179104 | 108 | 0.714892 |
edc78b6cefc3085b0770663252c162ac8fcee7c1 | 3,909 | # encoding: utf-8
require 'json'
require_relative '../helper'
module Reporter
#
# Used to send inspec reports to Chef Automate via the data_collector service
#
class ChefAutomate
include ReportHelpers
def initialize(opts)
@entity_uuid = opts[:entity_uuid]
@run_id = opts[:run_id]
@nod... | 34.901786 | 126 | 0.600665 |
628582fe5dbd48a058a28ae5b5e210b41520cc8d | 1,801 | require 'test_helper'
class AdminsControllerTest < ActionController::TestCase
# All kinds of admins
def setup
@tom = admins(:tom) # root
@jerry = admins(:jerry) # admin
@mary = admins(:mary) # expert
@barack = admins(:barack) # operator
@michelle = admins(:mi... | 24.671233 | 64 | 0.642421 |
266a36460f53e7300c56f2e36d56734e3c08334c | 157 | class UsersController < ApplicationController
def edit
end
def destroy
current_user.destroy
clear_session
redirect_to root_path
end
end
| 14.272727 | 45 | 0.757962 |
6214255090960fc376cc17953c72414784c48305 | 710 | # frozen_string_literal: true
require 'rails_helper'
RSpec.describe FriendshipPolicy, type: :policy do
let(:kurt) { create(:user, :male, first_name: 'Kurt') }
let(:mary) { create(:user, :male, first_name: 'Mary') }
let(:friendship) { create(:friendship, active_friend: kurt, passive_friend: mary) }
context 'p... | 33.809524 | 85 | 0.71831 |
28f904b0463a3cf66eab6e43d26e7f59f41064ef | 11,695 | class LlvmAT6 < Formula
desc "Next-gen compiler infrastructure"
homepage "https://llvm.org/"
url "https://releases.llvm.org/6.0.1/llvm-6.0.1.src.tar.xz"
sha256 "b6d6c324f9c71494c0ccaf3dac1f16236d970002b42bb24a6c9e1634f7d0f4e2"
license "NCSA"
revision OS.mac? ? 3 : 4
bottle do
cellar :any
sha256 "... | 36.319876 | 114 | 0.637452 |
6afe4db41ea6011345e5c752271c17381bdea911 | 784 | class SendInvite
prepend SimpleCommand
include ActiveModel::Validations
def initialize(email, list, sender, recipient = nil)
@email = email
@list = list
@sender = sender
@recipient = recipient
end
def call
create_invitation
end
private
attr_reader :email, :list, :sender, :recipi... | 19.6 | 54 | 0.625 |
5d9f0c3e0645ce055a13ce02a496fecc79b162b5 | 100 | class Image < ActiveRecord::Base
belongs_to :user
has_many :thumbnails, class_name: "Image"
end
| 20 | 43 | 0.76 |
ff724b537a3b6937e3077a3f4b6946a506650409 | 165 | require "date"
class Date
# Returns "00:00:00".
#
# Provided for parity with {Time#to_hms}.
#
# @return [String]
def to_hms
"00:00:00"
end
end
| 10.3125 | 43 | 0.587879 |
91896d2b9cf36e0b8e772883282d88822890a37d | 670 | class AddGroupsSourceToLabs < ActiveRecord::Migration[5.2]
def change
#Create groups_source column in labs
unless column_exists? :labs, :groups_source_id
add_reference :labs, :groups_source, index: true, after: :source_id
end
#for each lab with a status of 'released' or 'retrieved', get groups_... | 41.875 | 169 | 0.735821 |
878001f0f9263f8db647d7b23ad6c50a29b0dec3 | 264 | module ApplicationHelper
# Returns the full title on a per-page basis.
def full_title(page_title = '')
base_title = "Ruby on Rails Tutorial Sample App"
if page_title.empty?
base_title
else
page_title + ' | ' + base_title
end
end
end
| 22 | 51 | 0.674242 |
bb36daa81e5a8bfa2d8d60fc12ec3044ecc87c95 | 829 | require 'concurrent'
require 'open-uri'
def get_year_end_closing(symbol, year)
uri = "http://ichart.finance.yahoo.com/table.csv?s=#{symbol}&a=11&b=01&c=#{year}&d=11&e=31&f=#{year}&g=m"
data = open(uri) {|f| f.collect{|line| line.strip } }
price = data[1].split(',')[4]
price.to_f
[symbol, price.to_f]
end
def... | 33.16 | 107 | 0.683957 |
6a7bb02cc1a60ab14286ad8b1a5d302028c50db1 | 448 | require 'spec_helper'
describe Rack::App::Router do
include Rack::App::Test
let(:router) { rack_app.router }
rack_app Rack::App do
end
describe 'merge_router!' do
subject { router.merge_router!(other_router) }
context 'when not static router given' do
let(:other_router) { 'nope, this is a st... | 22.4 | 100 | 0.685268 |
188aac14ac46c8d89705ee764f553d478bf50c5b | 619 | module TransactionAccountable
def new_credit(transaction_account_id, credit_amount, at = Time.zone.now)
credit = new_transaction(transaction_account_id, 0, credit_amount, at)
end
def new_debit(transaction_account_id, debit_amount, at = Time.zone.now)
debit = new_transaction(transaction_account_id, debit... | 38.6875 | 172 | 0.767367 |
4a252f1c9dc4daa7bc9c7282ccbd7219e1075a85 | 1,097 | # encoding: UTF-8
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative sou... | 36.566667 | 86 | 0.749316 |
01bb070e5b880c8dff530b6c395a6446ea5b09e7 | 1,041 | # frozen_string_literal: true
require_relative 'helper'
class TestConditionsDiskUsage < Minitest::Test
# valid?
def test_valid_should_return_false_if_no_above_given
c = Conditions::DiskUsage.new
c.mount_point = '/'
c.watch = stub(name: 'foo')
refute c.valid?
end
def test_valid_should_return_... | 19.641509 | 63 | 0.684918 |
6163eaf9004a0f5c1089876205e538d671bdf4e5 | 157 | include_recipe 'scp_sitecore_modules::azuretoolkit'
include_recipe 'scp_sitecore_modules::sxa_181_sc91'
include_recipe 'scp_sitecore_modules::jss_1101_sc91'
| 39.25 | 52 | 0.88535 |
18692960b0831c1facb4b61557aff701330a3c86 | 1,111 | require 'observer'
class Employee
include Observable
attr_reader :name, :title
attr_reader :salary
def initialize(name, title, salary)
super()
@name = name
@title = title
@salary = salary
end
def salary=(new_salary)
old_salary = @salary
... | 17.919355 | 43 | 0.59856 |
5d0e9ed344c1c01339c1a90b317d14831f6ab2f3 | 613 | module Intrigue
module Ident
module SshCheck
class ArrayOs < Intrigue::Ident::SshCheck::Base
def generate_checks
[
{
:type => "fingerprint",
:category => "operating_system",
:tags => ["SSHServer"],
:vendor => "Array Networks",
:product => "Arr... | 21.892857 | 49 | 0.491028 |
618597bb6bd03bb473787dd20024d8d116829790 | 1,303 | module DisqusApi
class Namespace
attr_reader :api, :name, :specification
# @param [Api] api
# @param [String, Symbol] name
def initialize(api, name)
@api = api
@name = name
@specification = @api.specifications[@name]
@specification or raise(ArgumentError, "No such namespace <#... | 29.613636 | 87 | 0.657713 |
e8edfde5bd1a3830a03dbb5e2b1ec60002734a15 | 529 | require_relative '../../test_helper'
class StateAfterBeingCopiedTest < StateMachinesTest
def setup
@machine = StateMachines::Machine.new(Class.new)
@machine.states << @state = StateMachines::State.new(@machine, :parked)
@copied_state = @state.dup
end
def test_should_not_have_the_context
state_co... | 26.45 | 75 | 0.73913 |
281705d8e727eab77a64ff3714611fa5a994b464 | 16,345 | require 'rpi_gpio'
# Copyright (c) 2014 Adafruit Industries
# Author: Tony DiCola
# Ported by: Rigel
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without l... | 36.647982 | 212 | 0.639095 |
919e3288bfdbc3076018737e54b226e17b8305cf | 442 | ActiveAdmin.register Offer do
# See permitted parameters documentation:
# https://github.com/activeadmin/activeadmin/blob/master/docs/2-resource-customization.md#setting-up-strong-parameters
#
# permit_params :list, :of, :attributes, :on, :model
#
# or
#
# permit_params do
# permitted = [:permitted,... | 29.466667 | 120 | 0.69457 |
185012b57d357e0ef78e34279e63c5edb7dce1fa | 3,515 | require "spec_helper"
describe "documentation" do
let(:request) do
double({
env: {}
})
end
let(:render_context) do
double({
request: request
})
end
def render_navigation(configuration, options = {})
Navigatrix::Renderer.new(configuration, options.merge(render_context: render... | 22.677419 | 97 | 0.51266 |
1a8b62d64e32aacaf08f1be1a699bd2459cdbb21 | 3,727 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'sensu_api'))
Puppet::Type.type(:sensu_hook).provide(:sensu_api, :parent => Puppet::Provider::SensuAPI) do
desc "Provider sensu_hook using sensu API"
mk_resource_methods
def self.instances
hooks = []
namespaces.each do |namespace|
... | 27.007246 | 135 | 0.583043 |
214979c7273e234b3191121e7c106a1458565113 | 779 | cask "font-source-serif-pro" do
version :latest
sha256 :no_check
url "https://github.com/google/fonts/trunk/ofl/sourceserifpro",
verified: "github.com/google/fonts/",
using: :svn,
trust_cert: true
name "Source Serif Pro"
homepage "https://fonts.google.com/specimen/Source+Serif+Pro"
... | 31.16 | 65 | 0.744544 |
f734ffb7aaf8cb9b2a48e7956b28f8299146fbb0 | 4,061 | ##
# This Service serves as an interface for the Slack Web API
#
# @see https://github.com/slack-ruby/slack-ruby-client
class SlackService
##
# Returns the id of a usergroup
#
# @param [String] usergroup_handle The text after the `@` used to reference a
# group in slack - ex: ombuteam
# @pa... | 33.561983 | 104 | 0.670278 |
d54c6cdc7b179bc143b4d89dc971c713ed9f7a6b | 234 | class CreateBoardDrawingActions < ActiveRecord::Migration[4.2]
def change
create_table :board_drawing_actions do |t|
t.string :action_type
t.string :uid
t.text :properties
t.timestamps
end
end
end
| 19.5 | 62 | 0.688034 |
2171e8170dcf5517201c7323289b91a780bd3f14 | 481 | module ApplicationHelper
def full_title(page_title = '')
base_title = 'Friend App'
if page_title.empty?
base_title
else
page_title + ' | ' + base_title
end
end
def like_dislike(post)
like = Like.find_by(post: post, user: current_user)
if like
link_to('Dislike!', pos... | 22.904762 | 89 | 0.642412 |
330fa212a4f6437436c2e33ce61df5f0b9b4cec9 | 7,228 | #-- copyright
# OpenProject is a project management system.
# Copyright (C) 2012-2013 the OpenProject Foundation (OPF)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
#
# OpenProject is a fork of ChiliProject, which is a fork of ... | 23.166667 | 102 | 0.574571 |
5d1a0ad6affaa47e7abb31fafc8090775a8bfb69 | 200 | class AddFacilityIdToInspection < ActiveRecord::Migration
def change
add_column :inspections, :facility_id, :integer
add_foreign_key :inspections, :facilities, on_delete: :cascade
end
end
| 28.571429 | 66 | 0.785 |
6a22fdb857b3383d0e0c2b55feb7bade09d9b242 | 436 | # frozen_string_literal: true
require 'spec_helper'
describe 'contribution analytics' do
let(:user) { create(:user) }
let(:group) { create(:group)}
before do
group.add_developer(user)
login_as(user)
end
it 'redirects from -/analytics to -/contribution_analytics' do
get "/groups/#{group.full_pa... | 21.8 | 87 | 0.727064 |
2184801154014f17c22b52509bdea1b1707d50cc | 2,858 | module DataMapper
module Is
module StateMachine
module Data
# This Machine class represents one state machine.
#
# A model (i.e. a DataMapper resource) can have more than one Machine.
class Machine
# The property of the DM resource that will hold this Machine's
... | 31.406593 | 80 | 0.558782 |
f73e3ecdf5ea70c6cae704b8ac4c4c622da22b4d | 4,005 | require 'adroll/demo_responses'
module AdRoll
class Service
include DemoResponses
attr_accessor :client
# Override Object's clone method and pass to method_missing
def self.clone(params)
method_missing(:clone, params)
end
def self.method_missing(meth, *args)
# @TODO add logging... | 33.099174 | 93 | 0.632959 |
d57a708880db708eaec10d56a8dffb2a5be8ad94 | 218 | require 'spec_helper'
describe GraphicalGitLogger do
it 'has a version number' do
expect(GraphicalGitLogger::VERSION).not_to be nil
end
it 'does something useful' do
expect(false).to eq(true)
end
end
| 18.166667 | 53 | 0.733945 |
ff80506109311cdffccdf8e865ddafadd3466617 | 192 | class AddIsFilterSpecsToErpProductsPropertyGroups < ActiveRecord::Migration[5.1]
def change
add_column :erp_products_property_groups, :is_filter_specs, :boolean, default: false
end
end | 38.4 | 88 | 0.822917 |
91b0b5cb28df7aa08f737504749671c2829bec2b | 1,107 | Gem::Specification.new do |s|
s.name = "textfile"
s.version = "1.1.0"
s.authors = ["Piers Chambers"]
s.email = "piers@varyonic.com"
s.summary = "Set-like wrapper around GNU comm and related textfile utilities."
s.description = "Set-like wrapper around GNU comm and related textfile utilities.\n\nA commo... | 29.918919 | 237 | 0.665763 |
f7902b65ad7e9be9c0a694f7b3d973f519a1a081 | 592 | name 'apache2'
source_url 'https://github.com/sous-chefs/apache2'
issues_url 'https://github.com/sous-chefs/apache2/issues'
maintainer 'Sous Chefs'
maintainer_email 'help@sous-chefs.org'
chef_version '>= 13.0'
license 'Apache-2.0'
description 'Installs and configures apache2'
long_description IO.read(File.join(File.dir... | 24.666667 | 72 | 0.778716 |
614361d3c264963217ed5c5e7e1466e8b852d22e | 1,955 | require 'spec_helper'
require 'rspec/given'
require 'given/assertions'
describe Given::Assertions do
use_natural_assertions_if_supported
Given { extend Given::Assertions }
describe "Assert { }" do
Given { Given::Assertions.enable_asserts }
context "with true assertion" do
When(:result) { Assert ... | 25.723684 | 95 | 0.625575 |
6273080e15a6f470a6e3f74c7d2356bac94613ca | 699 | require 'spec_helper'
describe UsersController do
describe 'routing' do
it 'routes to #index' do
expect(get('/users')).to route_to('users#index')
end
it 'routes to #show' do
expect(get('/users/1')).to route_to('users#show', id: '1')
end
it 'routes to #edit' do
expect(get('/use... | 23.3 | 70 | 0.597997 |
1df0dddb9e8b281c58b69d25f333cf8e2d170c71 | 1,006 | # Copyright (C) 2014 Ruby-GNOME2 Project Team
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This libra... | 35.928571 | 80 | 0.766402 |
ffe860857e65b4384be4fdcd0f58aec1be81720b | 3,510 | require 'spec_helper'
describe Citygram::Workers::SubscriptionConfirmation do
subject { Citygram::Workers::SubscriptionConfirmation.new }
context 'email' do
include Mail::Matchers
let(:to_email_address) { 'human@example.com' }
let(:from_email_address) { ENV.fetch('SMTP_FROM_ADDRESS') }
let(:publ... | 37.340426 | 213 | 0.673219 |
189bea4274db92b11c9d29d315207f6ca17bf35a | 4,320 | require 'spec_helper'
require 'date'
require 'time'
RSpec.describe ApexCharts::Utils::DateTime do
context '.convert' do
let(:converted) { described_class.convert(input) }
context 'input is a Time' do
let(:input) { Time.iso8601('2019-06-18T20:20:20+0700') }
it 'converts correctly' do
exp... | 21.818182 | 96 | 0.578009 |
01cf77d5a28650892a243ab85e038a5795eb8c0a | 946 | require "rails_helper"
RSpec.describe LocationsController, type: :routing do
describe "routing" do
it "routes to #index" do
expect(:get => "/locations").to route_to("locations#index")
end
it "routes to #show" do
expect(:get => "/locations/1").to route_to("locations#show", :id => "1")
en... | 26.277778 | 84 | 0.603594 |
380f8abfee22f7487029a6d736f6af176ad74e50 | 1,268 | require 'spec_helper'
RSpec.describe Algorithms::BinarySearch do
it 'finds the target index' do
sorted_array = [1,3,5,7,9,11,13]
index = described_class.search(sorted_array, 11)
expect(index).to eq 5
index = described_class.search(sorted_array, 1)
expect(index).to eq 0
index = described_cl... | 25.877551 | 101 | 0.683754 |
e9f3d8b45d368dc6cd622f5b16c042120437fb90 | 609 | # An abstract class for asyncronous jobs that transcode files using FFMpeg
module Hydra::Derivatives::Processors
module Ffmpeg
extend ActiveSupport::Concern
INPUT_OPTIONS = :input_options
OUTPUT_OPTIONS = :output_options
included do
include ShellBasedProcessor
end
module ClassMethods
... | 27.681818 | 117 | 0.689655 |
e8c9436798edc7bf3144237a43b3d2dafb84de10 | 136 | module Employer
class Employer < OpenStruct
def locations
super.map { |location| Location.new(location) }
end
end
end
| 17 | 53 | 0.683824 |
b90abe61addbe0d987a7994dfd2d82891ab24e11 | 7,794 | =begin
#DocuSign REST API
#The DocuSign REST API provides you with a powerful, convenient, and simple Web services API for interacting with DocuSign.
OpenAPI spec version: v2.1
Contact: devcenter@docusign.com
Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.4.13-SNAPSHOT
=e... | 31.427419 | 177 | 0.636259 |
1d7941b8a17e4583b246417ec30b7af7febd4c9c | 405 | # frozen_string_literal: true
require "cli/parser"
require "utils/shell"
module Homebrew
module_function
def security_available_tools_args
Homebrew::CLI::Parser.new do
description <<~EOS
Prints list of available tools for m9/security tap
EOS
end
end
def security_available_tools
... | 18.409091 | 58 | 0.74321 |
390daff87198c6d80eec2862d223e0eb9fd56f9c | 5,099 | #
# Be sure to run `pod spec lint PrettyRuler.podspec' to ensure this is a
# valid spec and to remove all comments including this before submitting the spec.
#
# To learn more about Podspec attributes see http://docs.cocoapods.org/specification.html
# To see working Podspecs in the CocoaPods repo see https://github... | 36.949275 | 93 | 0.595019 |
03aebb03ecec8f530dcb7b99fcba0ebbbed051ad | 1,516 | #
# Cookbook Name:: bcpc
# Recipe:: kibana
#
# Copyright 2013, Bloomberg Finance L.P.
#
# 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... | 26.137931 | 74 | 0.704485 |
1c604d301f19bfda827b5e466581ae9a3680284b | 570 | # frozen_string_literal: true
require_relative 'command_handler'
module Ftpd
class CmdType < CommandHandler
def cmd_type(argument)
ensure_logged_in
syntax_error unless argument =~ /^\S(?: \S+)?$/
unless argument =~ /^([AEI]( [NTC])?|L .*)$/
error 'Invalid type code', 504
end
... | 19.655172 | 53 | 0.568421 |
f70e664761d05372f11231cf07e1736089e2655e | 1,630 | class ApplicationController < ActionController::Base
config.relative_url_root = ""
protect_from_forgery
layout 'application'
before_filter :locale_workaround
helper_method :current_user
def paginated_scope(relation)
instance_variable_set "@#{controller_name}", relation.page(params[:page])
end... | 24.328358 | 77 | 0.709816 |
1a7dc0dafe6e5a57158c44bbe3caf923416a1ff4 | 706 | require 'spec_helper'
describe RemoveUnusedTags::Job do
describe "#perform" do
let!(:project) { projects(:socialitis) }
let!(:aggregate_project) { aggregate_projects(:internal_projects_aggregate) }
before do
ActsAsTaggableOn::Tag.destroy_all
ActsAsTaggableOn::Tag.create!(name: "iamunused")
... | 28.24 | 81 | 0.699717 |
f7fa394fd5850b5c7d9508851a9f07759f7dec9f | 382 | require 'pathname'
module Gamefic
module Sdk
module Tasks
# Common methods for Rake tasks.
#
module Common
attr_reader :directory
def initialize directory = '.'
@directory = directory
end
def absolute_path
@absolute_path ||= Pathname.new(dir... | 17.363636 | 66 | 0.586387 |
e831ced3525cd60074c1f46e7c3e1e1523942481 | 754 | class SessionsController < ApplicationController
get '/login' do
redirect_if_logged_in
erb :'sessions/new'
end
post '/login' do
redirect_if_logged_in
user = User.find_by(email: params["user"]["email"])
if user && user.authenticate(params["user"]["password"])... | 30.16 | 98 | 0.568966 |
91fcf3f5c31bba681f74ad322ec8b5c589b315b9 | 43 | require './web.rb'
run GeradorCertificados
| 14.333333 | 23 | 0.790698 |
1a991ca5601ff5fa8bbdaa99c476e7a23da29c72 | 5,775 | module ActsAsSolr #:nodoc:
module InstanceMethods
# Solr id is <class.name>:<id> to be unique across all models
def solr_id
"#{self.class.name}:#{record_id(self)}"
end
# saves to the Solr index
def solr_save
return true if indexing_disabled?
if evaluate_condition(:if, self) ... | 34.580838 | 128 | 0.602424 |
39cca475821c548a359d00803de1d295c82754cb | 462 | require 'spec_helper'
describe Sansu::Operator do
describe '#sum' do
it { expect([1, 2, 3].sum).to eq 6.0 }
end
describe '#mean' do
it { expect([1, 2, 3].mean).to eq 2.0 }
end
describe '#median' do
it { expect([2, 2, 1, 3].median).to eq 2.0 }
it { expect([5, 4, 6].median).to eq 5.0 }
end
... | 21 | 59 | 0.541126 |
6a1c2111ac9cc39d26333d5228c8607f10559aaf | 13,517 | =begin
#Hydrogen Proton API
#Financial engineering module of Hydrogen Atom
OpenAPI spec version: 1.7.18
Contact: info@hydrogenplatform.com
Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.4.14
=end
require 'date'
module ProtonApi
class PurchaseCalculatorAmountRequest
... | 33.375309 | 180 | 0.656359 |
8723791971567f6c50bb9ea9a8feb58c802c62c2 | 711 | require 'pathname'
# An isolated operation to perform on a set of files
class Task
include Virtus.value_object
values do
attribute :id, String
attribute :type, String
attribute :status, String
attribute :language, String
attribute :tool, String
attribute :build, Build
attribute :source... | 22.21875 | 71 | 0.697609 |
7a5644b800397741615318021b958dd5a77d9308 | 946 | lat = params[:latitude].to_f
lng = params[:longitude].to_f
store = @outlet.store
json.store_name store.name
json.store_id store.id
json.outlet_locality @outlet.locality
json.outlet_phone @outlet.phone_number
json.is_following_store current_user.follow_store?(store)
json.steps @outlet.steps(lat, lng)
json.deals @deals... | 27.823529 | 57 | 0.813953 |
7aaaf688812e9927168a26b334a3973013e3e75d | 254 | class CreateItems < ActiveRecord::Migration
def change
create_table :items do |t|
t.references :store, index:true
t.string :name
t.decimal :price
t.text :details
t.timestamps null: false
end
end
end
| 21.166667 | 43 | 0.614173 |
7a0550ec6f4f7ab5e42539be2095341c5b22b49a | 1,464 | require_relative 'lib/shipyard_exporter/version'
Gem::Specification.new do |spec|
spec.name = 'shipyard_exporter'
spec.version = ShipyardExporter::VERSION
spec.authors = ['Gan Yi Zhong']
spec.email = ['ganyizhong@gmail.com']
spec.summary = 'all-in-one exporter feature for ... | 41.828571 | 104 | 0.691257 |
e9fac640b000ae91cd74232eba93d86d55375790 | 3,790 | require "inspec/resources/command"
module Inspec::Resources
class FileSystemResource < Inspec.resource(1)
name "filesystem"
supports platform: "linux"
supports platform: "windows"
desc "Use the filesystem InSpec resource to test file system"
example <<~EXAMPLE
describe filesystem('/') do
... | 27.071429 | 156 | 0.59657 |
01c622ccac226f39e58acd8c298207717a1232e3 | 287 | if ActiveRecord::Base.connection.database_version < 90500
exclude :test_add_index_which_already_exists_does_not_raise_error_with_option, 'ADD INDEX IF NOT EXISTS is PG >= 9.5'
exclude :test_add_index_with_if_not_exists_matches_exact_index, 'ADD INDEX IF NOT EXISTS is PG >= 9.5'
end
| 57.4 | 119 | 0.825784 |
5da02a7a3d52de541cbd0ed6e49df6d08af314a4 | 1,535 | #!/usr/bin/env ruby
# Each Warden container is a /30 in Warden's network range, which is
# configured as 10.244.0.0/22. There are 256 available entries.
#
# We want two subnets, so I've arbitrarily divided this in half for each.
#
# cf1 will be 10.244.0.0/23
# cf2 will be 10.244.2.0/23
#
# Each network will have 128 s... | 26.465517 | 76 | 0.592834 |
1c6a082a5e5d37183af43601ba248074a457907f | 265 | require './config/environment'
class ApplicationController < Sinatra::Base
configure do
set :public_folder, 'public'
set :views, 'app/views'
enable :sessions
set :session_secret, "password_security"
end
get '/' do
erb :homepage
end
end | 16.5625 | 43 | 0.690566 |
bfab9c2562ac7d55db78119053decd1f2b31d523 | 372 | Deface::Override.new(virtual_path: 'spree/admin/orders/_shipment',
name: 'add_purchase_postage_to_shipments_page',
insert_after: "strong.stock-location-name",
text: "
<% if shipment.ready? %>
<%= link_to 'Purchase Postage', 'javascript:;', class: 'purchase-postage pull-right btn btn-success', data: { 'o... | 46.5 | 151 | 0.680108 |
26e5e84d4fba9f2723a1351ea88b4f94a9515d77 | 21,964 | # ====================================================================
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this f... | 25.809636 | 86 | 0.613777 |
1a812f6e6b9f7cebe9488c8b3fdde7c625f2d0f9 | 556 | require 'spec_helper'
def execute(query, context = {})
CacheSchema.execute(query, context: context)
end
RSpec.describe 'caching connection fields' do
let(:query) do
%Q{
{
customer(id: #{Customer.last.id}) {
orders {
edges {
node {
id
... | 17.935484 | 49 | 0.534173 |
e813c5050017766c12e608c7f3e11ff7f5cb551f | 293 | require "treetop"
require "polyglot"
require "tweetparser/grammar"
module TweetParser
def self.parse(input)
kcode = $KCODE
$KCODE = "n"
parser = TweetContentParser.new
parsed = parser.parse(input)
$KCODE = kcode
return nil unless parsed
parsed.content
end
end
| 18.3125 | 35 | 0.692833 |
879c4269584c5b2d3872fb33540ce40d782316f7 | 1,377 | require 'active_support/concern'
module Schema::Accessors
extend ActiveSupport::Concern
included do
props = self.schema.properties
raise "Schema #{schema.inspect} has no properties" unless props
generated_methods.module_eval do
props.each do |name, prop|
define_method prop, ""
end... | 20.863636 | 78 | 0.615105 |
ac3ba443a37a7a784108d5ca22898d970ce4790d | 243 | Rails.application.routes.draw do
get 'staticpages/home'
get 'staticpages/help'
get 'staticpages/about'
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
root 'application#hello'
end
| 22.090909 | 101 | 0.761317 |
91914353c812ac19342fa431b685169bddce7020 | 2,675 | # frozen_string_literal: true
require "spec_helper"
require "bump/dependency"
require "bump/dependency_file"
require "bump/file_updaters/java_script/yarn"
require_relative "../shared_examples_for_file_updaters"
RSpec.describe Bump::FileUpdaters::JavaScript::Yarn do
it_behaves_like "a dependency file updater"
let(... | 29.395604 | 80 | 0.651963 |
210596547a3d047b8e178b977b5cd14157eebe46 | 444 | $LOAD_PATH.unshift(File.dirname(__FILE__))
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
require 'rubygems'
require 'rspec'
require 'automatic_foreign_key'
require 'connection'
Dir[File.dirname(__FILE__) + "/support/**/*.rb"].each {|f| require f}
RSpec.configure do |config|
config.include(Automa... | 27.75 | 75 | 0.747748 |
2132e5d24847af3dcc06b1a786f11e859c3cd2f4 | 6,628 | # frozen_string_literal: true
module ActiveRecord
module ConnectionAdapters
module MySQL
module DatabaseStatements
# Returns an ActiveRecord::Result instance.
def select_all(*) # :nodoc:
result = if ExplainRegistry.collect? && prepared_statements
unprepared_statement {... | 32.975124 | 186 | 0.560501 |
bf17c1f0cad4f41dfc5516778887e1e428f64d57 | 3,660 | # From itunes_parser by Pete Higgins
# http://github.com/phiggins/itunes_parser
require 'nokogiri'
module ItunesParser
class NokogiriSax
class SaxDoc < Nokogiri::XML::SAX::Document
def initialize on_track, on_playlist
super()
@on_track, @on_playlist = on_track, on_playlist
@with_ca... | 23.461538 | 65 | 0.544809 |
622d3846c31101b30ac6227ae5beb65818dfee80 | 2,532 | require 'net/http'
require 'net/https'
require 'json'
require 'rack/utils'
module PaypalAdaptive
class IpnNotification
def initialize(env=nil)
config = PaypalAdaptive.config(env)
@paypal_base_url = config.paypal_base_url
@ssl_cert_path = config.ssl_cert_path
@ssl_cert_file = config.ssl_c... | 31.259259 | 68 | 0.64613 |
3391da4324d29dd89aea470346a80feac1dc3e00 | 457 | # frozen_string_literal: true
shared_examples 'class' do
it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_augeas('/etc/sysconfig/elasticsearch') }
it { is_expected.to contain_file('/etc/elasticsearch/elasticsearch.yml') }
it { is_expected.to contain_datacat('/etc/elasticsearch/elasticsea... | 41.545455 | 79 | 0.772429 |
bb25a3be4e5729dafccbe34db27049ccb6b49cea | 13,258 | module Stupidedi
module Versions
module Interchanges
module ThreeHundred
#
# @see FunctionalGroups::FortyTen::ElementTypes
# @see Schema::CodeList
#
module ElementDefs
# Import definitions of DT, R, ID, Nn, AN, TM, and SimpleElementDef
t = Functi... | 47.862816 | 200 | 0.544275 |
619567df13e160092f8896b8c4af2b7db368f6dc | 2,103 | # frozen_string_literal: true
require_relative '../../../step/track'
module Engine
module Game
module G18Ireland
module Step
class Track < Engine::Step::Track
def hex_neighbors(entity, hex)
super || @game.narrow_connected_hexes(entity)[hex]
end
def proces... | 33.919355 | 111 | 0.545887 |
b975fdc445b089f8582e5b98af0ba52d09ca7dce | 4,998 | # frozen_string_literal: true
RSpec.describe CronKubernetes::CronJob do
subject { CronKubernetes::CronJob.new }
let(:manifest) do
YAML.safe_load <<~MANIFEST
apiVersion: batch/v1
kind: Job
spec:
template:
spec:
containers:
- name: hello
... | 29.4 | 104 | 0.528011 |
bf216a60dc4cf898be6304ac313f2bcec198600e | 12,864 | # frozen_string_literal: true
require "utils/spdx"
describe SPDX do
describe ".license_data" do
it "has the license list version" do
expect(described_class.license_data["licenseListVersion"]).not_to eq(nil)
end
it "has the release date" do
expect(described_class.license_data["releaseDate"])... | 37.835294 | 115 | 0.703436 |
e91801fca6995c3280be8cc6e9ad3a8db269cc7c | 365 | cask "a-slower-speed-of-light" do
version "summer12"
sha256 "4163053a6caa6d258475aa29209fb863fe63139c8d3048661f8a9bc11ffd187c"
url "https://web.mit.edu/gambit/#{version}/speedoflight/beta/A_Slower_Speed_of_Light.dmg"
name "A Slower Speed of Light"
homepage "http://gamelab.mit.edu/games/a-slower-speed-of-ligh... | 33.181818 | 91 | 0.772603 |
1d9f2c551bc81475ef36decca8625879c754bb6f | 992 | =begin
#OpenAPI Petstore
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 3.3.2-SNAPSHOT
=end
require 'spe... | 23.619048 | 157 | 0.72379 |
39f911dfd713df37921f9c2a37f574582c82af89 | 14,596 | require 'spec_helper'
require 'monitor'
describe 'Client - Reconnect' do
before(:each) do
@s = NatsServerControl.new
@s.start_server(true)
end
after(:each) do
@s.kill_server
sleep 1
end
it 'should process errors from a server and reconnect' do
nats = NATS::IO::Client.new
nats.conne... | 23.316294 | 100 | 0.591189 |
08c30d02d8f1cb9965941082e0688d9c092f21b3 | 1,225 | class GitUrlSub < Formula
desc "Recursively substitute remote URLs for multiple repos"
homepage "https://gosuri.github.io/git-url-sub"
url "https://github.com/gosuri/git-url-sub/archive/1.0.1.tar.gz"
sha256 "6c943b55087e786e680d360cb9e085d8f1d7b9233c88e8f2e6a36f8e598a00a9"
head "https://github.com/gosuri/git-... | 42.241379 | 93 | 0.763265 |
f8b910dc33ec04e517033a41a428808b0fa834e6 | 2,514 | # encoding: utf-8
module LogStash; module Outputs; class SumoLogic;
class Piler
require "logstash/outputs/sumologic/common"
require "logstash/outputs/sumologic/statistics"
require "logstash/outputs/sumologic/message_queue"
include LogStash::Outputs::SumoLogic::Common
attr_reader :is_pile
d... | 28.247191 | 94 | 0.565632 |
bb63e79248cdbf3394b25a2c69ca057d1801a855 | 505 | class RosterController < ApplicationController
before_filter :ensure_logged_in
before_filter :set_tab
def index
return unless load_course( params[:course] )
return unless allowed_to_see_course( @course, @user )
@instructors = @course.instructors
@students = @course.students
@breadcrumb = Br... | 21.956522 | 57 | 0.716832 |
26c3a4e5a10e6dbe758647b0a5b6d14f9da538e6 | 384 | # frozen_string_literal: true
require_relative '../../lib/Sento.rb'
describe PluginMap do
it 'validate the count of start and end' do
maper = described_class.new
maper.add_start(1)
maper.add_end(3)
expect(maper.is_valid_brackets_count()).to eq(true)
maper.add_end(3)
e... | 25.6 | 60 | 0.671875 |
218e9004704ad20d40f7b29832a1c2e8e47a5c85 | 492 | require 'redmine'
ApplicationHelper.prepend(AbsoluteDateHelperPatch::ApplicationHelperWithAbsoluteDate)
Rails.application.config.i18n.load_path += Dir["#{File.dirname(__FILE__)}/config/locales/*.{rb,yml}"]
Redmine::Plugin.register :redmine_absolute_dates do
name 'Redmine Absolute Dates plugin'
author 'suer'
de... | 32.8 | 101 | 0.780488 |
aceaa74e35c3bffa9777ed99aa6031ae41eb0bff | 882 | require 'beaker-rspec/spec_helper'
require 'beaker-rspec/helpers/serverspec'
require 'beaker/puppet_install_helper'
run_puppet_install_helper unless ENV['BEAKER_provision'] == 'no'
RSpec.configure do |c|
# Project root
proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
# Readable test descri... | 35.28 | 100 | 0.705215 |
39a617a4be57bdc1daf872a8f60fcf4cee122e1a | 12,083 | # frozen_string_literal: true
require 'lib/settings'
require 'engine/auto_router'
require 'view/game/actionable'
module View
module Game
class RouteSelector < Snabberb::Component
include Actionable
include Lib::Settings
needs :last_entity, store: true, default: nil
needs :last_round, st... | 32.923706 | 123 | 0.53596 |
fff49f0d0b8343f99bcebd2732b157729252bc4b | 1,152 | =begin
The Trust Payments API allows an easy interaction with the Trust Payments web service.
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 requ... | 32 | 114 | 0.751736 |
390d36958635a3b47e007dbea33d36c74152c7b5 | 1,127 | class ImportBook
def initialize(isbn)
@isbn = isbn
end
def perform
import_params
format_response
end
private
attr_reader :isbn
def import_params
goodreads_api = Goodreads::Client.new
begin
@book = goodreads_api.book_by_isbn(@isbn)
rescue Goodreads::NotFound
{}
... | 18.783333 | 59 | 0.652174 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.