license_finder 2.1.0.rc6 → 2.1.0.rc7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bbf949d7115f817832bcf5c25f76c57c8f43ca4f
4
- data.tar.gz: 1edbbb2de90eaa0d57791b3f560ec28efdc7fcb2
3
+ metadata.gz: de54a1c1786084407496fd2eb1731686dd81538e
4
+ data.tar.gz: 762d170826532bff157f863df8e9c6f3afd33f06
5
5
  SHA512:
6
- metadata.gz: 0c97e33455a8a162d0c44182fbfebccbabe11b4e76eab9c5871b594f016158041f52688b2165a48773d82a4c49b0910f00ede7255d3be6eef1a219a9a058e58b
7
- data.tar.gz: dd33c7312b0d2c1ef4f8cfcfafac5ddbbc7dc719388cfd4a153634a5594eec6e1c8fc30e194be25189c52ae9836aa87c8807fc0181ef35ae53b5f357c4feafad
6
+ metadata.gz: 32cb267d5a41b650a52c054ff96858ac5fe3810fc1946dcb65f3810c041f9cc71f5edaa2bfd179ae08e86e89ecb31de76fbc50a7b7693c903f41bb5cd1a8ea5b
7
+ data.tar.gz: db7599addf26235034a50946e1bf5e59010a312fb11f45607cf59e35ac6df65d89b03fd18fbe9651112b09f657a526b4dcbb41dad7306f57ff0f61fa2593e8b8
data/CHANGELOG.rdoc CHANGED
@@ -1,3 +1,9 @@
1
+ === 2.1.0.rc7 / 2016-03-16
2
+
3
+ * Features
4
+ * PackageManagers are not activated if the underlying package management tool isn't installed
5
+
6
+
1
7
  === 2.1.0.rc6 / 2016-03-11
2
8
 
3
9
  * Features
data/Rakefile CHANGED
@@ -26,31 +26,10 @@ end
26
26
 
27
27
  desc "Check for non-Ruby development dependencies."
28
28
  task :check_dependencies do
29
- dependencies = {
30
- "mvn" => "Maven",
31
- "npm" => "NPM",
32
- "pip" => "Pip",
33
- "gradle" => "Gradle",
34
- "bower" => "Bower",
35
- "rebar" => "Rebar",
36
- "godep" => "Go"
37
- }
38
- dependencies["pod"] = "Cocoapods" if LicenseFinder::Platform.darwin?
29
+ require './lib/license_finder'
39
30
  satisfied = true
40
- dependencies.each do |dependency, description|
41
- printf "checking dev dependency for #{description} ... "
42
- if LicenseFinder::Platform.windows?
43
- `where #{dependency} 2>NUL`
44
- else
45
- `which #{dependency} 2>/dev/null`
46
- end
47
- status = $?
48
- if status.success?
49
- puts "OK"
50
- else
51
- puts "missing `#{dependency}`"
52
- satisfied = false
53
- end
31
+ LicenseFinder::PackageManager.package_managers.each do |package_manager|
32
+ satisfied = false unless package_manager.installed?(LicenseFinder::Logger.new(debug:true))
54
33
  end
55
34
  exit 1 unless satisfied
56
35
  end
@@ -12,8 +12,22 @@ module LicenseFinder
12
12
  end
13
13
 
14
14
  class Base
15
+ def installed package_manager, is_installed
16
+ if String === is_installed
17
+ log package_manager, is_installed
18
+ elsif is_installed
19
+ log package_manager, Logger.green("is installed")
20
+ else
21
+ log package_manager, Logger.red("is not installed")
22
+ end
23
+ end
24
+
15
25
  def active package_manager, is_active
16
- log package_manager, sprintf("%s active", (is_active ? "is" : "not"))
26
+ if is_active
27
+ log package_manager, Logger.green("is active")
28
+ else
29
+ log package_manager, "is not active"
30
+ end
17
31
  end
18
32
 
19
33
  def package package_manager, package
@@ -44,6 +58,18 @@ module LicenseFinder
44
58
  end
45
59
  end
46
60
 
61
+ def self.green string
62
+ colorize 32, string
63
+ end
64
+
65
+ def self.red string
66
+ colorize 31, string
67
+ end
68
+
69
+ def self.colorize color_code, string
70
+ "\e[#{color_code}m#{string}\e[0m"
71
+ end
72
+
47
73
  class Quiet < Base
48
74
  def log prefix, string
49
75
  end
@@ -23,14 +23,33 @@ module LicenseFinder
23
23
  active_package_managers.flat_map(&:current_packages_with_relations)
24
24
  end
25
25
 
26
+ def self.installed?(logger=Core.default_logger)
27
+ if package_management_command.nil?
28
+ logger.installed self, "no command defined" # TODO comment me out
29
+ return true
30
+ end
31
+
32
+ if command_exists?(package_management_command)
33
+ logger.installed self, true
34
+ return true
35
+ end
36
+
37
+ logger.installed self, false
38
+ return false
39
+ end
40
+
41
+ def self.package_management_command
42
+ nil
43
+ end
44
+
26
45
  def initialize options={}
27
46
  @logger = options[:logger] || Core.default_logger
28
47
  @project_path = options[:project_path]
29
48
  end
30
49
 
31
50
  def active?
