Skip to content

Conversation

@doriantaylor
Copy link

@doriantaylor doriantaylor commented Aug 10, 2023

Resolves #173 and #174.

Created the following new methods:

  • .binary? predicate will tell if the input (IO, string, file extension, path, type, whatever) is binary
  • #binary? instance method likewise
  • .default_type will return either text/plain or application/octet-stream depending on whether the input is perceived to be binary
  • #aliases (and .aliases) will return the list of aliases for a given type
  • #alias? predicate will determine if a given type is an alias of a canonical type
  • #canonical (and .canonical) will return a canonical type for a (potentially aliased) type
  • #parents will return the immediate parent types of the given type
  • #lineage will return the entire (flattened) inheritance hierarchy of the given type, including itself
  • fancy new MimeMagic[…] constructor will generate from a type or file extension

Other changes:

  • internal database now contains aliases and the canonical type identifier
  • constructor now handles type parameters; params accessor
  • explicit #inspect method shows abridged diagnostic representation
  • default: keyword parameter on .by_extension, .by_path, .by_magic, .all_by_magic will guarantee a return value when truthy (either the result of .default_type for the given input or a user-supplied value)
  • normalized all the documentation to YARD

@doriantaylor doriantaylor changed the title aliases, recursive lineage tracing, documentation, lots whole schwack of new methods Aug 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add parents and lineage methods

1 participant