fiedl-log 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +26 -0
- data/lib/fiedl/log.rb +1 -0
- data/lib/fiedl/log/log.rb +25 -1
- data/lib/fiedl/log/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9c288e07d37916e6352cb8d15b65e7ebf1134930
|
4
|
+
data.tar.gz: 8d0f3703fa32c7a8d2301905e959f3e97356f99f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 84a6d781078865f827b6f0e9ad145c64fea6d5bc74b590c20ee8eacadb68d1efb12f14645a71eea2fefe3db9130fd438e46751fc54ad454dbce651310d6ad183
|
7
|
+
data.tar.gz: ff1a02a8a2fcdfe710bae3e0f550364567ca31d9d057d127c10502a4ca11be3507b553890958674b54c6dcee878e8901d283ab325b7c5354d3853279b7d524e2
|
data/README.md
CHANGED
@@ -58,6 +58,32 @@ shell "whoami"
|
|
58
58
|
|
59
59
|
![screenshot](screenshots/Bildschirmfoto 2016-11-24 um 18.15.47.png)
|
60
60
|
|
61
|
+
### Logging variables
|
62
|
+
|
63
|
+
```ruby
|
64
|
+
# ~/some_ruby_script.rb
|
65
|
+
require 'fiedl/log'
|
66
|
+
|
67
|
+
foo = "bar"
|
68
|
+
log.variable foo, "foo"
|
69
|
+
|
70
|
+
options = {
|
71
|
+
foo: 'bar'
|
72
|
+
}
|
73
|
+
log.configuration options
|
74
|
+
```
|
75
|
+
|
76
|
+
### Other helpers
|
77
|
+
|
78
|
+
Ensure that a certain file is present before continuing: If the file is missing, the error is logged and the script is stopped.
|
79
|
+
|
80
|
+
```ruby
|
81
|
+
# ~/some_ruby_script.rb
|
82
|
+
require 'fiedl/log'
|
83
|
+
|
84
|
+
log.ensure_file "$HOME/.zshrc"
|
85
|
+
```
|
86
|
+
|
61
87
|
## Installation
|
62
88
|
|
63
89
|
Add this line to your application's Gemfile:
|
data/lib/fiedl/log.rb
CHANGED
data/lib/fiedl/log/log.rb
CHANGED
@@ -26,12 +26,21 @@ class Fiedl::Log::Log
|
|
26
26
|
def prompt(text)
|
27
27
|
self.write "$ " + text.bold
|
28
28
|
end
|
29
|
+
def variable(variable, variable_name)
|
30
|
+
self.write "#{variable_name.to_s.blue} = #{variable}"
|
31
|
+
end
|
32
|
+
def configuration(hash)
|
33
|
+
pp hash
|
34
|
+
end
|
29
35
|
def write(text)
|
36
|
+
self.p "#{text}\n"
|
37
|
+
end
|
38
|
+
def p(text)
|
30
39
|
@filter_out ||= []
|
31
40
|
@filter_out.each do |expression|
|
32
41
|
text = text.gsub(expression, "[...]")
|
33
42
|
end
|
34
|
-
print text
|
43
|
+
print text
|
35
44
|
end
|
36
45
|
def filter_out(expression)
|
37
46
|
@filter_out ||= []
|
@@ -58,4 +67,19 @@ class Fiedl::Log::Log
|
|
58
67
|
return output
|
59
68
|
end
|
60
69
|
|
70
|
+
# Ensure that a certain file is present.
|
71
|
+
#
|
72
|
+
def ensure_file(filename, options = {})
|
73
|
+
if File.exists?(filename)
|
74
|
+
log.success "File: #{filename}"
|
75
|
+
else
|
76
|
+
log.error "Something went wrong. File #{filename} is missing."
|
77
|
+
if options[:show_log]
|
78
|
+
log.section "Last log"
|
79
|
+
shell "tail -n 20 #{options[:show_log]}"
|
80
|
+
end
|
81
|
+
raise "File is missing."
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
61
85
|
end
|
data/lib/fiedl/log/version.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.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sebastian Fiedlschuster
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-12-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|