-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support custom GTINs #29
Commits on Jun 23, 2022
-
This refactors GTIN handler class lookup so it can be extended without monkeypatching. Developers can add/remove classes in `BarcodeValidation::GTIN.gtin_classes` to control which class wraps a GTIN. The use case I need this for is internall dummy GTINs that are longer than any of the standard ones. The Readme is updated to describe the feature.
Configuration menu - View commit details
-
Copy full SHA for a0d0e9b - Browse repository at this point
Copy the full SHA a0d0e9bView commit details
Commits on Sep 19, 2022
-
Implemented GTIN::Base.prioritize_before
This is part of marketplacer#29, which makes it easier to implement custom GTINs as a user of this library. The first implementation in a0d0e9b worked, but required the user to directly manipulate registered classes inside an Array. As @beet pointed out, it's better to not expose implementation details like that and look for a more elegant interface. This commit changes the implementation by replacing `gtin_classes` with `prioritized_gtin_classes` and adding a note that this is a private API. Any subclass of `GTIN::Base` will be automatically appended to this list. The user gets two tools directly inside `GTIN::Base`: - `prioritize_before (other_class)`: moves this class to directly in front of the other class. This allows this class to be asked if it `handles?` a GTIN before the other class. - `abstract_class`: lets a class remove itself from the list of classes that are asked if they handle a GTIN. There are tests for both the implementation details and functionality.
Configuration menu - View commit details
-
Copy full SHA for cd32ab6 - Browse repository at this point
Copy the full SHA cd32ab6View commit details
Commits on Sep 20, 2022
-
Refactor: GTIN#remove_gtin_class handles delete behavior
The goal is to make `prioritized_gtin_classes` private data and only expose methods that have interactions with it. Replacing #delete behavior from GTIN::Base with calls to this new method is one step in the right direction.
Configuration menu - View commit details
-
Copy full SHA for 20719f3 - Browse repository at this point
Copy the full SHA 20719f3View commit details -
Refactor: GTIN handles internal logic of appending a GTIN class
This is another small step towards making GTIN::Base not manipulate the internals of `GTIN.prioritized_gtin_classes`, but letting GTIN handle that by itself.
Configuration menu - View commit details
-
Copy full SHA for 5a24eb6 - Browse repository at this point
Copy the full SHA 5a24eb6View commit details -
Refactor: GTIN::Base.prioritize_before does not touch GTIN internals
Manipulating `GTIN.prioritized_gtin_classes` now only happens through helper methods on GTIN, theoretically allowing the list itself to become private.
Configuration menu - View commit details
-
Copy full SHA for a324144 - Browse repository at this point
Copy the full SHA a324144View commit details -
Doc: document BarcodeValidation::GTIN
Having a few lines to outline the purpose of a class and its neighbours tends to help understanding and exploration of a codebase.
Configuration menu - View commit details
-
Copy full SHA for 91d8c97 - Browse repository at this point
Copy the full SHA 91d8c97View commit details -
GTIN.prioritized_gtin_classes is private
The only thing that still depended on it being public were the tests for functionality that manipulated the list. The tests have been overhauled to rely more on asserting behavior than internal state.
Configuration menu - View commit details
-
Copy full SHA for 284c50d - Browse repository at this point
Copy the full SHA 284c50dView commit details