inflection2 0.4.2

Forked #

IMPORTANT NOTE: This is a hard fork of the original inflection package, as the former is now archived, and abandoned.

Inflection #

Build Status

In grammar, inflection or inflexion is the modification of a word to express different grammatical categories such as tense, mood, voice, aspect, person, number, gender and case.

A port of the Rails/ActiveSupport inflector library to Dart.

Usage #

A simple usage example:

import 'package:inflection2/inflection2.dart';

main() {
  // Using 'shortcut' functions.
  
  print(pluralize("house")); // => "houses"
  print(convertToPlural("house")); // => "houses", alias for pluralize
  print(pluralizeVerb("goes")); // => "go"
  print(singularize("axes")); // => "axis"
  print(convertToSingular("axes")); // => "axis", alias for pluralize
  print(singularizeVerb("write")); // => "writes"
  print(convertToSnakeCase("CamelCaseName")); // => "camel_case_name"
  print(convertToSpinalCase("CamelCaseName")); // => "camel-case-name"
  print(past("forgo")); // => "forwent"

  // Using default encoders.
  
  print(PLURAL.convert("virus")); // => "viri"
  print(SINGULAR.convert("Matrices")); // => "Matrix"
  print(SINGULAR.convert("species")); // => "species"
  print(SNAKE_CASE.convert("CamelCaseName")); // => "camel_case_name"
  print(SPINAL_CASE.convert("CamelCaseName")); // => "camel-case-name"
  print(PAST.convert("miss")); // => "missed"
}

Features and bugs #

Please file feature requests and bugs at the issue tracker.

Changelog #

0.4.2 #

  • Dart 2 compatibility.
  • Hard fork.

0.4.1 #

  • Cleanup, follow latest conventions and developments in the Dartiverse.
  • Added past inflections.

0.3.2 #

  • Cleanup.

0.3.1 #

  • Case conversion handles sentences delimited with whitespace.

0.3.0 #

  • Handle irregular plural nouns.
  • Added shortcut functions.

0.2.0 #

  • Handle uncountable nouns.
  • Added singular inflection.
  • Added plural inflection.
  • Refactored to use a dart:convert based API.

0.1.0 #

  • Initial version, convertToSnakeCase / convertToSpinalCase.

example/main.dart

import 'package:inflection2/inflection2.dart';

main() {
  // Using 'shortcut' functions.

  print(pluralize("house")); // => "houses"
  print(convertToPlural("house")); // => "houses", alias for pluralize
  print(pluralizeVerb("goes")); // => "go"
  print(singularize("axes")); // => "axis"
  print(convertToSingular("axes")); // => "axis", alias for pluralize
  print(singularizeVerb("write")); // => "writes"
  print(convertToSnakeCase("CamelCaseName")); // => "camel_case_name"
  print(convertToSpinalCase("CamelCaseName")); // => "camel-case-name"
  print(past("forgo")); // => "forwent"

  // Using default encoders.

  print(PLURAL.convert("virus")); // => "viri"
  print(SINGULAR.convert("Matrices")); // => "Matrix"
  print(SINGULAR.convert("species")); // => "species"
  print(SNAKE_CASE.convert("CamelCaseName")); // => "camel_case_name"
  print(SPINAL_CASE.convert("CamelCaseName")); // => "camel-case-name"
  print(PAST.convert("miss")); // => "missed"
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  inflection2: ^0.4.2

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:inflection2/inflection2.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
52
Health:
Code health derived from static analysis. [more]
97
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
80
Overall:
Weighted score of the above. [more]
71
Learn more about scoring.

We analyzed this package on Aug 16, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.4.0
  • pana: 0.12.19

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:inflection2/inflection2.dart.

Health issues and suggestions

Document public APIs. (-0.30 points)

41 out of 42 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Fix lib/src/past.dart. (-1 points)

Analysis of lib/src/past.dart reported 2 hints:

line 44 col 9: Use isNotEmpty for Iterables and Maps.

line 50 col 13: DO use curly braces for all flow control structures.

Fix lib/src/plural.dart. (-0.50 points)

Analysis of lib/src/plural.dart reported 1 hint:

line 70 col 9: Use isNotEmpty for Iterables and Maps.

Fix lib/src/plural_verb.dart. (-0.50 points)

Analysis of lib/src/plural_verb.dart reported 1 hint:

line 36 col 9: Use isNotEmpty for Iterables and Maps.

Fix lib/src/singular.dart. (-0.50 points)

Analysis of lib/src/singular.dart reported 1 hint:

line 78 col 9: Use isNotEmpty for Iterables and Maps.

Fix lib/src/singular_verb.dart. (-0.50 points)

Analysis of lib/src/singular_verb.dart reported 1 hint:

line 33 col 9: Use isNotEmpty for Iterables and Maps.

Maintenance suggestions

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.8.0 <3.0.0
Dev dependencies
test any