Module: Selective::Ruby::Core::Helper

Included in:
Controller, FileCorrelator
Defined in:
lib/selective/ruby/core/helper.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details



62
63
64
65
66
67
68
69
70
71
72
# File 'lib/selective/ruby/core/helper.rb', line 62

def self.banner
  $selective_banner_displayed = true
  "     ____       _           _   _\n    / ___|  ___| | ___  ___| |_(_)_   _____\n    \\\\___ \\\\ / _ \\\\ |/ _ \\\\/ __| __| \\\\ \\\\ / / _ \\\\\n     ___) |  __/ |  __/ (__| |_| |\\\\ V /  __/\n    |____/ \\\\___|_|\\\\___|\\\\___|\\\\__|_| \\\\_/ \\\\___|\n    ________________________________________\n  BANNER\nend\n"

Instance Method Details



58
59
60
# File 'lib/selective/ruby/core/helper.rb', line 58

def banner
  Helper.banner
end


47
48
49
50
51
52
# File 'lib/selective/ruby/core/helper.rb', line 47

def print_notice(message)
  puts_indented "    \#{banner unless $selective_banner_displayed}\n    \#{message}\n  TEXT\nend\n"


39
40
41
42
43
44
45
# File 'lib/selective/ruby/core/helper.rb', line 39

def print_warning(message)
  puts_indented "    \\e[33m\n    \#{message}\n    \\e[0m\n  TEXT\nend\n"

#puts_indented(text) ⇒ Object



54
55
56
# File 'lib/selective/ruby/core/helper.rb', line 54

def puts_indented(text)
  puts text.gsub(/^/, "  ")
end

#safe_filename(filename) ⇒ Object



5
6
7
8
9
10
# File 'lib/selective/ruby/core/helper.rb', line 5

def safe_filename(filename)
  filename
    .gsub(/[\/\\:*?"<>|\n\r]+/, '_')
    .gsub(/^\.+|\.+$/, '')
    .strip[0, 255]
end

#with_error_handling(include_header: true) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/selective/ruby/core/helper.rb', line 12

def with_error_handling(include_header: true)
  yield
rescue => e
  raise e if debug?
  header = "    An error occurred. Please rerun with --debug\n    and contact support at https://selective.ci/support\n  TEXT\n\n  unless $selective_banner_displayed\n    header = <<~TEXT\n      \#{banner}\n\n      \#{header}\n    TEXT\n  end\n\n  puts_indented <<~TEXT\n    \\e[31m\n    \#{header if include_header}\n    \#{e.message}\n    \\e[0m\n  TEXT\n\n  exit 1\nend\n"