debendencies 1.0.0 → 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: d66f3206b716bbd71e12453919ed08f9b99853df2cbc0315223ff56967a321ae
4
- data.tar.gz: cba59a0eb411aeab169d0688f6dd8808655ef3e0f0cec926e3c3eebd26c67aa9
3
+ metadata.gz: 18596197b638956862fa80834e721cbfe870c1d5cada0d3060284a445da9cb7b
4
+ data.tar.gz: 28722328017819ceedbd601ff77f6867d7061569e98825a008e9c3be3003c72e
5
5
  SHA512:
6
- metadata.gz: 31edd084d3394a6e6badb9ef70458604cb034482d99b065f77f288f6247cc66e2403c410f0cc369c5ae9e2a23154b6ee35d13292685410c4375e46b9c8c8687d
7
- data.tar.gz: aa2cfd366f0ba55deee2dd469e3d40e814232e1b17fc1e58f72de7c311578244321bdda90cf35bff9602b31b34d490e32cdfecde2d81f9dcfa772a47d6811f4d
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,14 +31,13 @@ class Debendencies
31
31
 
32
32
  case @options[:format]
33
33
  when "oneline"
34
- puts dependencies.map { |d| d.to_s }.join(", ")
34
+ write_output(dependencies.map { |d| d.to_s }.join(", "))
35
35
  when "multiline"
36
- dependencies.each { |d| puts d.to_s }
36
+ write_output(dependencies.map { |d| d.to_s }.join("\n"))
37
37
  when "json"
38
- puts JSON.generate(dependencies.map { |d| d.as_json })
38
+ write_output(JSON.generate(dependencies.map { |d| d.as_json }))
39
39
  else
40
- puts "Invalid format: #{@options[:format]}"
41
- exit 1
40
+ abort "Invalid format: #{@options[:format]}"
42
41
  end
43
42
  end
44
43
 
@@ -55,6 +54,14 @@ class Debendencies
55
54
  @options[:format] = format
56
55
  end
57
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
+
58
65
  opts.on("--verbose", "Show verbose output") do
59
66
  @options[:verbose] = true
60
67
  end
@@ -71,6 +78,17 @@ class Debendencies
71
78
  end
72
79
  end
73
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
+
74
92
  def get_logger
75
93
  if @options[:verbose]
76
94
  require "logger"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Debendencies
4
- VERSION_STRING = "1.0.0"
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.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hongli Lai