license_finder 0.7.3 → 0.8.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.
Files changed (73) hide show
  1. data/.gitignore +4 -3
  2. data/.travis.yml +1 -8
  3. data/bin/license_finder +31 -1
  4. data/db/migrate/201303290935_create_dependencies.rb +14 -0
  5. data/db/migrate/201303291155_create_licenses.rb +13 -0
  6. data/db/migrate/201303291402_create_approvals.rb +13 -0
  7. data/db/migrate/201303291456_create_ancestries.rb +9 -0
  8. data/db/migrate/201303291519_create_bundler_groups.rb +13 -0
  9. data/db/migrate/201303291720_move_manual_from_approvals_to_licenses.rb +11 -0
  10. data/db/migrate/201303291753_allow_null_license_names.rb +7 -0
  11. data/db/migrate/201304011027_allow_null_dependency_version.rb +7 -0
  12. data/db/migrate/201304020947_change_table_name_licenses_to_license_aliases.rb +5 -0
  13. data/features/approve_dependencies.feature +0 -45
  14. data/features/html_report.feature +1 -11
  15. data/features/license_finder.feature +13 -27
  16. data/features/license_finder_rake_task.feature +2 -1
  17. data/features/set_license.feature +2 -4
  18. data/features/step_definitions/license_finder_steps.rb +25 -0
  19. data/features/step_definitions/steps.rb +40 -26
  20. data/features/text_report.feature +2 -2
  21. data/files/license_finder.yml +1 -1
  22. data/lib/license_finder.rb +14 -6
  23. data/lib/license_finder/bundle.rb +4 -17
  24. data/lib/license_finder/bundle_syncer.rb +2 -3
  25. data/lib/license_finder/bundled_gem.rb +4 -47
  26. data/lib/license_finder/cli.rb +9 -16
  27. data/lib/license_finder/configuration.rb +55 -3
  28. data/lib/license_finder/dependency_report.rb +1 -1
  29. data/lib/license_finder/gem_saver.rb +69 -0
  30. data/lib/license_finder/html_report.rb +2 -2
  31. data/lib/license_finder/license.rb +60 -58
  32. data/lib/license_finder/license_files.rb +36 -0
  33. data/lib/license_finder/license_url.rb +8 -6
  34. data/lib/license_finder/platform.rb +32 -0
  35. data/lib/license_finder/possible_license_file.rb +1 -1
  36. data/lib/license_finder/tables.rb +7 -0
  37. data/lib/license_finder/tables/approval.rb +4 -0
  38. data/lib/license_finder/tables/bundler_group.rb +4 -0
  39. data/lib/license_finder/tables/dependency.rb +31 -0
  40. data/lib/license_finder/tables/license_alias.rb +22 -0
  41. data/lib/license_finder/yml_to_sql.rb +127 -0
  42. data/lib/tasks/license_finder.rake +3 -0
  43. data/lib/templates/html_report.erb +50 -32
  44. data/lib/templates/text_report.erb +3 -2
  45. data/license_finder.gemspec +14 -5
  46. data/readme.md +10 -50
  47. data/spec/lib/license_finder/bundle_spec.rb +22 -19
  48. data/spec/lib/license_finder/bundle_syncer_spec.rb +4 -10
  49. data/spec/lib/license_finder/bundled_gem_spec.rb +40 -108
  50. data/spec/lib/license_finder/cli_spec.rb +3 -3
  51. data/spec/lib/license_finder/configuration_spec.rb +53 -21
  52. data/spec/lib/license_finder/gem_saver_spec.rb +155 -0
  53. data/spec/lib/license_finder/html_report_spec.rb +32 -15
  54. data/spec/lib/license_finder/license_files_spec.rb +50 -0
  55. data/spec/lib/license_finder/tables/dependency_spec.rb +102 -0
  56. data/spec/lib/license_finder/tables/license_alias_spec.rb +54 -0
  57. data/spec/lib/license_finder/text_report_spec.rb +6 -4
  58. data/spec/lib/license_finder/yml_to_sql_spec.rb +99 -0
  59. data/spec/lib/license_finder_spec.rb +5 -5
  60. data/spec/spec_helper.rb +17 -1
  61. metadata +79 -32
  62. data/lib/license_finder/dependency.rb +0 -50
  63. data/lib/license_finder/persistence.rb +0 -1
  64. data/lib/license_finder/persistence/yaml.rb +0 -7
  65. data/lib/license_finder/persistence/yaml/configuration.rb +0 -34
  66. data/lib/license_finder/persistence/yaml/dependency.rb +0 -127
  67. data/lib/license_finder/source_syncer.rb +0 -40
  68. data/lib/templates/dependency.html.erb +0 -54
  69. data/spec/lib/license_finder/dependency_spec.rb +0 -188
  70. data/spec/lib/license_finder/persistence/yaml/dependency_spec.rb +0 -5
  71. data/spec/lib/license_finder/source_syncer_spec.rb +0 -37
  72. data/spec/support/shared_examples/persistence/configuration.rb +0 -28
  73. data/spec/support/shared_examples/persistence/dependency.rb +0 -138
