debendencies 1.0.1 → 1.1.0

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
  SHA256:
3
- metadata.gz: 817968c6c63af2d8f361e1a881ee7221673de04b0304bd13ddb7f2b5536f2599
4
- data.tar.gz: c52a8958c2b4cf3e291e7bfcddf7626e2b1181f7b6a395c5d79e1d1d7cc0ab30
3
+ metadata.gz: 18596197b638956862fa80834e721cbfe870c1d5cada0d3060284a445da9cb7b
4
+ data.tar.gz: 28722328017819ceedbd601ff77f6867d7061569e98825a008e9c3be3003c72e
5
5
  SHA512:
6
- metadata.gz: 9308e8e793c7fe113d48bab942837e7348cb358d3459f07d1a47c2a061586d6bd1a34a8664eb9f48c4904a862a775e65b1ccde78f847db24d93fdf960bb4f4e0
7
- data.tar.gz: 346ff3cbd193b5fc567bbe25bc5209d689c3f814ba16364e8953a0dcdf4470e950e5d4ff4a85d56d1d357629ef8200480a832d9a41359176439d05a88946e450
6
+ metadata.gz: d1336d854ec1f9c7bb92eaa053e251751c9aaccdc26121b97db3f1274dd242b897315bb959bd612d0708caaa0ad6c265f2b5b56966bfe7673e757c4804b9c000
7
+ data.tar.gz: 7b6d30f496b56050e3113faabc01e37256c49584b04e8404fd60add9d0f7f0a1d575387e98e197880501831c3e0da3e4f98241f77564bfd407d9958fca164a1c
@@ -17,7 +17,7 @@ class Debendencies
17
17
 
18
18
  paths = ARGV
19
19
  if paths.empty?
20
- puts option_parser
20
+ STDERR.puts option_parser
21
21
  exit 1
22
22
  end
23
23
 
@@ -31,15 +31,13 @@ class Debendencies
31
31
 
32
32
  case @options[:format]
33
33
  when "oneline"
34
- output = dependencies.map { |d| d.to_s }.join(", ")
35
- puts output unless output.empty?
34
+ write_output(dependencies.map { |d| d.to_s }.join(", "))
36
35
  when "multiline"
37
- dependencies.each { |d| puts d.to_s }
36
+ write_output(dependencies.map { |d| d.to_s }.join("\n"))
38
37
  when "json"
39
- puts JSON.generate(dependencies.map { |d| d.as_json })
38
+ write_output(JSON.generate(dependencies.map { |d| d.as_json }))
40
39
  else
41
- puts "Invalid format: #{@options[:format]}"
42
- exit 1
40
+ abort "Invalid format: #{@options[:format]}"
43
41
  end
44
42
  end
45
43
 
@@ -56,6 +54,14 @@ class Debendencies
56
54
  @options[:format] = format
57
55
  end
58
56
 
57
+ opts.on("-o", "--output PATH", "Write output file instead of standard output") do |path|
58
+ @options[:output] = path
59
+ end
60
+
61
+ opts.on("--tee", "When --output is specified, also write to standard output") do
62
+ @options[:tee] = true
63
+ end
64
+
59
65
  opts.on("--verbose", "Show verbose output") do
60
66
  @options[:verbose] = true
61
67
  end
@@ -72,6 +78,17 @@ class Debendencies
72
78
  end
73
79
  end
74
80
 
81
+ def write_output(text)
82
+ if @options[:output]
83
+ File.open(@options[:output], "w") do |f|
84
+ f.write(text) unless text.empty?
85
+ end
86
+ puts text if @options[:tee] && !text.empty?
87
+ else
88
+ puts text unless text.empty?
89
+ end
90
+ end
91
+
75
92
  def get_logger
76
93
  if @options[:verbose]
77
94
  require "logger"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Debendencies
4
- VERSION_STRING = "1.0.1"
4
+ VERSION_STRING = "1.1.0"
5
5
  end
data/lib/debendencies.rb CHANGED
@@ -87,9 +87,7 @@ class Debendencies
87
87
  soname, dependency_libs = Private.extract_soname_and_dependency_libs(path)
88
88
  @logger&.info("Detected soname: #{soname || "(none)"}")
89
89
  @logger&.info("Detected dependencies: #{dependency_libs.inspect}")
90
- if Private.path_resembles_library?(path) && soname.nil?
91
- raise Error, "Error scanning ELF file: cannot determine shared library name (soname) for #{path}"
92
- end
90
+ soname = File.basename(path) if Private.path_resembles_library?(path) && soname.nil?
93
91
 
94
92
  @scanned_libs << soname if soname
95
93
  dependency_libs.each do |dependency_soname|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: debendencies
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hongli Lai