bwrap 1.0.0 → 1.1.1
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
- checksums.yaml.gz.sig +0 -0
- data/CHANGELOG.md +16 -0
- data/lib/bwrap/args/args.rb +36 -1
- data/lib/bwrap/args/bind/library/ruby_binds.rb +45 -0
- data/lib/bwrap/args/bind/library.rb +25 -51
- data/lib/bwrap/args/bind/mime.rb +9 -2
- data/lib/bwrap/args/bind.rb +28 -16
- data/lib/bwrap/args/construct.rb +80 -42
- data/lib/bwrap/args/features/binds_base.rb +13 -0
- data/lib/bwrap/args/features/ruby_binds.rb +47 -0
- data/lib/bwrap/args/features.rb +11 -43
- data/lib/bwrap/args/library.rb +1 -3
- data/lib/bwrap/args/mount.rb +5 -5
- data/lib/bwrap/args/network.rb +43 -0
- data/lib/bwrap/bwrap.rb +9 -2
- data/lib/bwrap/config/features/base.rb +28 -0
- data/lib/bwrap/config/features/ruby.rb +86 -0
- data/lib/bwrap/config/features.rb +6 -78
- data/lib/bwrap/execution/exceptions.rb +12 -0
- data/lib/bwrap/execution/execute.rb +21 -3
- data/lib/bwrap/execution/execution.rb +26 -2
- data/lib/bwrap/execution/path.rb +3 -3
- data/lib/bwrap/execution/popen2e.rb +87 -0
- data/lib/bwrap/output/levels.rb +33 -3
- data/lib/bwrap/output/output_impl.rb +54 -0
- data/lib/bwrap/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +39 -4
- metadata.gz.sig +0 -0
data/lib/bwrap/output/levels.rb
CHANGED
@@ -8,7 +8,8 @@ class Bwrap::Output::Levels
|
|
8
8
|
|
9
9
|
@@_verbose = false
|
10
10
|
@@_debug = false
|
11
|
-
@@_trace = ENV
|
11
|
+
@@_trace = ENV.fetch("BWRAP_TRACE", nil) && true || false
|
12
|
+
@@_quiet = false
|
12
13
|
|
13
14
|
# @see Bwrap::Output#verbose?
|
14
15
|
def self.verbose?
|
@@ -25,8 +26,18 @@ class Bwrap::Output::Levels
|
|
25
26
|
@@_trace
|
26
27
|
end
|
27
28
|
|
29
|
+
# @see Bwrap::Output##quiet?
|
30
|
+
def self.quiet?
|
31
|
+
@@_quiet
|
32
|
+
end
|
33
|
+
|
28
34
|
# Takes hash of options received from Optimist and checks output related flags.
|
29
35
|
def self.handle_output_options options
|
36
|
+
if options[:quiet] or options[:silent]
|
37
|
+
quiet!
|
38
|
+
return
|
39
|
+
end
|
40
|
+
|
30
41
|
# Set output level flags to true or false, if it was given.
|
31
42
|
unless options[:trace].nil?
|
32
43
|
@@_verbose = options[:trace]
|
@@ -64,6 +75,18 @@ class Bwrap::Output::Levels
|
|
64
75
|
out
|
65
76
|
end
|
66
77
|
|
78
|
+
# Formats given string and outputs it.
|
79
|
+
#
|
80
|
+
# @return formatted string
|
81
|
+
def self.info_print_formatted str, log_callback: 1
|
82
|
+
# TODO: Maybe have different color for NOTICE than for INFO?
|
83
|
+
out = "#{Bwrap::Output::Colors.color(130, 230, 130, bold: true)}[NOTICE]#{Bwrap::Output::Colors.stopcolor} #{str}"
|
84
|
+
out = append_caller out, log_callback: (log_callback + 1)
|
85
|
+
puts out
|
86
|
+
|
87
|
+
out
|
88
|
+
end
|
89
|
+
|
67
90
|
# Formats given string and outputs it.
|
68
91
|
#
|
69
92
|
# @return formatted string
|
@@ -98,9 +121,16 @@ class Bwrap::Output::Levels
|
|
98
121
|
# Appends caller information to given output.
|
99
122
|
#
|
100
123
|
# Used by *_print_formatted methods.
|
101
|
-
def self.append_caller out, log_callback: 1
|
124
|
+
private_class_method def self.append_caller out, log_callback: 1
|
102
125
|
out = "#{out} (called at #{caller_locations(log_callback, 1)[0]})" if @@_trace
|
103
126
|
out
|
104
127
|
end
|
105
|
-
|
128
|
+
|
129
|
+
# Sets variables so that no extra output is shown.
|
130
|
+
private_class_method def self.quiet!
|
131
|
+
@@_verbose = false
|
132
|
+
@@_debug = false
|
133
|
+
@@_trace = false
|
134
|
+
@@_quiet = true
|
135
|
+
end
|
106
136
|
end
|
@@ -32,6 +32,8 @@ require_relative "log"
|
|
32
32
|
# When using {Bwrap::Bwrap}, {Bwrap::Bwrap#parse_command_line_arguments}
|
33
33
|
# causes output levels to be set if relevant CLI arguments have been
|
34
34
|
# given. TODO: Add documentation about CLI args somewhere. Maybe README?
|
35
|
+
#
|
36
|
+
# TODO: Add new method info() which can then be silenced using --quiet or --silent.
|
35
37
|
module Bwrap::Output
|
36
38
|
# @see #verbose?
|
37
39
|
def self.verbose?
|
@@ -43,6 +45,12 @@ module Bwrap::Output
|
|
43
45
|
Bwrap::Output::Levels.debug?
|
44
46
|
end
|
45
47
|
|
48
|
+
# @see #quiet?
|
49
|
+
# @see #info
|
50
|
+
def self.quiet?
|
51
|
+
Bwrap::Output::Levels.quiet?
|
52
|
+
end
|
53
|
+
|
46
54
|
# @see #trace?
|
47
55
|
def self.trace?
|
48
56
|
Bwrap::Output::Levels.trace?
|
@@ -89,6 +97,18 @@ module Bwrap::Output
|
|
89
97
|
Bwrap::Output::Log.puts_to_log out || str
|
90
98
|
end
|
91
99
|
|
100
|
+
# Handler used by #info to output given string.
|
101
|
+
def self.info_output str, raw: false, log_callback: 1
|
102
|
+
return if quiet?
|
103
|
+
|
104
|
+
if raw
|
105
|
+
print str
|
106
|
+
else
|
107
|
+
out = Bwrap::Output::Levels.info_print_formatted str, log_callback: (log_callback + 1)
|
108
|
+
end
|
109
|
+
Bwrap::Output::Log.puts_to_log out || str
|
110
|
+
end
|
111
|
+
|
92
112
|
# Handler used by #warn to output given string.
|
93
113
|
def self.warn_output str, raw: false, log_callback: 1
|
94
114
|
if raw
|
@@ -114,6 +134,13 @@ module Bwrap::Output
|
|
114
134
|
exit exit_code
|
115
135
|
end
|
116
136
|
|
137
|
+
# @see #info
|
138
|
+
#
|
139
|
+
# @return true if --quiet or --silent has been passed, false if not.
|
140
|
+
private def quiet?
|
141
|
+
Bwrap::Output::Levels.quiet?
|
142
|
+
end
|
143
|
+
|
117
144
|
# @return true if --verbose, --debug or --trace has been passed, false if not.
|
118
145
|
private def verbose?
|
119
146
|
Bwrap::Output::Levels.verbose?
|
@@ -161,6 +188,33 @@ module Bwrap::Output
|
|
161
188
|
Bwrap::Output.verb_output(str, raw: raw, log_callback: 2)
|
162
189
|
end
|
163
190
|
|
191
|
+
# Outputs given string if info flag has been set.
|
192
|
+
#
|
193
|
+
# This is meant for notices, and the log will be labeled with
|
194
|
+
# [NOTICE].
|
195
|
+
#
|
196
|
+
# Output flags can be set with {.handle_output_options}.
|
197
|
+
#
|
198
|
+
# == Implementation hint
|
199
|
+
#
|
200
|
+
# Usually implementing --quiet and/or --silent flag
|
201
|
+
# to control these messages (and all other output) may make
|
202
|
+
# sense.
|
203
|
+
#
|
204
|
+
# That way it would be possible to have some important
|
205
|
+
# informational messages that should be shown, but for script
|
206
|
+
# usage, those could be muted.
|
207
|
+
#
|
208
|
+
# Warning messages are meant to be shown always. Error messages
|
209
|
+
# will always be printed, as execution is halted after the
|
210
|
+
# error message has been printed.
|
211
|
+
#
|
212
|
+
# @param str String to be outputted
|
213
|
+
# @param raw [Boolean] If true, disables output formatting
|
214
|
+
private def info str, raw: false
|
215
|
+
Bwrap::Output.info_output(str, raw: raw, log_callback: 2)
|
216
|
+
end
|
217
|
+
|
164
218
|
# Outputs given string to `$stderr`.
|
165
219
|
#
|
166
220
|
# @param str String to be outputted
|
data/lib/bwrap/version.rb
CHANGED
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bwrap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samu Voutilainen
|
@@ -34,7 +34,7 @@ cert_chain:
|
|
34
34
|
X4ioQwEn1/9tHs19VO1CLF58451HgEo1BXd7eWLmV1V5cqw0YWok1ly4L/Su/Phf
|
35
35
|
MRxVMHiVAqY=
|
36
36
|
-----END CERTIFICATE-----
|
37
|
-
date: 2022-
|
37
|
+
date: 2022-06-07 00:00:00.000000000 Z
|
38
38
|
dependencies:
|
39
39
|
- !ruby/object:Gem::Dependency
|
40
40
|
name: bundler
|
@@ -92,20 +92,48 @@ dependencies:
|
|
92
92
|
- - "~>"
|
93
93
|
- !ruby/object:Gem::Version
|
94
94
|
version: '1.1'
|
95
|
+
- !ruby/object:Gem::Dependency
|
96
|
+
name: rspec
|
97
|
+
requirement: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - "~>"
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '3.11'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - "~>"
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '3.11'
|
95
109
|
- !ruby/object:Gem::Dependency
|
96
110
|
name: rspec-expectations
|
97
111
|
requirement: !ruby/object:Gem::Requirement
|
98
112
|
requirements:
|
99
113
|
- - "~>"
|
100
114
|
- !ruby/object:Gem::Version
|
101
|
-
version: '3.
|
115
|
+
version: '3.11'
|
116
|
+
type: :development
|
117
|
+
prerelease: false
|
118
|
+
version_requirements: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - "~>"
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '3.11'
|
123
|
+
- !ruby/object:Gem::Dependency
|
124
|
+
name: rspec-mocks
|
125
|
+
requirement: !ruby/object:Gem::Requirement
|
126
|
+
requirements:
|
127
|
+
- - "~>"
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: '3.11'
|
102
130
|
type: :development
|
103
131
|
prerelease: false
|
104
132
|
version_requirements: !ruby/object:Gem::Requirement
|
105
133
|
requirements:
|
106
134
|
- - "~>"
|
107
135
|
- !ruby/object:Gem::Version
|
108
|
-
version: '3.
|
136
|
+
version: '3.11'
|
109
137
|
description: For now this is tailored to my needs, so this may or may not be of any
|
110
138
|
use.
|
111
139
|
email:
|
@@ -121,23 +149,30 @@ files:
|
|
121
149
|
- lib/bwrap/args/args.rb
|
122
150
|
- lib/bwrap/args/bind.rb
|
123
151
|
- lib/bwrap/args/bind/library.rb
|
152
|
+
- lib/bwrap/args/bind/library/ruby_binds.rb
|
124
153
|
- lib/bwrap/args/bind/mime.rb
|
125
154
|
- lib/bwrap/args/construct.rb
|
126
155
|
- lib/bwrap/args/environment.rb
|
127
156
|
- lib/bwrap/args/features.rb
|
157
|
+
- lib/bwrap/args/features/binds_base.rb
|
158
|
+
- lib/bwrap/args/features/ruby_binds.rb
|
128
159
|
- lib/bwrap/args/library.rb
|
129
160
|
- lib/bwrap/args/machine_id.rb
|
130
161
|
- lib/bwrap/args/mount.rb
|
162
|
+
- lib/bwrap/args/network.rb
|
131
163
|
- lib/bwrap/bwrap.rb
|
132
164
|
- lib/bwrap/bwrap_module.rb
|
133
165
|
- lib/bwrap/config.rb
|
134
166
|
- lib/bwrap/config/features.rb
|
167
|
+
- lib/bwrap/config/features/base.rb
|
168
|
+
- lib/bwrap/config/features/ruby.rb
|
135
169
|
- lib/bwrap/execution.rb
|
136
170
|
- lib/bwrap/execution/exceptions.rb
|
137
171
|
- lib/bwrap/execution/execute.rb
|
138
172
|
- lib/bwrap/execution/execution.rb
|
139
173
|
- lib/bwrap/execution/labels.rb
|
140
174
|
- lib/bwrap/execution/path.rb
|
175
|
+
- lib/bwrap/execution/popen2e.rb
|
141
176
|
- lib/bwrap/output.rb
|
142
177
|
- lib/bwrap/output/colors.rb
|
143
178
|
- lib/bwrap/output/levels.rb
|
metadata.gz.sig
CHANGED
Binary file
|