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
ankane/pghero
https://github.com/ankane/pghero
lib/pghero/methods/users.rb
Ruby
mit
8,851
master
3,511
module PgHero module Methods module Users # documented as unsafe to pass user input # identifiers are now quoted, but still not officially supported def create_user(user, password: nil, schema: "public", database: nil, readonly: false, tables: nil) password ||= random_password da...
github
ankane/pghero
https://github.com/ankane/pghero
lib/pghero/methods/kill.rb
Ruby
mit
8,851
master
679
module PgHero module Methods module Kill def kill(pid) select_one("SELECT pg_terminate_backend(#{pid.to_i})") end def kill_long_running_queries(min_duration: nil) running_queries(min_duration: min_duration || long_running_query_sec).each { |query| kill(query[:pid]) } tru...
github
ankane/pghero
https://github.com/ankane/pghero
lib/pghero/methods/explain.rb
Ruby
mit
8,851
master
2,171
module PgHero module Methods module Explain # TODO remove in 4.0 # note: this method is not affected by the explain option def explain(sql) sql = squish(sql) explanation = nil # use transaction for safety with_transaction(statement_timeout: (explain_timeout_sec *...
github
ankane/pghero
https://github.com/ankane/pghero
lib/pghero/methods/indexes.rb
Ruby
mit
8,851
master
11,675
module PgHero module Methods module Indexes def index_hit_rate select_one <<~SQL SELECT (sum(idx_blks_hit)) / nullif(sum(idx_blks_hit + idx_blks_read), 0) AS rate FROM pg_statio_user_indexes SQL end def index_caching select_all...
github
ankane/pghero
https://github.com/ankane/pghero
lib/pghero/methods/constraints.rb
Ruby
mit
8,851
master
904
module PgHero module Methods module Constraints # referenced fields can be nil # as not all constraints are foreign keys def invalid_constraints select_all <<~SQL SELECT nsp.nspname AS schema, rel.relname AS table, con.conname AS name, ...
github
ankane/pghero
https://github.com/ankane/pghero
lib/pghero/methods/settings.rb
Ruby
mit
8,851
master
2,244
module PgHero module Methods module Settings def settings names = if server_version_num >= 180000 %i( max_connections shared_buffers effective_cache_size maintenance_work_mem checkpoint_completion_target wal_buffers default_statistics_target ...
github
ankane/pghero
https://github.com/ankane/pghero
lib/pghero/methods/system.rb
Ruby
mit
8,851
master
11,239
module PgHero module Methods module System def system_stats_enabled? !system_stats_provider.nil? end def system_stats_provider if aws_db_instance_identifier :aws elsif gcp_database_id :gcp elsif azure_resource_id :azure end ...
github
ankane/pghero
https://github.com/ankane/pghero
lib/pghero/methods/maintenance.rb
Ruby
mit
8,851
master
2,951
module PgHero module Methods module Maintenance # https://www.postgresql.org/docs/current/routine-vacuuming.html#VACUUM-FOR-WRAPAROUND # "the system will shut down and refuse to start any new transactions # once there are fewer than 1 million transactions left until wraparound" # warn when...
github
ankane/pghero
https://github.com/ankane/pghero
lib/pghero/methods/query_stats.rb
Ruby
mit
8,851
master
14,097
module PgHero module Methods module QueryStats def query_stats(historical: false, start_at: nil, end_at: nil, min_average_time: nil, min_calls: nil, **options) current_query_stats = historical && end_at && end_at < Time.now ? [] : current_query_stats(**options) historical_query_stats = histo...
github
ankane/pghero
https://github.com/ankane/pghero
lib/pghero/methods/suggested_indexes.rb
Ruby
mit
8,851
master
12,201
module PgHero module Methods module SuggestedIndexes def suggested_indexes_enabled? defined?(PgQuery) && Gem::Version.new(PgQuery::VERSION) >= Gem::Version.new("2") && query_stats_enabled? end # TODO clean this mess def suggested_indexes_by_query(queries: nil, query_stats: nil, in...
github
ankane/pghero
https://github.com/ankane/pghero
lib/pghero/methods/tables.rb
Ruby
mit
8,851
master
1,750
module PgHero module Methods module Tables def table_hit_rate select_one <<~SQL SELECT sum(heap_blks_hit) / nullif(sum(heap_blks_hit) + sum(heap_blks_read), 0) AS rate FROM pg_statio_user_tables SQL end def table_caching select...
github
ankane/pghero
https://github.com/ankane/pghero
lib/pghero/methods/space.rb
Ruby
mit
8,851
master
4,202
module PgHero module Methods module Space def database_size PgHero.pretty_size select_one("SELECT pg_database_size(current_database())") end def relation_sizes select_all_size <<~SQL SELECT n.nspname AS schema, c.relname AS relation, ...
github
ankane/pghero
https://github.com/ankane/pghero
lib/pghero/methods/connections.rb
Ruby
mit
8,851
master
1,806
module PgHero module Methods module Connections def connections if server_version_num >= 90500 select_all <<~SQL SELECT pg_stat_activity.pid, datname AS database, usename AS user, application_name AS source, ...
github
ankane/pghero
https://github.com/ankane/pghero
test/controller_test.rb
Ruby
mit
8,851
master
5,383
require_relative "test_helper" class ControllerTest < ActionDispatch::IntegrationTest def test_index get pg_hero.root_path assert_response :success end def test_space get pg_hero.space_path assert_response :success end def test_relation_space get pg_hero.relation_space_path(relation: "u...
github
ankane/pghero
https://github.com/ankane/pghero
test/connections_test.rb
Ruby
mit
8,851
master
421
require_relative "test_helper" class ConnectionsTest < Minitest::Test def test_connections assert_kind_of Array, database.connections end def test_total_connections assert_kind_of Integer, database.total_connections end def test_connection_states assert_kind_of Hash, database.connection_states ...
github
ankane/pghero
https://github.com/ankane/pghero
test/replication_test.rb
Ruby
mit
8,851
master
355
require_relative "test_helper" class ReplicationTest < Minitest::Test def test_replica refute database.replica? end def test_replication_lag assert_equal 0, database.replication_lag end def test_replication_slots assert_equal [], database.replication_slots end def test_replicating refu...
github
ankane/pghero
https://github.com/ankane/pghero
test/sequences_test.rb
Ruby
mit
8,851
master
914
require_relative "test_helper" class SequencesTest < Minitest::Test def test_sequences seq = database.sequences.find { |s| s[:sequence] == "cities_id_seq" } assert_equal "public", seq[:table_schema] assert_equal "cities", seq[:table] assert_equal "id", seq[:column] assert_equal "bigint", seq[:col...
github
ankane/pghero
https://github.com/ankane/pghero
test/maintenance_test.rb
Ruby
mit
8,851
master
630
require_relative "test_helper" class MaintenanceTest < Minitest::Test def test_transaction_id_danger assert database.transaction_id_danger(threshold: 10000000000).any? assert_equal [], database.transaction_id_danger end def test_autovacuum_danger assert_equal [], database.autovacuum_danger end ...
github
ankane/pghero
https://github.com/ankane/pghero
test/basic_test.rb
Ruby
mit
8,851
master
390
require_relative "test_helper" class BasicTest < Minitest::Test def test_ssl_used? refute database.ssl_used? end def test_database_name assert_equal "pghero_test", database.database_name end def test_server_version assert_kind_of String, database.server_version end def test_server_version_...
github
ankane/pghero
https://github.com/ankane/pghero
test/explain_test.rb
Ruby
mit
8,851
master
2,454
require_relative "test_helper" class ExplainTest < Minitest::Test def setup City.delete_all end def test_explain assert_match "Result", database.explain("SELECT 1") end def test_explain_analyze City.create! assert_equal 1, City.count database.explain("ANALYZE DELETE FROM cities") as...
github
ankane/pghero
https://github.com/ankane/pghero
test/queries_test.rb
Ruby
mit
8,851
master
971
require_relative "test_helper" class QueriesTest < Minitest::Test def test_running_queries assert database.running_queries end def test_filter_data query = "SELECT pg_sleep(1)" # TODO manually checkout connection if needed t = Thread.new { ActiveRecord::Base.connection.execute(query) } sleep...
github
ankane/pghero
https://github.com/ankane/pghero
test/settings_test.rb
Ruby
mit
8,851
master
338
require_relative "test_helper" class SettingsTest < Minitest::Test def test_settings assert database.settings[:max_connections] end def test_autovacuum_settings assert_equal "on", database.autovacuum_settings[:autovacuum] end def test_vacuum_settings assert database.vacuum_settings[:vacuum_cost...
github
ankane/pghero
https://github.com/ankane/pghero
test/config_generator_test.rb
Ruby
mit
8,851
master
352
require_relative "test_helper" require "generators/pghero/config_generator" class ConfigGeneratorTest < Rails::Generators::TestCase tests Pghero::Generators::ConfigGenerator destination File.expand_path("../tmp", __dir__) setup :prepare_destination def test_works run_generator assert_file "config/pgh...
github
ankane/pghero
https://github.com/ankane/pghero
test/module_test.rb
Ruby
mit
8,851
master
816
require_relative "test_helper" class ModuleTest < Minitest::Test def test_databases assert PgHero.databases.any? end def test_connection_pool 1000.times do [:@config, :@databases].each do |var| PgHero.remove_instance_variable(var) if PgHero.instance_variable_defined?(var) end ...
github
ankane/pghero
https://github.com/ankane/pghero
test/space_stats_generator_test.rb
Ruby
mit
8,851
master
415
require_relative "test_helper" require "generators/pghero/space_stats_generator" class SpaceStatsGeneratorTest < Rails::Generators::TestCase tests Pghero::Generators::SpaceStatsGenerator destination File.expand_path("../tmp", __dir__) setup :prepare_destination def test_works run_generator assert_mig...
github
ankane/pghero
https://github.com/ankane/pghero
test/indexes_test.rb
Ruby
mit
8,851
master
1,046
require_relative "test_helper" class IndexesTest < Minitest::Test def test_index_hit_rate database.index_hit_rate assert true end def test_index_caching assert database.index_caching end def test_index_usage assert database.index_usage end def test_missing_indexes assert database.m...
github
ankane/pghero
https://github.com/ankane/pghero
test/query_stats_test.rb
Ruby
mit
8,851
master
3,608
require_relative "test_helper" class QueryStatsTest < Minitest::Test def test_query_stats assert database.query_stats end def test_query_stats_available assert database.query_stats_available? end def test_query_stats_enabled assert database.query_stats_enabled? end def test_query_stats_ext...
github
ankane/pghero
https://github.com/ankane/pghero
test/query_stats_generator_test.rb
Ruby
mit
8,851
master
415
require_relative "test_helper" require "generators/pghero/query_stats_generator" class QueryStatsGeneratorTest < Rails::Generators::TestCase tests Pghero::Generators::QueryStatsGenerator destination File.expand_path("../tmp", __dir__) setup :prepare_destination def test_works run_generator assert_mig...
github
ankane/pghero
https://github.com/ankane/pghero
test/tables_test.rb
Ruby
mit
8,851
master
340
require_relative "test_helper" class TablesTest < Minitest::Test def test_table_hit_rate database.table_hit_rate assert true end def test_table_caching assert database.table_caching end def test_unused_tables assert database.unused_tables end def test_table_stats assert database.ta...
github
ankane/pghero
https://github.com/ankane/pghero
test/test_helper.rb
Ruby
mit
8,851
master
1,829
require "bundler/setup" require "combustion" Bundler.require(:default) require "minitest/autorun" class Minitest::Test def database @database ||= PgHero.databases[:primary] end def with_explain(value) PgHero.config.merge!({"explain" => value}) yield ensure PgHero.remove_instance_variable(:@con...
github
ankane/pghero
https://github.com/ankane/pghero
test/kill_test.rb
Ruby
mit
8,851
master
329
require_relative "test_helper" class KillTest < Minitest::Test def test_kill # prevent warning for now # refute database.kill(1_000_000_000) end def test_kill_long_running_queries assert database.kill_long_running_queries end def test_kill_all # skip for now # assert database.kill_all ...
github
ankane/pghero
https://github.com/ankane/pghero
test/users_test.rb
Ruby
mit
8,851
master
309
require_relative "test_helper" class UsersTest < Minitest::Test def teardown database.drop_user(user) end def test_create_user database.create_user(user) end def test_create_user_tables database.create_user(user, tables: ["cities"]) end def user "pghero_test_user" end end
github
ankane/pghero
https://github.com/ankane/pghero
test/best_index_test.rb
Ruby
mit
8,851
master
6,476
require_relative "test_helper" class BestIndexTest < Minitest::Test def test_where assert_best_index ({table: "users", columns: ["city_id"]}), "SELECT * FROM users WHERE city_id = 1" end def test_all_values index = database.best_index("SELECT * FROM users WHERE login_attempts = 1 ORDER BY created_at") ...
github
ankane/pghero
https://github.com/ankane/pghero
test/suggested_indexes_test.rb
Ruby
mit
8,851
master
3,277
require_relative "test_helper" class SuggestedIndexesTest < Minitest::Test def setup if database.server_version_num >= 120000 database.reset_query_stats else database.reset_instance_query_stats end end def test_suggested_indexes_enabled assert database.suggested_indexes_enabled? en...
github
ankane/pghero
https://github.com/ankane/pghero
test/system_test.rb
Ruby
mit
8,851
master
236
require_relative "test_helper" class SystemTest < Minitest::Test def test_system_stats_enabled refute database.system_stats_enabled? end def test_system_stats_provider assert_nil database.system_stats_provider end end
github
ankane/pghero
https://github.com/ankane/pghero
test/space_test.rb
Ruby
mit
8,851
master
1,032
require_relative "test_helper" class SpaceTest < Minitest::Test def test_database_size assert database.database_size end def test_relation_sizes relation_sizes = database.relation_sizes assert relation_sizes.find { |r| r[:relation] == "users" && r[:type] == "table" } assert relation_sizes.find {...
github
ankane/pghero
https://github.com/ankane/pghero
test/internal/db/schema.rb
Ruby
mit
8,851
master
1,488
ActiveRecord::Schema.define do enable_extension "pg_stat_statements" enable_extension "pg_trgm" enable_extension "ltree" create_table :pghero_query_stats, force: true do |t| t.text :database t.text :user t.text :query t.integer :query_hash, limit: 8 t.float :total_time t.integer :calls,...
github
ankane/pghero
https://github.com/ankane/pghero
app/helpers/pg_hero/home_helper.rb
Ruby
mit
8,851
master
1,153
module PgHero module HomeHelper def pghero_pretty_ident(table, schema: nil) ident = table if schema && schema != "public" ident = "#{schema}.#{table}" end if /\A[a-z0-9_]+\z/.match?(ident) ident else @database.quote_ident(ident) end end def pghe...
github
ankane/pghero
https://github.com/ankane/pghero
app/controllers/pg_hero/home_controller.rb
Ruby
mit
8,851
master
20,148
module PgHero class HomeController < ActionController::Base http_basic_authenticate_with name: PgHero.username, password: PgHero.password if PgHero.password protect_from_forgery with: :exception before_action :check_api before_action :set_database before_action :set_query_stats_enabled befor...
github
kaminari/kaminari
https://github.com/kaminari/kaminari
kaminari.gemspec
Ruby
mit
8,670
master
1,524
# frozen_string_literal: true $:.push File.expand_path("../lib", __FILE__) require "kaminari/version" Gem::Specification.new do |spec| spec.name = 'kaminari' spec.version = Kaminari::VERSION spec.authors = ['Akira Matsuda', 'Yuki Nishijima', 'Zachary Scott', 'Hiroshi Shibata'] spec.email ...
github
kaminari/kaminari
https://github.com/kaminari/kaminari
Gemfile
Ruby
mit
8,670
master
2,561
# frozen_string_literal: true source 'https://rubygems.org' # Specify your gem's dependencies in kaminari.gemspec gemspec if ENV['RAILS_VERSION'] == 'edge' gem 'railties', git: 'https://github.com/rails/rails.git' gem 'activerecord', git: 'https://github.com/rails/rails.git', require: 'active_record' gem 'acti...
github
kaminari/kaminari
https://github.com/kaminari/kaminari
Rakefile
Ruby
mit
8,670
master
1,007
# frozen_string_literal: true require "bundler/gem_tasks" require 'rake/testtask' Rake::TestTask.new do |t| t.libs << 'test' t.pattern = "{test,#{File.join(Gem.loaded_specs['kaminari-core'].gem_dir, 'test')}}/**/*_test.rb" t.warning = true t.verbose = true end task :install_tasks_for_sub_gems do Bundler::...
github
kaminari/kaminari
https://github.com/kaminari/kaminari
misc/bug_report_template.rb
Ruby
mit
8,670
master
1,349
begin require "bundler/inline" rescue LoadError => e $stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler" raise e end gemfile(true) do source "https://rubygems.org" # Activate the gem you are reporting the issue against. gem "railties", "5.0.1" gem "activerecord", "5.0.1" ...
github
kaminari/kaminari
https://github.com/kaminari/kaminari
kaminari-core/kaminari-core.gemspec
Ruby
mit
8,670
master
1,156
# frozen_string_literal: true lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'kaminari/core/version' Gem::Specification.new do |spec| spec.name = "kaminari-core" spec.version = Kaminari::Core::VERSION spec.authors = ["Akira Matsuda...
github
kaminari/kaminari
https://github.com/kaminari/kaminari
kaminari-core/test/fake_gem.rb
Ruby
mit
8,670
master
478
# frozen_string_literal: true module Kaminari module FakeGem extend ActiveSupport::Concern module ClassMethods def inherited(kls) super def kls.fake_gem_defined_method; end end end end end ActiveSupport.on_load :active_record do ActiveRecord::Base.send :include, Kaminari...
github
kaminari/kaminari
https://github.com/kaminari/kaminari
kaminari-core/test/config/config_test.rb
Ruby
mit
8,670
master
2,474
# frozen_string_literal: true require 'test_helper' class ConfigurationTest < ::Test::Unit::TestCase sub_test_case 'default_per_page' do test 'by default' do assert_equal 25, Kaminari.config.default_per_page end test 'configured via config block' do begin Kaminari.configure {|c| c.de...
github
kaminari/kaminari
https://github.com/kaminari/kaminari
kaminari-core/test/helpers/helpers_test.rb
Ruby
mit
8,670
master
1,751
# frozen_string_literal: true require 'test_helper' class PaginatorHelperTest < ActiveSupport::TestCase include Kaminari::Helpers def template stub(r = Object.new) do render.with_any_args params { {} } options { {} } url_for {|h| "/foo?page=#{h[:page]}"} link_to { "<a href='#'>l...
github
kaminari/kaminari
https://github.com/kaminari/kaminari
kaminari-core/test/helpers/tags_test.rb
Ruby
mit
8,670
master
9,305
# frozen_string_literal: true require 'test_helper' if defined?(::Rails::Railtie) && defined?(ActionView) class TagTest < ActionView::TestCase sub_test_case '#page_url_for' do setup do self.params[:controller] = 'users' self.params[:action] = 'index' end sub_test_case 'for...
github
kaminari/kaminari
https://github.com/kaminari/kaminari
kaminari-core/test/helpers/paginator_tags_test.rb
Ruby
mit
8,670
master
2,754
# frozen_string_literal: true require 'test_helper' if defined? ::Kaminari::Actionview class PaginatorTagsTest < ActionView::TestCase # A test paginator that can detect instantiated tags inside class TagSpy < Kaminari::Helpers::Paginator def initialize(*, **) super @tags = [] end...
github
kaminari/kaminari
https://github.com/kaminari/kaminari
kaminari-core/test/helpers/action_view_extension_test.rb
Ruby
mit
8,670
master
21,595
# frozen_string_literal: true require 'test_helper' if defined?(::Rails::Railtie) && defined?(::ActionView) class ActionViewExtensionTest < ActionView::TestCase setup do self.output_buffer = ::ActionView::OutputBuffer.new I18n.available_locales = [:en, :de, :fr] I18n.locale = :en end t...
github
kaminari/kaminari
https://github.com/kaminari/kaminari
kaminari-core/test/fake_app/rails_app.rb
Ruby
mit
8,670
master
1,953
# frozen_string_literal: true # require 'rails/all' require 'action_controller/railtie' require 'action_view/railtie' require 'active_record/railtie' if defined? ActiveRecord # config class KaminariTestApp < Rails::Application config.load_defaults "#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}" if config.respon...
github
kaminari/kaminari
https://github.com/kaminari/kaminari
kaminari-core/test/fake_app/active_record/models.rb
Ruby
mit
8,670
master
2,658
# frozen_string_literal: true # models class User < ActiveRecord::Base has_many :authorships has_many :readerships has_many :books_authored, through: :authorships, source: :book has_many :books_read, through: :readerships, source: :book has_many :addresses, class_name: 'User::Address' def readers User...
github
kaminari/kaminari
https://github.com/kaminari/kaminari
kaminari-core/test/generators/views_generator_test.rb
Ruby
mit
8,670
master
566
# frozen_string_literal: true require 'test_helper' if defined?(::Rails::Railtie) && ENV['GENERATOR_SPEC'] require 'rails/generators' require 'generators/kaminari/views_generator' class GitHubApiHelperTest < ::Test::Unit::TestCase test '.get_files_in_master' do assert_include Kaminari::Generators::Gi...
github
kaminari/kaminari
https://github.com/kaminari/kaminari
kaminari-core/test/models/array_test.rb
Ruby
mit
8,670
master
4,819
# frozen_string_literal: true require 'test_helper' class PaginatableArrayTest < ActiveSupport::TestCase setup do @array = Kaminari::PaginatableArray.new((1..100).to_a) end test 'initial state' do assert_equal 0, Kaminari::PaginatableArray.new.count end test 'specifying limit and offset when initi...
github
kaminari/kaminari
https://github.com/kaminari/kaminari
kaminari-core/test/models/configuration_methods_test.rb
Ruby
mit
8,670
master
2,771
# frozen_string_literal: true require 'test_helper' class ConfigurationMethodsTest < ActiveSupport::TestCase sub_test_case '#default_per_page' do if defined? ActiveRecord test 'AR::Base should be not polluted by configuration methods' do assert_not_respond_to ActiveRecord::Base, :paginates_per ...
github
kaminari/kaminari
https://github.com/kaminari/kaminari
kaminari-core/test/models/active_record/paginable_without_count_test.rb
Ruby
mit
8,670
master
2,854
# frozen_string_literal: true require 'test_helper' if defined? ActiveRecord class PaginableWithoutCountTest < ActiveSupport::TestCase def self.startup 26.times { User.create! } super end def self.shutdown User.delete_all super end test 'it does not make count queries a...
github
kaminari/kaminari
https://github.com/kaminari/kaminari
kaminari-core/test/models/active_record/active_record_relation_methods_test.rb
Ruby
mit
8,670
master
6,190
# frozen_string_literal: true require 'test_helper' if defined? ActiveRecord class ActiveRecordRelationMethodsTest < ActiveSupport::TestCase sub_test_case '#total_count' do setup do @author = User.create! name: 'author' @author2 = User.create! name: 'author2' @author3 = User.create...
github
kaminari/kaminari
https://github.com/kaminari/kaminari
kaminari-core/test/models/active_record/inherited_test.rb
Ruby
mit
8,670
master
457
# frozen_string_literal: true require 'test_helper' if defined? ActiveRecord class ActiveRecordModelExtensionTest < ActiveSupport::TestCase test 'An AR model responds to Kaminari defined methods' do assert_respond_to Class.new(ActiveRecord::Base), :page end test "Kaminari doesn't prevent other AR...
github
kaminari/kaminari
https://github.com/kaminari/kaminari
kaminari-core/test/models/active_record/scopes_test.rb
Ruby
mit
8,670
master
12,126
# frozen_string_literal: true require 'test_helper' if defined? ActiveRecord class ActiveRecordModelExtensionTest < ActiveSupport::TestCase test 'Changing page_method_name' do begin Kaminari.configure {|config| config.page_method_name = :per_page_kaminari } model = Class.new ActiveRecord:...
github
kaminari/kaminari
https://github.com/kaminari/kaminari
kaminari-core/test/requests/navigation_test.rb
Ruby
mit
8,670
master
1,742
# frozen_string_literal: true require 'test_helper' class NavigationTest < Test::Unit::TestCase include Capybara::DSL setup do 1.upto(100) {|i| User.create! name: "user#{'%03d' % i}" } Capybara.current_driver = :rack_test end teardown do Capybara.reset_sessions! Capybara.use_default_driver ...
github
kaminari/kaminari
https://github.com/kaminari/kaminari
kaminari-core/test/requests/request_format_test.rb
Ruby
mit
8,670
master
516
# frozen_string_literal: true require 'test_helper' class RenderingWithFormatOptionTest < Test::Unit::TestCase include Capybara::DSL setup do User.create! name: 'user1' end teardown do Capybara.reset_sessions! Capybara.use_default_driver User.delete_all end test "Make sure that kaminari...
github
kaminari/kaminari
https://github.com/kaminari/kaminari
kaminari-core/lib/generators/kaminari/config_generator.rb
Ruby
mit
8,670
master
499
# frozen_string_literal: true module Kaminari module Generators # rails g kaminari:config class ConfigGenerator < Rails::Generators::Base # :nodoc: source_root File.expand_path(File.join(File.dirname(__FILE__), 'templates')) desc <<DESC Description: Copies Kaminari configuration file to your...
github
kaminari/kaminari
https://github.com/kaminari/kaminari
kaminari-core/lib/generators/kaminari/views_generator.rb
Ruby
mit
8,670
master
4,721
# frozen_string_literal: true module Kaminari module Generators # rails g kaminari:views THEME class ViewsGenerator < Rails::Generators::NamedBase # :nodoc: source_root File.expand_path('../../../../app/views/kaminari', __FILE__) class_option :template_engine, type: :string, aliases: '-e', desc:...
github
kaminari/kaminari
https://github.com/kaminari/kaminari
kaminari-core/lib/generators/kaminari/templates/kaminari_config.rb
Ruby
mit
8,670
master
353
# frozen_string_literal: true Kaminari.configure do |config| # config.default_per_page = 25 # config.max_per_page = nil # config.window = 4 # config.outer_window = 0 # config.left = 0 # config.right = 0 # config.page_method_name = :page # config.param_name = :page # config.max_pages = nil # config....
github
kaminari/kaminari
https://github.com/kaminari/kaminari
kaminari-core/lib/kaminari/railtie.rb
Ruby
mit
8,670
master
230
# frozen_string_literal: true module Kaminari class Railtie < ::Rails::Railtie #:nodoc: # Doesn't actually do anything. Just keeping this hook point, mainly for compatibility initializer 'kaminari' do end end end
github
kaminari/kaminari
https://github.com/kaminari/kaminari
kaminari-core/lib/kaminari/config.rb
Ruby
mit
8,670
master
942
# frozen_string_literal: true module Kaminari # Configures global settings for Kaminari # Kaminari.configure do |config| # config.default_per_page = 10 # end class << self def configure yield config end def config @_config ||= Config.new end end class Config attr...
github
kaminari/kaminari
https://github.com/kaminari/kaminari
kaminari-core/lib/kaminari/core.rb
Ruby
mit
8,670
master
624
# frozen_string_literal: true module Kaminari def self.deprecator @deprecator ||= ActiveSupport::Deprecation.new("2.0", "kaminari-core") end end # load Rails/Railtie begin require 'rails' rescue LoadError #do nothing end # load Kaminari components require 'kaminari/config' require 'kaminari/exceptions' r...
github
kaminari/kaminari
https://github.com/kaminari/kaminari
kaminari-core/lib/kaminari/engine.rb
Ruby
mit
8,670
master
241
# frozen_string_literal: true module Kaminari #:nodoc: class Engine < ::Rails::Engine #:nodoc: initializer :deprecator do |app| app.deprecators[:kaminari] = Kaminari.deprecator if app.respond_to?(:deprecators) end end end
github
kaminari/kaminari
https://github.com/kaminari/kaminari
kaminari-core/lib/kaminari/models/configuration_methods.rb
Ruby
mit
8,670
master
1,876
# frozen_string_literal: true require 'active_support/concern' module Kaminari module ConfigurationMethods #:nodoc: extend ActiveSupport::Concern module ClassMethods #:nodoc: # Overrides the default +per_page+ value per model # class Article < ActiveRecord::Base # paginates_per 10 ...
github
kaminari/kaminari
https://github.com/kaminari/kaminari
kaminari-core/lib/kaminari/models/array_extension.rb
Ruby
mit
8,670
master
2,483
# frozen_string_literal: true require 'active_support/core_ext/module' module Kaminari # Kind of Array that can paginate class PaginatableArray < Array include Kaminari::ConfigurationMethods::ClassMethods ENTRY = 'entry'.freeze attr_internal_accessor :limit_value, :offset_value # ==== Options ...
github
kaminari/kaminari
https://github.com/kaminari/kaminari
kaminari-core/lib/kaminari/models/page_scope_methods.rb
Ruby
mit
8,670
master
2,828
# frozen_string_literal: true module Kaminari module PageScopeMethods # Specify the <tt>per_page</tt> value for the preceding <tt>page</tt> scope # Model.page(3).per(10) def per(num, max_per_page: nil) max_per_page ||= ((defined?(@_max_per_page) && @_max_per_page) || self.max_per_page) @_pe...
github
kaminari/kaminari
https://github.com/kaminari/kaminari
kaminari-core/lib/kaminari/helpers/tags.rb
Ruby
mit
8,670
master
5,795
# frozen_string_literal: true module Kaminari module Helpers PARAM_KEY_EXCEPT_LIST = [:authenticity_token, :commit, :utf8, :_method, :script_name, :original_script_name].freeze # A tag stands for an HTML tag inside the paginator. # Basically, a tag has its own partial template file, so every tag can be ...
github
kaminari/kaminari
https://github.com/kaminari/kaminari
kaminari-core/lib/kaminari/helpers/helper_methods.rb
Ruby
mit
8,670
master
9,131
# frozen_string_literal: true module Kaminari module Helpers # The Kaminari::Helpers::UrlHelper module provides useful methods for # generating a path or url to a particular page. A class must implement the # following methods: # # * <tt>url_for</tt>: A method that generates an actual path ...
github
kaminari/kaminari
https://github.com/kaminari/kaminari
kaminari-core/lib/kaminari/helpers/paginator.rb
Ruby
mit
8,670
master
6,355
# frozen_string_literal: true require 'active_support/inflector' require 'kaminari/helpers/tags' module Kaminari module Helpers # The main container tag class Paginator < Tag def initialize(template, window: nil, outer_window: Kaminari.config.outer_window, left: Kaminari.config.left, right: Kaminari.c...
github
kaminari/kaminari
https://github.com/kaminari/kaminari
kaminari-activerecord/kaminari-activerecord.gemspec
Ruby
mit
8,670
master
1,280
# frozen_string_literal: true lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'kaminari/activerecord/version' Gem::Specification.new do |spec| spec.name = "kaminari-activerecord" spec.version = Kaminari::Activerecord::VERSION spec.authors...
github
kaminari/kaminari
https://github.com/kaminari/kaminari
kaminari-activerecord/lib/kaminari/activerecord.rb
Ruby
mit
8,670
master
311
# frozen_string_literal: true require "kaminari/activerecord/version" require 'active_support/lazy_load_hooks' ActiveSupport.on_load :active_record do require 'kaminari/core' require 'kaminari/activerecord/active_record_extension' ::ActiveRecord::Base.send :include, Kaminari::ActiveRecordExtension end
github
kaminari/kaminari
https://github.com/kaminari/kaminari
kaminari-activerecord/lib/kaminari/activerecord/active_record_extension.rb
Ruby
mit
8,670
master
689
# frozen_string_literal: true require 'kaminari/activerecord/active_record_model_extension' module Kaminari module ActiveRecordExtension extend ActiveSupport::Concern module ClassMethods #:nodoc: # Future subclasses will pick up the model extension def inherited(kls) #:nodoc: super ...
github
kaminari/kaminari
https://github.com/kaminari/kaminari
kaminari-activerecord/lib/kaminari/activerecord/active_record_relation_methods.rb
Ruby
mit
8,670
master
4,438
# frozen_string_literal: true module Kaminari # Active Record specific page scope methods implementations module ActiveRecordRelationMethods # Used for page_entry_info def entry_name(options = {}) default = options[:count] == 1 ? model_name.human : model_name.human.pluralize model_name.human(op...
github
kaminari/kaminari
https://github.com/kaminari/kaminari
kaminari-activerecord/lib/kaminari/activerecord/active_record_model_extension.rb
Ruby
mit
8,670
master
848
# frozen_string_literal: true require 'kaminari/activerecord/active_record_relation_methods' module Kaminari module ActiveRecordModelExtension extend ActiveSupport::Concern included do include Kaminari::ConfigurationMethods # Fetch the values at the specified page number # Model.page(5...
github
kaminari/kaminari
https://github.com/kaminari/kaminari
test/test_helper.rb
Ruby
mit
8,670
master
831
# frozen_string_literal: true $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) $LOAD_PATH.unshift(File.join(Gem.loaded_specs['kaminari-core'].gem_dir, 'test')) $LOAD_PATH.unshift(File.dirname(__FILE__)) ENV['RAILS_ENV'] ||= 'test' ENV['DB'] ||= 'sqlite3' # require logger before requiring rails, or ...
github
kaminari/kaminari
https://github.com/kaminari/kaminari
kaminari-actionview/kaminari-actionview.gemspec
Ruby
mit
8,670
master
1,277
# frozen_string_literal: true lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'kaminari/actionview/version' Gem::Specification.new do |spec| spec.name = "kaminari-actionview" spec.version = Kaminari::Actionview::VERSION spec.authors ...
github
kaminari/kaminari
https://github.com/kaminari/kaminari
kaminari-actionview/lib/kaminari/actionview.rb
Ruby
mit
8,670
master
321
# frozen_string_literal: true require "kaminari/actionview/version" require 'active_support/lazy_load_hooks' ActiveSupport.on_load :action_view do require 'kaminari/helpers/helper_methods' ::ActionView::Base.send :include, Kaminari::Helpers::HelperMethods require 'kaminari/actionview/action_view_extension' end
github
kaminari/kaminari
https://github.com/kaminari/kaminari
kaminari-actionview/lib/kaminari/actionview/action_view_extension.rb
Ruby
mit
8,670
master
623
# frozen_string_literal: true require 'action_view/log_subscriber' require 'action_view/context' require 'kaminari/helpers/paginator' module Kaminari # = Helpers module ActionViewExtension # Monkey-patching AV::LogSubscriber not to log each render_partial module LogSubscriberSilencer def render_par...
github
varvet/pundit
https://github.com/varvet/pundit
Gemfile
Ruby
mit
8,500
main
538
# frozen_string_literal: true source "https://rubygems.org" gemspec # Rails-related - for testing purposes gem "actionpack", ">= 3.0.0" # Used to test strong parameters gem "activemodel", ">= 3.0.0" # Used to test ActiveModel::Naming gem "railties", ">= 3.0.0" # Used to test generators # Testing gem "rspec", ">= 3....
github
varvet/pundit
https://github.com/varvet/pundit
Rakefile
Ruby
mit
8,500
main
358
# frozen_string_literal: true require "rubygems" require "bundler/gem_tasks" require "rspec/core/rake_task" require "yard" require "rubocop/rake_task" RuboCop::RakeTask.new desc "Run all examples" RSpec::Core::RakeTask.new(:spec) YARD::Rake::YardocTask.new do |t| t.files = ["lib/**/*.rb"] t.stats_options = ["--...
github
varvet/pundit
https://github.com/varvet/pundit
pundit.gemspec
Ruby
mit
8,500
main
1,174
# frozen_string_literal: true require_relative "lib/pundit/version" Gem::Specification.new do |gem| gem.name = "pundit" gem.version = Pundit::VERSION gem.authors = ["Jonas Nicklas", "Varvet AB"] gem.email = ["jonas.nicklas@gmail.com", "info@varvet.com"] gem.description = "Object oriented authorization for R...
github
varvet/pundit
https://github.com/varvet/pundit
lib/pundit.rb
Ruby
mit
8,500
main
2,112
# frozen_string_literal: true require "active_support" require "pundit/version" require "pundit/error" require "pundit/policy_finder" require "pundit/context" require "pundit/authorization" require "pundit/helper" require "pundit/cache_store" require "pundit/cache_store/null_store" require "pundit/cache_store/legacy_...
github
varvet/pundit
https://github.com/varvet/pundit
lib/pundit/rspec.rb
Ruby
mit
8,500
main
5,018
# frozen_string_literal: true require "pundit" # Array#to_sentence require "active_support/core_ext/array/conversions" module Pundit # Namespace for Pundit's RSpec integration. # @since v0.1.0 module RSpec # Namespace for Pundit's RSpec matchers. module Matchers extend ::RSpec::Matchers::DSL ...
github
varvet/pundit
https://github.com/varvet/pundit
lib/pundit/railtie.rb
Ruby
mit
8,500
main
565
# frozen_string_literal: true module Pundit # @since v2.5.0 class Railtie < Rails::Railtie if Rails.version.to_f >= 8.0 initializer "pundit.stats_directories" do require "rails/code_statistics" if Rails.root.join("app/policies").directory? Rails::CodeStatistics.register_directo...
github
varvet/pundit
https://github.com/varvet/pundit
lib/pundit/error.rb
Ruby
mit
8,500
main
2,424
# frozen_string_literal: true module Pundit # @api private # @since v1.0.0 # To avoid name clashes with common Error naming when mixing in Pundit, # keep it here with compact class style definition. class Error < StandardError; end # Error that will be raised when authorization has failed # @since v0.1....
github
varvet/pundit
https://github.com/varvet/pundit
lib/pundit/helper.rb
Ruby
mit
8,500
main
382
# frozen_string_literal: true module Pundit # Rails view helpers, to allow a slightly different view-specific # implementation of the methods in {Pundit::Authorization}. # # @api private # @since v1.0.0 module Helper # @see Pundit::Authorization#pundit_policy_scope # @since v1.0.0 def policy_sc...
github
varvet/pundit
https://github.com/varvet/pundit
lib/pundit/policy_finder.rb
Ruby
mit
8,500
main
3,855
# frozen_string_literal: true # String#safe_constantize, String#demodulize, String#underscore, String#camelize require "active_support/core_ext/string/inflections" module Pundit # Finds policy and scope classes for given object. # @since v0.1.0 # @api public # @example # user = User.find(params[:id]) # ...
github
varvet/pundit
https://github.com/varvet/pundit
lib/pundit/context.rb
Ruby
mit
8,500
main
6,181
# frozen_string_literal: true module Pundit # {Pundit::Context} is intended to be created once per request and user, and # it is then used to perform authorization checks throughout the request. # # @example Using Sinatra # helpers do # def current_user = ... # # def pundit # @pundit ...
github
varvet/pundit
https://github.com/varvet/pundit
lib/pundit/cache_store.rb
Ruby
mit
8,500
main
745
# frozen_string_literal: true module Pundit # Namespace for cache store implementations. # # Cache stores are used to cache policy lookups, so you get the same policy # instance for the same record. # @since v2.3.2 module CacheStore # @!group Cache Store Interface # @!method fetch(user:, record:, ...
github
varvet/pundit
https://github.com/varvet/pundit
lib/pundit/authorization.rb
Ruby
mit
8,500
main
10,405
# frozen_string_literal: true module Pundit # Pundit DSL to include in your controllers to provide authorization helpers. # # @example # class ApplicationController < ActionController::Base # include Pundit::Authorization # end # @see #pundit # @api public # @since v2.2.0 module Authorizati...
github
varvet/pundit
https://github.com/varvet/pundit
lib/pundit/cache_store/null_store.rb
Ruby
mit
8,500
main
666
# frozen_string_literal: true module Pundit module CacheStore # A cache store that does not cache anything. # # Use `NullStore.instance` to get the singleton instance, it is thread-safe. # # @see Pundit::Context#initialize # @api private # @since v2.3.2 class NullStore @instance...
github
varvet/pundit
https://github.com/varvet/pundit
lib/pundit/cache_store/legacy_store.rb
Ruby
mit
8,500
main
630
# frozen_string_literal: true module Pundit module CacheStore # A cache store that uses only the record as a cache key, and ignores the user. # # The original cache mechanism used by Pundit. # # @api private # @since v2.3.2 class LegacyStore # @since v2.3.2 def initialize(hash...
github
varvet/pundit
https://github.com/varvet/pundit
lib/generators/pundit/install/install_generator.rb
Ruby
mit
8,500
main
350
# frozen_string_literal: true module Pundit # @private module Generators # @private class InstallGenerator < ::Rails::Generators::Base source_root File.expand_path("templates", __dir__) def copy_application_policy template "application_policy.rb.tt", "app/policies/application_policy.rb...
github
varvet/pundit
https://github.com/varvet/pundit
lib/generators/pundit/policy/policy_generator.rb
Ruby
mit
8,500
main
391
# frozen_string_literal: true module Pundit # @private module Generators # @private class PolicyGenerator < ::Rails::Generators::NamedBase source_root File.expand_path("templates", __dir__) def create_policy template "policy.rb.tt", File.join("app/policies", class_path, "#{file_name}_p...
github
varvet/pundit
https://github.com/varvet/pundit
lib/generators/rspec/policy_generator.rb
Ruby
mit
8,500
main
385
# frozen_string_literal: true # @private module Rspec # @private module Generators # @private class PolicyGenerator < ::Rails::Generators::NamedBase source_root File.expand_path("templates", __dir__) def create_policy_spec template "policy_spec.rb.tt", File.join("spec/policies", class_...