license_finder 0.8.1-java → 0.8.2-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. data/.gitignore +1 -0
  2. data/CHANGELOG.rdoc +15 -1
  3. data/bin/license_finder +1 -61
  4. data/db/migrate/201304181524_add_manual_to_dependencies.rb +7 -0
  5. data/features/ignore_bundle_groups.feature +15 -2
  6. data/features/non_bundler_dependencies.feature +19 -0
  7. data/features/step_definitions/approve_dependencies_steps.rb +1 -1
  8. data/features/step_definitions/cli_steps.rb +1 -1
  9. data/features/step_definitions/html_report_steps.rb +1 -6
  10. data/features/step_definitions/ignore_bundle_groups_steps.rb +18 -2
  11. data/features/step_definitions/non_bundler_steps.rb +33 -0
  12. data/features/step_definitions/set_license_steps.rb +1 -1
  13. data/features/step_definitions/shared_steps.rb +5 -8
  14. data/lib/license_finder.rb +24 -25
  15. data/lib/license_finder/bundle.rb +2 -2
  16. data/lib/license_finder/bundled_gem.rb +3 -3
  17. data/lib/license_finder/{gem_saver.rb → bundled_gem_saver.rb} +3 -5
  18. data/lib/license_finder/bundler_group_manager.rb +22 -0
  19. data/lib/license_finder/cli.rb +137 -31
  20. data/lib/license_finder/configuration.rb +28 -12
  21. data/lib/license_finder/dependency_manager.rb +49 -0
  22. data/lib/license_finder/license.rb +3 -3
  23. data/lib/license_finder/{license_files.rb → possible_license_files.rb} +2 -2
  24. data/lib/license_finder/{dependency_report.rb → reports/dependency_report.rb} +1 -1
  25. data/lib/license_finder/{html_report.rb → reports/html_report.rb} +0 -0
  26. data/lib/license_finder/{reporter.rb → reports/reporter.rb} +0 -0
  27. data/lib/license_finder/{text_report.rb → reports/text_report.rb} +0 -0
  28. data/lib/license_finder/tables.rb +1 -1
  29. data/lib/license_finder/tables/dependency.rb +24 -5
  30. data/lib/license_finder/yml_to_sql.rb +5 -0
  31. data/lib/tasks/license_finder.rake +1 -1
  32. data/license_finder.gemspec +5 -3
  33. data/readme.md +103 -26
  34. data/release.md +7 -2
  35. data/spec/lib/license_finder/bundle_spec.rb +4 -11
  36. data/spec/lib/license_finder/{gem_saver_spec.rb → bundled_gem_saver_spec.rb} +7 -4
  37. data/spec/lib/license_finder/bundled_gem_spec.rb +1 -1
  38. data/spec/lib/license_finder/bundler_group_manager_spec.rb +60 -0
  39. data/spec/lib/license_finder/cli_spec.rb +119 -19
  40. data/spec/lib/license_finder/configuration_spec.rb +31 -8
  41. data/spec/lib/license_finder/dependency_manager_spec.rb +107 -0
  42. data/spec/lib/license_finder/html_report_spec.rb +3 -3
  43. data/spec/lib/license_finder/{license_files_spec.rb → possible_license_files_spec.rb} +7 -7
  44. data/spec/lib/license_finder/tables/dependency_spec.rb +31 -44
  45. data/spec/lib/license_finder/yml_to_sql_spec.rb +24 -2
  46. data/spec/spec_helper.rb +0 -1
  47. data/spec/support/silence_stdout.rb +13 -0
  48. metadata +85 -76
  49. data/lib/license_finder/bundle_syncer.rb +0 -11
  50. data/spec/lib/license_finder/bundle_syncer_spec.rb +0 -16
data/.gitignore CHANGED
@@ -10,3 +10,4 @@ doc/dependencies.*
10
10
  db/schema.rb
11
11
  config/
12
12
  .pairs
