papers 2.4.1 → 2.4.2
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +4 -0
- data/Rakefile +1 -0
- data/lib/papers/cli.rb +28 -26
- data/lib/papers/configuration.rb +3 -0
- data/lib/papers/dependency_specification.rb +2 -1
- data/lib/papers/version.rb +1 -1
- data/spec/papers_spec.rb +46 -0
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff0340e975da31aa959dcddcdd5b7a78c9140ecc
|
4
|
+
data.tar.gz: fd4265cbcdbd98799e115667658eb9450e52493f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0d97ddcc2a8b633bf5a091d1da0451cf19f1c2043c419f38b0cf443b17034045e70923236b46664705fbc6e16195d4644c6787fa65e25a907cf5c2453a7cb883
|
7
|
+
data.tar.gz: 19262716885a3d898bf6629376a5e76904ed3c45a9b9a2258a36d8995385cb8966efd23f9e0d6591b72a5acfb4671038ffd09d6e37916208355c0bb8f13d308a
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -68,6 +68,10 @@ Papers.configure do |config|
|
|
68
68
|
# ]
|
69
69
|
# config.license_whitelist << 'New Relic'
|
70
70
|
|
71
|
+
# You can specify packages which should be whitelisted regardless of license, in case you know your usage
|
72
|
+
# is OK even though you prefer not to use its license in other cases.
|
73
|
+
# config.package_whitelist << 'thin-1.7.0'
|
74
|
+
|
71
75
|
# You can specify a single license that, when used, ignores the version. Defaults to nil.
|
72
76
|
# WARNING: You should only use this for software licensed in house.
|
73
77
|
# config.version_whitelisted_license = 'New Relic'
|
data/Rakefile
CHANGED
data/lib/papers/cli.rb
CHANGED
@@ -5,48 +5,50 @@ module Papers
|
|
5
5
|
class CLI
|
6
6
|
|
7
7
|
def run
|
8
|
-
|
9
|
-
begin
|
10
|
-
Papers::ManifestGenerator.new.generate!
|
11
|
-
rescue Papers::FileExistsError => e
|
12
|
-
warn "Error: 'papers_manifest.yml' already exists at '#{e.message}'. Aborting..."
|
13
|
-
end
|
14
|
-
end
|
8
|
+
options.parse!
|
15
9
|
|
16
|
-
|
10
|
+
case @command
|
11
|
+
when :generate
|
12
|
+
Papers::ManifestGenerator.new.generate!
|
13
|
+
when :update
|
17
14
|
Papers::ManifestUpdater.new.update!
|
15
|
+
when :help
|
16
|
+
emit_help ""
|
17
|
+
else
|
18
|
+
emit_help "Unrecognized command."
|
18
19
|
end
|
20
|
+
rescue Papers::FileExistsError => e
|
21
|
+
warn "Error: 'papers_manifest.yml' already exists at '#{e.message}'. Aborting..."
|
22
|
+
rescue OptionParser::ParseError => e
|
23
|
+
emit_help "Problem parsing options: #{e.message}"
|
19
24
|
end
|
20
25
|
|
21
26
|
private
|
22
27
|
|
23
28
|
def options
|
24
|
-
@options ||=
|
25
|
-
|
26
|
-
|
27
|
-
def parse_options
|
28
|
-
options = {}
|
29
|
-
OptionParser.new do |opts|
|
30
|
-
opts.banner = "Usage: papers [options]"
|
29
|
+
@options ||= OptionParser.new do |opts|
|
30
|
+
opts.banner = 'Usage: papers [options]'
|
31
31
|
|
32
|
-
opts.on(
|
33
|
-
|
32
|
+
opts.on('-g', '--generate', 'Generate papers_manifest.yml') do |v|
|
33
|
+
@command = :generate
|
34
34
|
end
|
35
35
|
|
36
36
|
opts.on("-u", "--update", "Update papers_manifest.yml for Rubygems") do |v|
|
37
|
-
|
37
|
+
@command = :update
|
38
38
|
end
|
39
39
|
|
40
|
-
opts.
|
41
|
-
|
42
|
-
exit
|
40
|
+
opts.on('-h', '--help', 'Display this screen') do
|
41
|
+
@command = :help
|
43
42
|
end
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
p @avail_opts if options.empty?
|
43
|
+
end
|
44
|
+
end
|
48
45
|
|
49
|
-
|
46
|
+
def emit_help(header)
|
47
|
+
unless header.empty?
|
48
|
+
puts header
|
49
|
+
puts
|
50
|
+
end
|
51
|
+
puts options
|
50
52
|
end
|
51
53
|
end
|
52
54
|
end
|
data/lib/papers/configuration.rb
CHANGED
@@ -2,6 +2,7 @@ module Papers
|
|
2
2
|
class Configuration
|
3
3
|
attr_accessor :license_whitelist
|
4
4
|
attr_accessor :version_whitelisted_license
|
5
|
+
attr_accessor :package_whitelist
|
5
6
|
|
6
7
|
attr_accessor :manifest_file
|
7
8
|
|
@@ -30,6 +31,8 @@ module Papers
|
|
30
31
|
'ISC'
|
31
32
|
]
|
32
33
|
|
34
|
+
@package_whitelist = []
|
35
|
+
|
33
36
|
@version_whitelisted_license = nil
|
34
37
|
|
35
38
|
@manifest_file = File.join(Dir.pwd, 'config', 'papers_manifest.yml')
|
@@ -16,7 +16,8 @@ module Papers
|
|
16
16
|
|
17
17
|
def acceptable_license?
|
18
18
|
Papers.config.license_whitelist.include?(license) ||
|
19
|
-
Papers.config.version_whitelisted_license == license
|
19
|
+
Papers.config.version_whitelisted_license == license ||
|
20
|
+
Papers.config.package_whitelist.include?(name)
|
20
21
|
end
|
21
22
|
|
22
23
|
protected
|
data/lib/papers/version.rb
CHANGED
data/spec/papers_spec.rb
CHANGED
@@ -121,6 +121,27 @@ describe 'Papers' do
|
|
121
121
|
])
|
122
122
|
end
|
123
123
|
|
124
|
+
it 'is OK with whitelisting specific gems' do
|
125
|
+
allow_any_instance_of(Papers::Configuration).to receive(:package_whitelist).and_return(['foo-1.2'])
|
126
|
+
allow_any_instance_of(Papers::LicenseValidator).to receive(:manifest).and_return({
|
127
|
+
'javascripts' => {},
|
128
|
+
'gems' => {
|
129
|
+
'foo-1.2' => { 'license' => 'GPL' },
|
130
|
+
'baz-1.3' => { 'license' => 'GPL' }
|
131
|
+
}
|
132
|
+
})
|
133
|
+
allow(Bundler).to receive_message_chain(:load, :specs).and_return([
|
134
|
+
double(name: 'foo', version: '1.2', licenses: ['GPL']),
|
135
|
+
double(name: 'baz', version: '1.3', licenses: ['GPL'])
|
136
|
+
])
|
137
|
+
|
138
|
+
expect(validator).not_to be_valid
|
139
|
+
|
140
|
+
expect(validator.errors).to eq([
|
141
|
+
'Gem baz-1.3 is licensed under GPL, which is not whitelisted'
|
142
|
+
])
|
143
|
+
end
|
144
|
+
|
124
145
|
it 'is OK with matching gem sets but complain about a license issue' do
|
125
146
|
allow_any_instance_of(Papers::LicenseValidator).to receive(:manifest).and_return({
|
126
147
|
'javascripts' => {},
|
@@ -413,5 +434,30 @@ describe 'Papers' do
|
|
413
434
|
expect(validator).to be_valid
|
414
435
|
end
|
415
436
|
|
437
|
+
describe "Command Line" do
|
438
|
+
def silently
|
439
|
+
vblevel = $VERBOSE
|
440
|
+
$VERBOSE = nil
|
441
|
+
yield
|
442
|
+
ensure
|
443
|
+
$VERBOSE = vblevel
|
444
|
+
end
|
445
|
+
|
446
|
+
before do
|
447
|
+
@old_argv = ARGV
|
448
|
+
end
|
449
|
+
after do
|
450
|
+
silently { ARGV = @old_argv }
|
451
|
+
end
|
452
|
+
it "runs the papers command and prints out help" do
|
453
|
+
silently { ARGV = %w[-h] }
|
454
|
+
cli = Papers::CLI.new
|
455
|
+
expect(cli).to receive(:puts) do |opts|
|
456
|
+
expect(opts.to_s).to match /^Usage: papers.*/
|
457
|
+
end
|
458
|
+
cli.run
|
459
|
+
end
|
460
|
+
end
|
461
|
+
|
416
462
|
|
417
463
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: papers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.4.
|
4
|
+
version: 2.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ralph Bodenner
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date:
|
15
|
+
date: 2017-05-02 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: rake
|
@@ -100,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
100
100
|
version: '0'
|
101
101
|
requirements: []
|
102
102
|
rubyforge_project:
|
103
|
-
rubygems_version: 2.
|
103
|
+
rubygems_version: 2.6.11
|
104
104
|
signing_key:
|
105
105
|
specification_version: 4
|
106
106
|
summary: Validate the licenses of software dependencies you use
|
@@ -111,4 +111,3 @@ test_files:
|
|
111
111
|
- spec/spec_helper.rb
|
112
112
|
- spec/support/package.json
|
113
113
|
- spec/support/package_with_error.json
|
114
|
-
has_rdoc:
|