license_finder 2.0.4 → 2.1.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (135) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +6 -4
  3. data/.travis/install_godep.sh +6 -0
  4. data/.travis/install_gradle.sh +1 -1
  5. data/.travis/install_rebar.sh +7 -5
  6. data/CHANGELOG.rdoc +13 -0
  7. data/CONTRIBUTING.md +16 -2
  8. data/README.md +41 -4
  9. data/Rakefile +8 -2
  10. data/features/features/{cli_spec.rb → cli/cli_spec.rb} +24 -18
  11. data/features/features/configure/add_dependencies_spec.rb +18 -1
  12. data/features/features/configure/approve_dependencies_spec.rb +31 -1
  13. data/features/features/configure/assign_licenses_spec.rb +18 -3
  14. data/features/features/configure/blacklist_licenses_spec.rb +30 -0
  15. data/features/features/configure/ignore_dependencies_spec.rb +1 -1
  16. data/features/features/configure/ignore_groups_spec.rb +16 -1
  17. data/features/features/configure/name_project_spec.rb +1 -1
  18. data/features/features/configure/set_project_path_spec.rb +1 -1
  19. data/features/features/configure/whitelist_licenses_spec.rb +1 -3
  20. data/features/features/package_managers/bower_spec.rb +1 -1
  21. data/features/features/package_managers/cocoapods_spec.rb +1 -1
  22. data/features/features/package_managers/godep_spec.rb +17 -0
  23. data/features/features/package_managers/gradle_spec.rb +18 -4
  24. data/features/features/package_managers/maven_spec.rb +1 -1
  25. data/features/features/package_managers/npm_spec.rb +1 -1
  26. data/features/features/package_managers/nuget_spec.rb +14 -0
  27. data/features/features/package_managers/pip_spec.rb +1 -1
  28. data/features/features/package_managers/rebar_spec.rb +1 -1
  29. data/features/features/report/composite_spec.rb +15 -0
  30. data/features/features/report/csv_spec.rb +1 -1
  31. data/features/features/report/diff_spec.rb +190 -0
  32. data/features/features/report/html_spec.rb +1 -1
  33. data/features/features/report/subproject_spec.rb +52 -0
  34. data/features/fixtures/file-based-libs-gradle/build.gradle +18 -0
  35. data/features/fixtures/file-based-libs-gradle/libs/data.json-0.2.3.jar +0 -0
  36. data/features/fixtures/gopath/src/github.com/pivotal/foo/Godeps/Godeps.json +16 -0
  37. data/features/fixtures/gopath/src/github.com/pivotal/foo/Godeps/Readme +5 -0
  38. data/features/fixtures/gopath/src/github.com/pivotal/foo/foo.go +6 -0
  39. data/features/fixtures/multi-module-gradle/build.gradle +18 -0
  40. data/features/fixtures/multi-module-gradle/module1/build.gradle +3 -0
  41. data/features/fixtures/multi-module-gradle/module2/build.gradle +3 -0
  42. data/features/fixtures/multi-module-gradle/settings.gradle +1 -0
  43. data/features/fixtures/nuget/Fun.Test/packages.config +4 -0
  44. data/features/fixtures/nuget/Fun/packages.config +5 -0
  45. data/features/fixtures/nuget/packages/Microsoft.AspNet.Mvc.4.0.30506.0/.keep +0 -0
  46. data/features/fixtures/nuget/packages/NUnit.2.6.4/.keep +0 -0
  47. data/features/fixtures/nuget/packages/Ninject.MVC4.3.2.1.0/.keep +0 -0
  48. data/features/fixtures/nuget/packages/repositories.config +6 -0
  49. data/features/fixtures/{build.gradle → single-module-gradle/build.gradle} +0 -0
  50. data/{spec → features/support}/feature_helper.rb +5 -1
  51. data/features/support/testing_dsl.rb +297 -212
  52. data/lib/license_finder/cli.rb +1 -0
  53. data/lib/license_finder/cli/base.rb +16 -3
  54. data/lib/license_finder/cli/blacklist.rb +30 -0
  55. data/lib/license_finder/cli/main.rb +62 -4
  56. data/lib/license_finder/configuration.rb +39 -8
  57. data/lib/license_finder/core.rb +13 -10
  58. data/lib/license_finder/decision_applier.rb +14 -9
  59. data/lib/license_finder/decisions.rb +24 -6
  60. data/lib/license_finder/diff.rb +47 -0
  61. data/lib/license_finder/license_aggregator.rb +25 -0
  62. data/lib/license_finder/package.rb +39 -6
  63. data/lib/license_finder/package_delta.rb +65 -0
  64. data/lib/license_finder/package_manager.rb +10 -3
  65. data/lib/license_finder/package_managers/bower.rb +3 -1
  66. data/lib/license_finder/package_managers/bundler.rb +18 -9
  67. data/lib/license_finder/package_managers/bundler_package.rb +6 -2
  68. data/lib/license_finder/package_managers/go_dep.rb +25 -0
  69. data/lib/license_finder/package_managers/go_package.rb +19 -0
  70. data/lib/license_finder/package_managers/go_workspace.rb +35 -0
  71. data/lib/license_finder/package_managers/gradle.rb +16 -17
  72. data/lib/license_finder/package_managers/gradle_dependency_finder.rb +13 -0
  73. data/lib/license_finder/package_managers/gradle_package.rb +6 -1
  74. data/lib/license_finder/package_managers/maven.rb +3 -1
  75. data/lib/license_finder/package_managers/merged_package.rb +43 -0
  76. data/lib/license_finder/package_managers/npm.rb +42 -24
  77. data/lib/license_finder/package_managers/nuget.rb +50 -0
  78. data/lib/license_finder/package_managers/nuget_package.rb +4 -0
  79. data/lib/license_finder/package_managers/pip_package.rb +1 -0
  80. data/lib/license_finder/package_managers/rebar.rb +2 -6
  81. data/lib/license_finder/platform.rb +4 -1
  82. data/lib/license_finder/project_finder.rb +56 -0
  83. data/lib/license_finder/report.rb +3 -2
  84. data/lib/license_finder/reports/csv_report.rb +6 -2
  85. data/lib/license_finder/reports/diff_report.rb +33 -0
  86. data/lib/license_finder/reports/merged_report.rb +13 -0
  87. data/lib/license_finder/version.rb +1 -1
  88. data/license_finder.gemspec +6 -2
  89. data/spec/dummy_app/Gemfile +6 -0
  90. data/spec/fixtures/all_pms/.envrc +0 -0
  91. data/spec/fixtures/all_pms/Godeps/Godeps.json +0 -0
  92. data/spec/fixtures/all_pms/packages/.keep +0 -0
  93. data/spec/fixtures/composite/Gemfile +0 -0
  94. data/spec/fixtures/composite/nested_project/.envrc +8 -0
  95. data/spec/fixtures/composite/nested_project/src/github.com/pivotal/foo/Godeps/Godeps.json +16 -0
  96. data/spec/fixtures/composite/nested_project/src/github.com/pivotal/foo/Godeps/Readme +5 -0
  97. data/spec/fixtures/composite/nested_project/src/github.com/pivotal/foo/foo.go +6 -0
  98. data/spec/fixtures/composite/not_a_project/DONTREADME.md +0 -0
  99. data/spec/fixtures/composite/project1/Gemfile +0 -0
  100. data/spec/fixtures/composite/project2/package.json +0 -0
  101. data/spec/lib/license_finder/cli/approvals_spec.rb +1 -1
  102. data/spec/lib/license_finder/cli/blacklist_spec.rb +58 -0
  103. data/spec/lib/license_finder/cli/dependencies_spec.rb +1 -1
  104. data/spec/lib/license_finder/cli/ignored_dependencies_spec.rb +1 -1
  105. data/spec/lib/license_finder/cli/ignored_groups_spec.rb +1 -1
  106. data/spec/lib/license_finder/cli/licenses_spec.rb +1 -1
  107. data/spec/lib/license_finder/cli/main_spec.rb +113 -7
  108. data/spec/lib/license_finder/cli/project_name_spec.rb +1 -1
  109. data/spec/lib/license_finder/cli/whitelist_spec.rb +1 -1
  110. data/spec/lib/license_finder/configuration_spec.rb +63 -4
  111. data/spec/lib/license_finder/core_spec.rb +49 -0
  112. data/spec/lib/license_finder/decision_applier_spec.rb +101 -1
  113. data/spec/lib/license_finder/decisions_spec.rb +62 -0
  114. data/spec/lib/license_finder/diff_spec.rb +106 -0
  115. data/spec/lib/license_finder/license_aggregator_spec.rb +61 -0
  116. data/spec/lib/license_finder/package_delta_spec.rb +18 -0
  117. data/spec/lib/license_finder/package_managers/bower_spec.rb +8 -6
  118. data/spec/lib/license_finder/package_managers/bundler_package_spec.rb +4 -2
  119. data/spec/lib/license_finder/package_managers/go_dep_spec.rb +72 -0
  120. data/spec/lib/license_finder/package_managers/go_workspace_spec.rb +69 -0
  121. data/spec/lib/license_finder/package_managers/gradle_package_spec.rb +9 -0
  122. data/spec/lib/license_finder/package_managers/gradle_spec.rb +94 -44
  123. data/spec/lib/license_finder/package_managers/maven_spec.rb +8 -6
  124. data/spec/lib/license_finder/package_managers/merged_package_spec.rb +52 -0
  125. data/spec/lib/license_finder/package_managers/npm_spec.rb +59 -20
  126. data/spec/lib/license_finder/package_managers/nuget_spec.rb +82 -0
  127. data/spec/lib/license_finder/package_managers/pip_package_spec.rb +1 -0
  128. data/spec/lib/license_finder/package_managers/rebar_spec.rb +12 -12
  129. data/spec/lib/license_finder/package_spec.rb +59 -2
  130. data/spec/lib/license_finder/project_finder_spec.rb +33 -0
  131. data/spec/lib/license_finder/reports/csv_report_spec.rb +9 -3
  132. data/spec/lib/license_finder/reports/diff_report_spec.rb +56 -0
  133. data/spec/lib/license_finder/reports/merged_report_spec.rb +21 -0
  134. metadata +82 -9
  135. data/.travis/install_virtualenv.sh +0 -9
