license_finder 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. data/.gitignore +6 -0
  2. data/Gemfile +4 -0
  3. data/MIT-LICENSE +22 -0
  4. data/README.markdown +84 -0
  5. data/Rakefile +12 -0
  6. data/bin/license_finder +7 -0
  7. data/files/license_finder.yml +7 -0
  8. data/lib/license_finder.rb +15 -0
  9. data/lib/license_finder/dependency.rb +63 -0
  10. data/lib/license_finder/dependency_list.rb +55 -0
  11. data/lib/license_finder/file_parser.rb +32 -0
  12. data/lib/license_finder/finder.rb +48 -0
  13. data/lib/license_finder/gem_spec_details.rb +101 -0
  14. data/lib/license_finder/license_file.rb +77 -0
  15. data/lib/license_finder/railtie.rb +9 -0
  16. data/lib/license_finder/version.rb +3 -0
  17. data/lib/tasks/license_finder.rake +17 -0
  18. data/lib/templates/Apache-2.0-body +172 -0
  19. data/lib/templates/GPL-2.0-body +339 -0
  20. data/lib/templates/MIT-body +9 -0
  21. data/license_finder.gemspec +23 -0
  22. data/spec/dependency_list_spec.rb +202 -0
  23. data/spec/dependency_spec.rb +57 -0
  24. data/spec/file_parser_spec.rb +16 -0
  25. data/spec/finder_spec.rb +44 -0
  26. data/spec/fixtures/APACHE-2-LICENSE +202 -0
  27. data/spec/fixtures/GPLv2 +339 -0
  28. data/spec/fixtures/MIT-LICENSE +22 -0
  29. data/spec/fixtures/MIT-LICENSE-with-varied-disclaimer +22 -0
  30. data/spec/fixtures/README-with-MIT-LICENSE +222 -0
  31. data/spec/fixtures/apache_licensed_gem/LICENSE +191 -0
  32. data/spec/fixtures/gplv2_licensed_gem/LICENSE +339 -0
  33. data/spec/fixtures/license_directory/COPYING +0 -0
  34. data/spec/fixtures/license_directory/LICENSE/BSD-2-Clause.txt +25 -0
  35. data/spec/fixtures/license_directory/LICENSE/GPL-2.0.txt +339 -0
  36. data/spec/fixtures/license_directory/LICENSE/LICENSE +191 -0
  37. data/spec/fixtures/license_directory/LICENSE/MIT.txt +21 -0
  38. data/spec/fixtures/license_directory/LICENSE/RUBY.txt +60 -0
  39. data/spec/fixtures/license_names/COPYING.txt +0 -0
  40. data/spec/fixtures/license_names/LICENSE +0 -0
  41. data/spec/fixtures/license_names/Mit-License +0 -0
  42. data/spec/fixtures/license_names/README.rdoc +0 -0
  43. data/spec/fixtures/mit_licensed_gem/LICENSE +22 -0
  44. data/spec/fixtures/mit_licensed_gem_in_README/README.rdoc +222 -0
  45. data/spec/fixtures/mit_licensed_gem_via_url/README +210 -0
  46. data/spec/fixtures/nested_gem/vendor/LICENSE +0 -0
  47. data/spec/fixtures/nested_readme/vendor/README +0 -0
  48. data/spec/fixtures/no_license/.gitkeep +0 -0
  49. data/spec/fixtures/other_licensed_gem/LICENSE +3 -0
  50. data/spec/fixtures/readme/Project ReadMe b/data/spec/fixtures/readme/Project → ReadMe +0 -0
  51. data/spec/fixtures/readme/README +0 -0
  52. data/spec/fixtures/readme/Readme.markdown +0 -0
  53. data/spec/fixtures/utf8_gem/README +210 -0
  54. data/spec/gem_spec_details_spec.rb +167 -0
  55. data/spec/license_file_spec.rb +129 -0
  56. data/spec/spec_helper.rb +10 -0
  57. metadata +159 -0
