pivotal/LicenseFinder — pull request #74 by mainej (2014-02-11 09:47:52+00:00)
Title: License subclasses become instances

The existing system has a handful of subclasses of License which represent the various licenses (License::MIT, License::Apache2, etc.). For each project file, you instantiate each subclass, providing the text of the file, and ask the instance whether the text and license match. This obscures the matching logic, convolutes the License class, which has to deal with the global state represented by the subclasses, and makes adding licenses more complicated than necessary.

This patch changes things so that each license is an instance of License, and you can ask an instance whether it matches some file text. This makes it more explicit that each license definition is just a collection of data: some names for the license, a url, and an algorithm for matching against file text.

Making licenses be instances of License also simplifies testing. You can make new licenses in the tests easily, and creating new types of license won't pollute other tests.