@@ -7,6 +7,8 @@ module Settings
7
7
MIN_GNUPLOT_VERSION = 5.0
8
8
9
9
class << self
10
+ DEFAULT_MAX_FIT_DELAY = 5
11
+ DEFAULT_GNUPLOT_PATH = 'gnuplot'
10
12
##
11
13
# For heavy calculations max_fit_delay may be increased.
12
14
attr_writer :max_fit_delay
@@ -18,15 +20,15 @@ class << self
18
20
# this behaviour is considered as errorneus.
19
21
# @return [Integer] seconds to wait for output
20
22
def max_fit_delay
21
- @max_fit_delay ||= 5
23
+ @max_fit_delay ||= DEFAULT_MAX_FIT_DELAY
22
24
end
23
25
24
26
##
25
27
# Get path that should be used to run gnuplot executable.
26
28
# Default value: 'gnuplot'.
27
29
# @return [String] path to gnuplot executable
28
30
def gnuplot_path
29
- self . gnuplot_path = 'gnuplot' unless defined? ( @gnuplot_path )
31
+ self . gnuplot_path = DEFAULT_GNUPLOT_PATH unless defined? ( @gnuplot_path )
30
32
@gnuplot_path
31
33
end
32
34
@@ -72,8 +74,15 @@ def validate_version(path)
72
74
. read
73
75
. match ( /gnuplot ([^ ]+)/ ) [ 1 ]
74
76
. to_f
75
- message = "Your Gnuplot version is #{ @version } , please update it to at least 5.0"
76
- fail ( ArgumentError , message ) if @version < MIN_GNUPLOT_VERSION
77
+ raise (
78
+ ArgumentError ,
79
+ "Your Gnuplot version is #{ @version } , please update it to at least 5.0"
80
+ ) if @version < MIN_GNUPLOT_VERSION
81
+ rescue Errno ::ENOENT
82
+ raise (
83
+ ArgumentError ,
84
+ "Can't find Gnuplot executable. Please make sure it's installed and added to PATH."
85
+ )
77
86
end
78
87
end
79
88
end
0 commit comments