debendencies 1.0.1 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/debendencies/cli.rb +24 -7
- data/lib/debendencies/version.rb +1 -1
- data/lib/debendencies.rb +1 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 18596197b638956862fa80834e721cbfe870c1d5cada0d3060284a445da9cb7b
|
4
|
+
data.tar.gz: 28722328017819ceedbd601ff77f6867d7061569e98825a008e9c3be3003c72e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d1336d854ec1f9c7bb92eaa053e251751c9aaccdc26121b97db3f1274dd242b897315bb959bd612d0708caaa0ad6c265f2b5b56966bfe7673e757c4804b9c000
|
7
|
+
data.tar.gz: 7b6d30f496b56050e3113faabc01e37256c49584b04e8404fd60add9d0f7f0a1d575387e98e197880501831c3e0da3e4f98241f77564bfd407d9958fca164a1c
|
data/lib/debendencies/cli.rb
CHANGED
@@ -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
|
-
|
35
|
-
puts output unless output.empty?
|
34
|
+
write_output(dependencies.map { |d| d.to_s }.join(", "))
|
36
35
|
when "multiline"
|
37
|
-
dependencies.
|
36
|
+
write_output(dependencies.map { |d| d.to_s }.join("\n"))
|
38
37
|
when "json"
|
39
|
-
|
38
|
+
write_output(JSON.generate(dependencies.map { |d| d.as_json }))
|
40
39
|
else
|
41
|
-
|
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"
|
data/lib/debendencies/version.rb
CHANGED
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|
|