license-compatibility 1.4.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 43bffa2cc0a5572d7209879d564e49999c8b9065
4
- data.tar.gz: 5e7c17e467e2cf9a94c4bea422eee108efdb6b05
3
+ metadata.gz: a9b836aa63d8b42686e9d83db0955aa93b87943d
4
+ data.tar.gz: e20de8bc61396605f16686e2a07dd2b00ca673e6
5
5
  SHA512:
6
- metadata.gz: 91d87ed20f58ef48e8a6367325259b311fb3032675cce572c71b7f10713eac28130d4bfc20f9a708f1405f470d767901fadd6a2d5d638482260dcc864a0d97e9
7
- data.tar.gz: b4f90166ac309514573f26e8a260a1dbfd29e3e2f3f6375c664be91acbf7a2d2e4b29f7637478d4434b328847ff4aba8f0bb27c7dc843aa8c0cf405987d0085a
6
+ metadata.gz: 3a04e6e9d72126e4eb2b1fa185314f820c39ed0470edbc1744610d2272fc765db071103a04acf020d100ff32d0e23d51b08b4fdf9ebd7417f701cf5df32fd20b
7
+ data.tar.gz: 00b63d3e9ae6bb5e0ff06d6fb0b002508d40fb5bb83d52ec968308d3cb3c8ff2c7e1d4e5f97dadbf067f2c783f2635d589ab429c2a4db62219cd50925f381f1d
@@ -0,0 +1,166 @@
1
+ ## Contributing to Libraries.io :heart:
2
+ Thanks for considering contributing. These guidelines outline how to contribute to the [Libraries.io](http://github.com/librariesio) project.
3
+
4
+ ## Table of Contents
5
+ [What is Libraries.io all about?](#whats-librariesio-about)
6
+ [What should I know Beofre I get started?](#what-should-i-know-before-i-get-started)
7
+ * [Code of conduct](#code-of-conduct)
8
+ * [Langauge](#langauge)
9
+ * [Installation and setup](#setup)
10
+
11
+ [How can I contribute?](#how-can-i-contribute)
12
+ * [Reporting bugs](#reporting-bugs)
13
+ * [Suggesting enhancements](#suggesting-enhancements)
14
+ * [Suggesting a new feature](#suggesting-new-features)
15
+ * [Your first contribution](#your-first-contribution)
16
+ * [Tackling something meatier](#tackling-something-meatier)
17
+
18
+ [How can I talk to other contributors?](#how-can-i-talk-to-other-contributors)
19
+ * [Chat](#chat)
20
+ * [Video](#video)
21
+ * [Social media](#twitter)
22
+
23
+ [Our workflow](#workflow)
24
+
25
+
26
+ ## What's Libraries.io About?
27
+ _Our goal is to raise the quality of all software._
28
+
29
+ By outlining our [mission and strategy](https://docs.libraries.io/strategy) we hope to give you more power to make decisions and determine how best to spend your time. Specifically we tackle three distinct problems:
30
+
31
+ * Discovery: _Helping developers make faster, more informed decisions about the software that they use._
32
+ * Maintainability: _Helping maintainers understand more about the software they depend upon and the consumers of their software._
33
+ * Sustainability: _Supporting undervalued software by highlighting shortfalls in contribution and funneling support to them._
34
+
35
+ ## What Should I Know Before I Get Started?
36
+
37
+ ### Code of Conduct
38
+ Libraries.io is an open and inclusive [community of people](https://github.com/orgs/librariesio/people) working together. We expect contributors to abide by our [contributor code of conduct](https://docs.libraries.io/CODE_OF_CONDUCT.md) which basically say 'be excellent to each other'. Please report unacceptable behavior to conduct@libraries.io
39
+
40
+ ### Langauge
41
+ We communicate predominately in English. Contributions to the project should be made with English as the first language. We are happy for members of the community to communicate in a language other than English in chat, email and video but be aware that this might be considered exclusive by other members of the community.
42
+
43
+ ### Setup
44
+ If you wish to make contributions to Libraries.io then you'll need a local version of the site to test. You can find instructions to install the correct Ruby version, Postgres, and to set up the database in our [README](https://github.com/librariesio/libraries.io/blob/master/README.md#getting-started).
45
+
46
+ ## How Can I Contribute?
47
+
48
+ ### Reporting Bugs
49
+
50
+ The simplest thing that you can do to help us is by filing good bug reports, so here we go:
51
+
52
+ #### Before Submitting a Bug Report
53
+
54
+ * Double-check that the bug is persistent. The site is still in it's infancy and sometimes artifacts may appear and disappear.
55
+ * Double-check the bug hasn't already been reported [on our issue tracker](https://github.com/issues?utf8=%E2%9C%93&q=is%3Aopen+is%3Aissue+org%3Alibrariesio), they *should* be labelled `bug` or `bugsnag`.
56
+
57
+ If something hasn't been raised, you can go ahead and create a new issue using [the template](https://docs.libraries.io/issue_template.md). If you'd like to help investigate further or fix the bug just mention it in your issue and check out our [workflow](#workflow).
58
+
59
+ ### Suggesting Enhancements
60
+
61
+ The next simplest thing you can do to help us is by telling us how we can improve the features we already support, here we go:
62
+
63
+ #### Before Submitting an Enhancement
64
+
65
+ * Check that the enhancement is not already [in our issue tracker](https://github.com/issues?utf8=%E2%9C%93&q=is%3Aopen+is%3Aissue+org%3Alibrariesio), they should be labelled 'enhancement'.
66
+
67
+ If there isn't already an issue for feature then go ahead and create a new issue for it using the [template](https://docs.libraries.io/issue_template.md). If you'd like to work on the enhancement then just mention it in a comment and check out our [workflow](#workflow).
68
+
69
+ ### Suggesting New Features
70
+
71
+ If you're into this zone then you need to understand a little more about what we're trying to achieve:
72
+
73
+ #### Before Suggesting a Feature
74
+
75
+ * Check that it aligns with [our strategy](https://docs.libraries.io/strategy) and is specifically not in line with something we have said we will not do (for the moment this is anything to do with ranking *people*).
76
+ * Check that the feature is not already [in our issue tracker](https://github.com/issues?utf8=%E2%9C%93&q=is%3Aopen+is%3Aissue+org%3Alibrariesio), they should be tagged 'feature'.
77
+ * Specifically check that it is not already a [funded commitment](https://github.com/librariesio/supporters/issues).
78
+
79
+ If you're still thinking about that killer feature that no one else is thinking about then *please* create an issue for it using the [template](https://docs.libraries.io/issue_template.md).
80
+
81
+ ### Your First Contribution
82
+ You're in luck! We label issues that are ideal for first time contributors with [`first-pr`](https://github.com/issues?utf8=%E2%9C%93&q=is%3Aopen+is%3Aissue+user%3Alibrariesio+label%3A%22first-pr%22). For someone who wants something a little more meaty you might find an issue that needs some assistance with [`help wanted`](https://github.com/issues?utf8=%E2%9C%93&q=is%3Aopen+is%3Aissue+user%3Alibrariesio+label%3A%22help+wanted%22). Next you'll want to read our [workflow](#workflow).
83
+
84
+ ### Tackling Something Meatier
85
+
86
+ Tickets are labeled by size, skills required and to indicate workflow. Details can be found in our [labelling policy](https://docs.libraries.io/labelling).
87
+
88
+ To get you started you might want to check out issues concerning [documentation](https://github.com/librariesio/documentation/issues/), [user experience](https://github.com/librariesio/libraries.io/labels/ux), [visual design](https://github.com/librariesio/libraries.io/issues/labels/visual%20design) or perhaps something already [awaiting help](https://github.com/librariesio/libraries.io/labels/help%20wanted). You may find the following useful:
89
+
90
+ * Our [strategy](https://docs.libraries.io/strategy) which outlines what our goals are, how we are going to achieve those goals and what we are specifically going to avoid.
91
+ * An [overview](https://docs.libraries.io/overview) of the components that make up the Libraries.io project and run the [https://libraries.io](https://libraries.io) site.
92
+
93
+ ## How Can I Talk To Other Contributors?
94
+
95
+ ### Chat
96
+ We use [Slack](http://slack.io) for chat. There's an open invitation avaialble to anyone who wishes to join the conversation at [http://slack.libraries.io](http://slack.libraries.io).
97
+
98
+ We try to use the following channels accordingly:
99
+
100
+ * `#general` channel is used for general, water cooler-type conversation, contributor updates and issue discusion.
101
+ * `#events` is used to share and discuss events that may be of interest to or attended by members of the community
102
+ * `#activity` contains notifications from the various platforms that we use to keep the Libraries.io project turning. Including notifications from GitHub, Twitter and our servers.
103
+
104
+ Members are encouraged to openly discuss their work, their lives, share views and ask for help using chat. It should be considered a *safe space* in which there is *no such thing as a stupid question*. Conversely no one contributor should ever be expected to have read something said in a chat. If someone should know something then it should be written down as an issue and/or documented in an obvious place for others to find.
105
+
106
+ ### Video
107
+ [Google Hangouts](http://hangouts.google.com) is our preferred tool for video chat. We operate an [open hangout](http://bit.ly/2kWtYak) for anyone to jump into at any time to discuss issues face to face.
108
+
109
+ ### Regular updates
110
+ Contributors are encouraged to share what they're working on. We do this through daily or weekly updates in the `#general` channel on Slack. Updates should take the format 'currently working on X, expecting to move onto Y, blocked on Z' where x, y and z are issues in our [issue tracker](https://github.com/issues?utf8=%E2%9C%93&q=is%3Aopen+is%3Aissue+org%3Alibrariesio).
111
+
112
+ Additionally we host an [open hangout](http://bit.ly/2kWtYak) for any contributor to join at *5pm UTC on a Tuesday* to discuss their work, the next week's priorities and to ask questions of other contributors regarding any aspect of the project. Again this is considered a *safe space* in which *there is no such thing as a stupid question*.
113
+
114
+ ### Mail
115
+ The [core team](https://github.com/orgs/librariesio/teams/core) operate a mailing list for project updates. If you'd like to subscribe you'll find a form in the footer on [Libraries.io](http://libraries.io).
116
+
117
+ ### Twitter
118
+ We have an account on Twitter at [@librariesio](http://twitter.com/librariesio). This is predominately used to retweet news, events and musings by contributors rather than as a direct method of communication. Contributors are encouraged to use @librariesio in a tweet when talking about the project, so that we may retweet if appropriate. The account is moderated and protected by the [core team](https://github.com/orgs/librariesio/teams/core).
119
+
120
+ ### Facebook
121
+ We have a Facebook page at [@libraries.io](https://www.facebook.com/libraries.io). Again this is predominantly used to gather and reflect news, events and musings by contributors rather than as a direct method of communication. Contributors are encouraged to reference Libraries.io in a post when talking about the project, so that we may reflect this if appropriate. Again the account is moderated and protected by the [core team](https://github.com/orgs/librariesio/teams/core).
122
+
123
+ ### Medium
124
+ We have a Medium account at [@librariesio](https://medium.com/@librariesio) and once again it is used to reflect news, events and musings by contributors rather than a direct method of communication. Contributors are encouraged to reference @librariesio in a post when talking about the project, so that we may recommend it if appropriate. Again the account is moderated and protected by the [core team](https://github.com/orgs/librariesio/teams/core).
125
+
126
+ ## Workflow
127
+ In general we use [GitHub](https://help.github.com/) and [Git](https://git-scm.com/docs/gittutorial) to support our workflow. If you are unfamiliar with those tools then you should check them out until you feel you have a basic understanding of GitHub and a working understanding of Git. Specifically you should understand how forking, branching, committing, PRing and merging works.
128
+
129
+ #### Forking
130
+ We prefer that contributors fork the project in order to contribute.
131
+
132
+ #### Branching
133
+ We *try* to use principles of [GitHub-flow](https://lucamezzalira.com/2014/03/10/git-flow-vs-github-flow/) in our branching model. That is the `master` branch will always be deployable to the live site, and that every branch from that will be used to add a feature, fix a bug, improve something or otherwise represent an atomic unit of work.
134
+
135
+ #### Ticketing
136
+ We *try* to create an issue for everything. That is any bug, feature or enhancement that is worth an open, focussed and documented discussion.
137
+
138
+ #### Labelling
139
+ We constrain labels as they are a key part of our workflow. Tickets will be labeled according to our [labelling policy](https://docs.libraries.io/labelling).
140
+
141
+ #### Templates
142
+ We use templates to guide contributors toward good practice in [filing bugs, requesting enhancements and features](https://docs.libraries.io/issue_template.md) and in [issuing pull-requests](https://docs.libraries.io/pull_request_template.md).
143
+
144
+ #### Commenting
145
+ If it possible to comment your contribution — for instance if you are contributing code — then do so in a way that is simple, clear, concise and lowers the level of understanding necessary for others to comprehend what comes afterward does or achieves. If you are contributing code it is very likely it will be rejected if it does not contain sufficient comments.
146
+
147
+ #### Committing
148
+ When committing to a branch be sure to use plain, simple language that describes the incremental changes made on the branch toward the overall goal. Avoid unnecessary complexity. Simplify whenever possible. Assume a reasonable but not comprehensive knowledge of the tools, techniques and context of your work.
149
+
150
+ #### Testing
151
+ When adding or fixing functionality, tests should be added to help reduce future regressions and breakage. All tests are ran automatically when new commits are pushed to a branch. Pull requests with broken/missing tests are not likely to be merged.
152
+
153
+ #### Submitting for Review
154
+ Once a piece of work (in a branch) is complete it should be readied for review. This is your last chance to ensure that your contribution is [properly tested](#testing). If you are contributing code it is likely your contribution will be rejected if it would lower the test-coverage. Once this is done you can submit a pull-request following the [template](https://docs.libraries.io/pull_request_template.md).
155
+
156
+ It is likely that your contributions will need to be checked by at least one member of the [core team](https://github.com/orgs/librariesio/teams/core) prior to merging. It is also incredibly likely that your contribution may need some re-work in order to be accepted. Particularly if it lacks an appropriate level of comments, tests or it is difficult to understand your commits. Please do not take offense if this is the case. We understand that contributors give their time because they want to improve the project but please understand it is another's responsibility to ensure that the project is maintainable, and good practices like these are key to ensuring that is possible.
157
+
158
+ #### Reviewing a PR
159
+ We appreciate that it may be difficult to offer constructive criticism, but it is a necessary part of ensuring the project is maintainable and successful. If it is difficult to understand something, request it is better commented. If you do not feel assured of the robustness of a contribution, request it is better tested. If it is unclear what the goal of the piece of work is and how it relates to the [strategy](https://docs.libraries.io/strategy), request a clarification in the corresponding issue. If a pull-request has no corresponding issue, decreases code coverage or otherwise decreases the quality of the project. Reject it. Otherwise, merge it.
160
+
161
+ #### Merging
162
+ As we keep the `master` branch in a permanent state of 'deployment ready' once-merged your contribution will be live on the next deployment.
163
+
164
+ #### Deploying
165
+ Any member of the [deployers](https://github.com/orgs/librariesio/teams/deployers) team are able to redeploy the site. If you require a deployment then you might find one of them in our `#general` [chat channel on Slack](slack.libraries.io).
166
+
@@ -0,0 +1,18 @@
1
+ Thanks for taking the time to raise an issue. This template should guide you through the process of submitting a bug, enhancement or feature request. Please erase any part of this template that is not relevant to your issue.
2
+
3
+ ## Bugs
4
+ Before submitting a bug report:
5
+
6
+ - [ ] Double-check that the bug is persistent,
7
+ - [ ] Double-check the bug hasn't already been reported [on our issue tracker](https://github.com/issues?utf8=%E2%9C%93&q=is%3Aopen+is%3Aissue+org%3Alibrariesio), they *should* be labelled `bug` or `bugsnag`.
8
+
9
+ If you have completed those steps then please replace this section with a description of the steps taken to recreate the bug, the expected behavior and the observed behavior.
10
+
11
+ ## Enhancements and Features
12
+
13
+ Before submitting an enhancement or feature request:
14
+
15
+ - [ ] Check that the enhancement is not already [in our issue tracker](https://github.com/issues?utf8=%E2%9C%93&q=is%3Aopen+is%3Aissue+org%3Alibrariesio), they should be labelled 'enhancement'.,
16
+ - [ ] For large feature requests, check that your request aligns with our strategy http://docs.libraries.io/strategy.
17
+
18
+ If you have complete the above step then please replace this section with a description of your proposed enhancement or feature, the motivation for it, an approach and any alternative approaches considered, and whether you are willing and able to create a pull request for it. Note that we may close this issue if it's not something we're planning on working on.
@@ -0,0 +1,10 @@
1
+ Thanks taking the time to contribute. This template should help guide you through the process of creating a pull request for review. Please erase any part of this template that is not relevant to your pull request:
2
+
3
+
4
+ - [ ] Have you followed the guidelines for [contributors](http://docs.libraries.io/contributorshandbook)?
5
+ - [ ] Have you checked to ensure there aren't other open pull requests on the repository for a similar change?
6
+ - [ ] Is there a corresponding ticket for your pull request?
7
+ - [ ] Have you written new tests for your changes?
8
+ - [ ] Have you successfully run the project with your changes locally?
9
+
10
+ If so then please replace this section with a link to the ticket(s) it addressed, an explanation of your change and why you think we should include it. Thanks again!
data/.gitignore CHANGED
@@ -7,3 +7,4 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+ /.idea/
@@ -0,0 +1 @@
1
+ 2.4.0
@@ -1,6 +1,8 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.2.4
4
- before_install: gem install bundler -v 1.11
3
+ - 2.4.0
4
+ before_install: gem install bundler -v 1.14
5
5
  cache: bundler
6
6
  sudo: false
7
+ script:
8
+ - bundle exec rake spec && bundle exec codeclimate-test-reporter
data/Gemfile CHANGED
@@ -2,3 +2,8 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in license-compatibility.gemspec
4
4
  gemspec
5
+
6
+ group :test do
7
+ gem "simplecov"
8
+ gem "codeclimate-test-reporter", "~> 1.0.0"
9
+ end
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2016 Andrew Nesbitt
3
+ Copyright (c) 2017 Andrew Nesbitt
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,8 +1,14 @@
1
1
  # License::Compatibility
2
2
 
3
- Check compatibility between different SPDX licenses.
3
+ Check compatibility between different SPDX licenses, used by [Libraries.io](https://libraries.io) for checking dependency license compatibility.
4
4
 
5
- I am not a lawyer and any results should be confirmed with a copyright lawyer if it's important to you.
5
+ [![Build Status](https://travis-ci.org/librariesio/license-compatibility.svg?branch=master)](https://travis-ci.org/librariesio/license-compatibility)
6
+ [![Code Climate](https://img.shields.io/codeclimate/github/librariesio/license-compatibility.svg?style=flat)](https://codeclimate.com/github/librariesio/license-compatibility)
7
+ [![Test Coverage](https://img.shields.io/codeclimate/coverage/github/librariesio/license-compatibility.svg?style=flat)](https://codeclimate.com/github/librariesio/license-compatibility)
8
+ [![Code Climate](https://img.shields.io/codeclimate/issues/github/librariesio/license-compatibility.svg)](https://codeclimate.com/github/librariesio/license-compatibility/issues)
9
+ [![license](https://img.shields.io/github/license/librariesio/license-compatibility.svg)](https://github.com/librariesio/license-compatibility/blob/master/LICENSE.txt)
10
+
11
+ *n.b. I am not a lawyer and any results should be confirmed with a copyright lawyer if it's important to you.*
6
12
 
7
13
  ## Installation
8
14
 
@@ -22,8 +28,30 @@ Or install it yourself as:
22
28
 
23
29
  ## Usage
24
30
 
31
+ On the command-line:
32
+
33
+ `license-compatibility [-h] [-v] [-l] [-r file] [args]`
34
+
35
+ Arguments are a list of licenses or a list of package:license couples.
36
+ Examples:
37
+ ```
38
+ license-compatibility MIT GPL-3.0 Unlicense
39
+ license-compatibility my_package:ISC other_pkg:BSD-2-Clause
40
+ ```
41
+ Mixing the two formats is not allowed.
42
+ Additional args after a --read option are accepted.
43
+
44
+ Options:
45
+ - **-l, --list**: Print the list of supported licenses.
46
+ - **-r, --read FILE**: Read arguments from file.
47
+ - **-v, --version**: Show the program version.
48
+ - **-h, --help**: Print help message.
49
+
50
+
51
+ In your code:
52
+
25
53
  ```ruby
26
- License::Compatibility.forward_compatiblity('MIT', 'GPL-3.0') #=> true
54
+ License::Compatibility.forward_compatibility('MIT', 'GPL-3.0') #=> true
27
55
  ```
28
56
 
29
57
  ## Development
@@ -36,7 +64,6 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
36
64
 
37
65
  Bug reports and pull requests are welcome on GitHub at https://github.com/librariesio/license-compatibility. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
38
66
 
39
-
40
67
  ## License
41
68
 
42
69
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -0,0 +1,62 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'license/compatibility'
4
+
5
+ begin
6
+ options = License::CommandLine.parse(ARGV)
7
+ rescue => e
8
+ STDERR.puts e
9
+ exit 2
10
+ end
11
+
12
+ status = 0
13
+
14
+ if options[:version]
15
+ puts options[:version]
16
+
17
+ elsif options[:help]
18
+ puts options[:help]
19
+
20
+ elsif options[:list]
21
+ options[:list].each do |key, array|
22
+ puts "#{key}:"
23
+ array.each do |license|
24
+ puts " #{license}"
25
+ end
26
+ puts
27
+ end
28
+
29
+ else
30
+
31
+ args = ARGV
32
+ if options[:read]
33
+ File.read(options[:read]).split("\n").each { |line|
34
+ unless line.empty?
35
+ args.push(line)
36
+ end
37
+ }
38
+ end
39
+
40
+ if args.empty?
41
+ STDERR.puts License::USAGE
42
+ exit 2
43
+ end
44
+
45
+ begin
46
+ type, args = License::CommandLine.parse_positional(args)
47
+ rescue => e
48
+ STDERR.puts e
49
+ exit 2
50
+ end
51
+
52
+ case type
53
+ when 'licenses'; status = License::Compatibility.check_license_list(args)
54
+ when 'packages'; status = License::Compatibility.check_package_licence_list(args)
55
+ else
56
+ STDERR.puts 'Invalid arguments: they should be a list of licenses'
57
+ STDERR.puts ' or a list of package:license couples.'
58
+ status = 2
59
+ end
60
+ end
61
+
62
+ exit status
@@ -1,12 +1,16 @@
1
1
  require 'json'
2
- require "license/compatibility/version"
2
+ require 'optparse'
3
+ require 'license/compatibility/version'
3
4
 
4
5
  module License
6
+ EXEC = File.basename($PROGRAM_NAME)
7
+ USAGE = "Usage: #{EXEC} [-h] [-v] [-l] [-r file] [args]"
8
+
5
9
  module Compatibility
6
- def self.forward_compatiblity(source_license, derivative_license)
7
- souce_type = license_type(source_license)
10
+ def self.forward_compatibility(source_license, derivative_license)
11
+ source_type = license_type(source_license)
8
12
  derivative_type = license_type(derivative_license)
9
- case souce_type
13
+ case source_type
10
14
  when :public_domain
11
15
  return true
12
16
  when :permissive, :weak_copyleft
@@ -16,7 +20,7 @@ module License
16
20
  when :network_copyleft
17
21
  [:network_copyleft].include? derivative_type
18
22
  else
19
- raise 'Unknown license compatiblity'
23
+ raise "Unknown license compatibility: #{source_license} and #{derivative_license}"
20
24
  end
21
25
  end
22
26
 
@@ -25,7 +29,7 @@ module License
25
29
  end
26
30
 
27
31
  def self.license_type(license)
28
- license = license.gsub('+', '')
32
+ license = license.delete('+')
29
33
  if license_data['public_domain'].include?(license)
30
34
  :public_domain
31
35
  elsif license_data['permissive'].include?(license)
@@ -37,7 +41,111 @@ module License
37
41
  elsif license_data['network_copyleft'].include?(license)
38
42
  :network_copyleft
39
43
  else
40
- raise 'Unknown license type'
44
+ raise "Unknown license type: #{license}"
45
+ end
46
+ end
47
+
48
+ def self.filter_known_licenses(list)
49
+ known = []
50
+ list.each { |license |
51
+ begin
52
+ self.license_type(license)
53
+ unless known.include? license
54
+ known.push(license)
55
+ end
56
+ rescue => e
57
+ STDERR.puts e
58
+ end
59
+ }
60
+ return known
61
+ end
62
+
63
+ def self.check_license_list(list)
64
+ result = true
65
+ self.filter_known_licenses(list).permutation(2).to_a.each { |couple|
66
+ intermediate_result = self.forward_compatibility(couple[0], couple[1])
67
+ puts "#{couple[0]} is not forward-compatible with #{couple[1]}" unless intermediate_result
68
+ result &= intermediate_result
69
+ }
70
+ result
71
+ end
72
+
73
+ def self.check_package_licence_list(list)
74
+ result = true
75
+ known_licenses = self.filter_known_licenses(list.map { |x| x[1] })
76
+ list.select { |x| known_licenses.include? x[1] }.permutation(2).to_a.each { |couple|
77
+ intermediate_result = self.forward_compatibility(couple[0][1], couple[1][1])
78
+ puts "#{couple[0][0]} (#{couple[0][1]}) is not forward-compatible with #{couple[1][0]} (#{couple[1][1]})" unless intermediate_result
79
+ result &= intermediate_result
80
+ }
81
+ result
82
+ end
83
+ end
84
+
85
+ module CommandLine
86
+ def self.parse(args)
87
+ options = {}
88
+ option_parser = OptionParser.new do |opts|
89
+ opts.banner = "#{USAGE}\n\n"
90
+ opts.banner += "Arguments:\n"
91
+ opts.banner += " List of licenses or list of package:license couples (separated by ':').\n"
92
+ opts.banner += " Example: 'MIT' 'GPL-3.0' or 'my_package:ISC' 'other_pkg:BSD-2-Clause'.\n"
93
+ opts.banner += " Mixing the two formats is not allowed.\n"
94
+ opts.banner += " Additional args after a --read option are accepted.\n\n"
95
+ opts.banner += "Options:"
96
+
97
+ opts.on('-l', '--list', 'Print the list of supported licenses.') do
98
+ options[:list] = License::Compatibility.license_data
99
+ return options
100
+ end
101
+
102
+ opts.on('-r', '--read FILE', 'Read arguments from file.') do |file|
103
+ unless File.exist?(file)
104
+ raise Errno::ENOENT, "#{file}"
105
+ end
106
+ unless File.file?(file)
107
+ raise ArgumentError, "#{file} is a directory, you must specify a regular file"
108
+ end
109
+ options[:read] = file
110
+ end
111
+
112
+ opts.on('-v', '--version', "Show the program version (#{License::Compatibility::VERSION}).") do
113
+ options[:version] = "license-compatibility v#{License::Compatibility::VERSION}"
114
+ return options
115
+ end
116
+
117
+ opts.on('-h', '--help', 'Print this help.') do
118
+ options[:help] = opts.to_s
119
+ return options
120
+ end
121
+ end
122
+ option_parser.parse!(args)
123
+ return options
124
+ end
125
+
126
+ def self.parse_positional(args)
127
+ licenses = false
128
+ packages = false
129
+ prepared = []
130
+
131
+ args.each { |arg|
132
+ split = arg.split(':', 2)
133
+ if split.length == 2
134
+ prepared.push(split)
135
+ packages = true
136
+ else
137
+ prepared += split
138
+ licenses = true
139
+ end
140
+ raise ArgumentError, 'do not mix license and package:license arguments' if (licenses && packages)
141
+ }
142
+
143
+ if packages
144
+ return 'packages', prepared
145
+ elsif licenses
146
+ return 'licenses', prepared
147
+ else
148
+ return 'unknown', prepared
41
149
  end
42
150
  end
43
151
  end
@@ -1,5 +1,5 @@
1
1
  module License
2
2
  module Compatibility
3
- VERSION = "1.4.0"
3
+ VERSION = "2.0.0"
4
4
  end
5
5
  end
@@ -14,11 +14,11 @@ Gem::Specification.new do |spec|
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
- spec.bindir = "exe"
18
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
17
+ spec.bindir = "bin"
18
+ spec.executables = ["license-compatibility"]
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_development_dependency "bundler", "~> 1.10"
22
- spec.add_development_dependency "rake", "~> 11.0"
23
- spec.add_development_dependency "rspec", "~> 3.4"
21
+ spec.add_development_dependency "bundler", "~> 1.14"
22
+ spec.add_development_dependency "rake", "~> 12.0"
23
+ spec.add_development_dependency "rspec", "~> 3.5"
24
24
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: license-compatibility
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Nesbitt
8
8
  autorequire:
9
- bindir: exe
9
+ bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-20 00:00:00.000000000 Z
11
+ date: 2017-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,59 +16,64 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.10'
19
+ version: '1.14'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.10'
26
+ version: '1.14'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '11.0'
33
+ version: '12.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '11.0'
40
+ version: '12.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '3.4'
47
+ version: '3.5'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '3.4'
54
+ version: '3.5'
55
55
  description:
56
56
  email:
57
57
  - andrewnez@gmail.com
58
- executables: []
58
+ executables:
59
+ - license-compatibility
59
60
  extensions: []
60
61
  extra_rdoc_files: []
61
62
  files:
63
+ - ".github/CONTRIBUTING.md"
64
+ - ".github/ISSUE_TEMPLATE.md"
65
+ - ".github/PULL_REQUEST_TEMPLATE.md"
62
66
  - ".gitignore"
63
67
  - ".rspec"
68
+ - ".ruby-version"
64
69
  - ".travis.yml"
65
70
  - CODE_OF_CONDUCT.md
66
- - CONTRIBUTING.md
67
71
  - Gemfile
68
72
  - LICENSE.txt
69
73
  - README.md
70
74
  - Rakefile
71
75
  - bin/console
76
+ - bin/license-compatibility
72
77
  - bin/setup
73
78
  - lib/license/compatibility.rb
74
79
  - lib/license/compatibility/version.rb
@@ -94,8 +99,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
94
99
  version: '0'
95
100
  requirements: []
96
101
  rubyforge_project:
97
- rubygems_version: 2.6.4
102
+ rubygems_version: 2.6.8
98
103
  signing_key:
99
104
  specification_version: 4
100
105
  summary: Check compatibility between different SPDX licenses
101
106
  test_files: []
107
+ has_rdoc:
@@ -1,10 +0,0 @@
1
- # Contributing
2
-
3
- * Fork the project.
4
- * Make your feature addition or bug fix.
5
- * Add tests for it. This is important so I don't break it in a future version unintentionally.
6
- * Send a pull request. Bonus points for topic branches.
7
-
8
- ## Code of Conduct
9
-
10
- Please note that this project is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md). By participating in this project you agree to abide by its terms.