ctioga2 0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/COPYING +339 -0
- data/Changelog +6 -0
- data/bin/ctioga2 +26 -0
- data/lib/ctioga2/commands/arguments.rb +58 -0
- data/lib/ctioga2/commands/commands.rb +258 -0
- data/lib/ctioga2/commands/doc/doc.rb +118 -0
- data/lib/ctioga2/commands/doc/documentation-commands.rb +119 -0
- data/lib/ctioga2/commands/doc/help.rb +95 -0
- data/lib/ctioga2/commands/doc/html.rb +230 -0
- data/lib/ctioga2/commands/doc/introspection.rb +211 -0
- data/lib/ctioga2/commands/doc/man.rb +279 -0
- data/lib/ctioga2/commands/doc/markup.rb +359 -0
- data/lib/ctioga2/commands/general-commands.rb +119 -0
- data/lib/ctioga2/commands/general-types.rb +118 -0
- data/lib/ctioga2/commands/groups.rb +73 -0
- data/lib/ctioga2/commands/interpreter.rb +257 -0
- data/lib/ctioga2/commands/parsers/command-line.rb +187 -0
- data/lib/ctioga2/commands/parsers/file.rb +186 -0
- data/lib/ctioga2/commands/strings.rb +303 -0
- data/lib/ctioga2/commands/type.rb +100 -0
- data/lib/ctioga2/commands/variables.rb +101 -0
- data/lib/ctioga2/data/backends/backend.rb +260 -0
- data/lib/ctioga2/data/backends/backends.rb +39 -0
- data/lib/ctioga2/data/backends/backends/gnuplot.rb +140 -0
- data/lib/ctioga2/data/backends/backends/math.rb +121 -0
- data/lib/ctioga2/data/backends/backends/text.rb +335 -0
- data/lib/ctioga2/data/backends/description.rb +405 -0
- data/lib/ctioga2/data/backends/factory.rb +73 -0
- data/lib/ctioga2/data/backends/parameter.rb +109 -0
- data/lib/ctioga2/data/datacolumn.rb +245 -0
- data/lib/ctioga2/data/dataset.rb +233 -0
- data/lib/ctioga2/data/filters.rb +131 -0
- data/lib/ctioga2/data/merge.rb +43 -0
- data/lib/ctioga2/data/point.rb +72 -0
- data/lib/ctioga2/data/stack.rb +294 -0
- data/lib/ctioga2/graphics/coordinates.rb +73 -0
- data/lib/ctioga2/graphics/elements.rb +111 -0
- data/lib/ctioga2/graphics/elements/containers.rb +111 -0
- data/lib/ctioga2/graphics/elements/curve2d.rb +155 -0
- data/lib/ctioga2/graphics/elements/element.rb +90 -0
- data/lib/ctioga2/graphics/elements/primitive.rb +256 -0
- data/lib/ctioga2/graphics/elements/subplot.rb +140 -0
- data/lib/ctioga2/graphics/generator.rb +68 -0
- data/lib/ctioga2/graphics/legends.rb +108 -0
- data/lib/ctioga2/graphics/legends/area.rb +199 -0
- data/lib/ctioga2/graphics/legends/items.rb +183 -0
- data/lib/ctioga2/graphics/legends/provider.rb +58 -0
- data/lib/ctioga2/graphics/legends/storage.rb +65 -0
- data/lib/ctioga2/graphics/root.rb +209 -0
- data/lib/ctioga2/graphics/styles.rb +30 -0
- data/lib/ctioga2/graphics/styles/axes.rb +247 -0
- data/lib/ctioga2/graphics/styles/background.rb +122 -0
- data/lib/ctioga2/graphics/styles/base.rb +115 -0
- data/lib/ctioga2/graphics/styles/carrays.rb +53 -0
- data/lib/ctioga2/graphics/styles/curve.rb +101 -0
- data/lib/ctioga2/graphics/styles/drawable.rb +87 -0
- data/lib/ctioga2/graphics/styles/factory.rb +351 -0
- data/lib/ctioga2/graphics/styles/legend.rb +63 -0
- data/lib/ctioga2/graphics/styles/plot.rb +410 -0
- data/lib/ctioga2/graphics/styles/sets.rb +64 -0
- data/lib/ctioga2/graphics/styles/texts.rb +277 -0
- data/lib/ctioga2/graphics/subplot-commands.rb +141 -0
- data/lib/ctioga2/graphics/types.rb +188 -0
- data/lib/ctioga2/graphics/types/bijection.rb +79 -0
- data/lib/ctioga2/graphics/types/boundaries.rb +170 -0
- data/lib/ctioga2/graphics/types/boxes.rb +157 -0
- data/lib/ctioga2/graphics/types/dimensions.rb +157 -0
- data/lib/ctioga2/graphics/types/point.rb +247 -0
- data/lib/ctioga2/log.rb +97 -0
- data/lib/ctioga2/metabuilder/type.rb +316 -0
- data/lib/ctioga2/metabuilder/types.rb +39 -0
- data/lib/ctioga2/metabuilder/types/coordinates.rb +124 -0
- data/lib/ctioga2/metabuilder/types/dates.rb +43 -0
- data/lib/ctioga2/metabuilder/types/lists.rb +188 -0
- data/lib/ctioga2/metabuilder/types/numbers.rb +97 -0
- data/lib/ctioga2/metabuilder/types/strings.rb +93 -0
- data/lib/ctioga2/metabuilder/types/styles.rb +178 -0
- data/lib/ctioga2/plotmaker.rb +677 -0
- data/lib/ctioga2/postprocess.rb +115 -0
- data/lib/ctioga2/utils.rb +120 -0
- data/setup.rb +1586 -0
- metadata +144 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# general-types.rb: various useful command types
|
|
2
|
+
# copyright (c) 2009 by Vincent Fourmond
|
|
3
|
+
|
|
4
|
+
# This program is free software; you can redistribute it and/or modify
|
|
5
|
+
# it under the terms of the GNU General Public License as published by
|
|
6
|
+
# the Free Software Foundation; either version 2 of the License, or
|
|
7
|
+
# (at your option) any later version.
|
|
8
|
+
|
|
9
|
+
# This program is distributed in the hope that it will be useful,
|
|
10
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
# GNU General Public License for more details (in the COPYING file).
|
|
13
|
+
|
|
14
|
+
require 'ctioga2/utils'
|
|
15
|
+
|
|
16
|
+
module CTioga2
|
|
17
|
+
|
|
18
|
+
Version::register_svn_info('$Revision: 101 $', '$Date: 2009-07-21 23:29:59 +0200 (Tue, 21 Jul 2009) $')
|
|
19
|
+
|
|
20
|
+
module Commands
|
|
21
|
+
|
|
22
|
+
# A file name.
|
|
23
|
+
FileType = CmdType.new('file', :string, <<EOD)
|
|
24
|
+
A file name.
|
|
25
|
+
EOD
|
|
26
|
+
|
|
27
|
+
# Plain text
|
|
28
|
+
TextType = CmdType.new('text', :string, <<EOD)
|
|
29
|
+
Plain text.
|
|
30
|
+
EOD
|
|
31
|
+
|
|
32
|
+
# A series of datasets
|
|
33
|
+
DatasetType = CmdType.new('dataset', :string, <<EOD)
|
|
34
|
+
One expandable dataset.
|
|
35
|
+
EOD
|
|
36
|
+
|
|
37
|
+
# Commands
|
|
38
|
+
CommandsType = CmdType.new('commands', :string, <<EOD)
|
|
39
|
+
ctioga2 commands, such as the ones that could be found in
|
|
40
|
+
command files.
|
|
41
|
+
EOD
|
|
42
|
+
|
|
43
|
+
BooleanType = CmdType.new('boolean', :boolean, <<EOD)
|
|
44
|
+
Yes or no.
|
|
45
|
+
EOD
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
FloatType = CmdType.new('float', :float, <<EOD)
|
|
50
|
+
A floating-point number.
|
|
51
|
+
EOD
|
|
52
|
+
|
|
53
|
+
IntegerType = CmdType.new('integer', :integer, <<EOD)
|
|
54
|
+
An integer.
|
|
55
|
+
EOD
|
|
56
|
+
|
|
57
|
+
PartialFloatRangeType = CmdType.new('partial-float-range',
|
|
58
|
+
:partial_float_range, <<EOD)
|
|
59
|
+
A beginning:end range, where either of the endpoints can be ommitted.
|
|
60
|
+
EOD
|
|
61
|
+
|
|
62
|
+
FloatRangeType = CmdType.new('float-range',
|
|
63
|
+
:float_range, <<EOD)
|
|
64
|
+
A beginning:end range.
|
|
65
|
+
EOD
|
|
66
|
+
|
|
67
|
+
StringOrRegexp = CmdType.new('regexp',
|
|
68
|
+
:string_or_regexp, <<EOD)
|
|
69
|
+
A plain string or a regular expression (the latter being enclosed
|
|
70
|
+
within /.../).
|
|
71
|
+
EOD
|
|
72
|
+
|
|
73
|
+
# Data-point. Unlike other types, this one needs to be processed
|
|
74
|
+
# afterwards, actually, since an access to a plotmaker object is
|
|
75
|
+
# necessary.
|
|
76
|
+
DataPointType = CmdType.new('data-point', :string, <<EOD)
|
|
77
|
+
A point from a Dataset.
|
|
78
|
+
|
|
79
|
+
TODO: document ;-)...
|
|
80
|
+
EOD
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
# This ones get here since they mess up with syntax highlighting
|
|
85
|
+
|
|
86
|
+
# A stored dataset.
|
|
87
|
+
StoredDatasetType = CmdType.new('stored-dataset',
|
|
88
|
+
:string, <<EOD)
|
|
89
|
+
A dataset that has already been loaded. It is either:
|
|
90
|
+
* A number, in which case it specifies the index inside the stack. 0
|
|
91
|
+
is the first on that was pushed onto the stack (the oldest
|
|
92
|
+
dataset), 1 the second, -1 the last one, -2 the one before the last
|
|
93
|
+
and so on. (it works just like Ruby's arrays).
|
|
94
|
+
* The name of a named dataset.
|
|
95
|
+
EOD
|
|
96
|
+
|
|
97
|
+
# Something meant to be fed to PlotStyle#get_axis_style
|
|
98
|
+
AxisType = CmdType.new('axis', :string, <<EOD)
|
|
99
|
+
The name of an axis. It can be:
|
|
100
|
+
* left, top, bottom or right;
|
|
101
|
+
* x, xaxis, y, yaxis, which return one of the above depending
|
|
102
|
+
on the preferences of the current plot;
|
|
103
|
+
* one of the named axes.
|
|
104
|
+
EOD
|
|
105
|
+
|
|
106
|
+
# Something meant to be fed to PlotStyle#get_label_style
|
|
107
|
+
LabelType = CmdType.new('label', :string, <<EOD)
|
|
108
|
+
The name of an label. It can be:
|
|
109
|
+
* title to mean the current plot's title.
|
|
110
|
+
* axis_tick or axis_ticks or simply axis, where axis is a a valid
|
|
111
|
+
{type: axis}. It means the ticks of the given axis.
|
|
112
|
+
* axis_label, same as above but targets the label of the given axis.
|
|
113
|
+
EOD
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# groups.rb: a group of commands
|
|
2
|
+
# copyright (c) 2009 by Vincent Fourmond
|
|
3
|
+
|
|
4
|
+
# This program is free software; you can redistribute it and/or modify
|
|
5
|
+
# it under the terms of the GNU General Public License as published by
|
|
6
|
+
# the Free Software Foundation; either version 2 of the License, or
|
|
7
|
+
# (at your option) any later version.
|
|
8
|
+
|
|
9
|
+
# This program is distributed in the hope that it will be useful,
|
|
10
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
# GNU General Public License for more details (in the COPYING file).
|
|
13
|
+
|
|
14
|
+
require 'ctioga2/utils'
|
|
15
|
+
require 'ctioga2/metabuilder/types'
|
|
16
|
+
|
|
17
|
+
module CTioga2
|
|
18
|
+
|
|
19
|
+
Version::register_svn_info('$Revision: 14 $', '$Date: 2009-04-27 21:49:16 +0200 (Mon, 27 Apr 2009) $')
|
|
20
|
+
|
|
21
|
+
module Commands
|
|
22
|
+
|
|
23
|
+
# A group of commands, organized along a same theme.
|
|
24
|
+
class CommandGroup
|
|
25
|
+
|
|
26
|
+
# The commands belonging to the group
|
|
27
|
+
attr_accessor :commands
|
|
28
|
+
|
|
29
|
+
# The name of the group
|
|
30
|
+
attr_accessor :name
|
|
31
|
+
|
|
32
|
+
# A short, unique, codelike name for the group.
|
|
33
|
+
attr_accessor :id
|
|
34
|
+
|
|
35
|
+
# A (longer) description of the group
|
|
36
|
+
attr_accessor :description
|
|
37
|
+
|
|
38
|
+
# The priority of the group. It influences the positioning of
|
|
39
|
+
# its command-line options in the --help display. Lower
|
|
40
|
+
# priorities come first.
|
|
41
|
+
attr_accessor :priority
|
|
42
|
+
|
|
43
|
+
# Whether the group is blacklisted or not, ie whether the group's
|
|
44
|
+
# help text will be displayed at all.
|
|
45
|
+
attr_accessor :blacklisted
|
|
46
|
+
|
|
47
|
+
# The context of definition [file, line]
|
|
48
|
+
attr_accessor :context
|
|
49
|
+
|
|
50
|
+
def initialize(id, name, desc = nil, priority = 0, blacklist = false,
|
|
51
|
+
register = true)
|
|
52
|
+
@commands = []
|
|
53
|
+
@name = name
|
|
54
|
+
@id = id
|
|
55
|
+
@description = desc || name
|
|
56
|
+
@priority = priority
|
|
57
|
+
@blacklisted = blacklist
|
|
58
|
+
|
|
59
|
+
if register
|
|
60
|
+
Interpreter.register_group(self)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# The context in which the group was defined
|
|
64
|
+
caller[1].gsub(/.*\/ctioga2\//, 'lib/ctioga2/') =~ /(.*):(\d+)/
|
|
65
|
+
@context = [$1, $2.to_i]
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
end
|
|
73
|
+
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
# interpreter.rb: the interpreter of commands
|
|
2
|
+
# copyright (c) 2009 by Vincent Fourmond
|
|
3
|
+
|
|
4
|
+
# This program is free software; you can redistribute it and/or modify
|
|
5
|
+
# it under the terms of the GNU General Public License as published by
|
|
6
|
+
# the Free Software Foundation; either version 2 of the License, or
|
|
7
|
+
# (at your option) any later version.
|
|
8
|
+
|
|
9
|
+
# This program is distributed in the hope that it will be useful,
|
|
10
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
# GNU General Public License for more details (in the COPYING file).
|
|
13
|
+
|
|
14
|
+
require 'ctioga2/utils'
|
|
15
|
+
require 'ctioga2/commands/commands'
|
|
16
|
+
require 'ctioga2/commands/variables'
|
|
17
|
+
require 'ctioga2/commands/strings'
|
|
18
|
+
require 'ctioga2/commands/parsers/command-line'
|
|
19
|
+
require 'ctioga2/commands/doc/doc'
|
|
20
|
+
|
|
21
|
+
module CTioga2
|
|
22
|
+
|
|
23
|
+
Version::register_svn_info('$Revision: 18 $', '$Date: 2009-04-28 23:43:54 +0200 (Tue, 28 Apr 2009) $')
|
|
24
|
+
|
|
25
|
+
# This module contains the real core of ctioga2: a set of classes
|
|
26
|
+
# that implement the concept of commands. Each command translates
|
|
27
|
+
# into an action (of any kind).
|
|
28
|
+
#
|
|
29
|
+
# Commands can be specified using several ways: either using command-line
|
|
30
|
+
# options/arguments or through a commands file.
|
|
31
|
+
module Commands
|
|
32
|
+
|
|
33
|
+
# An exception raised when a command is defined twice
|
|
34
|
+
class DoubleDefinition < Exception
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# An exception raised when a command is not known to the interpreter
|
|
38
|
+
class UnknownCommand < Exception
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# An exception raised upon invalid names.
|
|
42
|
+
class InvalidName < Exception
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# An exception raised when a CommandType is not known
|
|
46
|
+
class InvalidType < Exception
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# A CommandGroup#id or Command#name should match this regular
|
|
50
|
+
# expression.
|
|
51
|
+
NameValidationRE = /^[a-z0-9-]+$/
|
|
52
|
+
|
|
53
|
+
# The core class interpreting all the commands and executing them.
|
|
54
|
+
# It holds a hash class variable containing all the Command
|
|
55
|
+
# objects defined so far.
|
|
56
|
+
class Interpreter
|
|
57
|
+
|
|
58
|
+
# All commands defined so far.
|
|
59
|
+
@@commands = {}
|
|
60
|
+
|
|
61
|
+
# All command groups defined so far.
|
|
62
|
+
@@groups = {}
|
|
63
|
+
|
|
64
|
+
# All types defined so fat
|
|
65
|
+
@@types = {}
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
# Registers a given command. This is called automatically from
|
|
70
|
+
# Command.new, so you should not have to do it yourself.
|
|
71
|
+
def self.register_command(command)
|
|
72
|
+
if self.command(command.name)
|
|
73
|
+
raise DoubleDefinition, "Command '#{command.name}' already defined"
|
|
74
|
+
else
|
|
75
|
+
if command.name =~ NameValidationRE
|
|
76
|
+
@@commands[command.name] = command
|
|
77
|
+
else
|
|
78
|
+
raise InvalidName, "Name '#{command.name}' is invalid"
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
# Registers a given group. This is called automatically from
|
|
84
|
+
# CommandGroup.new, so you should not have to do it yourself.
|
|
85
|
+
def self.register_group(group)
|
|
86
|
+
if self.group(group.id)
|
|
87
|
+
raise DoubleDefinition, "Group '#{group.id}' already defined"
|
|
88
|
+
else
|
|
89
|
+
if group.id =~ NameValidationRE
|
|
90
|
+
@@groups[group.id] = group
|
|
91
|
+
else
|
|
92
|
+
raise InvalidName, "Name '#{group.id}' is invalid"
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
# Registers a given type. This is called automatically from
|
|
98
|
+
# CommandType.new, so you should not have to do it yourself.
|
|
99
|
+
def self.register_type(type)
|
|
100
|
+
if self.type(type.name)
|
|
101
|
+
raise DoubleDefinition, "Type '#{type.name}' already defined"
|
|
102
|
+
else
|
|
103
|
+
if type.name =~ NameValidationRE
|
|
104
|
+
@@types[type.name] = type
|
|
105
|
+
else
|
|
106
|
+
raise InvalidName, "Name '#{type.name}' is invalid"
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
# Returns the named CommandType
|
|
113
|
+
def self.type(name)
|
|
114
|
+
return @@types[name]
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
# Returns all registered CommandType objects
|
|
118
|
+
def self.types
|
|
119
|
+
return @@types
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
# Deletes a command whose name is given
|
|
123
|
+
def self.delete_command(cmd)
|
|
124
|
+
@@commands.delete(cmd)
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
# Returns the command given by its name _cmd_, or nil if none was found.
|
|
128
|
+
def self.command(cmd)
|
|
129
|
+
return @@commands[cmd]
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
# Returns the groups given by its _id_, or nil if none was found.
|
|
133
|
+
def self.group(id)
|
|
134
|
+
return @@groups[id]
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
# Returns the commands hash
|
|
138
|
+
def self.commands
|
|
139
|
+
return @@commands
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
# Returns the groups hash
|
|
143
|
+
def self.groups
|
|
144
|
+
return @@groups
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
# A Variables object holding the ... variables ! (I'm sure you
|
|
148
|
+
# guessed it !)
|
|
149
|
+
attr_accessor :variables
|
|
150
|
+
|
|
151
|
+
# The PlotMaker object that will receive the commands of the
|
|
152
|
+
# Interpreter.
|
|
153
|
+
attr_accessor :plotmaker_target
|
|
154
|
+
|
|
155
|
+
# The Parsers::CommandLineParser object used to... parse the command-line.
|
|
156
|
+
# (surprising, isn't it ??)
|
|
157
|
+
attr_reader :command_line_parser
|
|
158
|
+
|
|
159
|
+
# The Documentation::Doc object that can interact with documentation
|
|
160
|
+
attr_reader :doc
|
|
161
|
+
|
|
162
|
+
# The Parsers::FileParser object used to... parse files ?
|
|
163
|
+
attr_reader :file_parser
|
|
164
|
+
|
|
165
|
+
# Creates an Interpreter with _target_ as the PlotMaker target
|
|
166
|
+
# object.
|
|
167
|
+
#
|
|
168
|
+
# As far as command-line and help is concerned, it takes a
|
|
169
|
+
# snapshot of the current commands known to the system, so
|
|
170
|
+
# please instantiate it last.
|
|
171
|
+
#
|
|
172
|
+
# TODO: probably this behavior is not really desired.
|
|
173
|
+
# Easy to fix.
|
|
174
|
+
def initialize(target)
|
|
175
|
+
@plotmaker_target = target
|
|
176
|
+
@command_line_parser =
|
|
177
|
+
Parsers::CommandLineParser.new(@@commands.values,
|
|
178
|
+
CTioga2::PlotMaker::PlotCommand)
|
|
179
|
+
|
|
180
|
+
@doc = Documentation::Doc.new()
|
|
181
|
+
@variables = Variables.new
|
|
182
|
+
|
|
183
|
+
@file_parser = Parsers::FileParser.new
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
# Parses and run the given command-line, sending the commands to
|
|
188
|
+
# the #plotmaker_target.
|
|
189
|
+
def run_command_line(args)
|
|
190
|
+
@command_line_parser.parse_command_line(args, self) do |arg|
|
|
191
|
+
puts "Non-optional argument: #{arg.first}"
|
|
192
|
+
end
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
# Parses and runs the given file. Sets PlotMaker#figure_name to
|
|
196
|
+
# the base name of the given file if no figure name was
|
|
197
|
+
# specified.
|
|
198
|
+
def run_command_file(file)
|
|
199
|
+
@file_parser.run_command_file(file, self)
|
|
200
|
+
if ! @plotmaker_target.figure_name
|
|
201
|
+
@plotmaker_target.figure_name = file.gsub(/\.[^.]+$/,'')
|
|
202
|
+
end
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
# Parses and runs the given string.
|
|
206
|
+
def run_commands(string)
|
|
207
|
+
@file_parser.run_commands(string, self)
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
# Returns a Command object corresponding to the given _symbol_, or
|
|
211
|
+
# raises an UnknownCommand exception.
|
|
212
|
+
def get_command(symbol)
|
|
213
|
+
if @@commands.key? symbol
|
|
214
|
+
return @@commands[symbol]
|
|
215
|
+
else
|
|
216
|
+
raise UnknownCommand, "Unknown command: #{symbol}"
|
|
217
|
+
end
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
# Returns the list of all know command names
|
|
221
|
+
def command_names
|
|
222
|
+
return @@commands.keys
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
# Runs _command_ with the given _arguments_ and _options_,
|
|
226
|
+
# converting them as necessary. All the commands ran from this
|
|
227
|
+
# interpreter should be ran from here.
|
|
228
|
+
#
|
|
229
|
+
# _command_ can be either a String or a Command
|
|
230
|
+
#
|
|
231
|
+
# Later, it could be a good idea to add a spying mechanism here.
|
|
232
|
+
def run_command(command, arguments, options = nil)
|
|
233
|
+
converted_args = command.convert_arguments(arguments)
|
|
234
|
+
if options
|
|
235
|
+
converted_options = command.convert_options(options)
|
|
236
|
+
else
|
|
237
|
+
converted_options = nil
|
|
238
|
+
end
|
|
239
|
+
command.run_command(@plotmaker_target, converted_args,
|
|
240
|
+
converted_options)
|
|
241
|
+
end
|
|
242
|
+
end
|
|
243
|
+
end
|
|
244
|
+
|
|
245
|
+
# An alias for Commands::Command
|
|
246
|
+
Cmd = Commands::Command
|
|
247
|
+
|
|
248
|
+
# An alias for Commands::CommandArgument
|
|
249
|
+
CmdArg = Commands::CommandArgument
|
|
250
|
+
|
|
251
|
+
# An alias for Commands::CommandGroup
|
|
252
|
+
CmdGroup = Commands::CommandGroup
|
|
253
|
+
|
|
254
|
+
# An alias for Commands::CommandType
|
|
255
|
+
CmdType = Commands::CommandType
|
|
256
|
+
end
|
|
257
|
+
|