license_finder 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +22 -0
- data/README.markdown +56 -92
- data/Rakefile +1 -1
- data/bin/license_finder +1 -1
- data/features/approve_dependencies.feature +49 -0
- data/features/html_report.feature +48 -0
- data/features/license_finder.feature +36 -0
- data/features/license_finder_rake_task.feature +36 -0
- data/features/rails_rake.feature +9 -0
- data/features/step_definitions/steps.rb +78 -31
- data/features/text_report.feature +27 -0
- data/lib/{templates/Apache.txt → data/licenses/Apache2.txt} +0 -0
- data/lib/{templates → data/licenses}/BSD.txt +0 -0
- data/lib/{templates → data/licenses}/GPLv2.txt +0 -0
- data/lib/{templates → data/licenses}/ISC.txt +0 -0
- data/lib/{templates → data/licenses}/LGPL.txt +0 -0
- data/lib/{templates → data/licenses}/MIT.txt +0 -0
- data/lib/{templates → data/licenses}/NewBSD.txt +0 -0
- data/lib/{templates → data/licenses}/Ruby.txt +0 -0
- data/lib/{templates → data/licenses}/SimplifiedBSD.txt +0 -0
- data/lib/license_finder.rb +11 -32
- data/lib/license_finder/bundle.rb +33 -0
- data/lib/license_finder/bundled_gem.rb +20 -14
- data/lib/license_finder/cli.rb +4 -3
- data/lib/license_finder/configuration.rb +34 -0
- data/lib/license_finder/dependency.rb +27 -22
- data/lib/license_finder/dependency_list.rb +35 -13
- data/lib/license_finder/license.rb +11 -1
- data/lib/license_finder/license/apache2.rb +8 -0
- data/lib/license_finder/license/bsd.rb +2 -0
- data/lib/license_finder/license/gplv2.rb +2 -0
- data/lib/license_finder/license/isc.rb +1 -0
- data/lib/license_finder/license/lgpl.rb +1 -0
- data/lib/license_finder/license/mit.rb +4 -1
- data/lib/license_finder/license/new_bsd.rb +3 -0
- data/lib/license_finder/license/ruby.rb +2 -2
- data/lib/license_finder/license/simplified_bsd.rb +3 -0
- data/lib/license_finder/license_url.rb +10 -0
- data/lib/license_finder/possible_license_file.rb +2 -2
- data/lib/license_finder/railtie.rb +1 -3
- data/lib/license_finder/reporter.rb +51 -0
- data/lib/license_finder/viewable.rb +31 -0
- data/lib/tasks/license_finder.rake +3 -28
- data/lib/templates/dependency.html.erb +54 -0
- data/lib/templates/dependency_list.html.erb +38 -0
- data/license_finder.gemspec +12 -4
- data/spec/lib/license_finder/bundled_gem_spec.rb +5 -3
- data/spec/lib/license_finder/dependency_list_spec.rb +54 -9
- data/spec/lib/license_finder/dependency_spec.rb +93 -57
- data/spec/lib/license_finder/license/apache_spec.rb +2 -2
- data/spec/lib/license_finder/license/mit_spec.rb +1 -1
- data/spec/lib/license_finder/license_spec.rb +14 -0
- data/spec/lib/license_finder/license_url_spec.rb +20 -0
- data/spec/lib/license_finder/reporter_spec.rb +5 -0
- data/spec/lib/license_finder_spec.rb +2 -0
- data/spec/spec_helper.rb +0 -1
- data/spec/support/license_examples.rb +6 -0
- metadata +68 -33
- data/features/executables/license_finder.feature +0 -19
- data/features/rake_tasks/action_items.feature +0 -27
- data/features/rake_tasks/action_items_ok.feature +0 -23
- data/features/rake_tasks/generate_dependencies.feature +0 -62
- data/features/rake_tasks/init.feature +0 -26
- data/features/rake_tasks/regressions.feature +0 -18
- data/lib/license_finder/bundler_dependency_query.rb +0 -51
- data/lib/license_finder/finder.rb +0 -39
- data/lib/license_finder/license/apache.rb +0 -5
- data/spec/lib/license_finder/finder_spec.rb +0 -36
data/.travis.yml
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
rvm:
|
2
|
+
- 1.9.3
|
3
|
+
- 1.9.2
|
4
|
+
- jruby-18mode
|
5
|
+
- jruby-19mode
|
6
|
+
- rbx-18mode
|
7
|
+
- rbx-19mode
|
8
|
+
- ruby-head
|
9
|
+
- jruby-head
|
10
|
+
- 1.8.7
|
11
|
+
- ree
|
12
|
+
|
13
|
+
matrix:
|
14
|
+
allow_failures:
|
15
|
+
- rvm: jruby-18mode
|
16
|
+
- rvm: jruby-19mode
|
17
|
+
- rvm: rbx-18mode
|
18
|
+
- rvm: rbx-19mode
|
19
|
+
- rvm: ruby-head
|
20
|
+
- rvm: jruby-head
|
21
|
+
- rvm: 1.8.7
|
22
|
+
- rvm: ree
|
data/README.markdown
CHANGED
@@ -1,38 +1,61 @@
|
|
1
1
|
# License Finder
|
2
2
|
|
3
3
|
[![Build Status](https://secure.travis-ci.org/pivotal/LicenseFinder.png)](http://travis-ci.org/pivotal/LicenseFinder)
|
4
|
+
[![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/pivotal/LicenseFinder)
|
4
5
|
|
5
6
|
With bundler it's easy for your project to depend on many gems. This decomposition is nice, but managing licenses becomes difficult. This tool gathers info about the licenses of the gems in your project.
|
6
7
|
|
7
8
|
## Installation
|
8
|
-
=====
|
9
9
|
|
10
10
|
Add license_finder to your Rails project's Gemfile and `bundle`:
|
11
11
|
|
12
12
|
```ruby
|
13
|
-
gem 'license_finder'
|
13
|
+
gem 'license_finder'
|
14
14
|
```
|
15
15
|
|
16
|
-
|
16
|
+
## Usage
|
17
|
+
|
18
|
+
License finder will generate reports of action items - i.e., dependencies that do not fall within your license "whitelist".
|
17
19
|
|
18
20
|
```sh
|
19
|
-
$ bundle exec
|
21
|
+
$ bundle exec license_finder
|
20
22
|
```
|
21
23
|
|
22
|
-
|
23
|
-
This is where you should add licenses which are allowed on the project, so they will be automatically approved.
|
24
|
+
The first time you run this, `license_finder` will create a default configuration file `./config/license_finder.yml`:
|
24
25
|
|
25
|
-
## Usage
|
26
26
|
|
27
|
-
|
28
|
-
|
27
|
+
```yaml
|
28
|
+
---
|
29
|
+
whitelist:
|
30
|
+
#- MIT
|
31
|
+
#- Apache 2.0
|
32
|
+
ignore_groups:
|
33
|
+
#- test
|
34
|
+
#- development
|
35
|
+
```
|
36
|
+
|
37
|
+
This allows you to configure bundler groups and add licenses to the whitelist.
|
29
38
|
|
30
|
-
|
31
|
-
|
39
|
+
On a brand new Rails project, you could expect `license_finder` to output something like the following
|
40
|
+
(assuming you whitelisted the MIT license in your `config/license_finder.yml`):
|
41
|
+
|
42
|
+
```
|
43
|
+
Dependencies that need approval:
|
44
|
+
|
45
|
+
highline, 1.6.14, ruby
|
46
|
+
json, 1.7.5, ruby
|
47
|
+
mime-types, 1.19, ruby
|
48
|
+
rails, 3.2.8, other
|
49
|
+
rdoc, 3.12, other
|
50
|
+
rubyzip, 0.9.9, ruby
|
51
|
+
xml-simple, 1.1.1, other
|
32
52
|
```
|
33
53
|
|
34
|
-
|
35
|
-
|
54
|
+
The executable task will also write out a dependencies.yml, dependencies.txt, and dependencies.html file in the root of your project.
|
55
|
+
|
56
|
+
The latter two files are human readable reports that you could send to your non-technical business partners, lawyers, etc.
|
57
|
+
|
58
|
+
`license_finder` will also return a non-zero exit status if there are
|
36
59
|
unapproved dependencies. You could use this in a CI build, for example, to alert you whenever someone adds an
|
37
60
|
unapproved dependency to the project.
|
38
61
|
|
@@ -41,15 +64,15 @@ and then edited the resulting file).
|
|
41
64
|
|
42
65
|
### Manually approving dependencies
|
43
66
|
|
44
|
-
Whenever you have a dependency that falls outside of your whitelist, `
|
67
|
+
Whenever you have a dependency that falls outside of your whitelist, `license_finder` will tell you.
|
45
68
|
If your business decides that this is an acceptable risk, you can manually approve the dependency by finding its
|
46
69
|
section in the `dependencies.yml` file and setting its `approved` attribute to true. For example, lets assume you've only
|
47
70
|
whitelisted the "MIT" license in your `config/license_finder.yml`. You then add the 'awesome_gpl_gem' to your Gemfile,
|
48
|
-
which we'll assume is licensed with the `GPL` license. You then run `
|
71
|
+
which we'll assume is licensed with the `GPL` license. You then run `license_finder` and see
|
49
72
|
the gem listed in the output:
|
50
73
|
|
51
74
|
```txt
|
52
|
-
awesome_gpl_gem 1.0.0, GPL
|
75
|
+
awesome_gpl_gem, 1.0.0, GPL
|
53
76
|
```
|
54
77
|
|
55
78
|
Your business tells you that in this case, it's acceptable to use this gem. You should now update your `dependencies.yml`
|
@@ -62,7 +85,7 @@ file, setting the `approved` attribute to `true` for the `awesome_gpl_gem` secti
|
|
62
85
|
approved: true
|
63
86
|
```
|
64
87
|
|
65
|
-
If you rerun `
|
88
|
+
If you rerun `license_finder`, you should no longer see `awesome_gpl_gem` in the output.
|
66
89
|
|
67
90
|
|
68
91
|
## Manually managing Javascript Dependencies
|
@@ -82,89 +105,26 @@ You could then update the "approved" attribute to true once you have signoff fro
|
|
82
105
|
remember any manually added licenses between successive runs.
|
83
106
|
|
84
107
|
|
85
|
-
## Usage
|
86
|
-
|
87
|
-
As a standalone script:
|
88
|
-
|
89
|
-
```sh
|
90
|
-
$ git clone http://github.com/pivotal/LicenseFinder.git license_finder
|
91
|
-
$ cd /path/to/your/project
|
92
|
-
$ /path/to/license_finder/bin/license_finder
|
93
|
-
```
|
94
|
-
|
95
|
-
Optionally add `--with-licenses` to include the full text of the licenses in the output.
|
96
|
-
|
108
|
+
## Usage with Rake
|
97
109
|
|
98
|
-
|
110
|
+
First, add license finder to your project's Gemfile:
|
99
111
|
|
100
|
-
|
101
|
-
|
102
|
-
```yaml
|
103
|
-
---
|
104
|
-
whitelist:
|
105
|
-
- MIT
|
106
|
-
- Apache 2.0
|
107
|
-
ignore_groups:
|
108
|
-
- test
|
109
|
-
- development
|
112
|
+
```ruby
|
113
|
+
gem "license_finder"
|
110
114
|
```
|
111
115
|
|
112
|
-
|
113
|
-
|
114
|
-
```yaml
|
115
|
-
---
|
116
|
-
- name: "json_pure"
|
117
|
-
version: "1.5.1"
|
118
|
-
license: "other"
|
119
|
-
approved: false
|
116
|
+
Next, update your project's Rakefile with the license finder rake task:
|
120
117
|
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
118
|
+
```ruby
|
119
|
+
require 'bundler/setup'
|
120
|
+
require 'license_finder'
|
121
|
+
LicenseFinder.load_rake_tasks
|
125
122
|
```
|
126
123
|
|
127
|
-
|
128
|
-
|
129
|
-
json_pure 1.5.1, other
|
130
|
-
rake 0.8.7, MIT
|
124
|
+
You can now run `bundle exec rake license_finder`. This is the equivalent of running `bundle exec license_finder`.
|
131
125
|
|
132
|
-
|
133
|
-
|
134
|
-
```yaml
|
135
|
-
---
|
136
|
-
json_pure 1.5.1:
|
137
|
-
dependency_name: json_pure
|
138
|
-
dependency_version: 1.5.1
|
139
|
-
install_path: /some/path/.rvm/gems/ruby-1.9.2-p180/gems/json_pure-1.5.1
|
140
|
-
license_files:
|
141
|
-
- file_name: COPYING
|
142
|
-
header_type: other
|
143
|
-
body_type: other
|
144
|
-
disclaimer_of_liability: other
|
145
|
-
- file_name: COPYING-json-jruby
|
146
|
-
header_type: other
|
147
|
-
body_type: other
|
148
|
-
disclaimer_of_liability: other
|
149
|
-
readme_files:
|
150
|
-
- file_name: README
|
151
|
-
mentions_license: true
|
152
|
-
- file_name: README-json-jruby.markdown
|
153
|
-
mentions_license: false
|
154
|
-
---
|
155
|
-
rake 0.8.7:
|
156
|
-
dependency_name: rake
|
157
|
-
dependency_version: 0.8.7
|
158
|
-
install_path: /some/path/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7
|
159
|
-
license_files:
|
160
|
-
- file_name: MIT-LICENSE
|
161
|
-
header_type: other
|
162
|
-
body_type: mit
|
163
|
-
disclaimer_of_liability: "mit: THE AUTHORS OR COPYRIGHT HOLDERS"
|
164
|
-
readme_files:
|
165
|
-
- file_name: README
|
166
|
-
mentions_license: true
|
167
|
-
```
|
126
|
+
This could be handy if you have a build for CI that you want to break when you have unapproved dependencies. The
|
127
|
+
rake task will `exit 1` immediately if there are unapproved dependencies, stopping your build dead in its tracks!
|
168
128
|
|
169
129
|
## A note to gem authors / maintainers
|
170
130
|
|
@@ -178,3 +138,7 @@ end
|
|
178
138
|
```
|
179
139
|
|
180
140
|
And add a `LICENSE` file to your gem that contains your license text.
|
141
|
+
|
142
|
+
## License
|
143
|
+
|
144
|
+
LicenseFinder is released under the terms of the MIT License. http://www.opensource.org/licenses/mit-license
|
data/Rakefile
CHANGED
data/bin/license_finder
CHANGED
@@ -0,0 +1,49 @@
|
|
1
|
+
Feature: Approving non-whitelisted Dependencies
|
2
|
+
So that I can track the dependencies of my application which my business has approved
|
3
|
+
As an application developer using license finder
|
4
|
+
I want to be able to manually approve dependencies that have licenses which fall outside of my whitelist
|
5
|
+
|
6
|
+
Scenario: Manually approving a non-whitelisted dependency
|
7
|
+
Given I have an app with license finder
|
8
|
+
And my app depends on a gem "gpl_gem" licensed with "GPL"
|
9
|
+
And I whitelist the "MIT" license
|
10
|
+
|
11
|
+
When I run "license_finder"
|
12
|
+
Then I should see the following settings for "gpl_gem":
|
13
|
+
"""
|
14
|
+
version: "0.0.0"
|
15
|
+
license: "GPL"
|
16
|
+
approved: false
|
17
|
+
"""
|
18
|
+
|
19
|
+
When I update the settings for "gpl_gem" with the following content:
|
20
|
+
"""
|
21
|
+
approved: true
|
22
|
+
"""
|
23
|
+
When I run "license_finder"
|
24
|
+
Then I should not see "gpl_gem" in its output
|
25
|
+
|
26
|
+
Scenario: Manually adding a non-bundled dependency
|
27
|
+
Given I have an app with license finder
|
28
|
+
When I run "license_finder"
|
29
|
+
And I add the following content to "dependencies.yml":
|
30
|
+
"""
|
31
|
+
- name: "my_javascript_library"
|
32
|
+
version: "0.0.0"
|
33
|
+
license: "GPL"
|
34
|
+
approved: false
|
35
|
+
"""
|
36
|
+
Then I should see the following settings for "my_javascript_library":
|
37
|
+
"""
|
38
|
+
version: "0.0.0"
|
39
|
+
license: "GPL"
|
40
|
+
approved: false
|
41
|
+
"""
|
42
|
+
When I run "license_finder"
|
43
|
+
Then I should see "my_javascript_library" in its output
|
44
|
+
When I update the settings for "my_javascript_library" with the following content:
|
45
|
+
"""
|
46
|
+
approved: true
|
47
|
+
"""
|
48
|
+
When I run "license_finder"
|
49
|
+
Then I should not see "my_javascript_library" in its output
|
@@ -0,0 +1,48 @@
|
|
1
|
+
Feature: HTML Report
|
2
|
+
So that I can easily view a report outlining my application dependencies and licenses
|
3
|
+
As a non-technical application product owner
|
4
|
+
I want license finder to generate an easy-to-understand HTML report
|
5
|
+
|
6
|
+
Background:
|
7
|
+
Given I have an app with license finder
|
8
|
+
|
9
|
+
Scenario: Dependency details listed in HTML report
|
10
|
+
Given my application depends on a gem "mit_licensed_gem" with:
|
11
|
+
| license | summary | description | version | homepage | bundler_groups |
|
12
|
+
| MIT | mit is cool | seriously | 0.0.1 | http://mit_licensed_gem.github.com | test |
|
13
|
+
When I run "license_finder"
|
14
|
+
And I should see the "mit_licensed_gem" in the html with the following details:
|
15
|
+
| license | summary | description | name | bundler_groups |
|
16
|
+
| MIT | mit is cool | seriously | mit_licensed_gem v0.0.1 | test |
|
17
|
+
And the text "MIT" should link to "http://opensource.org/licenses/mit-license"
|
18
|
+
And the text "mit_licensed_gem" should link to "http://mit_licensed_gem.github.com"
|
19
|
+
|
20
|
+
Scenario: Approval status of dependencies indicated in HTML report
|
21
|
+
Given my app depends on a gem "gpl_licensed_gem" licensed with "GPL"
|
22
|
+
And my app depends on a gem "mit_licensed_gem" licensed with "MIT"
|
23
|
+
And I whitelist the "MIT" license
|
24
|
+
When I run "license_finder"
|
25
|
+
Then I should see the "gpl_licensed_gem" in the html flagged as "unapproved"
|
26
|
+
And I should see the "mit_licensed_gem" in the html flagged as "approved"
|
27
|
+
|
28
|
+
Scenario: Dependency summary
|
29
|
+
Given my app depends on a gem "gpl_licensed_gem" licensed with "GPL"
|
30
|
+
And my app depends on a gem "mit_licensed_gem" licensed with "MIT"
|
31
|
+
And I whitelist the following licenses: "MIT, other"
|
32
|
+
When I run "license_finder"
|
33
|
+
# rake, bundler, license_finder, my_app, gpl_licensed_gem, mit_licensed_gem
|
34
|
+
Then I should see "6 total" in the html
|
35
|
+
# gpl_licensed_gem
|
36
|
+
And I should see "1 unapproved" in the html
|
37
|
+
# gpl_licensed_gem
|
38
|
+
And I should see "1 GPL" in the html
|
39
|
+
|
40
|
+
Scenario: Implicit dependencies list their parent dependencies
|
41
|
+
Given I have a rails app with license finder
|
42
|
+
When I run "license_finder"
|
43
|
+
Then I should see the "activerecord" in the html with the following details:
|
44
|
+
| parent |
|
45
|
+
| rails |
|
46
|
+
And I should see "rails" in the html with the following details:
|
47
|
+
| children |
|
48
|
+
| activerecord |
|
@@ -0,0 +1,36 @@
|
|
1
|
+
Feature: License Finder command line executable
|
2
|
+
So that I can report and manage my application's dependencies and licenses to my business
|
3
|
+
As an application developer
|
4
|
+
I want a command-line interface
|
5
|
+
|
6
|
+
Scenario: Running without a configuration file
|
7
|
+
Given I have an app with license finder
|
8
|
+
And my app does not have a "config" directory
|
9
|
+
When I run "license_finder"
|
10
|
+
Then I should see a "config" directory
|
11
|
+
And I should see the file "config/license_finder.yml" with the following content:
|
12
|
+
"""
|
13
|
+
---
|
14
|
+
whitelist:
|
15
|
+
#- MIT
|
16
|
+
#- Apache 2.0
|
17
|
+
ignore_groups:
|
18
|
+
#- test
|
19
|
+
#- development
|
20
|
+
dependencies_file_dir: './'
|
21
|
+
"""
|
22
|
+
|
23
|
+
Scenario: Auditing an application with non-whitelisted licenses
|
24
|
+
Given I have an app with license finder
|
25
|
+
And my app depends on a gem "mit_licensed_gem" licensed with "MIT"
|
26
|
+
When I run "license_finder"
|
27
|
+
Then it should exit with status code 1
|
28
|
+
And I should see "mit_licensed_gem" in its output
|
29
|
+
|
30
|
+
Scenario: Auditing an application with whitelisted licenses
|
31
|
+
Given I have an app with license finder
|
32
|
+
And my app depends on a gem "mit_licensed_gem" licensed with "MIT"
|
33
|
+
And I whitelist the following licenses: "MIT, other"
|
34
|
+
When I run "license_finder"
|
35
|
+
Then it should exit with status code 0
|
36
|
+
And I should see "All gems are approved for use" in its output
|
@@ -0,0 +1,36 @@
|
|
1
|
+
Feature: License Finder command line executable
|
2
|
+
So that I can report and manage my application's dependencies and licenses to my business
|
3
|
+
As an application developer
|
4
|
+
I want a command-line interface
|
5
|
+
|
6
|
+
Scenario: Running without a configuration file
|
7
|
+
Given I have an app with rake and license finder
|
8
|
+
And my app does not have a "config" directory
|
9
|
+
When I run "rake license_finder"
|
10
|
+
Then I should see a "config" directory
|
11
|
+
And I should see the file "config/license_finder.yml" with the following content:
|
12
|
+
"""
|
13
|
+
---
|
14
|
+
whitelist:
|
15
|
+
#- MIT
|
16
|
+
#- Apache 2.0
|
17
|
+
ignore_groups:
|
18
|
+
#- test
|
19
|
+
#- development
|
20
|
+
dependencies_file_dir: './'
|
21
|
+
"""
|
22
|
+
|
23
|
+
Scenario: Auditing an application with non-whitelisted licenses
|
24
|
+
Given I have an app with rake and license finder
|
25
|
+
And my app depends on a gem "mit_licensed_gem" licensed with "MIT"
|
26
|
+
When I run "rake license_finder"
|
27
|
+
Then it should exit with status code 1
|
28
|
+
And I should see "mit_licensed_gem" in its output
|
29
|
+
|
30
|
+
Scenario: Auditing an application with whitelisted licenses
|
31
|
+
Given I have an app with rake and license finder
|
32
|
+
And my app depends on a gem "mit_licensed_gem" licensed with "MIT"
|
33
|
+
And I whitelist the following licenses: "MIT, other"
|
34
|
+
When I run "rake license_finder"
|
35
|
+
Then it should exit with status code 0
|
36
|
+
And I should see "All gems are approved for use" in its output
|
@@ -0,0 +1,9 @@
|
|
1
|
+
Feature: The rake task is automatically made available in Rails project
|
2
|
+
So that I do not have to modify the Rails rakefile
|
3
|
+
As an application developer
|
4
|
+
I want the license_finder rake task automatically loaded for me in a rails project
|
5
|
+
|
6
|
+
Scenario: The application is a Rails app
|
7
|
+
Given I have a rails app with license finder
|
8
|
+
When I run "rake license_finder"
|
9
|
+
Then I should see "Dependencies that need approval:" in its output
|
@@ -1,41 +1,39 @@
|
|
1
1
|
require 'fileutils'
|
2
|
+
require 'capybara'
|
2
3
|
|
3
|
-
Given /^I have a rails
|
4
|
-
@user = DSL::User.new
|
4
|
+
Given /^I have a rails app(?:lication)? with license finder$/ do
|
5
|
+
@user = ::DSL::User.new
|
5
6
|
@user.create_rails_app
|
6
7
|
end
|
7
8
|
|
8
|
-
Given /^I have an
|
9
|
-
@user = DSL::User.new
|
9
|
+
Given /^I have an app(?:lication)? with license finder$/ do
|
10
|
+
@user = ::DSL::User.new
|
10
11
|
@user.create_nonrails_app
|
11
12
|
end
|
12
13
|
|
13
14
|
|
14
|
-
Given /^I have an
|
15
|
-
@user = DSL::User.new
|
15
|
+
Given /^I have an app(?:lication)? with rake and license finder$/ do
|
16
|
+
@user = ::DSL::User.new
|
16
17
|
@user.create_nonrails_app
|
17
18
|
@user.add_license_finder_to_rakefile
|
18
|
-
@user.execute_command "rake license:init"
|
19
19
|
end
|
20
20
|
|
21
|
-
Given /^my
|
22
|
-
|
23
|
-
File.exists?(@user.config_path).should be_false
|
24
|
-
end
|
21
|
+
Given /^my app(?:lication)? does not have a "([^"]+)" directory$/ do |name|
|
22
|
+
path = @user.app_path(name)
|
25
23
|
|
26
|
-
|
27
|
-
File.
|
24
|
+
FileUtils.rm_rf(path)
|
25
|
+
File.should_not be_exists(path)
|
28
26
|
end
|
29
27
|
|
30
|
-
|
31
|
-
@user.
|
28
|
+
Then /^I should see a "([^"]+)" directory$/ do |name|
|
29
|
+
File.should be_exists(@user.app_path(name))
|
32
30
|
end
|
33
31
|
|
34
|
-
Given /^my (?:rails )?app depends on a gem "(.*?)" licensed with "(.*?)"$/ do |gem_name, license|
|
32
|
+
Given /^my (?:rails )?app(?:lication)? depends on a gem "(.*?)" licensed with "(.*?)"$/ do |gem_name, license|
|
35
33
|
@user.add_dependency_to_app gem_name, :license => license
|
36
34
|
end
|
37
35
|
|
38
|
-
Given /^my (?:rails )?app depends on a gem "(.*?)" licensed with "(.*?)" in the "(.*?)" bundler groups$/ do |gem_name, license, bundler_groups|
|
36
|
+
Given /^my (?:rails )?app(?:lication)? depends on a gem "(.*?)" licensed with "(.*?)" in the "(.*?)" bundler groups$/ do |gem_name, license, bundler_groups|
|
39
37
|
@user.add_dependency_to_app gem_name, :license => license, :bundler_groups => bundler_groups
|
40
38
|
end
|
41
39
|
|
@@ -59,12 +57,15 @@ When /^I add the following content to "([^"]*)":$/ do |filename, text|
|
|
59
57
|
@user.append_to_file(filename, @content = text)
|
60
58
|
end
|
61
59
|
|
62
|
-
When /^my
|
60
|
+
When /^my app(?:lication)? depends on a gem "([^"]*)" with:$/ do |gem_name, gem_info|
|
63
61
|
info = gem_info.hashes.first
|
64
62
|
@user.add_dependency_to_app(gem_name,
|
65
|
-
:license
|
66
|
-
:summary
|
67
|
-
:description
|
63
|
+
:license => info["license"],
|
64
|
+
:summary => info["summary"],
|
65
|
+
:description => info["description"],
|
66
|
+
:version => info["version"],
|
67
|
+
:homepage => info["homepage"],
|
68
|
+
:bundler_groups => info["bundler_groups"]
|
68
69
|
)
|
69
70
|
end
|
70
71
|
|
@@ -76,19 +77,18 @@ Then /^I should not see "(.*?)" in its output$/ do |gem_name|
|
|
76
77
|
@output.should_not include gem_name
|
77
78
|
end
|
78
79
|
|
79
|
-
Then /^
|
80
|
-
File.read(
|
80
|
+
Then /^I should see the file "([^"]*)" with the following content:$/ do |filename, text|
|
81
|
+
File.read(@user.app_path(filename)).should == text.gsub(/^\s+/, "")
|
81
82
|
end
|
82
83
|
|
83
|
-
Then /^
|
84
|
-
File.read(
|
84
|
+
Then /^I should see the file "([^"]*)" containing:$/ do |filename, text|
|
85
|
+
File.read(@user.app_path(filename)).should include(text.gsub(/^\s+/, ""))
|
85
86
|
end
|
86
87
|
|
87
88
|
Then /^I should see the following settings for "([^"]*)":$/ do |name, yaml|
|
88
89
|
expected_settings = YAML.load(yaml)
|
89
90
|
all_settings = YAML.load(File.read(@user.dependencies_file_path))
|
90
91
|
actual_settings = all_settings.detect { |gem| gem['name'] == name }
|
91
|
-
|
92
92
|
actual_settings.should include expected_settings
|
93
93
|
end
|
94
94
|
|
@@ -96,6 +96,29 @@ Then /^it should exit with status code (\d)$/ do |status|
|
|
96
96
|
$?.exitstatus.should == status.to_i
|
97
97
|
end
|
98
98
|
|
99
|
+
Then /^I should see the "([^"]*)" in the html flagged as "([^"]*)"$/ do |gem_name, css_class|
|
100
|
+
html = File.read(@user.dependencies_html_path)
|
101
|
+
page = Capybara.string(html)
|
102
|
+
gpl_gem = page.find("##{gem_name}")
|
103
|
+
gpl_gem[:class].should == css_class
|
104
|
+
end
|
105
|
+
|
106
|
+
Then /^I should see (?:the )?"([^"]*)" in the html with the following details:$/ do |gem_name, table|
|
107
|
+
html = File.read(@user.dependencies_html_path)
|
108
|
+
page = Capybara.string(html)
|
109
|
+
section = page.find("##{gem_name}")
|
110
|
+
|
111
|
+
table.hashes.first.each do |property_name, property_value|
|
112
|
+
section.should have_content property_value
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
Then /^I should see "([^"]*)" in the html$/ do |text|
|
117
|
+
html = File.read(@user.dependencies_html_path)
|
118
|
+
page = Capybara.string(html)
|
119
|
+
|
120
|
+
page.should have_content text
|
121
|
+
end
|
99
122
|
|
100
123
|
module DSL
|
101
124
|
class User
|
@@ -106,6 +129,8 @@ module DSL
|
|
106
129
|
|
107
130
|
add_gem_dependency('rake')
|
108
131
|
add_gem_dependency('license_finder', :path => root_path)
|
132
|
+
|
133
|
+
bundle_app
|
109
134
|
end
|
110
135
|
|
111
136
|
def create_rails_app
|
@@ -147,7 +172,9 @@ module DSL
|
|
147
172
|
license = options.fetch(:license)
|
148
173
|
summary = options.fetch(:summary, "")
|
149
174
|
description = options.fetch(:description, "")
|
150
|
-
bundler_groups = options.fetch(:bundler_groups, "").split(',').map(&:strip)
|
175
|
+
bundler_groups = options.fetch(:bundler_groups, "").to_s.split(',').map(&:strip)
|
176
|
+
version = options[:version] || "0.0.0"
|
177
|
+
homepage = options[:homepage]
|
151
178
|
|
152
179
|
gem_dir = File.join(projects_path, gem_name)
|
153
180
|
|
@@ -156,11 +183,12 @@ module DSL
|
|
156
183
|
file.write <<-GEMSPEC
|
157
184
|
Gem::Specification.new do |s|
|
158
185
|
s.name = "#{gem_name}"
|
159
|
-
s.version = "
|
186
|
+
s.version = "#{version}"
|
160
187
|
s.author = "Cucumber"
|
161
188
|
s.summary = "#{summary}"
|
162
189
|
s.license = "#{license}"
|
163
190
|
s.description = "#{description}"
|
191
|
+
s.homepage = "#{homepage}"
|
164
192
|
end
|
165
193
|
GEMSPEC
|
166
194
|
end
|
@@ -175,6 +203,7 @@ module DSL
|
|
175
203
|
end
|
176
204
|
|
177
205
|
def configure_license_finder_whitelist(whitelisted_licenses=[])
|
206
|
+
FileUtils.mkdir_p(config_path)
|
178
207
|
File.open(File.join(config_path, "license_finder.yml"), "w") do |f|
|
179
208
|
f.write({'whitelist' => whitelisted_licenses}.to_yaml)
|
180
209
|
end
|
@@ -188,8 +217,16 @@ module DSL
|
|
188
217
|
@output
|
189
218
|
end
|
190
219
|
|
191
|
-
def app_path
|
192
|
-
File.join(projects_path, app_name)
|
220
|
+
def app_path(sub_directory = nil)
|
221
|
+
path = app_path = Pathname.new(File.join(projects_path, app_name)).cleanpath.to_s
|
222
|
+
|
223
|
+
if sub_directory
|
224
|
+
path = Pathname.new(File.join(app_path, sub_directory)).cleanpath.to_s
|
225
|
+
|
226
|
+
raise "#{name} is outside of the app" unless path =~ %r{^#{app_path}/}
|
227
|
+
end
|
228
|
+
|
229
|
+
path
|
193
230
|
end
|
194
231
|
|
195
232
|
def config_path
|
@@ -200,6 +237,10 @@ module DSL
|
|
200
237
|
File.join(app_path, 'dependencies.yml')
|
201
238
|
end
|
202
239
|
|
240
|
+
def dependencies_html_path
|
241
|
+
File.join(app_path, 'dependencies.html')
|
242
|
+
end
|
243
|
+
|
203
244
|
private
|
204
245
|
|
205
246
|
def bundle_app
|
@@ -245,7 +286,13 @@ module DSL
|
|
245
286
|
end
|
246
287
|
|
247
288
|
def root_path
|
248
|
-
|
289
|
+
Pathname.new(File.join(File.dirname(__FILE__), "..", "..")).realpath.to_s
|
249
290
|
end
|
250
291
|
end
|
251
292
|
end
|
293
|
+
|
294
|
+
|
295
|
+
When /^the text "([^"]*)" should link to "([^"]*)"$/ do |text, link|
|
296
|
+
html = Capybara.string File.read(@user.dependencies_html_path)
|
297
|
+
html.find(:xpath, "//a[@href='#{link}']").text.should == text
|
298
|
+
end
|