Module: ForgetPasswords::Types
- Defined in:
- lib/forget-passwords/types.rb
Constant Summary collapse
- ASCIIToken =
config primitives
Strict::String.constrained(format: ASCII).constructor(&:strip)
- Hostname =
actually pretty sure i can define constraints for this type, oh well
String.constructor(&:strip).constrained(format: HN)
- Duration =
Types.Constructor(ISO8601::Duration) do |x| begin out = ISO8601::Duration.new x.to_s.strip.upcase rescue ISO8601::Errors::UnknownPattern => e raise Dry::Types::CoercionError.new e end out end
- URI =
XXX note this is a fail in dry-types
Types.Constructor(::URI) do |x| begin out = ::URI.parse(x) rescue ::URI::InvalidURIError => e raise Dry::Types::CoercionError, e end out end
- RelativePathname =
Types.Constructor(::Pathname) { |x| Pathname(x) }
- ExtantPathname =
Types.Constructor(::Pathname) do |x| out = Pathname(x). dir = out.dirname raise Dry::Types::CoercionError, "#{dir} does not exist" unless out.exist? || dir.exist? out end
- WritablePathname =
should be WritablePathname but whatever
Types.Constructor(::Pathname) do |x| out = Pathname(x) dir = out..dirname raise Dry::Types::CoercionError, "#{dir} is not writable" unless dir.writable? raise Dry::Types::CoercionError, "#{out} can't be overwritten" if out.exist? and !out.writable? out end
- NormSym =
Symbol.constructor do |k| k.to_s.strip.downcase.tr_s(' _-', ?_).to_sym end
- SymbolHash =
symbol hash
Hash.schema({}).with_key_transform do |k| NormSym.call k end
- SymbolMap =
apparently you can’t go from schema to map
Hash.map NormSym, Any
- Atomic =
this is a generic type for stuff that comes off the command line or out of a config file that we don’t want to explicitly define but nevertheless needs to be coerced (in particular integers, floats) so it can be passed into eg a constructor
Coercible::Integer | Coercible::Float | Coercible::String