Skip to content

Commit af0f8ba

Browse files
committed
cosmetic fixes
1 parent fc783bc commit af0f8ba

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

lib/gnuplotrb/staff/settings.rb

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ module Settings
77
MIN_GNUPLOT_VERSION = 5.0
88

99
class << self
10+
DEFAULT_MAX_FIT_DELAY = 5
11+
DEFAULT_GNUPLOT_PATH = 'gnuplot'
1012
##
1113
# For heavy calculations max_fit_delay may be increased.
1214
attr_writer :max_fit_delay
@@ -18,15 +20,15 @@ class << self
1820
# this behaviour is considered as errorneus.
1921
# @return [Integer] seconds to wait for output
2022
def max_fit_delay
21-
@max_fit_delay ||= 5
23+
@max_fit_delay ||= DEFAULT_MAX_FIT_DELAY
2224
end
2325

2426
##
2527
# Get path that should be used to run gnuplot executable.
2628
# Default value: 'gnuplot'.
2729
# @return [String] path to gnuplot executable
2830
def gnuplot_path
29-
self.gnuplot_path = 'gnuplot' unless defined?(@gnuplot_path)
31+
self.gnuplot_path = DEFAULT_GNUPLOT_PATH unless defined?(@gnuplot_path)
3032
@gnuplot_path
3133
end
3234

@@ -72,8 +74,15 @@ def validate_version(path)
7274
.read
7375
.match(/gnuplot ([^ ]+)/)[1]
7476
.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+
)
7786
end
7887
end
7988
end

0 commit comments

Comments
 (0)