repo
stringlengths
5
92
file_url
stringlengths
80
287
file_path
stringlengths
5
197
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 15:37:27
2026-01-04 17:58:21
truncated
bool
2 classes
mislav/will_paginate
https://github.com/mislav/will_paginate/blob/50017c3eb0712e7b3a53268a81e81a184b7a49f6/spec/spec_helper.rb
spec/spec_helper.rb
require 'rspec' require 'view_helpers/view_example_group' Dir[File.expand_path('../matchers/*_matcher.rb', __FILE__)].each { |matcher| require matcher } RSpec::Matchers.alias_matcher :include_phrase, :include RSpec.configure do |config| config.include Module.new { protected def have_deprecation(msg) ...
ruby
MIT
50017c3eb0712e7b3a53268a81e81a184b7a49f6
2026-01-04T15:42:46.511340Z
false
mislav/will_paginate
https://github.com/mislav/will_paginate/blob/50017c3eb0712e7b3a53268a81e81a184b7a49f6/spec/finders/active_record_spec.rb
spec/finders/active_record_spec.rb
require 'spec_helper' require 'will_paginate/active_record' require File.expand_path('../activerecord_test_connector', __FILE__) ActiverecordTestConnector.setup RSpec.describe WillPaginate::ActiveRecord do extend ActiverecordTestConnector::FixtureSetup fixtures :topics, :replies, :users, :projects, :develop...
ruby
MIT
50017c3eb0712e7b3a53268a81e81a184b7a49f6
2026-01-04T15:42:46.511340Z
false
mislav/will_paginate
https://github.com/mislav/will_paginate/blob/50017c3eb0712e7b3a53268a81e81a184b7a49f6/spec/finders/activerecord_test_connector.rb
spec/finders/activerecord_test_connector.rb
require 'active_record' require 'active_record/fixtures' require 'stringio' require 'erb' require 'time' require 'date' require 'yaml' # forward compatibility with Rails 7 (needed for time expressions within fixtures) class Time alias_method :to_fs, :to_s end unless Time.new.respond_to?(:to_fs) # monkeypatch needed...
ruby
MIT
50017c3eb0712e7b3a53268a81e81a184b7a49f6
2026-01-04T15:42:46.511340Z
false
mislav/will_paginate
https://github.com/mislav/will_paginate/blob/50017c3eb0712e7b3a53268a81e81a184b7a49f6/spec/fixtures/project.rb
spec/fixtures/project.rb
class Project < ActiveRecord::Base has_and_belongs_to_many :developers, :join_table => 'developers_projects' has_many :topics # :finder_sql => 'SELECT * FROM topics WHERE (topics.project_id = #{id})', # :counter_sql => 'SELECT COUNT(*) FROM topics WHERE (topics.project_id = #{id})' has_many :replie...
ruby
MIT
50017c3eb0712e7b3a53268a81e81a184b7a49f6
2026-01-04T15:42:46.511340Z
false
mislav/will_paginate
https://github.com/mislav/will_paginate/blob/50017c3eb0712e7b3a53268a81e81a184b7a49f6/spec/fixtures/topic.rb
spec/fixtures/topic.rb
class Topic < ActiveRecord::Base has_many :replies, :dependent => :destroy belongs_to :project scope :mentions_activerecord, lambda { where(['topics.title LIKE ?', '%ActiveRecord%']) } end
ruby
MIT
50017c3eb0712e7b3a53268a81e81a184b7a49f6
2026-01-04T15:42:46.511340Z
false
mislav/will_paginate
https://github.com/mislav/will_paginate/blob/50017c3eb0712e7b3a53268a81e81a184b7a49f6/spec/fixtures/reply.rb
spec/fixtures/reply.rb
class Reply < ActiveRecord::Base scope :recent, lambda { where(['replies.created_at > ?', 15.minutes.ago]). order('replies.created_at DESC') } validates_presence_of :content end
ruby
MIT
50017c3eb0712e7b3a53268a81e81a184b7a49f6
2026-01-04T15:42:46.511340Z
false
mislav/will_paginate
https://github.com/mislav/will_paginate/blob/50017c3eb0712e7b3a53268a81e81a184b7a49f6/spec/fixtures/schema.rb
spec/fixtures/schema.rb
ActiveRecord::Schema.define do create_table "users", :force => true do |t| t.column "name", :text t.column "salary", :integer, :default => 70000 t.column "created_at", :datetime t.column "updated_at", :datetime t.column "type", :text end create_table "projects", :force => tr...
ruby
MIT
50017c3eb0712e7b3a53268a81e81a184b7a49f6
2026-01-04T15:42:46.511340Z
false
mislav/will_paginate
https://github.com/mislav/will_paginate/blob/50017c3eb0712e7b3a53268a81e81a184b7a49f6/spec/fixtures/admin.rb
spec/fixtures/admin.rb
class Admin < User has_many :companies end
ruby
MIT
50017c3eb0712e7b3a53268a81e81a184b7a49f6
2026-01-04T15:42:46.511340Z
false
mislav/will_paginate
https://github.com/mislav/will_paginate/blob/50017c3eb0712e7b3a53268a81e81a184b7a49f6/spec/fixtures/developer.rb
spec/fixtures/developer.rb
class Developer < User has_and_belongs_to_many :projects, :join_table => 'developers_projects' scope :poor, lambda { where(['salary <= ?', 80000]).order('salary') } def self.per_page() 10 end end
ruby
MIT
50017c3eb0712e7b3a53268a81e81a184b7a49f6
2026-01-04T15:42:46.511340Z
false
mislav/will_paginate
https://github.com/mislav/will_paginate/blob/50017c3eb0712e7b3a53268a81e81a184b7a49f6/spec/fixtures/user.rb
spec/fixtures/user.rb
class User < ActiveRecord::Base end
ruby
MIT
50017c3eb0712e7b3a53268a81e81a184b7a49f6
2026-01-04T15:42:46.511340Z
false
mislav/will_paginate
https://github.com/mislav/will_paginate/blob/50017c3eb0712e7b3a53268a81e81a184b7a49f6/spec/view_helpers/action_view_spec.rb
spec/view_helpers/action_view_spec.rb
# encoding: utf-8 require 'spec_helper' require 'action_controller' require 'action_view' require 'will_paginate/view_helpers/action_view' require 'will_paginate/collection' Routes = ActionDispatch::Routing::RouteSet.new Routes.draw do get 'dummy/page/:page' => 'dummy#index' get 'dummy/dots/page.:page' => 'dummy#...
ruby
MIT
50017c3eb0712e7b3a53268a81e81a184b7a49f6
2026-01-04T15:42:46.511340Z
false
mislav/will_paginate
https://github.com/mislav/will_paginate/blob/50017c3eb0712e7b3a53268a81e81a184b7a49f6/spec/view_helpers/view_example_group.rb
spec/view_helpers/view_example_group.rb
require 'active_support' require 'stringio' require 'minitest/assertions' require 'rails/dom/testing/assertions' require 'will_paginate/array' module ViewExampleGroup include Rails::Dom::Testing::Assertions::SelectorAssertions include Minitest::Assertions def assert(value, message) raise message unless v...
ruby
MIT
50017c3eb0712e7b3a53268a81e81a184b7a49f6
2026-01-04T15:42:46.511340Z
false
mislav/will_paginate
https://github.com/mislav/will_paginate/blob/50017c3eb0712e7b3a53268a81e81a184b7a49f6/spec/view_helpers/base_spec.rb
spec/view_helpers/base_spec.rb
require 'spec_helper' require 'will_paginate/view_helpers' require 'will_paginate/array' require 'active_support' require 'active_support/core_ext/string/inflections' require 'active_support/inflections' RSpec.describe WillPaginate::ViewHelpers do before(:all) do # make sure default translations aren't loaded ...
ruby
MIT
50017c3eb0712e7b3a53268a81e81a184b7a49f6
2026-01-04T15:42:46.511340Z
false
mislav/will_paginate
https://github.com/mislav/will_paginate/blob/50017c3eb0712e7b3a53268a81e81a184b7a49f6/spec/view_helpers/link_renderer_base_spec.rb
spec/view_helpers/link_renderer_base_spec.rb
require 'spec_helper' require 'will_paginate/view_helpers/link_renderer_base' require 'will_paginate/collection' RSpec.describe WillPaginate::ViewHelpers::LinkRendererBase do before do @renderer = described_class.new end it "should raise error when unprepared" do expect { @renderer.pagination...
ruby
MIT
50017c3eb0712e7b3a53268a81e81a184b7a49f6
2026-01-04T15:42:46.511340Z
false
mislav/will_paginate
https://github.com/mislav/will_paginate/blob/50017c3eb0712e7b3a53268a81e81a184b7a49f6/spec/matchers/query_count_matcher.rb
spec/matchers/query_count_matcher.rb
RSpec::Matchers.define :execute do |expected_count| match do |block| run(block) if expected_count.respond_to? :include? expected_count.include? @count else @count == expected_count end end def run(block) $query_count = 0 $query_sql = [] block.call ensure @queries = ...
ruby
MIT
50017c3eb0712e7b3a53268a81e81a184b7a49f6
2026-01-04T15:42:46.511340Z
false
mislav/will_paginate
https://github.com/mislav/will_paginate/blob/50017c3eb0712e7b3a53268a81e81a184b7a49f6/spec-non-rails/sequel_spec.rb
spec-non-rails/sequel_spec.rb
require_relative './spec_helper' require 'sequel' require 'will_paginate/sequel' Sequel.sqlite.create_table :cars do primary_key :id, :integer, :auto_increment => true column :name, :text column :notes, :text end RSpec.describe Sequel::Dataset::Pagination, 'extension' do class Car < Sequel::Model self.da...
ruby
MIT
50017c3eb0712e7b3a53268a81e81a184b7a49f6
2026-01-04T15:42:46.511340Z
false
mislav/will_paginate
https://github.com/mislav/will_paginate/blob/50017c3eb0712e7b3a53268a81e81a184b7a49f6/spec-non-rails/mongoid_spec.rb
spec-non-rails/mongoid_spec.rb
require_relative './spec_helper' require 'will_paginate/mongoid' RSpec.describe WillPaginate::Mongoid do class MongoidModel include Mongoid::Document end before(:all) do Mongoid.configure do |config| mongodb_host = ENV["MONGODB_HOST"] || "localhost" mongodb_port = ENV["MONGODB_PORT"] || "27...
ruby
MIT
50017c3eb0712e7b3a53268a81e81a184b7a49f6
2026-01-04T15:42:46.511340Z
false
mislav/will_paginate
https://github.com/mislav/will_paginate/blob/50017c3eb0712e7b3a53268a81e81a184b7a49f6/spec-non-rails/spec_helper.rb
spec-non-rails/spec_helper.rb
require 'rspec' RSpec.configure do |config| config.mock_with :mocha config.expose_dsl_globally = false config.expect_with :rspec do |expectations| expectations.include_chain_clauses_in_custom_matcher_descriptions = true end config.shared_context_metadata_behavior = :apply_to_host_groups config.disable_...
ruby
MIT
50017c3eb0712e7b3a53268a81e81a184b7a49f6
2026-01-04T15:42:46.511340Z
false
mislav/will_paginate
https://github.com/mislav/will_paginate/blob/50017c3eb0712e7b3a53268a81e81a184b7a49f6/lib/will_paginate.rb
lib/will_paginate.rb
# You will paginate! module WillPaginate end if defined?(Rails::Railtie) require 'will_paginate/railtie' elsif defined?(Rails::Initializer) raise "will_paginate 3.0 is not compatible with Rails 2.3 or older" end if defined?(Sinatra) and Sinatra.respond_to? :register require 'will_paginate/view_helpers/sinatra' ...
ruby
MIT
50017c3eb0712e7b3a53268a81e81a184b7a49f6
2026-01-04T15:42:46.511340Z
false
mislav/will_paginate
https://github.com/mislav/will_paginate/blob/50017c3eb0712e7b3a53268a81e81a184b7a49f6/lib/will_paginate/page_number.rb
lib/will_paginate/page_number.rb
require 'forwardable' module WillPaginate # a module that page number exceptions are tagged with module InvalidPage; end # integer representing a page number class PageNumber < Numeric # a value larger than this is not supported in SQL queries BIGINT = 9223372036854775807 extend Forwardable ...
ruby
MIT
50017c3eb0712e7b3a53268a81e81a184b7a49f6
2026-01-04T15:42:46.511340Z
false
mislav/will_paginate
https://github.com/mislav/will_paginate/blob/50017c3eb0712e7b3a53268a81e81a184b7a49f6/lib/will_paginate/active_record.rb
lib/will_paginate/active_record.rb
require 'will_paginate/per_page' require 'will_paginate/page_number' require 'will_paginate/collection' require 'active_record' module WillPaginate # = Paginating finders for ActiveRecord models # # WillPaginate adds +paginate+, +per_page+ and other methods to # ActiveRecord::Base class methods and associatio...
ruby
MIT
50017c3eb0712e7b3a53268a81e81a184b7a49f6
2026-01-04T15:42:46.511340Z
false
mislav/will_paginate
https://github.com/mislav/will_paginate/blob/50017c3eb0712e7b3a53268a81e81a184b7a49f6/lib/will_paginate/collection.rb
lib/will_paginate/collection.rb
require 'will_paginate/per_page' require 'will_paginate/page_number' module WillPaginate # Any will_paginate-compatible collection should have these methods: # # current_page, per_page, offset, total_entries, total_pages # # It can also define some of these optional methods: # # out_of_bounds?, previ...
ruby
MIT
50017c3eb0712e7b3a53268a81e81a184b7a49f6
2026-01-04T15:42:46.511340Z
false
mislav/will_paginate
https://github.com/mislav/will_paginate/blob/50017c3eb0712e7b3a53268a81e81a184b7a49f6/lib/will_paginate/deprecation.rb
lib/will_paginate/deprecation.rb
module WillPaginate::Deprecation class << self def warn(message, stack = caller) offending_line = origin_of_call(stack) full_message = "DEPRECATION WARNING: #{message} (called from #{offending_line})" logger = rails_logger || Kernel logger.warn full_message end private def ra...
ruby
MIT
50017c3eb0712e7b3a53268a81e81a184b7a49f6
2026-01-04T15:42:46.511340Z
false
mislav/will_paginate
https://github.com/mislav/will_paginate/blob/50017c3eb0712e7b3a53268a81e81a184b7a49f6/lib/will_paginate/version.rb
lib/will_paginate/version.rb
module WillPaginate #:nodoc: module VERSION #:nodoc: MAJOR = 4 MINOR = 0 TINY = 1 STRING = [MAJOR, MINOR, TINY].join('.') end end
ruby
MIT
50017c3eb0712e7b3a53268a81e81a184b7a49f6
2026-01-04T15:42:46.511340Z
false
mislav/will_paginate
https://github.com/mislav/will_paginate/blob/50017c3eb0712e7b3a53268a81e81a184b7a49f6/lib/will_paginate/core_ext.rb
lib/will_paginate/core_ext.rb
require 'set' # copied from ActiveSupport so we don't depend on it unless Hash.method_defined? :except Hash.class_eval do # Returns a new hash without the given keys. def except(*keys) rejected = Set.new(respond_to?(:convert_key) ? keys.map { |key| convert_key(key) } : keys) reject { |key,| reje...
ruby
MIT
50017c3eb0712e7b3a53268a81e81a184b7a49f6
2026-01-04T15:42:46.511340Z
false
mislav/will_paginate
https://github.com/mislav/will_paginate/blob/50017c3eb0712e7b3a53268a81e81a184b7a49f6/lib/will_paginate/sequel.rb
lib/will_paginate/sequel.rb
require 'sequel' require 'sequel/extensions/pagination' require 'will_paginate/collection' module WillPaginate # Sequel already supports pagination; we only need to make the # resulting dataset look a bit more like WillPaginate::Collection module SequelMethods include WillPaginate::CollectionMethods def...
ruby
MIT
50017c3eb0712e7b3a53268a81e81a184b7a49f6
2026-01-04T15:42:46.511340Z
false
mislav/will_paginate
https://github.com/mislav/will_paginate/blob/50017c3eb0712e7b3a53268a81e81a184b7a49f6/lib/will_paginate/view_helpers.rb
lib/will_paginate/view_helpers.rb
# encoding: utf-8 require 'will_paginate/core_ext' require 'will_paginate/i18n' require 'will_paginate/deprecation' module WillPaginate # = Will Paginate view helpers # # The main view helper is +will_paginate+. It renders the pagination links # for the given collection. The helper itself is lightweight and se...
ruby
MIT
50017c3eb0712e7b3a53268a81e81a184b7a49f6
2026-01-04T15:42:46.511340Z
false
mislav/will_paginate
https://github.com/mislav/will_paginate/blob/50017c3eb0712e7b3a53268a81e81a184b7a49f6/lib/will_paginate/array.rb
lib/will_paginate/array.rb
require 'will_paginate/collection' class Array # Paginates a static array (extracting a subset of it). The result is a # WillPaginate::Collection instance, which is an array with a few more # properties about its paginated state. # # Parameters: # * <tt>:page</tt> - current page, defaults to 1 # * <tt>:p...
ruby
MIT
50017c3eb0712e7b3a53268a81e81a184b7a49f6
2026-01-04T15:42:46.511340Z
false
mislav/will_paginate
https://github.com/mislav/will_paginate/blob/50017c3eb0712e7b3a53268a81e81a184b7a49f6/lib/will_paginate/mongoid.rb
lib/will_paginate/mongoid.rb
require 'mongoid' require 'will_paginate/collection' module WillPaginate module Mongoid module CriteriaMethods def paginate(options = {}) extend CollectionMethods @current_page = WillPaginate::PageNumber(options[:page] || @current_page || 1) @page_multiplier = current_page - 1 ...
ruby
MIT
50017c3eb0712e7b3a53268a81e81a184b7a49f6
2026-01-04T15:42:46.511340Z
false
mislav/will_paginate
https://github.com/mislav/will_paginate/blob/50017c3eb0712e7b3a53268a81e81a184b7a49f6/lib/will_paginate/railtie.rb
lib/will_paginate/railtie.rb
require 'will_paginate/page_number' require 'will_paginate/collection' require 'will_paginate/i18n' module WillPaginate class Railtie < Rails::Railtie initializer "will_paginate" do |app| ActiveSupport.on_load :active_record do require 'will_paginate/active_record' end ActiveSupport.on...
ruby
MIT
50017c3eb0712e7b3a53268a81e81a184b7a49f6
2026-01-04T15:42:46.511340Z
false
mislav/will_paginate
https://github.com/mislav/will_paginate/blob/50017c3eb0712e7b3a53268a81e81a184b7a49f6/lib/will_paginate/i18n.rb
lib/will_paginate/i18n.rb
module WillPaginate module I18n def self.locale_dir File.expand_path('../locale', __FILE__) end def self.load_path Dir["#{locale_dir}/*.{rb,yml}"] end def will_paginate_translate(keys, options = {}, &block) if defined? ::I18n defaults = Array(keys).dup defaults ...
ruby
MIT
50017c3eb0712e7b3a53268a81e81a184b7a49f6
2026-01-04T15:42:46.511340Z
false
mislav/will_paginate
https://github.com/mislav/will_paginate/blob/50017c3eb0712e7b3a53268a81e81a184b7a49f6/lib/will_paginate/per_page.rb
lib/will_paginate/per_page.rb
module WillPaginate module PerPage def per_page defined?(@per_page) ? @per_page : WillPaginate.per_page end def per_page=(limit) @per_page = limit.to_i end def self.extended(base) base.extend Inheritance if base.is_a? Class end module Inheritance def inherited(su...
ruby
MIT
50017c3eb0712e7b3a53268a81e81a184b7a49f6
2026-01-04T15:42:46.511340Z
false
mislav/will_paginate
https://github.com/mislav/will_paginate/blob/50017c3eb0712e7b3a53268a81e81a184b7a49f6/lib/will_paginate/view_helpers/sinatra.rb
lib/will_paginate/view_helpers/sinatra.rb
require 'sinatra/base' require 'will_paginate/view_helpers' require 'will_paginate/view_helpers/link_renderer' module WillPaginate module Sinatra module Helpers include ViewHelpers def will_paginate(collection, options = {}) #:nodoc: options = options.merge(:renderer => LinkRenderer) unless ...
ruby
MIT
50017c3eb0712e7b3a53268a81e81a184b7a49f6
2026-01-04T15:42:46.511340Z
false
mislav/will_paginate
https://github.com/mislav/will_paginate/blob/50017c3eb0712e7b3a53268a81e81a184b7a49f6/lib/will_paginate/view_helpers/action_view.rb
lib/will_paginate/view_helpers/action_view.rb
require 'will_paginate/view_helpers' require 'will_paginate/view_helpers/link_renderer' module WillPaginate # = ActionView helpers # # This module serves for availability in ActionView templates. It also adds a new # view helper: +paginated_section+. # # == Using the helper without arguments # If the h...
ruby
MIT
50017c3eb0712e7b3a53268a81e81a184b7a49f6
2026-01-04T15:42:46.511340Z
false
mislav/will_paginate
https://github.com/mislav/will_paginate/blob/50017c3eb0712e7b3a53268a81e81a184b7a49f6/lib/will_paginate/view_helpers/link_renderer.rb
lib/will_paginate/view_helpers/link_renderer.rb
require 'cgi' require 'will_paginate/core_ext' require 'will_paginate/view_helpers' require 'will_paginate/view_helpers/link_renderer_base' module WillPaginate module ViewHelpers # This class does the heavy lifting of actually building the pagination # links. It is used by +will_paginate+ helper internally. ...
ruby
MIT
50017c3eb0712e7b3a53268a81e81a184b7a49f6
2026-01-04T15:42:46.511340Z
false
mislav/will_paginate
https://github.com/mislav/will_paginate/blob/50017c3eb0712e7b3a53268a81e81a184b7a49f6/lib/will_paginate/view_helpers/link_renderer_base.rb
lib/will_paginate/view_helpers/link_renderer_base.rb
module WillPaginate module ViewHelpers # This class does the heavy lifting of actually building the pagination # links. It is used by +will_paginate+ helper internally. class LinkRendererBase # * +collection+ is a WillPaginate::Collection instance or any other object # that conforms to that...
ruby
MIT
50017c3eb0712e7b3a53268a81e81a184b7a49f6
2026-01-04T15:42:46.511340Z
false
mislav/will_paginate
https://github.com/mislav/will_paginate/blob/50017c3eb0712e7b3a53268a81e81a184b7a49f6/lib/will_paginate/view_helpers/hanami.rb
lib/will_paginate/view_helpers/hanami.rb
require 'hanami/view' require 'will_paginate/view_helpers' require 'will_paginate/view_helpers/link_renderer' module WillPaginate module Hanami module Helpers include ViewHelpers def will_paginate(collection, options = {}) #:nodoc: options = options.merge(:renderer => LinkRenderer) unless op...
ruby
MIT
50017c3eb0712e7b3a53268a81e81a184b7a49f6
2026-01-04T15:42:46.511340Z
false
mislav/will_paginate
https://github.com/mislav/will_paginate/blob/50017c3eb0712e7b3a53268a81e81a184b7a49f6/environments/Gemfile.non-rails.rb
environments/Gemfile.non-rails.rb
source 'https://rubygems.org' gem 'rspec', '~> 3.12' gem 'mocha', '~> 2.0' gem 'sqlite3', '~> 1.4.0' gem 'sequel', '~> 5.29' gem 'mongoid', '~> 7.2.0'
ruby
MIT
50017c3eb0712e7b3a53268a81e81a184b7a49f6
2026-01-04T15:42:46.511340Z
false
mislav/will_paginate
https://github.com/mislav/will_paginate/blob/50017c3eb0712e7b3a53268a81e81a184b7a49f6/environments/Gemfile.rails6.1.rb
environments/Gemfile.rails6.1.rb
source 'https://rubygems.org' rails_version = '~> 6.1.0' gem 'activerecord', rails_version gem 'actionpack', rails_version gem 'rspec', '~> 3.12' gem 'mocha', '~> 2.0' gem 'sqlite3', '~> 1.4.0' gem 'mysql2', '~> 0.5.2', :group => :mysql gem 'pg', '~> 1.2', :group => :pg
ruby
MIT
50017c3eb0712e7b3a53268a81e81a184b7a49f6
2026-01-04T15:42:46.511340Z
false
mislav/will_paginate
https://github.com/mislav/will_paginate/blob/50017c3eb0712e7b3a53268a81e81a184b7a49f6/environments/Gemfile.rails5.2.rb
environments/Gemfile.rails5.2.rb
source 'https://rubygems.org' rails_version = '~> 5.2.4' gem 'activerecord', rails_version gem 'actionpack', rails_version gem 'rspec', '~> 3.12' gem 'mocha', '~> 2.0' gem 'sqlite3', '~> 1.3.6' gem 'mysql2', '~> 0.5.2', :group => :mysql gem 'pg', '~> 1.2.3', :group => :pg # ruby 2.4 compat re: nokogiri gem 'loof...
ruby
MIT
50017c3eb0712e7b3a53268a81e81a184b7a49f6
2026-01-04T15:42:46.511340Z
false
mislav/will_paginate
https://github.com/mislav/will_paginate/blob/50017c3eb0712e7b3a53268a81e81a184b7a49f6/environments/Gemfile.rails7.0.rb
environments/Gemfile.rails7.0.rb
source 'https://rubygems.org' # We test against other Rails versions, too. See `environments/` rails_version = '~> 7.0.2' gem 'activerecord', rails_version gem 'actionpack', rails_version gem 'rspec', '~> 3.12' gem 'mocha', '~> 2.0' gem 'sqlite3', '~> 1.5.0' gem 'mysql2', '~> 0.5.2', :group => :mysql gem 'pg', '~...
ruby
MIT
50017c3eb0712e7b3a53268a81e81a184b7a49f6
2026-01-04T15:42:46.511340Z
false
mislav/will_paginate
https://github.com/mislav/will_paginate/blob/50017c3eb0712e7b3a53268a81e81a184b7a49f6/environments/Gemfile.rails5.0.rb
environments/Gemfile.rails5.0.rb
source 'https://rubygems.org' rails_version = '~> 5.0.7' gem 'activerecord', rails_version gem 'actionpack', rails_version gem 'rails-dom-testing' gem 'rspec', '~> 3.12' gem 'mocha', '~> 2.0' gem 'sqlite3', '~> 1.3.6' gem 'mysql2', '~> 0.5.2', :group => :mysql gem 'pg', '~> 1.2.3', :group => :pg # ruby 2.4 comp...
ruby
MIT
50017c3eb0712e7b3a53268a81e81a184b7a49f6
2026-01-04T15:42:46.511340Z
false
mislav/will_paginate
https://github.com/mislav/will_paginate/blob/50017c3eb0712e7b3a53268a81e81a184b7a49f6/environments/Gemfile.rails-edge.rb
environments/Gemfile.rails-edge.rb
source 'https://rubygems.org' gem 'activerecord', git: 'https://github.com/rails/rails.git', branch: 'main' gem 'actionpack', git: 'https://github.com/rails/rails.git', branch: 'main' gem 'thread_safe' gem 'rspec', '~> 3.12' gem 'mocha', '~> 2.0' gem 'sqlite3', '~> 1.4.0' gem 'mysql2', '~> 0.5.2', :group => :mys...
ruby
MIT
50017c3eb0712e7b3a53268a81e81a184b7a49f6
2026-01-04T15:42:46.511340Z
false
mislav/will_paginate
https://github.com/mislav/will_paginate/blob/50017c3eb0712e7b3a53268a81e81a184b7a49f6/environments/Gemfile.rails5.1.rb
environments/Gemfile.rails5.1.rb
source 'https://rubygems.org' rails_version = '~> 5.1.7' gem 'activerecord', rails_version gem 'actionpack', rails_version gem 'rspec', '~> 3.12' gem 'mocha', '~> 2.0' gem 'sqlite3', '~> 1.3.6' gem 'mysql2', '~> 0.5.2', :group => :mysql gem 'pg', '~> 1.2.3', :group => :pg # ruby 2.4 compat re: nokogiri gem 'loo...
ruby
MIT
50017c3eb0712e7b3a53268a81e81a184b7a49f6
2026-01-04T15:42:46.511340Z
false
mislav/will_paginate
https://github.com/mislav/will_paginate/blob/50017c3eb0712e7b3a53268a81e81a184b7a49f6/environments/Gemfile.rails6.0.rb
environments/Gemfile.rails6.0.rb
source 'https://rubygems.org' rails_version = '~> 6.0.0' gem 'activerecord', rails_version gem 'actionpack', rails_version gem 'rspec', '~> 3.12' gem 'mocha', '~> 2.0' gem 'sqlite3', '~> 1.4.0' gem 'mysql2', '~> 0.5.2', :group => :mysql gem 'pg', '~> 1.2', :group => :pg
ruby
MIT
50017c3eb0712e7b3a53268a81e81a184b7a49f6
2026-01-04T15:42:46.511340Z
false
rack/rack-attack
https://github.com/rack/rack-attack/blob/d1a979dd32ac5783e06d661fab65c8c390019f4b/spec/rack_attack_path_normalizer_spec.rb
spec/rack_attack_path_normalizer_spec.rb
# frozen_string_literal: true require_relative 'spec_helper' describe Rack::Attack::PathNormalizer do subject { Rack::Attack::PathNormalizer } it 'should have a normalize_path method' do _(subject.normalize_path('/foo')).must_equal '/foo' end describe 'FallbackNormalizer' do subject { Rack::Attack::...
ruby
MIT
d1a979dd32ac5783e06d661fab65c8c390019f4b
2026-01-04T15:42:47.875992Z
false
rack/rack-attack
https://github.com/rack/rack-attack/blob/d1a979dd32ac5783e06d661fab65c8c390019f4b/spec/rack_attack_dalli_proxy_spec.rb
spec/rack_attack_dalli_proxy_spec.rb
# frozen_string_literal: true require_relative 'spec_helper' describe Rack::Attack::StoreProxy::DalliProxy do it 'should stub Dalli::Client#with on older clients' do proxy = Rack::Attack::StoreProxy::DalliProxy.new(Class.new) proxy.with {} # will not raise an error end end
ruby
MIT
d1a979dd32ac5783e06d661fab65c8c390019f4b
2026-01-04T15:42:47.875992Z
false
rack/rack-attack
https://github.com/rack/rack-attack/blob/d1a979dd32ac5783e06d661fab65c8c390019f4b/spec/configuration_spec.rb
spec/configuration_spec.rb
# frozen_string_literal: true require_relative "spec_helper" describe Rack::Attack::Configuration do subject { Rack::Attack::Configuration.new } describe 'attributes' do it 'exposes the safelists attribute' do _(subject.safelists).must_equal({}) end it 'exposes the blocklists attribute' do ...
ruby
MIT
d1a979dd32ac5783e06d661fab65c8c390019f4b
2026-01-04T15:42:47.875992Z
false
rack/rack-attack
https://github.com/rack/rack-attack/blob/d1a979dd32ac5783e06d661fab65c8c390019f4b/spec/rack_attack_spec.rb
spec/rack_attack_spec.rb
# frozen_string_literal: true require_relative 'spec_helper' describe 'Rack::Attack' do it_allows_ok_requests describe 'normalizing paths' do before do Rack::Attack.blocklist("banned_path") { |req| req.path == '/foo' } end it 'blocks requests with trailing slash' do if Rack::Attack::Path...
ruby
MIT
d1a979dd32ac5783e06d661fab65c8c390019f4b
2026-01-04T15:42:47.875992Z
false
rack/rack-attack
https://github.com/rack/rack-attack/blob/d1a979dd32ac5783e06d661fab65c8c390019f4b/spec/rack_attack_reset_spec.rb
spec/rack_attack_reset_spec.rb
# frozen_string_literal: true require_relative "spec_helper" describe "Rack::Attack.reset!" do it "raises an error when is not supported by cache store" do Rack::Attack.cache.store = Class.new assert_raises(Rack::Attack::IncompatibleStoreError) do Rack::Attack.reset! end end if defined?(Redis...
ruby
MIT
d1a979dd32ac5783e06d661fab65c8c390019f4b
2026-01-04T15:42:47.875992Z
false
rack/rack-attack
https://github.com/rack/rack-attack/blob/d1a979dd32ac5783e06d661fab65c8c390019f4b/spec/allow2ban_spec.rb
spec/allow2ban_spec.rb
# frozen_string_literal: true require_relative 'spec_helper' describe 'Rack::Attack.Allow2Ban' do before do # Use a long findtime; failures due to cache key rotation less likely @cache = Rack::Attack.cache @findtime = 60 @bantime = 60 Rack::Attack.cache.store = ActiveSupport::Cache::MemoryStore...
ruby
MIT
d1a979dd32ac5783e06d661fab65c8c390019f4b
2026-01-04T15:42:47.875992Z
false
rack/rack-attack
https://github.com/rack/rack-attack/blob/d1a979dd32ac5783e06d661fab65c8c390019f4b/spec/fail2ban_spec.rb
spec/fail2ban_spec.rb
# frozen_string_literal: true require_relative 'spec_helper' describe 'Rack::Attack.Fail2Ban' do before do # Use a long findtime; failures due to cache key rotation less likely @cache = Rack::Attack.cache @findtime = 60 @bantime = 60 Rack::Attack.cache.store = ActiveSupport::Cache::MemoryStore....
ruby
MIT
d1a979dd32ac5783e06d661fab65c8c390019f4b
2026-01-04T15:42:47.875992Z
false
rack/rack-attack
https://github.com/rack/rack-attack/blob/d1a979dd32ac5783e06d661fab65c8c390019f4b/spec/rack_attack_request_spec.rb
spec/rack_attack_request_spec.rb
# frozen_string_literal: true require_relative 'spec_helper' describe 'Rack::Attack' do describe 'helpers' do before do Rack::Attack::Request.define_method :remote_ip do ip end Rack::Attack.safelist('valid IP') do |req| req.remote_ip == "127.0.0.1" end end it_al...
ruby
MIT
d1a979dd32ac5783e06d661fab65c8c390019f4b
2026-01-04T15:42:47.875992Z
false
rack/rack-attack
https://github.com/rack/rack-attack/blob/d1a979dd32ac5783e06d661fab65c8c390019f4b/spec/rack_attack_track_spec.rb
spec/rack_attack_track_spec.rb
# frozen_string_literal: true require_relative 'spec_helper' describe 'Rack::Attack.track' do let(:notifications) { [] } before do Rack::Attack.track("everything") { |_req| true } end it_allows_ok_requests it "should tag the env" do get '/' _(last_request.env['rack.attack.matched']).must_equ...
ruby
MIT
d1a979dd32ac5783e06d661fab65c8c390019f4b
2026-01-04T15:42:47.875992Z
false
rack/rack-attack
https://github.com/rack/rack-attack/blob/d1a979dd32ac5783e06d661fab65c8c390019f4b/spec/rack_attack_throttle_spec.rb
spec/rack_attack_throttle_spec.rb
# frozen_string_literal: true require_relative 'spec_helper' require_relative 'support/freeze_time_helper' describe 'Rack::Attack.throttle' do before do @period = 60 Rack::Attack.cache.store = ActiveSupport::Cache::MemoryStore.new Rack::Attack.throttle('ip/sec', limit: 1, period: @period) { |req| req.ip...
ruby
MIT
d1a979dd32ac5783e06d661fab65c8c390019f4b
2026-01-04T15:42:47.875992Z
false
rack/rack-attack
https://github.com/rack/rack-attack/blob/d1a979dd32ac5783e06d661fab65c8c390019f4b/spec/rack_attack_instrumentation_spec.rb
spec/rack_attack_instrumentation_spec.rb
# frozen_string_literal: true require_relative "spec_helper" require 'active_support' require 'active_support/subscriber' class CustomSubscriber < ActiveSupport::Subscriber @notification_count = 0 class << self attr_accessor :notification_count end def throttle(_event) self.class.notification_count ...
ruby
MIT
d1a979dd32ac5783e06d661fab65c8c390019f4b
2026-01-04T15:42:47.875992Z
false
rack/rack-attack
https://github.com/rack/rack-attack/blob/d1a979dd32ac5783e06d661fab65c8c390019f4b/spec/spec_helper.rb
spec/spec_helper.rb
# frozen_string_literal: true require "bundler/setup" require "logger" require "minitest/autorun" require "minitest/pride" require "rack/test" require "active_support" require "rack/attack" if RUBY_ENGINE == "ruby" require "byebug" end def safe_require(name) require name rescue LoadError nil end safe_require...
ruby
MIT
d1a979dd32ac5783e06d661fab65c8c390019f4b
2026-01-04T15:42:47.875992Z
false
rack/rack-attack
https://github.com/rack/rack-attack/blob/d1a979dd32ac5783e06d661fab65c8c390019f4b/spec/support/freeze_time_helper.rb
spec/support/freeze_time_helper.rb
# frozen_string_literal: true require "timecop" class Minitest::Spec def within_same_period(&block) Timecop.freeze(&block) end end
ruby
MIT
d1a979dd32ac5783e06d661fab65c8c390019f4b
2026-01-04T15:42:47.875992Z
false
rack/rack-attack
https://github.com/rack/rack-attack/blob/d1a979dd32ac5783e06d661fab65c8c390019f4b/spec/support/cache_store_helper.rb
spec/support/cache_store_helper.rb
# frozen_string_literal: true require_relative 'freeze_time_helper' class Minitest::Spec def self.it_works_for_cache_backed_features(options) fetch_from_store = options.fetch(:fetch_from_store) it "works for throttle" do Rack::Attack.throttle("by ip", limit: 1, period: 60) do |request| reques...
ruby
MIT
d1a979dd32ac5783e06d661fab65c8c390019f4b
2026-01-04T15:42:47.875992Z
false
rack/rack-attack
https://github.com/rack/rack-attack/blob/d1a979dd32ac5783e06d661fab65c8c390019f4b/spec/integration/offline_spec.rb
spec/integration/offline_spec.rb
# frozen_string_literal: true require 'active_support/cache' require_relative '../spec_helper' OfflineExamples = Minitest::SharedExamples.new do it 'should write' do @cache.write('cache-test-key', 'foobar', 1) end it 'should read' do @cache.read('cache-test-key') end it 'should count' do @cach...
ruby
MIT
d1a979dd32ac5783e06d661fab65c8c390019f4b
2026-01-04T15:42:47.875992Z
false
rack/rack-attack
https://github.com/rack/rack-attack/blob/d1a979dd32ac5783e06d661fab65c8c390019f4b/spec/acceptance/cache_store_config_with_rails_spec.rb
spec/acceptance/cache_store_config_with_rails_spec.rb
# frozen_string_literal: true require_relative "../spec_helper" require "minitest/stub_const" require "ostruct" describe "Cache store config with Rails" do before do Rack::Attack.throttle("by ip", limit: 1, period: 60) do |request| request.ip end end unless defined?(Rails) it "fails when Rail...
ruby
MIT
d1a979dd32ac5783e06d661fab65c8c390019f4b
2026-01-04T15:42:47.875992Z
false
rack/rack-attack
https://github.com/rack/rack-attack/blob/d1a979dd32ac5783e06d661fab65c8c390019f4b/spec/acceptance/blocking_subnet_spec.rb
spec/acceptance/blocking_subnet_spec.rb
# frozen_string_literal: true require_relative "../spec_helper" describe "Blocking an IP subnet" do let(:notifications) { [] } before do Rack::Attack.blocklist_ip("1.2.3.4/31") end it "forbids request if IP is inside the subnet" do get "/", {}, "REMOTE_ADDR" => "1.2.3.4" assert_equal 403, last_...
ruby
MIT
d1a979dd32ac5783e06d661fab65c8c390019f4b
2026-01-04T15:42:47.875992Z
false
rack/rack-attack
https://github.com/rack/rack-attack/blob/d1a979dd32ac5783e06d661fab65c8c390019f4b/spec/acceptance/throttling_spec.rb
spec/acceptance/throttling_spec.rb
# frozen_string_literal: true require_relative "../spec_helper" require "timecop" describe "#throttle" do let(:notifications) { [] } before do Rack::Attack.cache.store = ActiveSupport::Cache::MemoryStore.new end it "allows one request per minute by IP" do Rack::Attack.throttle("by ip", limit: 1, per...
ruby
MIT
d1a979dd32ac5783e06d661fab65c8c390019f4b
2026-01-04T15:42:47.875992Z
false
rack/rack-attack
https://github.com/rack/rack-attack/blob/d1a979dd32ac5783e06d661fab65c8c390019f4b/spec/acceptance/cache_store_config_for_throttle_spec.rb
spec/acceptance/cache_store_config_for_throttle_spec.rb
# frozen_string_literal: true require_relative "../spec_helper" describe "Cache store config when throttling without Rails" do before do Rack::Attack.throttle("by ip", limit: 1, period: 60) do |request| request.ip end end unless defined?(Rails) it "gives semantic error if no store was configu...
ruby
MIT
d1a979dd32ac5783e06d661fab65c8c390019f4b
2026-01-04T15:42:47.875992Z
false
rack/rack-attack
https://github.com/rack/rack-attack/blob/d1a979dd32ac5783e06d661fab65c8c390019f4b/spec/acceptance/track_spec.rb
spec/acceptance/track_spec.rb
# frozen_string_literal: true require_relative "../spec_helper" describe "#track" do let(:notifications) { [] } it "notifies when track block returns true" do Rack::Attack.track("ip 1.2.3.4") do |request| request.ip == "1.2.3.4" end ActiveSupport::Notifications.subscribe("track.rack_attack") d...
ruby
MIT
d1a979dd32ac5783e06d661fab65c8c390019f4b
2026-01-04T15:42:47.875992Z
false
rack/rack-attack
https://github.com/rack/rack-attack/blob/d1a979dd32ac5783e06d661fab65c8c390019f4b/spec/acceptance/blocking_ip_spec.rb
spec/acceptance/blocking_ip_spec.rb
# frozen_string_literal: true require_relative "../spec_helper" describe "Blocking an IP" do let(:notifications) { [] } before do Rack::Attack.blocklist_ip("1.2.3.4") end it "forbids request if IP matches" do get "/", {}, "REMOTE_ADDR" => "1.2.3.4" assert_equal 403, last_response.status end ...
ruby
MIT
d1a979dd32ac5783e06d661fab65c8c390019f4b
2026-01-04T15:42:47.875992Z
false
rack/rack-attack
https://github.com/rack/rack-attack/blob/d1a979dd32ac5783e06d661fab65c8c390019f4b/spec/acceptance/cache_store_config_for_fail2ban_spec.rb
spec/acceptance/cache_store_config_for_fail2ban_spec.rb
# frozen_string_literal: true require_relative "../spec_helper" require "minitest/stub_const" describe "Cache store config when using fail2ban" do before do Rack::Attack.blocklist("fail2ban pentesters") do |request| Rack::Attack::Fail2Ban.filter(request.ip, maxretry: 2, findtime: 30, bantime: 60) do ...
ruby
MIT
d1a979dd32ac5783e06d661fab65c8c390019f4b
2026-01-04T15:42:47.875992Z
false
rack/rack-attack
https://github.com/rack/rack-attack/blob/d1a979dd32ac5783e06d661fab65c8c390019f4b/spec/acceptance/extending_request_object_spec.rb
spec/acceptance/extending_request_object_spec.rb
# frozen_string_literal: true require_relative "../spec_helper" describe "Extending the request object" do before do Rack::Attack::Request.define_method :authorized? do env["APIKey"] == "private-secret" end Rack::Attack.blocklist("unauthorized requests") do |request| !request.authorized? ...
ruby
MIT
d1a979dd32ac5783e06d661fab65c8c390019f4b
2026-01-04T15:42:47.875992Z
false
rack/rack-attack
https://github.com/rack/rack-attack/blob/d1a979dd32ac5783e06d661fab65c8c390019f4b/spec/acceptance/allow2ban_spec.rb
spec/acceptance/allow2ban_spec.rb
# frozen_string_literal: true require_relative "../spec_helper" require "timecop" describe "allow2ban" do before do Rack::Attack.cache.store = ActiveSupport::Cache::MemoryStore.new Rack::Attack.blocklist("allow2ban pentesters") do |request| Rack::Attack::Allow2Ban.filter(request.ip, maxretry: 2, find...
ruby
MIT
d1a979dd32ac5783e06d661fab65c8c390019f4b
2026-01-04T15:42:47.875992Z
false
rack/rack-attack
https://github.com/rack/rack-attack/blob/d1a979dd32ac5783e06d661fab65c8c390019f4b/spec/acceptance/fail2ban_spec.rb
spec/acceptance/fail2ban_spec.rb
# frozen_string_literal: true require_relative "../spec_helper" require "timecop" describe "fail2ban" do let(:notifications) { [] } before do Rack::Attack.cache.store = ActiveSupport::Cache::MemoryStore.new Rack::Attack.blocklist("fail2ban pentesters") do |request| Rack::Attack::Fail2Ban.filter(re...
ruby
MIT
d1a979dd32ac5783e06d661fab65c8c390019f4b
2026-01-04T15:42:47.875992Z
false
rack/rack-attack
https://github.com/rack/rack-attack/blob/d1a979dd32ac5783e06d661fab65c8c390019f4b/spec/acceptance/safelisting_ip_spec.rb
spec/acceptance/safelisting_ip_spec.rb
# frozen_string_literal: true require_relative "../spec_helper" describe "Safelist an IP" do let(:notifications) { [] } before do Rack::Attack.blocklist("admin") do |request| request.path == "/admin" end Rack::Attack.safelist_ip("5.6.7.8") end it "forbids request if blocklist condition is...
ruby
MIT
d1a979dd32ac5783e06d661fab65c8c390019f4b
2026-01-04T15:42:47.875992Z
false
rack/rack-attack
https://github.com/rack/rack-attack/blob/d1a979dd32ac5783e06d661fab65c8c390019f4b/spec/acceptance/cache_store_config_for_allow2ban_spec.rb
spec/acceptance/cache_store_config_for_allow2ban_spec.rb
# frozen_string_literal: true require_relative "../spec_helper" require "minitest/stub_const" describe "Cache store config when using allow2ban" do before do Rack::Attack.blocklist("allow2ban pentesters") do |request| Rack::Attack::Allow2Ban.filter(request.ip, maxretry: 2, findtime: 30, bantime: 60) do ...
ruby
MIT
d1a979dd32ac5783e06d661fab65c8c390019f4b
2026-01-04T15:42:47.875992Z
false
rack/rack-attack
https://github.com/rack/rack-attack/blob/d1a979dd32ac5783e06d661fab65c8c390019f4b/spec/acceptance/rails_middleware_spec.rb
spec/acceptance/rails_middleware_spec.rb
# frozen_string_literal: true require_relative "../spec_helper" if defined?(Rails::Application) describe "Middleware for Rails" do before do @app = Class.new(Rails::Application) do config.eager_load = false config.logger = Logger.new(nil) # avoid creating the log/ directory automatically ...
ruby
MIT
d1a979dd32ac5783e06d661fab65c8c390019f4b
2026-01-04T15:42:47.875992Z
false
rack/rack-attack
https://github.com/rack/rack-attack/blob/d1a979dd32ac5783e06d661fab65c8c390019f4b/spec/acceptance/customizing_blocked_response_spec.rb
spec/acceptance/customizing_blocked_response_spec.rb
# frozen_string_literal: true require_relative "../spec_helper" describe "Customizing block responses" do before do Rack::Attack.blocklist("block 1.2.3.4") do |request| request.ip == "1.2.3.4" end end it "can be customized" do get "/", {}, "REMOTE_ADDR" => "1.2.3.4" assert_equal 403, las...
ruby
MIT
d1a979dd32ac5783e06d661fab65c8c390019f4b
2026-01-04T15:42:47.875992Z
false
rack/rack-attack
https://github.com/rack/rack-attack/blob/d1a979dd32ac5783e06d661fab65c8c390019f4b/spec/acceptance/safelisting_spec.rb
spec/acceptance/safelisting_spec.rb
# frozen_string_literal: true require_relative "../spec_helper" describe "#safelist" do let(:notifications) { [] } before do Rack::Attack.blocklist do |request| request.ip == "1.2.3.4" end Rack::Attack.safelist do |request| request.path == "/safe_space" end end it "forbids reque...
ruby
MIT
d1a979dd32ac5783e06d661fab65c8c390019f4b
2026-01-04T15:42:47.875992Z
false
rack/rack-attack
https://github.com/rack/rack-attack/blob/d1a979dd32ac5783e06d661fab65c8c390019f4b/spec/acceptance/blocking_spec.rb
spec/acceptance/blocking_spec.rb
# frozen_string_literal: true require_relative "../spec_helper" describe "#blocklist" do let(:notifications) { [] } before do Rack::Attack.blocklist do |request| request.ip == "1.2.3.4" end end it "forbids request if blocklist condition is true" do get "/", {}, "REMOTE_ADDR" => "1.2.3.4" ...
ruby
MIT
d1a979dd32ac5783e06d661fab65c8c390019f4b
2026-01-04T15:42:47.875992Z
false
rack/rack-attack
https://github.com/rack/rack-attack/blob/d1a979dd32ac5783e06d661fab65c8c390019f4b/spec/acceptance/customizing_throttled_response_spec.rb
spec/acceptance/customizing_throttled_response_spec.rb
# frozen_string_literal: true require_relative "../spec_helper" describe "Customizing throttled response" do before do Rack::Attack.cache.store = ActiveSupport::Cache::MemoryStore.new Rack::Attack.throttle("by ip", limit: 1, period: 60) do |request| request.ip end end it "can be customized" ...
ruby
MIT
d1a979dd32ac5783e06d661fab65c8c390019f4b
2026-01-04T15:42:47.875992Z
false
rack/rack-attack
https://github.com/rack/rack-attack/blob/d1a979dd32ac5783e06d661fab65c8c390019f4b/spec/acceptance/safelisting_subnet_spec.rb
spec/acceptance/safelisting_subnet_spec.rb
# frozen_string_literal: true require_relative "../spec_helper" describe "Safelisting an IP subnet" do let(:notifications) { [] } before do Rack::Attack.blocklist("admin") do |request| request.path == "/admin" end Rack::Attack.safelist_ip("5.6.0.0/16") end it "forbids request if blocklist...
ruby
MIT
d1a979dd32ac5783e06d661fab65c8c390019f4b
2026-01-04T15:42:47.875992Z
false
rack/rack-attack
https://github.com/rack/rack-attack/blob/d1a979dd32ac5783e06d661fab65c8c390019f4b/spec/acceptance/track_throttle_spec.rb
spec/acceptance/track_throttle_spec.rb
# frozen_string_literal: true require_relative "../spec_helper" require "timecop" describe "#track with throttle-ish options" do let(:notifications) { [] } it "notifies when throttle goes over the limit without actually throttling requests" do Rack::Attack.cache.store = ActiveSupport::Cache::MemoryStore.new ...
ruby
MIT
d1a979dd32ac5783e06d661fab65c8c390019f4b
2026-01-04T15:42:47.875992Z
false
rack/rack-attack
https://github.com/rack/rack-attack/blob/d1a979dd32ac5783e06d661fab65c8c390019f4b/spec/acceptance/stores/active_support_mem_cache_store_spec.rb
spec/acceptance/stores/active_support_mem_cache_store_spec.rb
# frozen_string_literal: true require_relative "../../spec_helper" if defined?(::Dalli) require_relative "../../support/cache_store_helper" describe "ActiveSupport::Cache::MemCacheStore as a cache backend" do before do Rack::Attack.cache.store = if ActiveSupport.gem_version >= Gem::Version.new("7.2.0")...
ruby
MIT
d1a979dd32ac5783e06d661fab65c8c390019f4b
2026-01-04T15:42:47.875992Z
false
rack/rack-attack
https://github.com/rack/rack-attack/blob/d1a979dd32ac5783e06d661fab65c8c390019f4b/spec/acceptance/stores/active_support_redis_cache_store_spec.rb
spec/acceptance/stores/active_support_redis_cache_store_spec.rb
# frozen_string_literal: true require_relative "../../spec_helper" should_run = defined?(::Redis) && Gem::Version.new(::Redis::VERSION) >= Gem::Version.new("4") && defined?(::ActiveSupport::Cache::RedisCacheStore) if should_run require_relative "../../support/cache_store_helper" describe "ActiveSupport::C...
ruby
MIT
d1a979dd32ac5783e06d661fab65c8c390019f4b
2026-01-04T15:42:47.875992Z
false
rack/rack-attack
https://github.com/rack/rack-attack/blob/d1a979dd32ac5783e06d661fab65c8c390019f4b/spec/acceptance/stores/redis_spec.rb
spec/acceptance/stores/redis_spec.rb
# frozen_string_literal: true require_relative "../../spec_helper" if defined?(::Redis) require_relative "../../support/cache_store_helper" describe "Plain redis as a cache backend" do before do Rack::Attack.cache.store = Redis.new end after do Rack::Attack.cache.store.flushdb end ...
ruby
MIT
d1a979dd32ac5783e06d661fab65c8c390019f4b
2026-01-04T15:42:47.875992Z
false
rack/rack-attack
https://github.com/rack/rack-attack/blob/d1a979dd32ac5783e06d661fab65c8c390019f4b/spec/acceptance/stores/redis_store_spec.rb
spec/acceptance/stores/redis_store_spec.rb
# frozen_string_literal: true require_relative "../../spec_helper" require_relative "../../support/cache_store_helper" if defined?(::Redis::Store) describe "Redis::Store as a cache backend" do before do Rack::Attack.cache.store = ::Redis::Store.new end after do Rack::Attack.cache.store.flus...
ruby
MIT
d1a979dd32ac5783e06d661fab65c8c390019f4b
2026-01-04T15:42:47.875992Z
false
rack/rack-attack
https://github.com/rack/rack-attack/blob/d1a979dd32ac5783e06d661fab65c8c390019f4b/spec/acceptance/stores/dalli_client_spec.rb
spec/acceptance/stores/dalli_client_spec.rb
# frozen_string_literal: true require_relative "../../spec_helper" if defined?(::Dalli) require_relative "../../support/cache_store_helper" require "dalli" describe "Dalli::Client as a cache backend" do before do Rack::Attack.cache.store = Dalli::Client.new end after do Rack::Attack.ca...
ruby
MIT
d1a979dd32ac5783e06d661fab65c8c390019f4b
2026-01-04T15:42:47.875992Z
false
rack/rack-attack
https://github.com/rack/rack-attack/blob/d1a979dd32ac5783e06d661fab65c8c390019f4b/spec/acceptance/stores/active_support_memory_store_spec.rb
spec/acceptance/stores/active_support_memory_store_spec.rb
# frozen_string_literal: true require_relative "../../spec_helper" require_relative "../../support/cache_store_helper" describe "ActiveSupport::Cache::MemoryStore as a cache backend" do before do Rack::Attack.cache.store = ActiveSupport::Cache::MemoryStore.new end after do Rack::Attack.cache.store.clea...
ruby
MIT
d1a979dd32ac5783e06d661fab65c8c390019f4b
2026-01-04T15:42:47.875992Z
false
rack/rack-attack
https://github.com/rack/rack-attack/blob/d1a979dd32ac5783e06d661fab65c8c390019f4b/examples/instrumentation.rb
examples/instrumentation.rb
ActiveSupport::Notifications.subscribe(/rack_attack/) do |name, start, finish, request_id, payload| puts payload[:request].inspect end
ruby
MIT
d1a979dd32ac5783e06d661fab65c8c390019f4b
2026-01-04T15:42:47.875992Z
false
rack/rack-attack
https://github.com/rack/rack-attack/blob/d1a979dd32ac5783e06d661fab65c8c390019f4b/examples/rack_attack.rb
examples/rack_attack.rb
# frozen_string_literal: true # NB: `req` is a Rack::Request object (basically an env hash with friendly accessor methods) # Throttle 10 requests/ip/second # NB: return value of block is key name for counter # falsy values bypass throttling Rack::Attack.throttle("req/ip", limit: 10, period: 1) { |req| req.ip } #...
ruby
MIT
d1a979dd32ac5783e06d661fab65c8c390019f4b
2026-01-04T15:42:47.875992Z
false
rack/rack-attack
https://github.com/rack/rack-attack/blob/d1a979dd32ac5783e06d661fab65c8c390019f4b/lib/rack/attack.rb
lib/rack/attack.rb
# frozen_string_literal: true require 'rack' require 'forwardable' require 'rack/attack/cache' require 'rack/attack/configuration' require 'rack/attack/path_normalizer' require 'rack/attack/request' require 'rack/attack/store_proxy/dalli_proxy' require 'rack/attack/store_proxy/mem_cache_store_proxy' require 'rack/atta...
ruby
MIT
d1a979dd32ac5783e06d661fab65c8c390019f4b
2026-01-04T15:42:47.875992Z
false
rack/rack-attack
https://github.com/rack/rack-attack/blob/d1a979dd32ac5783e06d661fab65c8c390019f4b/lib/rack/attack/version.rb
lib/rack/attack/version.rb
# frozen_string_literal: true module Rack class Attack VERSION = '6.8.0' end end
ruby
MIT
d1a979dd32ac5783e06d661fab65c8c390019f4b
2026-01-04T15:42:47.875992Z
false
rack/rack-attack
https://github.com/rack/rack-attack/blob/d1a979dd32ac5783e06d661fab65c8c390019f4b/lib/rack/attack/allow2ban.rb
lib/rack/attack/allow2ban.rb
# frozen_string_literal: true module Rack class Attack class Allow2Ban < Fail2Ban class << self protected def key_prefix 'allow2ban' end # everything is the same here except we only return true # (blocking the request) if they have tripped the limit. ...
ruby
MIT
d1a979dd32ac5783e06d661fab65c8c390019f4b
2026-01-04T15:42:47.875992Z
false
rack/rack-attack
https://github.com/rack/rack-attack/blob/d1a979dd32ac5783e06d661fab65c8c390019f4b/lib/rack/attack/track.rb
lib/rack/attack/track.rb
# frozen_string_literal: true module Rack class Attack class Track attr_reader :filter def initialize(name, options = {}, &block) options[:type] = :track @filter = if options[:limit] && options[:period] Throttle.new(name, options, &block) else ...
ruby
MIT
d1a979dd32ac5783e06d661fab65c8c390019f4b
2026-01-04T15:42:47.875992Z
false
rack/rack-attack
https://github.com/rack/rack-attack/blob/d1a979dd32ac5783e06d661fab65c8c390019f4b/lib/rack/attack/path_normalizer.rb
lib/rack/attack/path_normalizer.rb
# frozen_string_literal: true module Rack class Attack # When using Rack::Attack with a Rails app, developers expect the request path # to be normalized. In particular, trailing slashes are stripped. # (See # https://github.com/rails/rails/blob/f8edd20/actionpack/lib/action_dispatch/journey/router/ut...
ruby
MIT
d1a979dd32ac5783e06d661fab65c8c390019f4b
2026-01-04T15:42:47.875992Z
false
rack/rack-attack
https://github.com/rack/rack-attack/blob/d1a979dd32ac5783e06d661fab65c8c390019f4b/lib/rack/attack/railtie.rb
lib/rack/attack/railtie.rb
# frozen_string_literal: true begin require 'rails/railtie' rescue LoadError return end module Rack class Attack class Railtie < ::Rails::Railtie initializer "rack-attack.middleware" do |app| app.middleware.use(Rack::Attack) end end end end
ruby
MIT
d1a979dd32ac5783e06d661fab65c8c390019f4b
2026-01-04T15:42:47.875992Z
false
rack/rack-attack
https://github.com/rack/rack-attack/blob/d1a979dd32ac5783e06d661fab65c8c390019f4b/lib/rack/attack/configuration.rb
lib/rack/attack/configuration.rb
# frozen_string_literal: true require "ipaddr" module Rack class Attack class Configuration DEFAULT_BLOCKLISTED_RESPONDER = lambda { |_req| [403, { 'content-type' => 'text/plain' }, ["Forbidden\n"]] } DEFAULT_THROTTLED_RESPONDER = lambda do |req| if Rack::Attack.configuration.throttled_resp...
ruby
MIT
d1a979dd32ac5783e06d661fab65c8c390019f4b
2026-01-04T15:42:47.875992Z
false
rack/rack-attack
https://github.com/rack/rack-attack/blob/d1a979dd32ac5783e06d661fab65c8c390019f4b/lib/rack/attack/fail2ban.rb
lib/rack/attack/fail2ban.rb
# frozen_string_literal: true module Rack class Attack class Fail2Ban class << self def filter(discriminator, options) bantime = options[:bantime] or raise ArgumentError, "Must pass bantime option" findtime = options[:findtime] or raise ArgumentError, "Must pass findtime o...
ruby
MIT
d1a979dd32ac5783e06d661fab65c8c390019f4b
2026-01-04T15:42:47.875992Z
false
rack/rack-attack
https://github.com/rack/rack-attack/blob/d1a979dd32ac5783e06d661fab65c8c390019f4b/lib/rack/attack/safelist.rb
lib/rack/attack/safelist.rb
# frozen_string_literal: true module Rack class Attack class Safelist < Check def initialize(name = nil, &block) super @type = :safelist end end end end
ruby
MIT
d1a979dd32ac5783e06d661fab65c8c390019f4b
2026-01-04T15:42:47.875992Z
false
rack/rack-attack
https://github.com/rack/rack-attack/blob/d1a979dd32ac5783e06d661fab65c8c390019f4b/lib/rack/attack/base_proxy.rb
lib/rack/attack/base_proxy.rb
# frozen_string_literal: true require 'delegate' module Rack class Attack class BaseProxy < SimpleDelegator class << self def proxies @@proxies ||= [] end def inherited(klass) super proxies << klass end def lookup(store) pro...
ruby
MIT
d1a979dd32ac5783e06d661fab65c8c390019f4b
2026-01-04T15:42:47.875992Z
false
rack/rack-attack
https://github.com/rack/rack-attack/blob/d1a979dd32ac5783e06d661fab65c8c390019f4b/lib/rack/attack/check.rb
lib/rack/attack/check.rb
# frozen_string_literal: true module Rack class Attack class Check attr_reader :name, :block, :type def initialize(name, options = {}, &block) @name = name @block = block @type = options.fetch(:type, nil) end def matched_by?(request) block.call(request).t...
ruby
MIT
d1a979dd32ac5783e06d661fab65c8c390019f4b
2026-01-04T15:42:47.875992Z
false
rack/rack-attack
https://github.com/rack/rack-attack/blob/d1a979dd32ac5783e06d661fab65c8c390019f4b/lib/rack/attack/request.rb
lib/rack/attack/request.rb
# frozen_string_literal: true # Rack::Attack::Request is the same as :ActionDispatch::Request in Rails apps, # and ::Rack::Request in other apps by default. # # This is a safe place to add custom helper methods to the request object # through monkey patching: # # class Rack::Attack::Request < ::Rack::Request # d...
ruby
MIT
d1a979dd32ac5783e06d661fab65c8c390019f4b
2026-01-04T15:42:47.875992Z
false
rack/rack-attack
https://github.com/rack/rack-attack/blob/d1a979dd32ac5783e06d661fab65c8c390019f4b/lib/rack/attack/throttle.rb
lib/rack/attack/throttle.rb
# frozen_string_literal: true module Rack class Attack class Throttle MANDATORY_OPTIONS = [:limit, :period].freeze attr_reader :name, :limit, :period, :block, :type def initialize(name, options, &block) @name = name @block = block MANDATORY_OPTIONS.each do |opt| ...
ruby
MIT
d1a979dd32ac5783e06d661fab65c8c390019f4b
2026-01-04T15:42:47.875992Z
false