Module: Xnlogic
- Defined in:
- lib/xnlogic.rb,
lib/xnlogic/ui.rb,
lib/xnlogic/cli.rb,
lib/xnlogic/version.rb,
lib/xnlogic/ui/shell.rb,
lib/xnlogic/ui/silent.rb,
lib/xnlogic/cli/application.rb,
lib/xnlogic/friendly_errors.rb
Defined Under Namespace
Modules: UI
Classes: CLI, InvalidOption, XnlogicError
Constant Summary
collapse
- VERSION =
"1.0.11"
Class Attribute Summary collapse
Class Method Summary
collapse
Class Attribute Details
.ui ⇒ Object
18
19
20
|
# File 'lib/xnlogic.rb', line 18
def ui
@ui ||= UI::Silent.new
end
|
Class Method Details
.which(executable) ⇒ Object
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/xnlogic.rb', line 22
def which(executable)
if File.file?(executable) && File.executable?(executable)
executable
elsif ENV['PATH']
path = ENV['PATH'].split(File::PATH_SEPARATOR).find do |p|
File.executable?(File.join(p, executable))
end
path && File.expand_path(executable, path)
end
end
|
.with_friendly_errors ⇒ Object
11
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
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/xnlogic/friendly_errors.rb', line 11
def self.with_friendly_errors
yield
rescue Xnlogic::XnlogicError => e
Xnlogic.ui.error e.message, :wrap => true
Xnlogic.ui.trace e
exit e.status_code
rescue Thor::AmbiguousTaskError => e
Xnlogic.ui.error e.message
exit 15
rescue Thor::UndefinedTaskError => e
Xnlogic.ui.error e.message
exit 15
rescue Thor::Error => e
Xnlogic.ui.error e.message
exit 1
rescue LoadError => e
raise e unless e.message =~ /cannot load such file -- openssl|openssl.so|libcrypto.so/
Xnlogic.ui.error "\nCould not load OpenSSL."
Xnlogic.ui.warn <<-WARN, :wrap => true
You must recompile Ruby with OpenSSL support or change the sources in your \
Gemfile from 'https' to 'http'. Instructions for compiling with OpenSSL \
using RVM are available at http://rvm.io/packages/openssl.
WARN
Xnlogic.ui.trace e
exit 1
rescue Interrupt => e
Xnlogic.ui.error "\nQuitting..."
Xnlogic.ui.trace e
exit 1
rescue SystemExit => e
exit e.status
rescue Exception => e
Xnlogic.ui.error <<-ERR, :wrap => true
Unfortunately, a fatal error has occurred. Please see the XN Logic \
ZenDesk support pages: https://xnlogic.zendesk.com/hc/en-us
ERR
raise e
end
|