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 |
|---|---|---|---|---|---|---|---|---|
puma/puma | https://github.com/puma/puma/blob/5937d8953a154d69cab13887cc361eef9d7df2a4/lib/puma/cluster_accept_loop_delay.rb | lib/puma/cluster_accept_loop_delay.rb | # frozen_string_literal: true
module Puma
# Calculate a delay value for sleeping when running in clustered mode
#
# The main reason this is a class is so it can be unit tested independently.
# This makes modification easier in the future if we can encode properties of the
# delay into a test instead of relyi... | ruby | BSD-3-Clause | 5937d8953a154d69cab13887cc361eef9d7df2a4 | 2026-01-04T15:39:19.886485Z | false |
puma/puma | https://github.com/puma/puma/blob/5937d8953a154d69cab13887cc361eef9d7df2a4/lib/puma/error_logger.rb | lib/puma/error_logger.rb | # frozen_string_literal: true
require_relative 'const'
module Puma
# The implementation of a detailed error logging.
# @version 5.0.0
#
class ErrorLogger
include Const
attr_reader :ioerr
REQUEST_FORMAT = %{"%s %s%s" - (%s)}
LOG_QUEUE = Queue.new
def initialize(ioerr, env: ENV)
@i... | ruby | BSD-3-Clause | 5937d8953a154d69cab13887cc361eef9d7df2a4 | 2026-01-04T15:39:19.886485Z | false |
puma/puma | https://github.com/puma/puma/blob/5937d8953a154d69cab13887cc361eef9d7df2a4/lib/puma/binder.rb | lib/puma/binder.rb | # frozen_string_literal: true
require 'uri'
require 'socket'
require_relative 'const'
require_relative 'util'
module Puma
if HAS_SSL
require_relative 'minissl'
require_relative 'minissl/context_builder'
end
class Binder
include Puma::Const
RACK_VERSION = [1,6].freeze
def initialize(log_... | ruby | BSD-3-Clause | 5937d8953a154d69cab13887cc361eef9d7df2a4 | 2026-01-04T15:39:19.886485Z | false |
puma/puma | https://github.com/puma/puma/blob/5937d8953a154d69cab13887cc361eef9d7df2a4/lib/puma/util.rb | lib/puma/util.rb | # frozen_string_literal: true
require 'uri/common'
module Puma
module Util
module_function
def pipe
IO.pipe
end
# Escapes and unescapes a URI escaped string with
# +encoding+. +encoding+ will be the target encoding of the string
# returned, and it defaults to UTF-8
if defined?(::... | ruby | BSD-3-Clause | 5937d8953a154d69cab13887cc361eef9d7df2a4 | 2026-01-04T15:39:19.886485Z | false |
puma/puma | https://github.com/puma/puma/blob/5937d8953a154d69cab13887cc361eef9d7df2a4/lib/puma/json_serialization.rb | lib/puma/json_serialization.rb | # frozen_string_literal: true
require 'stringio'
module Puma
# Puma deliberately avoids the use of the json gem and instead performs JSON
# serialization without any external dependencies. In a puma cluster, loading
# any gem into the puma master process means that operators cannot use a
# phased restart to u... | ruby | BSD-3-Clause | 5937d8953a154d69cab13887cc361eef9d7df2a4 | 2026-01-04T15:39:19.886485Z | false |
puma/puma | https://github.com/puma/puma/blob/5937d8953a154d69cab13887cc361eef9d7df2a4/lib/puma/minissl/context_builder.rb | lib/puma/minissl/context_builder.rb | module Puma
module MiniSSL
class ContextBuilder
def initialize(params, log_writer)
@params = params
@log_writer = log_writer
end
def context
ctx = MiniSSL::Context.new
if defined?(JRUBY_VERSION)
unless params['keystore']
log_writer.error "P... | ruby | BSD-3-Clause | 5937d8953a154d69cab13887cc361eef9d7df2a4 | 2026-01-04T15:39:19.886485Z | false |
puma/puma | https://github.com/puma/puma/blob/5937d8953a154d69cab13887cc361eef9d7df2a4/lib/puma/plugin/systemd.rb | lib/puma/plugin/systemd.rb | # frozen_string_literal: true
require_relative '../plugin'
# Puma's systemd integration allows Puma to inform systemd:
# 1. when it has successfully started
# 2. when it is starting shutdown
# 3. periodically for a liveness check with a watchdog thread
# 4. periodically set the status
Puma::Plugin.create do
def... | ruby | BSD-3-Clause | 5937d8953a154d69cab13887cc361eef9d7df2a4 | 2026-01-04T15:39:19.886485Z | false |
puma/puma | https://github.com/puma/puma/blob/5937d8953a154d69cab13887cc361eef9d7df2a4/lib/puma/plugin/tmp_restart.rb | lib/puma/plugin/tmp_restart.rb | # frozen_string_literal: true
require_relative '../plugin'
Puma::Plugin.create do
def start(launcher)
path = File.join("tmp", "restart.txt")
orig = nil
# If we can't write to the path, then just don't bother with this plugin
begin
File.write(path, "") unless File.exist?(path)
orig = Fi... | ruby | BSD-3-Clause | 5937d8953a154d69cab13887cc361eef9d7df2a4 | 2026-01-04T15:39:19.886485Z | false |
puma/puma | https://github.com/puma/puma/blob/5937d8953a154d69cab13887cc361eef9d7df2a4/lib/puma/launcher/bundle_pruner.rb | lib/puma/launcher/bundle_pruner.rb | # frozen_string_literal: true
module Puma
class Launcher
# This class is used to pickup Gemfile changes during
# application restarts.
class BundlePruner
def initialize(original_argv, extra_runtime_dependencies, log_writer)
@original_argv = Array(original_argv)
@extra_runtime_depe... | ruby | BSD-3-Clause | 5937d8953a154d69cab13887cc361eef9d7df2a4 | 2026-01-04T15:39:19.886485Z | false |
puma/puma | https://github.com/puma/puma/blob/5937d8953a154d69cab13887cc361eef9d7df2a4/lib/puma/app/status.rb | lib/puma/app/status.rb | # frozen_string_literal: true
require_relative '../json_serialization'
module Puma
module App
# Check out {#call}'s source code to see what actions this web application
# can respond to.
class Status
OK_STATUS = '{ "status": "ok" }'.freeze
READ_ONLY_COMMANDS = %w[gc-stats stats].freeze
... | ruby | BSD-3-Clause | 5937d8953a154d69cab13887cc361eef9d7df2a4 | 2026-01-04T15:39:19.886485Z | false |
puma/puma | https://github.com/puma/puma/blob/5937d8953a154d69cab13887cc361eef9d7df2a4/lib/puma/rack/urlmap.rb | lib/puma/rack/urlmap.rb | # frozen_string_literal: true
module Puma::Rack
# Rack::URLMap takes a hash mapping urls or paths to apps, and
# dispatches accordingly. Support for HTTP/1.1 host names exists if
# the URLs start with <tt>http://</tt> or <tt>https://</tt>.
#
# URLMap modifies the SCRIPT_NAME and PATH_INFO such that the part... | ruby | BSD-3-Clause | 5937d8953a154d69cab13887cc361eef9d7df2a4 | 2026-01-04T15:39:19.886485Z | false |
puma/puma | https://github.com/puma/puma/blob/5937d8953a154d69cab13887cc361eef9d7df2a4/lib/puma/rack/builder.rb | lib/puma/rack/builder.rb | # frozen_string_literal: true
module Puma
end
module Puma::Rack
class Options
def parse!(args)
options = {}
opt_parser = OptionParser.new("", 24, ' ') do |opts|
opts.banner = "Usage: rackup [ruby options] [rack options] [rackup config]"
opts.separator ""
opts.separator "Rub... | ruby | BSD-3-Clause | 5937d8953a154d69cab13887cc361eef9d7df2a4 | 2026-01-04T15:39:19.886485Z | false |
puma/puma | https://github.com/puma/puma/blob/5937d8953a154d69cab13887cc361eef9d7df2a4/lib/puma/cluster/worker_handle.rb | lib/puma/cluster/worker_handle.rb | # frozen_string_literal: true
module Puma
class Cluster < Runner
#—————————————————————— DO NOT USE — this class is for internal use only ———
# This class represents a worker process from the perspective of the puma
# master process. It contains information about the process and its health
# and it ... | ruby | BSD-3-Clause | 5937d8953a154d69cab13887cc361eef9d7df2a4 | 2026-01-04T15:39:19.886485Z | false |
puma/puma | https://github.com/puma/puma/blob/5937d8953a154d69cab13887cc361eef9d7df2a4/lib/puma/cluster/worker.rb | lib/puma/cluster/worker.rb | # frozen_string_literal: true
module Puma
class Cluster < Puma::Runner
#—————————————————————— DO NOT USE — this class is for internal use only ———
# This class is instantiated by the `Puma::Cluster` and represents a single
# worker process.
#
# At the core of this class is running an instance ... | ruby | BSD-3-Clause | 5937d8953a154d69cab13887cc361eef9d7df2a4 | 2026-01-04T15:39:19.886485Z | false |
puma/puma | https://github.com/puma/puma/blob/5937d8953a154d69cab13887cc361eef9d7df2a4/lib/rack/handler/puma.rb | lib/rack/handler/puma.rb | # frozen_string_literal: true
module Puma
# This module is used as an 'include' file in code at bottom of file. It loads
# into either `Rackup::Handler::Puma` or `Rack::Handler::Puma`.
module RackHandler
DEFAULT_OPTIONS = {
:Verbose => false,
:Silent => false
}
def config(app, options... | ruby | BSD-3-Clause | 5937d8953a154d69cab13887cc361eef9d7df2a4 | 2026-01-04T15:39:19.886485Z | false |
puma/puma | https://github.com/puma/puma/blob/5937d8953a154d69cab13887cc361eef9d7df2a4/cops/tests_puma.rb | cops/tests_puma.rb | require 'rubocop'
module RuboCop
module Cop
module Puma
class TestsMustUsePumaTest < Base
extend AutoCorrector
MSG = 'Inherit from PumaTest instead of Minitest::Test'
def_node_matcher :inherits_from_minitest_test?, <<~PATTERN
(class _ (const (const nil? :Minitest) :Test)... | ruby | BSD-3-Clause | 5937d8953a154d69cab13887cc361eef9d7df2a4 | 2026-01-04T15:39:19.886485Z | false |
skwp/dotfiles | https://github.com/skwp/dotfiles/blob/9e3425d11dcde7706fbeabc3e9c3f7a7bdc63e23/bin/marky.rb | bin/marky.rb | #!/usr/bin/env ruby
# source http://brettterpstra.com/marky-the-markdownifier-reintroductions/
require 'open-uri'
require 'net/http'
require 'iconv'
require 'optparse'
require 'fileutils'
require 'cgi'
$options = {}
# $fymdhost = "http://fym.dev"
$fymdhost = "http://heckyesmarkdown.com"
optparse = OptionParser.new ... | ruby | BSD-2-Clause | 9e3425d11dcde7706fbeabc3e9c3f7a7bdc63e23 | 2026-01-04T15:39:44.665514Z | false |
skwp/dotfiles | https://github.com/skwp/dotfiles/blob/9e3425d11dcde7706fbeabc3e9c3f7a7bdc63e23/bin/yadr/vundle.rb | bin/yadr/vundle.rb | require 'fileutils'
module Vundle
@vundles_path = File.expand_path File.join(ENV['HOME'], '.vim', '.vundles.local')
def self.add_plugin_to_vundle(plugin_repo)
return if contains_vundle? plugin_repo
vundles = vundles_from_file
last_bundle_dir = vundles.rindex{ |line| line =~ /^Bundle / }
last_bundl... | ruby | BSD-2-Clause | 9e3425d11dcde7706fbeabc3e9c3f7a7bdc63e23 | 2026-01-04T15:39:44.665514Z | false |
skwp/dotfiles | https://github.com/skwp/dotfiles/blob/9e3425d11dcde7706fbeabc3e9c3f7a7bdc63e23/bin/yadr/default_libs.rb | bin/yadr/default_libs.rb | Dir[File.join(File.dirname(__FILE__),"lib/**/lib")].each {|dir| $LOAD_PATH << dir}
require 'git-style-binary/command'
$yadr = File.join(ENV['HOME'], ".yadr")
| ruby | BSD-2-Clause | 9e3425d11dcde7706fbeabc3e9c3f7a7bdc63e23 | 2026-01-04T15:39:44.665514Z | false |
skwp/dotfiles | https://github.com/skwp/dotfiles/blob/9e3425d11dcde7706fbeabc3e9c3f7a7bdc63e23/bin/yadr/lib/trollop-1.16.2/test/test_trollop.rb | bin/yadr/lib/trollop-1.16.2/test/test_trollop.rb | ## test/test_trollop.rb -- unit tests for trollop
## Author:: William Morgan (mailto: wmorgan-trollop@masanjin.net)
## Copyright:: Copyright 2007 William Morgan
## License:: GNU GPL version 2
require 'test/unit'
require 'stringio'
require 'trollop'
module Trollop
module Test
class Trollop < ::Test::Unit::TestCa... | ruby | BSD-2-Clause | 9e3425d11dcde7706fbeabc3e9c3f7a7bdc63e23 | 2026-01-04T15:39:44.665514Z | true |
skwp/dotfiles | https://github.com/skwp/dotfiles/blob/9e3425d11dcde7706fbeabc3e9c3f7a7bdc63e23/bin/yadr/lib/trollop-1.16.2/lib/trollop.rb | bin/yadr/lib/trollop-1.16.2/lib/trollop.rb | ## lib/trollop.rb -- trollop command-line processing library
## Author:: William Morgan (mailto: wmorgan-trollop@masanjin.net)
## Copyright:: Copyright 2007 William Morgan
## License:: the same terms as ruby itself
require 'date'
module Trollop
VERSION = "1.16.2"
## Thrown by Parser in the event of a commandli... | ruby | BSD-2-Clause | 9e3425d11dcde7706fbeabc3e9c3f7a7bdc63e23 | 2026-01-04T15:39:44.665514Z | false |
skwp/dotfiles | https://github.com/skwp/dotfiles/blob/9e3425d11dcde7706fbeabc3e9c3f7a7bdc63e23/bin/yadr/lib/git-style-binaries-0.1.11/test/test_helper.rb | bin/yadr/lib/git-style-binaries-0.1.11/test/test_helper.rb | require 'rubygems'
require 'test/unit'
require 'shoulda'
begin require 'redgreen'; rescue LoadError; end
require 'open3'
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
$LOAD_PATH.unshift(File.dirname(__FILE__))
Dir[File.join(File.dirname(__FILE__), "shoulda_macros", "*.rb")].each {|f| require f}
EN... | ruby | BSD-2-Clause | 9e3425d11dcde7706fbeabc3e9c3f7a7bdc63e23 | 2026-01-04T15:39:44.665514Z | false |
skwp/dotfiles | https://github.com/skwp/dotfiles/blob/9e3425d11dcde7706fbeabc3e9c3f7a7bdc63e23/bin/yadr/lib/git-style-binaries-0.1.11/test/git_style_binary_test.rb | bin/yadr/lib/git-style-binaries-0.1.11/test/git_style_binary_test.rb | require File.dirname(__FILE__) + "/test_helper.rb"
class GitStyleBinariesTest < Test::Unit::TestCase
context "parsing basenames" do
should "accurately parse basenames" do
assert_equal "wordpress", GitStyleBinary.basename("bin/wordpress")
assert_equal "wordpress", GitStyleBinary.basename("bin/wordpres... | ruby | BSD-2-Clause | 9e3425d11dcde7706fbeabc3e9c3f7a7bdc63e23 | 2026-01-04T15:39:44.665514Z | false |
skwp/dotfiles | https://github.com/skwp/dotfiles/blob/9e3425d11dcde7706fbeabc3e9c3f7a7bdc63e23/bin/yadr/lib/git-style-binaries-0.1.11/test/running_binaries_test.rb | bin/yadr/lib/git-style-binaries-0.1.11/test/running_binaries_test.rb | require File.dirname(__FILE__) + "/test_helper.rb"
THIS_YEAR=Time.now.year # todo
class RunningBinariesTest < Test::Unit::TestCase
include RunsBinaryFixtures
context "when running primary" do
["wordpress -h", "wordpress help"].each do |format|
context "and getting help as a '#{format}'" do
setu... | ruby | BSD-2-Clause | 9e3425d11dcde7706fbeabc3e9c3f7a7bdc63e23 | 2026-01-04T15:39:44.665514Z | false |
skwp/dotfiles | https://github.com/skwp/dotfiles/blob/9e3425d11dcde7706fbeabc3e9c3f7a7bdc63e23/bin/yadr/lib/git-style-binaries-0.1.11/test/shoulda_macros/matching_stdio.rb | bin/yadr/lib/git-style-binaries-0.1.11/test/shoulda_macros/matching_stdio.rb | class Test::Unit::TestCase
def output_should_match(regexp)
assert_match regexp, @stdout + @stderr
end
alias_method :output_matches, :output_should_match
def stdout_should_match(regexp)
assert_match regexp, @stdout
end
def stderr_should_match(regexp)
assert_match regexp, @stderr
end
end
| ruby | BSD-2-Clause | 9e3425d11dcde7706fbeabc3e9c3f7a7bdc63e23 | 2026-01-04T15:39:44.665514Z | false |
skwp/dotfiles | https://github.com/skwp/dotfiles/blob/9e3425d11dcde7706fbeabc3e9c3f7a7bdc63e23/bin/yadr/lib/git-style-binaries-0.1.11/test/git-style-binary/command_test.rb | bin/yadr/lib/git-style-binaries-0.1.11/test/git-style-binary/command_test.rb | require File.dirname(__FILE__) + "/../test_helper.rb"
require 'git-style-binary/command'
class CommandTest < Test::Unit::TestCase
context "cmd" do
setup do
@c = GitStyleBinary::Command.new
end
should "be able to easily work with constraints" do
assert_equal @c.constraints, []
@c.constr... | ruby | BSD-2-Clause | 9e3425d11dcde7706fbeabc3e9c3f7a7bdc63e23 | 2026-01-04T15:39:44.665514Z | false |
skwp/dotfiles | https://github.com/skwp/dotfiles/blob/9e3425d11dcde7706fbeabc3e9c3f7a7bdc63e23/bin/yadr/lib/git-style-binaries-0.1.11/lib/git-style-binary.rb | bin/yadr/lib/git-style-binaries-0.1.11/lib/git-style-binary.rb | $:.unshift(File.dirname(__FILE__))
require 'rubygems'
# Load the vendor gems
$:.unshift(File.dirname(__FILE__) + "/../vendor/gems")
%w(trollop).each do |library|
begin
require "#{library}/lib/#{library}"
rescue LoadError
begin
require 'trollop'
rescue LoadError
puts "There was an error load... | ruby | BSD-2-Clause | 9e3425d11dcde7706fbeabc3e9c3f7a7bdc63e23 | 2026-01-04T15:39:44.665514Z | false |
skwp/dotfiles | https://github.com/skwp/dotfiles/blob/9e3425d11dcde7706fbeabc3e9c3f7a7bdc63e23/bin/yadr/lib/git-style-binaries-0.1.11/lib/ext/core.rb | bin/yadr/lib/git-style-binaries-0.1.11/lib/ext/core.rb | class Object
def returning(value)
yield(value)
value
end unless Object.respond_to?(:returning)
end
class Symbol
def to_proc
Proc.new { |*args| args.shift.__send__(self, *args) }
end
end
class IO
attr_accessor :use_color
end
| ruby | BSD-2-Clause | 9e3425d11dcde7706fbeabc3e9c3f7a7bdc63e23 | 2026-01-04T15:39:44.665514Z | false |
skwp/dotfiles | https://github.com/skwp/dotfiles/blob/9e3425d11dcde7706fbeabc3e9c3f7a7bdc63e23/bin/yadr/lib/git-style-binaries-0.1.11/lib/ext/colorize.rb | bin/yadr/lib/git-style-binaries-0.1.11/lib/ext/colorize.rb | #
# Colorize String class extension.
#
class String
#
# Version string
#
COLORIZE_VERSION = '0.5.6'
#
# Colors Hash
#
COLORS = {
:black => 0,
:red => 1,
:green => 2,
:yellow => 3,
:blue => 4,
:magenta => 5,
:cyan ... | ruby | BSD-2-Clause | 9e3425d11dcde7706fbeabc3e9c3f7a7bdc63e23 | 2026-01-04T15:39:44.665514Z | false |
skwp/dotfiles | https://github.com/skwp/dotfiles/blob/9e3425d11dcde7706fbeabc3e9c3f7a7bdc63e23/bin/yadr/lib/git-style-binaries-0.1.11/lib/git-style-binary/command.rb | bin/yadr/lib/git-style-binaries-0.1.11/lib/git-style-binary/command.rb | require 'git-style-binary'
module GitStyleBinary
def self.command(&block)
returning Command.new(:constraints => [block]) do |c|
c.name ||= (GitStyleBinary.name_of_command_being_loaded || GitStyleBinary.current_command_name)
GitStyleBinary.known_commands[c.name] = c
if !GitStyleBinary.current_c... | ruby | BSD-2-Clause | 9e3425d11dcde7706fbeabc3e9c3f7a7bdc63e23 | 2026-01-04T15:39:44.665514Z | false |
skwp/dotfiles | https://github.com/skwp/dotfiles/blob/9e3425d11dcde7706fbeabc3e9c3f7a7bdc63e23/bin/yadr/lib/git-style-binaries-0.1.11/lib/git-style-binary/autorunner.rb | bin/yadr/lib/git-style-binaries-0.1.11/lib/git-style-binary/autorunner.rb | require 'git-style-binary/parser'
module GitStyleBinary
class AutoRunner
def self.run(argv=ARGV)
r = new
r.run
end
def run
unless GitStyleBinary.run?
if !GitStyleBinary.current_command
GitStyleBinary.load_primary
end
GitStyleBinary.current_command.run
end
end
end
e... | ruby | BSD-2-Clause | 9e3425d11dcde7706fbeabc3e9c3f7a7bdc63e23 | 2026-01-04T15:39:44.665514Z | false |
skwp/dotfiles | https://github.com/skwp/dotfiles/blob/9e3425d11dcde7706fbeabc3e9c3f7a7bdc63e23/bin/yadr/lib/git-style-binaries-0.1.11/lib/git-style-binary/parser.rb | bin/yadr/lib/git-style-binaries-0.1.11/lib/git-style-binary/parser.rb | module GitStyleBinary
class Parser < Trollop::Parser
attr_reader :runs, :callbacks
attr_reader :short_desc
attr_accessor :command
def initialize *a, &b
super
@runs = []
setup_callbacks
end
def setup_callbacks
@callbacks = {}
%w(run).each do |event|
%w(before after).each do... | ruby | BSD-2-Clause | 9e3425d11dcde7706fbeabc3e9c3f7a7bdc63e23 | 2026-01-04T15:39:44.665514Z | false |
skwp/dotfiles | https://github.com/skwp/dotfiles/blob/9e3425d11dcde7706fbeabc3e9c3f7a7bdc63e23/bin/yadr/lib/git-style-binaries-0.1.11/lib/git-style-binary/helpers/pager.rb | bin/yadr/lib/git-style-binaries-0.1.11/lib/git-style-binary/helpers/pager.rb | module GitStyleBinary
module Helpers
module Pager
# by Nathan Weizenbaum - http://nex-3.com/posts/73-git-style-automatic-paging-in-ruby
def run_pager
return if RUBY_PLATFORM =~ /win32/
return unless STDOUT.tty?
STDOUT.use_color = true
read, write = IO.pipe
un... | ruby | BSD-2-Clause | 9e3425d11dcde7706fbeabc3e9c3f7a7bdc63e23 | 2026-01-04T15:39:44.665514Z | false |
skwp/dotfiles | https://github.com/skwp/dotfiles/blob/9e3425d11dcde7706fbeabc3e9c3f7a7bdc63e23/bin/yadr/lib/git-style-binaries-0.1.11/lib/git-style-binary/helpers/name_resolver.rb | bin/yadr/lib/git-style-binaries-0.1.11/lib/git-style-binary/helpers/name_resolver.rb | module GitStyleBinary
module Helpers
module NameResolver
def basename(filename=zero)
File.basename(filename).match(/(.*?)(\-|$)/).captures.first
end
alias_method :primary_name, :basename
# checks the bin directory for all files starting with +basename+ and
# returns an array of strings spe... | ruby | BSD-2-Clause | 9e3425d11dcde7706fbeabc3e9c3f7a7bdc63e23 | 2026-01-04T15:39:44.665514Z | false |
skwp/dotfiles | https://github.com/skwp/dotfiles/blob/9e3425d11dcde7706fbeabc3e9c3f7a7bdc63e23/bin/yadr/lib/git-style-binaries-0.1.11/lib/git-style-binary/commands/help.rb | bin/yadr/lib/git-style-binaries-0.1.11/lib/git-style-binary/commands/help.rb | module GitStyleBinary
module Commands
class Help
# not loving this syntax, but works for now
GitStyleBinary.command do
short_desc "get help for a specific command"
run do |command|
# this is slightly ugly b/c it has to muck around in the internals to
# get informat... | ruby | BSD-2-Clause | 9e3425d11dcde7706fbeabc3e9c3f7a7bdc63e23 | 2026-01-04T15:39:44.665514Z | false |
BetterErrors/better_errors | https://github.com/BetterErrors/better_errors/blob/fde3b7025db17b5cda13fcf8d08dfb3f76e189f6/spec/without_binding_of_caller.rb | spec/without_binding_of_caller.rb | module Kernel
alias_method :require_with_binding_of_caller, :require
def require(feature)
raise LoadError if feature == "binding_of_caller"
require_with_binding_of_caller(feature)
end
end
| ruby | MIT | fde3b7025db17b5cda13fcf8d08dfb3f76e189f6 | 2026-01-04T15:39:58.699166Z | false |
BetterErrors/better_errors | https://github.com/BetterErrors/better_errors/blob/fde3b7025db17b5cda13fcf8d08dfb3f76e189f6/spec/spec_helper.rb | spec/spec_helper.rb | $: << File.expand_path("../../lib", __FILE__)
ENV["EDITOR"] = nil
ENV["BETTER_ERRORS"] = nil
require 'simplecov'
require 'simplecov-lcov'
# Fix incompatibility of simplecov-lcov with older versions of simplecov that are not expresses in its gemspec.
# https://github.com/fortissimo1997/simplecov-lcov/pull/25
if !Simp... | ruby | MIT | fde3b7025db17b5cda13fcf8d08dfb3f76e189f6 | 2026-01-04T15:39:58.699166Z | false |
BetterErrors/better_errors | https://github.com/BetterErrors/better_errors/blob/fde3b7025db17b5cda13fcf8d08dfb3f76e189f6/spec/better_errors_spec.rb | spec/better_errors_spec.rb | require "spec_helper"
RSpec.describe BetterErrors do
describe ".editor" do
context "when set to a specific value" do
before do
allow(BetterErrors::Editor).to receive(:editor_from_symbol).and_return(:editor_from_symbol)
allow(BetterErrors::Editor).to receive(:for_formatting_string).and_retur... | ruby | MIT | fde3b7025db17b5cda13fcf8d08dfb3f76e189f6 | 2026-01-04T15:39:58.699166Z | false |
BetterErrors/better_errors | https://github.com/BetterErrors/better_errors/blob/fde3b7025db17b5cda13fcf8d08dfb3f76e189f6/spec/better_errors/middleware_spec.rb | spec/better_errors/middleware_spec.rb | require "spec_helper"
module BetterErrors
describe Middleware do
let(:app) { Middleware.new(->env { ":)" }) }
let(:exception) { RuntimeError.new("oh no :(") }
let(:status) { response_env[0] }
let(:headers) { response_env[1] }
let(:body) { response_env[2].join }
context 'when the application ... | ruby | MIT | fde3b7025db17b5cda13fcf8d08dfb3f76e189f6 | 2026-01-04T15:39:58.699166Z | false |
BetterErrors/better_errors | https://github.com/BetterErrors/better_errors/blob/fde3b7025db17b5cda13fcf8d08dfb3f76e189f6/spec/better_errors/editor_spec.rb | spec/better_errors/editor_spec.rb | require "spec_helper"
RSpec.describe BetterErrors::Editor do
describe ".for_formatting_string" do
it "returns an object that reponds to #url" do
editor = described_class.for_formatting_string("custom://%{file}:%{file_unencoded}:%{line}")
expect(editor.url("/path&file", 42)).to eq("custom://%2Fpath%26... | ruby | MIT | fde3b7025db17b5cda13fcf8d08dfb3f76e189f6 | 2026-01-04T15:39:58.699166Z | false |
BetterErrors/better_errors | https://github.com/BetterErrors/better_errors/blob/fde3b7025db17b5cda13fcf8d08dfb3f76e189f6/spec/better_errors/stack_frame_spec.rb | spec/better_errors/stack_frame_spec.rb | require "spec_helper"
module BetterErrors
describe StackFrame do
context "#application?" do
it "is true for application filenames" do
allow(BetterErrors).to receive(:application_root).and_return("/abc/xyz")
frame = StackFrame.new("/abc/xyz/app/controllers/crap_controller.rb", 123, "index")
... | ruby | MIT | fde3b7025db17b5cda13fcf8d08dfb3f76e189f6 | 2026-01-04T15:39:58.699166Z | false |
BetterErrors/better_errors | https://github.com/BetterErrors/better_errors/blob/fde3b7025db17b5cda13fcf8d08dfb3f76e189f6/spec/better_errors/exception_hint_spec.rb | spec/better_errors/exception_hint_spec.rb | require 'spec_helper'
RSpec.describe BetterErrors::ExceptionHint do
let(:described_instance) { described_class.new(exception) }
describe '#hint' do
subject(:hint) { described_instance.hint }
context "when the exception is a NameError" do
let(:exception) {
begin
foo
rescue ... | ruby | MIT | fde3b7025db17b5cda13fcf8d08dfb3f76e189f6 | 2026-01-04T15:39:58.699166Z | false |
BetterErrors/better_errors | https://github.com/BetterErrors/better_errors/blob/fde3b7025db17b5cda13fcf8d08dfb3f76e189f6/spec/better_errors/error_page_spec.rb | spec/better_errors/error_page_spec.rb | require "spec_helper"
class ErrorPageTestIgnoredClass; end
module BetterErrors
describe ErrorPage do
# It's necessary to use HTML matchers here that are specific as possible.
# This is because if there's an exception within this file, the lines of code will be reflected in the
# generated HTML, so any s... | ruby | MIT | fde3b7025db17b5cda13fcf8d08dfb3f76e189f6 | 2026-01-04T15:39:58.699166Z | false |
BetterErrors/better_errors | https://github.com/BetterErrors/better_errors/blob/fde3b7025db17b5cda13fcf8d08dfb3f76e189f6/spec/better_errors/raised_exception_spec.rb | spec/better_errors/raised_exception_spec.rb | require "spec_helper"
require "rspec/its"
module BetterErrors
describe RaisedException do
let(:exception) { RuntimeError.new("whoops") }
subject(:described_instance) { RaisedException.new(exception) }
before do
allow(BetterErrors::ExceptionHint).to receive(:new).and_return(exception_hint)
end
... | ruby | MIT | fde3b7025db17b5cda13fcf8d08dfb3f76e189f6 | 2026-01-04T15:39:58.699166Z | false |
BetterErrors/better_errors | https://github.com/BetterErrors/better_errors/blob/fde3b7025db17b5cda13fcf8d08dfb3f76e189f6/spec/better_errors/support/my_source.rb | spec/better_errors/support/my_source.rb | one
two
three
four
five
six
seven
eight
nine
ten
eleven
twelve
thirteen
fourteen
fifteen
sixteen
seventeen
eighteen
nineteen
twenty
| ruby | MIT | fde3b7025db17b5cda13fcf8d08dfb3f76e189f6 | 2026-01-04T15:39:58.699166Z | false |
BetterErrors/better_errors | https://github.com/BetterErrors/better_errors/blob/fde3b7025db17b5cda13fcf8d08dfb3f76e189f6/spec/better_errors/repl/shared_examples.rb | spec/better_errors/repl/shared_examples.rb | shared_examples_for "a REPL provider" do
it "evaluates ruby code in a given context" do
repl.send_input("local_a = 456")
expect(fresh_binding.eval("local_a")).to eq(456)
end
it "returns a tuple of output and the new prompt" do
output, prompt = repl.send_input("1 + 2")
expect(output).to eq("=> 3\n... | ruby | MIT | fde3b7025db17b5cda13fcf8d08dfb3f76e189f6 | 2026-01-04T15:39:58.699166Z | false |
BetterErrors/better_errors | https://github.com/BetterErrors/better_errors/blob/fde3b7025db17b5cda13fcf8d08dfb3f76e189f6/spec/better_errors/repl/basic_spec.rb | spec/better_errors/repl/basic_spec.rb | require "spec_helper"
require "better_errors/repl/basic"
require "better_errors/repl/shared_examples"
module BetterErrors
module REPL
describe Basic do
let(:fresh_binding) {
local_a = 123
binding
}
let!(:exception) { raise ZeroDivisionError, "you divided by zero you silly goose... | ruby | MIT | fde3b7025db17b5cda13fcf8d08dfb3f76e189f6 | 2026-01-04T15:39:58.699166Z | false |
BetterErrors/better_errors | https://github.com/BetterErrors/better_errors/blob/fde3b7025db17b5cda13fcf8d08dfb3f76e189f6/spec/better_errors/repl/pry_spec.rb | spec/better_errors/repl/pry_spec.rb | require "spec_helper"
require "better_errors/repl/shared_examples"
if defined? ::Pry
RSpec.describe 'BetterErrors::REPL::Pry' do
before(:all) do
load "better_errors/repl/pry.rb"
end
after(:all) do
# Ensure the Pry REPL file has not been included. If this is not done,
# the constant leak... | ruby | MIT | fde3b7025db17b5cda13fcf8d08dfb3f76e189f6 | 2026-01-04T15:39:58.699166Z | false |
BetterErrors/better_errors | https://github.com/BetterErrors/better_errors/blob/fde3b7025db17b5cda13fcf8d08dfb3f76e189f6/spec/better_errors/code_formatter/text_spec.rb | spec/better_errors/code_formatter/text_spec.rb | require "spec_helper"
RSpec.describe BetterErrors::CodeFormatter::Text do
let(:filename) { File.expand_path("../../support/my_source.rb", __FILE__) }
let(:line) { 8 }
let(:formatter) { described_class.new(filename, line) }
it "shows 5 lines of context" do
expect(formatter.line_range).to eq(3..13)
exp... | ruby | MIT | fde3b7025db17b5cda13fcf8d08dfb3f76e189f6 | 2026-01-04T15:39:58.699166Z | false |
BetterErrors/better_errors | https://github.com/BetterErrors/better_errors/blob/fde3b7025db17b5cda13fcf8d08dfb3f76e189f6/spec/better_errors/code_formatter/html_spec.rb | spec/better_errors/code_formatter/html_spec.rb | require "spec_helper"
RSpec.describe BetterErrors::CodeFormatter::HTML do
let(:filename) { File.expand_path("../../support/my_source.rb", __FILE__) }
let(:line) { 8 }
let(:formatter) { described_class.new(filename, line) }
it "shows 5 lines of context above and below the line" do
expect(formatter.line_ran... | ruby | MIT | fde3b7025db17b5cda13fcf8d08dfb3f76e189f6 | 2026-01-04T15:39:58.699166Z | false |
BetterErrors/better_errors | https://github.com/BetterErrors/better_errors/blob/fde3b7025db17b5cda13fcf8d08dfb3f76e189f6/lib/better_errors.rb | lib/better_errors.rb | require "pp"
require "erubi"
require "uri"
require "better_errors/version"
require "better_errors/code_formatter"
require "better_errors/inspectable_value"
require "better_errors/error_page"
require "better_errors/middleware"
require "better_errors/raised_exception"
require "better_errors/repl"
require "better_errors/... | ruby | MIT | fde3b7025db17b5cda13fcf8d08dfb3f76e189f6 | 2026-01-04T15:39:58.699166Z | false |
BetterErrors/better_errors | https://github.com/BetterErrors/better_errors/blob/fde3b7025db17b5cda13fcf8d08dfb3f76e189f6/lib/better_errors/exception_hint.rb | lib/better_errors/exception_hint.rb | module BetterErrors
class ExceptionHint
def initialize(exception)
@exception = exception
end
def hint
case exception
when NoMethodError
/\Aundefined method `(?<method>[^']+)' for (?<val>[^:]+):(?<klass>\w+)/.match(exception.message) do |match|
if match[:val] == "nil"
... | ruby | MIT | fde3b7025db17b5cda13fcf8d08dfb3f76e189f6 | 2026-01-04T15:39:58.699166Z | false |
BetterErrors/better_errors | https://github.com/BetterErrors/better_errors/blob/fde3b7025db17b5cda13fcf8d08dfb3f76e189f6/lib/better_errors/inspectable_value.rb | lib/better_errors/inspectable_value.rb | require "cgi"
require "objspace" rescue nil
module BetterErrors
class ValueLargerThanConfiguredMaximum < StandardError; end
class InspectableValue
def initialize(value)
@original_value = value
end
def to_html
raise ValueLargerThanConfiguredMaximum unless value_small_enough_to_inspect?
... | ruby | MIT | fde3b7025db17b5cda13fcf8d08dfb3f76e189f6 | 2026-01-04T15:39:58.699166Z | false |
BetterErrors/better_errors | https://github.com/BetterErrors/better_errors/blob/fde3b7025db17b5cda13fcf8d08dfb3f76e189f6/lib/better_errors/version.rb | lib/better_errors/version.rb | module BetterErrors
# This is changed by CI before building a gem for release, but is not committed.
VERSION = "0.0.1dev"
end
| ruby | MIT | fde3b7025db17b5cda13fcf8d08dfb3f76e189f6 | 2026-01-04T15:39:58.699166Z | false |
BetterErrors/better_errors | https://github.com/BetterErrors/better_errors/blob/fde3b7025db17b5cda13fcf8d08dfb3f76e189f6/lib/better_errors/rails.rb | lib/better_errors/rails.rb | module BetterErrors
# @private
class Railtie < Rails::Railtie
initializer "better_errors.configure_rails_initialization" do
if use_better_errors?
insert_middleware
BetterErrors.logger = Rails.logger
BetterErrors.application_root = Rails.root.to_s
end
end
def insert_m... | ruby | MIT | fde3b7025db17b5cda13fcf8d08dfb3f76e189f6 | 2026-01-04T15:39:58.699166Z | false |
BetterErrors/better_errors | https://github.com/BetterErrors/better_errors/blob/fde3b7025db17b5cda13fcf8d08dfb3f76e189f6/lib/better_errors/raised_exception.rb | lib/better_errors/raised_exception.rb | require 'better_errors/exception_hint'
# @private
module BetterErrors
class RaisedException
attr_reader :exception, :message, :backtrace, :hint
def initialize(exception)
if exception.class.name == "ActionView::Template::Error" && exception.respond_to?(:cause)
# Rails 6+ exceptions of this type... | ruby | MIT | fde3b7025db17b5cda13fcf8d08dfb3f76e189f6 | 2026-01-04T15:39:58.699166Z | false |
BetterErrors/better_errors | https://github.com/BetterErrors/better_errors/blob/fde3b7025db17b5cda13fcf8d08dfb3f76e189f6/lib/better_errors/middleware.rb | lib/better_errors/middleware.rb | require "json"
require "ipaddr"
require "securerandom"
require "set"
require "rack"
module BetterErrors
# Better Errors' error handling middleware. Including this in your middleware
# stack will show a Better Errors error page for exceptions raised below this
# middleware.
#
# If you are using Ruby on Rails,... | ruby | MIT | fde3b7025db17b5cda13fcf8d08dfb3f76e189f6 | 2026-01-04T15:39:58.699166Z | false |
BetterErrors/better_errors | https://github.com/BetterErrors/better_errors/blob/fde3b7025db17b5cda13fcf8d08dfb3f76e189f6/lib/better_errors/repl.rb | lib/better_errors/repl.rb | module BetterErrors
# @private
module REPL
PROVIDERS = [
{ impl: "better_errors/repl/basic",
const: :Basic },
]
def self.provider
@provider ||= const_get detect[:const]
end
def self.provider=(prov)
@provider = prov
end
def self.detect
PROVIDERS... | ruby | MIT | fde3b7025db17b5cda13fcf8d08dfb3f76e189f6 | 2026-01-04T15:39:58.699166Z | false |
BetterErrors/better_errors | https://github.com/BetterErrors/better_errors/blob/fde3b7025db17b5cda13fcf8d08dfb3f76e189f6/lib/better_errors/error_page_style.rb | lib/better_errors/error_page_style.rb | module BetterErrors
# @private
module ErrorPageStyle
def self.compiled_css(for_deployment = false)
begin
require "sassc"
rescue LoadError
raise LoadError, "The `sassc` gem is required when developing the `better_errors` gem. "\
"If you're using a release of `better_errors`,... | ruby | MIT | fde3b7025db17b5cda13fcf8d08dfb3f76e189f6 | 2026-01-04T15:39:58.699166Z | false |
BetterErrors/better_errors | https://github.com/BetterErrors/better_errors/blob/fde3b7025db17b5cda13fcf8d08dfb3f76e189f6/lib/better_errors/error_page.rb | lib/better_errors/error_page.rb | require "cgi"
require "json"
require "securerandom"
require "rouge"
require "better_errors/error_page_style"
module BetterErrors
# @private
class ErrorPage
VariableInfo = Struct.new(:frame, :editor_url, :rails_params, :rack_session, :start_time)
def self.template_path(template_name)
File.expand_path... | ruby | MIT | fde3b7025db17b5cda13fcf8d08dfb3f76e189f6 | 2026-01-04T15:39:58.699166Z | false |
BetterErrors/better_errors | https://github.com/BetterErrors/better_errors/blob/fde3b7025db17b5cda13fcf8d08dfb3f76e189f6/lib/better_errors/code_formatter.rb | lib/better_errors/code_formatter.rb | module BetterErrors
# @private
class CodeFormatter
require "better_errors/code_formatter/html"
require "better_errors/code_formatter/text"
attr_reader :filename, :line, :context
def initialize(filename, line, context = 5)
@filename = filename
@line = line
@context = context
... | ruby | MIT | fde3b7025db17b5cda13fcf8d08dfb3f76e189f6 | 2026-01-04T15:39:58.699166Z | false |
BetterErrors/better_errors | https://github.com/BetterErrors/better_errors/blob/fde3b7025db17b5cda13fcf8d08dfb3f76e189f6/lib/better_errors/editor.rb | lib/better_errors/editor.rb | require "uri"
module BetterErrors
class Editor
KNOWN_EDITORS = [
{ symbols: [:atom], sniff: /atom/i, url: "atom://core/open/file?filename=%{file}&line=%{line}" },
{ symbols: [:emacs, :emacsclient], sniff: /emacs/i, url: "emacs://open?url=file://%{file}&line=%{line}" },
{ symbols: [:idea], sniff... | ruby | MIT | fde3b7025db17b5cda13fcf8d08dfb3f76e189f6 | 2026-01-04T15:39:58.699166Z | false |
BetterErrors/better_errors | https://github.com/BetterErrors/better_errors/blob/fde3b7025db17b5cda13fcf8d08dfb3f76e189f6/lib/better_errors/exception_extension.rb | lib/better_errors/exception_extension.rb | module BetterErrors
module ExceptionExtension
prepend_features Exception
def set_backtrace(*)
if caller_locations.none? { |loc| loc.path == __FILE__ }
@__better_errors_bindings_stack = ::Kernel.binding.callers.drop(1)
end
super
end
def __better_errors_bindings_stack
... | ruby | MIT | fde3b7025db17b5cda13fcf8d08dfb3f76e189f6 | 2026-01-04T15:39:58.699166Z | false |
BetterErrors/better_errors | https://github.com/BetterErrors/better_errors/blob/fde3b7025db17b5cda13fcf8d08dfb3f76e189f6/lib/better_errors/stack_frame.rb | lib/better_errors/stack_frame.rb | require "set"
module BetterErrors
# @private
class StackFrame
def self.from_exception(exception)
RaisedException.new(exception).backtrace
end
attr_reader :filename, :line, :name, :frame_binding
def initialize(filename, line, name, frame_binding = nil)
@filename = filename
... | ruby | MIT | fde3b7025db17b5cda13fcf8d08dfb3f76e189f6 | 2026-01-04T15:39:58.699166Z | false |
BetterErrors/better_errors | https://github.com/BetterErrors/better_errors/blob/fde3b7025db17b5cda13fcf8d08dfb3f76e189f6/lib/better_errors/repl/pry.rb | lib/better_errors/repl/pry.rb | require "fiber"
require "pry"
module BetterErrors
module REPL
class Pry
class Input
def readline
Fiber.yield
end
end
class Output
def initialize
@buffer = ""
end
def puts(*args)
args.each do |arg|
@buffer << "#{... | ruby | MIT | fde3b7025db17b5cda13fcf8d08dfb3f76e189f6 | 2026-01-04T15:39:58.699166Z | false |
BetterErrors/better_errors | https://github.com/BetterErrors/better_errors/blob/fde3b7025db17b5cda13fcf8d08dfb3f76e189f6/lib/better_errors/repl/basic.rb | lib/better_errors/repl/basic.rb | module BetterErrors
module REPL
class Basic
def initialize(binding, _exception)
@binding = binding
end
def send_input(str)
[execute(str), ">>", ""]
end
private
def execute(str)
"=> #{@binding.eval(str).inspect}\n"
rescue Exception => e
"!! ... | ruby | MIT | fde3b7025db17b5cda13fcf8d08dfb3f76e189f6 | 2026-01-04T15:39:58.699166Z | false |
BetterErrors/better_errors | https://github.com/BetterErrors/better_errors/blob/fde3b7025db17b5cda13fcf8d08dfb3f76e189f6/lib/better_errors/code_formatter/text.rb | lib/better_errors/code_formatter/text.rb | module BetterErrors
# @private
class CodeFormatter::Text < CodeFormatter
def source_unavailable
"# Source is not available"
end
def formatted_lines
each_line_of(context_lines) { |highlight, current_line, str|
sprintf '%s %3d %s', (highlight ? '>' : ' '), current_line, str
}
... | ruby | MIT | fde3b7025db17b5cda13fcf8d08dfb3f76e189f6 | 2026-01-04T15:39:58.699166Z | false |
BetterErrors/better_errors | https://github.com/BetterErrors/better_errors/blob/fde3b7025db17b5cda13fcf8d08dfb3f76e189f6/lib/better_errors/code_formatter/html.rb | lib/better_errors/code_formatter/html.rb | require "rouge"
module BetterErrors
# @private
class CodeFormatter::HTML < CodeFormatter
def source_unavailable
"<p class='unavailable'>Source is not available</p>"
end
def formatted_lines
each_line_of(highlighted_lines) { |highlight, current_line, str|
class_name = highlight ? "hi... | ruby | MIT | fde3b7025db17b5cda13fcf8d08dfb3f76e189f6 | 2026-01-04T15:39:58.699166Z | false |
bkeepers/dotenv | https://github.com/bkeepers/dotenv/blob/34156bf400cd67387fa6ed9f146778f6a2f5f743/benchmark/parse_ips.rb | benchmark/parse_ips.rb | require "bundler/setup"
require "dotenv"
require "benchmark/ips"
require "tempfile"
f = Tempfile.create("benchmark_ips.env")
1000.times.map { |i| f.puts "VAR_#{i}=#{i}" }
f.close
Benchmark.ips do |x|
x.report("parse, overwrite:false") { Dotenv.parse(f.path, overwrite: false) }
x.report("parse, overwrite:true") { ... | ruby | MIT | 34156bf400cd67387fa6ed9f146778f6a2f5f743 | 2026-01-04T15:40:05.785256Z | false |
bkeepers/dotenv | https://github.com/bkeepers/dotenv/blob/34156bf400cd67387fa6ed9f146778f6a2f5f743/benchmark/parse_profile.rb | benchmark/parse_profile.rb | require "bundler/setup"
require "dotenv"
require "stackprof"
require "benchmark/ips"
require "tempfile"
f = Tempfile.create("benchmark_ips.env")
1000.times.map { |i| f.puts "VAR_#{i}=#{i}" }
f.close
profile = StackProf.run(mode: :wall, interval: 1_000) do
10_000.times do
Dotenv.parse(f.path, overwrite: false)
... | ruby | MIT | 34156bf400cd67387fa6ed9f146778f6a2f5f743 | 2026-01-04T15:40:05.785256Z | false |
bkeepers/dotenv | https://github.com/bkeepers/dotenv/blob/34156bf400cd67387fa6ed9f146778f6a2f5f743/test/autorestore_test.rb | test/autorestore_test.rb | require "active_support" # Rails 6.1 fails if this is not loaded
require "active_support/test_case"
require "minitest/autorun"
require "dotenv"
require "dotenv/autorestore"
class AutorestoreTest < ActiveSupport::TestCase
test "restores ENV between tests, part 1" do
assert_nil ENV["DOTENV"], "ENV was not restore... | ruby | MIT | 34156bf400cd67387fa6ed9f146778f6a2f5f743 | 2026-01-04T15:40:05.785256Z | false |
bkeepers/dotenv | https://github.com/bkeepers/dotenv/blob/34156bf400cd67387fa6ed9f146778f6a2f5f743/spec/dotenv_spec.rb | spec/dotenv_spec.rb | require "spec_helper"
describe Dotenv do
before do
Dir.chdir(File.expand_path("../fixtures", __FILE__))
end
shared_examples "load" do
context "with no args" do
let(:env_files) { [] }
it "defaults to .env" do
expect(Dotenv::Environment).to receive(:new).with(expand(".env"), anything)... | ruby | MIT | 34156bf400cd67387fa6ed9f146778f6a2f5f743 | 2026-01-04T15:40:05.785256Z | false |
bkeepers/dotenv | https://github.com/bkeepers/dotenv/blob/34156bf400cd67387fa6ed9f146778f6a2f5f743/spec/spec_helper.rb | spec/spec_helper.rb | require "dotenv"
require "dotenv/autorestore"
require "tmpdir"
def fixture_path(*parts)
Pathname.new(__dir__).join("./fixtures", *parts)
end
# Capture output to $stdout and $stderr
def capture_output(&_block)
original_stderr = $stderr
original_stdout = $stdout
output = $stderr = $stdout = StringIO.new
yield... | ruby | MIT | 34156bf400cd67387fa6ed9f146778f6a2f5f743 | 2026-01-04T15:40:05.785256Z | false |
bkeepers/dotenv | https://github.com/bkeepers/dotenv/blob/34156bf400cd67387fa6ed9f146778f6a2f5f743/spec/dotenv/rails_spec.rb | spec/dotenv/rails_spec.rb | require "spec_helper"
require "rails"
require "dotenv/rails"
describe Dotenv::Rails do
let(:log_output) { StringIO.new }
let(:application) do
log_output = self.log_output
Class.new(Rails::Application) do
config.load_defaults Rails::VERSION::STRING.to_f
config.eager_load = false
config.log... | ruby | MIT | 34156bf400cd67387fa6ed9f146778f6a2f5f743 | 2026-01-04T15:40:05.785256Z | false |
bkeepers/dotenv | https://github.com/bkeepers/dotenv/blob/34156bf400cd67387fa6ed9f146778f6a2f5f743/spec/dotenv/log_subscriber_spec.rb | spec/dotenv/log_subscriber_spec.rb | require "spec_helper"
require "active_support/all"
require "rails"
require "dotenv/rails"
describe Dotenv::LogSubscriber do
let(:logs) { StringIO.new }
before do
Dotenv.instrumenter = ActiveSupport::Notifications
Dotenv::Rails.logger = Logger.new(logs)
end
describe "load" do
it "logs when a file ... | ruby | MIT | 34156bf400cd67387fa6ed9f146778f6a2f5f743 | 2026-01-04T15:40:05.785256Z | false |
bkeepers/dotenv | https://github.com/bkeepers/dotenv/blob/34156bf400cd67387fa6ed9f146778f6a2f5f743/spec/dotenv/cli_spec.rb | spec/dotenv/cli_spec.rb | require "spec_helper"
require "dotenv/cli"
describe "dotenv binary" do
before do
Dir.chdir(File.expand_path("../../fixtures", __FILE__))
end
def run(*args)
Dotenv::CLI.new(args).run
end
it "loads from .env by default" do
expect(ENV).not_to have_key("DOTENV")
run
expect(ENV).to have_key(... | ruby | MIT | 34156bf400cd67387fa6ed9f146778f6a2f5f743 | 2026-01-04T15:40:05.785256Z | false |
bkeepers/dotenv | https://github.com/bkeepers/dotenv/blob/34156bf400cd67387fa6ed9f146778f6a2f5f743/spec/dotenv/diff_spec.rb | spec/dotenv/diff_spec.rb | require "spec_helper"
describe Dotenv::Diff do
let(:before) { {} }
let(:after) { {} }
subject { Dotenv::Diff.new(a: before, b: after) }
context "no changes" do
let(:before) { {"A" => 1} }
let(:after) { {"A" => 1} }
it { expect(subject.added).to eq({}) }
it { expect(subject.removed).to eq({}) ... | ruby | MIT | 34156bf400cd67387fa6ed9f146778f6a2f5f743 | 2026-01-04T15:40:05.785256Z | false |
bkeepers/dotenv | https://github.com/bkeepers/dotenv/blob/34156bf400cd67387fa6ed9f146778f6a2f5f743/spec/dotenv/parser_spec.rb | spec/dotenv/parser_spec.rb | require "spec_helper"
describe Dotenv::Parser do
def env(...)
Dotenv::Parser.call(...)
end
it "parses unquoted values" do
expect(env("FOO=bar")).to eql("FOO" => "bar")
end
it "parses unquoted values with spaces after seperator" do
expect(env("FOO= bar")).to eql("FOO" => "bar")
end
it "pars... | ruby | MIT | 34156bf400cd67387fa6ed9f146778f6a2f5f743 | 2026-01-04T15:40:05.785256Z | false |
bkeepers/dotenv | https://github.com/bkeepers/dotenv/blob/34156bf400cd67387fa6ed9f146778f6a2f5f743/spec/dotenv/environment_spec.rb | spec/dotenv/environment_spec.rb | require "spec_helper"
describe Dotenv::Environment do
subject { env("OPTION_A=1\nOPTION_B=2") }
describe "initialize" do
it "reads the file" do
expect(subject["OPTION_A"]).to eq("1")
expect(subject["OPTION_B"]).to eq("2")
end
it "fails if file does not exist" do
expect do
Do... | ruby | MIT | 34156bf400cd67387fa6ed9f146778f6a2f5f743 | 2026-01-04T15:40:05.785256Z | false |
bkeepers/dotenv | https://github.com/bkeepers/dotenv/blob/34156bf400cd67387fa6ed9f146778f6a2f5f743/lib/dotenv.rb | lib/dotenv.rb | require "dotenv/version"
require "dotenv/parser"
require "dotenv/environment"
require "dotenv/missing_keys"
require "dotenv/diff"
# Shim to load environment variables from `.env files into `ENV`.
module Dotenv
extend self
# An internal monitor to synchronize access to ENV in multi-threaded environments.
SEMAPHO... | ruby | MIT | 34156bf400cd67387fa6ed9f146778f6a2f5f743 | 2026-01-04T15:40:05.785256Z | false |
bkeepers/dotenv | https://github.com/bkeepers/dotenv/blob/34156bf400cd67387fa6ed9f146778f6a2f5f743/lib/dotenv-rails.rb | lib/dotenv-rails.rb | require "dotenv"
| ruby | MIT | 34156bf400cd67387fa6ed9f146778f6a2f5f743 | 2026-01-04T15:40:05.785256Z | false |
bkeepers/dotenv | https://github.com/bkeepers/dotenv/blob/34156bf400cd67387fa6ed9f146778f6a2f5f743/lib/dotenv/version.rb | lib/dotenv/version.rb | module Dotenv
VERSION = "3.2.0".freeze
end
| ruby | MIT | 34156bf400cd67387fa6ed9f146778f6a2f5f743 | 2026-01-04T15:40:05.785256Z | false |
bkeepers/dotenv | https://github.com/bkeepers/dotenv/blob/34156bf400cd67387fa6ed9f146778f6a2f5f743/lib/dotenv/rails.rb | lib/dotenv/rails.rb | # Since rubygems doesn't support optional dependencies, we have to manually check
unless Gem::Requirement.new(">= 6.1").satisfied_by?(Gem::Version.new(Rails.version))
warn "dotenv 3.0 only supports Rails 6.1 or later. Use dotenv ~> 2.0."
return
end
require "dotenv/replay_logger"
require "dotenv/log_subscriber"
Do... | ruby | MIT | 34156bf400cd67387fa6ed9f146778f6a2f5f743 | 2026-01-04T15:40:05.785256Z | false |
bkeepers/dotenv | https://github.com/bkeepers/dotenv/blob/34156bf400cd67387fa6ed9f146778f6a2f5f743/lib/dotenv/rails-now.rb | lib/dotenv/rails-now.rb | # If you use gems that require environment variables to be set before they are
# loaded, then list `dotenv` in the `Gemfile` before those other gems and
# require `dotenv/load`.
#
# gem "dotenv", require: "dotenv/load"
# gem "gem-that-requires-env-variables"
#
require "dotenv/load"
warn '[DEPRECATION] `require... | ruby | MIT | 34156bf400cd67387fa6ed9f146778f6a2f5f743 | 2026-01-04T15:40:05.785256Z | false |
bkeepers/dotenv | https://github.com/bkeepers/dotenv/blob/34156bf400cd67387fa6ed9f146778f6a2f5f743/lib/dotenv/diff.rb | lib/dotenv/diff.rb | module Dotenv
# A diff between multiple states of ENV.
class Diff
# The initial state
attr_reader :a
# The final or current state
attr_reader :b
# Create a new diff. If given a block, the state of ENV after the block will be preserved as
# the final state for comparison. Otherwise, the cur... | ruby | MIT | 34156bf400cd67387fa6ed9f146778f6a2f5f743 | 2026-01-04T15:40:05.785256Z | false |
bkeepers/dotenv | https://github.com/bkeepers/dotenv/blob/34156bf400cd67387fa6ed9f146778f6a2f5f743/lib/dotenv/environment.rb | lib/dotenv/environment.rb | module Dotenv
# A `.env` file that will be read and parsed into a Hash
class Environment < Hash
attr_reader :filename, :overwrite
# Create a new Environment
#
# @param filename [String] the path to the file to read
# @param overwrite [Boolean] whether the parser should assume existing values wi... | ruby | MIT | 34156bf400cd67387fa6ed9f146778f6a2f5f743 | 2026-01-04T15:40:05.785256Z | false |
bkeepers/dotenv | https://github.com/bkeepers/dotenv/blob/34156bf400cd67387fa6ed9f146778f6a2f5f743/lib/dotenv/log_subscriber.rb | lib/dotenv/log_subscriber.rb | require "active_support/log_subscriber"
module Dotenv
# Logs instrumented events
#
# Usage:
# require "active_support/notifications"
# require "dotenv/log_subscriber"
# Dotenv.instrumenter = ActiveSupport::Notifications
#
class LogSubscriber < ActiveSupport::LogSubscriber
attach_to :dotenv
... | ruby | MIT | 34156bf400cd67387fa6ed9f146778f6a2f5f743 | 2026-01-04T15:40:05.785256Z | false |
bkeepers/dotenv | https://github.com/bkeepers/dotenv/blob/34156bf400cd67387fa6ed9f146778f6a2f5f743/lib/dotenv/load.rb | lib/dotenv/load.rb | require "dotenv"
defined?(Dotenv::Rails) ? Dotenv::Rails.load : Dotenv.load
| ruby | MIT | 34156bf400cd67387fa6ed9f146778f6a2f5f743 | 2026-01-04T15:40:05.785256Z | false |
bkeepers/dotenv | https://github.com/bkeepers/dotenv/blob/34156bf400cd67387fa6ed9f146778f6a2f5f743/lib/dotenv/parser.rb | lib/dotenv/parser.rb | require "dotenv/substitutions/variable"
require "dotenv/substitutions/command" if RUBY_VERSION > "1.8.7"
module Dotenv
# Error raised when encountering a syntax error while parsing a .env file.
class FormatError < SyntaxError; end
# Parses the `.env` file format into key/value pairs.
# It allows for variable ... | ruby | MIT | 34156bf400cd67387fa6ed9f146778f6a2f5f743 | 2026-01-04T15:40:05.785256Z | false |
bkeepers/dotenv | https://github.com/bkeepers/dotenv/blob/34156bf400cd67387fa6ed9f146778f6a2f5f743/lib/dotenv/missing_keys.rb | lib/dotenv/missing_keys.rb | module Dotenv
class Error < StandardError; end
class MissingKeys < Error # :nodoc:
def initialize(keys)
key_word = "key#{"s" if keys.size > 1}"
super("Missing required configuration #{key_word}: #{keys.inspect}")
end
end
end
| ruby | MIT | 34156bf400cd67387fa6ed9f146778f6a2f5f743 | 2026-01-04T15:40:05.785256Z | false |
bkeepers/dotenv | https://github.com/bkeepers/dotenv/blob/34156bf400cd67387fa6ed9f146778f6a2f5f743/lib/dotenv/template.rb | lib/dotenv/template.rb | module Dotenv
EXPORT_COMMAND = "export ".freeze
# Class for creating a template from a env file
class EnvTemplate
def initialize(env_file)
@env_file = env_file
end
def create_template
File.open(@env_file, "r") do |env_file|
File.open("#{@env_file}.template", "w") do |env_template|... | ruby | MIT | 34156bf400cd67387fa6ed9f146778f6a2f5f743 | 2026-01-04T15:40:05.785256Z | false |
bkeepers/dotenv | https://github.com/bkeepers/dotenv/blob/34156bf400cd67387fa6ed9f146778f6a2f5f743/lib/dotenv/cli.rb | lib/dotenv/cli.rb | require "dotenv"
require "dotenv/version"
require "dotenv/template"
require "optparse"
module Dotenv
# The `dotenv` command line interface. Run `$ dotenv --help` to see usage.
class CLI < OptionParser
attr_reader :argv, :filenames, :overwrite
def initialize(argv = [])
@argv = argv.dup
@filenam... | ruby | MIT | 34156bf400cd67387fa6ed9f146778f6a2f5f743 | 2026-01-04T15:40:05.785256Z | false |
bkeepers/dotenv | https://github.com/bkeepers/dotenv/blob/34156bf400cd67387fa6ed9f146778f6a2f5f743/lib/dotenv/autorestore.rb | lib/dotenv/autorestore.rb | # Automatically restore `ENV` to its original state after
if defined?(RSpec.configure)
RSpec.configure do |config|
# Save ENV before the suite starts
config.before(:suite) { Dotenv.save }
# Restore ENV after each example
config.after { Dotenv.restore }
end
end
if defined?(ActiveSupport)
ActiveS... | ruby | MIT | 34156bf400cd67387fa6ed9f146778f6a2f5f743 | 2026-01-04T15:40:05.785256Z | false |
bkeepers/dotenv | https://github.com/bkeepers/dotenv/blob/34156bf400cd67387fa6ed9f146778f6a2f5f743/lib/dotenv/tasks.rb | lib/dotenv/tasks.rb | desc "Load environment settings from .env"
task :dotenv do
require "dotenv"
Dotenv.load
end
task environment: :dotenv
| ruby | MIT | 34156bf400cd67387fa6ed9f146778f6a2f5f743 | 2026-01-04T15:40:05.785256Z | false |
bkeepers/dotenv | https://github.com/bkeepers/dotenv/blob/34156bf400cd67387fa6ed9f146778f6a2f5f743/lib/dotenv/replay_logger.rb | lib/dotenv/replay_logger.rb | module Dotenv
# A logger that can be used before the apps real logger is initialized.
class ReplayLogger < Logger
def initialize
super(nil) # Doesn't matter what this is, it won't be used.
@logs = []
end
# Override the add method to store logs so we can replay them to a real logger later.
... | ruby | MIT | 34156bf400cd67387fa6ed9f146778f6a2f5f743 | 2026-01-04T15:40:05.785256Z | false |
bkeepers/dotenv | https://github.com/bkeepers/dotenv/blob/34156bf400cd67387fa6ed9f146778f6a2f5f743/lib/dotenv/substitutions/command.rb | lib/dotenv/substitutions/command.rb | require "English"
module Dotenv
module Substitutions
# Substitute shell commands in a value.
#
# SHA=$(git rev-parse HEAD)
#
module Command
class << self
INTERPOLATED_SHELL_COMMAND = /
(?<backslash>\\)? # is it escaped with a backslash?
\$ # ... | ruby | MIT | 34156bf400cd67387fa6ed9f146778f6a2f5f743 | 2026-01-04T15:40:05.785256Z | false |
bkeepers/dotenv | https://github.com/bkeepers/dotenv/blob/34156bf400cd67387fa6ed9f146778f6a2f5f743/lib/dotenv/substitutions/variable.rb | lib/dotenv/substitutions/variable.rb | require "English"
module Dotenv
module Substitutions
# Substitute variables in a value.
#
# HOST=example.com
# URL="https://$HOST"
#
module Variable
class << self
VARIABLE = /
(\\)? # is it escaped with a backslash?
(\$) # literal $
... | ruby | MIT | 34156bf400cd67387fa6ed9f146778f6a2f5f743 | 2026-01-04T15:40:05.785256Z | false |
github-linguist/linguist | https://github.com/github-linguist/linguist/blob/a7e40d31e271f6747fa1234df37b5fff3e6e2406/samples/Ruby/sinatra.rb | samples/Ruby/sinatra.rb | # external dependencies
require 'rack'
require 'tilt'
require "rack/protection"
# stdlib dependencies
require 'thread'
require 'time'
require 'uri'
# other files we need
require 'sinatra/showexceptions'
require 'sinatra/version'
module Sinatra
# The request object. See Rack::Request for more info:
# http://rack.... | ruby | MIT | a7e40d31e271f6747fa1234df37b5fff3e6e2406 | 2026-01-04T15:37:32.851738Z | true |
github-linguist/linguist | https://github.com/github-linguist/linguist/blob/a7e40d31e271f6747fa1234df37b5fff3e6e2406/samples/Ruby/gen-rb-linguist-thrift.rb | samples/Ruby/gen-rb-linguist-thrift.rb | #
# Autogenerated by Thrift Compiler (1.0.0-dev)
#
# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
#
require 'thrift'
require 'linguist_types'
| ruby | MIT | a7e40d31e271f6747fa1234df37b5fff3e6e2406 | 2026-01-04T15:37:32.851738Z | false |
github-linguist/linguist | https://github.com/github-linguist/linguist/blob/a7e40d31e271f6747fa1234df37b5fff3e6e2406/samples/Ruby/resque.rb | samples/Ruby/resque.rb | require 'redis/namespace'
require 'resque/version'
require 'resque/errors'
require 'resque/failure'
require 'resque/failure/base'
require 'resque/helpers'
require 'resque/stat'
require 'resque/job'
require 'resque/worker'
require 'resque/plugin'
require 'resque/queue'
require 'resque/multi_queue'
require 'resque/co... | ruby | MIT | a7e40d31e271f6747fa1234df37b5fff3e6e2406 | 2026-01-04T15:37:32.851738Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.