gnuplot 2.1 → 2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/gnuplot.rb +44 -8
- metadata +7 -4
data/lib/gnuplot.rb
CHANGED
@@ -7,6 +7,45 @@ require 'matrix'
|
|
7
7
|
|
8
8
|
module Gnuplot
|
9
9
|
|
10
|
+
# Trivial implementation of the which command that uses the PATH environment
|
11
|
+
# variable to attempt to find the given application. The application must
|
12
|
+
# be executable and reside in one of the directories in the PATH environment
|
13
|
+
# to be found. The first match that is found will be returned.
|
14
|
+
#
|
15
|
+
# bin [String] The name of the executable to search for.
|
16
|
+
#
|
17
|
+
# Return the full path to the first match or nil if no match is found.
|
18
|
+
#
|
19
|
+
def Gnuplot.which ( bin )
|
20
|
+
return bin if File::executable? bin
|
21
|
+
|
22
|
+
path = ENV['PATH'] # || ENV['WHAT_EVER_WINDOWS_PATH_VAR_IS']
|
23
|
+
path.split(File::PATH_SEPARATOR).each do |dir|
|
24
|
+
candidate = File::join dir, bin.strip
|
25
|
+
return candidate if File::executable? candidate
|
26
|
+
end
|
27
|
+
|
28
|
+
# This is an implementation that works when the which command is
|
29
|
+
# available.
|
30
|
+
#
|
31
|
+
# IO.popen("which #{bin}") { |io| return io.readline.chomp }
|
32
|
+
|
33
|
+
return nil
|
34
|
+
end
|
35
|
+
|
36
|
+
# Find the path to the gnuplot executable. The name of the executable can
|
37
|
+
# be specified using the RB_GNUPLOT environment variable but will default to
|
38
|
+
# the command 'gnuplot'.
|
39
|
+
#
|
40
|
+
# persist [bool] Add the persist flag to the gnuplot executable
|
41
|
+
#
|
42
|
+
# Return the path to the gnuplot executable or nil if one cannot be found.
|
43
|
+
def Gnuplot.gnuplot( persist = true )
|
44
|
+
cmd = which( ENV['RB_GNUPLOT'] || 'gnuplot' )
|
45
|
+
cmd += " -persist" if persist
|
46
|
+
cmd
|
47
|
+
end
|
48
|
+
|
10
49
|
# Open a gnuplot process that exists in the current PATH. If the persist
|
11
50
|
# flag is true then the -persist flag is added to the command line. The
|
12
51
|
# path to the gnuplot executable is determined using the 'which' command.
|
@@ -15,12 +54,9 @@ module Gnuplot
|
|
15
54
|
#
|
16
55
|
# <b>todo</b> Add a method to pass the gnuplot path to the function.
|
17
56
|
|
18
|
-
def Gnuplot.open(persist=true)
|
19
|
-
cmd =
|
20
|
-
IO
|
21
|
-
cmd += " -persist" if persist
|
22
|
-
|
23
|
-
IO::popen(cmd, "w") { |io| yield io }
|
57
|
+
def Gnuplot.open( persist=true )
|
58
|
+
cmd = Gnuplot.gnuplot( persist ) or raise 'gnuplot not found'
|
59
|
+
IO::popen( cmd, "w") { |io| yield io }
|
24
60
|
end
|
25
61
|
|
26
62
|
|
@@ -181,7 +217,7 @@ module Gnuplot
|
|
181
217
|
case @data
|
182
218
|
when nil then nil
|
183
219
|
when String then nil
|
184
|
-
else @data.
|
220
|
+
else @data.to_gsplot
|
185
221
|
end
|
186
222
|
end
|
187
223
|
|
@@ -192,7 +228,7 @@ class Array
|
|
192
228
|
def to_gplot
|
193
229
|
if ( self[0].kind_of? Array ) then
|
194
230
|
tmp = self[0].zip( *self[1..-1] )
|
195
|
-
tmp.collect { |a| a.join(" ") }.join("\n") + "\
|
231
|
+
tmp.collect { |a| a.join(" ") }.join("\n") + "\ne"
|
196
232
|
elsif ( self[0].kind_of? Numeric ) then
|
197
233
|
s = ""
|
198
234
|
self.length.times { |i| s << "#{self[i]}\n" }
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.8.
|
2
|
+
rubygems_version: 0.8.11
|
3
3
|
specification_version: 1
|
4
4
|
name: gnuplot
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: "2.
|
7
|
-
date:
|
6
|
+
version: "2.2"
|
7
|
+
date: 2005-11-14 00:00:00 -05:00
|
8
8
|
summary: Utility library to aid in interacting with gnuplot
|
9
9
|
require_paths:
|
10
10
|
- lib
|
11
|
-
author: Gordon James Miller
|
12
11
|
email: gmiller@bittwiddlers.com
|
13
12
|
homepage: http://rgplot.rubyforge.org
|
14
13
|
rubyforge_project: rgplot
|
@@ -25,6 +24,10 @@ required_ruby_version: !ruby/object:Gem::Version::Requirement
|
|
25
24
|
version: 0.0.0
|
26
25
|
version:
|
27
26
|
platform: ruby
|
27
|
+
signing_key:
|
28
|
+
cert_chain:
|
29
|
+
authors:
|
30
|
+
- Gordon James Miller
|
28
31
|
files:
|
29
32
|
- lib/gnuplot.rb
|
30
33
|
test_files: []
|