@@ -0,0 +1,47 @@
1
+ module LicenseFinder
2
+ class Diff
3
+ def self.compare(f1, f2)
4
+ p1 = Set.new(build_packages(f1))
5
+ p2 = Set.new(build_packages(f2))
6
+
7
+ added = p2.difference(p1).to_a
8
+ removed = p1.difference(p2).to_a
9
+ unchanged = p1.intersection(p2).to_a
10
+
11
+ [].tap do |packages|
12
+ unchanged.each do |package|
13
+ package_previous = package_with_name(p1, package)
14
+ package_current = package_with_name(p2, package)
15
+
16
+ if package_current.licenses == package_previous.licenses
17
+ packages << PackageDelta.unchanged(package_current, package_previous)
18
+ else
19
+ packages << PackageDelta.removed(package_previous)
20
+ packages << PackageDelta.added(package_current)
21
+ end
22
+ end
23
+
24
+ added.each { |package| packages << PackageDelta.added(package) }
25
+ removed.each { |package| packages << PackageDelta.removed(package) }
26
+ end
27
+ end
28
+
29
+ private
30
+
31
+ def self.build_packages(content)
32
+ CSV.parse(content).map do |row|
33
+ row.map!(&:strip)
34
+ package = Package.new(row[0], row[1], spec_licenses: [row[2]])
35
+ if row.count == 4
36
+ MergedPackage.new(package, row[3].split(','))
37
+ else
38
+ package
39
+ end
40
+ end
41
+ end
42
+
43
+ def self.package_with_name(set, package)
44
+ set.find { |p| p.name == package.name }
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,25 @@
1
+ module LicenseFinder
2
+ class LicenseAggregator
3
+ def initialize(license_finder_config, subprojects)
4
+ @license_finder_config = license_finder_config
5
+ @subprojects = subprojects
6
+ end
7
+
8
+ def dependencies
9
+ aggregate_packages
10
+ .group_by { |package| [package.name, package.version] }
11
+ .map do |_, packages|
12
+ MergedPackage.new(packages[0].dependency, packages.flat_map(&:subproject_paths))
13
+ end
14
+ end
15
+
16
+ private
17
+
18
+ def aggregate_packages
19
+ @subprojects.flat_map do |project_path|
20
+ finder = LicenseFinder::Core.new(@license_finder_config.merge(project_path: project_path))
21
+ finder.acknowledged.map { |dep| MergedPackage.new(dep, [project_path]) }
22
+ end
23
+ end
24
+ end
25
+ end
@@ -32,8 +32,10 @@ module LicenseFinder
32
32
  def initialize(name, version = nil, options={})
