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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0c5a56e0c4fc76b55797ff6d1cafaa5d013689ef
4
- data.tar.gz: e66f0a11e239932fbc3200df64f6685f6532fb01
3
+ metadata.gz: 9c288e07d37916e6352cb8d15b65e7ebf1134930
4
+ data.tar.gz: 8d0f3703fa32c7a8d2301905e959f3e97356f99f
5
5
  SHA512:
6
- metadata.gz: 38fcd880973d29deabcc6c16722287ba2d34cbee74636ad7cc696d818b0e76314b701a1296d8fcae6d0674854005023c0e49c86ea321e9ce65dd592be250fd7a
7
- data.tar.gz: 362f6ac6c8308408d95b262d4d5a18bba480c1b295ad090cd20c916ab5bcdb539c24bbb4d461134547bf74df33f0237c9158afaf79b277736d8963cb79618813
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:
@@ -1,6 +1,7 @@
1
1
  require "fiedl/log/version"
2
2
  require "fiedl/log/log"
3
3
  require "colored"
4
+ require "pp"
4
5
 
5
6
  STDOUT.sync = true
6
7
 
@@ -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 + "\n"
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
@@ -1,5 +1,5 @@
1
1
  module Fiedl
2
2
  module Log
3
- VERSION = "0.2.0"
3
+ VERSION = "0.3.0"
4
4
  end
5
5
  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.2.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-24 00:00:00.000000000 Z
11
+ date: 2016-12-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler