Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

ignore bundle groups feature

  • Loading branch information...
commit e39cb2d2dd3de006946ed5768ddd4c223d336e70 1 parent 522327d
Matthew Kane Parker authored
View
11 features/ignore_bundle_groups.feature
@@ -0,0 +1,11 @@
+Feature: Ignore Bundle Groups
+ As a developer
+ I want to ignore certain bundler groups
+ So that any gems I use in development, or for testing, are automatically approved for use
+
+ Scenario:
+ Given I have an app with license finder
+ And my application depends on a gem "gpl_gem" licensed with "GPL" in the "test" bundler groups
+ And I whitelist the "test" bundler group
+ When I run "license_finder"
+ Then I should not see "gpl_gem" in its output
View
11 features/step_definitions/steps.rb
@@ -224,6 +224,14 @@ def configure_license_finder_whitelist(whitelisted_licenses=[])
end
end
+ def configure_license_finder_bundler_whitelist(whitelisted_groups=[])
+ whitelisted_groups = Array whitelisted_groups
+ FileUtils.mkdir_p(config_path)
+ File.open(File.join(config_path, "license_finder.yml"), "w") do |f|
+ f.write({'ignore_groups' => whitelisted_groups}.to_yaml)
+ end
+ end
+
def execute_command(command)
Bundler.with_clean_env do
@output = `cd #{app_path} && bundle exec #{command}`
@@ -306,3 +314,6 @@ def root_path
end
end
+When /^I whitelist the "([^"]*)" bundler group$/ do |group|
+ @user.configure_license_finder_bundler_whitelist(group)
+end
View
8 lib/license_finder/bundle.rb
@@ -1,5 +1,7 @@
module LicenseFinder
class Bundle
+ attr_writer :ignore_groups
+
def initialize(bundler_definition=nil)
@definition = bundler_definition || Bundler::Definition.build(gemfile_path, lockfile_path, nil)
end
@@ -21,6 +23,10 @@ def gems
private
attr_reader :definition
+ def ignore_groups
+ @ignore_groups ||= LicenseFinder.config.ignore_groups
+ end
+
def setup_parent_child_relationships
dependency_index = {}
@@ -41,7 +47,7 @@ def dependencies
end
def included_groups
- definition.groups - LicenseFinder.config.ignore_groups
+ definition.groups - ignore_groups
end
def gemfile_path
Please sign in to comment.
Something went wrong with that request. Please try again.