33
33
  @logger = options[:logger] || Core.default_logger
34
34
 
35
+ ## DESCRIPTION
35
36
  @name = name
36
37
  @version = version
38
+ @authors = options[:authors] || ""
37
39
  @summary = options[:summary] || ""
38
40
  @description = options[:description] || ""
39
41
  @homepage = options[:homepage] || ""
@@ -43,6 +45,7 @@ module LicenseFinder
43
45
 
44
46
  ## APPROVAL
45
47
  @whitelisted = false
48
+ @blacklisted = false
46
49
  @manual_approval = nil
47
50
 
48
51
  ## LICENSING
@@ -52,7 +55,9 @@ module LicenseFinder
52
55
  @decided_licenses = Set.new
53
56
  end
54
57
 
55
- attr_reader :name, :version,
58
+ ## DESCRIPTION
59
+
60
+ attr_reader :name, :version, :authors,
56
61
  :summary, :description, :homepage,
57
62
  :children, :parents, :groups
58
63
 
@@ -62,24 +67,49 @@ module LicenseFinder
62
67
  @manual_approval = approval
63
68
  end
64
69
 
65
- def whitelisted!
66
- @whitelisted = true
70
+ def approved_manually?
71
+ !@manual_approval.nil?
67
72
  end
68
73
 
