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 |
|---|---|---|---|---|---|---|---|---|
heartcombo/simple_form | https://github.com/heartcombo/simple_form/blob/584127a00bfe027ff5fb779fa11f859045d5ae9f/lib/simple_form/railtie.rb | lib/simple_form/railtie.rb | # frozen_string_literal: true
require 'rails/railtie'
module SimpleForm
class Railtie < Rails::Railtie
config.eager_load_namespaces << SimpleForm
config.after_initialize do
unless SimpleForm.configured?
warn '[Simple Form] Simple Form is not configured in the application and will use the defau... | ruby | MIT | 584127a00bfe027ff5fb779fa11f859045d5ae9f | 2026-01-04T15:39:08.979660Z | false |
heartcombo/simple_form | https://github.com/heartcombo/simple_form/blob/584127a00bfe027ff5fb779fa11f859045d5ae9f/lib/simple_form/form_builder.rb | lib/simple_form/form_builder.rb | # frozen_string_literal: true
require 'active_support/core_ext/object/deep_dup'
require 'simple_form/map_type'
require 'simple_form/tags'
module SimpleForm
class FormBuilder < ActionView::Helpers::FormBuilder
attr_reader :template, :object_name, :object, :wrapper
# When action is create or update, we still ... | ruby | MIT | 584127a00bfe027ff5fb779fa11f859045d5ae9f | 2026-01-04T15:39:08.979660Z | false |
heartcombo/simple_form | https://github.com/heartcombo/simple_form/blob/584127a00bfe027ff5fb779fa11f859045d5ae9f/lib/simple_form/wrappers.rb | lib/simple_form/wrappers.rb | # frozen_string_literal: true
module SimpleForm
module Wrappers
autoload :Builder, 'simple_form/wrappers/builder'
autoload :Many, 'simple_form/wrappers/many'
autoload :Root, 'simple_form/wrappers/root'
autoload :Single, 'simple_form/wrappers/single'
autoload :Leaf, 'simple_form/wrappers/... | ruby | MIT | 584127a00bfe027ff5fb779fa11f859045d5ae9f | 2026-01-04T15:39:08.979660Z | false |
heartcombo/simple_form | https://github.com/heartcombo/simple_form/blob/584127a00bfe027ff5fb779fa11f859045d5ae9f/lib/simple_form/inputs.rb | lib/simple_form/inputs.rb | # frozen_string_literal: true
module SimpleForm
module Inputs
extend ActiveSupport::Autoload
autoload :Base
autoload :BlockInput
autoload :BooleanInput
autoload :CollectionCheckBoxesInput
autoload :CollectionInput
autoload :CollectionRadioButtonsInput
autoload :CollectionSelectInput
... | ruby | MIT | 584127a00bfe027ff5fb779fa11f859045d5ae9f | 2026-01-04T15:39:08.979660Z | false |
heartcombo/simple_form | https://github.com/heartcombo/simple_form/blob/584127a00bfe027ff5fb779fa11f859045d5ae9f/lib/simple_form/tags.rb | lib/simple_form/tags.rb | # frozen_string_literal: true
module SimpleForm
module Tags
module CollectionExtensions
private
def render_collection
item_wrapper_tag = @options.fetch(:item_wrapper_tag, :span)
item_wrapper_class = @options[:item_wrapper_class]
@collection.map do |item|
value = v... | ruby | MIT | 584127a00bfe027ff5fb779fa11f859045d5ae9f | 2026-01-04T15:39:08.979660Z | false |
heartcombo/simple_form | https://github.com/heartcombo/simple_form/blob/584127a00bfe027ff5fb779fa11f859045d5ae9f/lib/simple_form/helpers/autofocus.rb | lib/simple_form/helpers/autofocus.rb | # frozen_string_literal: true
module SimpleForm
module Helpers
module Autofocus
private
def has_autofocus?
options[:autofocus] == true
end
end
end
end
| ruby | MIT | 584127a00bfe027ff5fb779fa11f859045d5ae9f | 2026-01-04T15:39:08.979660Z | false |
heartcombo/simple_form | https://github.com/heartcombo/simple_form/blob/584127a00bfe027ff5fb779fa11f859045d5ae9f/lib/simple_form/helpers/required.rb | lib/simple_form/helpers/required.rb | # frozen_string_literal: true
module SimpleForm
module Helpers
module Required
private
def required_field?
@required
end
def calculate_required
if !options[:required].nil?
options[:required]
elsif has_validators?
required_by_validators?
... | ruby | MIT | 584127a00bfe027ff5fb779fa11f859045d5ae9f | 2026-01-04T15:39:08.979660Z | false |
heartcombo/simple_form | https://github.com/heartcombo/simple_form/blob/584127a00bfe027ff5fb779fa11f859045d5ae9f/lib/simple_form/helpers/readonly.rb | lib/simple_form/helpers/readonly.rb | # frozen_string_literal: true
module SimpleForm
module Helpers
module Readonly
private
def readonly_class
:readonly if has_readonly?
end
def has_readonly?
options[:readonly] == true
end
end
end
end
| ruby | MIT | 584127a00bfe027ff5fb779fa11f859045d5ae9f | 2026-01-04T15:39:08.979660Z | false |
heartcombo/simple_form | https://github.com/heartcombo/simple_form/blob/584127a00bfe027ff5fb779fa11f859045d5ae9f/lib/simple_form/helpers/disabled.rb | lib/simple_form/helpers/disabled.rb | # frozen_string_literal: true
module SimpleForm
module Helpers
module Disabled
private
def has_disabled?
options[:disabled] == true
end
def disabled_class
:disabled if has_disabled?
end
end
end
end
| ruby | MIT | 584127a00bfe027ff5fb779fa11f859045d5ae9f | 2026-01-04T15:39:08.979660Z | false |
heartcombo/simple_form | https://github.com/heartcombo/simple_form/blob/584127a00bfe027ff5fb779fa11f859045d5ae9f/lib/simple_form/helpers/validators.rb | lib/simple_form/helpers/validators.rb | # frozen_string_literal: true
module SimpleForm
module Helpers
module Validators
def has_validators?
@has_validators ||= attribute_name && object.class.respond_to?(:validators_on)
end
private
def attribute_validators
object.class.validators_on(attribute_name)
end
... | ruby | MIT | 584127a00bfe027ff5fb779fa11f859045d5ae9f | 2026-01-04T15:39:08.979660Z | false |
heartcombo/simple_form | https://github.com/heartcombo/simple_form/blob/584127a00bfe027ff5fb779fa11f859045d5ae9f/lib/simple_form/action_view_extensions/form_helper.rb | lib/simple_form/action_view_extensions/form_helper.rb | # frozen_string_literal: true
module SimpleForm
module ActionViewExtensions
# This module creates SimpleForm wrappers around default form_for and fields_for.
#
# Example:
#
# simple_form_for @user do |f|
# f.input :name, hint: 'My hint'
# end
#
module FormHelper
def ... | ruby | MIT | 584127a00bfe027ff5fb779fa11f859045d5ae9f | 2026-01-04T15:39:08.979660Z | false |
heartcombo/simple_form | https://github.com/heartcombo/simple_form/blob/584127a00bfe027ff5fb779fa11f859045d5ae9f/lib/simple_form/action_view_extensions/builder.rb | lib/simple_form/action_view_extensions/builder.rb | # frozen_string_literal: true
module SimpleForm
module ActionViewExtensions
# A collection of methods required by simple_form but added to rails default form.
# This means that you can use such methods outside simple_form context.
module Builder
# Wrapper for using SimpleForm inside a default rails... | ruby | MIT | 584127a00bfe027ff5fb779fa11f859045d5ae9f | 2026-01-04T15:39:08.979660Z | false |
heartcombo/simple_form | https://github.com/heartcombo/simple_form/blob/584127a00bfe027ff5fb779fa11f859045d5ae9f/lib/simple_form/components/maxlength.rb | lib/simple_form/components/maxlength.rb | # frozen_string_literal: true
module SimpleForm
module Components
# Needs to be enabled in order to do automatic lookups.
module Maxlength
def maxlength(wrapper_options = nil)
input_html_options[:maxlength] ||= maximum_length_from_validation || limit
nil
end
private
d... | ruby | MIT | 584127a00bfe027ff5fb779fa11f859045d5ae9f | 2026-01-04T15:39:08.979660Z | false |
heartcombo/simple_form | https://github.com/heartcombo/simple_form/blob/584127a00bfe027ff5fb779fa11f859045d5ae9f/lib/simple_form/components/errors.rb | lib/simple_form/components/errors.rb | # frozen_string_literal: true
module SimpleForm
module Components
module Errors
def error(wrapper_options = nil)
error_text if has_errors?
end
def full_error(wrapper_options = nil)
full_error_text if options[:error] != false && has_errors?
end
def has_errors?
... | ruby | MIT | 584127a00bfe027ff5fb779fa11f859045d5ae9f | 2026-01-04T15:39:08.979660Z | false |
heartcombo/simple_form | https://github.com/heartcombo/simple_form/blob/584127a00bfe027ff5fb779fa11f859045d5ae9f/lib/simple_form/components/readonly.rb | lib/simple_form/components/readonly.rb | # frozen_string_literal: true
module SimpleForm
module Components
# Needs to be enabled in order to do automatic lookups.
module Readonly
def readonly(wrapper_options = nil)
if readonly_attribute? && !has_readonly?
input_html_options[:readonly] ||= true
input_html_classes << ... | ruby | MIT | 584127a00bfe027ff5fb779fa11f859045d5ae9f | 2026-01-04T15:39:08.979660Z | false |
heartcombo/simple_form | https://github.com/heartcombo/simple_form/blob/584127a00bfe027ff5fb779fa11f859045d5ae9f/lib/simple_form/components/html5.rb | lib/simple_form/components/html5.rb | # frozen_string_literal: true
module SimpleForm
module Components
module HTML5
def initialize(*)
@html5 = false
end
def html5(wrapper_options = nil)
@html5 = true
input_html_options[:required] = input_html_required_option
input_html_options[:'aria-invalid... | ruby | MIT | 584127a00bfe027ff5fb779fa11f859045d5ae9f | 2026-01-04T15:39:08.979660Z | false |
heartcombo/simple_form | https://github.com/heartcombo/simple_form/blob/584127a00bfe027ff5fb779fa11f859045d5ae9f/lib/simple_form/components/min_max.rb | lib/simple_form/components/min_max.rb | # frozen_string_literal: true
module SimpleForm
module Components
module MinMax
def min_max(wrapper_options = nil)
if numeric_validator = find_numericality_validator
validator_options = numeric_validator.options
input_html_options[:min] ||= minimum_value(validator_options)
... | ruby | MIT | 584127a00bfe027ff5fb779fa11f859045d5ae9f | 2026-01-04T15:39:08.979660Z | false |
heartcombo/simple_form | https://github.com/heartcombo/simple_form/blob/584127a00bfe027ff5fb779fa11f859045d5ae9f/lib/simple_form/components/placeholders.rb | lib/simple_form/components/placeholders.rb | # frozen_string_literal: true
module SimpleForm
module Components
# Needs to be enabled in order to do automatic lookups.
module Placeholders
def placeholder(wrapper_options = nil)
input_html_options[:placeholder] ||= placeholder_text
nil
end
def placeholder_text(wrapper_opt... | ruby | MIT | 584127a00bfe027ff5fb779fa11f859045d5ae9f | 2026-01-04T15:39:08.979660Z | false |
heartcombo/simple_form | https://github.com/heartcombo/simple_form/blob/584127a00bfe027ff5fb779fa11f859045d5ae9f/lib/simple_form/components/hints.rb | lib/simple_form/components/hints.rb | # frozen_string_literal: true
module SimpleForm
module Components
# Needs to be enabled in order to do automatic lookups.
module Hints
def hint(wrapper_options = nil)
@hint ||= begin
hint = options[:hint]
if hint.is_a?(String)
html_escape(hint)
else
... | ruby | MIT | 584127a00bfe027ff5fb779fa11f859045d5ae9f | 2026-01-04T15:39:08.979660Z | false |
heartcombo/simple_form | https://github.com/heartcombo/simple_form/blob/584127a00bfe027ff5fb779fa11f859045d5ae9f/lib/simple_form/components/label_input.rb | lib/simple_form/components/label_input.rb | # frozen_string_literal: true
module SimpleForm
module Components
module LabelInput
extend ActiveSupport::Concern
included do
include SimpleForm::Components::Labels
end
def label_input(wrapper_options = nil)
if options[:label] == false
deprecated_component(:inpu... | ruby | MIT | 584127a00bfe027ff5fb779fa11f859045d5ae9f | 2026-01-04T15:39:08.979660Z | false |
heartcombo/simple_form | https://github.com/heartcombo/simple_form/blob/584127a00bfe027ff5fb779fa11f859045d5ae9f/lib/simple_form/components/pattern.rb | lib/simple_form/components/pattern.rb | # frozen_string_literal: true
module SimpleForm
module Components
# Needs to be enabled in order to do automatic lookups.
module Pattern
def pattern(wrapper_options = nil)
input_html_options[:pattern] ||= pattern_source
nil
end
private
def pattern_source
patte... | ruby | MIT | 584127a00bfe027ff5fb779fa11f859045d5ae9f | 2026-01-04T15:39:08.979660Z | false |
heartcombo/simple_form | https://github.com/heartcombo/simple_form/blob/584127a00bfe027ff5fb779fa11f859045d5ae9f/lib/simple_form/components/minlength.rb | lib/simple_form/components/minlength.rb | # frozen_string_literal: true
module SimpleForm
module Components
# Needs to be enabled in order to do automatic lookups.
module Minlength
def minlength(wrapper_options = nil)
input_html_options[:minlength] ||= minimum_length_from_validation
nil
end
private
def minimu... | ruby | MIT | 584127a00bfe027ff5fb779fa11f859045d5ae9f | 2026-01-04T15:39:08.979660Z | false |
heartcombo/simple_form | https://github.com/heartcombo/simple_form/blob/584127a00bfe027ff5fb779fa11f859045d5ae9f/lib/simple_form/components/labels.rb | lib/simple_form/components/labels.rb | # frozen_string_literal: true
module SimpleForm
module Components
module Labels
extend ActiveSupport::Concern
module ClassMethods #:nodoc:
def translate_required_html
I18n.t(:"required.html", scope: i18n_scope, default:
%(<abbr title="#{translate_required_text}">#{transl... | ruby | MIT | 584127a00bfe027ff5fb779fa11f859045d5ae9f | 2026-01-04T15:39:08.979660Z | false |
heartcombo/simple_form | https://github.com/heartcombo/simple_form/blob/584127a00bfe027ff5fb779fa11f859045d5ae9f/lib/simple_form/wrappers/single.rb | lib/simple_form/wrappers/single.rb | # frozen_string_literal: true
module SimpleForm
module Wrappers
# `Single` is an optimization for a wrapper that has only one component.
class Single < Many
def initialize(name, wrapper_options = {}, options = {})
@component = Leaf.new(name, options)
super(name, [@component], wrapper_op... | ruby | MIT | 584127a00bfe027ff5fb779fa11f859045d5ae9f | 2026-01-04T15:39:08.979660Z | false |
heartcombo/simple_form | https://github.com/heartcombo/simple_form/blob/584127a00bfe027ff5fb779fa11f859045d5ae9f/lib/simple_form/wrappers/leaf.rb | lib/simple_form/wrappers/leaf.rb | # frozen_string_literal: true
module SimpleForm
module Wrappers
class Leaf
attr_reader :namespace
def initialize(namespace, options = {})
@namespace = namespace
@options = options
end
def render(input)
method = input.method(@namespace)
if method.arity.zer... | ruby | MIT | 584127a00bfe027ff5fb779fa11f859045d5ae9f | 2026-01-04T15:39:08.979660Z | false |
heartcombo/simple_form | https://github.com/heartcombo/simple_form/blob/584127a00bfe027ff5fb779fa11f859045d5ae9f/lib/simple_form/wrappers/root.rb | lib/simple_form/wrappers/root.rb | # frozen_string_literal: true
module SimpleForm
module Wrappers
# `Root` is the root wrapper for all components. It is special cased to
# always have a namespace and to add special html classes.
class Root < Many
attr_reader :options
def initialize(*args)
super(:wrapper, *args)
... | ruby | MIT | 584127a00bfe027ff5fb779fa11f859045d5ae9f | 2026-01-04T15:39:08.979660Z | false |
heartcombo/simple_form | https://github.com/heartcombo/simple_form/blob/584127a00bfe027ff5fb779fa11f859045d5ae9f/lib/simple_form/wrappers/many.rb | lib/simple_form/wrappers/many.rb | # frozen_string_literal: true
module SimpleForm
module Wrappers
# A wrapper is an object that holds several components and render them.
# A component may be any object that responds to `render`.
# This API allows inputs/components to be easily wrapped, removing the
# need to modify the code only to wr... | ruby | MIT | 584127a00bfe027ff5fb779fa11f859045d5ae9f | 2026-01-04T15:39:08.979660Z | false |
heartcombo/simple_form | https://github.com/heartcombo/simple_form/blob/584127a00bfe027ff5fb779fa11f859045d5ae9f/lib/simple_form/wrappers/builder.rb | lib/simple_form/wrappers/builder.rb | # frozen_string_literal: true
module SimpleForm
module Wrappers
# Provides the builder syntax for components. The builder provides
# three methods `use`, `optional` and `wrapper` and they allow the following invocations:
#
# config.wrappers do |b|
# # Use a single component
# b... | ruby | MIT | 584127a00bfe027ff5fb779fa11f859045d5ae9f | 2026-01-04T15:39:08.979660Z | false |
heartcombo/simple_form | https://github.com/heartcombo/simple_form/blob/584127a00bfe027ff5fb779fa11f859045d5ae9f/lib/simple_form/inputs/rich_text_area_input.rb | lib/simple_form/inputs/rich_text_area_input.rb | # frozen_string_literal: true
module SimpleForm
module Inputs
class RichTextAreaInput < Base
enable :placeholder
def input(wrapper_options = nil)
merged_input_options = merge_wrapper_options(input_html_options, wrapper_options)
@builder.rich_text_area(attribute_name, merged_input_opt... | ruby | MIT | 584127a00bfe027ff5fb779fa11f859045d5ae9f | 2026-01-04T15:39:08.979660Z | false |
heartcombo/simple_form | https://github.com/heartcombo/simple_form/blob/584127a00bfe027ff5fb779fa11f859045d5ae9f/lib/simple_form/inputs/string_input.rb | lib/simple_form/inputs/string_input.rb | # frozen_string_literal: true
module SimpleForm
module Inputs
class StringInput < Base
enable :placeholder, :maxlength, :minlength, :pattern
def input(wrapper_options = nil)
unless string?
input_html_classes.unshift("string")
input_html_options[:type] ||= input_type if htm... | ruby | MIT | 584127a00bfe027ff5fb779fa11f859045d5ae9f | 2026-01-04T15:39:08.979660Z | false |
heartcombo/simple_form | https://github.com/heartcombo/simple_form/blob/584127a00bfe027ff5fb779fa11f859045d5ae9f/lib/simple_form/inputs/block_input.rb | lib/simple_form/inputs/block_input.rb | # frozen_string_literal: true
module SimpleForm
module Inputs
class BlockInput < Base
def initialize(*args, &block)
super
@block = block
end
def input(wrapper_options = nil)
template.capture(&@block)
end
end
end
end
| ruby | MIT | 584127a00bfe027ff5fb779fa11f859045d5ae9f | 2026-01-04T15:39:08.979660Z | false |
heartcombo/simple_form | https://github.com/heartcombo/simple_form/blob/584127a00bfe027ff5fb779fa11f859045d5ae9f/lib/simple_form/inputs/range_input.rb | lib/simple_form/inputs/range_input.rb | # frozen_string_literal: true
module SimpleForm
module Inputs
class RangeInput < NumericInput
def input(wrapper_options = nil)
if html5?
input_html_options[:type] ||= "range"
input_html_options[:step] ||= 1
end
super
end
end
end
end
| ruby | MIT | 584127a00bfe027ff5fb779fa11f859045d5ae9f | 2026-01-04T15:39:08.979660Z | false |
heartcombo/simple_form | https://github.com/heartcombo/simple_form/blob/584127a00bfe027ff5fb779fa11f859045d5ae9f/lib/simple_form/inputs/priority_input.rb | lib/simple_form/inputs/priority_input.rb | # frozen_string_literal: true
module SimpleForm
module Inputs
class PriorityInput < CollectionSelectInput
def input(wrapper_options = nil)
merged_input_options = merge_wrapper_options(input_html_options, wrapper_options)
send(:"#{input_type}_input", merged_input_options)
end
de... | ruby | MIT | 584127a00bfe027ff5fb779fa11f859045d5ae9f | 2026-01-04T15:39:08.979660Z | false |
heartcombo/simple_form | https://github.com/heartcombo/simple_form/blob/584127a00bfe027ff5fb779fa11f859045d5ae9f/lib/simple_form/inputs/color_input.rb | lib/simple_form/inputs/color_input.rb | # frozen_string_literal: true
module SimpleForm
module Inputs
class ColorInput < Base
def input(wrapper_options = nil)
input_html_options[:type] ||= "color" if html5?
merged_input_options = merge_wrapper_options(input_html_options, wrapper_options)
@builder.text_field(attribute_nam... | ruby | MIT | 584127a00bfe027ff5fb779fa11f859045d5ae9f | 2026-01-04T15:39:08.979660Z | false |
heartcombo/simple_form | https://github.com/heartcombo/simple_form/blob/584127a00bfe027ff5fb779fa11f859045d5ae9f/lib/simple_form/inputs/collection_select_input.rb | lib/simple_form/inputs/collection_select_input.rb | # frozen_string_literal: true
module SimpleForm
module Inputs
class CollectionSelectInput < CollectionInput
def input(wrapper_options = nil)
label_method, value_method = detect_collection_methods
merged_input_options = merge_wrapper_options(input_html_options, wrapper_options)
@bui... | ruby | MIT | 584127a00bfe027ff5fb779fa11f859045d5ae9f | 2026-01-04T15:39:08.979660Z | false |
heartcombo/simple_form | https://github.com/heartcombo/simple_form/blob/584127a00bfe027ff5fb779fa11f859045d5ae9f/lib/simple_form/inputs/collection_radio_buttons_input.rb | lib/simple_form/inputs/collection_radio_buttons_input.rb | # frozen_string_literal: true
module SimpleForm
module Inputs
class CollectionRadioButtonsInput < CollectionInput
def input(wrapper_options = nil)
label_method, value_method = detect_collection_methods
merged_input_options = merge_wrapper_options(input_html_options, wrapper_options)
... | ruby | MIT | 584127a00bfe027ff5fb779fa11f859045d5ae9f | 2026-01-04T15:39:08.979660Z | false |
heartcombo/simple_form | https://github.com/heartcombo/simple_form/blob/584127a00bfe027ff5fb779fa11f859045d5ae9f/lib/simple_form/inputs/date_time_input.rb | lib/simple_form/inputs/date_time_input.rb | # frozen_string_literal: true
module SimpleForm
module Inputs
class DateTimeInput < Base
def input(wrapper_options = nil)
merged_input_options = merge_wrapper_options(input_html_options, wrapper_options)
if use_html5_inputs?
@builder.send(:"#{input_type}_field", attribute_name, me... | ruby | MIT | 584127a00bfe027ff5fb779fa11f859045d5ae9f | 2026-01-04T15:39:08.979660Z | false |
heartcombo/simple_form | https://github.com/heartcombo/simple_form/blob/584127a00bfe027ff5fb779fa11f859045d5ae9f/lib/simple_form/inputs/base.rb | lib/simple_form/inputs/base.rb | # frozen_string_literal: true
require 'active_support/core_ext/string/output_safety'
require 'action_view/helpers'
module SimpleForm
module Inputs
class Base
include ERB::Util
include ActionView::Helpers::TranslationHelper
include SimpleForm::Helpers::Autofocus
include SimpleForm::Helper... | ruby | MIT | 584127a00bfe027ff5fb779fa11f859045d5ae9f | 2026-01-04T15:39:08.979660Z | false |
heartcombo/simple_form | https://github.com/heartcombo/simple_form/blob/584127a00bfe027ff5fb779fa11f859045d5ae9f/lib/simple_form/inputs/collection_check_boxes_input.rb | lib/simple_form/inputs/collection_check_boxes_input.rb | # frozen_string_literal: true
module SimpleForm
module Inputs
class CollectionCheckBoxesInput < CollectionRadioButtonsInput
protected
# Checkbox components do not use the required html tag.
# More info: https://github.com/heartcombo/simple_form/issues/340#issuecomment-2871956
def has_requ... | ruby | MIT | 584127a00bfe027ff5fb779fa11f859045d5ae9f | 2026-01-04T15:39:08.979660Z | false |
heartcombo/simple_form | https://github.com/heartcombo/simple_form/blob/584127a00bfe027ff5fb779fa11f859045d5ae9f/lib/simple_form/inputs/numeric_input.rb | lib/simple_form/inputs/numeric_input.rb | # frozen_string_literal: true
module SimpleForm
module Inputs
class NumericInput < Base
enable :placeholder, :min_max
def input(wrapper_options = nil)
input_html_classes.unshift("numeric")
if html5?
input_html_options[:type] ||= "number"
input_html_options[:step] |... | ruby | MIT | 584127a00bfe027ff5fb779fa11f859045d5ae9f | 2026-01-04T15:39:08.979660Z | false |
heartcombo/simple_form | https://github.com/heartcombo/simple_form/blob/584127a00bfe027ff5fb779fa11f859045d5ae9f/lib/simple_form/inputs/boolean_input.rb | lib/simple_form/inputs/boolean_input.rb | # frozen_string_literal: true
module SimpleForm
module Inputs
class BooleanInput < Base
def input(wrapper_options = nil)
merged_input_options = merge_wrapper_options(input_html_options, wrapper_options)
if nested_boolean_style?
build_hidden_field_for_checkbox +
templat... | ruby | MIT | 584127a00bfe027ff5fb779fa11f859045d5ae9f | 2026-01-04T15:39:08.979660Z | false |
heartcombo/simple_form | https://github.com/heartcombo/simple_form/blob/584127a00bfe027ff5fb779fa11f859045d5ae9f/lib/simple_form/inputs/collection_input.rb | lib/simple_form/inputs/collection_input.rb | # frozen_string_literal: true
module SimpleForm
module Inputs
class CollectionInput < Base
BASIC_OBJECT_CLASSES = [String, Integer, Float, NilClass, Symbol, TrueClass, FalseClass]
BASIC_OBJECT_CLASSES.push(Fixnum, Bignum) unless 1.class == Integer
# Default boolean collection for use with selec... | ruby | MIT | 584127a00bfe027ff5fb779fa11f859045d5ae9f | 2026-01-04T15:39:08.979660Z | false |
heartcombo/simple_form | https://github.com/heartcombo/simple_form/blob/584127a00bfe027ff5fb779fa11f859045d5ae9f/lib/simple_form/inputs/file_input.rb | lib/simple_form/inputs/file_input.rb | # frozen_string_literal: true
module SimpleForm
module Inputs
class FileInput < Base
def input(wrapper_options = nil)
merged_input_options = merge_wrapper_options(input_html_options, wrapper_options)
@builder.file_field(attribute_name, merged_input_options)
end
end
end
end
| ruby | MIT | 584127a00bfe027ff5fb779fa11f859045d5ae9f | 2026-01-04T15:39:08.979660Z | false |
heartcombo/simple_form | https://github.com/heartcombo/simple_form/blob/584127a00bfe027ff5fb779fa11f859045d5ae9f/lib/simple_form/inputs/password_input.rb | lib/simple_form/inputs/password_input.rb | # frozen_string_literal: true
module SimpleForm
module Inputs
class PasswordInput < Base
enable :placeholder, :maxlength, :minlength
def input(wrapper_options = nil)
merged_input_options = merge_wrapper_options(input_html_options, wrapper_options)
@builder.password_field(attribute_na... | ruby | MIT | 584127a00bfe027ff5fb779fa11f859045d5ae9f | 2026-01-04T15:39:08.979660Z | false |
heartcombo/simple_form | https://github.com/heartcombo/simple_form/blob/584127a00bfe027ff5fb779fa11f859045d5ae9f/lib/simple_form/inputs/hidden_input.rb | lib/simple_form/inputs/hidden_input.rb | # frozen_string_literal: true
module SimpleForm
module Inputs
class HiddenInput < Base
disable :label, :errors, :hint, :required
def input(wrapper_options = nil)
merged_input_options = merge_wrapper_options(input_html_options, wrapper_options)
@builder.hidden_field(attribute_name, me... | ruby | MIT | 584127a00bfe027ff5fb779fa11f859045d5ae9f | 2026-01-04T15:39:08.979660Z | false |
heartcombo/simple_form | https://github.com/heartcombo/simple_form/blob/584127a00bfe027ff5fb779fa11f859045d5ae9f/lib/simple_form/inputs/grouped_collection_select_input.rb | lib/simple_form/inputs/grouped_collection_select_input.rb | # frozen_string_literal: true
module SimpleForm
module Inputs
class GroupedCollectionSelectInput < CollectionInput
def input(wrapper_options = nil)
label_method, value_method = detect_collection_methods
merged_input_options = merge_wrapper_options(input_html_options, wrapper_options)
... | ruby | MIT | 584127a00bfe027ff5fb779fa11f859045d5ae9f | 2026-01-04T15:39:08.979660Z | false |
heartcombo/simple_form | https://github.com/heartcombo/simple_form/blob/584127a00bfe027ff5fb779fa11f859045d5ae9f/lib/simple_form/inputs/text_input.rb | lib/simple_form/inputs/text_input.rb | # frozen_string_literal: true
module SimpleForm
module Inputs
class TextInput < Base
enable :placeholder, :maxlength, :minlength
def input(wrapper_options = nil)
merged_input_options = merge_wrapper_options(input_html_options, wrapper_options)
@builder.text_area(attribute_name, merge... | ruby | MIT | 584127a00bfe027ff5fb779fa11f859045d5ae9f | 2026-01-04T15:39:08.979660Z | false |
heartcombo/simple_form | https://github.com/heartcombo/simple_form/blob/584127a00bfe027ff5fb779fa11f859045d5ae9f/lib/simple_form/inputs/weekday_input.rb | lib/simple_form/inputs/weekday_input.rb | # frozen_string_literal: true
module SimpleForm
module Inputs
class WeekdayInput < CollectionSelectInput
enable :placeholder
def input(wrapper_options = nil)
merged_input_options = merge_wrapper_options(input_html_options, wrapper_options)
@builder.weekday_select(attribute_name, inpu... | ruby | MIT | 584127a00bfe027ff5fb779fa11f859045d5ae9f | 2026-01-04T15:39:08.979660Z | false |
heartcombo/simple_form | https://github.com/heartcombo/simple_form/blob/584127a00bfe027ff5fb779fa11f859045d5ae9f/lib/generators/simple_form/install_generator.rb | lib/generators/simple_form/install_generator.rb | # frozen_string_literal: true
module SimpleForm
module Generators
class InstallGenerator < Rails::Generators::Base
desc "Copy SimpleForm default files"
source_root File.expand_path('../templates', __FILE__)
class_option :template_engine, desc: 'Template engine to be invoked (erb, haml or slim).'... | ruby | MIT | 584127a00bfe027ff5fb779fa11f859045d5ae9f | 2026-01-04T15:39:08.979660Z | false |
heartcombo/simple_form | https://github.com/heartcombo/simple_form/blob/584127a00bfe027ff5fb779fa11f859045d5ae9f/lib/generators/simple_form/templates/config/initializers/simple_form_foundation.rb | lib/generators/simple_form/templates/config/initializers/simple_form_foundation.rb | # frozen_string_literal: true
#
# Uncomment this and change the path if necessary to include your own
# components.
# See https://github.com/heartcombo/simple_form#custom-components to know
# more about custom components.
# Dir[Rails.root.join('lib/components/**/*.rb')].each { |f| require f }
#
# Use this setup block t... | ruby | MIT | 584127a00bfe027ff5fb779fa11f859045d5ae9f | 2026-01-04T15:39:08.979660Z | false |
heartcombo/simple_form | https://github.com/heartcombo/simple_form/blob/584127a00bfe027ff5fb779fa11f859045d5ae9f/lib/generators/simple_form/templates/config/initializers/simple_form_bootstrap.rb | lib/generators/simple_form/templates/config/initializers/simple_form_bootstrap.rb | # frozen_string_literal: true
# These defaults are defined and maintained by the community at
# https://github.com/heartcombo/simple_form-bootstrap
# Please submit feedback, changes and tests only there.
# Uncomment this and change the path if necessary to include your own
# components.
# See https://github.com/heart... | ruby | MIT | 584127a00bfe027ff5fb779fa11f859045d5ae9f | 2026-01-04T15:39:08.979660Z | false |
heartcombo/simple_form | https://github.com/heartcombo/simple_form/blob/584127a00bfe027ff5fb779fa11f859045d5ae9f/lib/generators/simple_form/templates/config/initializers/simple_form.rb | lib/generators/simple_form/templates/config/initializers/simple_form.rb | # frozen_string_literal: true
#
# Uncomment this and change the path if necessary to include your own
# components.
# See https://github.com/heartcombo/simple_form#custom-components to know
# more about custom components.
# Dir[Rails.root.join('lib/components/**/*.rb')].each { |f| require f }
#
# Use this setup block t... | ruby | MIT | 584127a00bfe027ff5fb779fa11f859045d5ae9f | 2026-01-04T15:39:08.979660Z | false |
puma/puma | https://github.com/puma/puma/blob/5937d8953a154d69cab13887cc361eef9d7df2a4/.github/workflows/github_actions_info.rb | .github/workflows/github_actions_info.rb | # logs repo/commit info
puts "ENV['GITHUB_WORKFLOW_REF'] #{ENV['GITHUB_WORKFLOW_REF']}\n" \
"ENV['GITHUB_WORKFLOW_SHA'] #{ENV['GITHUB_WORKFLOW_SHA']}\n" \
"ENV['GITHUB_REPOSITORY'] #{ENV['GITHUB_REPOSITORY']}\n" \
"ENV['GITHUB_REF_TYPE'] #{ENV['GITHUB_REF_TYPE']}\n" \
"ENV['GITHUB_REF']... | ruby | BSD-3-Clause | 5937d8953a154d69cab13887cc361eef9d7df2a4 | 2026-01-04T15:39:19.886485Z | false |
puma/puma | https://github.com/puma/puma/blob/5937d8953a154d69cab13887cc361eef9d7df2a4/benchmarks/local/long_tail_hey.rb | benchmarks/local/long_tail_hey.rb | # frozen_string_literal: true
require_relative 'bench_base'
require_relative 'puma_info'
require 'json'
module TestPuma
# This file is called from `long_tail_hey.sh`. It requires `hey`.
# See https://github.com/rakyll/hey.
#
# It starts a `Puma` server, then collects data from one or more runs of hey.
# I... | ruby | BSD-3-Clause | 5937d8953a154d69cab13887cc361eef9d7df2a4 | 2026-01-04T15:39:19.886485Z | false |
puma/puma | https://github.com/puma/puma/blob/5937d8953a154d69cab13887cc361eef9d7df2a4/benchmarks/local/bench_base.rb | benchmarks/local/bench_base.rb | # frozen_string_literal: true
require 'optparse'
module TestPuma
HOST4 = ENV.fetch('PUMA_TEST_HOST4', '127.0.0.1')
HOST6 = ENV.fetch('PUMA_TEST_HOST6', '::1')
PORT = ENV.fetch('PUMA_TEST_PORT', 40001).to_i
# Array of response body sizes. If specified, set by ENV['PUMA_TEST_SIZES']
#
SIZES = if (t = EN... | ruby | BSD-3-Clause | 5937d8953a154d69cab13887cc361eef9d7df2a4 | 2026-01-04T15:39:19.886485Z | false |
puma/puma | https://github.com/puma/puma/blob/5937d8953a154d69cab13887cc361eef9d7df2a4/benchmarks/local/puma_info.rb | benchmarks/local/puma_info.rb | # frozen_string_literal: true
require 'optparse'
require_relative '../../lib/puma/state_file'
require_relative '../../lib/puma/const'
require_relative '../../lib/puma/detect'
require_relative '../../lib/puma/configuration'
require 'uri'
require 'socket'
require 'json'
module TestPuma
# Similar to puma_ctl.rb, but ... | ruby | BSD-3-Clause | 5937d8953a154d69cab13887cc361eef9d7df2a4 | 2026-01-04T15:39:19.886485Z | false |
puma/puma | https://github.com/puma/puma/blob/5937d8953a154d69cab13887cc361eef9d7df2a4/benchmarks/local/response_time_wrk.rb | benchmarks/local/response_time_wrk.rb | # frozen_string_literal: true
require_relative 'bench_base'
require_relative 'puma_info'
module TestPuma
# This file is called from `response_time_wrk.sh`. It requires `wrk`.
# We suggest using https://github.com/ioquatix/wrk
#
# It starts a `Puma` server, then collects data from one or more runs of wrk.
... | ruby | BSD-3-Clause | 5937d8953a154d69cab13887cc361eef9d7df2a4 | 2026-01-04T15:39:19.886485Z | false |
puma/puma | https://github.com/puma/puma/blob/5937d8953a154d69cab13887cc361eef9d7df2a4/benchmarks/local/sleep_fibonacci_test.rb | benchmarks/local/sleep_fibonacci_test.rb | # frozen_string_literal: true
=begin
change to benchmarks/local folder
ruby sleep_fibonacci_test.rb s
ruby sleep_fibonacci_test.rb m
ruby sleep_fibonacci_test.rb l
ruby sleep_fibonacci_test.rb a
ruby sleep_fibonacci_test.rb 0.001,0.005,0.01,0.02,0.04
=end
module SleepFibonacciTest
class << self
TIME_RE = / ... | ruby | BSD-3-Clause | 5937d8953a154d69cab13887cc361eef9d7df2a4 | 2026-01-04T15:39:19.886485Z | false |
puma/puma | https://github.com/puma/puma/blob/5937d8953a154d69cab13887cc361eef9d7df2a4/benchmarks/local/sinatra/puma.rb | benchmarks/local/sinatra/puma.rb | silence_single_worker_warning
workers 1
before_fork do
require "puma_worker_killer"
PumaWorkerKiller.config do |config|
config.ram = 1024 # mb
config.frequency = 0.3 # seconds
config.reaper_status_logs = true # Log memory: PumaWorkerKiller: Consuming 54.34765625 mb with master and 1 workers.
end
... | ruby | BSD-3-Clause | 5937d8953a154d69cab13887cc361eef9d7df2a4 | 2026-01-04T15:39:19.886485Z | false |
puma/puma | https://github.com/puma/puma/blob/5937d8953a154d69cab13887cc361eef9d7df2a4/tools/trickletest.rb | tools/trickletest.rb | require 'socket'
require 'stringio'
def do_test(st, chunk)
s = TCPSocket.new('127.0.0.1',ARGV[0].to_i);
req = StringIO.new(st)
nout = 0
randstop = rand(st.length / 10)
STDERR.puts "stopping after: #{randstop}"
begin
while data = req.read(chunk)
nout += s.write(data)
s.flush
sleep 0.1... | ruby | BSD-3-Clause | 5937d8953a154d69cab13887cc361eef9d7df2a4 | 2026-01-04T15:39:19.886485Z | false |
puma/puma | https://github.com/puma/puma/blob/5937d8953a154d69cab13887cc361eef9d7df2a4/test/test_fiber_storage_application.rb | test/test_fiber_storage_application.rb | # frozen_string_literal: true
# Released under the MIT License.
# Copyright, 2023, by Samuel Williams.
require_relative "helper"
require "puma/server"
class FiberStorageApplication
def call(env)
count = (Fiber[:request_count] ||= 0)
Fiber[:request_count] += 1
[200, {"Content-Type" => "text/plain"}, [c... | ruby | BSD-3-Clause | 5937d8953a154d69cab13887cc361eef9d7df2a4 | 2026-01-04T15:39:19.886485Z | false |
puma/puma | https://github.com/puma/puma/blob/5937d8953a154d69cab13887cc361eef9d7df2a4/test/test_app_status.rb | test/test_app_status.rb | # frozen_string_literal: true
require_relative "helper"
require "puma/app/status"
require "rack"
class TestAppStatus < PumaTest
class FakeServer
def initialize
@status = :running
end
attr_reader :status
def stop
@status = :stop
end
def halt
@status = :halt
end
... | ruby | BSD-3-Clause | 5937d8953a154d69cab13887cc361eef9d7df2a4 | 2026-01-04T15:39:19.886485Z | false |
puma/puma | https://github.com/puma/puma/blob/5937d8953a154d69cab13887cc361eef9d7df2a4/test/test_puma_localhost_authority.rb | test/test_puma_localhost_authority.rb | # frozen_string_literal: true
# Nothing in this file runs if Puma isn't compiled with ssl support
#
# helper is required first since it loads Puma, which needs to be
# loaded so HAS_SSL is defined
require_relative "helper"
require "localhost/authority"
if ::Puma::HAS_SSL && !Puma::IS_JRUBY
require "puma/minissl"
... | ruby | BSD-3-Clause | 5937d8953a154d69cab13887cc361eef9d7df2a4 | 2026-01-04T15:39:19.886485Z | false |
puma/puma | https://github.com/puma/puma/blob/5937d8953a154d69cab13887cc361eef9d7df2a4/test/test_redirect_io.rb | test/test_redirect_io.rb | # frozen_string_literal: true
require_relative "helper"
require_relative "helpers/integration"
class TestRedirectIO < TestIntegration
parallelize_me!
FILE_STR = 'puma startup'
def setup
skip_unless_signal_exist? :HUP
super
# Keep the Tempfile instances alive to avoid being GC'd
@out_file = Te... | ruby | BSD-3-Clause | 5937d8953a154d69cab13887cc361eef9d7df2a4 | 2026-01-04T15:39:19.886485Z | false |
puma/puma | https://github.com/puma/puma/blob/5937d8953a154d69cab13887cc361eef9d7df2a4/test/test_http10.rb | test/test_http10.rb | # frozen_string_literal: true
require_relative "helper"
require "puma/puma_http11"
class Http10ParserTest < PumaTest
def test_parse_simple
parser = Puma::HttpParser.new
req = {}
http = "GET / HTTP/1.0\r\n\r\n"
nread = parser.execute(req, http, 0)
assert nread == http.length, "Failed to parse t... | ruby | BSD-3-Clause | 5937d8953a154d69cab13887cc361eef9d7df2a4 | 2026-01-04T15:39:19.886485Z | false |
puma/puma | https://github.com/puma/puma/blob/5937d8953a154d69cab13887cc361eef9d7df2a4/test/test_minissl.rb | test/test_minissl.rb | require_relative "helper"
require "puma/minissl" if ::Puma::HAS_SSL
class TestMiniSSL < PumaTest
if Puma.jruby?
def test_raises_with_invalid_keystore_file
ctx = Puma::MiniSSL::Context.new
exception = assert_raises(ArgumentError) { ctx.keystore = "/no/such/keystore" }
assert_equal("Keystore f... | ruby | BSD-3-Clause | 5937d8953a154d69cab13887cc361eef9d7df2a4 | 2026-01-04T15:39:19.886485Z | false |
puma/puma | https://github.com/puma/puma/blob/5937d8953a154d69cab13887cc361eef9d7df2a4/test/test_skip_systemd.rb | test/test_skip_systemd.rb | # frozen_string_literal: true
require_relative "helper"
require_relative "helpers/integration"
require "puma/plugin"
class TestSkipSystemd < TestIntegration
def setup
skip_unless :linux
skip_if :jruby
super
end
def teardown
super unless skipped?
end
def test_systemd_plugin_not_loaded
... | ruby | BSD-3-Clause | 5937d8953a154d69cab13887cc361eef9d7df2a4 | 2026-01-04T15:39:19.886485Z | false |
puma/puma | https://github.com/puma/puma/blob/5937d8953a154d69cab13887cc361eef9d7df2a4/test/test_request_invalid_multiple.rb | test/test_request_invalid_multiple.rb | # frozen_string_literal: true
require_relative "helper"
require_relative "helpers/test_puma/puma_socket"
# These tests check for invalid request headers and metadata.
# Content-Length, Transfer-Encoding, and chunked body size
# values are checked for validity
#
# See https://httpwg.org/specs/rfc9112.html
#
# https://... | ruby | BSD-3-Clause | 5937d8953a154d69cab13887cc361eef9d7df2a4 | 2026-01-04T15:39:19.886485Z | false |
puma/puma | https://github.com/puma/puma/blob/5937d8953a154d69cab13887cc361eef9d7df2a4/test/test_response_header.rb | test/test_response_header.rb | # frozen_string_literal: true
require_relative "helper"
require "puma/events"
require "net/http"
require "nio"
class TestResponseHeader < PumaTest
parallelize_me!
# this file has limited response length, so 10kB works.
CLIENT_SYSREAD_LENGTH = 10_240
def setup
@host = "127.0.0.1"
@ios = []
@app... | ruby | BSD-3-Clause | 5937d8953a154d69cab13887cc361eef9d7df2a4 | 2026-01-04T15:39:19.886485Z | false |
puma/puma | https://github.com/puma/puma/blob/5937d8953a154d69cab13887cc361eef9d7df2a4/test/test_iobuffer.rb | test/test_iobuffer.rb | # frozen_string_literal: true
require_relative "helper"
require "puma/io_buffer"
class TestIOBuffer < PumaTest
attr_accessor :iobuf
def setup
self.iobuf = Puma::IOBuffer.new
end
def test_initial_size
assert_equal 0, iobuf.size
end
def test_append_op
iobuf << "abc"
assert_equal "abc", io... | ruby | BSD-3-Clause | 5937d8953a154d69cab13887cc361eef9d7df2a4 | 2026-01-04T15:39:19.886485Z | false |
puma/puma | https://github.com/puma/puma/blob/5937d8953a154d69cab13887cc361eef9d7df2a4/test/test_worker_gem_independence.rb | test/test_worker_gem_independence.rb | # frozen_string_literal: true
require_relative "helper"
require_relative "helpers/integration"
class TestWorkerGemIndependence < TestIntegration
ENV_RUBYOPT = {
'RUBYOPT' => ENV['RUBYOPT']
}
def setup
skip_unless :fork
super
end
def teardown
return if skipped?
FileUtils.rm current_rel... | ruby | BSD-3-Clause | 5937d8953a154d69cab13887cc361eef9d7df2a4 | 2026-01-04T15:39:19.886485Z | false |
puma/puma | https://github.com/puma/puma/blob/5937d8953a154d69cab13887cc361eef9d7df2a4/test/test_preserve_bundler_env.rb | test/test_preserve_bundler_env.rb | # frozen_string_literal: true
require_relative "helper"
require_relative "helpers/integration"
class TestPreserveBundlerEnv < TestIntegration
def setup
skip_unless :fork
super
end
def teardown
return if skipped?
FileUtils.rm current_release_symlink, force: true
super
end
# It does not ... | ruby | BSD-3-Clause | 5937d8953a154d69cab13887cc361eef9d7df2a4 | 2026-01-04T15:39:19.886485Z | false |
puma/puma | https://github.com/puma/puma/blob/5937d8953a154d69cab13887cc361eef9d7df2a4/test/test_web_server.rb | test/test_web_server.rb | # frozen_string_literal: true
# Copyright (c) 2011 Evan Phoenix
# Copyright (c) 2005 Zed A. Shaw
require_relative "helper"
require "puma/server"
class TestHandler
attr_reader :ran_test
def call(env)
@ran_test = true
[200, {"Content-Type" => "text/plain"}, ["hello!"]]
end
end
class WebServerTest < Pu... | ruby | BSD-3-Clause | 5937d8953a154d69cab13887cc361eef9d7df2a4 | 2026-01-04T15:39:19.886485Z | false |
puma/puma | https://github.com/puma/puma/blob/5937d8953a154d69cab13887cc361eef9d7df2a4/test/test_cli.rb | test/test_cli.rb | # frozen_string_literal: true
require_relative "helper"
require_relative "helpers/ssl" if ::Puma::HAS_SSL
require_relative "helpers/tmp_path"
require_relative "helpers/test_puma/puma_socket"
require "puma/cli"
require "json"
require "psych"
class TestCLI < PumaTest
include SSLHelper if ::Puma::HAS_SSL
include Tm... | ruby | BSD-3-Clause | 5937d8953a154d69cab13887cc361eef9d7df2a4 | 2026-01-04T15:39:19.886485Z | false |
puma/puma | https://github.com/puma/puma/blob/5937d8953a154d69cab13887cc361eef9d7df2a4/test/test_json_serialization.rb | test/test_json_serialization.rb | # frozen_string_literal: true
require_relative "helper"
require "json"
require "puma/json_serialization"
class TestJSONSerialization < PumaTest
parallelize_me! unless JRUBY_HEAD
def test_json_generates_string_for_hash_with_string_keys
value = { "key" => "value" }
assert_puma_json_generates_string '{"key"... | ruby | BSD-3-Clause | 5937d8953a154d69cab13887cc361eef9d7df2a4 | 2026-01-04T15:39:19.886485Z | false |
puma/puma | https://github.com/puma/puma/blob/5937d8953a154d69cab13887cc361eef9d7df2a4/test/test_events.rb | test/test_events.rb | # frozen_string_literal: true
require 'puma/events'
require_relative "helper"
class TestEvents < PumaTest
def test_register_callback_with_block
res = false
events = Puma::Events.new
events.register(:exec) { res = true }
events.fire(:exec)
assert_equal true, res
end
def test_register_cal... | ruby | BSD-3-Clause | 5937d8953a154d69cab13887cc361eef9d7df2a4 | 2026-01-04T15:39:19.886485Z | false |
puma/puma | https://github.com/puma/puma/blob/5937d8953a154d69cab13887cc361eef9d7df2a4/test/test_plugin.rb | test/test_plugin.rb | # frozen_string_literal: true
require_relative "helper"
require_relative "helpers/integration"
class TestPlugin < TestIntegration
def test_plugin
@control_tcp_port = UniquePort.call
Dir.mkdir("tmp") unless Dir.exist?("tmp")
cli_server "--control-url tcp://#{HOST}:#{@control_tcp_port} --control-token #... | ruby | BSD-3-Clause | 5937d8953a154d69cab13887cc361eef9d7df2a4 | 2026-01-04T15:39:19.886485Z | false |
puma/puma | https://github.com/puma/puma/blob/5937d8953a154d69cab13887cc361eef9d7df2a4/test/test_unix_socket.rb | test/test_unix_socket.rb | # frozen_string_literal: true
require_relative "helper"
require_relative "helpers/tmp_path"
class TestPumaUnixSocket < PumaTest
include TmpPath
App = lambda { |env| [200, {}, ["Works"]] }
def teardown
return if skipped?
@server.stop(true)
end
def server_unix(type)
@tmp_socket_path = type == :... | ruby | BSD-3-Clause | 5937d8953a154d69cab13887cc361eef9d7df2a4 | 2026-01-04T15:39:19.886485Z | false |
puma/puma | https://github.com/puma/puma/blob/5937d8953a154d69cab13887cc361eef9d7df2a4/test/test_integration_ssl.rb | test/test_integration_ssl.rb | # frozen_string_literal: true
require_relative 'helper'
require_relative "helpers/integration"
if ::Puma::HAS_SSL # don't load any files if no ssl support
require "net/http"
require "openssl"
require_relative "helpers/test_puma/puma_socket"
end
# These tests are used to verify that Puma works with SSL sockets.... | ruby | BSD-3-Clause | 5937d8953a154d69cab13887cc361eef9d7df2a4 | 2026-01-04T15:39:19.886485Z | false |
puma/puma | https://github.com/puma/puma/blob/5937d8953a154d69cab13887cc361eef9d7df2a4/test/test_url_map.rb | test/test_url_map.rb | # frozen_string_literal: true
require_relative "helper"
require_relative "helpers/integration"
class TestURLMap < TestIntegration
def teardown
return if skipped?
super
end
# make sure the mapping defined in url_map_test/config.ru works
def test_basic_url_mapping
skip_if :jruby
env = { "BUNDL... | ruby | BSD-3-Clause | 5937d8953a154d69cab13887cc361eef9d7df2a4 | 2026-01-04T15:39:19.886485Z | false |
puma/puma | https://github.com/puma/puma/blob/5937d8953a154d69cab13887cc361eef9d7df2a4/test/test_error_logger.rb | test/test_error_logger.rb | # frozen_string_literal: true
require 'puma/error_logger'
require_relative "helper"
class TestErrorLogger < PumaTest
Req = Struct.new(:env, :body)
def test_stdio
error_logger = Puma::ErrorLogger.stdio
assert_equal STDERR, error_logger.ioerr
end
def test_stdio_respects_sync
error_logger = Puma:... | ruby | BSD-3-Clause | 5937d8953a154d69cab13887cc361eef9d7df2a4 | 2026-01-04T15:39:19.886485Z | false |
puma/puma | https://github.com/puma/puma/blob/5937d8953a154d69cab13887cc361eef9d7df2a4/test/test_launcher.rb | test/test_launcher.rb | # frozen_string_literal: true
require_relative "helper"
require_relative "helpers/tmp_path"
require "puma/configuration"
require 'puma/log_writer'
# Do not add any tests creating workers to this, as Cluster may call `Process.waitall`,
# which may cause issues in the test process.
# Intermittent failures & errors wh... | ruby | BSD-3-Clause | 5937d8953a154d69cab13887cc361eef9d7df2a4 | 2026-01-04T15:39:19.886485Z | false |
puma/puma | https://github.com/puma/puma/blob/5937d8953a154d69cab13887cc361eef9d7df2a4/test/test_config.rb | test/test_config.rb | # frozen_string_literal: true
require_relative "helper"
require "puma/configuration"
require 'puma/log_writer'
require 'rack'
class TestConfigFile < PumaTest
parallelize_me!
def test_default_max_threads
max_threads = 16
max_threads = 5 if RUBY_ENGINE.nil? || RUBY_ENGINE == 'ruby'
conf = Puma::Config... | ruby | BSD-3-Clause | 5937d8953a154d69cab13887cc361eef9d7df2a4 | 2026-01-04T15:39:19.886485Z | false |
puma/puma | https://github.com/puma/puma/blob/5937d8953a154d69cab13887cc361eef9d7df2a4/test/test_example_cert_expiration.rb | test/test_example_cert_expiration.rb | # frozen_string_literal: true
require_relative 'helper'
require 'openssl'
#
# Thes are tests to ensure that the checked in certs in the ./examples/
# directory are valid and work as expected.
#
# These tests will start to fail 1 month before the certs expire
#
class TestExampleCertExpiration < PumaTest
EXAMPLES_DIR... | ruby | BSD-3-Clause | 5937d8953a154d69cab13887cc361eef9d7df2a4 | 2026-01-04T15:39:19.886485Z | false |
puma/puma | https://github.com/puma/puma/blob/5937d8953a154d69cab13887cc361eef9d7df2a4/test/test_log_writer.rb | test/test_log_writer.rb | require 'puma/detect'
require 'puma/log_writer'
require_relative "helper"
class TestLogWriter < PumaTest
def test_null
log_writer = Puma::LogWriter.null
assert_instance_of Puma::NullIO, log_writer.stdout
assert_instance_of Puma::NullIO, log_writer.stderr
assert_equal log_writer.stdout, log_writer.st... | ruby | BSD-3-Clause | 5937d8953a154d69cab13887cc361eef9d7df2a4 | 2026-01-04T15:39:19.886485Z | false |
puma/puma | https://github.com/puma/puma/blob/5937d8953a154d69cab13887cc361eef9d7df2a4/test/test_pumactl.rb | test/test_pumactl.rb | # frozen_string_literal: true
require_relative "helper"
require_relative "helpers/ssl"
require 'pathname'
require 'puma/control_cli'
class TestPumaControlCli < PumaTest
include SSLHelper
def setup
# use a pipe to get info across thread boundary
@wait, @ready = IO.pipe
end
def wait_booted(log: nil)
... | ruby | BSD-3-Clause | 5937d8953a154d69cab13887cc361eef9d7df2a4 | 2026-01-04T15:39:19.886485Z | false |
puma/puma | https://github.com/puma/puma/blob/5937d8953a154d69cab13887cc361eef9d7df2a4/test/test_puma_server_hijack.rb | test/test_puma_server_hijack.rb | # frozen_string_literal: true
require_relative "helper"
require_relative "helpers/test_puma/puma_socket"
require "puma/events"
require "puma/server"
require "net/http"
require "nio"
require "rack"
require "rack/body_proxy"
# Tests check both the proper passing of the socket to the app, and also calling
# of `body.cl... | ruby | BSD-3-Clause | 5937d8953a154d69cab13887cc361eef9d7df2a4 | 2026-01-04T15:39:19.886485Z | false |
puma/puma | https://github.com/puma/puma/blob/5937d8953a154d69cab13887cc361eef9d7df2a4/test/test_puma_server.rb | test/test_puma_server.rb | # frozen_string_literal: true
require_relative "helper"
require_relative "helpers/test_puma/puma_socket"
require "puma/events"
require "puma/server"
require "nio"
require "ipaddr"
class WithoutBacktraceError < StandardError
def backtrace; nil; end
def message; "no backtrace error"; end
end
class TestPumaServer <... | ruby | BSD-3-Clause | 5937d8953a154d69cab13887cc361eef9d7df2a4 | 2026-01-04T15:39:19.886485Z | true |
puma/puma | https://github.com/puma/puma/blob/5937d8953a154d69cab13887cc361eef9d7df2a4/test/test_normalize.rb | test/test_normalize.rb | # frozen_string_literal: true
require_relative "helper"
require "puma/request"
class TestNormalize < PumaTest
parallelize_me!
include Puma::Request
def test_comma_headers
env = {
"HTTP_X_FORWARDED_FOR" => "1.1.1.1",
"HTTP_X_FORWARDED,FOR" => "2.2.2.2",
}
req_env_post_parse env
e... | ruby | BSD-3-Clause | 5937d8953a154d69cab13887cc361eef9d7df2a4 | 2026-01-04T15:39:19.886485Z | false |
puma/puma | https://github.com/puma/puma/blob/5937d8953a154d69cab13887cc361eef9d7df2a4/test/test_out_of_band_server.rb | test/test_out_of_band_server.rb | # frozen_string_literal: true
require_relative "helper"
class TestOutOfBandServer < PumaTest
parallelize_me!
def setup
@ios = []
@server = nil
@oob_finished = ConditionVariable.new
@app_finished = ConditionVariable.new
end
def teardown
@oob_finished.broadcast
@app_finished.broadcast
... | ruby | BSD-3-Clause | 5937d8953a154d69cab13887cc361eef9d7df2a4 | 2026-01-04T15:39:19.886485Z | false |
puma/puma | https://github.com/puma/puma/blob/5937d8953a154d69cab13887cc361eef9d7df2a4/test/test_web_concurrency_auto.rb | test/test_web_concurrency_auto.rb | # frozen_string_literal: true
require_relative "helper"
require_relative "helpers/integration"
require_relative "helpers/test_puma/puma_socket"
require "puma/configuration"
require 'puma/log_writer'
class TestWebConcurrencyAuto < TestIntegration
include TestPuma::PumaSocket
ENV_WC_TEST = {
# -W0 removes l... | ruby | BSD-3-Clause | 5937d8953a154d69cab13887cc361eef9d7df2a4 | 2026-01-04T15:39:19.886485Z | false |
puma/puma | https://github.com/puma/puma/blob/5937d8953a154d69cab13887cc361eef9d7df2a4/test/test_integration_cluster.rb | test/test_integration_cluster.rb | # frozen_string_literal: true
require_relative "helper"
require_relative "helpers/integration"
require "puma/configuration"
require "time"
class TestIntegrationCluster < TestIntegration
parallelize_me! if ::Puma.mri?
def workers ; 2 ; end
def setup
skip_unless :fork
super
end
def teardown
r... | ruby | BSD-3-Clause | 5937d8953a154d69cab13887cc361eef9d7df2a4 | 2026-01-04T15:39:19.886485Z | false |
puma/puma | https://github.com/puma/puma/blob/5937d8953a154d69cab13887cc361eef9d7df2a4/test/test_rack_handler.rb | test/test_rack_handler.rb | # frozen_string_literal: true
require_relative "helper"
# Most tests check that ::Rack::Handler::Puma works by itself
# RackUp#test_bin runs Puma using the rackup bin file
module TestRackUp
require "rack/handler/puma"
require "puma/events"
begin
require 'rackup/version'
rescue LoadError
end
class Te... | ruby | BSD-3-Clause | 5937d8953a154d69cab13887cc361eef9d7df2a4 | 2026-01-04T15:39:19.886485Z | false |
puma/puma | https://github.com/puma/puma/blob/5937d8953a154d69cab13887cc361eef9d7df2a4/test/test_null_io.rb | test/test_null_io.rb | # frozen_string_literal: true
require_relative "helper"
require "puma/null_io"
class TestNullIO < PumaTest
parallelize_me!
attr_accessor :nio
def setup
self.nio = Puma::NullIO.new
end
def test_eof_returns_true
assert nio.eof?
end
def test_gets_returns_nil
assert_nil nio.gets
end
de... | ruby | BSD-3-Clause | 5937d8953a154d69cab13887cc361eef9d7df2a4 | 2026-01-04T15:39:19.886485Z | false |
puma/puma | https://github.com/puma/puma/blob/5937d8953a154d69cab13887cc361eef9d7df2a4/test/test_cluster_accept_loop_delay.rb | test/test_cluster_accept_loop_delay.rb | # frozen_string_literal: true
require_relative "helper"
require "puma/cluster_accept_loop_delay"
class TestClusterAcceptLoopDelay < PumaTest
parallelize_me!
def test_off_when_fewer_than_two_workers
cal_delay = Puma::ClusterAcceptLoopDelay.new(
workers: 2,
max_delay: 1
)
assert_equal true,... | ruby | BSD-3-Clause | 5937d8953a154d69cab13887cc361eef9d7df2a4 | 2026-01-04T15:39:19.886485Z | false |
puma/puma | https://github.com/puma/puma/blob/5937d8953a154d69cab13887cc361eef9d7df2a4/test/test_puma_server_current.rb | test/test_puma_server_current.rb | # frozen_string_literal: true
# Released under the MIT License.
# Copyright, 2023, by Samuel Williams.
require_relative "helper"
require "puma/server"
class PumaServerCurrentApplication
def call(env)
[200, {"Content-Type" => "text/plain"}, [Puma::Server.current.to_s]]
end
end
class PumaServerCurrentTest < ... | ruby | BSD-3-Clause | 5937d8953a154d69cab13887cc361eef9d7df2a4 | 2026-01-04T15:39:19.886485Z | false |
puma/puma | https://github.com/puma/puma/blob/5937d8953a154d69cab13887cc361eef9d7df2a4/test/test_integration_pumactl.rb | test/test_integration_pumactl.rb | # frozen_string_literal: true
require_relative "helper"
require_relative "helpers/integration"
class TestIntegrationPumactl < TestIntegration
include TmpPath
parallelize_me! if ::Puma.mri?
def workers ; 2 ; end
def setup
super
@control_path = nil
@state_path = tmp_path('.state')
end
def tea... | ruby | BSD-3-Clause | 5937d8953a154d69cab13887cc361eef9d7df2a4 | 2026-01-04T15:39:19.886485Z | false |
puma/puma | https://github.com/puma/puma/blob/5937d8953a154d69cab13887cc361eef9d7df2a4/test/test_integration_single.rb | test/test_integration_single.rb | # frozen_string_literal: true
require_relative "helper"
require_relative "helpers/integration"
class TestIntegrationSingle < TestIntegration
parallelize_me! if ::Puma::IS_MRI
def workers ; 0 ; end
def test_hot_restart_does_not_drop_connections_threads
ttl_reqs = Puma.windows? ? 500 : 1_000
restart_doe... | ruby | BSD-3-Clause | 5937d8953a154d69cab13887cc361eef9d7df2a4 | 2026-01-04T15:39:19.886485Z | false |
puma/puma | https://github.com/puma/puma/blob/5937d8953a154d69cab13887cc361eef9d7df2a4/test/test_fiber_local_application.rb | test/test_fiber_local_application.rb | # frozen_string_literal: true
# Released under the MIT License.
# Copyright, 2023, by Samuel Williams.
require_relative "helper"
require "puma/server"
class FiberLocalApplication
def call(env)
# Just in case you didn't know, this is fiber local...
count = (Thread.current[:request_count] ||= 0)
Thread.... | ruby | BSD-3-Clause | 5937d8953a154d69cab13887cc361eef9d7df2a4 | 2026-01-04T15:39:19.886485Z | false |
puma/puma | https://github.com/puma/puma/blob/5937d8953a154d69cab13887cc361eef9d7df2a4/test/helper.rb | test/helper.rb | # frozen_string_literal: true
# Copyright (c) 2011 Evan Phoenix
# Copyright (c) 2005 Zed A. Shaw
# WIth GitHub Actions, OS's `/tmp` folder may be on a HDD, while
# ENV['RUNNER_TEMP'] is an SSD. Faster.
if ENV['GITHUB_ACTIONS'] == 'true'
ENV['TMPDIR'] = ENV['RUNNER_TEMP']
end
require "securerandom"
# needs to be l... | ruby | BSD-3-Clause | 5937d8953a154d69cab13887cc361eef9d7df2a4 | 2026-01-04T15:39:19.886485Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.