license_finder 0.9.0 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +0 -1
  3. data/CHANGELOG.rdoc +27 -3
  4. data/db/migrate/201307250917_add_license_manual_to_dependencies.rb +7 -0
  5. data/db/migrate/201307251004_data_fix_manual_licenses.rb +15 -0
  6. data/db/migrate/201307251107_reassociate_license.rb +23 -0
  7. data/db/migrate/201307251340_remove_manual_from_license_aliases.rb +7 -0
  8. data/features/cli.feature +1 -1
  9. data/features/html_report.feature +3 -2
  10. data/features/project_name.feature +10 -0
  11. data/features/set_license.feature +1 -0
  12. data/features/step_definitions/cli_steps.rb +3 -3
  13. data/features/step_definitions/project_name_steps.rb +3 -0
  14. data/features/step_definitions/set_license_steps.rb +9 -4
  15. data/features/step_definitions/shared_steps.rb +11 -2
  16. data/features/step_definitions/text_report_steps.rb +12 -2
  17. data/features/text_report.feature +7 -1
  18. data/files/dependency_breakdown.png +0 -0
  19. data/files/license_finder.yml +1 -0
  20. data/files/report_breakdown.png +0 -0
  21. data/lib/license_finder.rb +0 -5
  22. data/lib/license_finder/bundle.rb +22 -4
  23. data/lib/license_finder/bundled_gem.rb +17 -10
  24. data/lib/license_finder/bundled_gem_saver.rb +42 -30
  25. data/lib/license_finder/cli.rb +37 -5
  26. data/lib/license_finder/configuration.rb +13 -2
  27. data/lib/license_finder/dependency_manager.rb +21 -8
  28. data/lib/license_finder/reports/dependency_report.rb +1 -1
  29. data/lib/license_finder/reports/reporter.rb +4 -0
  30. data/lib/license_finder/tables/dependency.rb +9 -1
  31. data/lib/license_finder/tables/license_alias.rb +0 -4
  32. data/lib/license_finder/yml_to_sql.rb +1 -11
  33. data/lib/templates/html_report.erb +13 -3
  34. data/license_finder.gemspec +3 -4
  35. data/readme.md +25 -3
  36. data/release/gem_version.rb +3 -0
  37. data/{release.md → release/manual_instructions.md} +6 -0
  38. data/release/publish.sh +29 -0
  39. data/spec/lib/license_finder/bundle_spec.rb +16 -4
  40. data/spec/lib/license_finder/bundled_gem_saver_spec.rb +41 -38
  41. data/spec/lib/license_finder/bundled_gem_spec.rb +22 -4
  42. data/spec/lib/license_finder/cli_spec.rb +22 -0
  43. data/spec/lib/license_finder/configuration_spec.rb +34 -14
  44. data/spec/lib/license_finder/dependency_manager_spec.rb +61 -10
  45. data/spec/lib/license_finder/reporter_spec.rb +35 -1
  46. data/spec/lib/license_finder/tables/dependency_spec.rb +23 -0
  47. data/spec/lib/license_finder/tables/license_alias_spec.rb +0 -16
  48. data/spec/lib/license_finder/yml_to_sql_spec.rb +11 -3
  49. data/spec/lib/license_finder_spec.rb +2 -2
  50. data/spec/spec_helper.rb +3 -13
  51. metadata +21 -8
@@ -1,4 +1,38 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe LicenseFinder::Reporter do
3
+ module LicenseFinder
4
+ describe Reporter do
5
+ describe "#write_reports" do
6
+ subject { Reporter.write_reports }
7
+
8
+ before do
9
+ Dependency.stub(:all) { [double(:dep)] }
10
+ File.any_instance.stub(:puts)
11
+
12
+ LicenseFinder.stub_chain(:config, :dependencies_html) { 'html_file_path' }
13
+ LicenseFinder.stub_chain(:config, :dependencies_text) { 'text_file_path' }
14
+
15
+ TextReport.stub_chain(:new, :to_s) { 'text report' }
16
+ HtmlReport.stub_chain(:new, :to_s) { 'text report' }
17
+
18
+ LicenseFinder.stub_chain(:config, :dependencies_legacy_text) { 'legacy_text_path' }
19
+ File.stub(:exists?).with('legacy_text_path') { false }
20
+
21
+ File.stub(:open).with('html_file_path', 'w+')
22
+ File.stub(:open).with('text_file_path', 'w+')
23
+ end
24
+
25
+ it "writes an html file" do
26
+ File.should_receive(:open).with('html_file_path', 'w+')
27
+ File.should_receive(:open).with('text_file_path', 'w+')
28
+ subject
29
+ end
30
+
31
+ it "deletes old dependencies.txt file" do
32
+ File.stub(:exists?).with('legacy_text_path') { true }
33
+ File.should_receive(:delete).with('legacy_text_path')
34
+ subject
35
+ end
36
+ end
37
+ end
4
38
  end
@@ -76,12 +76,35 @@ module LicenseFinder
76
76
  dependency.stub_chain(:license, whitelisted?: false)
77
77
  dependency.stub_chain(:approval, state: true)