69
74
  def approved?
70
- approved_manually? || whitelisted?
75
+ # Question: is `!blacklisted?` redundant?
76
+ # DecisionApplier does not call `whitelisted!` or `approved_manually!`
77
+ # if a Package has been blacklisted.
78
+ (approved_manually? || whitelisted?) && !blacklisted?
71
79
  end
72
80
 
73
- def approved_manually?
74
- !@manual_approval.nil?
81
+ def whitelisted!
82
+ @whitelisted = true
75
83
  end
76
84
 
77
85
  def whitelisted?
78
86
  @whitelisted
79
87
  end
80
88
 
89
+ def blacklisted!
90
+ @blacklisted = true
91
+ end
92
+
93
+ def blacklisted?
94
+ @blacklisted
95
+ end
96
+
81
97
  attr_reader :manual_approval
82
98
 
99
+ ## EQUALITY
100
+
101
+ def <=>(other)
102
+ name <=> other.name
103
+ end
104
+
105
+ def eql?(other)
106
+ name == other.name
107
+ end
108
+
109
+ def hash
110
+ [name].hash
111
+ end
112
+
83
113
  ## LICENSING
84
114
 
85
115
  attr_reader :license_names_from_spec # stubbed in tests, otherwise private
@@ -121,6 +151,7 @@ end
121
151
 
122
152
  require 'license_finder/packages/manual_package'
123
153
  require 'license_finder/package_managers/bower_package'
154
+ require 'license_finder/package_managers/go_package'
124
155
  require 'license_finder/package_managers/bundler_package'
125
156
  require 'license_finder/package_managers/pip_package'
126
157
  require 'license_finder/package_managers/npm_package'
@@ -128,3 +159,5 @@ require 'license_finder/package_managers/maven_package'
128
159
  require 'license_finder/package_managers/gradle_package'
129
160
  require 'license_finder/package_managers/cocoa_pods_package'
130
161
  require 'license_finder/package_managers/rebar_package'
162
+ require 'license_finder/package_managers/merged_package'
163
+ require 'license_finder/package_managers/nuget_package'
@@ -0,0 +1,65 @@
1
+ module LicenseFinder
2
+ class PackageDelta
3
+ STATUSES = [:added, :removed, :unchanged]
4
+
5
+ def initialize(status, current_package, previous_package)
6
+ @status = status
7
+ @current_package = current_package
8
+ @previous_package = previous_package
9
+ end
10
+
11
+ def name
12
+ pick_package.name
13
+ end
14
+
15
+ def current_version
16
+ @current_package ? @current_package.version : nil
17
+ end
18
+
19
+ def previous_version
20
+ @previous_package ? @previous_package.version : nil
21
+ end
22
+
23
+ def subproject_paths
24
+ pick_package.subproject_paths
25
+ end
26
+
27
+ def status
28
+ @status
29
+ end
30
+
31
+ def licenses
32
+ pick_package.licenses
33
+ end
34
+
35
+ def merged_package?
36
+ pick_package.class == MergedPackage
37
+ end
38
+
39
+ def method_missing(method_name)
40
+ nil
41
+ end
42
+
43
+ def self.added(package)
44
+ new(:added, package, nil)
45
+ end
46
+
47
+ def self.removed(package)
48
+ new(:removed, nil, package)
49
+ end
50
+
51
+ def self.unchanged(current_package, previous_package)
52
+ new(:unchanged, current_package, previous_package)
53
+ end
54
+
55
+ def <=>(other)
56
+ STATUSES.index(status) <=> STATUSES.index(other.status)
57
+ end
58
+
59
+ private
60
+
61
+ def pick_package
62
+ @current_package ? @current_package : @previous_package
63
+ end
64
+ end
65
+ end
@@ -13,14 +13,14 @@ module LicenseFinder
13
13
  #
