Using Licensee

Command line usage

Licensee has an extensive command line interface. See the command line documentation for more information.

License Ruby API

license = Licensee.license "/path/to/a/project"
=> #<Licensee::License name="MIT" match=0.9842154131847726>

=> "mit"
=> "MIT License"

=> ""

=> "A permissive license that is short and to the point. It lets people do anything with your code with proper attribution and without warranty."

=> ["commercial-use","modifications","distribution","private-use"]

Consider handling multiple conflicting license matches. See what we look at.

project = Licensee.project "/path/to/a/project"

=> # an array of all matching licenses

Providing an access token

If you wish to scan private GitHub repositories, or are hitting API rate limits, you can configure the embedded Octokit client using environment variables, for example:

OCTOKIT_ACCESS_TOKEN=abc123 licensee

Octokit can also be configured using standard module-level configuration:

# see
Octokit.configure do |c|
  c.access_token = "<your 40 char token>"

license = Licensee.license ""

Advanced API usage

You can gather more information by working with the project object, and the top level Licensee class.

 Licensee::VERSION                                 # The Licensee version
 Licensee.licenses                                 # All the licenses Licensee knows about

 project = Licensee.project "/path/to/a/project"   # Get a Project (Git checkout or just local Filesystem) (post 6.0.0)

 project.license                                   # The matched license
 project.matched_file                              # Object for the particular file containing the apparent license
 project.matched_file.filename                     #   Its filename
 project.matched_file.confidence                   #   The confidence level in the license matching
 project.matched_file.content                      #   The content of your license file
 project.license.content                           # The Open Source License text it matched against