inflection2 0.4.3

  • Readme
  • Changelog
  • Example
  • Installing
  • 74

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.3 #

  • Add past tense support (thanks @phodonou !)

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.3

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]
64
Health:
Code health derived from static analysis. [more]
87
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
80
Overall:
Weighted score of the above. [more]
74
Learn more about scoring.

We analyzed this package on Jan 19, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.0
  • pana: 0.13.4

Health suggestions

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

Analysis of lib/src/past.dart reported 6 hints, including:

line 28 col 15: Unnecessary new keyword.

line 33 col 7: Unnecessary new keyword.

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

line 46 col 22: Unnecessary new keyword.

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

Fix lib/src/snake_case.dart. (-1.99 points)

Analysis of lib/src/snake_case.dart reported 4 hints:

line 5 col 24: Unnecessary new keyword.

line 6 col 24: Unnecessary new keyword.

line 7 col 24: Unnecessary new keyword.

line 24 col 46: Avoid const keyword.

Fix lib/src/spinal_case.dart. (-1.99 points)

Analysis of lib/src/spinal_case.dart reported 4 hints:

line 5 col 24: Unnecessary new keyword.

line 6 col 24: Unnecessary new keyword.

line 7 col 24: Unnecessary new keyword.

line 24 col 47: Avoid const keyword.

Fix additional 5 files with analysis or formatting issues. (-6.46 points)

Additional issues in the following files:

  • lib/src/plural.dart (3 hints)
  • lib/src/plural_verb.dart (3 hints)
  • lib/src/singular.dart (3 hints)
  • lib/src/singular_verb.dart (3 hints)
  • lib/src/uncountable_nouns.dart (1 hint)

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