14
14
  class PackageManager
15
15
  def self.package_managers
16
- [Bundler, NPM, Pip, Bower, Maven, Gradle, CocoaPods, Rebar]
16
+ [GoDep, GoWorkspace, Bundler, NPM, Pip, Bower, Maven, Gradle, CocoaPods, Rebar, Nuget]
17
17
  end
18
18
 
19
19
  def self.current_packages(options)
20
- package_managers
20
+ active_package_managers = package_managers
21
21
  .map { |pm| pm.new(options) }
22
22
  .select(&:active?)
23
- .flat_map(&:current_packages_with_relations)
23
+ active_package_managers.flat_map(&:current_packages_with_relations)
24
24
  end
25
25
 
26
26
  def initialize options={}
@@ -33,6 +33,10 @@ module LicenseFinder
33
33
  .tap { |is_active| logger.active self.class, is_active }
34
34
  end
35
35
 
36
+ def capture(command)
37
+ [`#{command}`, $?.success?]
38
+ end
39
+
36
40
  def current_packages_with_relations
37
41
  packages = current_packages
38
42
  packages.each do |parent|
@@ -51,6 +55,8 @@ module LicenseFinder
51
55
  end
52
56
 
53
57
  require 'license_finder/package_managers/bower'
58
+ require 'license_finder/package_managers/go_workspace'
59
+ require 'license_finder/package_managers/go_dep'
54
60
  require 'license_finder/package_managers/bundler'
55
61
  require 'license_finder/package_managers/npm'
56
62
  require 'license_finder/package_managers/pip'
@@ -58,5 +64,6 @@ require 'license_finder/package_managers/maven'
58
64
  require 'license_finder/package_managers/cocoa_pods'
59
65
  require 'license_finder/package_managers/gradle'
60
66
  require 'license_finder/package_managers/rebar'
67
+ require 'license_finder/package_managers/nuget'
61
68
 
62
69
  require 'license_finder/package'
@@ -11,7 +11,9 @@ module LicenseFinder
11
11
  private
12
12
 
13
13
  def bower_output
14
- output = `bower list --json -l action`
14
+ command = 'bower list --json -l action'
15
+ output, success = Dir.chdir(project_path) { capture(command) }
16
+ raise "Command '#{command}' failed to execute: #{output}" unless success
15
17
 
16
18
  JSON(output)
17
19
  .fetch("dependencies", {})
@@ -10,9 +10,8 @@ module LicenseFinder
10
10
 
11
11
  def current_packages
12
12
  logger.log self.class, "including groups #{included_groups.inspect}"
13
- definition.specs_for(included_groups).map do |gem_def|
14
- bundler_def = bundler_defs.detect { |bundler_def| bundler_def.name == gem_def.name }
15
- BundlerPackage.new(gem_def, bundler_def, logger: logger).tap do |package|
13
+ details.map do |gem_detail, bundle_detail|
14
+ BundlerPackage.new(gem_detail, bundle_detail, logger: logger).tap do |package|
16
15
  logger.package self.class, package
17
16
  end
18
17
  end
@@ -27,21 +26,31 @@ module LicenseFinder
27
26
  @definition ||= ::Bundler::Definition.build(package_path, lockfile_path, nil)
28
27
  end
29
28
 