13
+ *.swp
data/CHANGELOG.rdoc CHANGED
@@ -1,8 +1,22 @@
1
+ === 0.8.2 / 2012-07-09
2
+
3
+ * Features
4
+
5
+ * Switch to thor for CLI, to support future additions to CLI
6
+ * Restore ability to manage (add/remove) dependencies that Bundler can't find
7
+ * Can maintain ignored bundler groups from command line
8
+
9
+ * Bugfixes
10
+
11
+ * Fix bug preventing manual approval of child dependencies (Issue #23)
12
+ * Fix issue with database URI when the absolute path to the database file
13
+ contains spaces.
14
+ * Upgrading from 0.7.2 no longer removes non-gem dependencies (Issue #20)
15
+
1
16
  === 0.8.1 / 2013-04-14
2
17
 
3
18
  * Features
4
19
 
5
- * Add spinner to show that the binary is actually doing something.
6
20
  * JRuby version of the gem.
7
21
  * Official ruby 2.0 support.
8
22
  * CLI interface for moving dependencies.* files to `doc/`.
data/bin/license_finder CHANGED
@@ -1,65 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'license_finder'
4
- require 'optparse'
5
4
 
6
- module SpinnerStrategy
7
- module Spin
8
- def self.run
9
- thread = Thread.new() {
10
- wheel = '\|/-'
11
- i = 0
12
- while not LicenseFinder::CLI.class_variable_get("@@run_complete") do
13
- print "\r ---------- #{wheel[i]} ----------"
14
- i = (i + 1) % 4
15
- end
16
- }
17
- yield
18
- thread.join
19
- end
20
- end
21
-
22
- module Noop
23
- def self.run
24
- yield
25
- end
26
- end
27
- end
28
-
29
- options = {}
30
- spinner = SpinnerStrategy::Spin
31
- skip = false
32
-
33
- OptionParser.new do |opts|
34
- opts.banner = "Usage: license_finder [options] [dependency]"
35
-
36
- opts.on("-a", "--approve", "Approve a gem by name.") do |gem_name|
37
- options[:approve] = true
38
- end
39
-
40
- opts.on("-l", "--license [LICENSE]", "Update a gem's license.") do |license|
41
- options[:license] = license
42
- end
43
-
44
- opts.on("-q", "--quiet") do
45
- spinner = SpinnerStrategy::Noop
46
- end
47
-
48
- opts.on("-m", "--move") do
49
- skip = true
50
- `sed '$d' < config/license_finder.yml > tmp34567.txt`
51
- `mv tmp34567.txt config/license_finder.yml`
52
- `echo "dependencies_file_dir: './doc/'" >> config/license_finder.yml`
53
- `mkdir doc`
54
- `mv dependencies.* doc/`
55
- puts "Congratulations, you have cleaned up your root directory!'"
56
- end
57
- end.parse!
58
-
59
- unless options.empty?
60
- options[:dependency] = ARGV.last
61
- end
62
-
63
- spinner.run {
64
- LicenseFinder::CLI.execute!(options)
65
- } unless skip
5
+ LicenseFinder::CLI::Main.start
@@ -0,0 +1,7 @@
1
+ Sequel.migration do
2
+ change do
3
+ alter_table(:dependencies) do
4
+ add_column :manual, TrueClass # i.e., keep this dependency eternally
5
+ end
6
+ end
7
+ end
@@ -3,8 +3,21 @@ Feature: Ignore Bundle Groups
3
3
  I want to ignore certain bundler groups
4
4
  So that any gems I use in development, or for testing, are automatically approved for use
5
5
 
6
- Scenario:
6
+ Scenario: Ignored bundler groups are not evaluated for licenses
7
7
  Given I have an app with license finder that depends on a GPL licensed gem in the test bundler group
8
- And I ignore the test group
8
+ And I add the test group to the ignored bundler groups
9
9
  When I run license_finder
10
10
  Then I should not see the GPL licensed gem in the output
11
+
12
+ Scenario: Bundler groups can be added to the ignore list from command line
13
+ Given I have an app with license finder
14
+ And I add the test group to the ignored bundler groups
15
+ When I get the ignored groups from the command line
16
+ Then I should see the test group in the output
17
+
18
+ Scenario: Bundler groups can be removed from the ignore list from command line
19
+ Given I have an app with license finder
20
+ And I add the test group to the ignored bundler groups
21
+ And I remove the test group from the ignored bundler groups
22
+ When I get the ignored groups from the command line
23
+ Then I should not see the test group in the output
@@ -0,0 +1,19 @@
1
+ Feature: Tracking non-Bundler Dependencies
2
+ So that I can track JS and other dependencies not tracked by Bundler
3
+ As an application developer using license finder
4
+ I want to be able to manually manage non-Bundler dependencies
5
+
6
+ Scenario: Adding a non-Bundler dependency
7
+ Given I have an app with license finder
8
+ When I add my JS dependency
9
+ Then I should see the JS dependency in the console output
10
+
11
+ Scenario: Auto approving a non-Bundler dependency I add
12
+ Given I have an app with license finder
13
+ When I add my JS dependency with an approval flag
14
+ Then I should not see the JS dependency in the console output since it is approved
15
+
16
+ Scenario: Removing a non-Bundler dependency
17
+ Given I have an app with license finder and a JS dependency
18
+ When I remove my JS dependency
19
+ Then I should not see the JS dependency in the console output
@@ -7,7 +7,7 @@ end
7
7
  When(/^I approve that gem$/) do
8
8
  @output = @user.execute_command "license_finder"
9
9
  @output.should include "gpl_gem"
10
- @output = @user.execute_command "license_finder -a gpl_gem"
10
+ @output = @user.execute_command "license_finder approve gpl_gem"
11
11
  @output = @user.execute_command "license_finder -q"
12
12
  end
13
13
 
@@ -18,7 +18,7 @@ Given(/^I have a project that depends on mime\-types with a manual license type$
18
18
  @user.add_gem_dependency('mime-types')
19
19
  @user.bundle_app
20
20
  @user.execute_command "license_finder -q"
21
- @output = @user.execute_command "license_finder -l Ruby mime-types"
21
+ @output = @user.execute_command "license_finder license Ruby mime-types"
22
22
  @output.should =~ /mime-types.*Ruby/
23
23
  end
24
24
 
@@ -1,8 +1,3 @@
1
- Given(/^I have an app with license finder$/) do
2
- @user = ::DSL::User.new
3
- @user.create_nonrails_app
4
- end
5
-
6
1
  Given(/^my app depends on a gem with specific details$/) do
7
2
  @gem_name = "mit_licensed_gem"
8
3
  @table = {
@@ -54,7 +49,7 @@ end
54
49
  Then(/^I should see only see GPL liceneses as unapproved in the html$/) do
55
50
  html = File.read(@user.dependencies_html_path)
56
51
  page = Capybara.string(html)
57
- page.should have_content '8 total'
52
+ page.should have_content '9 total'
58
53
  page.should have_content '1 unapproved'
59
54
  page.should have_content '1 GPL'
60
55
  end
@@ -4,10 +4,26 @@ Given(/^I have an app with license finder that depends on a GPL licensed gem in
4
4
  @user.add_dependency_to_app 'gpl_gem', :license => 'GPL', :bundler_groups => 'test'
5
5
  end
6
6
 
7
- And(/^I ignore the test group$/) do
8
- @user.configure_license_finder_bundler_whitelist('test')
7
+ And(/^I add the test group to the ignored bundler groups$/) do
8
+ @user.execute_command('license_finder ignored_bundler_group add test')
9
+ end
10
+
11
+ And(/^I remove the test group from the ignored bundler groups$/) do
12
+ @user.execute_command('license_finder ignored_bundler_group remove test')
9
13
  end
10
14
 
11
15
  Then(/^I should not see the GPL licensed gem in the output$/) do
12
16
  @output.should_not include 'gpl_gem'
13
17
  end
18
+
19
+ When(/^I get the ignored groups from the command line$/) do
20
+ @output = @user.execute_command('license_finder ignored_bundler_group list')
21
+ end
22
+
23
+ Then(/^I should see the test group in the output$/) do
24
+ @output.should include 'test'
25
+ end
26
+
27
+ Then(/^I should not see the test group in the output$/) do
28
+ @output.should_not include 'test'
29
+ end
@@ -0,0 +1,33 @@
1
+ Given(/^I have an app with license finder and a JS dependency$/) do
2
+ @user = ::DSL::User.new
3
+ @user.create_nonrails_app
4
+ @output = @user.execute_command 'license_finder dependencies add MIT my_js_dep 1.2.3'
5
+ end
6
+
7
+ When(/^I add my JS dependency$/) do
8
+ @output = @user.execute_command 'license_finder dependencies add MIT my_js_dep 1.2.3'
9
+ end
10
+
11
+ When(/^I add my JS dependency with an approval flag$/) do
12
+ @output = @user.execute_command 'license_finder dependencies add -a MIT my_js_dep 1.2.3'
13
+ @output.should == "The my_js_dep dependency has been added and approved!\n"
14
+ end
15
+
16
+ When(/^I remove my JS dependency$/) do
17
+ @user.execute_command 'license_finder dependencies remove my_js_dep'
18
+ end
19
+
20
+ Then(/^I should see the JS dependency in the console output$/) do
21
+ @output = @user.execute_command 'license_finder -q'
22
+ @output.should include 'my_js_dep, 1.2.3, MIT'
23
+ end
24
+
25
+ Then(/^I should not see the JS dependency in the console output$/) do
26
+ @output = @user.execute_command 'license_finder -q'
27
+ @output.should_not include 'my_js_dep, 1.2.3, MIT'
28
+ end
29
+
30
+ Then(/^I should not see the JS dependency in the console output since it is approved$/) do
31
+ @output = @user.execute_command 'license_finder -q'
32
+ @output.should_not include 'my_js_dep, 1.2.3, MIT'
33
+ end
@@ -7,7 +7,7 @@ end
7
7
 
8
8
  When(/^I set that gems license to MIT from the command line$/) do
9
9
  @output = @user.execute_command 'license_finder -q'
10
- @output = @user.execute_command 'license_finder -lq MIT other_gem'
10
+ @output = @user.execute_command 'license_finder license MIT other_gem'
11
11
  @output = @user.execute_command 'license_finder -q'
12
12
  end
13
13
 
@@ -5,6 +5,11 @@ require 'capybara'
5
5
 
6
6
  ########## COMMON STEPS ##########
7
7
 
8
+ Given(/^I have an app with license finder$/) do
9
+ @user = ::DSL::User.new
10
+ @user.create_nonrails_app
11
+ end
12
+
8
13
  When(/^I run license_finder$/) do
9
14
  @output = @user.execute_command "license_finder -q"
10
15
  end
@@ -103,14 +108,6 @@ module DSL
103
108
  end
104
109
  end
105
110
 
106
- def configure_license_finder_bundler_whitelist(whitelisted_groups=[])
107
- whitelisted_groups = Array whitelisted_groups
108
- FileUtils.mkdir_p(config_path)
109
- File.open(File.join(config_path, "license_finder.yml"), "w") do |f|
110
- f.write({'ignore_groups' => whitelisted_groups}.to_yaml)
111
- end
112
- end
113
-
114
111
  def execute_command(command)
115
112
  Bundler.with_clean_env do
116
113
  @output = `cd #{app_path} && bundle exec #{command}`
@@ -5,32 +5,31 @@ require 'erb'
5
5
  module LicenseFinder
6
6
  ROOT_PATH = Pathname.new(__FILE__).dirname
7
7
 
8
- DEPENDENCY_ATTRIBUTES = [
9
- "name", "version", "license", "license_url", "approved", "notes",
10
- "license_files", "bundler_groups", "summary",
11
- "description", "homepage", "children", "parents", "manual"
12
- ]
13
-
14
- autoload :Bundle, 'license_finder/bundle'
15
- autoload :BundledGem, 'license_finder/bundled_gem'
16
- autoload :CLI, 'license_finder/cli'
17
- autoload :Configuration, 'license_finder/configuration'
18
- autoload :License, 'license_finder/license'
19
- autoload :LicenseUrl, 'license_finder/license_url'
20
- autoload :PossibleLicenseFile, 'license_finder/possible_license_file'
21
- autoload :DependencyReport, 'license_finder/dependency_report'
22
- autoload :HtmlReport, 'license_finder/html_report'
23
- autoload :TextReport, 'license_finder/text_report'
24
- autoload :Reporter, 'license_finder/reporter'
25
- autoload :BundleSyncer, 'license_finder/bundle_syncer'
26
- autoload :YmlToSql, 'license_finder/yml_to_sql'
27
- autoload :Dependency, 'license_finder/tables/dependency'
28
- autoload :Approval, 'license_finder/tables/approval'
29
- autoload :LicenseAlias, 'license_finder/tables/license_alias'
8
+ Error = Class.new(StandardError)
9
+
10
+ autoload :Bundle, 'license_finder/bundle'
11
+ autoload :BundledGem, 'license_finder/bundled_gem'
12
+ autoload :BundledGemSaver, 'license_finder/bundled_gem_saver'
13
+ autoload :BundlerGroupManager, 'license_finder/bundler_group_manager'
14
+ autoload :CLI, 'license_finder/cli'
15
+ autoload :Configuration, 'license_finder/configuration'
16
+ autoload :DependencyManager, 'license_finder/dependency_manager'
17
+ autoload :License, 'license_finder/license'
18
+ autoload :LicenseUrl, 'license_finder/license_url'
19
+ autoload :Platform, 'license_finder/platform'
20
+ autoload :PossibleLicenseFile, 'license_finder/possible_license_file'
21
+ autoload :PossibleLicenseFiles, 'license_finder/possible_license_files'
22
+ autoload :YmlToSql, 'license_finder/yml_to_sql'
23
+
24
+ autoload :Approval, 'license_finder/tables/approval'
30
25
  autoload :BundlerGroup, 'license_finder/tables/bundler_group'
31
- autoload :GemSaver, 'license_finder/gem_saver'
32
- autoload :LicenseFiles, 'license_finder/license_files'
33
- autoload :Platform, 'license_finder/platform'
26
+ autoload :Dependency, 'license_finder/tables/dependency'
27
+ autoload :LicenseAlias, 'license_finder/tables/license_alias'
28
+
29
+ autoload :DependencyReport, 'license_finder/reports/dependency_report'
30
+ autoload :HtmlReport, 'license_finder/reports/html_report'
31
+ autoload :Reporter, 'license_finder/reports/reporter'
32
+ autoload :TextReport, 'license_finder/reports/text_report'
34
33
 
35
34
  def self.config
36
35
  @config ||= Configuration.ensure_default
@@ -2,8 +2,8 @@ module LicenseFinder
2
2
  class Bundle
3
3
  attr_writer :ignore_groups
4
4
 
5
- def self.current_gem_dependencies(bundler_definition=nil)
6
- new(bundler_definition).gems.map(&:save_or_merge)
5
+ def self.current_gems(bundler_definition=nil)
6
+ new(bundler_definition).gems
7
7
  end
8
8
 
9
9
  def initialize(bundler_definition=nil)
@@ -34,15 +34,15 @@ module LicenseFinder
34
34
  end
35
35
 
36
36
  def license_files
37
- LicenseFiles.new(@spec.full_gem_path).files
37
+ PossibleLicenseFiles.new(@spec.full_gem_path).find
38
38
  end
39
39
 
40
40
  def sort_order
41
41
  dependency_name.downcase
42
42
  end
43
43
 
44
- def save_or_merge
45
- GemSaver.find_or_initialize_by_name(@spec.name, self).save
44
+ def save_as_dependency
45
+ BundledGemSaver.find_or_initialize_by_name(@spec.name, self).save
46
46
  end
47
47
  end
48
48
  end
@@ -1,13 +1,11 @@
1
1
  module LicenseFinder
2
- class GemSaver
2
+ class BundledGemSaver
3
3
  extend Forwardable
4
4
  def_delegators :spec, :name, :version, :summary, :description, :homepage
5
5
  def_delegators :bundled_gem, :bundler_dependency, :determine_license, :children
6
6
 
7
7
  def self.find_or_initialize_by_name(name, bundled_gem)
8
- dependency = Dependency.find_or_create(name: name) do |d|
9
- d.approval = Approval.create
10
- end
8
+ dependency = Dependency.named(name)
11
9
  new(dependency, bundled_gem)
12
10
  end
13
11
 
@@ -55,7 +53,7 @@ module LicenseFinder
55
53
  def refresh_children
56
54
  dependency.remove_all_children
57
55
  children.each do |child|
58
- dependency.add_child Dependency.find_or_create(name: child.to_s)
56
+ dependency.add_child Dependency.named(child)
59
57
  end
60
58
  end
61
59
 
@@ -0,0 +1,22 @@
1
+ module LicenseFinder
2
+ module BundlerGroupManager
3
+ def self.add_ignored_group(group)
4
+ config = LicenseFinder.config
5
+ ignored_groups = config.ignore_groups.map(&:to_s)
6
+ return if ignored_groups.include?(group)
7
+
8
+ config.ignore_groups << group.to_sym
9
+ config.save_to_yaml
10
+ end
11
+
12
+ def self.remove_ignored_group(group)
13
+ config = LicenseFinder.config
14
+ ignored_groups = config.ignore_groups.map(&:to_s)
15
+ return unless ignored_groups.include?(group)
16
+
17
+ config.ignore_groups.delete(group.to_sym)
18
+ config.save_to_yaml
19
+ end
20
+ end
21
+ end
22
+
@@ -1,49 +1,155 @@
1
+ require 'thor'
2
+
1
3
  module LicenseFinder
2
4
  module CLI
3
- extend self
5
+ class Base < Thor
6
+ def self.subcommand(namespace, klass, namespace_description)
7
+ description = "#{namespace} [#{(klass.tasks.keys - ["help"]).join("|")}]"
8
+ desc description, "#{namespace_description} - see `license_finder #{namespace} help` for more information"
9
+ super namespace, klass
10
+ end
4
11
 
5
- @@run_complete = false
12
+ private
6
13
 
7
- def check_for_action_items
8
- BundleSyncer.sync!
9
- @@run_complete = true
10
- generate_reports
14
+ def die_on_error
15
+ yield
16
+ rescue LicenseFinder::Error => e
17
+ say e.message, :red
18
+ exit 1
19
+ end
20
+ end
11
21
 
12
- unapproved = Dependency.unapproved
22
+ class Dependencies < Base
23
+ option :approve, type: :boolean, aliases: :a
24
+ desc "add LICENSE DEPENDENCY_NAME [VERSION] [--approve]", "Add a dependency that is not managed by Bundler"
25
+ def add(license, name, version = nil)
26
+ die_on_error {
27
+ DependencyManager.create_non_bundler(license, name, version)
28
+ DependencyManager.approve!(name) if options[:approve]
29
+ }
30
+ if options[:approve]
31
+ say "The #{name} dependency has been added and approved!", :green
32
+ else
33
+ say "The #{name} dependency has been added!", :green
34
+ end
35
+ end
13
36
 
14
- puts "\r" + " "*24
15
- if unapproved.count == 0
16
- puts "All gems are approved for use"
17
- else
18
- puts "Dependencies that need approval:"
19
- puts TextReport.new(unapproved)
20
- exit 1
37
+ desc "remove DEPENDENCY_NAME", "Remove a dependency that is not managed by Bundler"
38
+ def remove(name)
39
+ die_on_error {
40
+ DependencyManager.destroy_non_bundler(name)
41
+ }
42
+
43
+ say "The #{name} dependency has been removed.", :green
21
44
  end
22
45
  end
23
46
 
24
- def execute!(options={})
25
- if options.empty?
26
- check_for_action_items
27
- else
28
- dependency = Dependency.first(name: options[:dependency])
47
+ class IgnoredBundlerGroups < Base
48
+ desc "list", "List all the ignored bundler groups"
49
+ def list
50
+ ignored = LicenseFinder.config.ignore_groups
29
51
 
30
- @@run_complete = true
31
- puts "\r" + " "*24
32
- if options[:approve]
33
- dependency.approve!
34
- puts "The #{dependency.name} has been approved!\n\n"
35
- elsif options[:license]
36
- dependency.set_license_manually options[:license]
37
- puts "The #{dependency.name} has been marked as using #{options[:license]} license!\n\n"
52
+ say "Ignored Bundler Groups:", :red
53
+ ignored.each do |group|
54
+ say group
38
55
  end
56
+ end
57
+
58
+ desc "add", "Add a bundler group to be ignored"
59
+ def add(group)
60
+ die_on_error {
61
+ BundlerGroupManager.add_ignored_group(group)
62
+ }
63
+ say "Added #{group} to the ignored bundler groups"
64
+ end
39
65
 
40
- generate_reports
66
+ desc "remove", "Remove a bundler group from the ignored bundler groups"
67
+ def remove(group)
68
+ die_on_error {
69
+ BundlerGroupManager.remove_ignored_group(group)
70
+ }
71
+ say "Removed #{group} from the ignored bundler groups"
41
72
  end
42
73
  end
43
74
 
44
- private
45
- def generate_reports
46
- Reporter.write_reports
75
+ class Main < Base
76
+ option :quiet, type: :boolean, aliases: :q
77
+ desc "rescan", "Find new dependencies."
78
+ def rescan
79
+ die_on_error {
80
+ spinner {
81
+ DependencyManager.sync_with_bundler
82
+ }
83
+ }
84
+
85
+ action_items
86
+ end
87
+ default_task :rescan
88
+
89
+ desc "approve DEPENDENCY_NAME", "Approve a dependency by name."
90
+ def approve(name)
91
+ die_on_error {
92
+ DependencyManager.approve!(name)
93
+ }
94
+
95
+ say "The #{name} dependency has been approved!", :green
96
+ end
97
+
98
+ desc "license LICENSE DEPENDENCY_NAME", "Update a dependency's license."
99
+ def license(license, name)
100
+ die_on_error {
101
+ DependencyManager.license!(name, license)
102
+ }
103
+
104
+ say "The #{name} dependency has been marked as using #{license} license!", :green
105
+ end
106
+
107
+ desc "move", "Move dependency.* files from root directory to doc/."
108
+ def move
109
+ Configuration.move!
110
+ say "Congratulations, you have cleaned up your root directory!'", :green
111
+ end
112
+
113
+ desc "action_items", "List unapproved dependencies"
114
+ def action_items
115
+ unapproved = Dependency.unapproved
116
+
117
+ if unapproved.empty?
118
+ say "All gems are approved for use", :green
119
+ else
120
+ say "Dependencies that need approval:", :red
121
+ say TextReport.new(unapproved)
122
+ exit 1
123
+ end
124
+ end
125
+
126
+ subcommand "dependencies", Dependencies, "manage non-Bundler dependencies"
127
+ subcommand "ignored_bundler_groups", IgnoredBundlerGroups, "manage ignored bundler groups"
128
+
129
+ private
130
+
131
+ def spinner
132
+ if options[:quiet]
133
+ yield
134
+ else
135
+ begin
136
+ thread = Thread.new {
137
+ wheel = '\|/-'
138
+ i = 0
139
+ while true do
140
+ print "\r ---------- #{wheel[i]} ----------"
141
+ i = (i + 1) % 4
142
+ end
143
+ }
144
+ yield
145
+ ensure
146
+ if thread
147
+ thread.kill
148
+ puts "\r" + " "*24
149
+ end
150
+ end
151
+ end
152
+ end
47
153
  end
48
154
  end
49
155
  end