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 |
|---|---|---|---|---|---|
bffc475055c368bcbfbaeac99e952b64de19a2d5 | 44 | class Connection < ActiveRecord::Base
end
| 11 | 37 | 0.772727 |
1df9d43c7ffef913b3cb67e34e3bccfeba461037 | 191 | #!/usr/bin/env ruby
# -*- encoding: us-ascii -*-
desc "readme", "Display helpful information for beginners"
def readme
STDOUT.write Bun.readfile("doc/readme.md", :encoding=>'us-ascii')
end | 27.285714 | 67 | 0.706806 |
18024db8dd3a6c7bb9a6f770a2ec535ca5b61719 | 289 | module Jekyll
module Tags
class ContentFor < Liquid::Block
include ::Jekyll::ContentBlocks::ContentBlockTag
alias_method :render_block, :render
def render(context)
content_for_block(context) << render_block(context)
''
end
end
end
end
| 19.266667 | 59 | 0.657439 |
abc45bed5e8033780936fe72e64ef5f1c2a3bafa | 72 | # frozen_string_literal: true
module RailsPing
VERSION = '0.1.4'
end
| 12 | 29 | 0.736111 |
0160aaef213b7e1c4cc832eb9ed38a499df0eef3 | 1,324 | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'vir/version'
Gem::Specification.new do |spec|
spec.name = "vir"
spec.version = Vir::VERSION
spec.authors = ["723"]
spec.email = ["rb.natsumi@gmail.com"]
sp... | 35.783784 | 96 | 0.650302 |
1d880422641eabcdd1331cf04126a40beffec63b | 793 | class CollectionsSideNav < Draper::Decorator
attr_reader :collection, :form
def initialize(collection:, form:)
@collection = collection
@form = form
end
def homepage_link
h.link_to("Homepage", h.site_setup_form_collection_path(collection, form: "homepage"))
end
def copyright_text_link
h.l... | 25.580645 | 97 | 0.723834 |
1d2e4d42c5d18cca71329e02464f58160ed8472c | 8,314 | # Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved.
# This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either lic... | 40.359223 | 245 | 0.671518 |
03ce2eb22f499977025328d8a973e217f2baf85d | 389 | cask 'craftmanager' do
version '1.0.87'
sha256 '14faf273dcb13c610a32d10aacace2b8989df4cedab7dc01d53b5c712116d96d'
url 'https://craft-assets.invisionapp.com/CraftManager/production/CraftManager.zip'
appcast 'https://craft-assets.invisionapp.com/CraftManager/production/appcast.xml'
name 'CraftManager'
homepa... | 32.416667 | 85 | 0.796915 |
e935083b117ef2069eaf1048dedfb18baf1fab92 | 51 | module TestBoosters
VERSION = "2.2.4".freeze
end
| 12.75 | 26 | 0.72549 |
6a9af75a14c6e554892c754f499b1bed7ceafb27 | 208 | # frozen_string_literal: true
SolidusTaxExemptions.configure do |config|
# TODO: Remember to change this with the actual preferences you have implemented!
# config.sample_preference = 'sample_value'
end
| 29.714286 | 83 | 0.798077 |
4a9631ac25673f5a223ee9634c074a36efc043a4 | 1,521 | # frozen_string_literal: true
require 'kubernetes-deploy/container_logs'
module KubernetesDeploy
class RemoteLogs
attr_reader :container_logs
def initialize(logger:, parent_id:, container_names:, namespace:, context:)
@logger = logger
@parent_id = parent_id
@container_logs = container_name... | 24.934426 | 93 | 0.613412 |
395377ae2d9695e9b5ec988faadc3756687f2046 | 1,331 | require 'test_helper'
class Blog::SettingTest < ActiveSupport::TestCase
def setup
@user = users(:michael)
@yangsong = users(:yangsong)
@setting = @user.blog_setting
end
test 'should be valid' do
assert @setting.valid?
end
test 'domain should be unique' do
setting = @user.blog_setting
... | 22.559322 | 72 | 0.703231 |
6a2d3c8d328de98c834fddc0fa713b3b7e1a73f9 | 499 | require 'spec_helper'
describe Sufia::Download, type: :model do
before do
@download = described_class
end
it 'has an events metric' do
expect(@download.metrics).to be == Legato::ListParameter.new(:metrics, [:totalEvents])
end
it 'has dimensions' do
expect(@download.dimensions).to be == Legato::... | 24.95 | 132 | 0.707415 |
5dcad30405d11e4100a0d2eebabd362022f212b5 | 87 | module CurrencyCloud
class PurposeCode
include CurrencyCloud::Resource
end
end
| 14.5 | 35 | 0.793103 |
79ca689949876cbb549b92c829d68ac87d519531 | 1,352 | class Goreleaser < Formula
desc "Deliver Go binaries as fast and easily as possible"
homepage "https://goreleaser.com/"
url "https://github.com/goreleaser/goreleaser/archive/v0.102.0.tar.gz"
sha256 "b8340f4c6f5d285f027eab0dc1cd5f34842ed3daf38fee21e3ff8c32301297b7"
bottle do
root_url "https://linuxbrew.bi... | 39.764706 | 94 | 0.747781 |
bfb69d7ddbc49268fa1ab711b5f6b0beb504de43 | 653 | class UsersController < ApplicationController
before_action :require_login, except: [:new, :create]
def new
@user = User.new
end
def create
@user = User.create(user_params)
# binding.pry
if @user.valid?
session[:user_id] = @user.id
redirect_to user_path(@user)
else
rend... | 20.40625 | 98 | 0.647779 |
38fa05a668e97e9fc7ec93b2aed9870cb18a3b40 | 2,258 | #
# Traverse the filesystem with a nice helper function.
#
# @see https://github.com/gizmore/filewalker
#
# @version 1.00
# @since 1.00
# @author gizmore@wechall.net
# @license MIT
#
class GDO::File::Walker
def self.proc_files(dir, pattern='*', dotfiles=true, &block)
__traverse(dir, pattern, false, dotfiles, tru... | 27.204819 | 102 | 0.572631 |
1a23475fd5a0d0eded8b5e1655ce727226e742b1 | 1,657 | #!/usr/bin/env ruby
require 'sinatra'
require 'pp'
require 'sqlite3'
require 'json'
db = SQLite3::Database.new "ids.db"
rows = db.execute "CREATE TABLE IF NOT EXISTS order_ids(id TEXT, activated BIT);"
set :environment, :production
set :port, 8001
post '/add-id' do
# So users can't add a key
unless request.env.k... | 21.519481 | 81 | 0.633675 |
61a9cf05dbccecdaa82e0eda37b3d12e48cb8bf3 | 1,670 | Prosedy::Application.routes.draw do
devise_for :users
root 'proses#index'
resources :proses
# The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes".
# You can have the root of your site routed with "root"
# root 'welcome#in... | 26.935484 | 84 | 0.648503 |
fffd4440bb7dbae6c144c00259d410206e7e725b | 329 | module Dotclear2
class User < ActiveRecord::Base
set_table_name 'dc_user'
set_primary_key 'user_id'
establish_connection configurations['dc2']
has_many :posts, :foreign_key => 'user_id', :class_name => 'Dotclear2::Post'
def self.prefix=(prefix)
set_table_name "#{prefix}_user"
end
... | 23.5 | 80 | 0.68997 |
7a988bb0f853108fbd92593edb027f7f68a6b530 | 1,603 | require 'taglib'
require 'active_support/core_ext/hash'
module Id3Tags
module MP3FieldsReader
private
def get_tag_fields(file, attrs = {})
read_tag_fields(file, attrs) do |opts|
file.tag.send opts[:method]
end
end
def get_audio_properties_fields(file, attrs = {})
read_audio_p... | 26.716667 | 65 | 0.64005 |
1a6eccaf8bb46e930ab236dd68a63b1f750f8a06 | 6,170 | =begin
#NSX-T Data Center Policy API
#VMware NSX-T Data Center Policy REST API
OpenAPI spec version: 3.1.0.0.0
Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.4.17
=end
require 'date'
module NSXTPolicy
# Site fedeation configuration.
class SiteFederationConfig
#... | 28.173516 | 107 | 0.610859 |
33a16476aba364453a529daa3d925b4c37c50402 | 786 | cask "pokemon-trading-card-game-online" do
version "2.88.0.5535"
sha256 :no_check
url "https://tcgo-installer.s3.amazonaws.com/PokemonInstaller_Mac.dmg",
verified: "https://tcgo-installer.s3.amazonaws.com/"
name "Pokemon Trading Card Game Online"
desc "Play the Pokemon TCG online"
homepage "https://w... | 41.368421 | 133 | 0.75827 |
f75e69d569a81a5ff16ea3cc95b31673ebd328fd | 1,515 | class Xgboost < Formula
desc "Scalable, Portable and Distributed Gradient Boosting Library"
homepage "https://xgboost.ai/"
url "https://github.com/dmlc/xgboost.git",
tag: "v1.2.0",
revision: "738786680b65b6f7716e9db2ae60161c6121926f"
license "Apache-2.0"
bottle do
sha256 cellar: :any, ca... | 33.666667 | 135 | 0.740594 |
21801c73e780cc6f426b1fe63eb15cdf2299046a | 819 | require 'test_helper'
class MicropostsControllerTest < ActionDispatch::IntegrationTest
def setup
@micropost = microposts(:orange)
end
test 'should redirect create when not logged in' do
assert_no_difference 'Micropost.count' do
post microposts_path, params: { micropost: { content: 'Lorem ipsum' } ... | 26.419355 | 77 | 0.741148 |
aceafe101d0334a0775a5df30cee2255b4ef550d | 3,029 | module Spree
module Core
module ControllerHelpers
module Common
def self.included(base)
base.class_eval do
helper_method :title
helper_method :title=
helper_method :accurate_title
helper_method :current_order
helper_method :curren... | 31.226804 | 132 | 0.597557 |
4a62c6d7b07f88437d201cadef0ffe4cc2933e5c | 3,598 | module Api
module V1
module Mobile::Util
class SecurityUtil < Api::V1::Mobile::Base
attr_accessor :employer_profile, :person
def initialize args
super args
@employer_profile = EmployerProfile.find @params[:employer_profile_id] if @params[:employer_profile_id]
@... | 34.266667 | 141 | 0.622568 |
aca41a6f51a119f420042b2131d28dbac29e6078 | 161 | # frozen_string_literal: true
require_relative "../config/environment"
module CourierStories
class Error < StandardError; end
# Your code goes here...
end
| 17.888889 | 40 | 0.763975 |
ff655559236a9299f394ca2e6b0c8e3cfc7ba403 | 936 | # frozen_string_literal: true
class Benefits < ApplicationRecord
def self.save(file, backup = false)
data_path = Rails.root.join("public", "data")
full_file_name = "#{data_path}/#{file.original_filename}"
f = File.open(full_file_name, "wb+")
f.write file.read
f.close
make_backup(file, data_pa... | 29.25 | 128 | 0.678419 |
ab74eb31f7c3859b9336ec44ca6ab4e9c7601805 | 1,338 | =begin
#Datadog API V1 Collection
#Collection of all Datadog Public endpoints.
The version of the OpenAPI document: 1.0
Contact: support@datadoghq.com
Generated by: https://openapi-generator.tech
Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
This product... | 35.210526 | 108 | 0.800448 |
03f778989cc581008f4371576a96bf14d8f80705 | 3,023 | # Generated by the protocol buffer compiler. DO NOT EDIT!
# source: google/cloud/dataplex/v1/content.proto
require 'google/protobuf'
require 'google/api/annotations_pb'
require 'google/api/client_pb'
require 'google/api/field_behavior_pb'
require 'google/api/resource_pb'
require 'google/cloud/dataplex/v1/analyze_pb'... | 45.80303 | 166 | 0.748263 |
acefbde9d0fce148f2c71cfea24e2037c150917b | 4,949 | require File.dirname(File.join(__rhoGetCurrentDir(), __FILE__)) + '/../../spec_helper'
require File.dirname(File.join(__rhoGetCurrentDir(), __FILE__)) + '/fixtures/classes'
describe "Module#include" do
it "calls #append_features(self) in reversed order on each module" do
$appended_modules = []
m = Module.ne... | 31.724359 | 116 | 0.672257 |
6a3c7979e1fa58eb987794ed3a2b7909bf406569 | 172 | class Item < ApplicationRecord
belongs_to :category
validates_presence_of :name, :price, :category_id
validates_numericality_of :price, :greater_than => 0
end
| 24.571429 | 56 | 0.761628 |
873e066728b56e62b5455c41572dd31c1f159cee | 15,604 | class PeopleController < ApplicationController
include ApplicationHelper
include ErrorBubble
include VlpDoc
before_action :sanitize_contact_method, only: [:update]
def new
@person = Person.new
build_nested_models
# render action: "new", layout: "form"
end
def check_qle_marriage_date
dat... | 36.12037 | 237 | 0.702128 |
4ab7cb8292d53717c9fdbc9e94b3ffe2e4b8b74a | 942 | # (C) Copyright 2017 Hewlett Packard Enterprise Development LP
#
# 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... | 42.818182 | 98 | 0.771762 |
014c247687939370bbe13a648322991d85903187 | 797 | class CompleteSkill < ServiceObject
def setup
validate_key :skill, :user
validate("cannot re-complete a skill") { |c| !Completion.for(c.user, c.skill) }
validate("provide a valid skill") { org_matches? }
end
def run
create_completion(context.user, context.skill)
complete_deadline
rescue
... | 23.441176 | 83 | 0.713927 |
bb42d63a9bddd5d21066e5e9d7f1f3e3d1b8acd1 | 5,449 | # Copyright (c) 2018-2019 VMware, Inc. All Rights Reserved.
# SPDX-License-Identifier: MIT
# DO NOT MODIFY. THIS CODE IS GENERATED. CHANGES WILL BE OVERWRITTEN.
# vcenter - VMware vCenter Server provides a centralized platform for managing your VMware vSphere environments
require 'date'
module VSphereAutomation
... | 28.984043 | 111 | 0.620481 |
6293e80adf7fa41fbc8b760403b7993b64d0d0e9 | 139 | module GeoConcerns
class VectorWorkShowPresenter < GeoConcernsShowPresenter
self.file_format_service = VectorFormatService
end
end
| 23.166667 | 58 | 0.841727 |
e297d33a9518108054800a2c595e6afee5d1b860 | 1,820 | require_relative './queue_latency'
module RooOnRails
module Sidekiq
class Settings
DEFAULT_QUEUE_LATENCY_VALUES = {
'monitoring' => 10.seconds.to_i,
'realtime' => 10.seconds.to_i,
'within1minute' => 1.minute.to_i,
'within5minutes' => 5.minutes.to_i,
'within30minutes'... | 32.5 | 131 | 0.573626 |
1136370ab0b6c7d9dc91115f363fd13f93df3bb3 | 5,452 | require 'test_helper'
class AccountsControllerTest < ActionController::TestCase
fixtures :accounts
def test_should_allow_signup_if_enabled
Masquerade::Application::Config['disable_registration'] = false
assert_difference 'Account.count' do
post :create, :account => valid_account_attributes
... | 37.861111 | 116 | 0.781548 |
383e622a1ce59211e3381bc477291b6b72d54de4 | 552 | cask 'pdfsam-basic' do
version '2.2.4'
sha256 'fa8686d2be68ee67be40324723f316e8d5b708924e25b58af5296f7f302ede46'
# github.com is the official download host per the vendor homepage
url "https://github.com/torakiki/pdfsam-v2/releases/download/v#{version}/pdfsam-#{version}.dmg"
appcast 'https://github.com/torak... | 36.8 | 97 | 0.759058 |
e85b764bdc4a9c3a53a8737589a69165dd080d01 | 1,214 | require File.expand_path('../boot', __FILE__)
# Pick the frameworks you want:
require "active_record/railtie"
require "action_controller/railtie"
# require "action_mailer/railtie"
# require "sprockets/railtie"
# require "rails/test_unit/railtie"
# Require the gems listed in Gemfile, including any gems
# you've limite... | 39.16129 | 99 | 0.73229 |
117e4373e9641630b2c2e29bc50a6b8642d6c40d | 1,301 | require "routing/shared_examples"
describe EmsInfraController do
let(:controller_name) { "ems_infra" }
it_behaves_like "A controller that has advanced search routes"
it_behaves_like "A controller that has compare routes"
it_behaves_like "A controller that has CRUD routes"
it_behaves_like "A controller that ... | 26.02 | 93 | 0.700231 |
5d38b00fc16313e4194815cd5342c7c1e902ed8f | 204 | class AddScormCloudPlainIdToScormCourse < ActiveRecord::Migration
def change
add_column :scorm_courses, :scorm_cloud_plain_id, :integer
add_index :scorm_courses, :scorm_cloud_plain_id
end
end
| 29.142857 | 65 | 0.813725 |
612fd46bb961e54666e61e95979e9d147f26e886 | 515 | class CreateChangesets < ActiveRecord::Migration
def self.up
create_table :changesets do |t|
t.column :repository_id, :integer, :null => false
t.column :revision, :integer, :null => false
t.column :committer, :string, :limit => 30
t.column :committed_on, :datetime, :null => false
t.c... | 30.294118 | 103 | 0.667961 |
39a9dd553094d287a06821785ec88ad73328d551 | 12,021 | # frozen_string_literal: true
# Copyright The OpenTelemetry Authors
#
# SPDX-License-Identifier: Apache-2.0
require 'test_helper'
require 'opentelemetry-sdk'
describe OpenTelemetry::Propagator::Jaeger::TextMapPropagator do
let(:propagator) { OpenTelemetry::Propagator::Jaeger::TextMapPropagator.new }
before do
... | 37.332298 | 96 | 0.68555 |
e9eb27d605eb002a9ed267401accb9807e8159e8 | 357 | # frozen_string_literal: true
# setroubleshoot.rb
# Check if setroubleshoot package is installed
Facter.add('setroubleshoot_pkg') do
confine :osfamily => 'RedHat'
setcode do
val = Facter::Core::Execution.exec("rpm -q setroubleshoot")
if val.empty? or val =~ %r{not installed} then
false
e... | 21 | 65 | 0.663866 |
6151fa9a67fc84cc58689edd3ede8529900dfa96 | 823 | # -*- encoding: utf-8 -*-
Gem::Specification.new do |gem|
gem.authors = ["Joel Andritsch", "Damon Butler"]
gem.email = ["joel.andritsch@gmail.com", "iamdamocles@gmail.com"]
gem.description = %q{MTGExtractor is a Ruby gem that allows you to extract Magic: The Gathering card information from the Ga... | 41.15 | 144 | 0.648846 |
ab7633c760d77d4f49699e907ea613003ff6a6b5 | 2,556 | require File.expand_path('../../../../../spec_helper', __FILE__)
module Pod
class Installer
class Xcode
class PodsProjectGenerator
describe AppHostInstaller do
before do
@project = Project.new(config.sandbox.project_path)
config.sandbox.project = @project
... | 48.226415 | 120 | 0.651017 |
03a5e9b39adf52440f1573e2e9971a9a57045520 | 5,374 | module RailsEmailPreview
class EmailsController < ::RailsEmailPreview::ApplicationController
include ERB::Util
before_filter :load_preview, except: :index
around_filter :set_locale
before_filter :set_email_preview_locale
helper_method :with_email_locale
# List of emails
def index
@p... | 34.229299 | 127 | 0.669334 |
610ace2d6715c3bfb159b3df99a432398f30393b | 680 | class CreateSipityModelsSimpleControlledVocabularies < ActiveRecord::Migration[4.2]
def change
create_table :sipity_simple_controlled_vocabularies do |t|
t.string :predicate_name
t.string :predicate_value
t.timestamps null: false
end
add_index :sipity_simple_controlled_vocabularies, :p... | 42.5 | 162 | 0.816176 |
62cabbeebecd45301449b88214df3a7c7184a41d | 2,054 | #
# Cookbook Name:: apt
# Attributes:: default
#
# Copyright 2009-2013, Opscode, Inc.
#
# 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
#
# Un... | 43.702128 | 75 | 0.728335 |
7a91c21650d5e4a52e5b920f41d18ff172f2734f | 139 | require File.expand_path('../../../spec_helper', __FILE__)
describe "Dir.chroot" do
it "needs to be reviewed for spec completeness"
end
| 23.166667 | 58 | 0.726619 |
6a20e2d608d8428011f368f4206bdbd8e40f22fe | 3,336 | require File.expand_path('../../spec_helper', __FILE__)
describe ReadmeScore::Document::Filter do
describe "#filtered_html!" do
describe "removing license" do
it "works" do
html = %Q{
<h2>LICENSE</h2>
<p>Some info about the license here</p>
<p>More info</p>}
f... | 30.054054 | 96 | 0.53717 |
035c73335a80a04ad4a6e53a36f3bc2c86dd603a | 4,786 | # -*- encoding : utf-8 -*-
require 'spec_helper'
describe 'Tagger' do
before(:each) do
@user = User.create
@taggable = TaggableModel.create(name: 'Bob Jones')
end
it 'should have taggings' do
@user.tag(@taggable, with: 'ruby,scheme', on: :tags)
expect(@user.owned_taggings.size).to eq(2)
end
... | 33.704225 | 87 | 0.657961 |
1c10216b8eebd4465052bb93cf318ecefff45599 | 215 | class GenCompanies < ActiveRecord::Migration[5.1]
def up
Company.reset_column_information
User.find_each do |u|
u.create_company if u.company.nil?
end
end
def down
# nothing
end
end
| 14.333333 | 49 | 0.67907 |
ffb997a5ee3d497c8516b2bfee795ea1ce6c761c | 168 | json.array!(@attendances) do |attendance|
json.extract! attendance, :id, :attendance, :client_id, :lesson_id
json.url attendance_url(attendance, format: :json)
end
| 33.6 | 68 | 0.755952 |
626b32508f56254b2ba21c64c6a8003d03eb993c | 900 | # frozen_string_literal: true
# JoinPre: join an array of values with separator as a string and using the separator at the beginning of string
RSpec.describe Funcky::AArray::JoinPre do
let(:instance) { described_class.new }
describe 'initialize' do
subject { instance }
it { is_expected.not_to be_nil ... | 21.95122 | 112 | 0.618889 |
0852aa05e5d4acb0da0cb57d59bb2f094f7460db | 1,612 | class CreateUnidomChinaIdentityCards < ActiveRecord::Migration
def change
create_table :unidom_china_identity_cards, id: :uuid do |t|
t.string :name, null: false, default: '', limit: 200
t.date :birth_date, null: false, default: nil
t.string :address, null: false, default: '', limi... | 42.421053 | 173 | 0.650744 |
bb2a121b89ea61b3a6d4479fa063f005e157c0f8 | 3,082 | require 'rubygems'
require_relative 'lib/sweph4ruby'
require 'test/unit'
class Rsweph_test < Test::Unit::TestCase
def test_initialize()
s = Rsweph.new()
assert_equal($LOAD_PATH[1] , s.eph_path)
end
def test_swe_set_ephe_path()
s = Rsweph.new()
s.swe_set_ephe_path($LOAD_PATH[1])
assert_e... | 23.707692 | 78 | 0.659637 |
d5136e49a54864b92846ffe284c57c309f51508f | 669 | class FixPartOrdering < Mongoid::Migration
def self.up
count = 0
Edition.skip_callback(:save, :before, :check_for_archived_artefact)
Edition.all.each do |edition|
next unless edition.is_a?(Parted)
if edition.parts.map(&:order).any?(&:nil?)
puts "Fixing nil parts order for #{edition.t... | 29.086957 | 107 | 0.663677 |
e23cc3bcfec6828f522f456cdaacc18ad20a4fce | 2,962 | # Readable Code Refactoring Challenge
# -----------------------------------
# Goals of readable code
# 1. Elimination of repetition, using looping and branching wisely
# 2. Complex operations are decomposed into constituent parts
# 3. Descriptive names for methods, variables, classes, and modules
# 4. Methods are smal... | 33.659091 | 110 | 0.674882 |
bfd636fa62acf5f3e66adb36e1e3a2cef1aadcd3 | 41,775 | # frozen_string_literal: true
class MergeRequest < ApplicationRecord
include AtomicInternalId
include IidRoutes
include Issuable
include Noteable
include Referable
include Presentable
include TimeTrackable
include ManualInverseAssociation
include EachBatch
include ThrottledTouch
include Gitlab::U... | 29.050765 | 161 | 0.732974 |
f83dfaf9bb34ef481957684184511be0edda6468 | 925 | module Tinder
class Util
HEADERS = {
'Content-Type': 'application/json',
'User-agent': 'Tinder/7.5.3 (iPhone; iOS 10.3.2; Scale/2.00)'
}
class << self
def request(method, endpoint, payload, headers)
uri = URI.parse('https://api.gotinder.com' + endpoint)
https = Net::... | 24.342105 | 69 | 0.547027 |
61b4018e04beff144312f4134b22a066988448fa | 1,535 | # frozen_string_literal: true
module GitHubPages
module HealthCheck
class Error < StandardError
DOCUMENTATION_BASE = "https://help.github.com"
DOCUMENTATION_PATH = "/categories/github-pages-basics/"
LOCAL_ONLY = false # Error is only used when running locally
attr_reader :repository, :do... | 23.257576 | 80 | 0.591531 |
26995947a9dd615af81738c3b223a9f8e30c7be4 | 990 | require File.expand_path('../boot', __FILE__)
require 'rails/all'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(:default, Rails.env)
module RailsTagBench
class Application < Rails::Application
# Settings in config/environments/... | 41.25 | 99 | 0.724242 |
39bf889f13b26acae66f836c5c79c28bfa946670 | 442 | module CardNumberValidator
module Cards
class Hipercard
REGEX_LIST = [
/^606282\d{10}$/,
/^3841(0|4|6)0\d{13}$/
].freeze
def self.validate(card_number)
return unless card_number
REGEX_LIST.each { |rgx| return true if rgx.match(card_number) }
false
... | 19.217391 | 71 | 0.572398 |
6aae5910e68ab20022bb9a9654657137800415d6 | 3,268 | # Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
module Azure::Web::Mgmt::V2015_04_01
module Models
#
# Azure resource. This resource is tracked in Azure Resource Manager
#
class Resource
include Ms... | 27.008264 | 72 | 0.445838 |
382ce0feda0c812d3595e28b3ce679b8c9ef4b5c | 63,638 | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Projects::IssuesController do
include ProjectForksHelper
include_context 'includes Spam constants'
let_it_be(:project, reload: true) { create(:project) }
let_it_be(:user, reload: true) { create(:user) }
let(:issue) { create(:issue, project... | 31.739651 | 241 | 0.635014 |
f874517dcee3db8a5ac2eac87dedd60538a91ea0 | 151 | module UCD
module Node
module HasName
attr_reader :name
def name=(value)
@name = value.to_s
end
end
end
end
| 9.4375 | 26 | 0.556291 |
ed2ea43546a6cf8f3d5ad7f7826659090b58e6e3 | 1,141 | # encoding: utf-8
require 'spec_helper'
describe Mutant::Mutator::Node::ConditionalLoop do
context 'with while statement' do
let(:source) { 'while true; foo; bar; end' }
let(:mutations) do
mutations = []
mutations << 'while true; bar; end'
mutations << 'while true; foo; end'
mutati... | 26.534884 | 50 | 0.593339 |
877613d384e3b917aa11fc59f43bd3308a35d133 | 4,219 | ##
# This module requires Metasploit: http://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##
class MetasploitModule < Msf::Exploit::Remote
Rank = ExcellentRanking
include Msf::Exploit::Remote::HttpClient
include Msf::Auxiliary::WmapScanUniqueQuery
def initialize(in... | 30.79562 | 90 | 0.556293 |
625b9ba6c13367836719f926b99d092b2b05f83b | 1,973 | # Defines our constants
RACK_ENV = ENV['RACK_ENV'] ||= 'development' unless defined?(RACK_ENV)
PADRINO_ROOT = File.expand_path('../..', __FILE__) unless defined?(PADRINO_ROOT)
# Load our dependencies
require 'bundler/setup'
Bundler.require(:default, RACK_ENV)
##
# ## Enable devel logging
#
# Padrino::Logger::Config[:... | 27.402778 | 101 | 0.73188 |
ac655dfa55c6a093d0c36daf151a332da1de2361 | 1,520 | # frozen_string_literal: true
class PhotoUploader < CarrierWave::Uploader::Base
# Include RMagick or MiniMagick support:
# include CarrierWave::RMagick
# include CarrierWave::MiniMagick
# Choose what kind of storage to use for this uploader:
storage :file
# storage :fog
# Override the directory where u... | 30.4 | 112 | 0.701316 |
bf970df59d22955ad1d42e8aeedc6fce40a08387 | 1,043 | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'aji_second_gem/version'
Gem::Specification.new do |spec|
spec.name = "aji_second_gem"
spec.version = AjiSecondGem::VERSION
spec.authors = ["ajith"]
spec.email ... | 33.645161 | 96 | 0.653883 |
ffa6541c7278f9b0518439cd3a8ab2cf4c2128b9 | 4,001 | # frozen_string_literal: false
require 'test/unit'
class TestIseqLoad < Test::Unit::TestCase
require '-test-/iseq_load'
ISeq = RubyVM::InstructionSequence
def test_bug8543
assert_iseq_roundtrip "#{<<~"begin;"}\n#{<<~'end;'}"
begin;
puts "tralivali"
def funct(a, b)
a**b
end
... | 25.484076 | 92 | 0.564109 |
3352dd624c0b1e0ab5cdc144837edf02d3fa4e50 | 1,767 | require 'spec_helper'
describe Spree::ReimbursementTaxCalculator, type: :model do
subject do
Spree::ReimbursementTaxCalculator.call(reimbursement)
end
let!(:tax_rate) { nil }
let(:reimbursement) { create(:reimbursement, return_items_count: 1) }
let(:return_item) { reimbursement.return_items.first }
l... | 28.047619 | 87 | 0.674024 |
5d95392af99f41066627094ea58fa94c0d82cfe7 | 3,108 | require File.expand_path('../boot', __FILE__)
require 'rails/all'
if defined?(Bundler)
# If you precompile assets before deploying to production, use this line
Bundler.require(*Rails.groups(:assets => %w(development test)))
# If you want your assets lazily compiled in production, use this line
# Bundler.requi... | 44.4 | 156 | 0.741634 |
bb3f14ce89ff9b4cb5579fd776f934e7e38fe177 | 2,552 | # frozen_string_literal: true
# This file was auto-generated by lib/tasks/web.rake
desc 'Reminders methods.'
command 'reminders' do |g|
g.desc 'Creates a reminder.'
g.long_desc %( Creates a reminder. )
g.command 'add' do |c|
c.flag 'text', desc: 'The content of the reminder.'
c.flag 'time', desc: 'When t... | 44 | 249 | 0.696317 |
1832c6bed8323346ff23a13d01a9a7687220b480 | 421 | # frozen_string_literal: true
require 'bundler/setup'
require_relative '../lib/datatrans_ruby_api'
RSpec.configure do |config|
# Enable flags like --only-failures and --next-failure
config.example_status_persistence_file_path = '.rspec_status'
# Disable RSpec exposing methods globally on `Module` and `main`
... | 24.764706 | 66 | 0.76247 |
5d606bac43102c56485ee181857b49cb430ac84a | 2,552 | # frozen_string_literal: true
RSpec.describe FaradayMiddleware::FollowRedirects do
it 'redirects on 301' do
stub_request(:get, 'http://www.site-a.com/').to_return(
status: 301,
headers: { 'Location' => 'https://www.site-b.com/' }
)
stub_request(:get, 'https://www.site-b.com/')
connection... | 30.380952 | 68 | 0.640674 |
e9e849199e3c513ada26f1e02e6954a96b122df0 | 3,822 | module IntegrationMacros
extend ActiveSupport::Concern
module ClassMethods
##
# Creates a integration testing context with a particular
# type of user.
#
# Accepts keyword arguments which are given directly to
# the User factory to customize the user as the test sees fit.
#
# The 'r... | 31.586777 | 158 | 0.629775 |
1d12d48cf32bce94db9d47cb988288f2f591fc01 | 4,151 | require 'ostruct'
require 'pact_broker/api/pact_broker_urls'
require 'pact_broker/api/decorators/reason_decorator'
require 'pact_broker/api/decorators/format_date_time'
module PactBroker
module Api
module Decorators
class MatrixDecorator
include PactBroker::Api::PactBrokerUrls
include Forma... | 29.439716 | 112 | 0.564442 |
5d2f7df2d41f32feb23198c4b24a78429de0cfd0 | 129 | class AddCardRefToComments < ActiveRecord::Migration[5.2]
def change
add_reference :comments, :card, index: true
end
end
| 21.5 | 57 | 0.751938 |
abc328d31050212f7788b1bff0ea42f8c131908d | 228 | # frozen_string_literal: true
namespace :solidus do
desc "Delete Spree::Price records which amount field is NULL"
task delete_prices_with_nil_amount: :environment do
Spree::Price.where(amount: nil).delete_all
end
end
| 25.333333 | 63 | 0.780702 |
ac186f9488ceded889ac269ed4c483651cd68e82 | 1,148 | class Streams::ParentChild::LinksProcessor
def self.update_parent_and_sort_siblings(edition, parent_warehouse_id)
new(edition, parent_warehouse_id).update_parent_and_sort_siblings
end
def initialize(edition, parent_warehouse_id)
@edition = edition
@parent_warehouse_id = parent_warehouse_id
end
d... | 28.7 | 104 | 0.790941 |
08fbb50b5d5663b30e6bd8ea94834c496d773d5e | 1,509 | # frozen_string_literal: true
require 'telegram/core_ext'
module Telegram
module API
module Bot
module Methods
# See the {https://core.telegram.org/bots/api#setwebhook official documentation}.
#
# @!attribute [rw] url
# @return [String]
# @!attribute [rw] certific... | 27.436364 | 89 | 0.508946 |
ac499e0f15679f4706bb030456f53ba8ed8cbd7e | 730 | require File.dirname(__FILE__) + '/abstract_unit'
require 'action_controller' # console_app uses 'action_controller/integration'
unless defined? ApplicationController
class ApplicationController < ActionController::Base; end
end
require 'dispatcher'
require 'console_app'
# console_app sets Test::Unit.run to work ... | 24.333333 | 95 | 0.726027 |
010fc6828d727297a7e659089c677dfc25208785 | 1,743 | Pod::Spec.new do |s|
s.name = "ADXLibrary"
s.version = "1.5.8.1"
s.summary = "ADX Library for iOS"
s.license = {"type"=>"MIT", "file"=>"LICENSE"}
s.authors = {"Chiung Choi"=>"god@adxcorp.kr"}
s.homepage = "https://github.com/adxcorp/AdxLibrary_iOS"
s.description = "ADX Library for iOS"
s.frameworks = ["... | 56.225806 | 236 | 0.550775 |
117f723d7026d1366f0ee6dff1b83969dbf07b37 | 6,582 | # encoding: utf-8
# This file is autogenerated. Do not edit it manually.
# If you want change the content of this file, edit
#
# /spec/fixtures/responses/whois.ua/ua/uaepp/status_registered.expected
#
# and regenerate the tests with the following rake task
#
# $ rake spec:generate
#
require 'spec_helper'
require ... | 43.019608 | 113 | 0.705409 |
338aa9099a7995b6e425e831193b5fe991622c23 | 6,179 | class Food
CALORIES_DAILY_VALUE = 2000 # Constant of calories's daily value
TOTAL_FAT_DAILY_VALUE = 65 # Constant of total fat's maximum daily value
SATURATED_FAT_DAILY_VALUE = 20 # Constant of saturated fat's maximum ... | 53.267241 | 143 | 0.635216 |
266ded690266fc8acdd5da2c2fe2508694846d51 | 1,849 | Rails.application.routes.draw do
resources :reservations
resources :spaces
get 'users/index'
get 'users/show'
devise_for :users, :controllers => { registrations: 'registrations' }
resources :users, :only => [:index, :show]
get 'home/index'
root 'home#index'
# The priority is based upon order of... | 25.680556 | 84 | 0.64954 |
7a27c0e7a54ce81582e9c34262ff790a6defe842 | 1,330 | # -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = "activeresource"
s.version = "3.2.20"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["David Heinemeier Hansson"]
s.date = "2014-10-29"
s.description = "REST on Rails. Wrap... | 35.945946 | 124 | 0.657895 |
e2d0a91e01b3c13874254c24889f02935329e9c2 | 1,024 | require 'amalgalite'
# this is Functions
module Functions
def exe(query)
Rubylite.new.exec_this(@database, query)
end
def find_table_name
(to_s + 's').downcase
end
def first(arg = 1)
exe("select * from #{find_table_name} order by
#{find_table_name}.id ASC limit #{arg}")
end
def take(... | 22.755556 | 76 | 0.625977 |
2160f461fe997ba30792d07ddf647ef53ff690b7 | 532 | # -*- encoding : utf-8 -*-
require 'git_stats/hash_initializable'
module GitStats
module GitData
class Tree
include HashInitializable
attr_reader :repo, :relative_path
def authors
@authors ||= run_and_parse("git shortlog -se #{commit_range}").map do |author|
Author.new(repo:... | 22.166667 | 86 | 0.610902 |
4a4ed2327a33646fad638c43a49b47475b6ade92 | 1,884 | # encoding: UTF-8
# via https://github.com/bbhoss/ruby-hl7/blob/master/lib/segments/in1.rb
class HL7::Message::Segment::IN1 < HL7::Message::Segment
add_field :set_id
add_field :insurance_plan_id
add_field :insurance_company_id
add_field :insurance_company_name
add_field :insurance_company_address
add_field ... | 32.482759 | 72 | 0.838641 |
bfd553ac2a44417db254bb43e56e662d6945d441 | 4,567 | # frozen_string_literal: true
require "generators/generators_test_helper"
require "rails/generators/rails/controller/controller_generator"
class ControllerGeneratorTest < Rails::Generators::TestCase
include GeneratorsTestHelper
arguments %w(Account foo bar)
setup :copy_routes
def test_help_does_not_show_inv... | 31.715278 | 114 | 0.762207 |
216063bb66754d2d394f7db6ada31b0d40cecbfe | 278 | module Aggro
module Message
# Public: OK message.
class OK
TYPE_CODE = '01'.freeze
def self.parse(_string)
new
end
def self.new
@singleton ||= super
end
def to_s
"#{TYPE_CODE}"
end
end
end
end
| 13.238095 | 29 | 0.514388 |
f720899a26b5a536e8d698de726b52c36ec604d2 | 2,507 | # frozen_string_literal: true
module Fog
module Compute
class Aliyun
class Real
# Mount a disk.
#
# ==== Parameters
# * instanceId<~String> - id of the instance
# * diskId<~String> - id of the disk
# * options<~hash>
# * :deleteWithInstance - if '... | 30.573171 | 123 | 0.534105 |
ff3e0a3780fc94e52d621c77fda91046273b7cef | 3,505 | # 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... | 43.271605 | 154 | 0.694722 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.