30
- def package_path
31
- project_path.join("Gemfile")
29
+ def details
30
+ gem_details.map do |gem_detail|
31
+ bundle_detail = bundler_details.detect { |bundle_detail| bundle_detail.name == gem_detail.name }
32
+ [gem_detail, bundle_detail]
33
+ end
34
+ end
35
+
36
+ def gem_details
37
+ @gem_details ||= definition.specs_for(included_groups)
32
38
  end
33
39
 
34
- def bundler_defs
35
- # memoized
36
- @bundler_defs ||= definition.dependencies
40
+ def bundler_details
41
+ @bundler_details ||= definition.dependencies
37
42
  end
38
43
 
39
44
  def included_groups
40
45
  definition.groups - ignore_groups.map(&:to_sym)
41
46
  end
42
47
 
48
+ def package_path
49
+ project_path.join("Gemfile")
50
+ end
51
+
43
52
  def lockfile_path
44
- package_path.dirname.join('Gemfile.lock')
53
+ project_path.join('Gemfile.lock')
45
54
  end
46
55
  end
47
56
  end
@@ -1,15 +1,19 @@
1
1
  module LicenseFinder
2
2
  class BundlerPackage < Package
3
3
  def initialize(spec, bundler_def, options={})
4
+ children = spec.dependencies.map(&:name)
5
+ groups = Array(bundler_def && bundler_def.groups).map(&:to_s)
6
+
4
7
  super(
5
8
  spec.name,
6
9
  spec.version.to_s,
7
10
  options.merge(
11
+ authors: Array(spec.authors).join(', '),
8
12
  summary: spec.summary,
9
13
  description: spec.description,
10
14
  homepage: spec.homepage,
11
- children: spec.dependencies.map(&:name),
12
- groups: Array(bundler_def && bundler_def.groups),
15
+ children: children,
16
+ groups: groups,
13
17
  spec_licenses: spec.licenses,
14
18
  install_path: spec.full_gem_path
15
19
  )
@@ -0,0 +1,25 @@
1
+ require 'json'
2
+
3
+ module LicenseFinder
4
+ class GoDep < PackageManager
5
+ def current_packages
6
+ json = JSON.parse(package_path.read)
7
+ json['Deps'].map { |dep| GoPackage.from_dependency(dep, install_prefix) }
8
+ end
9
+
10
+ def package_path
11
+ project_path.join('Godeps/Godeps.json')
12
+ end
13
+
14
+ private
15
+
16
+ def install_prefix
17
+ go_path = workspace_dir.exist? ? workspace_dir : Pathname(ENV['GOPATH'])
18
+ go_path.join('src')
19
+ end
20
+
21
+ def workspace_dir
22
+ project_path.join('Godeps/_workspace')
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,19 @@
1
+ module LicenseFinder
2
+ class GoPackage < Package
3
+ def self.from_workspace(name, path)
4
+ LicenseFinder::Package.new(name, 'unknown', {install_path: install_path(path)})
5
+ end
6
+
7
+ def self.from_dependency(hash, prefix)
8
+ name = hash['ImportPath']
9
+ version = hash['Rev'][0..6]
10
+ LicenseFinder::Package.new(name, version, {install_path: install_path(prefix.join(name))})
11
+ end
12
+
13
+ private
14
+
15
+ def self.install_path(path)
16
+ Pathname(path).cleanpath.to_s
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,35 @@
1
+ require 'json'
2
+
3
+ module LicenseFinder
4
+ class GoWorkspace < PackageManager
5
+ def current_packages
6
+ package_paths.map do |package_path|
7
+ package_name = Pathname(package_path).relative_path_from(project_src).to_s
8
+ GoPackage.from_workspace(package_name, package_path)
9
+ end
10
+ end
11
+
12
+ def package_path
13
+ project_path.join('.envrc')
14
+ end
15
+
16
+ def active?
17
+ active = package_path.exist? && IO.read(package_path).include?('GOPATH')
18
+ active.tap { |is_active| logger.active self.class, is_active }
19
+ end
20
+
21
+ private
22
+
23
+ def project_src
24
+ project_path.join('src')
25
+ end
26
+
27
+ def package_paths
28
+ command = 'go list -f "{{.ImportPath}} " ./...'
29
+ output, success = Dir.chdir(project_path) { capture(command) }
30
+ raise "Command '#{command}' failed to execute: #{output}" unless success
31
+
32
+ output.gsub(/\s{2,}/, ',').split(',').map { |path| path[1..-1] }
33
+ end
34
+ end
35
+ end