32
- package_path.exist?
33
- .tap { |is_active| logger.active self.class, is_active }
51
+ self.class.installed?(logger) &&
52
+ package_path.exist?.tap { |is_active| logger.active self.class, is_active }
34
53
  end
35
54
 
36
55
  def capture(command)
@@ -48,6 +67,16 @@ module LicenseFinder
48
67
  packages
49
68
  end
50
69
 
70
+ def self.command_exists? command
71
+ if LicenseFinder::Platform.windows?
72
+ `where #{command} 2>NUL`
73
+ else
74
+ `which #{command} 2>/dev/null`
75
+ end
76
+ status = $?
77
+ return status.success?
78
+ end
79
+
51
80
  private
52
81
 
53
82
  attr_reader :logger, :project_path
@@ -8,6 +8,10 @@ module LicenseFinder
8
8
  end
9
9
  end
10
10
 
11
+ def self.package_management_command
12
+ "bower"
13
+ end
14
+
11
15
  private
12
16
 
13
17
  def bower_output
@@ -17,6 +17,10 @@ module LicenseFinder
17
17
  end
18
18
  end
19
19
 
20
+ def self.package_management_command
21
+ "bundler"
22
+ end
23
+
20
24
  private
21
25
 
22
26
  attr_reader :ignore_groups
@@ -19,6 +19,10 @@ module LicenseFinder
19
19
  end
20
20
  end
21
21
 
22
+ def self.package_management_command
23
+ LicenseFinder::Platform.darwin? ? "pod" : nil
24
+ end
25
+
22
26
  private
23
27
 
24
28
  def package_path
@@ -23,6 +23,10 @@ module LicenseFinder
23
23
  project_path.join('Godeps/Godeps.json')
24
24
  end
25
25
 
26
+ def self.package_management_command
27
+ "godep"
28
+ end
29
+
26
30
  private
27
31
 
28
32
  def install_prefix
@@ -9,7 +9,15 @@ module LicenseFinder
9
9
  end
10
10
 
11
11
  def active?
12
- !Dir[project_path.join("**/*.go")].empty? && package_path.exist?
12
+ return false unless self.class.installed?(@logger)
13
+
14
+ (has_go_files? && package_path.exist?).tap do |is_active|
15
+ logger.active self.class, is_active
16
+ end
17
+ end
18
+
19
+ def has_go_files?
20
+ !Dir[project_path.join("**/*.go")].empty?
13
21
  end
14
22
 
15
23
  def package_path
@@ -31,9 +31,12 @@ module LicenseFinder
31
31
  end
32
32
 
33
33
  def active?
34
- go_dep = LicenseFinder::GoDep.new({project_path: Pathname(project_path), logger: logger})
35
- return if go_dep.package_path.exist?
36
- active = !! (envrc_path && ENVRC_REGEXP.match(IO.read(envrc_path)))
34
+ return false unless self.class.installed?(logger)
35
+
36
+ godep = LicenseFinder::GoDep.new({project_path: Pathname(project_path)})
37
+ # go workspace is only active if GoDep wasn't. There are some projects
38
+ # that will use the .envrc and have a Godep folder as well.
39
+ active = !! (!godep.active? && envrc_path && ENVRC_REGEXP.match(IO.read(envrc_path)))
37
40
  active.tap { |is_active| logger.active self.class, is_active }
38
41
  end
39
42
 
@@ -26,6 +26,10 @@ module LicenseFinder
26
26
  packages.uniq
27
27
  end
28
28
 
29
+ def self.package_management_command
30
+ "gradle"
31
+ end
32
+
29
33
  private
30
34
 
31
35
  def package_path
@@ -20,6 +20,10 @@ module LicenseFinder
20
20
  end
21
21
  end
22
22
 
23
+ def self.package_management_command
24
+ "mvn"
25
+ end
26
+
23
27
  private
24
28
 
25
29
  def license_report
@@ -22,6 +22,10 @@ module LicenseFinder
22
22
  packages.values
23
23
  end
24
24
 
25
+ def self.package_management_command
26
+ "npm"
27
+ end
28
+
25
29
  private
26
30
 
27
31
  def direct_dependencies
@@ -16,6 +16,10 @@ module LicenseFinder
16
16
  end
17
17
  end
18
18
 
19
+ def self.package_management_command
20
+ "pip"
21
+ end
22
+
19
23
  private
20
24
 
21
25
  def package_path
@@ -18,6 +18,10 @@ module LicenseFinder
18
18
  end
19
19
  end
20
20
 
21
+ def self.package_management_command
22
+ "rebar"
23
+ end
24
+
21
25
  private
22
26
 
23
27
  def rebar_ouput
@@ -1,3 +1,3 @@
1
1
  module LicenseFinder
2
- VERSION = "2.1.0.rc6"
2
+ VERSION = "2.1.0.rc7"
3
3
  end
@@ -42,6 +42,7 @@ Gem::Specification.new do |s|
42
42
  s.add_dependency "thor"
43
43
  s.add_dependency "httparty"
44
44
  s.add_dependency "xml-simple"
45
+ s.add_dependency "colorize"
45
46
 
46
47
  s.add_development_dependency "capybara", "~> 2.0.0"
47
48
  s.add_development_dependency "cocoapods", "0.34.0" if LicenseFinder::Platform.darwin?
@@ -0,0 +1 @@
1
+ GOPATH=$PWD
File without changes