Sha256: a11518533f579addd558ae228326a7a023d8bd429bcafdf100c81bd814d90d30
Contents?: true
Size: 1.12 KB
Versions: 5
Compression:
Stored size: 1.12 KB
Contents
# typed: true # frozen_string_literal: true require "active_support/inflector" require "packwerk/inflections/default" require "packwerk/inflections/custom" module Packwerk class Inflector class << self extend T::Sig def default @default ||= new(custom_inflector: Inflections::Custom.new) end sig { params(inflections_file: String).returns(::Packwerk::Inflector) } def from_file(inflections_file) new(custom_inflector: Inflections::Custom.new(inflections_file)) end end extend T::Sig include ::ActiveSupport::Inflector # For #camelize, #classify, #pluralize, #singularize sig do params( custom_inflector: Inflections::Custom ).void end def initialize(custom_inflector:) @inflections = ::ActiveSupport::Inflector::Inflections.new Inflections::Default.apply_to(@inflections) custom_inflector.apply_to(@inflections) end def pluralize(word, count = nil) if count == 1 singularize(word) else super(word) end end def inflections(_ = nil) @inflections end end end
Version data entries
5 entries across 5 versions & 1 rubygems