@@ -1,5 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe LicenseFinder::Persistence::Dependency do
4
- it_behaves_like "a persistable dependency"
5
- end
@@ -1,37 +0,0 @@
1
- require "spec_helper"
2
-
3
- module LicenseFinder
4
- describe SourceSyncer do
5
- it "deletes any dependencies no longer in the source" do
6
- foo_dep = double :foo, name: "foo"
7
-
8
- foo_dep.should_receive(:destroy)
9
-
10
- SourceSyncer.new([], [foo_dep]).sync!
11
- end
12
-
13
- it "merges any dependencies in the source" do
14
- source_foo = double :source_foo, name: "foo"
15
- foo = double :foo, name: "foo"
16
-
17
- foo.should_receive(:merge).with source_foo
18
-
19
- SourceSyncer.new([source_foo], [foo]).sync!
20
- end
21
-
22
- it "creates any new source dependencies" do
23
- source_dep = double :source_dep, name: "foo", attributes: double(:attributes)
24
-
25
- source_dep.should_receive :save
26
-
27
- SourceSyncer.new([source_dep], []).sync!
28
- end
29
-
30
- it "returns the synced dependency set" do
31
- source_dep = double(:source_dep, name: "source_dep", attributes: double(:attributes)).as_null_object
32
- existing_dep = double :existing_dep, name: "existing", merge: nil
33
-
34
- SourceSyncer.new([source_dep, existing_dep], [existing_dep]).sync!.should =~ [source_dep, existing_dep]
35
- end
36
- end
37
- end
@@ -1,28 +0,0 @@
1
- shared_examples_for "a persistable configuration" do
2
- let(:klass) { described_class }
3
-
4
- let(:attributes) do
5
- {
6
- "whitelist" => ["FooLicense", "BarLicense"],
7
- "ignore_groups" => [:test, :development]
8
- }
9
- end
10
-
11
- describe '.new' do
12
- subject { klass.new(attributes) }
13
-
14
- context "with known attributes" do
15
- it "should set the all of the attributes on the instance" do
16
- attributes.each do |key, value|
17
- subject.send("#{key}").should == value
18
- end
19
- end
20
- end
21
- end
22
-
23
- describe "#whitelist" do
24
- it "should default to an empty array" do
25
- klass.new.whitelist.should == []
26
- end
27
- end
28
- end
@@ -1,138 +0,0 @@
1
- shared_examples_for "a persistable dependency" do
2
- let(:klass) { described_class }
3
-
4
- let(:attributes) do
5
- {
6
- 'name' => "spec_name",
7
- 'version' => "2.1.3",
8
- 'license' => "GPLv2",
9
- 'approved' => false,
10
- 'notes' => 'some notes',
11
- 'homepage' => 'homepage',
12
- 'license_files' => ['/Users/pivotal/foo/lic1', '/Users/pivotal/bar/lic2'],
13
- 'source' => "bundle",
14
- 'bundler_groups' => ["test"]
15
- }
16
- end
17
-
18
- before do
19
- klass.delete_all
20
- end
21
-
22
- describe '.new' do
23
- subject { klass.new(attributes) }
24
-
25
- context "with known attributes" do
26
- it "should set the all of the attributes on the instance" do
27
- attributes.each do |key, value|
28
- if key != "approved"
29
- subject.send("#{key}").should equal(value), "expected #{value.inspect} for #{key}, got #{subject.send("#{key}").inspect}"
30
- else
31
- subject.approved?.should == value
32
- end
33
- end
34
- end
35
- end
36
-
37
- context "with unknown attributes" do
38
- before do
39
- attributes['foo'] = 'bar'
40
- end
41
-
42
- it "should raise an exception" do
43
- expect { subject }.to raise_exception(NoMethodError)
44
- end
45
- end
46
- end
47
-
48
- describe '.unapproved' do
49
- it "should return all unapproved dependencies" do
50
- klass.new(name: "unapproved dependency", approved: false).save
51
- klass.new(name: "approved dependency", approved: true).save
52
-
53
- unapproved = klass.unapproved
54
- unapproved.count.should == 1
55
- unapproved.collect(&:approved?).any?.should be_false
56
- end
57
- end
58
-
59
- describe '.find_by_name' do
60
- subject { klass.find_by_name gem_name }
61
- let(:gem_name) { "foo" }
62
-
63
- context "when a gem with the provided name exists" do
64
- before do
65
- klass.new(
66
- 'name' => gem_name,
67
- 'version' => '0.0.1'
68
- ).save
69
- end
70
-
71
- its(:name) { should == gem_name }
72
- its(:version) { should == '0.0.1' }
73
- end
74
-
75
- context "when no gem with the provided name exists" do
76
- it { should == nil }
77
- end
78
- end
79
-
80
- describe "#config" do
81
- it 'should respond to it' do
82
- klass.new.should respond_to(:config)
83
- end
84
- end
85
-
86
- describe '#attributes' do
87
- it "should return a hash containing the values of all the accessible properties" do
88
- dep = klass.new(attributes)
89
- attributes = dep.attributes
90
- LicenseFinder::DEPENDENCY_ATTRIBUTES.each do |name|
91
- attributes[name].should == dep.send(name)
92
- end
93
- end
94
- end
95
-
96
- describe '#save' do
97
- it "should persist all of the dependency's attributes" do
98
- dep = klass.new(attributes)
99
- dep.save
100
-
101
- saved_dep = klass.find_by_name(dep.name)
102
-
103
- attributes.each do |key, value|
104
- if key != "approved"
105
- saved_dep.send("#{key}").should eql(value), "expected #{value.inspect} for #{key}, got #{saved_dep.send("#{key}").inspect}"
106
- else
107
- saved_dep.approved?.should == value
108
- end
109
- end
110
- end
111
- end
112
-
113
- describe "#update_attributes" do
114
- it "should update the provided attributes with the provided values" do
115
- gem = klass.new(attributes)
116
- updated_attributes = {"version" => "new_version", "license" => "updated_license"}
117
- gem.update_attributes(updated_attributes)
118
-
119
- saved_gem = klass.find_by_name(gem.name)
120
- saved_gem.version.should == "new_version"
121
- saved_gem.license.should == "updated_license"
122
- end
123
- end
124
-
125
- describe "#destroy" do
126
- it "should remove itself from the database" do
127
- foo_dep = klass.new(name: "foo")
128
- bar_dep = klass.new(name: "bar")
129
- foo_dep.save
130
- bar_dep.save
131
-
132
- expect { foo_dep.destroy }.to change { klass.all.count }.by -1
133
-
134
- klass.all.count.should == 1
135
- klass.all.first.name.should == "bar"
136
- end
137
- end
138
- end