Class: Yawast::Utilities
- Inherits:
-
Object
- Object
- Yawast::Utilities
- Defined in:
- lib/util.rb
Class Method Summary collapse
- .diff_text(txt1, txt2) ⇒ Object
- .indent_text(msg) ⇒ Object
- .prompt(msg) ⇒ Object
- .puts_error(msg) ⇒ Object
- .puts_info(msg) ⇒ Object
- .puts_msg(type, msg) ⇒ Object
- .puts_raw(msg = '') ⇒ Object
- .puts_vuln(msg) ⇒ Object
- .puts_warn(msg) ⇒ Object
Class Method Details
.diff_text(txt1, txt2) ⇒ Object
53 54 55 |
# File 'lib/util.rb', line 53 def self.diff_text(txt1, txt2) indent_text(Diffy::Diff.new(txt1, txt2, {context: 1}).to_s(:color)) end |
.indent_text(msg) ⇒ Object
49 50 51 |
# File 'lib/util.rb', line 49 def self.indent_text(msg) msg.gsub!(/^/, "\t") end |
.prompt(msg) ⇒ Object
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/util.rb', line 38 def self.prompt(msg) puts puts msg print '> ' val = $stdin.gets.chomp.strip Yawast::Shared::Output.log_append_value 'prompt', msg, val val end |
.puts_error(msg) ⇒ Object
12 13 14 15 |
# File 'lib/util.rb', line 12 def self.puts_error(msg) puts_msg('[E]'.red, msg) Yawast::Shared::Output.log_append_value 'messages', 'error', msg end |
.puts_info(msg) ⇒ Object
27 28 29 30 |
# File 'lib/util.rb', line 27 def self.puts_info(msg) puts_msg('[I]'.green, msg) Yawast::Shared::Output.log_append_value 'messages', 'info', msg end |
.puts_msg(type, msg) ⇒ Object
8 9 10 |
# File 'lib/util.rb', line 8 def self.puts_msg(type, msg) puts "#{type} #{msg}" end |
.puts_raw(msg = '') ⇒ Object
32 33 34 35 36 |
# File 'lib/util.rb', line 32 def self.puts_raw(msg = '') puts msg Yawast::Shared::Output.log_append_value 'messages', 'raw', msg if msg != '' end |
.puts_vuln(msg) ⇒ Object
17 18 19 20 |
# File 'lib/util.rb', line 17 def self.puts_vuln(msg) puts_msg('[V]'.magenta, msg) Yawast::Shared::Output.log_append_value 'messages', 'vulnerability', msg end |
.puts_warn(msg) ⇒ Object
22 23 24 25 |
# File 'lib/util.rb', line 22 def self.puts_warn(msg) puts_msg('[W]'.yellow, msg) Yawast::Shared::Output.log_append_value 'messages', 'warning', msg end |