fiedl-log 0.4.0 → 0.5.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 +9 -4
- data/lib/fiedl/log/version.rb +1 -1
- data/lib/fiedl/log.rb +2 -2
- 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: 50633d096202849e748b14cc35cf0badcf887040d719239480c5117dda15d454
|
4
|
+
data.tar.gz: 83cd6b2bc6aea3834a3ef40a52bd1c19a8f573da7027a64fb8c325aa8ec2e352
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 298c22019b349406edb0569f75c416e1209c78cd7715fdb635e093d9de61f3e36b48db493ac55427a816150756c51cd7159ad4cf65f63aabd0567bc65556bd2a
|
7
|
+
data.tar.gz: e36ea52a0268251cebffc7c8b348941e37391f4a884755bb91716e18718ce9bfb0e7bd1d6a39da142e12f91c4463bfc9ecff658cf54edb9114aa4314008c10e6
|
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
@@ -50,11 +50,16 @@ class Fiedl::Log::Log
|
|
50
50
|
filter_out expression
|
51
51
|
end
|
52
52
|
|
53
|
+
def raise(text)
|
54
|
+
self.error(text.bold)
|
55
|
+
super(text)
|
56
|
+
end
|
57
|
+
|
53
58
|
# Print commant, execute it and display result.
|
54
59
|
# See also: http://stackoverflow.com/a/10224650/2066546
|
55
60
|
#
|
56
|
-
def shell(command)
|
57
|
-
prompt command
|
61
|
+
def shell(command, verbose: true)
|
62
|
+
prompt command if verbose
|
58
63
|
|
59
64
|
output = ""
|
60
65
|
r, io = IO.pipe
|
@@ -62,10 +67,10 @@ class Fiedl::Log::Log
|
|
62
67
|
system(command, out: io, err: io)
|
63
68
|
end
|
64
69
|
io.close
|
65
|
-
r.each_char{|c| print c; output += c}
|
70
|
+
r.each_char{|c| (print c if verbose); output += c}
|
66
71
|
|
67
72
|
Process.waitpid pid
|
68
|
-
return output
|
73
|
+
return output.strip
|
69
74
|
end
|
70
75
|
|
71
76
|
# Ensure that a certain file is present.
|
data/lib/fiedl/log/version.rb
CHANGED
data/lib/fiedl/log.rb
CHANGED