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 |
|---|---|---|---|---|---|---|---|---|
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/spec/session/window/open_new_window_spec.rb | lib/capybara/spec/session/window/open_new_window_spec.rb | # frozen_string_literal: true
Capybara::SpecHelper.spec '#open_new_window', requires: [:windows] do
before do
@window = @session.current_window
@session.visit('/with_windows')
end
after do
(@session.windows - [@window]).each do |w|
@session.switch_to_window w
w.close
end
@session... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/spec/session/window/window_spec.rb | lib/capybara/spec/session/window/window_spec.rb | # frozen_string_literal: true
# NOTE: This file uses `sleep` to sync up parts of the tests. This is only implemented like this
# because of the methods being tested. In tests using Capybara this type of behavior should be implemented
# using Capybara provided assertions with builtin waiting behavior.
Capybara::SpecHe... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/spec/session/element/assert_match_selector_spec.rb | lib/capybara/spec/session/element/assert_match_selector_spec.rb | # frozen_string_literal: true
Capybara::SpecHelper.spec '#assert_matches_selector' do
before do
@session.visit('/with_html')
@element = @session.find(:css, 'span', text: '42')
end
it 'should be true if the given selector matches the element' do
expect(@element.assert_matches_selector(:css, '.number'... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/spec/session/element/match_css_spec.rb | lib/capybara/spec/session/element/match_css_spec.rb | # frozen_string_literal: true
Capybara::SpecHelper.spec '#match_css?' do
before do
@session.visit('/with_html')
@element = @session.find(:css, 'span', text: '42')
end
it 'should be true if the given selector matches the element' do
expect(@element).to match_css('span')
expect(@element).to match_... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/spec/session/element/matches_selector_spec.rb | lib/capybara/spec/session/element/matches_selector_spec.rb | # frozen_string_literal: true
Capybara::SpecHelper.spec '#match_selector?' do
let(:element) { @session.find(:xpath, '//span', text: '42') }
before do
@session.visit('/with_html')
end
it 'should be true if the element matches the given selector' do
expect(element).to match_selector(:xpath, '//span')
... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/spec/session/element/match_xpath_spec.rb | lib/capybara/spec/session/element/match_xpath_spec.rb | # frozen_string_literal: true
Capybara::SpecHelper.spec '#match_xpath?' do
before do
@session.visit('/with_html')
@element = @session.find(:css, 'span.number')
end
it 'should be true if the given selector is on the page' do
expect(@element).to match_xpath('//span')
expect(@element).to match_xpat... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/spec/session/frame/within_frame_spec.rb | lib/capybara/spec/session/frame/within_frame_spec.rb | # frozen_string_literal: true
Capybara::SpecHelper.spec '#within_frame', requires: [:frames] do
before do
@session.visit('/within_frames')
end
it 'should find the div in frameOne' do
@session.within_frame('frameOne') do
expect(@session.find("//*[@id='divInFrameOne']").text).to eql 'This is the tex... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/spec/session/frame/frame_url_spec.rb | lib/capybara/spec/session/frame/frame_url_spec.rb | # frozen_string_literal: true
Capybara::SpecHelper.spec '#frame_url', requires: [:frames] do
before do
@session.visit('/within_frames')
end
it 'should return the url in a frame' do
@session.within_frame('frameOne') do
expect(@session.driver.frame_url).to end_with '/frame_one'
end
end
it '... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/spec/session/frame/frame_title_spec.rb | lib/capybara/spec/session/frame/frame_title_spec.rb | # frozen_string_literal: true
Capybara::SpecHelper.spec '#frame_title', requires: [:frames] do
before do
@session.visit('/within_frames')
end
it 'should return the title in a frame' do
@session.within_frame('frameOne') do
expect(@session.driver.frame_title).to eq 'This is the title of frame one'
... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/spec/session/frame/switch_to_frame_spec.rb | lib/capybara/spec/session/frame/switch_to_frame_spec.rb | # frozen_string_literal: true
Capybara::SpecHelper.spec '#switch_to_frame', requires: [:frames] do
before do
@session.visit('/within_frames')
end
after do
# Ensure we clean up after the frame changes
@session.switch_to_frame(:top)
end
it 'should find the div in frameOne' do
frame = @session... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/server/animation_disabler.rb | lib/capybara/server/animation_disabler.rb | # frozen_string_literal: true
module Capybara
class Server
class AnimationDisabler
def self.selector_for(css_or_bool)
case css_or_bool
when String
css_or_bool
when true
'*'
else
raise CapybaraError, 'Capybara.disable_animation supports either a ... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/server/middleware.rb | lib/capybara/server/middleware.rb | # frozen_string_literal: true
module Capybara
class Server
class Middleware
class Counter
def initialize
@value = []
@mutex = Mutex.new
end
def increment(uri)
@mutex.synchronize { @value.push(uri) }
end
def decrement(uri)
@mu... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/server/checker.rb | lib/capybara/server/checker.rb | # frozen_string_literal: true
module Capybara
class Server
class Checker
TRY_HTTPS_ERRORS = [EOFError, Net::ReadTimeout, Errno::ECONNRESET].freeze
def initialize(host, port)
@host, @port = host, port
@ssl = false
end
def request(&block)
ssl? ? https_request(&bloc... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/driver/node.rb | lib/capybara/driver/node.rb | # frozen_string_literal: true
module Capybara
module Driver
class Node
attr_reader :driver, :native, :initial_cache
def initialize(driver, native, initial_cache = {})
@driver = driver
@native = native
@initial_cache = initial_cache
end
def all_text
raise ... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/driver/base.rb | lib/capybara/driver/base.rb | # frozen_string_literal: true
class Capybara::Driver::Base
attr_writer :session
def current_url
raise NotImplementedError
end
def visit(path)
raise NotImplementedError
end
def refresh
raise NotImplementedError
end
def find_xpath(query, **options)
raise NotImplementedError
end
d... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/rack_test/errors.rb | lib/capybara/rack_test/errors.rb | # frozen_string_literal: true
module Capybara::RackTest::Errors
class StaleElementReferenceError < StandardError
end
end
| ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/rack_test/driver.rb | lib/capybara/rack_test/driver.rb | # frozen_string_literal: true
require 'rack/test'
require 'rack/utils'
require 'mini_mime'
require 'nokogiri'
class Capybara::RackTest::Driver < Capybara::Driver::Base
DEFAULT_OPTIONS = {
respect_data_method: false,
follow_redirects: true,
redirect_limit: 5
}.freeze
attr_reader :app, :options
def... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/rack_test/browser.rb | lib/capybara/rack_test/browser.rb | # frozen_string_literal: true
class Capybara::RackTest::Browser
include ::Rack::Test::Methods
attr_reader :driver
attr_accessor :current_host
def initialize(driver)
@driver = driver
@current_fragment = nil
end
def app
driver.app
end
def options
driver.options
end
def visit(path... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/rack_test/form.rb | lib/capybara/rack_test/form.rb | # frozen_string_literal: true
class Capybara::RackTest::Form < Capybara::RackTest::Node
# This only needs to inherit from Rack::Test::UploadedFile because Rack::Test checks for
# the class specifically when determining whether to construct the request as multipart.
# That check should be based solely on the form... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/rack_test/node.rb | lib/capybara/rack_test/node.rb | # frozen_string_literal: true
require 'capybara/rack_test/errors'
require 'capybara/node/whitespace_normalizer'
class Capybara::RackTest::Node < Capybara::Driver::Node
include Capybara::Node::WhitespaceNormalizer
BLOCK_ELEMENTS = %w[p h1 h2 h3 h4 h5 h6 ol ul pre address blockquote dl div fieldset form hr noscrip... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/rack_test/css_handlers.rb | lib/capybara/rack_test/css_handlers.rb | # frozen_string_literal: true
class Capybara::RackTest::CSSHandlers < BasicObject
include ::Kernel
def disabled(list)
list.find_all { |node| node.has_attribute? 'disabled' }
end
def enabled(list)
list.find_all { |node| !node.has_attribute? 'disabled' }
end
end
| ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
javan/whenever | https://github.com/javan/whenever/blob/19daf02f970272ef8ce165cac8a58a7656d77b8a/test/test_case.rb | test/test_case.rb | module Whenever
require 'minitest/autorun'
begin
# 2.0.0
class TestCase < Minitest::Test; end
rescue NameError
# 1.9.3
class TestCase < Minitest::Unit::TestCase; end
end
class TestCase
class << self
def setup(&block)
define_method(:setup) do
super()
inst... | ruby | MIT | 19daf02f970272ef8ce165cac8a58a7656d77b8a | 2026-01-04T15:38:49.356492Z | false |
javan/whenever | https://github.com/javan/whenever/blob/19daf02f970272ef8ce165cac8a58a7656d77b8a/test/test_helper.rb | test/test_helper.rb | require 'whenever'
require 'test_case'
require 'mocha/minitest'
begin
require 'active_support/all'
rescue LoadError
end
module Whenever::TestHelpers
protected
def new_job(options={})
Whenever::Job.new(options)
end
def parse_time(time = nil, task = nil, at = nil, options = {})
Whenever::Out... | ruby | MIT | 19daf02f970272ef8ce165cac8a58a7656d77b8a | 2026-01-04T15:38:49.356492Z | false |
javan/whenever | https://github.com/javan/whenever/blob/19daf02f970272ef8ce165cac8a58a7656d77b8a/test/unit/executable_test.rb | test/unit/executable_test.rb | require 'test_helper'
describe 'Executable' do
describe 'bin/wheneverize' do
describe 'ARGV is not empty' do
describe 'file does not exist' do
file = '/tmp/this_does_not_exist'
it 'prints STDERR' do
out, err = capture_subprocess_io do
system('wheneverize', file)
... | ruby | MIT | 19daf02f970272ef8ce165cac8a58a7656d77b8a | 2026-01-04T15:38:49.356492Z | false |
javan/whenever | https://github.com/javan/whenever/blob/19daf02f970272ef8ce165cac8a58a7656d77b8a/test/unit/cron_test.rb | test/unit/cron_test.rb | require 'test_helper'
class CronTest < Whenever::TestCase
should "raise if less than 1 minute" do
assert_raises ArgumentError do
parse_time(Whenever.seconds(59, :seconds))
end
assert_raises ArgumentError do
parse_time(Whenever.seconds(0, :minutes))
end
end
# For sanity, do some test... | ruby | MIT | 19daf02f970272ef8ce165cac8a58a7656d77b8a | 2026-01-04T15:38:49.356492Z | false |
javan/whenever | https://github.com/javan/whenever/blob/19daf02f970272ef8ce165cac8a58a7656d77b8a/test/unit/job_test.rb | test/unit/job_test.rb | require 'test_helper'
class JobTest < Whenever::TestCase
should "return the :at set when #at is called" do
assert_equal 'foo', new_job(:at => 'foo').at
end
should "return the :roles set when #roles is called" do
assert_equal ['foo', 'bar'], new_job(:roles => ['foo', 'bar']).roles
end
should "return... | ruby | MIT | 19daf02f970272ef8ce165cac8a58a7656d77b8a | 2026-01-04T15:38:49.356492Z | false |
javan/whenever | https://github.com/javan/whenever/blob/19daf02f970272ef8ce165cac8a58a7656d77b8a/test/unit/capistrano_support_test.rb | test/unit/capistrano_support_test.rb | require 'test_helper'
require 'whenever/capistrano/v2/support'
class CapistranoSupportTestSubject
include Whenever::CapistranoSupport
end
class CapistranoTestCase < Whenever::TestCase
setup do
@capistrano = CapistranoSupportTestSubject.new
configuration = mock()
configuration.stubs(:load).yields(@capi... | ruby | MIT | 19daf02f970272ef8ce165cac8a58a7656d77b8a | 2026-01-04T15:38:49.356492Z | false |
javan/whenever | https://github.com/javan/whenever/blob/19daf02f970272ef8ce165cac8a58a7656d77b8a/test/functional/output_default_defined_jobs_test.rb | test/functional/output_default_defined_jobs_test.rb | require 'test_helper'
class OutputDefaultDefinedJobsTest < Whenever::TestCase
# command
test "A plain command with the job template set to nil" do
output = Whenever.cron \
<<-file
set :job_template, nil
every 2.hours do
command "blahblah"
end
file
assert_match(/^.+ .+ .... | ruby | MIT | 19daf02f970272ef8ce165cac8a58a7656d77b8a | 2026-01-04T15:38:49.356492Z | false |
javan/whenever | https://github.com/javan/whenever/blob/19daf02f970272ef8ce165cac8a58a7656d77b8a/test/functional/command_line_test.rb | test/functional/command_line_test.rb | require 'test_helper'
class CommandLineWriteTest < Whenever::TestCase
setup do
Time.stubs(:now).returns(Time.new(2017, 2, 24, 16, 21, 30, '+01:00'))
File.expects(:exist?).with('config/schedule.rb').returns(true)
@command = Whenever::CommandLine.new(:write => true, :identifier => 'My identifier')
@tas... | ruby | MIT | 19daf02f970272ef8ce165cac8a58a7656d77b8a | 2026-01-04T15:38:49.356492Z | false |
javan/whenever | https://github.com/javan/whenever/blob/19daf02f970272ef8ce165cac8a58a7656d77b8a/test/functional/output_at_test.rb | test/functional/output_at_test.rb | require 'test_helper'
class OutputAtTest < Whenever::TestCase
test "weekday at a (single) given time" do
output = Whenever.cron \
<<-file
set :job_template, nil
every "weekday", :at => '5:02am' do
command "blahblah"
end
file
assert_match '2 5 * * 1-5 blahblah', output
end... | ruby | MIT | 19daf02f970272ef8ce165cac8a58a7656d77b8a | 2026-01-04T15:38:49.356492Z | false |
javan/whenever | https://github.com/javan/whenever/blob/19daf02f970272ef8ce165cac8a58a7656d77b8a/test/functional/output_defined_job_test.rb | test/functional/output_defined_job_test.rb | require 'test_helper'
class OutputDefinedJobTest < Whenever::TestCase
test "defined job with a :task" do
output = Whenever.cron \
<<-file
set :job_template, nil
job_type :some_job, "before :task after"
every 2.hours do
some_job "during"
end
file
assert_match(/^.+ .+ .... | ruby | MIT | 19daf02f970272ef8ce165cac8a58a7656d77b8a | 2026-01-04T15:38:49.356492Z | false |
javan/whenever | https://github.com/javan/whenever/blob/19daf02f970272ef8ce165cac8a58a7656d77b8a/test/functional/output_jobs_for_roles_test.rb | test/functional/output_jobs_for_roles_test.rb | require 'test_helper'
class OutputJobsForRolesTest < Whenever::TestCase
test "one role requested and specified on the job" do
output = Whenever.cron :roles => [:role1], :string => \
<<-file
every 2.hours, :roles => [:role1] do
command "blahblah"
end
file
assert_equal two_hours + ... | ruby | MIT | 19daf02f970272ef8ce165cac8a58a7656d77b8a | 2026-01-04T15:38:49.356492Z | false |
javan/whenever | https://github.com/javan/whenever/blob/19daf02f970272ef8ce165cac8a58a7656d77b8a/test/functional/output_env_test.rb | test/functional/output_env_test.rb | require 'test_helper'
class OutputEnvTest < Whenever::TestCase
setup do
@output = Whenever.cron \
<<-file
env :MYVAR, 'blah'
env 'MAILTO', "someone@example.com"
env :BLANKVAR, ''
env :NILVAR, nil
file
end
should "output MYVAR environment variable" do
assert_match "MYVAR=b... | ruby | MIT | 19daf02f970272ef8ce165cac8a58a7656d77b8a | 2026-01-04T15:38:49.356492Z | false |
javan/whenever | https://github.com/javan/whenever/blob/19daf02f970272ef8ce165cac8a58a7656d77b8a/test/functional/output_redirection_test.rb | test/functional/output_redirection_test.rb | require 'test_helper'
class OutputRedirectionTest < Whenever::TestCase
test "command when the output is set to nil" do
output = Whenever.cron \
<<-file
set :job_template, nil
set :output, nil
every 2.hours do
command "blahblah"
end
file
assert_match(/^.+ .+ .+ .+ blah... | ruby | MIT | 19daf02f970272ef8ce165cac8a58a7656d77b8a | 2026-01-04T15:38:49.356492Z | false |
javan/whenever | https://github.com/javan/whenever/blob/19daf02f970272ef8ce165cac8a58a7656d77b8a/test/functional/output_jobs_with_mailto_test.rb | test/functional/output_jobs_with_mailto_test.rb | require 'test_helper'
class OutputJobsWithMailtoTest < Whenever::TestCase
test "defined job with a mailto argument" do
output = Whenever.cron \
<<-file
every 2.hours do
command "blahblah", mailto: 'someone@example.com'
end
file
output_without_empty_line = lines_without_empty_line... | ruby | MIT | 19daf02f970272ef8ce165cac8a58a7656d77b8a | 2026-01-04T15:38:49.356492Z | false |
javan/whenever | https://github.com/javan/whenever/blob/19daf02f970272ef8ce165cac8a58a7656d77b8a/lib/whenever.rb | lib/whenever.rb | require "whenever/version"
require 'whenever/numeric'
require 'whenever/numeric_seconds'
require 'whenever/job_list'
require 'whenever/job'
require 'whenever/command_line'
require 'whenever/cron'
require 'whenever/output_redirection'
require 'whenever/os'
module Whenever
def self.cron(options)
Whenever::JobList.... | ruby | MIT | 19daf02f970272ef8ce165cac8a58a7656d77b8a | 2026-01-04T15:38:49.356492Z | false |
javan/whenever | https://github.com/javan/whenever/blob/19daf02f970272ef8ce165cac8a58a7656d77b8a/lib/whenever/cron.rb | lib/whenever/cron.rb | require 'chronic'
module Whenever
module Output
class Cron
DAYS = %w(sun mon tue wed thu fri sat)
MONTHS = %w(jan feb mar apr may jun jul aug sep oct nov dec)
KEYWORDS = [:reboot, :yearly, :annually, :monthly, :weekly, :daily, :midnight, :hourly]
REGEX = /^(@(#{KEYWORDS.join '|'})|((\*?[\... | ruby | MIT | 19daf02f970272ef8ce165cac8a58a7656d77b8a | 2026-01-04T15:38:49.356492Z | false |
javan/whenever | https://github.com/javan/whenever/blob/19daf02f970272ef8ce165cac8a58a7656d77b8a/lib/whenever/version.rb | lib/whenever/version.rb | module Whenever
VERSION = '1.1.1'
end
| ruby | MIT | 19daf02f970272ef8ce165cac8a58a7656d77b8a | 2026-01-04T15:38:49.356492Z | false |
javan/whenever | https://github.com/javan/whenever/blob/19daf02f970272ef8ce165cac8a58a7656d77b8a/lib/whenever/setup.rb | lib/whenever/setup.rb | # Environment variable defaults to RAILS_ENV
set :environment_variable, "RAILS_ENV"
# Environment defaults to the value of RAILS_ENV in the current environment if
# it's set or production otherwise
set :environment, ENV.fetch("RAILS_ENV", "production")
# Path defaults to the directory `whenever` was run from
set :path,... | ruby | MIT | 19daf02f970272ef8ce165cac8a58a7656d77b8a | 2026-01-04T15:38:49.356492Z | false |
javan/whenever | https://github.com/javan/whenever/blob/19daf02f970272ef8ce165cac8a58a7656d77b8a/lib/whenever/capistrano.rb | lib/whenever/capistrano.rb | require 'capistrano/version'
if defined?(Capistrano::VERSION) && Gem::Version.new(Capistrano::VERSION).release >= Gem::Version.new('3.0.0')
load File.expand_path("../capistrano/v3/tasks/whenever.rake", __FILE__)
else
require 'whenever/capistrano/v2/hooks'
end
| ruby | MIT | 19daf02f970272ef8ce165cac8a58a7656d77b8a | 2026-01-04T15:38:49.356492Z | false |
javan/whenever | https://github.com/javan/whenever/blob/19daf02f970272ef8ce165cac8a58a7656d77b8a/lib/whenever/numeric_seconds.rb | lib/whenever/numeric_seconds.rb | module Whenever
class NumericSeconds
attr_reader :number
def self.seconds(number, units)
new(number).send(units)
end
def initialize(number)
@number = number.to_i
end
def seconds
number
end
alias :second :seconds
def minutes
number * 60
end
alias ... | ruby | MIT | 19daf02f970272ef8ce165cac8a58a7656d77b8a | 2026-01-04T15:38:49.356492Z | false |
javan/whenever | https://github.com/javan/whenever/blob/19daf02f970272ef8ce165cac8a58a7656d77b8a/lib/whenever/os.rb | lib/whenever/os.rb | module Whenever
module OS
def self.solaris?
(/solaris/ =~ RUBY_PLATFORM)
end
end
end
| ruby | MIT | 19daf02f970272ef8ce165cac8a58a7656d77b8a | 2026-01-04T15:38:49.356492Z | false |
javan/whenever | https://github.com/javan/whenever/blob/19daf02f970272ef8ce165cac8a58a7656d77b8a/lib/whenever/output_redirection.rb | lib/whenever/output_redirection.rb | module Whenever
module Output
class Redirection
def initialize(output)
@output = output
end
def to_s
return '' unless defined?(@output)
case @output
when String then redirect_from_string
when Hash then redirect_from_hash
when Nil... | ruby | MIT | 19daf02f970272ef8ce165cac8a58a7656d77b8a | 2026-01-04T15:38:49.356492Z | false |
javan/whenever | https://github.com/javan/whenever/blob/19daf02f970272ef8ce165cac8a58a7656d77b8a/lib/whenever/command_line.rb | lib/whenever/command_line.rb | require 'fileutils'
module Whenever
class CommandLine
def self.execute(options={})
new(options).run
end
def initialize(options={})
@options = options
@options[:crontab_command] ||= 'crontab'
@options[:file] ||= 'config/schedule.rb'
@options[:cut] ||=... | ruby | MIT | 19daf02f970272ef8ce165cac8a58a7656d77b8a | 2026-01-04T15:38:49.356492Z | false |
javan/whenever | https://github.com/javan/whenever/blob/19daf02f970272ef8ce165cac8a58a7656d77b8a/lib/whenever/job_list.rb | lib/whenever/job_list.rb | module Whenever
class JobList
attr_reader :roles
def initialize(options)
@jobs, @env, @set_variables, @pre_set_variables = {}, {}, {}, {}
if options.is_a? String
options = { :string => options }
end
pre_set(options[:set])
@roles = options[:roles] || []
setup_fi... | ruby | MIT | 19daf02f970272ef8ce165cac8a58a7656d77b8a | 2026-01-04T15:38:49.356492Z | false |
javan/whenever | https://github.com/javan/whenever/blob/19daf02f970272ef8ce165cac8a58a7656d77b8a/lib/whenever/job.rb | lib/whenever/job.rb | require 'shellwords'
module Whenever
class Job
attr_reader :at, :roles, :mailto
def initialize(options = {})
@options = options
@at = options.delete(:at)
@template = options.delete(:template)
@mailto = op... | ruby | MIT | 19daf02f970272ef8ce165cac8a58a7656d77b8a | 2026-01-04T15:38:49.356492Z | false |
javan/whenever | https://github.com/javan/whenever/blob/19daf02f970272ef8ce165cac8a58a7656d77b8a/lib/whenever/numeric.rb | lib/whenever/numeric.rb | Numeric.class_eval do
def respond_to?(method, include_private = false)
super || Whenever::NumericSeconds.public_method_defined?(method)
end
def method_missing(method, *args, &block)
if Whenever::NumericSeconds.public_method_defined?(method)
Whenever::NumericSeconds.new(self).send(method)
else
... | ruby | MIT | 19daf02f970272ef8ce165cac8a58a7656d77b8a | 2026-01-04T15:38:49.356492Z | false |
javan/whenever | https://github.com/javan/whenever/blob/19daf02f970272ef8ce165cac8a58a7656d77b8a/lib/whenever/capistrano/v2/hooks.rb | lib/whenever/capistrano/v2/hooks.rb | require "whenever/capistrano/v2/recipes"
Capistrano::Configuration.instance(:must_exist).load do
# Write the new cron jobs near the end.
before "deploy:finalize_update", "whenever:update_crontab"
# If anything goes wrong, undo.
after "deploy:rollback", "whenever:update_crontab"
end
| ruby | MIT | 19daf02f970272ef8ce165cac8a58a7656d77b8a | 2026-01-04T15:38:49.356492Z | false |
javan/whenever | https://github.com/javan/whenever/blob/19daf02f970272ef8ce165cac8a58a7656d77b8a/lib/whenever/capistrano/v2/recipes.rb | lib/whenever/capistrano/v2/recipes.rb | require 'whenever/capistrano/v2/support'
Capistrano::Configuration.instance(:must_exist).load do
Whenever::CapistranoSupport.load_into(self)
_cset(:whenever_roles) { :db }
_cset(:whenever_options) { {:roles => fetch(:whenever_roles)} }
_cset(:whenever_command) { "whenever" }
_cset(:whenever... | ruby | MIT | 19daf02f970272ef8ce165cac8a58a7656d77b8a | 2026-01-04T15:38:49.356492Z | false |
javan/whenever | https://github.com/javan/whenever/blob/19daf02f970272ef8ce165cac8a58a7656d77b8a/lib/whenever/capistrano/v2/support.rb | lib/whenever/capistrano/v2/support.rb | module Whenever
module CapistranoSupport
def self.load_into(capistrano_configuration)
capistrano_configuration.load do
def whenever_options
fetch(:whenever_options)
end
def whenever_roles
Array(whenever_options[:roles])
end
def whenever_servers
... | ruby | MIT | 19daf02f970272ef8ce165cac8a58a7656d77b8a | 2026-01-04T15:38:49.356492Z | false |
ankane/pghero | https://github.com/ankane/pghero/blob/c11401560bdae3477a531f799168355d45e789aa/app/helpers/pg_hero/home_helper.rb | app/helpers/pg_hero/home_helper.rb | 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... | ruby | MIT | c11401560bdae3477a531f799168355d45e789aa | 2026-01-04T15:38:52.602437Z | false |
ankane/pghero | https://github.com/ankane/pghero/blob/c11401560bdae3477a531f799168355d45e789aa/app/controllers/pg_hero/home_controller.rb | app/controllers/pg_hero/home_controller.rb | 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... | ruby | MIT | c11401560bdae3477a531f799168355d45e789aa | 2026-01-04T15:38:52.602437Z | false |
ankane/pghero | https://github.com/ankane/pghero/blob/c11401560bdae3477a531f799168355d45e789aa/test/query_stats_test.rb | test/query_stats_test.rb | 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... | ruby | MIT | c11401560bdae3477a531f799168355d45e789aa | 2026-01-04T15:38:52.602437Z | false |
ankane/pghero | https://github.com/ankane/pghero/blob/c11401560bdae3477a531f799168355d45e789aa/test/maintenance_test.rb | test/maintenance_test.rb | 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
... | ruby | MIT | c11401560bdae3477a531f799168355d45e789aa | 2026-01-04T15:38:52.602437Z | false |
ankane/pghero | https://github.com/ankane/pghero/blob/c11401560bdae3477a531f799168355d45e789aa/test/tables_test.rb | test/tables_test.rb | 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... | ruby | MIT | c11401560bdae3477a531f799168355d45e789aa | 2026-01-04T15:38:52.602437Z | false |
ankane/pghero | https://github.com/ankane/pghero/blob/c11401560bdae3477a531f799168355d45e789aa/test/best_index_test.rb | test/best_index_test.rb | 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")
... | ruby | MIT | c11401560bdae3477a531f799168355d45e789aa | 2026-01-04T15:38:52.602437Z | false |
ankane/pghero | https://github.com/ankane/pghero/blob/c11401560bdae3477a531f799168355d45e789aa/test/queries_test.rb | test/queries_test.rb | 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... | ruby | MIT | c11401560bdae3477a531f799168355d45e789aa | 2026-01-04T15:38:52.602437Z | false |
ankane/pghero | https://github.com/ankane/pghero/blob/c11401560bdae3477a531f799168355d45e789aa/test/query_stats_generator_test.rb | test/query_stats_generator_test.rb | 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... | ruby | MIT | c11401560bdae3477a531f799168355d45e789aa | 2026-01-04T15:38:52.602437Z | false |
ankane/pghero | https://github.com/ankane/pghero/blob/c11401560bdae3477a531f799168355d45e789aa/test/space_test.rb | test/space_test.rb | 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 {... | ruby | MIT | c11401560bdae3477a531f799168355d45e789aa | 2026-01-04T15:38:52.602437Z | false |
ankane/pghero | https://github.com/ankane/pghero/blob/c11401560bdae3477a531f799168355d45e789aa/test/replication_test.rb | test/replication_test.rb | 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... | ruby | MIT | c11401560bdae3477a531f799168355d45e789aa | 2026-01-04T15:38:52.602437Z | false |
ankane/pghero | https://github.com/ankane/pghero/blob/c11401560bdae3477a531f799168355d45e789aa/test/database_test.rb | test/database_test.rb | require_relative "test_helper"
class DatabaseTest < Minitest::Test
def test_id
assert_equal "primary", database.id
end
def test_name
assert_equal "Primary", database.name
end
end
| ruby | MIT | c11401560bdae3477a531f799168355d45e789aa | 2026-01-04T15:38:52.602437Z | false |
ankane/pghero | https://github.com/ankane/pghero/blob/c11401560bdae3477a531f799168355d45e789aa/test/basic_test.rb | test/basic_test.rb | 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_... | ruby | MIT | c11401560bdae3477a531f799168355d45e789aa | 2026-01-04T15:38:52.602437Z | false |
ankane/pghero | https://github.com/ankane/pghero/blob/c11401560bdae3477a531f799168355d45e789aa/test/indexes_test.rb | test/indexes_test.rb | 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... | ruby | MIT | c11401560bdae3477a531f799168355d45e789aa | 2026-01-04T15:38:52.602437Z | false |
ankane/pghero | https://github.com/ankane/pghero/blob/c11401560bdae3477a531f799168355d45e789aa/test/explain_test.rb | test/explain_test.rb | 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... | ruby | MIT | c11401560bdae3477a531f799168355d45e789aa | 2026-01-04T15:38:52.602437Z | false |
ankane/pghero | https://github.com/ankane/pghero/blob/c11401560bdae3477a531f799168355d45e789aa/test/controller_test.rb | test/controller_test.rb | 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... | ruby | MIT | c11401560bdae3477a531f799168355d45e789aa | 2026-01-04T15:38:52.602437Z | false |
ankane/pghero | https://github.com/ankane/pghero/blob/c11401560bdae3477a531f799168355d45e789aa/test/sequences_test.rb | test/sequences_test.rb | 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... | ruby | MIT | c11401560bdae3477a531f799168355d45e789aa | 2026-01-04T15:38:52.602437Z | false |
ankane/pghero | https://github.com/ankane/pghero/blob/c11401560bdae3477a531f799168355d45e789aa/test/test_helper.rb | test/test_helper.rb | 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... | ruby | MIT | c11401560bdae3477a531f799168355d45e789aa | 2026-01-04T15:38:52.602437Z | false |
ankane/pghero | https://github.com/ankane/pghero/blob/c11401560bdae3477a531f799168355d45e789aa/test/space_stats_generator_test.rb | test/space_stats_generator_test.rb | 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... | ruby | MIT | c11401560bdae3477a531f799168355d45e789aa | 2026-01-04T15:38:52.602437Z | false |
ankane/pghero | https://github.com/ankane/pghero/blob/c11401560bdae3477a531f799168355d45e789aa/test/system_test.rb | test/system_test.rb | 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
| ruby | MIT | c11401560bdae3477a531f799168355d45e789aa | 2026-01-04T15:38:52.602437Z | false |
ankane/pghero | https://github.com/ankane/pghero/blob/c11401560bdae3477a531f799168355d45e789aa/test/connections_test.rb | test/connections_test.rb | 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
... | ruby | MIT | c11401560bdae3477a531f799168355d45e789aa | 2026-01-04T15:38:52.602437Z | false |
ankane/pghero | https://github.com/ankane/pghero/blob/c11401560bdae3477a531f799168355d45e789aa/test/config_generator_test.rb | test/config_generator_test.rb | 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... | ruby | MIT | c11401560bdae3477a531f799168355d45e789aa | 2026-01-04T15:38:52.602437Z | false |
ankane/pghero | https://github.com/ankane/pghero/blob/c11401560bdae3477a531f799168355d45e789aa/test/users_test.rb | test/users_test.rb | 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
| ruby | MIT | c11401560bdae3477a531f799168355d45e789aa | 2026-01-04T15:38:52.602437Z | false |
ankane/pghero | https://github.com/ankane/pghero/blob/c11401560bdae3477a531f799168355d45e789aa/test/constraints_test.rb | test/constraints_test.rb | require_relative "test_helper"
class ConstraintsTest < Minitest::Test
def test_invalid_constraints
assert_equal [], database.invalid_constraints
end
end
| ruby | MIT | c11401560bdae3477a531f799168355d45e789aa | 2026-01-04T15:38:52.602437Z | false |
ankane/pghero | https://github.com/ankane/pghero/blob/c11401560bdae3477a531f799168355d45e789aa/test/settings_test.rb | test/settings_test.rb | 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... | ruby | MIT | c11401560bdae3477a531f799168355d45e789aa | 2026-01-04T15:38:52.602437Z | false |
ankane/pghero | https://github.com/ankane/pghero/blob/c11401560bdae3477a531f799168355d45e789aa/test/module_test.rb | test/module_test.rb | 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
... | ruby | MIT | c11401560bdae3477a531f799168355d45e789aa | 2026-01-04T15:38:52.602437Z | false |
ankane/pghero | https://github.com/ankane/pghero/blob/c11401560bdae3477a531f799168355d45e789aa/test/kill_test.rb | test/kill_test.rb | 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
... | ruby | MIT | c11401560bdae3477a531f799168355d45e789aa | 2026-01-04T15:38:52.602437Z | false |
ankane/pghero | https://github.com/ankane/pghero/blob/c11401560bdae3477a531f799168355d45e789aa/test/suggested_indexes_test.rb | test/suggested_indexes_test.rb | 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... | ruby | MIT | c11401560bdae3477a531f799168355d45e789aa | 2026-01-04T15:38:52.602437Z | false |
ankane/pghero | https://github.com/ankane/pghero/blob/c11401560bdae3477a531f799168355d45e789aa/test/internal/db/schema.rb | test/internal/db/schema.rb | 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,... | ruby | MIT | c11401560bdae3477a531f799168355d45e789aa | 2026-01-04T15:38:52.602437Z | false |
ankane/pghero | https://github.com/ankane/pghero/blob/c11401560bdae3477a531f799168355d45e789aa/test/internal/config/routes.rb | test/internal/config/routes.rb | Rails.application.routes.draw do
mount PgHero::Engine, at: "/"
end
| ruby | MIT | c11401560bdae3477a531f799168355d45e789aa | 2026-01-04T15:38:52.602437Z | false |
ankane/pghero | https://github.com/ankane/pghero/blob/c11401560bdae3477a531f799168355d45e789aa/lib/pghero.rb | lib/pghero.rb | # dependencies
require "active_support"
# stdlib
require "forwardable"
# methods
require_relative "pghero/methods/basic"
require_relative "pghero/methods/connections"
require_relative "pghero/methods/constraints"
require_relative "pghero/methods/explain"
require_relative "pghero/methods/indexes"
require_relative "pgh... | ruby | MIT | c11401560bdae3477a531f799168355d45e789aa | 2026-01-04T15:38:52.602437Z | false |
ankane/pghero | https://github.com/ankane/pghero/blob/c11401560bdae3477a531f799168355d45e789aa/lib/generators/pghero/space_stats_generator.rb | lib/generators/pghero/space_stats_generator.rb | require "rails/generators"
require "rails/generators/active_record"
module Pghero
module Generators
class SpaceStatsGenerator < Rails::Generators::Base
include ActiveRecord::Generators::Migration
source_root File.join(__dir__, "templates")
def copy_migration
migration_template "space_s... | ruby | MIT | c11401560bdae3477a531f799168355d45e789aa | 2026-01-04T15:38:52.602437Z | false |
ankane/pghero | https://github.com/ankane/pghero/blob/c11401560bdae3477a531f799168355d45e789aa/lib/generators/pghero/query_stats_generator.rb | lib/generators/pghero/query_stats_generator.rb | require "rails/generators"
require "rails/generators/active_record"
module Pghero
module Generators
class QueryStatsGenerator < Rails::Generators::Base
include ActiveRecord::Generators::Migration
source_root File.join(__dir__, "templates")
def copy_migration
migration_template "query_s... | ruby | MIT | c11401560bdae3477a531f799168355d45e789aa | 2026-01-04T15:38:52.602437Z | false |
ankane/pghero | https://github.com/ankane/pghero/blob/c11401560bdae3477a531f799168355d45e789aa/lib/generators/pghero/config_generator.rb | lib/generators/pghero/config_generator.rb | require "rails/generators"
module Pghero
module Generators
class ConfigGenerator < Rails::Generators::Base
source_root File.join(__dir__, "templates")
def create_initializer
template "config.yml", "config/pghero.yml"
end
end
end
end
| ruby | MIT | c11401560bdae3477a531f799168355d45e789aa | 2026-01-04T15:38:52.602437Z | false |
ankane/pghero | https://github.com/ankane/pghero/blob/c11401560bdae3477a531f799168355d45e789aa/lib/pghero/version.rb | lib/pghero/version.rb | module PgHero
VERSION = "3.7.0"
end
| ruby | MIT | c11401560bdae3477a531f799168355d45e789aa | 2026-01-04T15:38:52.602437Z | false |
ankane/pghero | https://github.com/ankane/pghero/blob/c11401560bdae3477a531f799168355d45e789aa/lib/pghero/space_stats.rb | lib/pghero/space_stats.rb | module PgHero
class SpaceStats < Stats
self.table_name = "pghero_space_stats"
end
end
| ruby | MIT | c11401560bdae3477a531f799168355d45e789aa | 2026-01-04T15:38:52.602437Z | false |
ankane/pghero | https://github.com/ankane/pghero/blob/c11401560bdae3477a531f799168355d45e789aa/lib/pghero/stats.rb | lib/pghero/stats.rb | module PgHero
class Stats < ActiveRecord::Base
self.abstract_class = true
establish_connection PgHero.stats_database_url if PgHero.stats_database_url
end
end
| ruby | MIT | c11401560bdae3477a531f799168355d45e789aa | 2026-01-04T15:38:52.602437Z | false |
ankane/pghero | https://github.com/ankane/pghero/blob/c11401560bdae3477a531f799168355d45e789aa/lib/pghero/connection.rb | lib/pghero/connection.rb | module PgHero
class Connection < ActiveRecord::Base
self.abstract_class = true
end
end
| ruby | MIT | c11401560bdae3477a531f799168355d45e789aa | 2026-01-04T15:38:52.602437Z | false |
ankane/pghero | https://github.com/ankane/pghero/blob/c11401560bdae3477a531f799168355d45e789aa/lib/pghero/engine.rb | lib/pghero/engine.rb | module PgHero
class Engine < ::Rails::Engine
isolate_namespace PgHero
initializer "pghero", group: :all do |app|
# check if Rails api mode
if app.config.respond_to?(:assets) && defined?(Sprockets)
if Sprockets::VERSION.to_i >= 4
app.config.assets.precompile << "pghero/applicatio... | ruby | MIT | c11401560bdae3477a531f799168355d45e789aa | 2026-01-04T15:38:52.602437Z | false |
ankane/pghero | https://github.com/ankane/pghero/blob/c11401560bdae3477a531f799168355d45e789aa/lib/pghero/query_stats.rb | lib/pghero/query_stats.rb | module PgHero
class QueryStats < Stats
self.table_name = "pghero_query_stats"
end
end
| ruby | MIT | c11401560bdae3477a531f799168355d45e789aa | 2026-01-04T15:38:52.602437Z | false |
ankane/pghero | https://github.com/ankane/pghero/blob/c11401560bdae3477a531f799168355d45e789aa/lib/pghero/database.rb | lib/pghero/database.rb | module PgHero
class Database
include Methods::Basic
include Methods::Connections
include Methods::Constraints
include Methods::Explain
include Methods::Indexes
include Methods::Kill
include Methods::Maintenance
include Methods::Queries
include Methods::QueryStats
include Method... | ruby | MIT | c11401560bdae3477a531f799168355d45e789aa | 2026-01-04T15:38:52.602437Z | false |
ankane/pghero | https://github.com/ankane/pghero/blob/c11401560bdae3477a531f799168355d45e789aa/lib/pghero/methods/users.rb | lib/pghero/methods/users.rb | 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... | ruby | MIT | c11401560bdae3477a531f799168355d45e789aa | 2026-01-04T15:38:52.602437Z | false |
ankane/pghero | https://github.com/ankane/pghero/blob/c11401560bdae3477a531f799168355d45e789aa/lib/pghero/methods/maintenance.rb | lib/pghero/methods/maintenance.rb | 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... | ruby | MIT | c11401560bdae3477a531f799168355d45e789aa | 2026-01-04T15:38:52.602437Z | false |
ankane/pghero | https://github.com/ankane/pghero/blob/c11401560bdae3477a531f799168355d45e789aa/lib/pghero/methods/explain.rb | lib/pghero/methods/explain.rb | 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 *... | ruby | MIT | c11401560bdae3477a531f799168355d45e789aa | 2026-01-04T15:38:52.602437Z | false |
ankane/pghero | https://github.com/ankane/pghero/blob/c11401560bdae3477a531f799168355d45e789aa/lib/pghero/methods/constraints.rb | lib/pghero/methods/constraints.rb | 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,
... | ruby | MIT | c11401560bdae3477a531f799168355d45e789aa | 2026-01-04T15:38:52.602437Z | false |
ankane/pghero | https://github.com/ankane/pghero/blob/c11401560bdae3477a531f799168355d45e789aa/lib/pghero/methods/suggested_indexes.rb | lib/pghero/methods/suggested_indexes.rb | 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... | ruby | MIT | c11401560bdae3477a531f799168355d45e789aa | 2026-01-04T15:38:52.602437Z | false |
ankane/pghero | https://github.com/ankane/pghero/blob/c11401560bdae3477a531f799168355d45e789aa/lib/pghero/methods/sequences.rb | lib/pghero/methods/sequences.rb | module PgHero
module Methods
module Sequences
def sequences
# get columns with default values
# use pg_get_expr to get correct default value
# it's what information_schema.columns uses
# also, exclude temporary tables to prevent error
# when accessing across sessions
... | ruby | MIT | c11401560bdae3477a531f799168355d45e789aa | 2026-01-04T15:38:52.602437Z | false |
ankane/pghero | https://github.com/ankane/pghero/blob/c11401560bdae3477a531f799168355d45e789aa/lib/pghero/methods/settings.rb | lib/pghero/methods/settings.rb | module PgHero
module Methods
module Settings
def settings
names =
if server_version_num >= 100000
%i(
max_connections shared_buffers effective_cache_size maintenance_work_mem
checkpoint_completion_target wal_buffers default_statistics_target
... | ruby | MIT | c11401560bdae3477a531f799168355d45e789aa | 2026-01-04T15:38:52.602437Z | false |
ankane/pghero | https://github.com/ankane/pghero/blob/c11401560bdae3477a531f799168355d45e789aa/lib/pghero/methods/basic.rb | lib/pghero/methods/basic.rb | module PgHero
module Methods
module Basic
def ssl_used?
ssl_used = nil
with_transaction(rollback: true) do
begin
execute("CREATE EXTENSION IF NOT EXISTS sslinfo")
rescue ActiveRecord::StatementInvalid
# not superuser
end
ssl_use... | ruby | MIT | c11401560bdae3477a531f799168355d45e789aa | 2026-01-04T15:38:52.602437Z | false |
ankane/pghero | https://github.com/ankane/pghero/blob/c11401560bdae3477a531f799168355d45e789aa/lib/pghero/methods/queries.rb | lib/pghero/methods/queries.rb | module PgHero
module Methods
module Queries
def running_queries(min_duration: nil, all: false)
query = <<~SQL
SELECT
pid,
state,
application_name AS source,
age(NOW(), COALESCE(query_start, xact_start)) AS duration,
#{server_versi... | ruby | MIT | c11401560bdae3477a531f799168355d45e789aa | 2026-01-04T15:38:52.602437Z | false |
ankane/pghero | https://github.com/ankane/pghero/blob/c11401560bdae3477a531f799168355d45e789aa/lib/pghero/methods/connections.rb | lib/pghero/methods/connections.rb | 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,
... | ruby | MIT | c11401560bdae3477a531f799168355d45e789aa | 2026-01-04T15:38:52.602437Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.