source
stringclasses
1 value
repo
stringlengths
5
63
repo_url
stringlengths
24
82
path
stringlengths
5
167
language
stringclasses
1 value
license
stringclasses
5 values
stars
int64
10
51.4k
ref
stringclasses
23 values
size_bytes
int64
200
258k
text
stringlengths
137
258k
github
rack/rack-attack
https://github.com/rack/rack-attack
spec/rack_attack_dalli_proxy_spec.rb
Ruby
mit
5,726
main
288
# 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
github
rack/rack-attack
https://github.com/rack/rack-attack
spec/rack_attack_instrumentation_spec.rb
Ruby
mit
5,726
main
1,063
# 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 ...
github
rack/rack-attack
https://github.com/rack/rack-attack
spec/rack_attack_throttle_spec.rb
Ruby
mit
5,726
main
5,934
# 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...
github
rack/rack-attack
https://github.com/rack/rack-attack
spec/spec_helper.rb
Ruby
mit
5,726
main
1,394
# 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...
github
rack/rack-attack
https://github.com/rack/rack-attack
spec/rack_attack_path_normalizer_spec.rb
Ruby
mit
5,726
main
467
# 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::...
github
rack/rack-attack
https://github.com/rack/rack-attack
spec/rack_attack_reset_spec.rb
Ruby
mit
5,726
main
3,436
# 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 fake_store_class = Class.new do def read(key); end def write(key, value); end def increment(key, count, options = {}); end def de...
github
rack/rack-attack
https://github.com/rack/rack-attack
spec/allow2ban_spec.rb
Ruby
mit
5,726
main
3,552
# 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...
github
rack/rack-attack
https://github.com/rack/rack-attack
spec/rack_attack_request_spec.rb
Ruby
mit
5,726
main
347
# 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...
github
rack/rack-attack
https://github.com/rack/rack-attack
spec/fail2ban_spec.rb
Ruby
mit
5,726
main
4,167
# 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....
github
rack/rack-attack
https://github.com/rack/rack-attack
spec/support/cache_store_helper.rb
Ruby
mit
5,726
main
2,256
# 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...
github
rack/rack-attack
https://github.com/rack/rack-attack
spec/acceptance/blocking_spec.rb
Ruby
mit
5,726
main
2,115
# 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" ...
github
rack/rack-attack
https://github.com/rack/rack-attack
spec/acceptance/allow2ban_spec.rb
Ruby
mit
5,726
main
1,779
# 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...
github
rack/rack-attack
https://github.com/rack/rack-attack
spec/acceptance/track_spec.rb
Ruby
mit
5,726
main
772
# 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...
github
rack/rack-attack
https://github.com/rack/rack-attack
spec/acceptance/blocking_subnet_spec.rb
Ruby
mit
5,726
main
1,126
# 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_...
github
rack/rack-attack
https://github.com/rack/rack-attack
spec/acceptance/safelisting_ip_spec.rb
Ruby
mit
5,726
main
1,614
# 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...
github
rack/rack-attack
https://github.com/rack/rack-attack
spec/acceptance/blocking_ip_spec.rb
Ruby
mit
5,726
main
1,069
# 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 ...
github
rack/rack-attack
https://github.com/rack/rack-attack
spec/acceptance/rails_middleware_spec.rb
Ruby
mit
5,726
main
545
# 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 ...
github
rack/rack-attack
https://github.com/rack/rack-attack
spec/acceptance/track_throttle_spec.rb
Ruby
mit
5,726
main
1,298
# 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 ...
github
rack/rack-attack
https://github.com/rack/rack-attack
spec/acceptance/cache_store_config_for_throttle_spec.rb
Ruby
mit
5,726
main
1,444
# 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...
github
rack/rack-attack
https://github.com/rack/rack-attack
spec/acceptance/extending_request_object_spec.rb
Ruby
mit
5,726
main
734
# 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? ...
github
rack/rack-attack
https://github.com/rack/rack-attack
spec/acceptance/customizing_blocked_response_spec.rb
Ruby
mit
5,726
main
1,372
# 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...
github
rack/rack-attack
https://github.com/rack/rack-attack
spec/acceptance/safelisting_spec.rb
Ruby
mit
5,726
main
3,055
# 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...
github
rack/rack-attack
https://github.com/rack/rack-attack
spec/acceptance/cache_store_config_with_rails_spec.rb
Ruby
mit
5,726
main
911
# frozen_string_literal: true require_relative "../spec_helper" require "minitest/stub_const" 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 Rails.cache is not set...
github
rack/rack-attack
https://github.com/rack/rack-attack
spec/acceptance/customizing_throttled_response_spec.rb
Ruby
mit
5,726
main
2,088
# 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" ...
github
rack/rack-attack
https://github.com/rack/rack-attack
spec/acceptance/cache_store_config_for_allow2ban_spec.rb
Ruby
mit
5,726
main
1,839
# 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 ...
github
rack/rack-attack
https://github.com/rack/rack-attack
spec/acceptance/throttling_spec.rb
Ruby
mit
5,726
main
4,955
# 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...
github
rack/rack-attack
https://github.com/rack/rack-attack
spec/acceptance/safelisting_subnet_spec.rb
Ruby
mit
5,726
main
1,446
# 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...
github
rack/rack-attack
https://github.com/rack/rack-attack
spec/acceptance/cache_store_config_for_fail2ban_spec.rb
Ruby
mit
5,726
main
1,679
# 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 ...
github
rack/rack-attack
https://github.com/rack/rack-attack
spec/acceptance/fail2ban_spec.rb
Ruby
mit
5,726
main
3,211
# 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...
github
rack/rack-attack
https://github.com/rack/rack-attack
spec/acceptance/stores/active_support_memory_store_spec.rb
Ruby
mit
5,726
main
437
# 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...
github
rack/rack-attack
https://github.com/rack/rack-attack
spec/acceptance/stores/dalli_client_spec.rb
Ruby
mit
5,726
main
869
# 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...
github
rack/rack-attack
https://github.com/rack/rack-attack
spec/acceptance/stores/active_support_redis_cache_store_spec.rb
Ruby
mit
5,726
main
908
# 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...
github
rack/rack-attack
https://github.com/rack/rack-attack
spec/acceptance/stores/redis_spec.rb
Ruby
mit
5,726
main
433
# 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 ...
github
rack/rack-attack
https://github.com/rack/rack-attack
spec/acceptance/stores/redis_store_spec.rb
Ruby
mit
5,726
main
448
# 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...
github
rack/rack-attack
https://github.com/rack/rack-attack
spec/acceptance/stores/active_support_mem_cache_store_spec.rb
Ruby
mit
5,726
main
755
# 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")...
github
rack/rack-attack
https://github.com/rack/rack-attack
spec/integration/offline_spec.rb
Ruby
mit
5,726
main
1,803
# 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...
github
rack/rack-attack
https://github.com/rack/rack-attack
lib/rack/attack.rb
Ruby
mit
5,726
main
3,998
# 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...
github
rack/rack-attack
https://github.com/rack/rack-attack
lib/rack/attack/fail2ban.rb
Ruby
mit
5,726
main
1,648
# 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...
github
rack/rack-attack
https://github.com/rack/rack-attack
lib/rack/attack/railtie.rb
Ruby
mit
5,726
main
279
# 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
github
rack/rack-attack
https://github.com/rack/rack-attack
lib/rack/attack/throttle.rb
Ruby
mit
5,726
main
2,449
# 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| ...
github
rack/rack-attack
https://github.com/rack/rack-attack
lib/rack/attack/track.rb
Ruby
mit
5,726
main
478
# 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 ...
github
rack/rack-attack
https://github.com/rack/rack-attack
lib/rack/attack/allow2ban.rb
Ruby
mit
5,726
main
678
# 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. ...
github
rack/rack-attack
https://github.com/rack/rack-attack
lib/rack/attack/path_normalizer.rb
Ruby
mit
5,726
main
987
# 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...
github
rack/rack-attack
https://github.com/rack/rack-attack
lib/rack/attack/request.rb
Ruby
mit
5,726
main
592
# 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...
github
rack/rack-attack
https://github.com/rack/rack-attack
lib/rack/attack/cache.rb
Ruby
mit
5,726
main
2,851
# frozen_string_literal: true module Rack class Attack class Cache attr_accessor :prefix attr_reader :last_epoch_time def self.default_store if Object.const_defined?(:Rails) && Rails.respond_to?(:cache) ::Rails.cache end end def initialize(store: self.cla...
github
rack/rack-attack
https://github.com/rack/rack-attack
lib/rack/attack/check.rb
Ruby
mit
5,726
main
563
# 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...
github
rack/rack-attack
https://github.com/rack/rack-attack
lib/rack/attack/base_proxy.rb
Ruby
mit
5,726
main
480
# 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...
github
rack/rack-attack
https://github.com/rack/rack-attack
lib/rack/attack/configuration.rb
Ruby
mit
5,726
main
3,968
# 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...
github
rack/rack-attack
https://github.com/rack/rack-attack
lib/rack/attack/store_proxy/redis_cache_store_proxy.rb
Ruby
mit
5,726
main
1,259
# frozen_string_literal: true require 'rack/attack/base_proxy' module Rack class Attack module StoreProxy class RedisCacheStoreProxy < BaseProxy def self.handle?(store) store.class.name == "ActiveSupport::Cache::RedisCacheStore" end if defined?(::ActiveSupport) && ::Acti...
github
rack/rack-attack
https://github.com/rack/rack-attack
lib/rack/attack/store_proxy/redis_store_proxy.rb
Ruby
mit
5,726
main
637
# frozen_string_literal: true require 'rack/attack/store_proxy/redis_proxy' module Rack class Attack module StoreProxy class RedisStoreProxy < RedisProxy def self.handle?(store) defined?(::Redis::Store) && store.is_a?(::Redis::Store) end def read(key) rescuing ...
github
rack/rack-attack
https://github.com/rack/rack-attack
lib/rack/attack/store_proxy/dalli_proxy.rb
Ruby
mit
5,726
main
1,783
# frozen_string_literal: true require 'rack/attack/base_proxy' module Rack class Attack module StoreProxy class DalliProxy < BaseProxy def self.handle?(store) return false unless defined?(::Dalli) # Consider extracting to a separate Connection Pool proxy to reduce # ...
github
rack/rack-attack
https://github.com/rack/rack-attack
lib/rack/attack/store_proxy/mem_cache_store_proxy.rb
Ruby
mit
5,726
main
599
# frozen_string_literal: true require 'rack/attack/base_proxy' module Rack class Attack module StoreProxy class MemCacheStoreProxy < BaseProxy def self.handle?(store) defined?(::Dalli) && defined?(::ActiveSupport::Cache::MemCacheStore) && store.is_a?(::ActiveSuppo...
github
rack/rack-attack
https://github.com/rack/rack-attack
lib/rack/attack/store_proxy/redis_proxy.rb
Ruby
mit
5,726
main
1,690
# frozen_string_literal: true require 'rack/attack/base_proxy' module Rack class Attack module StoreProxy class RedisProxy < BaseProxy def initialize(*args) if Gem::Version.new(Redis::VERSION) < Gem::Version.new("3") warn 'RackAttack requires Redis gem >= 3.0.0.' en...
github
mislav/will_paginate
https://github.com/mislav/will_paginate
will_paginate.gemspec
Ruby
mit
5,696
master
1,675
# encoding: utf-8 require 'rbconfig' require File.expand_path('../lib/will_paginate/version', __FILE__) Gem::Specification.new do |s| s.name = 'will_paginate' s.version = WillPaginate::VERSION::STRING s.required_ruby_version = '>= 2.0' s.summary = "Pagination plugin for web frameworks and other apps" s...
github
mislav/will_paginate
https://github.com/mislav/will_paginate
init.rb
Ruby
mit
5,696
master
471
require 'will_paginate' # This is all duplication of what Railtie does, but is necessary because # the initializer defined by the Railtie won't ever run when loaded as plugin. if defined? ActiveRecord::Base require 'will_paginate/active_record' end if defined? ActionController::Base WillPaginate::Railtie.setup_a...
github
mislav/will_paginate
https://github.com/mislav/will_paginate
Gemfile
Ruby
mit
5,696
master
342
source 'https://rubygems.org' # We test against other Rails versions, too. See `environments/` rails_version = '~> 7.1.3' 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', '~...
github
mislav/will_paginate
https://github.com/mislav/will_paginate
environments/Gemfile.rails5.0.rb
Ruby
mit
5,696
master
361
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...
github
mislav/will_paginate
https://github.com/mislav/will_paginate
environments/Gemfile.rails5.1.rb
Ruby
mit
5,696
master
337
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...
github
mislav/will_paginate
https://github.com/mislav/will_paginate
environments/Gemfile.rails5.2.rb
Ruby
mit
5,696
master
336
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...
github
mislav/will_paginate
https://github.com/mislav/will_paginate
environments/Gemfile.rails7.0.rb
Ruby
mit
5,696
master
342
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', '~...
github
mislav/will_paginate
https://github.com/mislav/will_paginate
environments/Gemfile.rails-edge.rb
Ruby
mit
5,696
master
357
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...
github
mislav/will_paginate
https://github.com/mislav/will_paginate
environments/Gemfile.rails6.0.rb
Ruby
mit
5,696
master
278
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
github
mislav/will_paginate
https://github.com/mislav/will_paginate
environments/Gemfile.rails6.1.rb
Ruby
mit
5,696
master
278
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
github
mislav/will_paginate
https://github.com/mislav/will_paginate
spec/page_number_spec.rb
Ruby
mit
5,696
master
2,409
require 'spec_helper' require 'will_paginate/page_number' require 'json' RSpec.describe WillPaginate::PageNumber do describe "valid" do def num WillPaginate::PageNumber.new('12', 'page') end it "== 12" do expect(num).to eq(12) end it "inspects to 'page 12'" do expect(num.inspe...
github
mislav/will_paginate
https://github.com/mislav/will_paginate
spec/collection_spec.rb
Ruby
mit
5,696
master
4,243
require 'will_paginate/array' require 'spec_helper' RSpec.describe WillPaginate::Collection do before :all do @simple = ('a'..'e').to_a end it "should be a subset of original collection" do expect(@simple.paginate(:page => 1, :per_page => 3)).to eq(%w( a b c )) end it "can be shorter than per_page...
github
mislav/will_paginate
https://github.com/mislav/will_paginate
spec/console_fixtures.rb
Ruby
mit
5,696
master
796
require 'bundler' Bundler.setup require 'will_paginate/active_record' require 'finders/activerecord_test_connector' ActiverecordTestConnector.setup windows = RUBY_PLATFORM =~ /(:?mswin|mingw)/ # used just for the `color` method log_subscriber = ActiveSupport::LogSubscriber.log_subscribers.first IGNORE_SQL = /\b(sql...
github
mislav/will_paginate
https://github.com/mislav/will_paginate
spec/per_page_spec.rb
Ruby
mit
5,696
master
815
require 'spec_helper' require 'will_paginate/per_page' RSpec.describe WillPaginate::PerPage do class MyModel extend WillPaginate::PerPage end it "has the default value" do expect(MyModel.per_page).to eq(30) WillPaginate.per_page = 10 begin expect(MyModel.per_page).to eq(10) ensure ...
github
mislav/will_paginate
https://github.com/mislav/will_paginate
spec/spec_helper.rb
Ruby
mit
5,696
master
938
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) ...
github
mislav/will_paginate
https://github.com/mislav/will_paginate
spec/matchers/query_count_matcher.rb
Ruby
mit
5,696
master
627
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 = ...
github
mislav/will_paginate
https://github.com/mislav/will_paginate
spec/view_helpers/view_example_group.rb
Ruby
mit
5,696
master
2,477
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...
github
mislav/will_paginate
https://github.com/mislav/will_paginate
spec/view_helpers/action_view_spec.rb
Ruby
mit
5,696
master
14,094
# 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#...
github
mislav/will_paginate
https://github.com/mislav/will_paginate
spec/view_helpers/base_spec.rb
Ruby
mit
5,696
master
4,775
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 ...
github
mislav/will_paginate
https://github.com/mislav/will_paginate
spec/view_helpers/link_renderer_base_spec.rb
Ruby
mit
5,696
master
2,763
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...
github
mislav/will_paginate
https://github.com/mislav/will_paginate
spec/finders/activerecord_test_connector.rb
Ruby
mit
5,696
master
3,882
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...
github
mislav/will_paginate
https://github.com/mislav/will_paginate
spec/finders/active_record_spec.rb
Ruby
mit
5,696
master
13,711
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...
github
mislav/will_paginate
https://github.com/mislav/will_paginate
lib/will_paginate.rb
Ruby
mit
5,696
master
324
# 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' ...
github
mislav/will_paginate
https://github.com/mislav/will_paginate
lib/will_paginate/core_ext.rb
Ruby
mit
5,696
master
737
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...
github
mislav/will_paginate
https://github.com/mislav/will_paginate
lib/will_paginate/active_record.rb
Ruby
mit
5,696
master
7,654
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...
github
mislav/will_paginate
https://github.com/mislav/will_paginate
lib/will_paginate/array.rb
Ruby
mit
5,696
master
1,298
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...
github
mislav/will_paginate
https://github.com/mislav/will_paginate
lib/will_paginate/sequel.rb
Ruby
mit
5,696
master
782
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...
github
mislav/will_paginate
https://github.com/mislav/will_paginate
lib/will_paginate/page_number.rb
Ruby
mit
5,696
master
1,216
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 ...
github
mislav/will_paginate
https://github.com/mislav/will_paginate
lib/will_paginate/railtie.rb
Ruby
mit
5,696
master
2,274
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...
github
mislav/will_paginate
https://github.com/mislav/will_paginate
lib/will_paginate/view_helpers.rb
Ruby
mit
5,696
master
6,836
# 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...
github
mislav/will_paginate
https://github.com/mislav/will_paginate
lib/will_paginate/mongoid.rb
Ruby
mit
5,696
master
1,159
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 ...
github
mislav/will_paginate
https://github.com/mislav/will_paginate
lib/will_paginate/deprecation.rb
Ruby
mit
5,696
master
1,242
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...
github
mislav/will_paginate
https://github.com/mislav/will_paginate
lib/will_paginate/collection.rb
Ruby
mit
5,696
master
5,164
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...
github
mislav/will_paginate
https://github.com/mislav/will_paginate
lib/will_paginate/per_page.rb
Ruby
mit
5,696
master
489
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...
github
mislav/will_paginate
https://github.com/mislav/will_paginate
lib/will_paginate/i18n.rb
Ruby
mit
5,696
master
566
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 ...
github
mislav/will_paginate
https://github.com/mislav/will_paginate
lib/will_paginate/view_helpers/action_view.rb
Ruby
mit
5,696
master
4,702
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...
github
mislav/will_paginate
https://github.com/mislav/will_paginate
lib/will_paginate/view_helpers/hanami.rb
Ruby
mit
5,696
master
1,029
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...
github
mislav/will_paginate
https://github.com/mislav/will_paginate
lib/will_paginate/view_helpers/sinatra.rb
Ruby
mit
5,696
master
981
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 ...
github
mislav/will_paginate
https://github.com/mislav/will_paginate
lib/will_paginate/view_helpers/link_renderer.rb
Ruby
mit
5,696
master
4,778
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. ...
github
mislav/will_paginate
https://github.com/mislav/will_paginate
lib/will_paginate/view_helpers/link_renderer_base.rb
Ruby
mit
5,696
master
2,349
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...
github
mislav/will_paginate
https://github.com/mislav/will_paginate
spec-non-rails/mongoid_spec.rb
Ruby
mit
5,696
master
4,635
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...
github
mislav/will_paginate
https://github.com/mislav/will_paginate
spec-non-rails/sequel_spec.rb
Ruby
mit
5,696
master
1,931
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...
github
mislav/will_paginate
https://github.com/mislav/will_paginate
spec-non-rails/spec_helper.rb
Ruby
mit
5,696
master
341
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_...
github
CanCanCommunity/cancancan
https://github.com/CanCanCommunity/cancancan
Appraisals
Ruby
mit
5,670
develop
2,658
appraise 'activerecord_5.2.2' do gem 'activerecord', '~> 5.2.2', require: 'active_record' gem 'activesupport', '~> 5.2.2', require: 'active_support/all' gem 'actionpack', '~> 5.2.2', require: 'action_pack' gemfile.platforms :jruby do gem 'activerecord-jdbcsqlite3-adapter' gem 'jdbc-sqlite3' gem 'jd...
github
CanCanCommunity/cancancan
https://github.com/CanCanCommunity/cancancan
cancancan.gemspec
Ruby
mit
5,670
develop
1,220
# frozen_string_literal: true lib = File.expand_path('lib', __dir__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'cancan/version' Gem::Specification.new do |s| s.name = 'cancancan' s.version = CanCan::VERSION s.authors = ['Alessandro Rodi (Renuo AG)', 'Bryan Rite', 'Ryan Bates...
github
CanCanCommunity/cancancan
https://github.com/CanCanCommunity/cancancan
lib/cancan.rb
Ruby
mit
5,670
develop
1,115
# frozen_string_literal: true require 'cancan/version' require 'cancan/config' require 'cancan/parameter_validators' require 'cancan/ability' require 'cancan/rule' require 'cancan/controller_resource' require 'cancan/controller_additions' require 'cancan/model_additions' require 'cancan/exceptions' require 'cancan/mo...
github
CanCanCommunity/cancancan
https://github.com/CanCanCommunity/cancancan
lib/generators/cancan/ability/ability_generator.rb
Ruby
mit
5,670
develop
287
# frozen_string_literal: true module Cancan module Generators class AbilityGenerator < Rails::Generators::Base source_root File.expand_path('templates', __dir__) def generate_ability copy_file 'ability.rb', 'app/models/ability.rb' end end end end