78
78
  dependency.should be_approved
79
+
80
+ dependency.stub_chain(:approval, state: 1) # jruby
81
+ dependency.should be_approved
79
82
  end
80
83
 
81
84
  it "is false otherwise" do
82
85
  dependency.stub_chain(:license, whitelisted?: false)
83
86
  dependency.stub_chain(:approval, state: false)
84
87
  dependency.should_not be_approved
88
+
89
+ dependency.stub_chain(:approval, state: 0) # jruby
90
+ dependency.should_not be_approved
91
+ end
92
+ end
93
+
94
+ describe "#set_license_manually!" do
95
+ let(:license) { LicenseAlias.create(name: 'foolicense') }
96
+ let(:dependency) { Dependency.create(name: 'foogem') }
97
+
98
+ it "sets manual license to true" do
99
+ dependency.license_manual.should be_false
100
+ dependency.set_license_manually!('Updated')
101
+ dependency.license_manual.should be_true
102
+ end
103
+
104
+ it "modifies the license" do
105
+ LicenseAlias.should_receive(:find_or_create).with(name: 'Updated').and_return(license)
106
+ dependency.set_license_manually!('Updated')
107
+ dependency.reload.license.should == license
85
108
  end
86
109
  end
87
110
  end
@@ -10,22 +10,6 @@ module LicenseFinder
10
10
  end
11
11
  end
12
12
 
13
- describe "#set_manually" do
14
- subject do
15
- described_class.create(name: 'Original')
16
- end
17
-
18
- it "modifies the license" do
19
- subject.set_manually('Updated')
20
- subject.reload.name.should == 'Updated'
21
- end
22
-
23
- it "marks the approval as manual" do
24
- subject.set_manually('Updated')
25
- subject.reload.manual.should be_true
26
- end
27
- end
28
-
29
13
  describe "#whitelisted?" do
30
14
  let(:config) { Configuration.new }
31
15
 
@@ -61,7 +61,11 @@ describe LicenseFinder::YmlToSql do
61
61
  described_class.convert_all([legacy_attributes])
62
62
 
63
63
  saved_dep = described_class::Sql::Dependency.first
64
- saved_dep.manual.should == false
64
+ if LicenseFinder::Platform.java?
65
+ saved_dep.manual.should == 0
66
+ else
67
+ saved_dep.manual.should == false
68
+ end
65
69
  end
66
70
  end
67
71
 
@@ -72,7 +76,11 @@ describe LicenseFinder::YmlToSql do
72
76
  described_class.convert_all([legacy_attributes])
73
77
 
74
78
  saved_dep = described_class::Sql::Dependency.first
75
- saved_dep.manual.should == true
79
+ if LicenseFinder::Platform.java?
80
+ saved_dep.manual.should == 1
81
+ else
82
+ saved_dep.manual.should == true
83
+ end
76
84
  end
77
85
  end
78
86
 
@@ -93,7 +101,7 @@ describe LicenseFinder::YmlToSql do
93
101
 
94
102
  saved_dep = described_class::Sql::Dependency.first
95
103
  saved_dep.license.name.should == "GPLv2"
96
- saved_dep.license.url.should == "www.license_url.org"
104
+ saved_dep.license.url.should == "http://www.gnu.org/licenses/gpl-2.0.txt"
97
105
  end
98
106
 
99
107
  it "associates bundler groups" do
@@ -66,7 +66,7 @@ describe LicenseFinder do
66
66
  config = LicenseFinder.config
67
67
  config.dependencies_dir.should == './elsewhere'
68
68
  config.dependencies_yaml.should == './elsewhere/dependencies.yml'
69
- config.dependencies_text.should == './elsewhere/dependencies.txt'
69
+ config.dependencies_text.should == './elsewhere/dependencies.csv'
70
70
  config.dependencies_html.should == './elsewhere/dependencies.html'
71
71
  end
72
72
 
@@ -74,7 +74,7 @@ describe LicenseFinder do
74
74
  config = LicenseFinder.config
75
75
  config.dependencies_dir.should == './doc/'
76
76
  config.dependencies_yaml.should == './doc/dependencies.yml'
77
- config.dependencies_text.should == './doc/dependencies.txt'
77
+ config.dependencies_text.should == './doc/dependencies.csv'
78
78
  config.dependencies_html.should == './doc/dependencies.html'
79
79
  end
80
80
  end
@@ -1,6 +1,7 @@
1
1
  require 'rubygems'
2
2
  require 'bundler/setup'
3
3
 
4
+ require 'pry'
4
5
  require 'license_finder'
5
6
  require 'rspec'
6
7
 
@@ -12,19 +13,8 @@ RSpec.configure do |config|
12
13
  config.mock_with :rspec
13
14
  end
14
15
 
15
- require 'database_cleaner'
16
-
17
16
  RSpec.configure do |config|