@@ -0,0 +1,9 @@
1
+ Permission is hereby granted, free of charge, to any person obtaining a copy
2
+ of this software and associated documentation files (the "Software"), to deal
3
+ in the Software without restriction, including without limitation the rights
4
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
5
+ copies of the Software, and to permit persons to whom the Software is
6
+ furnished to do so, subject to the following conditions:
7
+
8
+ The above copyright notice and this permission notice shall be included in
9
+ all copies or substantial portions of the Software.
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "license_finder/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "license_finder"
7
+ s.version = LicenseFinder::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Jacob Maine"]
10
+ s.email = ["jacob.maine@gmail.com"]
11
+ # s.homepage = "http://rubygems.org/gems/license_finder"
12
+ s.summary = %q{License finding heaven.}
13
+ s.description = %q{Find and display licenses of a project's gem dependencies.}
14
+
15
+ s.rubyforge_project = "license_finder"
16
+ s.add_development_dependency 'rspec', '~>2.3'
17
+ s.add_development_dependency 'rr'
18
+
19
+ s.files = `git ls-files`.split("\n")
20
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
21
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
22
+ s.require_paths = ["lib"]
23
+ end
@@ -0,0 +1,202 @@
1
+ require 'spec_helper'
2
+
3
+ describe LicenseFinder::DependencyList do
4
+ before do
5
+ @mock_gemspec = Class.new do
6
+ def initialize(name = nil, version = nil, path = nil)
7
+ @name = name
8
+ @version = version
9
+ @path = path
10
+ end
11
+
12
+ def name
13
+ @name || 'spec_name'
14
+ end
15
+
16
+ def version
17
+ @version || '2.1.3'
18
+ end
19
+
20
+ def full_gem_path
21
+ @path || 'install/path'
22
+ end
23
+ end
24
+
25
+ end
26
+
27
+ describe 'from Bundler' do
28
+ subject do
29
+ mock_bundler = Object.new
30
+ stub(Bundler::Definition).build {mock_bundler}
31
+ stub(mock_bundler).groups {[]}
32
+ stub(mock_bundler).specs_for { [@mock_gemspec.new('gem1', '1.2.3'), @mock_gemspec.new('gem2', '0.4.2')] }
33
+ LicenseFinder::DependencyList.from_bundler
34
+ end
35
+
36
+ it "should have 2 dependencies" do
37
+ subject.dependencies.size.should == 2
38
+ end
39
+
40
+ describe "first" do
41
+ let(:dep) { subject.dependencies.first }
42
+ it { dep.name.should == 'gem1' }
43
+ it { dep.version.should == '1.2.3' }
44
+ end
45
+
46
+ describe "second" do
47
+ let(:dep) { subject.dependencies[1] }
48
+ it { dep.name.should == 'gem2' }
49
+ it { dep.version.should == '0.4.2' }
50
+ end
51
+
52
+ end
53
+
54
+ describe 'from yaml' do
55
+ subject { LicenseFinder::DependencyList.from_yaml("--- \n- name: \"gem1\"\n version: \"1.2.3\"\n license: \"MIT\"\n approved: false\n- name: \"gem2\"\n version: \"0.4.2\"\n license: \"MIT\"\n approved: false\n") }
56
+
57
+ it "should have 2 dependencies" do
58
+ subject.dependencies.size.should == 2
59
+ end
60
+
61
+ describe "first" do
62
+ let(:dep) { subject.dependencies.first }
63
+ it { dep.name.should == 'gem1' }
64
+ it { dep.version.should == '1.2.3' }
65
+ end
66
+
67
+ describe "second" do
68
+ let(:dep) { subject.dependencies[1] }
69
+ it { dep.name.should == 'gem2' }
70
+ it { dep.version.should == '0.4.2' }
71
+ end
72
+
73
+ end
74
+
75
+ describe 'to_yaml' do
76
+ it "should generate yaml" do
77
+ list = LicenseFinder::DependencyList.new([
78
+ LicenseFinder::Dependency.new('b_gem', '0.4.2', 'MIT', false),
79
+ LicenseFinder::Dependency.new('a_gem', '1.2.3', 'MIT', false)
80
+ ])
81
+
82
+ list.to_yaml.should == "--- \n- name: \"a_gem\"\n version: \"1.2.3\"\n license: \"MIT\"\n approved: false\n license_url: \"\"\n notes: \"\"\n license_files:\n readme_files:\n- name: \"b_gem\"\n version: \"0.4.2\"\n license: \"MIT\"\n approved: false\n license_url: \"\"\n notes: \"\"\n license_files:\n readme_files:\n"
83
+ end
84
+ end
85
+
86
+ describe 'round trip' do
87
+ it 'should recreate from to_yaml' do
88
+ list = LicenseFinder::DependencyList.new([
89
+ LicenseFinder::Dependency.new('gem1', '1.2.3', 'MIT', false),
90
+ LicenseFinder::Dependency.new('gem2', '0.4.2', 'MIT', false)
91
+ ])
92
+
93
+ new_list = LicenseFinder::DependencyList.from_yaml(list.to_yaml)
94
+ new_list.dependencies.size.should == 2
95
+ new_list.dependencies.first.name.should == 'gem1'
96
+ new_list.dependencies[1].name.should == 'gem2'
97
+ end
98
+ end
99
+
100
+ describe 'updating dependency list' do
101
+ before(:each) do
102
+ @yml_same = LicenseFinder::Dependency.new('same_gem', '1.2.3', 'MIT', true, 'a', 'b')
103
+ @yml_updated = LicenseFinder::Dependency.new('updated_gem', '1.0.1', 'MIT', true, 'a', 'b')
104
+ @yml_new_license = LicenseFinder::Dependency.new('new_license_gem', '1.0.1', 'MIT', true, 'a', 'b')
105
+ @yml_manual_license = LicenseFinder::Dependency.new('manual_license_gem', '1.0.1', 'Ruby', true, 'a', 'b')
106
+ @yml_removed_gem = LicenseFinder::Dependency.new('removed_gem', '1.0.1', 'MIT', true, 'a', 'b')
107
+ @yml_new_whitelist = LicenseFinder::Dependency.new('new_whitelist_gem', '1.0.1', 'MIT', false, 'a', 'b')
108
+
109
+ @gemspec_same = LicenseFinder::Dependency.new('same_gem', '1.2.3', 'MIT', false)
110
+ @gemspec_new = LicenseFinder::Dependency.new('brand_new_gem', '0.9', 'MIT', false)
111
+ @gemspec_updated = LicenseFinder::Dependency.new('updated_gem', '1.1.2', 'MIT', false)
112
+ @gemspec_new_license = LicenseFinder::Dependency.new('new_license_gem', '2.0.1', 'Apache 2.0', false)
113
+ @gemspec_new_whitelist = LicenseFinder::Dependency.new('new_whitelist_gem', '1.0.1', 'MIT', true)
114
+ @gemspec_manual_license = LicenseFinder::Dependency.new('manual_license_gem', '1.2.1', 'other', false)
115
+
116
+ @list_from_yml = LicenseFinder::DependencyList.new([@yml_same, @yml_updated, @yml_new_license, @yml_removed_gem, @yml_new_whitelist, @yml_manual_license])
117
+ @list_from_gemspec = LicenseFinder::DependencyList.new([@gemspec_same, @gemspec_new, @gemspec_updated, @gemspec_new_license, @gemspec_new_whitelist, @gemspec_manual_license])
118
+ end
119
+
120
+ it "should ignore existing gems with the same version" do
121
+ dep = @list_from_yml.merge(@list_from_gemspec).dependencies.detect { |d| d.name == 'same_gem' }
122
+ dep.approved.should == @yml_same.approved
123
+ dep.license_url.should == 'a'
124
+ dep.notes.should == 'b'
125
+ end
126
+
127
+ it "should keep old license value if gemspec license is other" do
128
+ dep = @list_from_yml.merge(@list_from_gemspec).dependencies.detect { |d| d.name == 'manual_license_gem' }
129
+ dep.license.should == @yml_manual_license.license
130
+ dep.version.should == @gemspec_manual_license.version
131
+ dep.approved.should == @yml_manual_license.approved
132
+ dep.license_url.should == 'a'
133
+ dep.notes.should == 'b'
134
+ end
135
+
136
+ it "should add new gem" do
137
+ dep = @list_from_yml.merge(@list_from_gemspec).dependencies.detect { |d| d.name == 'brand_new_gem' }
138
+ dep.should_not be_nil
139
+ dep.version.should == @gemspec_new.version
140
+ dep.approved.should == @gemspec_new.approved
141
+ dep.license.should == @gemspec_new.license
142
+ dep.license_url.should == ''
143
+ dep.notes.should == ''
144
+ end
145
+
146
+ it "should update version if gem exists and license is the same" do
147
+ dep = @list_from_yml.merge(@list_from_gemspec).dependencies.detect { |d| d.name == 'updated_gem' }
148
+ dep.name.should == @gemspec_updated.name
149
+ dep.approved.should == @yml_updated.approved
150
+ dep.license_url.should == 'a'
151
+ dep.notes.should == 'b'
152
+ end
153
+
154
+ it "should replace gem if version and license are different" do
155
+ dep = @list_from_yml.merge(@list_from_gemspec).dependencies.detect { |d| d.name == 'new_license_gem' }
156
+ dep.name.should == @gemspec_new_license.name
157
+ dep.version.should == @gemspec_new_license.version
158
+ dep.approved.should == @gemspec_new_license.approved
159
+ dep.license_url.should == ''
160
+ dep.notes.should == ''
161
+ end
162
+
163
+ it "should update approved if gemspec gem is approved" do
164
+ dep = @list_from_yml.merge(@list_from_gemspec).dependencies.detect { |d| d.name == 'new_whitelist_gem' }
165
+ dep.name.should == @gemspec_new_whitelist.name
166
+ dep.version.should == @gemspec_new_whitelist.version
167
+ dep.approved.should == @gemspec_new_whitelist.approved
168
+ dep.license_url.should == 'a'
169
+ dep.notes.should == 'b'
170
+ end
171
+
172
+ it "should remove gem if new list doesn't contain it" do
173
+ dep = @list_from_yml.merge(@list_from_gemspec).dependencies.detect { |d| d.name == 'removed_gem' }
174
+ dep.should be_nil
175
+ end
176
+ end
177
+
178
+ describe "#to_s" do
179
+ it "should return a human readable list of dependencies" do
180
+ gem1 = LicenseFinder::Dependency.new('b_gem', '1.2.3', 'MIT', true)
181
+ gem2 = LicenseFinder::Dependency.new('a_gem', '0.9', 'other', false, 'http://foo.com/LICENSE')
182
+
183
+ list = LicenseFinder::DependencyList.new([gem1, gem2])
184
+
185
+ list.to_s.should == "a_gem 0.9, other, http://foo.com/LICENSE\n license files:\n readme files:\nb_gem 1.2.3, MIT"
186
+ end
187
+ end
188
+
189
+ describe '#action_items' do
190
+ it "should return all unapproved dependencies" do
191
+ gem1 = LicenseFinder::Dependency.new('b_gem', '1.2.3', 'MIT', true)
192
+ gem2 = LicenseFinder::Dependency.new('a_gem', '0.9', 'other', false)
193
+ gem3 = LicenseFinder::Dependency.new('c_gem', '0.2', 'other', false)
194
+
195
+ list = LicenseFinder::DependencyList.new([gem1, gem2, gem3])
196
+
197
+ list.action_items.should == "a_gem 0.9, other\n license files:\n readme files:\nc_gem 0.2, other\n license files:\n readme files:"
198
+ end
199
+ end
200
+ end
201
+
202
+
@@ -0,0 +1,57 @@
1
+ require 'spec_helper'
2
+
3
+ class LicenseFinder::MockGemSpec3
4
+ def initialize(path = nil)
5
+ @path = path
6
+ end
7
+
8
+ def name
9
+ 'spec_name'
10
+ end
11
+
12
+ def version
13
+ '2.1.3'
14
+ end
15
+
16
+ def full_gem_path
17
+ @path || 'install/path'
18
+ end
19
+ end
20
+
21
+ #--
22
+ # name: activerecord
23
+ # version: 3.0.5
24
+ # license: MIT
25
+ # approved: true
26
+ # license_url: http://foo.com/README
27
+ # notes: some notes
28
+ # license_files:
29
+ # - path: /Users/pivotal/foo/lic1
30
+ # - path: /Users/pivotal/bar/lic2
31
+ # readme_files:
32
+ # - path: /Users/pivotal/foo/Readme1
33
+ # - path: /Users/pivotal/bar/Readme2
34
+
35
+ describe LicenseFinder::Dependency do
36
+
37
+ describe 'from hash' do
38
+ subject { LicenseFinder::Dependency.from_hash({'name' => "spec_name", 'version' => "2.1.3", 'license' => "MIT", 'approved' => false,
39
+ 'license_url' => 'http://www.apache.org/licenses/LICENSE-2.0.html', 'notes' => 'some notes',
40
+ 'license_files' => [{'path' => '/Users/pivotal/foo/lic1'}, {'path' => '/Users/pivotal/bar/lic2'}],
41
+ 'readme_files' => [{'path' => '/Users/pivotal/foo/Readme1'}, {'path' => '/Users/pivotal/bar/Readme2'}]}) }
42
+
43
+ its(:name) { should == 'spec_name' }
44
+ its(:version) { should == '2.1.3' }
45
+ its(:license) { should == 'MIT' }
46
+ its(:approved) { should == false }
47
+ its(:license_url) { should == "http://www.apache.org/licenses/LICENSE-2.0.html" }
48
+ its(:notes) { should == "some notes" }
49
+ its(:license_files) { should == ["/Users/pivotal/foo/lic1", "/Users/pivotal/bar/lic2"] }
50
+ its(:readme_files) { should == ["/Users/pivotal/foo/Readme1", "/Users/pivotal/bar/Readme2"] }
51
+
52
+ its(:to_yaml_entry) {should == "- name: \"spec_name\"\n version: \"2.1.3\"\n license: \"MIT\"\n approved: false\n license_url: \"http://www.apache.org/licenses/LICENSE-2.0.html\"\n notes: \"some notes\"\n license_files:\n - path: \"/Users/pivotal/foo/lic1\"\n - path: \"/Users/pivotal/bar/lic2\"\n readme_files:\n - path: \"/Users/pivotal/foo/Readme1\"\n - path: \"/Users/pivotal/bar/Readme2\"\n"}
53
+ end
54
+
55
+ end
56
+
57
+
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+
3
+ describe LicenseFinder::FileParser do
4
+ subject { LicenseFinder::FileParser.new('root', 'root/nested/path') }
5
+
6
+ context "ignoring text" do
7
+ before do
8
+ stub(IO).read { "file text" }
9
+ stub(IO).binread { "file text" }
10
+ end
11
+
12
+ its(:file_path) { should == 'nested/path' }
13
+ its(:file_name) { should == 'path' }
14
+ its(:text) { should == 'file text' }
15
+ end
16
+ end
@@ -0,0 +1,44 @@
1
+ require 'spec_helper'
2
+
3
+ describe LicenseFinder::Finder do
4
+ it "should generate a yml file and txt file" do
5
+ stub(File).exists?('./config/license_finder.yml') {false}
6
+ stub(File).exists?('./dependencies.yml') {false}
7
+
8
+ yml_output = StringIO.new
9
+ txt_output = StringIO.new
10
+ stub(File).open('./dependencies.yml', 'w+').yields(yml_output)
11
+ stub(File).open('./dependencies.txt', 'w+').yields(txt_output)
12
+ stub(LicenseFinder::DependencyList).from_bundler.stub!.to_yaml {"output"}
13
+ LicenseFinder::Finder.new.write_files
14
+ yml_output.string.should == "output\n"
15
+ end
16
+
17
+ it 'should update an existing yml file' do
18
+ stub(File).exists?('./config/license_finder.yml') {false}
19
+ stub(File).exists?('./dependencies.yml') {true}
20
+
21
+ yml_output = StringIO.new
22
+ txt_output = StringIO.new
23
+ stub(File).open('./dependencies.yml').stub!.readlines {['existing yml']}
24
+ stub(File).open('./dependencies.yml', 'w+').yields(yml_output)
25
+ stub(File).open('./dependencies.txt', 'w+').yields(txt_output)
26
+
27
+ stub(LicenseFinder::DependencyList).from_yaml.stub!.merge.stub!.to_yaml {"output"}
28
+ stub(LicenseFinder::DependencyList).from_bundler
29
+ LicenseFinder::Finder.new.write_files
30
+ yml_output.string.should == "output\n"
31
+ end
32
+
33
+ it "should load a whitelist from license_finder.yml" do
34
+ stub(File).exists?('./config/license_finder.yml') {true}
35
+ stub(File).open('./config/license_finder.yml').stub!.readlines.stub!.join {"--- \nwhitelist: \n- MIT\n- Apache\nignore_groups: \n- test\n- development\n"}
36
+ LicenseFinder::Finder.new.whitelist.should =~ ['MIT', 'Apache']
37
+ end
38
+
39
+ it "should load a ignore_groups list from license_finder.yml" do
40
+ stub(File).exists?('./config/license_finder.yml') {true}
41
+ stub(File).open('./config/license_finder.yml').stub!.readlines.stub!.join {"--- \nwhitelist: \n- MIT\n- Apache\nignore_groups: \n- test\n- development\n"}
42
+ LicenseFinder::Finder.new.ignore_groups.should == [:test, :development]
43
+ end
44
+ end
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.