livetext 0.9.46 → 0.9.47
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/livetext/errors.rb +3 -3
- data/lib/livetext/expansion.rb +1 -1
- data/lib/livetext/formatter.rb +11 -12
- data/lib/livetext/functions.rb +1 -1
- data/lib/livetext/handler/import.rb +1 -1
- data/lib/livetext/handler/mixin.rb +1 -1
- data/lib/livetext/helpers.rb +2 -10
- data/lib/livetext/html.rb +2 -35
- data/lib/livetext/more.rb +3 -5
- data/lib/livetext/parser/general.rb +1 -1
- data/lib/livetext/parser/set.rb +1 -1
- data/lib/livetext/parser/string.rb +1 -1
- data/lib/livetext/paths.rb +1 -1
- data/lib/livetext/processor.rb +1 -3
- data/lib/livetext/standard.rb +3 -3
- data/lib/livetext/userapi.rb +3 -5
- data/lib/livetext/version.rb +1 -1
- data/lib/livetext.rb +2 -2
- data/test/snapshots/table_with_heredocs/expected-output.txt +12 -4
- data/test/snapshots/table_with_heredocs/old-exp-out.txt +15 -0
- data/test/snapshots.rb +1 -1
- metadata +3 -3
- data/lib/cmdargs.rb +0 -106
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c1f67c2785b935c3c940db118d04f6613e186df48b4473659e14c69089e23a35
|
4
|
+
data.tar.gz: 6b08485471ca1c9aa2d44a83d9e5670f876999e70f3c20e975caa8fb3aadc2ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1becbb55d5267f754ee0c3dacc3c894fc6814aefd71386aaf0bc3f77f4dbefe76554d42ca78ade718e027b96874616219582dfcb0a4295eae10aac12bff11481
|
7
|
+
data.tar.gz: f169d21ca5e99b17869e10836fe4b4ae39cc5a239408562d95a3928e89b954f42184b2b51c8603e9d7570f3578acd81761417c56be7217942c7f4a8624089e8c
|
data/lib/livetext/errors.rb
CHANGED
@@ -10,16 +10,19 @@
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def checkpoint(msg = nil)
|
13
|
+
return unless ENV['LIVETEXT_DEBUG'] == "true"
|
13
14
|
file, line, meth = whence(1)
|
14
15
|
display(file, line, meth, msg)
|
15
16
|
end
|
16
17
|
|
17
18
|
def checkpoint?(msg = nil) # with sleep 3
|
19
|
+
return unless ENV['LIVETEXT_DEBUG'] == "true"
|
18
20
|
file, line, meth = whence(1)
|
19
21
|
display(file, line, meth, msg)
|
20
22
|
end
|
21
23
|
|
22
24
|
def checkpoint!(msg = nil) # with pause
|
25
|
+
return unless ENV['LIVETEXT_DEBUG'] == "true"
|
23
26
|
file, line, meth = whence(1)
|
24
27
|
display(file, line, meth, msg)
|
25
28
|
print "::: Pause..."
|
@@ -71,6 +74,3 @@ make_exception(:ExpectedDotEnd, "Error: expected .end but found end of file")
|
|
71
74
|
make_exception(:ExpectedAlphaNum, "Error: expected an alphanumeric but foun '%1'") # parser/set.rb
|
72
75
|
make_exception(:ExpectedCommaEOS, "Error: expected comma or end of string") # parser/set.rb
|
73
76
|
|
74
|
-
|
75
|
-
|
76
|
-
|
data/lib/livetext/expansion.rb
CHANGED
data/lib/livetext/formatter.rb
CHANGED
@@ -1,14 +1,6 @@
|
|
1
1
|
module Formatter
|
2
2
|
|
3
|
-
|
4
|
-
#
|
5
|
-
# Double: b, i, t, s
|
6
|
-
# Single: bits
|
7
|
-
# Brackt: bits
|
8
|
-
#
|
9
|
-
|
10
|
-
|
11
|
-
def self.format(str)
|
3
|
+
def self.format(str) # FIXME - unneeded?
|
12
4
|
str = str.chomp
|
13
5
|
s2 = Double.process(str.chomp)
|
14
6
|
s3 = Bracketed.process(s2)
|
@@ -16,8 +8,15 @@ module Formatter
|
|
16
8
|
s4
|
17
9
|
end
|
18
10
|
|
11
|
+
## Hmmm...
|
12
|
+
#
|
13
|
+
# Double: b, i, t, s
|
14
|
+
# Single: bits
|
15
|
+
# Brackt: bits
|
16
|
+
#
|
17
|
+
|
19
18
|
class Delimited
|
20
|
-
def initialize(str, marker, tag)
|
19
|
+
def initialize(str, marker, tag) # Delimited
|
21
20
|
@str, @marker, @tag = str.dup, marker, tag
|
22
21
|
@buffer = ""
|
23
22
|
@cdata = ""
|
@@ -170,7 +169,7 @@ module Formatter
|
|
170
169
|
end
|
171
170
|
|
172
171
|
class Double < Delimited
|
173
|
-
def initialize(str, sigil, tag)
|
172
|
+
def initialize(str, sigil, tag) # Double
|
174
173
|
super
|
175
174
|
# Convention: marker is "**", sigil is "*"
|
176
175
|
@marker = sigil + sigil
|
@@ -183,7 +182,7 @@ module Formatter
|
|
183
182
|
end
|
184
183
|
|
185
184
|
class Bracketed < Delimited
|
186
|
-
def initialize(str, sigil, tag)
|
185
|
+
def initialize(str, sigil, tag) # Bracketed
|
187
186
|
super
|
188
187
|
# Convention: marker is "*[", sigil is "*"
|
189
188
|
@marker = sigil + "["
|
data/lib/livetext/functions.rb
CHANGED
@@ -9,7 +9,7 @@ class Livetext::Handler::Mixin
|
|
9
9
|
|
10
10
|
attr_reader :file
|
11
11
|
|
12
|
-
def initialize(name, parent)
|
12
|
+
def initialize(name, parent) # Livetext::Handler::Mixin
|
13
13
|
@name = name
|
14
14
|
@file = find_file(name, ".rb", "plugin")
|
15
15
|
parent.graceful_error FileNotFound(name) if @file.nil?
|
data/lib/livetext/helpers.rb
CHANGED
@@ -2,9 +2,7 @@
|
|
2
2
|
require_relative 'global_helpers'
|
3
3
|
require_relative 'expansion'
|
4
4
|
|
5
|
-
|
6
5
|
module Livetext::Helpers
|
7
|
-
|
8
6
|
Space = " "
|
9
7
|
Sigil = "." # Can't change yet
|
10
8
|
|
@@ -75,6 +73,7 @@ module Livetext::Helpers
|
|
75
73
|
## FIXME process_file[!] should call process[_text] ?
|
76
74
|
|
77
75
|
def process_file(fname, btrace=false)
|
76
|
+
checkpoint "fname = #{fname.inspect}"
|
78
77
|
unless File.exist?(fname)
|
79
78
|
api.dump
|
80
79
|
raise FileNotFound(fname)
|
@@ -127,6 +126,7 @@ module Livetext::Helpers
|
|
127
126
|
api.data = data0.dup # should permit _ in function names at least
|
128
127
|
args0 = data0.split
|
129
128
|
api.args = args0.dup
|
129
|
+
checkpoint "name = #{name} args = #{args0.inspect}"
|
130
130
|
retval = @main.send(name) # , *args) # was 125
|
131
131
|
retval
|
132
132
|
rescue => err
|
@@ -258,14 +258,6 @@ module Livetext::Helpers
|
|
258
258
|
api.setvar(:File, file)
|
259
259
|
end
|
260
260
|
|
261
|
-
# def dump(file = nil) # not a dot command!
|
262
|
-
# file ||= ::STDOUT
|
263
|
-
# TTY.puts "--- Writing body (#{@body.size} bytes)" if @body
|
264
|
-
# file.puts @body
|
265
|
-
# rescue => err
|
266
|
-
# TTY.puts "#dump had an error: #{err.inspect}"
|
267
|
-
# end
|
268
|
-
|
269
261
|
def graceful_error(err, msg = nil)
|
270
262
|
api.dump
|
271
263
|
STDERR.puts msg if msg
|
data/lib/livetext/html.rb
CHANGED
@@ -1,39 +1,6 @@
|
|
1
|
+
class HTML # FIXME - better as Livetext::HTML ?
|
1
2
|
|
2
|
-
#
|
3
|
-
#
|
4
|
-
# def wrapped(str, *tags) # helper
|
5
|
-
# open, close = open_close_tags(*tags)
|
6
|
-
# open + str + close
|
7
|
-
# end
|
8
|
-
#
|
9
|
-
# def wrapped!(str, tag, **extras) # helper
|
10
|
-
# open, close = open_close_tags(tag)
|
11
|
-
# extras.each_pair do |name, value|
|
12
|
-
# open.sub!(">", " #{name}='#{value}'>")
|
13
|
-
# end
|
14
|
-
# open + str + close
|
15
|
-
# end
|
16
|
-
#
|
17
|
-
# def wrap(*tags) # helper
|
18
|
-
# open, close = open_close_tags(*tags)
|
19
|
-
# api.out open
|
20
|
-
# yield
|
21
|
-
# api.out close
|
22
|
-
# end
|
23
|
-
#
|
24
|
-
# def open_close_tags(*tags)
|
25
|
-
# open, close = "", ""
|
26
|
-
# tags.each do |tag|
|
27
|
-
# open << "<#{tag}>"
|
28
|
-
# close.prepend("</#{tag}>")
|
29
|
-
# end
|
30
|
-
# [open, close]
|
31
|
-
# end
|
32
|
-
# end
|
33
|
-
|
34
|
-
class HTML
|
35
|
-
|
36
|
-
def initialize(api)
|
3
|
+
def initialize(api) # HTML
|
37
4
|
raise "API is nil!" unless api
|
38
5
|
@api = api
|
39
6
|
@indent = 0
|
data/lib/livetext/more.rb
CHANGED
@@ -5,10 +5,10 @@ class Livetext
|
|
5
5
|
|
6
6
|
include Helpers
|
7
7
|
|
8
|
-
class Variables
|
8
|
+
class Variables # FIXME - split out into file as Livetext::Variables
|
9
9
|
attr_reader :vars
|
10
10
|
|
11
|
-
def initialize(hash = {})
|
11
|
+
def initialize(hash = {}) # Livetext::Variables
|
12
12
|
@vars = {}
|
13
13
|
hash.each_pair do |k, v|
|
14
14
|
sym = k.to_sym
|
@@ -98,7 +98,7 @@ class Livetext
|
|
98
98
|
@save_location = where # delegate
|
99
99
|
end
|
100
100
|
|
101
|
-
def initialize(output = ::STDOUT)
|
101
|
+
def initialize(output = ::STDOUT) # Livetext
|
102
102
|
@source = nil
|
103
103
|
@_mixins = []
|
104
104
|
@_imports = []
|
@@ -123,8 +123,6 @@ class Livetext
|
|
123
123
|
end
|
124
124
|
call.each {|cmd| obj.main.send(cmd[1..-1]) } # ignores leading dot, no param
|
125
125
|
obj.api.setvars(vars)
|
126
|
-
# puts "------ init: obj = "
|
127
|
-
# p obj
|
128
126
|
obj
|
129
127
|
end
|
130
128
|
|
data/lib/livetext/parser/set.rb
CHANGED
data/lib/livetext/paths.rb
CHANGED
data/lib/livetext/processor.rb
CHANGED
@@ -23,7 +23,7 @@ class Processor
|
|
23
23
|
|
24
24
|
attr_reader :parent, :sources
|
25
25
|
|
26
|
-
def initialize(parent, output = nil)
|
26
|
+
def initialize(parent, output = nil) # Processor
|
27
27
|
@parent = parent || self
|
28
28
|
# STDERR.puts "PARENT.api = #{parent.api.inspect}"
|
29
29
|
@parent.api ||= Livetext::UserAPI.new(@parent)
|
@@ -85,6 +85,4 @@ class Processor
|
|
85
85
|
@sources.pop
|
86
86
|
nil
|
87
87
|
end
|
88
|
-
|
89
|
-
|
90
88
|
end
|
data/lib/livetext/standard.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
1
|
require 'pathname' # For _seek - remove later??
|
3
2
|
|
4
3
|
require_relative 'parser' # nested requires
|
@@ -9,7 +8,6 @@ make_exception(:ExpectedOnOff, "Error: expected 'on' or 'off'")
|
|
9
8
|
make_exception(:DisallowedName, "Error: name '%1' is invalid")
|
10
9
|
make_exception(:FileNotFound, "Error: file '%1' not found")
|
11
10
|
|
12
|
-
|
13
11
|
# Module Standard comprises most of the standard or "common" methods.
|
14
12
|
|
15
13
|
module Livetext::Standard
|
@@ -74,6 +72,8 @@ module Livetext::Standard
|
|
74
72
|
return true
|
75
73
|
end
|
76
74
|
|
75
|
+
# FIXME - move these to a single universal place in code
|
76
|
+
|
77
77
|
def h1(args = nil, body = nil); api.out html.tag(:h1, cdata: api.data); return true; end
|
78
78
|
def h2(args = nil, body = nil); api.out html.tag(:h2, cdata: api.data); return true; end
|
79
79
|
def h3(args = nil, body = nil); api.out html.tag(:h3, cdata: api.data); return true; end
|
@@ -258,7 +258,7 @@ module Livetext::Standard
|
|
258
258
|
def dot_include(args = nil, body = nil) # dot command
|
259
259
|
file = api.expand_variables(api.args.first) # allows for variables
|
260
260
|
check_file_exists(file)
|
261
|
-
|
261
|
+
checkpoint
|
262
262
|
@parent.process_file(file)
|
263
263
|
api.optional_blank_line
|
264
264
|
end
|
data/lib/livetext/userapi.rb
CHANGED
@@ -4,8 +4,7 @@ require_relative 'html'
|
|
4
4
|
# Encapsulate the UserAPI as a class
|
5
5
|
|
6
6
|
class Livetext::UserAPI
|
7
|
-
|
8
|
-
include ::Livetext::Standard
|
7
|
+
include ::Livetext::Standard # FIXME - feels wonky?
|
9
8
|
|
10
9
|
KBD = File.new("/dev/tty", "r")
|
11
10
|
TTY = File.new("/dev/tty", "w")
|
@@ -14,7 +13,7 @@ class Livetext::UserAPI
|
|
14
13
|
|
15
14
|
attr_accessor :data, :args
|
16
15
|
|
17
|
-
def initialize(live)
|
16
|
+
def initialize(live) # Livetext::UserAPI
|
18
17
|
@live = live
|
19
18
|
@vars = live.vars
|
20
19
|
@html = HTML.new(self)
|
@@ -45,7 +44,7 @@ class Livetext::UserAPI
|
|
45
44
|
# checkpoint "DATA = #{file.inspect}"
|
46
45
|
api.data = file
|
47
46
|
api.args = [file]
|
48
|
-
|
47
|
+
dot_include
|
49
48
|
end
|
50
49
|
|
51
50
|
def expand_variables(str)
|
@@ -215,6 +214,5 @@ class Livetext::UserAPI
|
|
215
214
|
def debug(*args)
|
216
215
|
TTY.puts *args if @live.debug
|
217
216
|
end
|
218
|
-
|
219
217
|
end
|
220
218
|
|
data/lib/livetext/version.rb
CHANGED
data/lib/livetext.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
|
2
2
|
require_relative 'livetext/skeleton'
|
3
3
|
require_relative 'livetext/version'
|
4
|
+
require_relative 'livetext/helpers'
|
5
|
+
require_relative 'livetext/more'
|
4
6
|
require_relative 'livetext/paths'
|
5
7
|
|
6
8
|
require_relative 'livetext/reopen'
|
@@ -11,8 +13,6 @@ require_relative 'livetext/functions'
|
|
11
13
|
require_relative 'livetext/userapi'
|
12
14
|
require_relative 'livetext/formatter'
|
13
15
|
require_relative 'livetext/processor'
|
14
|
-
require_relative 'livetext/helpers'
|
15
|
-
require_relative 'livetext/more'
|
16
16
|
|
17
17
|
require_relative 'livetext/handler'
|
18
18
|
|
@@ -5,11 +5,19 @@ Testing heredocs (used in a table)
|
|
5
5
|
|
6
6
|
<center><table width=90% cellpadding=5>
|
7
7
|
<tr>
|
8
|
-
<td valign=top>This is <br
|
9
|
-
|
8
|
+
<td valign=top>This is <br><br>
|
9
|
+
only <br><br>
|
10
|
+
a test.<br></td>
|
11
|
+
<td valign=top>This is <br><br>
|
12
|
+
just <br><br>
|
13
|
+
some <br><br>
|
14
|
+
random text.<br></td>
|
10
15
|
</tr>
|
11
16
|
<tr>
|
12
|
-
<td valign=top>And so<br
|
13
|
-
|
17
|
+
<td valign=top>And so<br><br>
|
18
|
+
is this.<br></td>
|
19
|
+
<td valign=top>This is <br><br>
|
20
|
+
row 2<br><br>
|
21
|
+
col 2<br></td>
|
14
22
|
</tr>
|
15
23
|
</table></center>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
Testing heredocs (used in a table)
|
2
|
+
<p>
|
3
|
+
|
4
|
+
<br>
|
5
|
+
|
6
|
+
<center><table width=90% cellpadding=5>
|
7
|
+
<tr>
|
8
|
+
<td valign=top>This is <br>only <br>a test.<br></td>
|
9
|
+
<td valign=top>This is <br>just <br>some <br>random text.<br></td>
|
10
|
+
</tr>
|
11
|
+
<tr>
|
12
|
+
<td valign=top>And so<br>is this.<br></td>
|
13
|
+
<td valign=top>This is <br>row 2<br>col 2<br></td>
|
14
|
+
</tr>
|
15
|
+
</table></center>
|
data/test/snapshots.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: livetext
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.47
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hal Fulton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-05-
|
11
|
+
date: 2024-05-25 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A smart text processor extensible in Ruby
|
14
14
|
email: rubyhacker@gmail.com
|
@@ -26,7 +26,6 @@ files:
|
|
26
26
|
- imports/markdown.rb
|
27
27
|
- imports/pyggish.rb
|
28
28
|
- imports/tutorial.rb
|
29
|
-
- lib/cmdargs.rb
|
30
29
|
- lib/livetext.rb
|
31
30
|
- lib/livetext/errors.rb
|
32
31
|
- lib/livetext/expansion.rb
|
@@ -186,6 +185,7 @@ files:
|
|
186
185
|
- test/snapshots/subset.txt
|
187
186
|
- test/snapshots/table_with_heredocs/expected-error.txt
|
188
187
|
- test/snapshots/table_with_heredocs/expected-output.txt
|
188
|
+
- test/snapshots/table_with_heredocs/old-exp-out.txt
|
189
189
|
- test/snapshots/table_with_heredocs/source.lt3
|
190
190
|
- test/snapshots/var_into_func/expected-error.txt
|
191
191
|
- test/snapshots/var_into_func/expected-output.txt
|
data/lib/cmdargs.rb
DELETED
@@ -1,106 +0,0 @@
|
|
1
|
-
|
2
|
-
require_relative 'livetext'
|
3
|
-
|
4
|
-
=begin
|
5
|
-
Weird concepts to understand here...
|
6
|
-
|
7
|
-
1. A Livetext dot-command (flush left) usually looks like:
|
8
|
-
.foobar
|
9
|
-
|
10
|
-
2. A dot-command (left-indented) usually looks like:
|
11
|
-
$.foobar
|
12
|
-
|
13
|
-
3. More generally, it may have any number of parameters (0, 1, ...)
|
14
|
-
.redirect somefile.txt append
|
15
|
-
|
16
|
-
4. Variables and functions *can* appear (rare in practice??)
|
17
|
-
.redirect somefile$my_suffix $$my_mode
|
18
|
-
|
19
|
-
5. A trailing # comment may appear
|
20
|
-
a. Stripped... saved in #raw ? #data ? #comment ? elsewhere?
|
21
|
-
b. NOT the "dot" as a comment!
|
22
|
-
|
23
|
-
6. .foobar # This here is a comment
|
24
|
-
|
25
|
-
7. #data accessor returns all data on the .foo line...
|
26
|
-
a. ...After the initial space
|
27
|
-
b. ...Including later spaces
|
28
|
-
c. Including comment??
|
29
|
-
d. .foo This is o n l y a test.
|
30
|
-
# #data returns: "This is o n l y a test."
|
31
|
-
e. What about formatting???
|
32
|
-
f. What about: comments? variables? functions?
|
33
|
-
|
34
|
-
8. Some commands have NO body while others have an OPTIONAL or REQUIRED body
|
35
|
-
a. Assume .cmd1 definition forbids a body (then a body is an error)
|
36
|
-
.cmd1 # may NOT have a body
|
37
|
-
b. Assume .cmd2 definition PERMITS a body
|
38
|
-
.cmd2 # may or MAY NOT have body/.end
|
39
|
-
c. Assume .cmd3 definition REQUIRES a body
|
40
|
-
.cmd3 # REQUIRES a body/.end
|
41
|
-
. stuff...
|
42
|
-
.end
|
43
|
-
|
44
|
-
9. Inside a body:
|
45
|
-
a. Leading dot has no special meaning (though the associated method may parse it!)
|
46
|
-
b. BUG? Currently leading dot is a comment INSIDE a body?
|
47
|
-
c. No leading char is special (though the associated method may parse it!)
|
48
|
-
d. No trailing #-comments (though the associated method may parse it!)
|
49
|
-
e. ?? We should or shouldn't look for variables/functions? or make it an option?
|
50
|
-
f. .end may naturally not be used (but see .raw where it may)
|
51
|
-
|
52
|
-
10. The args accessor is a simple array of strings
|
53
|
-
a. there is also raw_args (without variables/functions, etc.)
|
54
|
-
b. Much of this HAS NOT been thought through yet!
|
55
|
-
|
56
|
-
=end
|
57
|
-
|
58
|
-
class Livetext::CmdData
|
59
|
-
|
60
|
-
attr_reader :data, :args, :nargs, :arity, :comment, :raw # , ...?
|
61
|
-
|
62
|
-
def initialize(data, body: false, arity: :N) # FIXME maybe just add **options ??
|
63
|
-
# arity: (num) fixed number 0 or more
|
64
|
-
# :N arbitrary number
|
65
|
-
# n1..n2 range
|
66
|
-
# body: true => this command has a body + .end
|
67
|
-
# how raw is raw?
|
68
|
-
# remove comment - always/sometimes/never?
|
69
|
-
# interpolate - always/sometimes/never?
|
70
|
-
# interpolate inside body??
|
71
|
-
@data = data.dup # comment? vars? funcs?
|
72
|
-
@raw = data.dup # comment? vars? funcs?
|
73
|
-
@args = data.split # simple array
|
74
|
-
@nargs = nargs # not really "needed"
|
75
|
-
check_num_args(nargs)
|
76
|
-
# @varfunc = Livetext.interpolate(data.dup)
|
77
|
-
end
|
78
|
-
|
79
|
-
def check_num_args(num)
|
80
|
-
num_range = /(\d{0,2})(\.\.)(\d{0,2})/ # Not "really" right...
|
81
|
-
min, max = 0, 9999
|
82
|
-
mdata = num_range.match(@nargs).to_a
|
83
|
-
bad_args = nil
|
84
|
-
case
|
85
|
-
when @nargs == ":N" # arbitrary
|
86
|
-
# max already set
|
87
|
-
when mdata[2] == ".." # range: 4..6 1.. ..4
|
88
|
-
vmin, vmax = mdata.values_at(1, 2)
|
89
|
-
min = Integer(vmin) unless vmin.empty?
|
90
|
-
max = Integer(vmax) unless vmax.empty?
|
91
|
-
min, max = Integer(min), Integer(max)
|
92
|
-
when %r[^\d+$] =~ num
|
93
|
-
min = max = Integer(num) # can raise error
|
94
|
-
else
|
95
|
-
raise "Invalid value or range '#{num.inspect}'"
|
96
|
-
end
|
97
|
-
|
98
|
-
bad_args = @args.size.between?(min, max)
|
99
|
-
raise "Expected #{num} args but found #{@args.size}!" if bad_args
|
100
|
-
end
|
101
|
-
|
102
|
-
def strip_comments(str)
|
103
|
-
str.sub!(/ # .*/, "")
|
104
|
-
end
|
105
|
-
|
106
|
-
end
|