fiedl-log 0.4.0 → 0.6.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/README.md +10 -2
- data/lib/fiedl/log/log.rb +26 -12
- data/lib/fiedl/log/version.rb +1 -1
- data/lib/fiedl/log.rb +2 -2
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8eb4f350bd36e35109a6fc799ba1b4af7e5173c79c13cdbe69277a9b1a36a9dd
|
4
|
+
data.tar.gz: 41200374085c40159f3c5c71f25a36af634a38f3304e713440d469c1f7b00261
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: af4d6d196b38eb29e74ca4675b38620b4022c6648a9f3b89a65c78e7525135e0a436aef99c010ebaf559ad93582ba39dc1824d958301fc07fae1ccb132f399c5
|
7
|
+
data.tar.gz: 11609ac7033c010650d6a3c2e135d5d50fd0d9768b1c62e45717a51690ea23484bbf0875899505b52371fc55d8b77f29585be553469c899ef348d85228ee4c80
|
data/README.md
CHANGED
@@ -21,7 +21,7 @@ log.error "This script does nothing, yet."
|
|
21
21
|
raise "This script does nothing, yet, sorry!"
|
22
22
|
```
|
23
23
|
|
24
|
-

|
25
25
|
|
26
26
|
### Manually defining a log instance
|
27
27
|
|
@@ -56,7 +56,15 @@ require 'fiedl/log'
|
|
56
56
|
shell "whoami"
|
57
57
|
```
|
58
58
|
|
59
|
-

|
60
|
+
|
61
|
+
The `shell` command returns both the output of the stdin and the stderr.
|
62
|
+
|
63
|
+
To prevent the `shell` command from printing anything, use `verbose: false`:
|
64
|
+
|
65
|
+
```ruby
|
66
|
+
user = shell "whoami", verbose: false
|
67
|
+
```
|
60
68
|
|
61
69
|
### Logging variables
|
62
70
|
|
data/lib/fiedl/log/log.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'tempfile'
|
2
|
+
|
1
3
|
class Fiedl::Log::Log
|
2
4
|
|
3
5
|
def head(text)
|
@@ -50,22 +52,34 @@ class Fiedl::Log::Log
|
|
50
52
|
filter_out expression
|
51
53
|
end
|
52
54
|
|
53
|
-
|
54
|
-
|
55
|
+
def raise(text)
|
56
|
+
self.error(text.bold)
|
57
|
+
super(text)
|
58
|
+
end
|
59
|
+
|
60
|
+
# Print command, execute it and display result.
|
61
|
+
# The command may be interactive.
|
62
|
+
#
|
63
|
+
# https://stackoverflow.com/a/20187740/2066546
|
64
|
+
# http://stackoverflow.com/a/10224650/2066546
|
65
|
+
# https://stackoverflow.com/q/20072781/2066546
|
66
|
+
# https://stackoverflow.com/a/29712307/2066546
|
55
67
|
#
|
56
|
-
def shell(command)
|
57
|
-
prompt command
|
68
|
+
def shell(command, verbose: true)
|
69
|
+
prompt command if verbose
|
58
70
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
system(command, out: io, err: io)
|
63
|
-
end
|
64
|
-
io.close
|
65
|
-
r.each_char{|c| print c; output += c}
|
71
|
+
file = Tempfile.new("fiedl-log")
|
72
|
+
@return_code = system "script -q #{file.path} #{command}"
|
73
|
+
output = file.read
|
66
74
|
|
67
|
-
Process.waitpid pid
|
68
75
|
return output
|
76
|
+
ensure
|
77
|
+
file.close
|
78
|
+
file.unlink
|
79
|
+
end
|
80
|
+
|
81
|
+
def return_code
|
82
|
+
@return_code
|
69
83
|
end
|
70
84
|
|
71
85
|
# Ensure that a certain file is present.
|
data/lib/fiedl/log/version.rb
CHANGED
data/lib/fiedl/log.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fiedl-log
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sebastian Fiedlschuster
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-12-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -92,7 +92,7 @@ homepage: https://github.com/fiedl/fiedl-log
|
|
92
92
|
licenses:
|
93
93
|
- MIT
|
94
94
|
metadata: {}
|
95
|
-
post_install_message:
|
95
|
+
post_install_message:
|
96
96
|
rdoc_options: []
|
97
97
|
require_paths:
|
98
98
|
- lib
|
@@ -108,8 +108,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
108
108
|
- !ruby/object:Gem::Version
|
109
109
|
version: '0'
|
110
110
|
requirements: []
|
111
|
-
rubygems_version: 3.
|
112
|
-
signing_key:
|
111
|
+
rubygems_version: 3.3.11
|
112
|
+
signing_key:
|
113
113
|
specification_version: 4
|
114
114
|
summary: Simple colored output helper for ruby scripts.
|
115
115
|
test_files: []
|