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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3ca8a558e1474746111a403e6fd436764f5231a55568e083e670c64d719acdaa
4
- data.tar.gz: e43c5793db564bb5cad0c42ddf46aba9eb73f5eb1aa1e079c2d6856c1c89454b
3
+ metadata.gz: 8eb4f350bd36e35109a6fc799ba1b4af7e5173c79c13cdbe69277a9b1a36a9dd
4
+ data.tar.gz: 41200374085c40159f3c5c71f25a36af634a38f3304e713440d469c1f7b00261
5
5
  SHA512:
6
- metadata.gz: 28998b2f0a0f520a5786b66e407cb9138593c1c8c822068eb1e06f88faf496d3399bfbb802b1dc43e1287ae333d31563fd1f14f959a2474f04c92ff12ad144ac
7
- data.tar.gz: e6cc038d50549d14dcb016635b09ccf193e0f889edd83c43c41167077466a1371c9a873ece5d99dcd6c9dab27da35c970876c6dc30bfa464f04f29a8d6de56cb
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
- ![screenshot](screenshots/Bildschirmfoto 2016-11-24 um 18.14.49.png)
24
+ ![screenshot](https://github.com/fiedl/fiedl-log/raw/master/screenshots/Bildschirmfoto%202016-11-24%20um%2018.14.49.png)
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
- ![screenshot](screenshots/Bildschirmfoto 2016-11-24 um 18.15.47.png)
59
+ ![screenshot](https://github.com/fiedl/fiedl-log/raw/master/screenshots/Bildschirmfoto%202016-11-24%20um%2018.15.47.png)
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
- # Print commant, execute it and display result.
54
- # See also: http://stackoverflow.com/a/10224650/2066546
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
- output = ""
60
- r, io = IO.pipe
61
- pid = fork do
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.
@@ -1,5 +1,5 @@
1
1
  module Fiedl
2
2
  module Log
3
- VERSION = "0.4.0"
3
+ VERSION = "0.6.0"
4
4
  end
5
5
  end
data/lib/fiedl/log.rb CHANGED
@@ -17,7 +17,7 @@ unless defined? log
17
17
  end
18
18
 
19
19
  unless defined? shell
20
- def shell(command)
21
- log.shell command
20
+ def shell(command, verbose: true)
21
+ log.shell command, verbose: verbose
22
22
  end
23
23
  end
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.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: 2021-11-21 00:00:00.000000000 Z
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.0.3.1
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: []