fiedl-log 0.1.0 → 0.2.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: c4e782e673e205f0b33c45c64b4770f8f36c28ca
4
- data.tar.gz: fe5b2363a8969ae792ec64b76d00e8e96165dec6
3
+ metadata.gz: 0c5a56e0c4fc76b55797ff6d1cafaa5d013689ef
4
+ data.tar.gz: e66f0a11e239932fbc3200df64f6685f6532fb01
5
5
  SHA512:
6
- metadata.gz: f1f0777da381db3ad3620c3dab2c010a4e32642483cbd0d3262f7deacb5037bd4d0971fd437c99d8edaecb18674fbe46581991a0040b1aa8f6d516ab83c20840
7
- data.tar.gz: 650e7588e9dbe262dfee9b75518f5aa83920d3e329816448eee3832afc941aa6bf2d0e59e8fc87552560d7f376867217c4df59c3814a6a78f98a08b1e1664d89
6
+ metadata.gz: 38fcd880973d29deabcc6c16722287ba2d34cbee74636ad7cc696d818b0e76314b701a1296d8fcae6d0674854005023c0e49c86ea321e9ce65dd592be250fd7a
7
+ data.tar.gz: 362f6ac6c8308408d95b262d4d5a18bba480c1b295ad090cd20c916ab5bcdb539c24bbb4d461134547bf74df33f0237c9158afaf79b277736d8963cb79618813
data/README.md CHANGED
@@ -2,23 +2,6 @@
2
2
 
3
3
  Simple colored output helper for ruby scripts.
4
4
 
5
-
6
- ## Installation
7
-
8
- Add this line to your application's Gemfile:
9
-
10
- ```ruby
11
- gem 'fiedl-log'
12
- ```
13
-
14
- And then execute:
15
-
16
- $ bundle
17
-
18
- Or install it yourself as:
19
-
20
- $ gem install fiedl-log
21
-
22
5
  ## Usage
23
6
 
24
7
  ```ruby
@@ -38,6 +21,8 @@ log.error "This script does nothing, yet."
38
21
  raise "This script does nothing, yet, sorry!"
39
22
  ```
40
23
 
24
+ ![screenshot](screenshots/Bildschirmfoto 2016-11-24 um 18.14.49.png)
25
+
41
26
  ### Manually defining a log instance
42
27
 
43
28
  This gem defines `log` unless `log` is already defined. But, of course, you may manually instantiate it:
@@ -60,6 +45,34 @@ log.filter_out("my_secret_password")
60
45
 
61
46
  This will filter out any occurance of "my_secret_password" and replace it by "[...]" in the output.
62
47
 
48
+ ### Shell commands
49
+
50
+ Print a shell command, execute it and display the result:
51
+
52
+ ```ruby
53
+ # ~/some_ruby_script.rb
54
+ require 'fiedl/log'
55
+
56
+ shell "whoami"
57
+ ```
58
+
59
+ ![screenshot](screenshots/Bildschirmfoto 2016-11-24 um 18.15.47.png)
60
+
61
+ ## Installation
62
+
63
+ Add this line to your application's Gemfile:
64
+
65
+ ```ruby
66
+ gem 'fiedl-log'
67
+ ```
68
+
69
+ And then execute:
70
+
71
+ $ bundle
72
+
73
+ Or install it yourself as:
74
+
75
+ $ gem install fiedl-log
63
76
 
64
77
  ## Development
65
78
 
@@ -69,7 +82,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
69
82
 
70
83
  ## Contributing
71
84
 
72
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/fiedl-log.
85
+ Bug reports and pull requests are welcome on GitHub at https://github.com/fiedl/fiedl-log.
73
86
 
74
87
 
75
88
  ## License
data/fiedl-log.gemspec CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
17
17
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
18
  f.match(%r{^(test|spec|features)/})
19
19
  end
20
- spec.require_paths = ["lib"]
20
+ spec.require_paths = ["lib", "lib/fiedl/log"]
21
21
 
22
22
  spec.add_development_dependency "bundler", "~> 1.13"
23
23
  spec.add_development_dependency "rake", "~> 10.0"
data/lib/fiedl/log/log.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  class Fiedl::Log::Log
2
+
2
3
  def head(text)
3
4
  info ""
4
5
  info "==========================================================".blue
@@ -40,4 +41,21 @@ class Fiedl::Log::Log
40
41
  filter_out expression
41
42
  end
42
43
 
44
+ # Print commant, execute it and display result.
45
+ # See also: http://stackoverflow.com/a/10224650/2066546
46
+ #
47
+ def shell(command)
48
+ prompt command
49
+
50
+ output = ""
51
+ r, io = IO.pipe
52
+ fork do
53
+ system(command, out: io, err: :out)
54
+ end
55
+ io.close
56
+ r.each_char{|c| print c; output += c}
57
+
58
+ return output
59
+ end
60
+
43
61
  end
@@ -1,5 +1,5 @@
1
1
  module Fiedl
2
2
  module Log
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
data/lib/fiedl/log.rb CHANGED
@@ -9,4 +9,14 @@ module Fiedl
9
9
  end
10
10
  end
11
11
 
12
- log = Fiedl::Log::Log.new unless defined? log
12
+ unless defined? log
13
+ def log
14
+ @log ||= Fiedl::Log::Log.new
15
+ end
16
+ end
17
+
18
+ unless defined? shell
19
+ def shell(command)
20
+ log.shell command
21
+ end
22
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fiedl-log
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sebastian Fiedlschuster
@@ -86,6 +86,8 @@ files:
86
86
  - lib/fiedl/log.rb
87
87
  - lib/fiedl/log/log.rb
88
88
  - lib/fiedl/log/version.rb
89
+ - screenshots/Bildschirmfoto 2016-11-24 um 18.14.49.png
90
+ - screenshots/Bildschirmfoto 2016-11-24 um 18.15.47.png
89
91
  homepage: https://github.com/fiedl/fiedl-log
90
92
  licenses:
91
93
  - MIT
@@ -94,6 +96,7 @@ post_install_message:
94
96
  rdoc_options: []
95
97
  require_paths:
96
98
  - lib
99
+ - lib/fiedl/log
97
100
  required_ruby_version: !ruby/object:Gem::Requirement
98
101
  requirements:
99
102
  - - ">="