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 |
|---|---|---|---|---|---|
5d673e6e48bdcae3e1a9851e82d5dcb5f4a8c922 | 587 | # frozen_string_literal: true
module V1
module Resources
class Orders < Base
resource :customers do
route_param :customer_id, type: Integer do
get :orders do
orders = ::Orders::Report.call(customer_id: params[:customer_id])
present orders
end
p... | 21.740741 | 77 | 0.545145 |
79626ac0b76b769ed7e25d06ea346ef16d479aa9 | 4,557 | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::BisectedAttrAccessor do
subject(:cop) { described_class.new }
it 'registers an offense and corrects when both accessors of the name exists' do
expect_offense(<<~RUBY)
class Foo
attr_reader :bar
^^^^ Combine bot... | 25.176796 | 119 | 0.592715 |
e82cfcbf2ece0f385dd815d796646e5eac34c62a | 139 | require 'spec_helper'
describe Github::Client::Repos::Projects do
it_should_behave_like 'api interface'
end # Github::Repos::Projects
| 17.375 | 43 | 0.776978 |
1c03321176e7e69122ec559ad9cfbb745f1e1799 | 1,441 | require 'pronto'
require 'brakeman'
module Pronto
class Brakeman < Runner
def run
return [] if ruby_patches.none?
output = ::Brakeman.run(app_path: repo_path,
output_formats: [:to_s])
messages_for(ruby_patches, output).compact
rescue ::Brakeman::NoApplication
... | 26.685185 | 91 | 0.632894 |
b9ba80068b1b340a72cb6813841e64c1f89f4312 | 37,131 | #
# Author:: Adam Jacob (<adam@opscode.com>)
# Author:: Christopher Walters (<cw@opscode.com>)
# Author:: Tim Hinderliter (<tim@opscode.com>)
# Author:: Seth Chisamore (<schisamo@opscode.com>)
# Copyright:: Copyright (c) 2008-2011 Opscode, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache Licen... | 34.799438 | 147 | 0.675096 |
4ae41aa19c1c6498c82a4bb82ec4a4bb4c7662eb | 6,563 | require "cases/helper"
require 'active_support/core_ext/object/instance_variables'
class SerializationTest < ActiveModel::TestCase
class User
include ActiveModel::Serialization
attr_accessor :name, :email, :gender, :address, :friends
def initialize(name, email, gender)
@name, @email, @gender = na... | 38.83432 | 110 | 0.628676 |
01168c1083ec2182dbe679c066a6d09ee4e08105 | 1,759 | Rails.application.routes.draw do
# Map admin controllers
scope "/#{Humpyard::config.admin_prefix}" do
resources :humpyard_pages, :controller => 'humpyard/pages', :path => "pages", :only => [:index, :new, :create, :edit, :update, :show, :destroy] do
collection do
post :move
end
end
... | 45.102564 | 201 | 0.654918 |
33e0286bc25511804eb473f5ab63c6fa5b197a8e | 882 | require 'spec_helper'
describe 'postfix::lookup::sqlite' do
let(:title) do
'/etc/postfix/test.cf'
end
let(:params) do
{
:dbpath => '/path/to/database',
:query => "SELECT address FROM aliases WHERE alias = '%s'",
}
end
on_supported_os.each do |os, facts|
context "on #{os}" do
... | 23.837838 | 102 | 0.611111 |
bf710879265d6ef4854457bceb06abb8e1e7aa57 | 1,781 | class Newsletter
attr_reader :data
def initialize(params)
@data = params
end
def valid?
data["X-Mailgun-Incoming"] == "Yes" && signature_valid?
end
def token
@token ||= begin
to_email.sub("@newsletters.feedbin.com", "").sub("@development.newsletters.feedbin.com", "").sub("test-subscrib... | 17.291262 | 147 | 0.627737 |
fff1a0bab07c42d58f67d8f730447802dc82c955 | 2,125 | # frozen_string_literal: true
module GitHubRepoable
extend ActiveSupport::Concern
# Public
#
def add_team_to_github_repository
github_repository = GitHubRepository.new(organization.github_client, github_repo_id)
github_team = GitHubTeam.new(organization.github_client, github_team_id)
github... | 25 | 103 | 0.763294 |
2152e90e3acd5cd3a9987ecd6dd3553d4f326a35 | 3,269 | module Elasticsearch
module Persistence
module Repository
module Response # :nodoc:
# Encapsulates the domain objects and documents returned from Elasticsearch when searching
#
# Implements `Enumerable` and forwards its methods to the {#results} object.
#
class Resul... | 30.839623 | 114 | 0.524013 |
ab922d2ed020f5277e33733b667fb6b74375ac5a | 3,744 | class FeedEvent < ActiveRecord::Base
def before_validation_on_create
send_email
end
belongs_to :source, :polymorphic => true
validates_presence_of :user_id #receiver
validate :source_user_has_event_enabled
validate :user_has_subscribed_to_event
@@event_types = []
belongs_to :user
seriali... | 31.462185 | 163 | 0.724626 |
08e37d6d02fbab3da100da6cb1738f6f7734ef0d | 190 | #!/usr/bin/env ruby
#
# Simple sinatra app to receive and display callbacks
#
require 'pp'
require 'sinatra'
set :port, 9230
post '/callback' do
puts "Received callback"
pp params
end
| 13.571429 | 53 | 0.715789 |
01cd357611475e2c0e1c9ac4eb98f84be65d299b | 315 | cask 'shruplay' do
version '2015_05_16'
sha256 'f23e25969e78935d94fbd6a8a3b28ac13fb3d0af9f3caa66fb3451eab9319150'
url 'http://cdn.getshru.com/wp-content/uploads/2015/10/SHRUPlayMac_2015_05_16.zip'
name 'PDX Pet Design SHRUPlay'
homepage 'https://getshru.com/'
license :gratis
app 'ShruPlay.app'
end
| 26.25 | 84 | 0.777778 |
bfd996b138178cc20bbbf8d43595f0e8493a8c9f | 715 | module PublicActivity
# Module extending classes that serve as owners
module Activist
extend ActiveSupport::Concern
# Module extending classes that serve as owners
module ClassMethods
# Adds has_many :activities association to model
# so you can list activities performed by the owner.
... | 26.481481 | 86 | 0.613986 |
01859efffef31727739ebcafefee7bf2870ac607 | 568 | require "stringio"
describe "StringIO#lineno" do
before(:each) do
@io = StringIO.new("this\nis\nan\nexample")
end
it "returns the number of lines read" do
@io.gets
@io.gets
@io.gets
@io.lineno.should eql(3)
end
end
describe "StringIO#lineno=" do
before(:each) do
@io = StringIO.new("... | 18.933333 | 73 | 0.639085 |
015fd9485c860385646bfea1c7b41a98f19c71ae | 222 | class CreateMarcas < ActiveRecord::Migration
def change
create_table :marcas do |t|
t.text :nombre
t.text :abreviacion
t.string :descripcion
t.timestamps null: false
end
end
end
| 20.181818 | 44 | 0.63964 |
ffcccb3677dbc76318f84c7f6e683bf1ac9f88ec | 589 | class CreateClients < ActiveRecord::Migration
def self.up
create_table :connect_clients do |t|
t.belongs_to :account
t.string(
:identifier,
:secret,
:name,
:jwks_uri,
:sector_identifier,
:redirect_uris
)
t.boolean :dynamic, :native, :ppid, de... | 21.814815 | 57 | 0.631579 |
083e4934eeda4e0e6e20461e4577d704442f97cb | 1,631 | # Copyright 2011 the original author or authors.
#
# 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 applicable law or a... | 35.456522 | 95 | 0.70141 |
081b3fed6c7a6d045b301e99566f1b0651741f57 | 11,994 | require 'spec_helper'
describe SQB::Select do
subject(:query) { SQB::Select.new(:posts) }
context "filtering" do
it "should always work on the default table" do
query.where(:title => 'Hello')
expect(query.to_sql).to eq "SELECT `posts`.* FROM `posts` WHERE (`posts`.`title` = ?)"
end
it "... | 38.442308 | 232 | 0.573537 |
79e64743fa7898ba679a16880c2972e4aa15cb99 | 407 | require_relative "words_from_strings.rb"
require_relative "count_frequency.rb"
raw_text = %{Here is a whack of text for analysis. Here is another sentence.}
word_list = words_from_strings(raw_text)
counts = count_frequency(word_list)
sorted = counts.sort_by {|word, count| count}
top_five = sorted.last(5)
for i in 0.... | 23.941176 | 77 | 0.72973 |
7999ca16aaa4d372fb83a786ed4b720cfca3a026 | 1,930 | # # Puma can serve each request in a thread from an internal thread pool.
# # The `threads` method setting takes two numbers: a minimum and maximum.
# # Any libraries that use thread pools should be configured to match
# # the maximum value specified for Puma. Default is set to 5 threads for minimum
# # and maximum; th... | 37.843137 | 87 | 0.736269 |
385884ec4d16deeb5be5acb10cbd9b6566d7b6b5 | 2,049 | # frozen_string_literal: true
module PlentyClient
module Item
module Variation
class DefaultCategory
include PlentyClient::Endpoint
include PlentyClient::Request
ITEM_VARIATION_DEFAULT_CATEGORY_PATH = '/items/{itemId}/variations/{variationId}'
LIST_ITEM_VARIATIONS_DEFAU... | 42.6875 | 118 | 0.60859 |
216606bde096eecd1e04b04e2a0349ab5bd43783 | 605 | module CustomerApi
module V1
class CustomersController < ApplicationController
def show
@customer = Customer(params[:id])
end
def create
result = AuthToken.verify(customer_params[:id_token])
if result['uid'].blank?
render status: :unauthorized, json: { status:... | 21.607143 | 86 | 0.616529 |
4a38b89d7770a3e479458ba23c7d6afe09487e6b | 2,694 | Rails.application.routes.draw do
resources :posts do
resources :comments
end
# These routes are reather interesting, but why are these routable
# destinations? It seem to me that the user should not be able to find these
# routes. Couldn't they be expressed as something like:
#
#
# POST /post/:id... | 29.604396 | 84 | 0.657016 |
7a1f7741c0bf0ff653cac35d0b736f8ec51e5700 | 418 | cask 'cheatsheet' do
version '1.2.2'
sha256 '41cfec767f761e2400d5ad700c936339c8c2e80a9dfbaf44b66375e63192763c'
url "http://mediaatelier.com/CheatSheet/CheatSheet_#{version}.zip"
appcast 'http://mediaatelier.com/CheatSheet/feed.php'
name 'CheatSheet'
homepage 'http://www.cheatsheetapp.com/CheatSheet/'
lic... | 24.588235 | 75 | 0.772727 |
bf6a499531bfaed543cf1ca1f04c5390f2f99822 | 133 | class AddIndexOnStateToSchoolDistricts < ActiveRecord::Migration[5.0]
def change
add_index :school_districts, :state
end
end
| 22.166667 | 69 | 0.789474 |
5d45b636bbc023c2a01a0f716cc7668ac3036c1b | 990 | module Fog
module Compute
class Google
class Mock
def abandon_instances(_instance_group_manager, _instances)
# :no-coverage:
Fog::Mock.not_implemented
# :no-coverage:
end
end
class Real
def abandon_instances(instance_group_manager, instances... | 34.137931 | 124 | 0.644444 |
6ad13a164d94e63d6180f7427db7f29c7110c3c8 | 13,439 | ##
# This code was generated by
# \ / _ _ _| _ _
# | (_)\/(_)(_|\/| |(/_ v1.0.0
# / /
#
# frozen_string_literal: true
module Twilio
module REST
class Accounts < Domain
class V1 < Version
class CredentialList < ListResource
class PublicKeyList < ListResource
... | 37.963277 | 99 | 0.532108 |
b9d57113e3ffd8dc8740845a551bf1d18e98b0b5 | 2,231 | module SoberSwag
module Reporting
module Output
##
# Partition output into one of two possible cases.
# We use a block to decide if we should use the first or the second.
# If the block returns a truthy value, we use the first output.
# If it returns a falsy value, we use the second.... | 28.602564 | 106 | 0.579561 |
7a67fb26184b1bd6a5ed2ed3bb0cf68d7367f715 | 986 | require "spec_helper"
describe EventStore do
describe ".insert_table_name" do
let(:date) { Date.parse("1955-01-31") }
context "without partitioning defined" do
let(:expected) { "es_test.test_events" }
it "returns a properly formatted default table name" do
expect(subject.insert_table_na... | 35.214286 | 132 | 0.681542 |
61d802c61c5c3fabff3add1e9a2bf253042f262b | 218 | class CreateCharacters < ActiveRecord::Migration[5.2]
def change
create_table :characters do |t|
t.string :pinyin
t.string :simplified
t.string :definition
t.timestamps
end
end
end
| 18.166667 | 53 | 0.665138 |
b91c1eb7f3e6a3481160befc16405a4efffd57c0 | 2,174 | # frozen_string_literal: true
# a single table inheritance class
# - attributes are defined on Request
# - behavior can be defined here
class AbsenceRequest < Request
include AasmConfig
def to_s
"#{creator} Absence"
end
aasm column: "status" do
# add in an additional state recorded which is only val... | 26.192771 | 93 | 0.74057 |
fff154a5a5b72a29323b8034a7ecfe8d1d224ef9 | 1,093 | require 'test_helper'
class MicropostsInterfaceTest < ActionDispatch::IntegrationTest
def setup
@user = users(:michael)
end
test "micropost interface" do
log_in_as(@user)
get root_path
assert_select 'div.pagination'
# Invalid submission
assert_no_difference 'Micropost.count' do
po... | 29.540541 | 71 | 0.706313 |
6a0ea12b62ef8af1055fe03734f063854d3ec40c | 1,345 | class Conan < Formula
include Language::Python::Virtualenv
desc "Distributed, open source, package manager for C/C++"
homepage "https://github.com/conan-io/conan"
url "https://github.com/conan-io/conan/archive/1.23.0.tar.gz"
sha256 "0f670f1b7d14fb6edf106971651f311e447d3d6d09cdd3c59ff84fae4fcb79f7"
head "ht... | 37.361111 | 94 | 0.725651 |
8786d295d6a23d4f224c8b59b35e8dda171ec294 | 1,664 | # frozen_string_literal: true
module Clusters
module Applications
class CheckUninstallProgressService < BaseHelmService
def execute
return unless app.uninstalling?
case installation_phase
when Gitlab::Kubernetes::Pod::SUCCEEDED
on_success
when Gitlab::Kubernetes::... | 26.412698 | 128 | 0.640024 |
2185c940717688d2845a07cb5ef859d2d7e06a75 | 979 | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'buildmetrics/version'
Gem::Specification.new do |spec|
spec.name = "buildmetrics"
spec.version = Buildmetrics::VERSION
spec.authors = ["Solomon White"]
spec.email ... | 37.653846 | 79 | 0.675179 |
7a55d83cc54b5649490aabe0141cca1dddaf74d0 | 2,244 | # Has the content "session=<base64>"
COOKIE_FILE = 'cookie'
YEAR=2021
def strip_newlines(strs)
strs.map {|str| str.delete_suffix("\n")}
end
# Run ./decXX.rb <test_name> to run code on input in file decXX.<test_name>.
#
# For input like:
# a
# b
# c
def get_input_str_arr(original_filename)
dot_slash_date = origin... | 21.371429 | 76 | 0.665775 |
ff51e3e13562d667a0f16efe20b229316f952e5f | 208 | class AddGoogleSyncToGroups < ActiveRecord::Migration
def change
add_column :groups, :google_sync, :boolean, null: false, default: false
add_column :groups, :google_sync_user_id, :integer
end
end
| 29.714286 | 75 | 0.764423 |
79ce49a50e5273433eecb3cc7606014e051dc3f7 | 809 | class IntegrationHelper
MIN_RUBY_VERSIONS = {
'rails_5.2.4.1' => '>= 2.2.2',
'rails_6.0.2.1' => '>= 2.5.0'
}.freeze
def self.able_to_run?(file_path, ruby_version)
return false unless ENV['INTEGRATION_TESTS']
file_name = File.basename(file_path)
rails_app = File.basename(file_name, '_spec.rb'... | 28.892857 | 73 | 0.656366 |
d5f6a558672f87fdbf3f35ec6f48e11642d7620c | 97 | SparkleFormation.dynamic(:local_dynamic) do
outputs.bar do
value "local_dynamic"
end
end
| 16.166667 | 43 | 0.762887 |
acd76f67a81fd7e000f3e90133e67dd93455c1c2 | 1,691 | FactoryBot.define do
factory :representative, class: OpenStruct do
end
trait :representative_valid do
type {:"questions.your_representatives_details.type_of_representative.options.solicitor"}
organisation_name { Faker::Company.bs }
name { Faker::Name.name }
building {"106"}
street {"Mayfair"}... | 36.76087 | 129 | 0.743938 |
d5895d8e5d19fd240dcc47f1321e8bc80cc1f43e | 344 | require 'clientele/pipeline/transforms'
module Clientele
class Pipeline
class Transforms
class Before < self
# Before forces yielding after transformation
def apply(transform)
Proc.new do |object, &block|
block.call transform.call(object)
end
end
... | 20.235294 | 53 | 0.622093 |
bf4c300198830d676ab14d6f921bd1db4642955a | 2,137 | class Hydra < Formula
desc "Network logon cracker which supports many services"
homepage "https://github.com/vanhauser-thc/thc-hydra"
url "https://github.com/vanhauser-thc/thc-hydra/archive/v9.1.tar.gz"
sha256 "ce08a5148c0ae5ff4b0a4af2f7f15c5946bc939a57eae1bbb6dda19f34410273"
license "AGPL-3.0"
head "https:... | 37.491228 | 106 | 0.709406 |
f741685a29c9190c8638418dad041b70a948d97e | 452 | require "test_helper"
class WryteePalindromeTest < Minitest::Test
def test_non_palindrome
refute "apple".palindrome?
end
def test_literal_palindrome
assert "racecar".palindrome?
end
def test_mixed_case_palindrome
assert "RaceCar".palindrome?
end
def test_palindrome_with_punctuation
as... | 17.384615 | 58 | 0.74115 |
ab2893ca7e3d7040903aabc3186c18d64055d9b6 | 3,470 | ##
# $Id: mysql_payload.rb 11899 2011-03-08 22:42:26Z todb $
##
##
# This file is part of the Metasploit Framework and may be subject to
# redistribution and commercial restrictions. Please see the Metasploit
# Framework web site for more information on licensing and terms of use.
# http://metasploit.com/frame... | 31.545455 | 113 | 0.67147 |
9103530d8df9bb2d8a12f2af24fcff0d1feb367f | 573 | Pod::Spec.new do |s|
s.name = 'Reader'
s.version = '2.7.3'
s.license = 'MIT'
s.summary = 'The open source PDF file reader/viewer for iOS.'
s.homepage = 'http://www.vfr.org/'
s.authors = { "Julius Oklamcak" => "joklamcak@gmail.com" }
s.source = { :git => 'https://github.com/vfr/Reader.git', :tag => "v#{s.version}... | 35.8125 | 91 | 0.643979 |
e8d7915d061a73bc3d6be2f4104dee7f8b6178bc | 761 | # frozen_string_literal: true
require 'test_helper'
class MeasureTest < Minitest::Test
def test_to_s
id = Spectator::MeterId.new('name')
m = Spectator::Measure.new(id, 42)
assert_equal("Measure{id=#{id}, value=42.0}", m.to_s)
end
def test_equal
id = Spectator::MeterId.new('name', test: 'val')
... | 23.060606 | 57 | 0.639947 |
4a870d434a1091b26c0cde7125ca676e953667b2 | 719 | def connected_graph?(graph)
visited = [0]
key = 0
queue = graph[key]
until queue.empty?
key = queue.shift
next if visited.include?(key)
for value in graph[key]
if !visited.include?(value)
queue << value
end
end
visited << key
end
visited.size == graph.keys.size
... | 14.098039 | 34 | 0.44089 |
ff1f39b8c8f128b9976b644191e84c31d7e03955 | 1,295 | class DataExport < ActiveRecord::Base
class Error < ::StandardError ; end
class FileNotFoundError < Error ; end
class FilePermissionError < Error ; end
def self.data_attribute(name, options={})
reader_method, writer_method = name, "#{name}="
define_method(reader_method){ data.fetch(name){ options[:defa... | 26.428571 | 88 | 0.687259 |
380baed7f135ca1db5f55d950a5802a98329ca15 | 45 | require_relative "deployment/packages/kibana" | 45 | 45 | 0.888889 |
1ddaeffba702cfed9af1737001562c0628edb7c9 | 528 | Pod::Spec.new do |s|
s.name = "RPJSONMapper"
s.version = "0.3.1"
s.summary = "JSON to object property mapper"
s.homepage = "https://github.com/reygonzales/RPJSONMapper"
s.license = 'MIT'
s.author = { "Rey Gonzales" => "reynaldo@mail.sfsu.edu" }
s.platform = :ios, '5.0'... | 37.714286 | 104 | 0.596591 |
186839ec551c13161d42be36e7a2db3546b9c7b0 | 380 | When /^I create a data bag '(.+)' containing the JSON '(.+)'$/ do |bag, json|
write_file "item.json", json
run_simple "knife data bag create #{bag} -z -c knife.rb -d"
run_simple "knife data bag from_file #{bag} -z -c knife.rb item.json"
end
Given(/^I create an empty data bag '(.+)'$/) do |databag|
run_simple "... | 38 | 77 | 0.655263 |
ff25b8f1c5035250f658a31244521f5b107d0922 | 2,370 | module Somemoji
class CommandLineArguments
# @param argv [Array<String>]
def initialize(argv)
@argv = argv
end
# @return [String]
def destination
slop_parse_result[:destination]
end
# @return [String]
def error_message
slop_options.to_s
end
# @return [Strin... | 26.629213 | 112 | 0.58903 |
38f62cbfe8cb8680902c461ae5b3cd712bcc5558 | 131 | class EchosController < ApiController
def show
respond_with Garage::HashRepresenter.new(:message => "Hello World")
end
end
| 21.833333 | 71 | 0.755725 |
87ef763ea44573330032125a23e1e09c1ef2fb9b | 870 | # frozen_string_literal: true
def add_or_delete_schedule(remove, cron_jobs, key)
if remove
Sidekiq.remove_schedule(key.to_s)
else
cron_jobs[key] = SCHEDULED_JOBS[key]
end
end
SCHEDULED_JOBS = {
clean_old_releases: {
cron: '0 6 * * *',
class: 'CleanOldReleasesJob',
queue: 'schedule',
de... | 24.857143 | 80 | 0.713793 |
3332c2deb62125c07d6f0575d96c21c61291712e | 2,047 | # encoding: utf-8
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
module Azure::ServiceFabric::V7_0_0_42
module Models
#
# Information about a Service Fabric property.
#
class PropertyInfo
include ... | 27.662162 | 75 | 0.513434 |
e84f4e95083fa5d34f3b0b27fcb7557b0e2848b3 | 123 | class AddNoCanDoDayToUsers < ActiveRecord::Migration
def change
add_column :users, :no_can_do_day, :date
end
end
| 13.666667 | 52 | 0.756098 |
33871dcae4edafb8e46856dcfb12b22b6227e35e | 1,380 | require 'rails_helper'
require 'datetime_period'
RSpec.describe DatetimePeriod, type: :model do
describe 'validations' do
let(:monday_string) { '20 September 2021 09:00' }
let(:tuesday_string) { '21 September 2021 09:00' }
it { is_expected.to validate_presence_of(:start_at_string) }
it { is_expected... | 32.857143 | 104 | 0.71087 |
61e7128d10387c495ba362c9d0410a76eb90b918 | 445 | # encoding: utf-8
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
module Azure::EdgeGateway::Mgmt::V2019_03_01
module Models
#
# Defines values for DownloadPhase
#
module DownloadPhase
Unknown = "Un... | 23.421053 | 70 | 0.694382 |
6107f2865757462e26c11ebc5d12eac2b0fc62ad | 2,283 | require 'ds9.so'
require 'stringio'
module DS9
VERSION = '1.1.1'
module Frames
class Frame
Header = Struct.new :length, :stream_id, :type, :flags
def length
header.length
end
def settings?; false; end
def headers?; false; end
def data?; false; end
def p... | 17.976378 | 60 | 0.605344 |
2629e29e7ffbb6a9f8e330ef4bbfc96677deb861 | 595 | Pod::Spec.new do |s|
s.name = "Verbena"
s.version = "0.0.2"
s.summary = "A collection of Core Graphics helper methods."
s.homepage = "https://github.com/kaishin/Verbena"
s.screenshots = "https://raw.github.com/kaishin/Verbena/master/screenshot.png"
s.license = 'BSD'
s.author ... | 39.666667 | 88 | 0.606723 |
e945571cf40eea2e5defa6d034f1f5a0fe11cb35 | 3,635 | require "yaml"
require_relative "data_loader"
Rect = Struct.new(:left, :top, :right, :bottom)
class Tileset
def self.load(name, loader: DataLoader)
data = loader.load_file("tilesets/#{name}")
new(data)
end
def initialize(tiles)
@tiles = tiles
end
def [](key)
tiles[key]
end
private
... | 16.674312 | 70 | 0.663549 |
e2158868b4c8924e80f79631b09ee4a779fa3934 | 2,029 | # frozen_string_literal: true
# rubocop:disable Style/NumericLiteralPrefix
describe RuboCop::Cop::Lint::ScriptPermission do
subject(:cop) { described_class.new(config, options) }
let(:config) { RuboCop::Config.new }
let(:options) { nil }
let(:file) { Tempfile.new('') }
let(:filename) { file.path.split('/')... | 22.797753 | 80 | 0.625924 |
79c00390669df9eb8cc63ee28344584792306d69 | 3,301 | require 'minitest/autorun'
require_relative 'pangram'
# Common test data version: 1.3.0 d79e13e
class PangramTest < Minitest::Test
def test_sentence_empty
# skip
phrase = ''
result = Pangram.pangram?(phrase)
refute result, "Expected false, got: #{result.inspect}. #{phrase.inspect} is NOT a pangram"
... | 33.683673 | 95 | 0.719479 |
5d78e5fbfd376159bebf34fb5e702750fcc415b1 | 1,414 | Spree::CheckoutController.class_eval do
before_filter :pay_with_payu, only: :update
private
def pay_with_payu
return unless params[:state] == 'confirm'
pm_id = @order.payments.order('created_at ASC').last.payment_method_id
payment_method = Spree::PaymentMethod.find(pm_id)
if payment_method &&... | 25.25 | 113 | 0.685997 |
282b79a3d0f49ff2072b912a84718fba75eff154 | 564 | module UiHelper
def return_to_dashboard_button
link_to "Return to Dashboard", root_path, {class: "btn btn-info pull-right"}
end
def grouped_options_for_assigning_case(volunteer)
[
[
"Not Assigned",
CasaCase
.not_assigned(@volunteer.casa_org)
.map{ |casa_case| [ca... | 24.521739 | 80 | 0.62234 |
bb19a9ce8ab008da0abca0f4c385c906bb42a8e8 | 1,332 | class Castxml < Formula
desc "C-family Abstract Syntax Tree XML Output"
homepage "https://github.com/CastXML/CastXML"
url "https://mirrors.ocf.berkeley.edu/debian/pool/main/c/castxml/castxml_0.1+git20170823.orig.tar.xz"
mirror "https://mirrorservice.org/sites/ftp.debian.org/debian/pool/main/c/castxml/castxml_0.... | 35.052632 | 127 | 0.71997 |
b98cb585c349954661838194a81b5ed1b880a726 | 1,175 | require_dependency "wms/application_controller"
module Wms
class AccountsController < ApplicationController
def welcome
end
def signup
@account = Wms::Account.new
end
def login
end
def logout
cookies.delete(:token)
session[:return_to] = nil
redirect_to root_url, no... | 22.596154 | 64 | 0.658723 |
038e8c51320d70e28c350e49e97724a4e62cae87 | 662 |
module EpicRoadTrips
class EpicRoadTrips::Trips
attr_accessor :road, :country, :description
def self.get_page
doc = Nokogiri::HTML(open("https://www.fodors.com/news/photos/the-20-best-road-trips-on-earth"))
list_trips = doc.css(".container.slides")
list_trips.collect do |road_trip|
... | 27.583333 | 103 | 0.599698 |
4ac5237e2dbf3402449eda5c8288a64811968395 | 808 | {
matrix_id: '1850',
name: 'BenElechi1',
group: 'BenElechi',
description: 'problem with many sparse right-hand sides, S. Ben Elechi',
author: 'S. Ben Elechi',
editor: 'T. Davis',
date: '2007',
kind: '2D/3D problem',
problem_2D_or_3D: '1',
num_rows: '245874',
num_cols: '245874... | 27.862069 | 78 | 0.648515 |
21d4a265599ae82d6728f9fe74a15b509cdf3827 | 3,439 | #
# Copyright Peter Donald
#
# 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 applicable law or agreed to in writing, so... | 39.079545 | 180 | 0.727246 |
e8062ddb09b824d6bed46e48189cca5f19f563fb | 1,655 | require 'test_helper'
class FollowingTest < ActionDispatch::IntegrationTest
def setup
@user = users(:michael)
@other = users(:archer)
log_in_as(@user)
end
test "following page" do
get following_user_path(@user)
assert_not @user.following.empty?
assert_match @user.following.count.to_s, ... | 28.534483 | 77 | 0.699094 |
5d291d9d7230707719059f45ea6de7a715ee396c | 2,535 | # frozen_string_literal: true
module Gitlab
module GithubImport
module Importer
class PullRequestsImporter
include ParallelScheduling
def importer_class
PullRequestImporter
end
def representation_class
Gitlab::GithubImport::Representation::PullRequest
... | 27.857143 | 112 | 0.625641 |
26e82b31fdc82cdb3e389a4a1fce072eac091300 | 669 | require WulinAuth::Engine.root.join('lib', 'password_complexity_validator')
module WulinAuth
class User < ApplicationRecord
has_secure_password
validates :email, presence: true, uniqueness: true
validates_with PasswordComplexityValidator
scope :by_token, lambda { |token|
where(["token = ? AND ... | 23.892857 | 75 | 0.695067 |
792137781391ef3c4363405b415926b96963b6d9 | 697 | require 'sinatra'
require 'byebug'
set :port, 3000
set :bind, '0.0.0.0'
def json(hash)
content_type :json
JSON.pretty_generate hash
end
def authorized?
auth ||= Rack::Auth::Basic::Request.new(request.env)
auth.provided? and auth.basic? and auth.credentials and auth.credentials == ["bill","dollar"]
end
def ... | 17 | 95 | 0.688666 |
e2fd009a5fab431c24aabb54f70e345fb177ef4e | 1,585 | require File.expand_path('../../../spec_helper', __FILE__)
ruby_version_is '2.5' do
describe "Integer#anybits?" do
it "returns true iff all the bits of the argument are set in the receiver" do
42.anybits?(42).should == true
0b1010_1010.anybits?(0b1000_0010).should == true
0b1010_1010.anybits?(0... | 40.641026 | 91 | 0.666246 |
1deff801fbe079f91eaccb40580490c8d93b5506 | 281 | cask 'terraform-0.8.1' do
version '0.8.1'
sha256 '275104513600bf50a28942131d928d2be405c75f9f36a9c722718500075856a1'
url "https://releases.hashicorp.com/terraform/#{version}/terraform_#{version}_darwin_amd64.zip"
name 'Terraform'
homepage 'https://www.terraform.io/'
end
| 31.222222 | 97 | 0.775801 |
7a98b12cedea9ae22a60895482b585db3e12a442 | 766 | cask "sauerbraten" do
version "2020.11.29,2020.12.21"
sha256 "a7e26c85ff15be88b9ced26e64c2fa0e68bde1325c146763833abac591898bcb"
url "https://downloads.sourceforge.net/sauerbraten/sauerbraten/#{version.csv.first.dots_to_underscores}/sauerbraten_#{version.csv.second.dots_to_underscores}_macos.dmg",
verified:... | 33.304348 | 171 | 0.686684 |
e9d7d8b190fb8d7c33bb9a6d5adac0740e9f3775 | 1,031 | # Cookbook Name:: docker_engine
# Attributes:: default
#
# Author : OneOps
# Apache License, Version 2.0
# Docker binary attributes
default[:docker_engine][:service] = 'docker'
default[:docker_engine][:package] = 'docker-engine'
default[:docker_engine][:release] = '1.el7.centos'
default[:docker_engine][:arch] = 'x86_6... | 41.24 | 102 | 0.748788 |
335e245615005cc03aa0781fe44aa70ac1906a87 | 980 | # frozen_string_literal: true
module Interaction
#
# The Result object is responsible for reporting the status and details
# of the action it was initialized on. A Result is a success until it
# is explicitly invoked to fail.
#
#
# Example usage
# result = Result.new
#
# result.fail(error: "Cou... | 18.148148 | 73 | 0.614286 |
1ae2dbaf1208198df73a514097129da7fbde4b9a | 8,393 | require 'test_helper'
begin
require "hiredis"
require "redis/connection/hiredis"
puts "running tests with hiredis driver"
rescue LoadError
puts "running test with default redis driver"
end
class TestRedis < Minitest::Test
ERROR_TIMEOUT = 5
ERROR_THRESHOLD = 1
SEMIAN_OPTIONS = {
name: :testing,
t... | 25.510638 | 134 | 0.694031 |
01a02202d0cb1c4d76fa0b9d53963edbc0618a87 | 574 | require 'test_helper'
class AssetTextDatumTest < ActiveSupport::TestCase
def setup
@asset_data = asset_text_datum(:one)
end
test "should validate with valid data" do
skip
assert @asset_data.valid?
end
test "should check if data is present" do
skip
@asset_data.data = ""
assert_not @assert_d... | 21.259259 | 53 | 0.736934 |
61d01eb7e918ecb1ef2bf105a0d76c239211540f | 9,435 | require 'spec_helper'
require 'puppet/defaults'
describe "Puppet defaults" do
describe "when default_manifest is set" do
it "returns ./manifests by default" do
expect(Puppet[:default_manifest]).to eq('./manifests')
end
end
describe "when disable_per_environment_manifest is set" do
it "return... | 37.145669 | 201 | 0.701007 |
4a8a43c41159ae47cf454ec2b51b14025a1dabc4 | 1,118 | # frozen_string_literal: true
class CreateEmployees < ActiveRecord::Migration[6.0]
def change
create_table :employees do |t|
t.references :user
t.references :language
t.references :company
t.references :team
t.string :uuid, limit: 36, null: false, index: true, unique: true
t.s... | 31.055556 | 71 | 0.653846 |
4a1f31ea444c980a06a01fc3453c02dff15887e9 | 1,118 | module Spree
class Store < Spree::Base
has_many :store_payment_methods, inverse_of: :store
has_many :payment_methods, through: :store_payment_methods
validates :code, presence: true, uniqueness: { allow_blank: true }
validates :name, presence: true
validates :url, presence: true
validates :ma... | 26.619048 | 85 | 0.685152 |
032efb2b1830c35dec4f8debb4c207913d5fa6ce | 21,557 | require 'timeout'
require 'digest'
# Message Queue entry to run a method on any server
# zone
# This states the subset of miq_servers in this region that can perform this job.
# put: Defaults to the zone of the current caller ("MyZone")
# Pass in nil to have this performed in any zone.
# get: Fe... | 36.475465 | 582 | 0.660528 |
01104aaad9c684be64a096389b5be5fa304bbf6c | 35 | module SSE
VERSION = "2.1.0"
end
| 8.75 | 19 | 0.628571 |
f742c84833f3686ffd84fc3a66860038d238d0dc | 1,058 | RSpec.shared_examples "ResourceList" do |klass|
let(:all_records){ klass.list.to_a }
context "default page size (50)" do
subject { klass.list }
specify "#to_a returns all records" do
expect(subject.to_a).to match_array all_records
end
end
context "page size: 2" do
subject { klass.list(p... | 24.045455 | 53 | 0.655955 |
038cbf1f2f2cf5d36aef8d1e0b95690d47026cfd | 1,962 | require "abstract_unit"
require "active_support/core_ext/module/concerning"
class ModuleConcerningTest < ActiveSupport::TestCase
def test_concerning_declares_a_concern_and_includes_it_immediately
klass = Class.new { concerning(:Foo) {} }
assert klass.ancestors.include?(klass::Foo), klass.ancestors.inspect
... | 29.727273 | 86 | 0.724261 |
f89ba5b8af459d687f83f6db7918a209380b1817 | 36 |
require_relative 'utils/calculator' | 18 | 35 | 0.861111 |
f7ddc6de12713315eeb306aab934aec359f0f38e | 2,214 | cask 'docker' do
if MacOS.version <= :el_capitan
version '18.06.1-ce-mac73,26764'
sha256 '3429eac38cf0d198039ad6e1adce0016f642cdb914a34c67ce40f069cdb047a5'
else
version '2.0.0.0-ce-mac81,29211'
sha256 '5343fa169b9f7bc6f41f91e5797d148a21d2c0fc1d5c2da80d7d93ed6b3bd1ff'
end
url "https://download.d... | 40.254545 | 89 | 0.552846 |
7abf45060d74f7bb6d9e96ff6ccce7ce2cfdbc77 | 762 | $LOAD_PATH.push File.expand_path('../lib', __FILE__)
# Maintain your gem's version:
require 'fastread/version'
# Describe your gem and declare its dependencies:
Gem::Specification.new do |s|
s.name = 'fastread'
s.version = Fastread::VERSION
s.authors = %w(sovetnik MistaTwista)
s.email = [... | 31.75 | 107 | 0.675853 |
61f30a914da94f5f7b2b69e6b19b16c15b9e4ab3 | 115 | require_relative "../models/group"
class GroupRepository
def self.list
Group.order("LOWER(name)")
end
end
| 14.375 | 34 | 0.721739 |
ab2a172bd1266307120925d8b64fba0b67501a72 | 4,554 | # frozen_string_literal: true
# Copyright 2015-2017, the Linux Foundation, IDA, and the
# CII Best Practices badge contributors
# SPDX-License-Identifier: MIT
# rubocop:disable Metrics/BlockLength
# The priority is based upon order of creation:
# first created -> highest priority.
# See how all your routes lay out w... | 33.485294 | 80 | 0.668863 |
e818c73c2bbe5dbec572690561b794200a146688 | 620 | require 'test_helper'
class UsersProfileTest < ActionDispatch::IntegrationTest
include ApplicationHelper
def setup
@user = users(:michael)
end
# test "profile display" do
# get user_path(@user)
# assert_template 'users/show'
# assert_select 'title', full_title(@user.name)
# assert_select... | 26.956522 | 61 | 0.696774 |
919b2f50e10768fffcf74e8d0057413689cbe68d | 7,005 | require 'spec_helper'
RSpec.describe Sentry::Event do
let(:configuration) do
Sentry::Configuration.new.tap do |config|
config.dsn = DUMMY_DSN
end
end
describe "#initialize" do
it "initializes a Event when all required keys are provided" do
expect(described_class.new(configuration: config... | 34.170732 | 129 | 0.61556 |
61e3865d536511aa4d8439daf659981a409d9bca | 1,850 | # cf. https://github.com/rubyzip/rubyzip/tree/d07b13a6cf0a413e010c48879aebd9576bfb5f68#zipping-a-directory-recursively
require 'zip'
# This is a simple example which uses rubyzip to
# recursively generate a zip file from the contents of
# a specified directory. The directory itself is not
# included in the archive, ra... | 31.355932 | 118 | 0.708649 |
4ae5cb0b3446e8327fee3b14d715125f0e7a701f | 2,440 | module Helpers
def self.random_lowercase_name
[*('a'..'z')].sample(8).join
end
class ServiceFactory
private_class_method :new
attr_reader :service
def self.new_service(client)
new(client).service
end
private
def initialize(client)
@service = create_service(client)
... | 27.41573 | 88 | 0.620082 |
acab7dd32d1a845a4bf42c08a53f1bff79f85866 | 3,994 | # frozen_string_literal: true
require "json"
class ByteInterpreter
##
# The Instructions class represents a collection of ordered operations to
# perform on an IO stream. This class is used by ByteInterpreter to either
# interpret or encode bytes in a rigid, structured way.
#
# At the most basic level, In... | 35.981982 | 113 | 0.673761 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.