18
- config.before(:suite) do
19
- DatabaseCleaner.strategy = :transaction
20
- DatabaseCleaner.clean_with(:truncation, except: [:schema_migrations])
21
- end
22
-
23
- config.before(:each) do
24
- DatabaseCleaner.start
25
- end
26
-
27
- config.after(:each) do
28
- DatabaseCleaner.clean
17
+ config.around(:each) do |example|
18
+ DB.transaction(rollback: :always) { example.run }
29
19
  end
30
20
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: license_finder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jacob Maine
@@ -10,12 +10,13 @@ authors:
10
10
  - David Edwards
11
11
  - Paul Meskers
12
12
  - Brent Wheeldon
13
+ - Trevor John
13
14
  - David Tengdin
14
15
  - William Ramsey
15
16
  autorequire:
16
17
  bindir: bin
17
18
  cert_chain: []
18
- date: 2013-07-16 00:00:00.000000000 Z
19
+ date: 2013-07-30 00:00:00.000000000 Z
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
22
  name: bundler
@@ -130,19 +131,19 @@ dependencies:
130
131
  - !ruby/object:Gem::Version
131
132
  version: '0'
132
133
  - !ruby/object:Gem::Dependency
133
- name: database_cleaner
134
+ name: pry
134
135
  requirement: !ruby/object:Gem::Requirement
135
136
  requirements:
136
- - - '='
137
+ - - '>='
137
138
  - !ruby/object:Gem::Version
138
- version: 0.9.1
139
+ version: '0'
139
140
  type: :development
140
141
  prerelease: false
141
142
  version_requirements: !ruby/object:Gem::Requirement
142
143
  requirements:
143
- - - '='
144
+ - - '>='
144
145
  - !ruby/object:Gem::Version
145
- version: 0.9.1
146
+ version: '0'
146
147
  - !ruby/object:Gem::Dependency
147
148
  name: capybara
148
149
  requirement: !ruby/object:Gem::Requirement
@@ -202,11 +203,16 @@ files:
202
203
  - db/migrate/201304011027_allow_null_dependency_version.rb
203
204
  - db/migrate/201304020947_change_table_name_licenses_to_license_aliases.rb
204
205
  - db/migrate/201304181524_add_manual_to_dependencies.rb
206
+ - db/migrate/201307250917_add_license_manual_to_dependencies.rb
207
+ - db/migrate/201307251004_data_fix_manual_licenses.rb
208
+ - db/migrate/201307251107_reassociate_license.rb
209
+ - db/migrate/201307251340_remove_manual_from_license_aliases.rb
205
210
  - features/approve_dependencies.feature
206
211
  - features/cli.feature
207
212
  - features/html_report.feature
208
213
  - features/ignore_bundle_groups.feature
209
214
  - features/non_bundler_dependencies.feature
215
+ - features/project_name.feature
210
216
  - features/rails_rake.feature
211
217
  - features/set_license.feature
212
218
  - features/step_definitions/approve_dependencies_steps.rb
@@ -214,6 +220,7 @@ files:
214
220
  - features/step_definitions/html_report_steps.rb
215
221
  - features/step_definitions/ignore_bundle_groups_steps.rb
216
222
  - features/step_definitions/non_bundler_steps.rb
223
+ - features/step_definitions/project_name_steps.rb
217
224
  - features/step_definitions/rails_rake_steps.rb
218
225
  - features/step_definitions/set_license_steps.rb
219
226
  - features/step_definitions/shared_steps.rb
@@ -221,7 +228,9 @@ files:
221
228
  - features/step_definitions/whitelist_steps.rb
222
229
  - features/text_report.feature
223
230
  - features/whitelist.feature
231
+ - files/dependency_breakdown.png
224
232
  - files/license_finder.yml
233
+ - files/report_breakdown.png
225
234
  - lib/data/licenses/Apache2.txt
226
235
  - lib/data/licenses/BSD.txt
227
236
  - lib/data/licenses/GPLv2.txt
@@ -268,7 +277,9 @@ files:
268
277
  - lib/templates/text_report.erb
269
278
  - license_finder.gemspec
270
279
  - readme.md
271
- - release.md
280
+ - release/gem_version.rb
281
+ - release/manual_instructions.md
282
+ - release/publish.sh
272
283
  - spec/fixtures/APACHE-2-LICENSE
273
284
  - spec/fixtures/GPLv2
274
285
  - spec/fixtures/ISC-LICENSE
@@ -353,6 +364,7 @@ test_files:
353
364
  - features/html_report.feature
354
365
  - features/ignore_bundle_groups.feature
355
366
  - features/non_bundler_dependencies.feature
367
+ - features/project_name.feature
356
368
  - features/rails_rake.feature
357
369
  - features/set_license.feature
358
370
  - features/step_definitions/approve_dependencies_steps.rb
@@ -360,6 +372,7 @@ test_files:
360
372
  - features/step_definitions/html_report_steps.rb
361
373
  - features/step_definitions/ignore_bundle_groups_steps.rb
362
374
  - features/step_definitions/non_bundler_steps.rb
375
+ - features/step_definitions/project_name_steps.rb
363
376
  - features/step_definitions/rails_rake_steps.rb
364
377
  - features/step_definitions/set_license_steps.rb
365
378
  - features/step_definitions/shared_steps.rb