license_finder 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +6 -0
- data/Gemfile +4 -0
- data/MIT-LICENSE +22 -0
- data/README.markdown +84 -0
- data/Rakefile +12 -0
- data/bin/license_finder +7 -0
- data/files/license_finder.yml +7 -0
- data/lib/license_finder.rb +15 -0
- data/lib/license_finder/dependency.rb +63 -0
- data/lib/license_finder/dependency_list.rb +55 -0
- data/lib/license_finder/file_parser.rb +32 -0
- data/lib/license_finder/finder.rb +48 -0
- data/lib/license_finder/gem_spec_details.rb +101 -0
- data/lib/license_finder/license_file.rb +77 -0
- data/lib/license_finder/railtie.rb +9 -0
- data/lib/license_finder/version.rb +3 -0
- data/lib/tasks/license_finder.rake +17 -0
- data/lib/templates/Apache-2.0-body +172 -0
- data/lib/templates/GPL-2.0-body +339 -0
- data/lib/templates/MIT-body +9 -0
- data/license_finder.gemspec +23 -0
- data/spec/dependency_list_spec.rb +202 -0
- data/spec/dependency_spec.rb +57 -0
- data/spec/file_parser_spec.rb +16 -0
- data/spec/finder_spec.rb +44 -0
- data/spec/fixtures/APACHE-2-LICENSE +202 -0
- data/spec/fixtures/GPLv2 +339 -0
- data/spec/fixtures/MIT-LICENSE +22 -0
- data/spec/fixtures/MIT-LICENSE-with-varied-disclaimer +22 -0
- data/spec/fixtures/README-with-MIT-LICENSE +222 -0
- data/spec/fixtures/apache_licensed_gem/LICENSE +191 -0
- data/spec/fixtures/gplv2_licensed_gem/LICENSE +339 -0
- data/spec/fixtures/license_directory/COPYING +0 -0
- data/spec/fixtures/license_directory/LICENSE/BSD-2-Clause.txt +25 -0
- data/spec/fixtures/license_directory/LICENSE/GPL-2.0.txt +339 -0
- data/spec/fixtures/license_directory/LICENSE/LICENSE +191 -0
- data/spec/fixtures/license_directory/LICENSE/MIT.txt +21 -0
- data/spec/fixtures/license_directory/LICENSE/RUBY.txt +60 -0
- data/spec/fixtures/license_names/COPYING.txt +0 -0
- data/spec/fixtures/license_names/LICENSE +0 -0
- data/spec/fixtures/license_names/Mit-License +0 -0
- data/spec/fixtures/license_names/README.rdoc +0 -0
- data/spec/fixtures/mit_licensed_gem/LICENSE +22 -0
- data/spec/fixtures/mit_licensed_gem_in_README/README.rdoc +222 -0
- data/spec/fixtures/mit_licensed_gem_via_url/README +210 -0
- data/spec/fixtures/nested_gem/vendor/LICENSE +0 -0
- data/spec/fixtures/nested_readme/vendor/README +0 -0
- data/spec/fixtures/no_license/.gitkeep +0 -0
- data/spec/fixtures/other_licensed_gem/LICENSE +3 -0
- data/spec/fixtures/readme/Project ReadMe b/data/spec/fixtures/readme/Project → ReadMe +0 -0
- data/spec/fixtures/readme/README +0 -0
- data/spec/fixtures/readme/Readme.markdown +0 -0
- data/spec/fixtures/utf8_gem/README +210 -0
- data/spec/gem_spec_details_spec.rb +167 -0
- data/spec/license_file_spec.rb +129 -0
- data/spec/spec_helper.rb +10 -0
- metadata +159 -0
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,210 @@
|
|
1
|
+
= Project: Builder
|
2
|
+
|
3
|
+
== Goal
|
4
|
+
|
5
|
+
Provide a simple way to create XML markup and data structures.
|
6
|
+
|
7
|
+
== Classes
|
8
|
+
|
9
|
+
Builder::XmlMarkup:: Generate XML markup notiation
|
10
|
+
Builder::XmlEvents:: Generate XML events (i.e. SAX-like)
|
11
|
+
|
12
|
+
<b>Notes</b>::
|
13
|
+
|
14
|
+
* An <tt>Builder::XmlTree</tt> class to generate XML tree
|
15
|
+
(i.e. DOM-like) structures is also planned, but not yet implemented.
|
16
|
+
Also, the events builder is currently lagging the markup builder in
|
17
|
+
features.
|
18
|
+
|
19
|
+
== Usage
|
20
|
+
|
21
|
+
require 'rubygems'
|
22
|
+
require_gem 'builder', '~> 2.0'
|
23
|
+
|
24
|
+
builder = Builder::XmlMarkup.new
|
25
|
+
xml = builder.person { |b| b.name("Jim"); b.phone("555-1234") }
|
26
|
+
xml #=> <person><name>Jim</name><phone>555-1234</phone></person>
|
27
|
+
|
28
|
+
or
|
29
|
+
|
30
|
+
require 'rubygems'
|
31
|
+
require_gem 'builder'
|
32
|
+
|
33
|
+
builder = Builder::XmlMarkup.new(:target=>STDOUT, :indent=>2)
|
34
|
+
builder.person { |b| b.name("Jim"); b.phone("555-1234") }
|
35
|
+
#
|
36
|
+
# Prints:
|
37
|
+
# <person>
|
38
|
+
# <name>Jim</name>
|
39
|
+
# <phone>555-1234</phone>
|
40
|
+
# </person>
|
41
|
+
|
42
|
+
== Compatibility
|
43
|
+
|
44
|
+
=== Version 2.0.0 Compatibility Changes
|
45
|
+
|
46
|
+
Version 2.0.0 introduces automatically escaped attribute values for
|
47
|
+
the first time. Versions prior to 2.0.0 did not insert escape
|
48
|
+
characters into attribute values in the XML markup. This allowed
|
49
|
+
attribute values to explicitly reference entities, which was
|
50
|
+
occasionally used by a small number of developers. Since strings
|
51
|
+
could always be explicitly escaped by hand, this was not a major
|
52
|
+
restriction in functionality.
|
53
|
+
|
54
|
+
However, it did suprise most users of builder. Since the body text is
|
55
|
+
normally escaped, everybody expected the attribute values to be
|
56
|
+
escaped as well. Escaped attribute values were the number one support
|
57
|
+
request on the 1.x Builder series.
|
58
|
+
|
59
|
+
Starting with Builder version 2.0.0, all attribute values expressed as
|
60
|
+
strings will be processed and the appropriate characters will be
|
61
|
+
escaped (e.g. "&" will be tranlated to "&"). Attribute values
|
62
|
+
that are expressed as Symbol values will not be processed for escaped
|
63
|
+
characters and will be unchanged in output. (Yes, this probably counts
|
64
|
+
as Symbol abuse, but the convention is convenient and flexible).
|
65
|
+
|
66
|
+
Example:
|
67
|
+
|
68
|
+
xml = Builder::XmlMarkup.new
|
69
|
+
xml.sample(:escaped=>"This&That", :unescaped=>:"Here&There")
|
70
|
+
xml.target! =>
|
71
|
+
<sample escaped="This&That" unescaped="Here&There"/>
|
72
|
+
|
73
|
+
=== Version 1.0.0 Compatibility Changes
|
74
|
+
|
75
|
+
Version 1.0.0 introduces some changes that are not backwards
|
76
|
+
compatible with earlier releases of builder. The main areas of
|
77
|
+
incompatibility are:
|
78
|
+
|
79
|
+
* Keyword based arguments to +new+ (rather than positional based). It
|
80
|
+
was found that a developer would often like to specify indentation
|
81
|
+
without providing an explicit target, or specify a target without
|
82
|
+
indentation. Keyword based arguments handle this situation nicely.
|
83
|
+
|
84
|
+
* Builder must now be an explicit target for markup tags. Instead of
|
85
|
+
writing
|
86
|
+
|
87
|
+
xml_markup = Builder::XmlMarkup.new
|
88
|
+
xml_markup.div { strong("text") }
|
89
|
+
|
90
|
+
you need to write
|
91
|
+
|
92
|
+
xml_markup = Builder::XmlMarkup.new
|
93
|
+
xml_markup.div { xml_markup.strong("text") }
|
94
|
+
|
95
|
+
* The builder object is passed as a parameter to all nested markup
|
96
|
+
blocks. This allows you to create a short alias for the builder
|
97
|
+
object that can be used within the block. For example, the previous
|
98
|
+
example can be written as:
|
99
|
+
|
100
|
+
xml_markup = Builder::XmlMarkup.new
|
101
|
+
xml_markup.div { |xml| xml.strong("text") }
|
102
|
+
|
103
|
+
* If you have both a pre-1.0 and a post-1.0 gem of builder installed,
|
104
|
+
you can choose which version to use through the RubyGems
|
105
|
+
+require_gem+ facility.
|
106
|
+
|
107
|
+
require_gem 'builder', "~> 0.0" # Gets the old version
|
108
|
+
require_gem 'builder', "~> 1.0" # Gets the new version
|
109
|
+
|
110
|
+
== Features
|
111
|
+
|
112
|
+
* XML Comments are supported ...
|
113
|
+
|
114
|
+
xml_markup.comment! "This is a comment"
|
115
|
+
#=> <!-- This is a comment -->
|
116
|
+
|
117
|
+
* XML processing instructions are supported ...
|
118
|
+
|
119
|
+
xml_markup.instruct! :xml, :version=>"1.0", :encoding=>"UTF-8"
|
120
|
+
#=> <?xml version="1.0" encoding="UTF-8"?>
|
121
|
+
|
122
|
+
If the processing instruction is omitted, it defaults to "xml".
|
123
|
+
When the processing instruction is "xml", the defaults attributes
|
124
|
+
are:
|
125
|
+
|
126
|
+
<b>version</b>:: 1.0
|
127
|
+
<b>encoding</b>:: "UTF-8"
|
128
|
+
|
129
|
+
* XML entity declarations are now supported to a small degree.
|
130
|
+
|
131
|
+
xml_markup.declare! :DOCTYPE, :chapter, :SYSTEM, "../dtds/chapter.dtd"
|
132
|
+
#=> <!DOCTYPE chapter SYSTEM "../dtds/chapter.dtd">
|
133
|
+
|
134
|
+
The parameters to a declare! method must be either symbols or
|
135
|
+
strings. Symbols are inserted without quotes, and strings are
|
136
|
+
inserted with double quotes. Attribute-like arguments in hashes are
|
137
|
+
not allowed.
|
138
|
+
|
139
|
+
If you need to have an argument to declare! be inserted without
|
140
|
+
quotes, but the arguement does not conform to the typical Ruby
|
141
|
+
syntax for symbols, then use the :"string" form to specify a symbol.
|
142
|
+
|
143
|
+
For example:
|
144
|
+
|
145
|
+
xml_markup.declare! :ELEMENT, :chapter, :"(title,para+)"
|
146
|
+
#=> <!ELEMENT chapter (title,para+)>
|
147
|
+
|
148
|
+
Nested entity declarations are allowed. For example:
|
149
|
+
|
150
|
+
@xml_markup.declare! :DOCTYPE, :chapter do |x|
|
151
|
+
x.declare! :ELEMENT, :chapter, :"(title,para+)"
|
152
|
+
x.declare! :ELEMENT, :title, :"(#PCDATA)"
|
153
|
+
x.declare! :ELEMENT, :para, :"(#PCDATA)"
|
154
|
+
end
|
155
|
+
|
156
|
+
#=>
|
157
|
+
|
158
|
+
<!DOCTYPE chapter [
|
159
|
+
<!ELEMENT chapter (title,para+)>
|
160
|
+
<!ELEMENT title (#PCDATA)>
|
161
|
+
<!ELEMENT para (#PCDATA)>
|
162
|
+
]>
|
163
|
+
|
164
|
+
* Some support for XML namespaces is now available. If the first
|
165
|
+
argument to a tag call is a symbol, it will be joined to the tag to
|
166
|
+
produce a namespace:tag combination. It is easier to show this than
|
167
|
+
describe it.
|
168
|
+
|
169
|
+
xml.SOAP :Envelope do ... end
|
170
|
+
|
171
|
+
Just put a space before the colon in a namespace to produce the
|
172
|
+
right form for builder (e.g. "<tt>SOAP:Envelope</tt>" =>
|
173
|
+
"<tt>xml.SOAP :Envelope</tt>")
|
174
|
+
|
175
|
+
* String attribute values are <em>now</em> escaped by default by
|
176
|
+
Builder (<b>NOTE:</b> this is _new_ behavior as of version 2.0).
|
177
|
+
|
178
|
+
However, occasionally you need to use entities in attribute values.
|
179
|
+
Using a symbols (rather than a string) for an attribute value will
|
180
|
+
cause Builder to not run its quoting/escaping algorithm on that
|
181
|
+
particular value.
|
182
|
+
|
183
|
+
(<b>Note:</b> The +escape_attrs+ option for builder is now
|
184
|
+
obsolete).
|
185
|
+
|
186
|
+
Example:
|
187
|
+
|
188
|
+
xml = Builder::XmlMarkup.new
|
189
|
+
xml.sample(:escaped=>"This&That", :unescaped=>:"Here&There")
|
190
|
+
xml.target! =>
|
191
|
+
<sample escaped="This&That" unescaped="Here&There"/>
|
192
|
+
|
193
|
+
* UTF-8 Support
|
194
|
+
|
195
|
+
Builder correctly translates UTF-8 characters into valid XML. (New
|
196
|
+
in version 2.0.0). Thanks to Sam Ruby for the translation code.
|
197
|
+
|
198
|
+
Example:
|
199
|
+
|
200
|
+
xml = Builder::Markup.new
|
201
|
+
xml.sample("I�t�rn�ti�n�l")
|
202
|
+
xml.target! =>
|
203
|
+
"<sample>Iñtërnâtiônàl</sample>"
|
204
|
+
|
205
|
+
== Contact
|
206
|
+
|
207
|
+
Author:: Jim Weirich
|
208
|
+
Email:: jim@weirichhouse.org
|
209
|
+
Home Page:: http://onestepback.org
|
210
|
+
License:: MIT Licence (http://www.opensource.org/licenses/mit-license.html)
|
@@ -0,0 +1,167 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe LicenseFinder::GemSpecDetails do
|
4
|
+
before do
|
5
|
+
@mock_gemspec = Class.new do
|
6
|
+
def initialize(path = nil)
|
7
|
+
@path = path
|
8
|
+
end
|
9
|
+
|
10
|
+
def name
|
11
|
+
'spec_name'
|
12
|
+
end
|
13
|
+
|
14
|
+
def version
|
15
|
+
'2.1.3'
|
16
|
+
end
|
17
|
+
|
18
|
+
def full_gem_path
|
19
|
+
if @path
|
20
|
+
gem_install_path = File.join(File.dirname(__FILE__), '/../', @path)
|
21
|
+
raise Errno::ENOENT, @path unless File.exists?(gem_install_path)
|
22
|
+
gem_install_path
|
23
|
+
else
|
24
|
+
'install/path'
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
subject { LicenseFinder::GemSpecDetails.new(@mock_gemspec.new) }
|
31
|
+
|
32
|
+
its(:name) { should == 'spec_name 2.1.3' }
|
33
|
+
its(:dependency_name) { should == 'spec_name' }
|
34
|
+
its(:dependency_version) { should == '2.1.3' }
|
35
|
+
its(:install_path) { should == 'install/path' }
|
36
|
+
|
37
|
+
describe "#license_files" do
|
38
|
+
it "is empty if there aren't any license files" do
|
39
|
+
LicenseFinder::GemSpecDetails.new(@mock_gemspec.new).license_files.should == []
|
40
|
+
end
|
41
|
+
|
42
|
+
it "includes files with names like LICENSE, License or COPYING" do
|
43
|
+
gem_spec = @mock_gemspec.new('spec/fixtures/license_names')
|
44
|
+
LicenseFinder::GemSpecDetails.new(gem_spec).license_files.map(&:file_name).should =~
|
45
|
+
%w[COPYING.txt LICENSE Mit-License README.rdoc]
|
46
|
+
end
|
47
|
+
|
48
|
+
it "includes files deep in the hierarchy" do
|
49
|
+
gem_spec = @mock_gemspec.new('spec/fixtures/nested_gem')
|
50
|
+
LicenseFinder::GemSpecDetails.new(gem_spec).license_files.map { |f| [f.file_name, f.file_path] }.should =~
|
51
|
+
[['LICENSE', 'vendor/LICENSE']]
|
52
|
+
end
|
53
|
+
|
54
|
+
it "includes both files nested inside LICENSE directory and top level files" do
|
55
|
+
gem_spec = @mock_gemspec.new('spec/fixtures/license_directory')
|
56
|
+
found_license_files = LicenseFinder::GemSpecDetails.new(gem_spec).license_files
|
57
|
+
found_license_files.map(&:file_name).should =~
|
58
|
+
%w[BSD-2-Clause.txt GPL-2.0.txt MIT.txt RUBY.txt COPYING LICENSE]
|
59
|
+
found_license_files.map(&:file_path).should =~
|
60
|
+
%w[LICENSE/BSD-2-Clause.txt LICENSE/GPL-2.0.txt LICENSE/MIT.txt LICENSE/RUBY.txt COPYING LICENSE/LICENSE]
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe "#readme_files" do
|
65
|
+
it "is empty if there aren't any readme files" do
|
66
|
+
LicenseFinder::GemSpecDetails.new(@mock_gemspec.new).readme_files.should == []
|
67
|
+
end
|
68
|
+
|
69
|
+
it "includes files with names like README, Readme or COPYING" do
|
70
|
+
gem_spec = @mock_gemspec.new('spec/fixtures/readme')
|
71
|
+
LicenseFinder::GemSpecDetails.new(gem_spec).readme_files.map(&:file_name).should =~
|
72
|
+
%w[Project\ ReadMe README Readme.markdown]
|
73
|
+
end
|
74
|
+
|
75
|
+
it "includes files deep in the hierarchy" do
|
76
|
+
gem_spec = @mock_gemspec.new('spec/fixtures/nested_readme')
|
77
|
+
LicenseFinder::GemSpecDetails.new(gem_spec).readme_files.map { |f| [f.file_name, f.file_path] }.should =~
|
78
|
+
[['README', 'vendor/README']]
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
describe 'to dependency' do
|
83
|
+
describe 'with MIT License' do
|
84
|
+
subject do
|
85
|
+
LicenseFinder::GemSpecDetails.new(@mock_gemspec.new('spec/fixtures/mit_licensed_gem'), ['MIT']).dependency
|
86
|
+
end
|
87
|
+
|
88
|
+
its(:name) { should == 'spec_name' }
|
89
|
+
its(:version) { should == '2.1.3' }
|
90
|
+
its(:license) { should == 'MIT' }
|
91
|
+
its(:approved) { should == true }
|
92
|
+
its(:license_url) { should == '' }
|
93
|
+
its(:notes) { should == '' }
|
94
|
+
end
|
95
|
+
|
96
|
+
describe 'with MIT License in README' do
|
97
|
+
subject do
|
98
|
+
LicenseFinder::GemSpecDetails.new(@mock_gemspec.new('spec/fixtures/mit_licensed_gem_in_README'), ['MIT']).dependency
|
99
|
+
end
|
100
|
+
|
101
|
+
its(:name) { should == 'spec_name' }
|
102
|
+
its(:version) { should == '2.1.3' }
|
103
|
+
its(:license) { should == 'MIT' }
|
104
|
+
its(:approved) { should == true }
|
105
|
+
its(:license_url) { should == '' }
|
106
|
+
its(:notes) { should == '' }
|
107
|
+
end
|
108
|
+
|
109
|
+
describe 'with MIT License in README' do
|
110
|
+
subject do
|
111
|
+
LicenseFinder::GemSpecDetails.new(@mock_gemspec.new('spec/fixtures/mit_licensed_gem_via_url'), ['MIT']).dependency
|
112
|
+
end
|
113
|
+
|
114
|
+
its(:name) { should == 'spec_name' }
|
115
|
+
its(:version) { should == '2.1.3' }
|
116
|
+
its(:license) { should == 'MIT' }
|
117
|
+
its(:approved) { should == true }
|
118
|
+
its(:license_url) { should == '' }
|
119
|
+
its(:notes) { should == '' }
|
120
|
+
end
|
121
|
+
|
122
|
+
describe 'with Apache License' do
|
123
|
+
subject do
|
124
|
+
LicenseFinder::GemSpecDetails.new(@mock_gemspec.new('spec/fixtures/apache_licensed_gem'), ['Apache 2.0']).dependency
|
125
|
+
end
|
126
|
+
|
127
|
+
its(:name) { should == 'spec_name' }
|
128
|
+
its(:version) { should == '2.1.3' }
|
129
|
+
its(:license) { should == 'Apache 2.0' }
|
130
|
+
its(:approved) { should == true }
|
131
|
+
its(:license_url) { should == '' }
|
132
|
+
its(:notes) { should == '' }
|
133
|
+
end
|
134
|
+
|
135
|
+
describe 'with GPLv2 License' do
|
136
|
+
subject do
|
137
|
+
LicenseFinder::GemSpecDetails.new(@mock_gemspec.new('spec/fixtures/gplv2_licensed_gem'), ['GPLv2']).dependency
|
138
|
+
end
|
139
|
+
|
140
|
+
its(:name) { should == 'spec_name' }
|
141
|
+
its(:version) { should == '2.1.3' }
|
142
|
+
its(:license) { should == 'GPLv2' }
|
143
|
+
its(:approved) { should == true }
|
144
|
+
its(:license_url) { should == '' }
|
145
|
+
its(:notes) { should == '' }
|
146
|
+
end
|
147
|
+
|
148
|
+
describe 'with unknown license' do
|
149
|
+
subject { LicenseFinder::GemSpecDetails.new(@mock_gemspec.new('spec/fixtures/other_licensed_gem')).dependency }
|
150
|
+
|
151
|
+
its(:name) { should == 'spec_name' }
|
152
|
+
its(:version) { should == '2.1.3' }
|
153
|
+
its(:license) { should == 'other' }
|
154
|
+
its(:approved) { should == false }
|
155
|
+
its(:license_url) { should == '' }
|
156
|
+
its(:notes) { should == '' }
|
157
|
+
end
|
158
|
+
|
159
|
+
describe 'with UTF8 file License' do
|
160
|
+
it "handles non UTF8 encodings" do
|
161
|
+
expect do
|
162
|
+
LicenseFinder::GemSpecDetails.new(@mock_gemspec.new('spec/fixtures/utf8_gem')).dependency
|
163
|
+
end.not_to raise_error ArgumentError, "invalid byte sequence in UTF-8"
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
@@ -0,0 +1,129 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe LicenseFinder::LicenseFile do
|
4
|
+
subject { LicenseFinder::LicenseFile.new('gem', 'gem/license/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
|
+
describe "#to_hash" do
|
13
|
+
it "includes file path" do
|
14
|
+
subject.to_hash['file_name'].should == 'license/path'
|
15
|
+
end
|
16
|
+
|
17
|
+
it "does not include file text by default" do
|
18
|
+
subject.to_hash['text'].should be_nil
|
19
|
+
end
|
20
|
+
|
21
|
+
it "includes file text if requested" do
|
22
|
+
subject.include_license_text = true
|
23
|
+
subject.to_hash['text'].should == 'file text'
|
24
|
+
end
|
25
|
+
|
26
|
+
it "includes data about license" do
|
27
|
+
subject.to_hash.should have_key 'body_type'
|
28
|
+
subject.to_hash.should have_key 'header_type'
|
29
|
+
subject.to_hash.should have_key 'disclaimer_of_liability'
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context "with MIT like license" do
|
35
|
+
before do
|
36
|
+
stub(IO).read { File.read(File.join(File.dirname(__FILE__), '/fixtures/MIT-LICENSE')) }
|
37
|
+
stub(IO).binread { File.read(File.join(File.dirname(__FILE__), '/fixtures/MIT-LICENSE')) }
|
38
|
+
end
|
39
|
+
|
40
|
+
its(:body_type) { should == 'mit' }
|
41
|
+
its(:header_type) { should == 'mit' }
|
42
|
+
its(:disclaimer_of_liability) { should == 'mit: THE AUTHORS OR COPYRIGHT HOLDERS' }
|
43
|
+
end
|
44
|
+
|
45
|
+
context "with MIT reference in README" do
|
46
|
+
before do
|
47
|
+
stub(IO).read { File.read(File.join(File.dirname(__FILE__), '/fixtures/README-with-MIT-LICENSE')) }
|
48
|
+
stub(IO).binread { File.read(File.join(File.dirname(__FILE__), '/fixtures/README-with-MIT-LICENSE')) }
|
49
|
+
end
|
50
|
+
|
51
|
+
its(:body_type) { should == 'other' }
|
52
|
+
its(:header_type) { should == 'mit' }
|
53
|
+
its(:disclaimer_of_liability) { should == 'other' }
|
54
|
+
end
|
55
|
+
|
56
|
+
context "with MIT url in README" do
|
57
|
+
before do
|
58
|
+
stub(IO).read { 'MIT Licence (http://www.opensource.org/licenses/mit-license.html)' }
|
59
|
+
stub(IO).binread { 'MIT Licence (http://www.opensource.org/licenses/mit-license.html)' }
|
60
|
+
end
|
61
|
+
|
62
|
+
its(:body_type) { should == 'mit' }
|
63
|
+
its(:disclaimer_of_liability) { should == 'mit: THE AUTHORS OR COPYRIGHT HOLDERS' }
|
64
|
+
end
|
65
|
+
|
66
|
+
|
67
|
+
|
68
|
+
context "with Apache like license" do
|
69
|
+
before do
|
70
|
+
stub(IO).read { File.read(File.join(File.dirname(__FILE__), '/fixtures/APACHE-2-LICENSE')) }
|
71
|
+
stub(IO).binread { File.read(File.join(File.dirname(__FILE__), '/fixtures/APACHE-2-LICENSE')) }
|
72
|
+
end
|
73
|
+
|
74
|
+
its(:body_type) { should == 'apache' }
|
75
|
+
end
|
76
|
+
|
77
|
+
context "with GPLv2 like license" do
|
78
|
+
before do
|
79
|
+
stub(IO).read { File.read(File.join(File.dirname(__FILE__), '/fixtures/GPLv2')) }
|
80
|
+
stub(IO).binread { File.read(File.join(File.dirname(__FILE__), '/fixtures/GPLv2')) }
|
81
|
+
end
|
82
|
+
|
83
|
+
its(:body_type) { should == 'gplv2' }
|
84
|
+
end
|
85
|
+
|
86
|
+
context "with another license" do
|
87
|
+
before do
|
88
|
+
stub(IO).read { "a non-standard license" }
|
89
|
+
stub(IO).binread { "a non-standard license" }
|
90
|
+
end
|
91
|
+
|
92
|
+
its(:body_type) { should == 'other' }
|
93
|
+
its(:header_type) { should == 'other' }
|
94
|
+
its(:disclaimer_of_liability) { should == 'other' }
|
95
|
+
end
|
96
|
+
|
97
|
+
context "with variation in disclaimer of liability" do
|
98
|
+
before do
|
99
|
+
stub(IO).read { File.read('spec/fixtures/MIT-LICENSE-with-varied-disclaimer') }
|
100
|
+
stub(IO).binread { File.read('spec/fixtures/MIT-LICENSE-with-varied-disclaimer') }
|
101
|
+
end
|
102
|
+
|
103
|
+
its(:body_type) { should == 'mit' }
|
104
|
+
its(:header_type) { should == 'mit' }
|
105
|
+
its(:disclaimer_of_liability) { should == 'mit: THE AUTHORS' }
|
106
|
+
end
|
107
|
+
|
108
|
+
context "with empty license file" do
|
109
|
+
before do
|
110
|
+
stub(IO).read { "" }
|
111
|
+
stub(IO).binread { "" }
|
112
|
+
end
|
113
|
+
|
114
|
+
describe "#to_hash" do
|
115
|
+
it "is safe" do
|
116
|
+
lambda { subject.to_hash }.should_not raise_error
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
describe "with variations on MIT header" do
|
122
|
+
before do
|
123
|
+
stub(IO).read { '(The MIT License)' }
|
124
|
+
stub(IO).binread { '(The MIT License)' }
|
125
|
+
end
|
126
|
+
|
127
|
+
its(:header_type) { should == 'mit' }
|
128
|
+
end
|
129
|
+
end
|