source stringclasses 1
value | repo stringlengths 5 63 | repo_url stringlengths 24 82 | path stringlengths 5 167 | language stringclasses 1
value | license stringclasses 5
values | stars int64 10 51.4k | ref stringclasses 23
values | size_bytes int64 200 258k | text stringlengths 137 258k |
|---|---|---|---|---|---|---|---|---|---|
github | hanami/hanami | https://github.com/hanami/hanami | lib/hanami/config.rb | Ruby | mit | 6,362 | main | 14,885 | # frozen_string_literal: true
require "uri"
require "pathname"
require "dry/configurable"
require "dry/inflector"
require_relative "constants"
require_relative "universal_logger"
module Hanami
# Hanami app config
#
# @since 2.0.0
class Config
include Dry::Configurable
# @!attribute [rw] root
# ... |
github | hanami/hanami | https://github.com/hanami/hanami | lib/hanami/port.rb | Ruby | mit | 6,362 | main | 837 | # frozen_string_literal: true
module Hanami
# @since 2.0.1
# @api private
module Port
# @since 2.0.1
# @api private
DEFAULT = 2300
# @since 2.0.1
# @api private
ENV_VAR = "HANAMI_PORT"
# @since 2.0.1
# @api private
def self.call(value, env = ENV.fetch(ENV_VAR, nil))
re... |
github | hanami/hanami | https://github.com/hanami/hanami | lib/hanami/version.rb | Ruby | mit | 6,362 | main | 716 | # frozen_string_literal: true
module Hanami
# Hanami version
#
# @since 0.9.0
# @api private
module Version
# @api public
VERSION = "2.3.2"
# @since 0.9.0
# @api private
def self.version
VERSION
end
# @since 0.9.0
# @api private
def self.gem_requirement
if pr... |
github | hanami/hanami | https://github.com/hanami/hanami | lib/hanami/extensions.rb | Ruby | mit | 6,362 | main | 587 | # frozen_string_literal: true
if Hanami.bundled?("hanami-db")
require_relative "extensions/db/repo"
end
if Hanami.bundled?("hanami-action")
require_relative "extensions/action"
end
if Hanami.bundled?("hanami-view")
require "hanami/view"
require_relative "extensions/view"
require_relative "extensions/view/c... |
github | hanami/hanami | https://github.com/hanami/hanami | lib/hanami/universal_logger.rb | Ruby | mit | 6,362 | main | 7,304 | # frozen_string_literal: true
require "json"
module Hanami
# An adapter that optionally wraps the logger configured for a Hanami app. Ensures that both
# structured and tagged logging can be used across the Hanami framework.
#
# Provides `.call` as its main entrypoint, expecting a logger object. If a compatib... |
github | hanami/hanami | https://github.com/hanami/hanami | lib/hanami/provider_registrar.rb | Ruby | mit | 6,362 | main | 550 | # frozen_string_literal: true
# @api private
# @since 2.2.0
module Hanami
class ProviderRegistrar < Dry::System::ProviderRegistrar
def self.for_slice(slice)
Class.new(self) do
define_singleton_method(:new) do |container|
super(container, slice)
end
end
end
attr_read... |
github | hanami/hanami | https://github.com/hanami/hanami | lib/hanami/slice_name.rb | Ruby | mit | 6,362 | main | 2,679 | # frozen_string_literal: true
require_relative "constants"
module Hanami
# Represents the name of an {App} or {Slice}.
#
# @see Slice::ClassMethods#slice_name
# @see App::ClassMethods#app_name
#
# @api public
# @since 2.0.0
class SliceName
# Returns a new SliceName for the slice or app.
#
... |
github | hanami/hanami | https://github.com/hanami/hanami | lib/hanami/slice_configurable.rb | Ruby | mit | 6,362 | main | 1,900 | # frozen_string_literal: true
require_relative "constants"
require_relative "errors"
module Hanami
# Calls `configure_for_slice(slice)` on the extended class whenever it is first
# subclassed within a module namespace corresponding to a slice.
#
# @example
# class BaseClass
# extend Hanami::SliceCon... |
github | hanami/hanami | https://github.com/hanami/hanami | lib/hanami/slice_registrar.rb | Ruby | mit | 6,362 | main | 6,550 | # frozen_string_literal: true
require_relative "constants"
module Hanami
# @api private
class SliceRegistrar
VALID_SLICE_NAME_RE = /^[a-z][a-z0-9_]*$/
SLICE_DELIMITER = CONTAINER_KEY_DELIMITER
attr_reader :parent, :slices
private :parent, :slices
def initialize(parent)
@parent = parent... |
github | hanami/hanami | https://github.com/hanami/hanami | lib/hanami/errors.rb | Ruby | mit | 6,362 | main | 769 | # frozen_string_literal: true
module Hanami
# Base class for all Hanami errors.
#
# @api public
# @since 2.0.0
Error = Class.new(StandardError)
# Error raised when {Hanami::App} fails to load.
#
# @api public
# @since 2.0.0
AppLoadError = Class.new(Error)
# Error raised when an {Hanami::Slice} ... |
github | hanami/hanami | https://github.com/hanami/hanami | lib/hanami/constants.rb | Ruby | mit | 6,362 | main | 1,275 | # frozen_string_literal: true
module Hanami
# @api private
CONTAINER_KEY_DELIMITER = "."
private_constant :CONTAINER_KEY_DELIMITER
# @api private
MODULE_DELIMITER = "::"
private_constant :MODULE_DELIMITER
# @api private
PATH_DELIMITER = "/"
private_constant :PATH_DELIMITER
# @api private
APP_P... |
github | hanami/hanami | https://github.com/hanami/hanami | lib/hanami/slice.rb | Ruby | mit | 6,362 | main | 36,073 | # frozen_string_literal: true
require "zeitwerk"
require "dry/system"
require_relative "constants"
require_relative "errors"
module Hanami
# A slice represents any distinct area of concern within an Hanami app.
#
# For smaller apps, a slice may encompass the whole app itself (see
# {Hanami::App}), whereas la... |
github | hanami/hanami | https://github.com/hanami/hanami | lib/hanami/settings.rb | Ruby | mit | 6,362 | main | 7,416 | # frozen_string_literal: true
require "dry/core/constants"
require "dry/configurable"
require_relative "errors"
module Hanami
# Provides user-defined settings for an Hanami app or slice.
#
# Define your own settings by inheriting from this class in `config/settings.rb` within an app or
# slice. Your settings ... |
github | hanami/hanami | https://github.com/hanami/hanami | lib/hanami/app.rb | Ruby | mit | 6,362 | main | 6,232 | # frozen_string_literal: true
require_relative "constants"
require_relative "env"
module Hanami
# The Hanami app is a singular slice tasked with managing the core components of the app and
# coordinating overall app boot.
#
# For smaller apps, the app may be the only slice present, whereas larger apps may con... |
github | hanami/hanami | https://github.com/hanami/hanami | lib/hanami/logger/sql_formatter.rb | Ruby | mit | 6,362 | main | 2,801 | # frozen_string_literal: true
require "dry/logger"
module Hanami
module Logger
# SQL query log formatter for Dry Logger.
#
# Formats SQL query log entries with a template that mirrors the structure of the built-in rack
# log formatter, providing consistent visual formatting across both HTTP request ... |
github | hanami/hanami | https://github.com/hanami/hanami | lib/hanami/logger/sql_logger.rb | Ruby | mit | 6,362 | main | 1,661 | # frozen_string_literal: true
module Hanami
module Logger
# SQL query logger that integrates with the Hanami logger using structured, tagged logging.
#
# Subscribes to `:sql` notification events (emitted by ROM via the Hanami app's
# `"notifications"` component) and logs each query as a structured pa... |
github | hanami/hanami | https://github.com/hanami/hanami | lib/hanami/logger/rack_formatter.rb | Ruby | mit | 6,362 | main | 2,094 | # frozen_string_literal: true
require "dry/logger"
module Hanami
module Logger
# Rack request log formatter for Dry Logger.
#
# Formats rack request log entries with colorized output for HTTP verbs, status codes, and
# request paths, making it easier to visually scan logs in development.
#
#... |
github | hanami/hanami | https://github.com/hanami/hanami | lib/hanami/extensions/view.rb | Ruby | mit | 6,362 | main | 799 | # frozen_string_literal: true
require "hanami/view"
require_relative "view/slice_configured_view"
module Hanami
# @api private
module Extensions
# Integrated behavior for `Hanami::View` classes within Hanami apps.
#
# @see Hanami::View
#
# @api public
# @since 2.1.0
module View
#... |
github | hanami/hanami | https://github.com/hanami/hanami | lib/hanami/extensions/operation.rb | Ruby | mit | 6,362 | main | 740 | # frozen_string_literal: true
require "dry/operation"
module Hanami
module Extensions
# Integrated behavior for `Dry::Operation` classes within Hanami apps.
#
# @see https://github.com/dry-rb/dry-operation
#
# @api public
# @since 2.2.0
module Operation
require_relative "operation/... |
github | hanami/hanami | https://github.com/hanami/hanami | lib/hanami/extensions/action.rb | Ruby | mit | 6,362 | main | 3,708 | # frozen_string_literal: true
require "hanami/action"
require_relative "action/slice_configured_action"
module Hanami
# @api private
module Extensions
# Integrated behavior for `Hanami::Action` classes within Hanami apps.
#
# @see InstanceMethods
# @see https://github.com/hanami/hanami-action
... |
github | hanami/hanami | https://github.com/hanami/hanami | lib/hanami/extensions/router/errors.rb | Ruby | mit | 6,362 | main | 1,666 | # frozen_string_literal: true
require "hanami/router"
module Hanami
class Router
# Error raised when a request is made for a missing route.
#
# Raised only when using hanami-router as part of a full Hanami app. When using hanami-router
# standalone, the behavior for such requests is to return a "Not... |
github | hanami/hanami | https://github.com/hanami/hanami | lib/hanami/extensions/view/slice_configured_view.rb | Ruby | mit | 6,362 | main | 8,531 | # frozen_string_literal: true
module Hanami
module Extensions
module View
# Provides slice-specific configuration and behavior for any view class defined within a
# slice's module namespace.
#
# @api public
# @since 2.1.0
class SliceConfiguredView < Module
TEMPLATES_DI... |
github | hanami/hanami | https://github.com/hanami/hanami | lib/hanami/extensions/view/scope.rb | Ruby | mit | 6,362 | main | 818 | # frozen_string_literal: true
require_relative "slice_configured_helpers"
require_relative "standard_helpers"
module Hanami
module Extensions
module View
# @api private
# @since 2.1.0
module Scope
# @api private
# @since 2.1.0
def self.included(scope_class)
su... |
github | hanami/hanami | https://github.com/hanami/hanami | lib/hanami/extensions/view/slice_configured_part.rb | Ruby | mit | 6,362 | main | 1,980 | # frozen_string_literal: true
module Hanami
module Extensions
module View
# Provides slice-specific configuration and behavior for any view part class defined within a
# slice's module namespace.
#
# @api public
# @since 2.1.0
class SliceConfiguredPart < Module
attr_re... |
github | hanami/hanami | https://github.com/hanami/hanami | lib/hanami/extensions/view/standard_helpers.rb | Ruby | mit | 6,362 | main | 547 | # frozen_string_literal: true
module Hanami
module Extensions
module View
# Module including the standard library of Hanami helpers
#
# @api public
# @since 2.1.0
module StandardHelpers
include Hanami::View::Helpers::EscapeHelper
include Hanami::View::Helpers::Number... |
github | hanami/hanami | https://github.com/hanami/hanami | lib/hanami/extensions/view/slice_configured_context.rb | Ruby | mit | 6,362 | main | 1,759 | # frozen_string_literal: true
module Hanami
module Extensions
module View
# Provides slice-specific configuration and behavior for any view context class defined within
# a slice's module namespace.
#
# @api public
# @since 2.1.0
class SliceConfiguredContext < Module
a... |
github | hanami/hanami | https://github.com/hanami/hanami | lib/hanami/extensions/view/slice_configured_helpers.rb | Ruby | mit | 6,362 | main | 1,241 | # frozen_string_literal: true
module Hanami
module Extensions
module View
# Provides slice-specific helper methods for any view object requiring access to helpers.
#
# @api public
# @since 2.1.0
class SliceConfiguredHelpers < Module
attr_reader :slice
# @api private... |
github | hanami/hanami | https://github.com/hanami/hanami | lib/hanami/extensions/view/part.rb | Ruby | mit | 6,362 | main | 2,341 | # frozen_string_literal: true
require_relative "standard_helpers"
require_relative "slice_configured_part"
module Hanami
module Extensions
module View
# @api public
# @since 2.1.0
module Part
# @api private
# @since 2.1.0
def self.included(part_class)
super
... |
github | hanami/hanami | https://github.com/hanami/hanami | lib/hanami/extensions/view/context.rb | Ruby | mit | 6,362 | main | 8,878 | # frozen_string_literal: true
require_relative "../../errors"
require_relative "slice_configured_context"
module Hanami
module Extensions
module View
# View context for views in Hanami apps.
#
# @api public
# @since 2.1.0
module Context
class << self
# Returns a c... |
github | hanami/hanami | https://github.com/hanami/hanami | lib/hanami/extensions/operation/slice_configured_db_operation.rb | Ruby | mit | 6,362 | main | 2,141 | # frozen_string_literal: true
module Hanami
module Extensions
module Operation
# Extends operations to support the database.
#
# Add an initializer accepting a `rom:` dependency, which is supplied automatically from the
# `"db.rom"` component in the operation's slice.
#
# @api... |
github | hanami/hanami | https://github.com/hanami/hanami | lib/hanami/extensions/action/slice_configured_action.rb | Ruby | mit | 6,362 | main | 5,750 | # frozen_string_literal: true
module Hanami
module Extensions
module Action
# Provides slice-specific configuration and behavior for any action class defined
# within a slice's module namespace.
#
# @api private
# @since 2.0.0
class SliceConfiguredAction < Module
attr_... |
github | hanami/hanami | https://github.com/hanami/hanami | lib/hanami/extensions/db/repo.rb | Ruby | mit | 6,362 | main | 2,592 | # frozen_string_literal: true
require "hanami/db"
module Hanami
module Extensions
# @api private
# @since 2.2.0
module DB
# @api private
# @since 2.2.0
module Repo
def self.included(repo_class)
super
repo_class.extend(Hanami::SliceConfigurable)
re... |
github | hanami/hanami | https://github.com/hanami/hanami | lib/hanami/config/null_config.rb | Ruby | mit | 6,362 | main | 398 | # frozen_string_literal: true
require "dry/configurable"
module Hanami
class Config
# NullConfig can serve as a fallback config object when out-of-gem config objects are not
# available (specifically, when the hanami-action, hanami-router or hanami-view gems are not
# loaded)
class NullConfig
... |
github | hanami/hanami | https://github.com/hanami/hanami | lib/hanami/config/console.rb | Ruby | mit | 6,362 | main | 1,850 | # frozen_string_literal: true
require "dry/configurable"
module Hanami
class Config
# Hanami console config
#
# @since 2.3.0
# @api public
class Console
include Dry::Configurable
# @!attribute [rw] engine
# Sets or returns the interactive console engine to be used by `hanami ... |
github | hanami/hanami | https://github.com/hanami/hanami | lib/hanami/config/views.rb | Ruby | mit | 6,362 | main | 2,784 | # frozen_string_literal: true
require "dry/configurable"
require "hanami/view"
module Hanami
class Config
# Hanami views config
#
# This exposes all the settings from the standalone `Hanami::View` class, pre-configured with
# sensible defaults for actions within a full Hanami app. It also provides a... |
github | hanami/hanami | https://github.com/hanami/hanami | lib/hanami/config/assets.rb | Ruby | mit | 6,362 | main | 2,193 | # frozen_string_literal: true
require "dry/configurable"
require "hanami/assets"
module Hanami
class Config
# Hanami assets config
#
# This exposes all the settings from the standalone `Hanami::Assets` class, pre-configured with
# sensible defaults for actions within a full Hanami app. It also provi... |
github | hanami/hanami | https://github.com/hanami/hanami | lib/hanami/config/logger.rb | Ruby | mit | 6,362 | main | 5,904 | # frozen_string_literal: true
require "dry/configurable"
require "dry/logger"
module Hanami
class Config
# Hanami logger config
#
# @api public
# @since 2.0.0
class Logger
include Dry::Configurable
# @return [Hanami::SliceName]
#
# @api private
# @since 2.0.0
... |
github | hanami/hanami | https://github.com/hanami/hanami | lib/hanami/config/actions.rb | Ruby | mit | 6,362 | main | 6,100 | # frozen_string_literal: true
require "dry/configurable"
require "hanami/action"
module Hanami
class Config
# Hanami actions config
#
# This exposes all the settings from the standalone `Hanami::Action` class, pre-configured with
# sensible defaults for actions within a full Hanami app. It also prov... |
github | hanami/hanami | https://github.com/hanami/hanami | lib/hanami/config/router.rb | Ruby | mit | 6,362 | main | 1,010 | # frozen_string_literal: true
require "dry/configurable"
require_relative "../slice/routing/resolver"
module Hanami
class Config
# Hanami router config
#
# @since 2.0.0
# @api private
class Router
include Dry::Configurable
# Base config is provided so router config can include the `... |
github | hanami/hanami | https://github.com/hanami/hanami | lib/hanami/config/i18n.rb | Ruby | mit | 6,362 | main | 3,405 | # frozen_string_literal: true
require "dry/configurable"
require_relative "../providers/i18n"
module Hanami
class Config
# Hanami I18n config
#
# @api public
# @since x.x.x
class I18n
include Dry::Configurable
# @!attribute [rw] default_locale
# Sets or returns the default l... |
github | hanami/hanami | https://github.com/hanami/hanami | lib/hanami/config/db.rb | Ruby | mit | 6,362 | main | 631 | # frozen_string_literal: true
require "dry/configurable"
module Hanami
class Config
# Hanami DB config
#
# @since 2.2.0
# @api public
class DB
include Dry::Configurable
setting :configure_from_parent, default: true
setting :import_from_parent, default: false
private
... |
github | hanami/hanami | https://github.com/hanami/hanami | lib/hanami/config/actions/cookies.rb | Ruby | mit | 6,362 | main | 1,397 | # frozen_string_literal: true
module Hanami
class Config
class Actions
# Wrapper for app-level config of HTTP cookies for Hanami actions.
#
# This decorates the hash of cookie options that is otherwise directly configurable on
# actions, and adds the `enabled?` method to allow app base ac... |
github | hanami/hanami | https://github.com/hanami/hanami | lib/hanami/config/actions/sessions.rb | Ruby | mit | 6,362 | main | 1,940 | # frozen_string_literal: true
require "hanami/utils/string"
require "hanami/utils/class"
module Hanami
class Config
class Actions
# Config for HTTP session middleware in Hanami actions.
#
# @api public
# @since 2.0.0
class Sessions
# Returns the configured session storage
... |
github | hanami/hanami | https://github.com/hanami/hanami | lib/hanami/config/actions/content_security_policy.rb | Ruby | mit | 6,362 | main | 3,637 | # frozen_string_literal: true
module Hanami
class Config
class Actions
# Config for Content Security Policy in Hanami apps
#
# @since 2.0.0
class ContentSecurityPolicy
# @since 2.0.0
# @api private
def initialize(&blk)
@policy = {
base_uri: "'... |
github | hanami/hanami | https://github.com/hanami/hanami | lib/hanami/settings/env_store.rb | Ruby | mit | 6,362 | main | 805 | # frozen_string_literal: true
require "dry/core/constants"
module Hanami
class Settings
# The default store for {Hanami::Settings}, loading setting values from `ENV`.
#
# If your app loads the dotenv gem, then `ENV` will also be populated from various `.env` files when
# you subclass `Hanami::App`.
... |
github | hanami/hanami | https://github.com/hanami/hanami | lib/hanami/settings/composite_store.rb | Ruby | mit | 6,362 | main | 1,539 | # frozen_string_literal: true
require "dry/core/constants"
module Hanami
class Settings
# A settings store that chains multiple stores with fallback resolution.
#
# Each store is tried in order. The first store to return a value wins.
# Stores must implement `#fetch` with the same signature as `Hash... |
github | hanami/hanami | https://github.com/hanami/hanami | lib/hanami/providers/rack.rb | Ruby | mit | 6,362 | main | 1,714 | # frozen_string_literal: true
module Hanami
# @api private
module Providers
# Provider source to register Rack integration components in Hanami slices.
#
# @see Hanami::Providers::Logger
# @see Hanami::Web::RackLogger
# @see https://github.com/rack/rack
# @see https://dry-rb.org/gems/dry-mo... |
github | hanami/hanami | https://github.com/hanami/hanami | lib/hanami/providers/routes.rb | Ruby | mit | 6,362 | main | 811 | # frozen_string_literal: true
module Hanami
# @api private
module Providers
# Provider source to register routes helper component in Hanami slices.
#
# @see Hanami::Slice::RoutesHelper
#
# @api private
# @since 2.0.0
class Routes < Hanami::Provider::Source
# @api private
def... |
github | hanami/hanami | https://github.com/hanami/hanami | lib/hanami/providers/assets.rb | Ruby | mit | 6,362 | main | 652 | # frozen_string_literal: true
module Hanami
# @api private
module Providers
# Provider source to register routes helper component in Hanami slices.
#
# @see Hanami::Slice::RoutesHelper
#
# @api private
# @since 2.0.0
class Assets < Hanami::Provider::Source
# @api private
def... |
github | hanami/hanami | https://github.com/hanami/hanami | lib/hanami/providers/logger.rb | Ruby | mit | 6,362 | main | 402 | # frozen_string_literal: true
module Hanami
# @api private
module Providers
# Provider source to register logger component in Hanami slices.
#
# @see Hanami::Config#logger
#
# @api private
# @since 2.0.0
class Logger < Hanami::Provider::Source
# @api private
def start
... |
github | hanami/hanami | https://github.com/hanami/hanami | lib/hanami/providers/i18n.rb | Ruby | mit | 6,362 | main | 3,314 | # frozen_string_literal: true
module Hanami
module Providers
# @api private
class I18n < Hanami::Provider::Source
SLICE_CONFIGURED_SETTINGS = %i[default_locale available_locales load_path fallbacks].freeze
DEFAULT_LOCALE = :en
DEFAULT_AVAILABLE_LOCALES = [].freeze
DEFAULT_LOAD_PATH =... |
github | hanami/hanami | https://github.com/hanami/hanami | lib/hanami/providers/relations.rb | Ruby | mit | 6,362 | main | 671 | # frozen_string_literal: true
module Hanami
module Providers
# @api private
# @since 2.2.0
class Relations < Hanami::Provider::Source
def start
start_and_import_parent_relations and return if slice.parent && slice.config.db.import_from_parent
slice.start :db
register_relat... |
github | hanami/hanami | https://github.com/hanami/hanami | lib/hanami/providers/db_logging.rb | Ruby | mit | 6,362 | main | 386 | # frozen_string_literal: true
module Hanami
module Providers
# @api private
class DBLogging < Hanami::Provider::Source
def prepare
slice["notifications"].register_event :sql
end
def start
require "hanami/logger/sql_logger"
Hanami::Logger::SQLLogger.new(slice["logger... |
github | hanami/hanami | https://github.com/hanami/hanami | lib/hanami/providers/inflector.rb | Ruby | mit | 6,362 | main | 359 | # frozen_string_literal: true
module Hanami
# @api private
module Providers
# Provider source to register inflector component in Hanami slices.
#
# @api private
# @since 2.0.0
class Inflector < Hanami::Provider::Source
# @api private
def start
register :inflector, Hanami.app... |
github | hanami/hanami | https://github.com/hanami/hanami | lib/hanami/providers/db.rb | Ruby | mit | 6,362 | main | 10,050 | # frozen_string_literal: true
require "dry/configurable"
require "dry/core"
require "uri"
require_relative "../constants"
module Hanami
module Providers
# rubocop:disable Metrics/AbcSize, Metrics/PerceivedComplexity
# @api private
# @since 2.2.0
class DB < Hanami::Provider::Source
extend Dry:... |
github | hanami/hanami | https://github.com/hanami/hanami | lib/hanami/providers/db/adapter.rb | Ruby | mit | 6,362 | main | 1,579 | # frozen_string_literal: true
require "dry/configurable"
module Hanami
module Providers
class DB < Hanami::Provider::Source
# @api public
# @since 2.2.0
class Adapter
include Dry::Configurable
# @api public
# @since 2.2.0
setting :plugins, mutable: true
... |
github | hanami/hanami | https://github.com/hanami/hanami | lib/hanami/providers/db/config.rb | Ruby | mit | 6,362 | main | 1,118 | # frozen_string_literal: true
require "dry/core"
module Hanami
module Providers
class DB < Hanami::Provider::Source
# @api public
# @since 2.2.0
class Config < Dry::Configurable::Config
include Dry::Core::Constants
# @api public
# @since 2.2.0
def gateway(key)
... |
github | hanami/hanami | https://github.com/hanami/hanami | lib/hanami/providers/db/sql_adapter.rb | Ruby | mit | 6,362 | main | 2,709 | # frozen_string_literal: true
module Hanami
module Providers
class DB < Hanami::Provider::Source
# @api public
# @since 2.2.0
class SQLAdapter < Adapter
# @api public
# @since 2.2.0
setting :extensions, mutable: true
# @api public
# @since 2.2.0
... |
github | hanami/hanami | https://github.com/hanami/hanami | lib/hanami/providers/db/gateway.rb | Ruby | mit | 6,362 | main | 2,308 | # frozen_string_literal: true
require "dry/configurable"
require "dry/core"
module Hanami
module Providers
class DB < Hanami::Provider::Source
# @api public
# @since 2.2.0
class Gateway
include Dry::Core::Constants
include Dry::Configurable
setting :database_url
... |
github | hanami/hanami | https://github.com/hanami/hanami | lib/hanami/providers/db/adapters.rb | Ruby | mit | 6,362 | main | 1,375 | # frozen_string_literal: true
module Hanami
module Providers
class DB < Hanami::Provider::Source
# @api public
# @since 2.2.0
class Adapters
# @api private
# @since 2.2.0
ADAPTER_CLASSES = Hash.new(Adapter).update(
sql: SQLAdapter
).freeze
priva... |
github | hanami/hanami | https://github.com/hanami/hanami | lib/hanami/providers/i18n/backend.rb | Ruby | mit | 6,362 | main | 11,065 | # frozen_string_literal: true
module Hanami
module Providers
class I18n < Hanami::Provider::Source
# A wrapper that provides a full `I18n`-like interface for an individual I18n backend. This
# allows each Hanami slice to have its own isolated I18n instance.
#
# Unlike the global I18n modu... |
github | hanami/hanami | https://github.com/hanami/hanami | lib/hanami/provider/source.rb | Ruby | mit | 6,362 | main | 306 | # frozen_string_literal: true
module Hanami
module Provider
class Source < Dry::System::Provider::Source
attr_reader :slice
def initialize(slice:, **options, &block)
@slice = slice
super(**options, &block)
end
def target_container = slice
end
end
end |
github | hanami/hanami | https://github.com/hanami/hanami | lib/hanami/web/welcome.rb | Ruby | mit | 6,362 | main | 876 | # frozen_string_literal: true
require "erb"
module Hanami
# @api private
module Web
# Middleware that renders a welcome view in fresh Hanami apps.
#
# @api private
# @since 2.1.0
class Welcome
# @api private
# @since 2.1.0
def initialize(app)
@app = app
end
... |
github | hanami/hanami | https://github.com/hanami/hanami | lib/hanami/web/rack_logger.rb | Ruby | mit | 6,362 | main | 3,152 | # frozen_string_literal: true
require "delegate"
require "json"
module Hanami
# @api private
module Web
# Rack logger for Hanami apps
#
# @api private
# @since 2.0.0
class RackLogger
EMPTY_PARAMS = {}.freeze
private_constant :EMPTY_PARAMS
REQUEST_METHOD = "REQUEST_METHOD"
... |
github | hanami/hanami | https://github.com/hanami/hanami | lib/hanami/helpers/assets_helper.rb | Ruby | mit | 6,362 | main | 26,831 | # frozen_string_literal: true
require "uri"
require "hanami/view"
require_relative "../constants"
module Hanami
module Helpers
# HTML assets helpers
#
# Inject these helpers in a view
#
# @since 2.1.0
#
# @see http://www.rubydoc.info/gems/hanami-helpers/Hanami/Helpers/HtmlHelper
modu... |
github | hanami/hanami | https://github.com/hanami/hanami | lib/hanami/helpers/form_helper.rb | Ruby | mit | 6,362 | main | 7,632 | # frozen_string_literal: true
require "hanami/view"
module Hanami
module Helpers
# Helper methods for generating HTML forms.
#
# These helpers will be automatically available in your view templates, part classes and scope
# classes.
#
# This module provides one primary method: {#form_for}, y... |
github | hanami/hanami | https://github.com/hanami/hanami | lib/hanami/helpers/form_helper/values.rb | Ruby | mit | 6,362 | main | 1,815 | # frozen_string_literal: true
module Hanami
module Helpers
module FormHelper
# Values from params and form helpers.
#
# It's responsible to populate input values with data coming from params
# and inline values specified via form helpers like `text_field`.
#
# @since 2.1.0
... |
github | hanami/hanami | https://github.com/hanami/hanami | lib/hanami/helpers/form_helper/form_builder.rb | Ruby | mit | 6,362 | main | 50,887 | # frozen_string_literal: true
require "hanami/view"
require_relative "values"
module Hanami
module Helpers
module FormHelper
# A range of convenient methods for building the fields within an HTML form, integrating with
# request params and template locals to populate the fields with appropriate valu... |
github | hanami/hanami | https://github.com/hanami/hanami | lib/hanami/middleware/content_security_policy_nonce.rb | Ruby | mit | 6,362 | main | 1,502 | # frozen_string_literal: true
require "rack"
require "securerandom"
require_relative "../constants"
module Hanami
module Middleware
# Generates a random per request nonce value like `mSMnSwfVZVe+LyQy1SPCGw==`, stores it as
# `"hanami.content_security_policy_nonce"` in the Rack environment, and replaces all ... |
github | hanami/hanami | https://github.com/hanami/hanami | lib/hanami/middleware/public_errors_app.rb | Ruby | mit | 6,362 | main | 1,911 | # frozen_string_literal: true
require "rack"
module Hanami
module Middleware
# The errors app given to {Hanami::Middleware::RenderErrors}, which renders error responses
# from HTML pages kept in `public/` as simple JSON structures.
#
# @see Hanami::Middleware::RenderErrors
#
# @api private
... |
github | hanami/hanami | https://github.com/hanami/hanami | lib/hanami/middleware/render_errors.rb | Ruby | mit | 6,362 | main | 2,267 | # frozen_string_literal: true
require "rack"
# rubocop:disable Lint/RescueException
module Hanami
module Middleware
# Rack middleware that rescues errors raised by the app renders friendly error responses, via a
# given "errors app".
#
# By default, this is enabled only in production mode.
#
... |
github | hanami/hanami | https://github.com/hanami/hanami | lib/hanami/middleware/assets.rb | Ruby | mit | 6,362 | main | 425 | # frozen_string_literal: true
require "rack/static"
module Hanami
module Middleware
class Assets < Rack::Static
def initialize(app, options = {}, config: Hanami.app.config)
root = config.actions.public_directory
urls = [config.assets.path_prefix]
defaults = {
root: root,... |
github | hanami/hanami | https://github.com/hanami/hanami | lib/hanami/slice/routes_helper.rb | Ruby | mit | 6,362 | main | 767 | # frozen_string_literal: true
module Hanami
class Slice
# Hanami app routes helpers
#
# An instance of this class will be registered with slice (at the "routes" key). You
# can use it to access the route helpers for your app.
#
# @example
# MyApp::App["routes"].path(:root) # => "/"
... |
github | hanami/hanami | https://github.com/hanami/hanami | lib/hanami/slice/router.rb | Ruby | mit | 6,362 | main | 8,425 | # frozen_string_literal: true
require "hanami/router"
require_relative "routing/resolver"
require_relative "routing/middleware/stack"
module Hanami
class Slice
# `Hanami::Router` subclass with enhancements for use within Hanami apps.
#
# This is loaded from Hanami apps and slices and made available as t... |
github | hanami/hanami | https://github.com/hanami/hanami | lib/hanami/slice/view_name_inferrer.rb | Ruby | mit | 6,362 | main | 2,045 | # frozen_string_literal: true
require_relative "../constants"
module Hanami
class Slice
# Infers a view name for automatically rendering within actions.
#
# @api private
# @since 2.0.0
class ViewNameInferrer
ALTERNATIVE_NAMES = {
"create" => "new",
"update" => "edit"
... |
github | hanami/hanami | https://github.com/hanami/hanami | lib/hanami/slice/routing/resolver.rb | Ruby | mit | 6,362 | main | 2,260 | # frozen_string_literal: true
module Hanami
class Slice
# @api private
module Routing
# Hanami app router endpoint resolver
#
# This resolves endpoints objects from a slice container using the strings passed to `to:` as
# their container keys.
#
# @api private
# @sin... |
github | hanami/hanami | https://github.com/hanami/hanami | lib/hanami/slice/routing/middleware/stack.rb | Ruby | mit | 6,362 | main | 6,367 | # frozen_string_literal: true
require "hanami/router"
require "hanami/middleware"
require "hanami/middleware/app"
require "hanami/errors"
module Hanami
class Slice
module Routing
# @since 2.0.0
# @api private
module Middleware
# Wraps a rack app with a middleware stack
#
... |
github | norman/friendly_id | https://github.com/norman/friendly_id | bench.rb | Ruby | mit | 6,218 | master | 1,890 | require File.expand_path("../test/helper", __FILE__)
require "ffaker"
N = 10000
def transaction
ActiveRecord::Base.transaction do
yield
raise ActiveRecord::Rollback
end
end
class Array
def rand
self[Kernel.rand(length)]
end
end
Book = Class.new ActiveRecord::Base
class Journalist < ActiveRecor... |
github | norman/friendly_id | https://github.com/norman/friendly_id | guide.rb | Ruby | mit | 6,218 | master | 832 | #!/usr/bin/env ruby
# This script generates the Guide.md file included in the Yard docs.
def comments_from path
path = File.expand_path("../lib/friendly_id/#{path}", __FILE__)
matches = File.read(path).match(/\n\s*# @guide begin\n(.*)\s*# @guide end/m)
return if matches.nil?
match = matches[1].to_s
match.... |
github | norman/friendly_id | https://github.com/norman/friendly_id | friendly_id.gemspec | Ruby | mit | 6,218 | master | 1,192 | require File.expand_path("../lib/friendly_id/version", __FILE__)
Gem::Specification.new do |s|
s.name = "friendly_id"
s.version = FriendlyId::VERSION
s.authors = ["Norman Clarke", "Philip Arndt"]
s.email = ["norman@njclarke.com", "gems@p.arndt.io"]
s.homepage = "https://github.com/norman/friendly_id"
s.sum... |
github | norman/friendly_id | https://github.com/norman/friendly_id | Rakefile | Ruby | mit | 6,218 | master | 2,662 | require "rubygems"
require "bundler/gem_tasks"
require "rake/testtask"
task default: :test
task :load_path do
%w[lib test].each do |path|
$LOAD_PATH.unshift(File.expand_path("../#{path}", __FILE__))
end
end
Rake::TestTask.new do |t|
t.libs << "test"
t.test_files = FileList["test/*_test.rb"]
t.verbose =... |
github | norman/friendly_id | https://github.com/norman/friendly_id | Gemfile | Ruby | mit | 6,218 | master | 339 | source "https://rubygems.org"
gemspec
gem "standard"
gem "rake"
group :development, :test do
platforms :ruby do
gem "byebug"
gem "pry"
end
platforms :jruby do
gem "activerecord-jdbcsqlite3-adapter", ">= 1.3.0.beta2"
gem "kramdown"
end
platforms :ruby, :rbx do
gem "sqlite3"
gem "re... |
github | norman/friendly_id | https://github.com/norman/friendly_id | test/finders_test.rb | Ruby | mit | 6,218 | master | 2,211 | require "helper"
class JournalistWithFriendlyFinders < ActiveRecord::Base
self.table_name = "journalists"
extend FriendlyId
scope :existing, -> { where("1 = 1") }
friendly_id :name, use: [:slugged, :finders]
end
class Finders < TestCaseClass
include FriendlyId::Test
def model_class
JournalistWithFrie... |
github | norman/friendly_id | https://github.com/norman/friendly_id | test/reserved_test.rb | Ruby | mit | 6,218 | master | 1,978 | require "helper"
class ReservedTest < TestCaseClass
include FriendlyId::Test
class Journalist < ActiveRecord::Base
extend FriendlyId
friendly_id :slug_candidates, use: [:slugged, :reserved], reserved_words: %w[new edit]
after_validation :move_friendly_id_error_to_name
def move_friendly_id_error_... |
github | norman/friendly_id | https://github.com/norman/friendly_id | test/configuration_test.rb | Ruby | mit | 6,218 | master | 1,604 | require "helper"
class ConfigurationTest < TestCaseClass
include FriendlyId::Test
def setup
@model_class = Class.new(ActiveRecord::Base) do
self.abstract_class = true
end
end
test "should set model class on initialization" do
config = FriendlyId::Configuration.new @model_class
assert_eq... |
github | norman/friendly_id | https://github.com/norman/friendly_id | test/core_test.rb | Ruby | mit | 6,218 | master | 754 | require "helper"
class Book < ActiveRecord::Base
extend FriendlyId
friendly_id :name
end
class Author < ActiveRecord::Base
extend FriendlyId
friendly_id :name
has_many :books
end
class CoreTest < TestCaseClass
include FriendlyId::Test
include FriendlyId::Test::Shared::Core
def model_class
Author... |
github | norman/friendly_id | https://github.com/norman/friendly_id | test/slugged_test.rb | Ruby | mit | 6,218 | master | 17,002 | require "helper"
class Journalist < ActiveRecord::Base
extend FriendlyId
friendly_id :name, use: :slugged
end
class Article < ActiveRecord::Base
extend FriendlyId
friendly_id :name, use: :slugged
end
class Novelist < ActiveRecord::Base
extend FriendlyId
friendly_id :name, use: :slugged, sequence_separato... |
github | norman/friendly_id | https://github.com/norman/friendly_id | test/scoped_test.rb | Ruby | mit | 6,218 | master | 3,097 | require "helper"
class Novelist < ActiveRecord::Base
extend FriendlyId
friendly_id :name, use: :slugged
end
class Novel < ActiveRecord::Base
extend FriendlyId
belongs_to :novelist
belongs_to :publisher
friendly_id :name, use: :scoped, scope: [:publisher, :novelist]
def should_generate_new_friendly_id?
... |
github | norman/friendly_id | https://github.com/norman/friendly_id | test/object_utils_test.rb | Ruby | mit | 6,218 | master | 653 | require "helper"
class ObjectUtilsTest < TestCaseClass
include FriendlyId::Test
test "strings with letters are friendly_ids" do
assert "a".friendly_id?
end
test "integers should be unfriendly ids" do
assert 1.unfriendly_id?
end
test "numeric strings are neither friendly nor unfriendly" do
as... |
github | norman/friendly_id | https://github.com/norman/friendly_id | test/history_test.rb | Ruby | mit | 6,218 | master | 12,165 | require "helper"
class HistoryTest < TestCaseClass
include FriendlyId::Test
include FriendlyId::Test::Shared::Core
class Manual < ActiveRecord::Base
extend FriendlyId
friendly_id :name, use: [:slugged, :history]
end
def model_class
Manual
end
test "should insert record in slugs table on cr... |
github | norman/friendly_id | https://github.com/norman/friendly_id | test/base_test.rb | Ruby | mit | 6,218 | master | 1,949 | require "helper"
class CoreTest < TestCaseClass
include FriendlyId::Test
test "friendly_id can be added using 'extend'" do
klass = Class.new(ActiveRecord::Base) do
extend FriendlyId
end
assert klass.respond_to? :friendly_id
end
test "friendly_id can be added using 'include'" do
klass = ... |
github | norman/friendly_id | https://github.com/norman/friendly_id | test/simple_i18n_test.rb | Ruby | mit | 6,218 | master | 4,441 | require "helper"
class SimpleI18nTest < TestCaseClass
include FriendlyId::Test
class Journalist < ActiveRecord::Base
extend FriendlyId
friendly_id :name, use: :simple_i18n
end
def setup
I18n.locale = :en
end
test "friendly_id should return the current locale's slug" do
journalist = Journ... |
github | norman/friendly_id | https://github.com/norman/friendly_id | test/shared.rb | Ruby | mit | 6,218 | master | 6,857 | module FriendlyId
module Test
module Shared
module Slugged
test "configuration should have a sequence_separator" do
assert !model_class.friendly_id_config.sequence_separator.empty?
end
test "should make a new slug if the slug has been set to nil changed" do
with_... |
github | norman/friendly_id | https://github.com/norman/friendly_id | test/numeric_slug_test.rb | Ruby | mit | 6,218 | master | 3,046 | require "helper"
class Article < ActiveRecord::Base
extend FriendlyId
friendly_id :name, use: :slugged
end
class ArticleWithNumericPrevention < ActiveRecord::Base
self.table_name = "articles"
extend FriendlyId
friendly_id :name, use: :slugged
friendly_id_config.treat_numeric_as_conflict = true
end
class ... |
github | norman/friendly_id | https://github.com/norman/friendly_id | test/schema.rb | Ruby | mit | 6,218 | master | 3,287 | require "friendly_id/migration"
module FriendlyId
module Test
migration_class =
if ActiveRecord::VERSION::MAJOR >= 5
ActiveRecord::Migration[4.2]
else
ActiveRecord::Migration
end
class Schema < migration_class
class << self
def down
CreateFriendlyIdS... |
github | norman/friendly_id | https://github.com/norman/friendly_id | test/candidates_test.rb | Ruby | mit | 6,218 | master | 3,497 | require "helper"
class CandidatesTest < TestCaseClass
include FriendlyId::Test
class Airport
def initialize(code)
@code = code
end
attr_reader :code
alias_method :to_s, :code
end
class City < ActiveRecord::Base
extend FriendlyId
friendly_id :slug_candidates, use: :slugged
al... |
github | norman/friendly_id | https://github.com/norman/friendly_id | test/helper.rb | Ruby | mit | 6,218 | master | 2,672 | require "bundler/setup"
if ENV["COVERALLS"] || ENV["COVERAGE"]
require "simplecov"
if ENV["COVERALLS"]
require "coveralls"
SimpleCov.formatter = Coveralls::SimpleCov::Formatter
end
SimpleCov.start do
add_filter "test"
add_filter "friendly_id/migration"
end
end
begin
require "minitest"
resc... |
github | norman/friendly_id | https://github.com/norman/friendly_id | test/sequentially_slugged_test.rb | Ruby | mit | 6,218 | master | 6,336 | require "helper"
class Article < ActiveRecord::Base
extend FriendlyId
friendly_id :name, use: :sequentially_slugged
end
class SequentiallySluggedTest < TestCaseClass
include FriendlyId::Test
include FriendlyId::Test::Shared::Core
def model_class
Article
end
test "should generate numerically sequen... |
github | norman/friendly_id | https://github.com/norman/friendly_id | test/generator_test.rb | Ruby | mit | 6,218 | master | 1,021 | require "helper"
require "rails/generators"
require "generators/friendly_id_generator"
class FriendlyIdGeneratorTest < Rails::Generators::TestCase
tests FriendlyIdGenerator
destination File.expand_path("../../tmp", __FILE__)
setup :prepare_destination
test "should generate a migration" do
run_generator
... |
github | norman/friendly_id | https://github.com/norman/friendly_id | test/sti_test.rb | Ruby | mit | 6,218 | master | 3,434 | require "helper"
class StiTest < TestCaseClass
include FriendlyId::Test
include FriendlyId::Test::Shared::Core
include FriendlyId::Test::Shared::Slugged
class Journalist < ActiveRecord::Base
extend FriendlyId
friendly_id :name, use: [:slugged]
end
class Editorialist < Journalist
end
def mode... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.