sequence 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +6 -0
- data/Makefile +32 -0
- data/README.txt +1 -0
- data/Rakefile +5 -3
- data/lib/sequence/buffered.rb +0 -2
- data/lib/sequence/file.rb +3 -3
- data/lib/sequence/io.rb +19 -10
- data/lib/sequence/list.rb +4 -5
- data/lib/sequence/position.rb +1 -1
- data/lib/sequence/shifting.rb +4 -4
- data/lib/sequence/stringlike.rb +18 -18
- data/lib/sequence/subseq.rb +8 -3
- data/lib/sequence/version.rb +1 -1
- data/lib/sequence/weakrefset.rb +8 -0
- data/lib/sequence.rb +4 -4
- data/sequence.gemspec +44 -0
- data/test/test_all.rb +3 -3
- data/test/test_rexscan.rb +26 -13
- data/test/test_seqrex.rb +16 -16
- metadata +18 -24
data/History.txt
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
=== 0.2.2 / 2009-08-05
|
2
|
+
* 3 Minor Enhancements:
|
3
|
+
* mostly works in ruby 1.9, but still some bizarre unit test failures
|
4
|
+
* should now work in windows without a problem
|
5
|
+
* replaced (no longer working) Hoe/Rakefile with Makefile/gemspec
|
6
|
+
|
1
7
|
=== 0.2.1 / 2009-01-07
|
2
8
|
* 1 Minor Enhancement:
|
3
9
|
* WeakRefSet now conforms to Set's api and tests more closely.
|
data/Makefile
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
.PHONY: all test docs gem tar pkg email
|
2
|
+
all: test
|
3
|
+
|
4
|
+
test:
|
5
|
+
ruby -Ilib test/test_all.rb
|
6
|
+
|
7
|
+
docs:
|
8
|
+
rdoc lib/*
|
9
|
+
|
10
|
+
pkg: gem tar
|
11
|
+
|
12
|
+
gem:
|
13
|
+
gem build sequence.gemspec
|
14
|
+
|
15
|
+
tar:
|
16
|
+
tar czf sequence-`ruby -r ./lib/sequence/version.rb -e 'puts Sequence::VERSION'`.tar.gz `git ls-files`
|
17
|
+
|
18
|
+
email: README.txt History.txt
|
19
|
+
ruby -e ' \
|
20
|
+
require "rubygems"; \
|
21
|
+
load "./sequence.gemspec"; \
|
22
|
+
spec= Gem::Specification.list.find{|x| x.name=="sequence"}; \
|
23
|
+
puts "\
|
24
|
+
Subject: [ANN] Sequence #{spec.version} Released \
|
25
|
+
\n\nSequence version #{spec.version} has been released! \n\n\
|
26
|
+
#{Array(spec.homepage).map{|url| " * #{url}\n" }} \
|
27
|
+
\n\
|
28
|
+
#{Sequence::Description} \
|
29
|
+
\n\nChanges:\n\n \
|
30
|
+
#{Sequence::Latest_changes} \
|
31
|
+
"\
|
32
|
+
'
|
data/README.txt
CHANGED
data/Rakefile
CHANGED
@@ -2,14 +2,16 @@
|
|
2
2
|
# Distributed under the terms of Ruby's license.
|
3
3
|
require 'rubygems'
|
4
4
|
require 'hoe'
|
5
|
-
require 'lib/sequence/version.rb'
|
6
|
-
|
5
|
+
require './lib/sequence/version.rb'
|
6
|
+
require 'test/unit'
|
7
7
|
|
8
8
|
if $*==["test"]
|
9
|
+
gem 'test-unit'
|
10
|
+
require 'test/unit'
|
9
11
|
#hack to get 'rake test' to stay in one process
|
10
12
|
#which keeps netbeans happy
|
11
13
|
$:<<"lib"
|
12
|
-
require "test/test_all.rb"
|
14
|
+
require "./test/test_all.rb"
|
13
15
|
Test::Unit::AutoRunner.run
|
14
16
|
exit
|
15
17
|
end
|
data/lib/sequence/buffered.rb
CHANGED
data/lib/sequence/file.rb
CHANGED
@@ -17,8 +17,8 @@ class File < Sequence
|
|
17
17
|
def initialize(file,mode="r")
|
18
18
|
|
19
19
|
case file
|
20
|
-
when Integer
|
21
|
-
when String
|
20
|
+
when Integer; file=IO.new(file,mode)
|
21
|
+
when String; file=File.new(file,mode)
|
22
22
|
else #do nothing, file is of a right type (we hope) already
|
23
23
|
end
|
24
24
|
|
@@ -169,4 +169,4 @@ class StringIO
|
|
169
169
|
def to_sequence
|
170
170
|
Sequence::File.new(self)
|
171
171
|
end
|
172
|
-
end
|
172
|
+
end
|
data/lib/sequence/io.rb
CHANGED
@@ -12,7 +12,8 @@ class Sequence
|
|
12
12
|
#At the moment, this even includes #scan and friends, tho I will try to make those work somewhat.
|
13
13
|
#Also note that this is one of the few Sequence classes that might return less that the amount asked
|
14
14
|
#for in a read, even if not at the end of file.
|
15
|
-
#Due to use of nonblocking io, this
|
15
|
+
#Due to use of nonblocking io, this only works on windows when wrapping a socket, not a named pipe,
|
16
|
+
#anonymous pipe, or device.
|
16
17
|
#The value of #size in this sequence continually increases over its lifetime, and it isn't possible to
|
17
18
|
#know the final value beforehand. Likewise, #eof? may return false even tho it's destined to return
|
18
19
|
#true at the same position. This is because the 'other end' may not have closed the IO, even if there's
|
@@ -25,10 +26,6 @@ class IO < Sequence
|
|
25
26
|
def initialize(io)
|
26
27
|
@io=io
|
27
28
|
@pos=0
|
28
|
-
|
29
|
-
@io.fcntl(::Fcntl::F_SETFL, ::Fcntl::O_NONBLOCK)
|
30
|
-
#I gather this won't work on windows....
|
31
|
-
|
32
29
|
@fragment=''
|
33
30
|
end
|
34
31
|
|
@@ -42,14 +39,14 @@ class IO < Sequence
|
|
42
39
|
|
43
40
|
def size
|
44
41
|
#refill fragment if needed
|
45
|
-
@fragment
|
42
|
+
@fragment=readchunk(4096) if @fragment.empty?
|
46
43
|
|
47
44
|
return @pos+@fragment.size
|
48
45
|
end
|
49
46
|
|
50
47
|
def more_data?
|
51
48
|
#refill fragment if needed
|
52
|
-
@fragment
|
49
|
+
@fragment=readchunk(4096) if @fragment.empty?
|
53
50
|
|
54
51
|
return !eof
|
55
52
|
end
|
@@ -59,6 +56,14 @@ class IO < Sequence
|
|
59
56
|
@io.eof?
|
60
57
|
end
|
61
58
|
|
59
|
+
def readchunk len
|
60
|
+
@fragment=@io.read_nonblock(len)
|
61
|
+
rescue IOError, EOFError
|
62
|
+
raise
|
63
|
+
rescue Exception
|
64
|
+
@fragment=''
|
65
|
+
end
|
66
|
+
|
62
67
|
def read len
|
63
68
|
if len<= @fragment.size
|
64
69
|
@pos+=len
|
@@ -71,7 +76,7 @@ class IO < Sequence
|
|
71
76
|
rem=len%4096
|
72
77
|
rem.nonzero? and readlen+=4096-rem
|
73
78
|
|
74
|
-
@fragment
|
79
|
+
@fragment=readchunk(readlen)
|
75
80
|
result+=@fragment.slice!(0,len)
|
76
81
|
@pos+=result.size
|
77
82
|
result
|
@@ -79,7 +84,11 @@ class IO < Sequence
|
|
79
84
|
end
|
80
85
|
|
81
86
|
def match pat
|
82
|
-
@fragment.size>=scanbuflen
|
87
|
+
unless @fragment.size>=scanbuflen
|
88
|
+
frag=@fragment
|
89
|
+
frag<<readchunk([4096,scanbuflen].max)
|
90
|
+
end
|
91
|
+
@fragment=frag
|
83
92
|
result=@fragment.match(pat)
|
84
93
|
result if result.begin(0).zero?
|
85
94
|
end
|
@@ -93,8 +102,8 @@ class IO < Sequence
|
|
93
102
|
else
|
94
103
|
len=newpos-(@pos+@fragment.size)
|
95
104
|
len > 10*4096 and raise ArgumentError
|
105
|
+
tossit=readchunk(len)
|
96
106
|
@fragment=''
|
97
|
-
tossit=@io.sysread(len)
|
98
107
|
@pos=newpos-(len-tossit.size)
|
99
108
|
end
|
100
109
|
end
|
data/lib/sequence/list.rb
CHANGED
@@ -76,9 +76,9 @@ class Sequence
|
|
76
76
|
assert @start_pos[high]>pos
|
77
77
|
mid=(low+high)/2
|
78
78
|
case pos<=>@start_pos[mid]
|
79
|
-
when -1
|
80
|
-
when 0
|
81
|
-
when 1
|
79
|
+
when -1; high=mid
|
80
|
+
when 0; break low=mid
|
81
|
+
when 1; low=mid
|
82
82
|
end
|
83
83
|
end
|
84
84
|
assert @start_pos[low]<=pos
|
@@ -91,8 +91,7 @@ class Sequence
|
|
91
91
|
result=@list[idx][pos-@start_pos[idx],len] || new_data
|
92
92
|
len-=result.size
|
93
93
|
assert len>=0
|
94
|
-
i
|
95
|
-
(idx+1).upto(@list.size-1){|i|
|
94
|
+
(idx+1).upto(@list.size-1){|i|
|
96
95
|
break(result+=@list[i][0,len]) if len<@list[i].size
|
97
96
|
result+=@list[i].all_data
|
98
97
|
len-=@list[i].size
|
data/lib/sequence/position.rb
CHANGED
data/lib/sequence/shifting.rb
CHANGED
@@ -98,8 +98,8 @@ public
|
|
98
98
|
diff=-diff
|
99
99
|
@seq[x,diff] rescue
|
100
100
|
case data_class
|
101
|
-
when ::Array
|
102
|
-
when ::String
|
101
|
+
when ::Array; [nil]
|
102
|
+
when ::String; "\0"
|
103
103
|
else fail
|
104
104
|
end*diff
|
105
105
|
|
@@ -116,8 +116,8 @@ public
|
|
116
116
|
@data.prepend((
|
117
117
|
@seq[x...offset] rescue
|
118
118
|
case data_class
|
119
|
-
when ::Array
|
120
|
-
when ::String
|
119
|
+
when ::Array; [nil]
|
120
|
+
when ::String; "\0"
|
121
121
|
else fail
|
122
122
|
end*(offset-x)
|
123
123
|
))
|
data/lib/sequence/stringlike.rb
CHANGED
@@ -174,7 +174,7 @@ class Sequence
|
|
174
174
|
(frags=newrex.split( /((?:[^\\(\[\]$^]+|\\(?:[CM]-)*[^CMZA])*)/ )).each_index{|i|
|
175
175
|
frag=frags[i]
|
176
176
|
case frag
|
177
|
-
when "\\"
|
177
|
+
when "\\"
|
178
178
|
if !incclass and frags[i+1][0,1]==buffanchor
|
179
179
|
frags[i+1].slice! 0
|
180
180
|
frag='(?!)'
|
@@ -191,9 +191,9 @@ class Sequence
|
|
191
191
|
frag="(?=\n)"
|
192
192
|
rewritten=true
|
193
193
|
end
|
194
|
-
when "("
|
195
|
-
when "["
|
196
|
-
when "]"
|
194
|
+
when "("; incclass or frags[i+1][0]==?? or groupnum+=1
|
195
|
+
when "["; incclass=true #ignore stuff til ]
|
196
|
+
when "]"; incclass=false #stop ignoring stuff
|
197
197
|
end
|
198
198
|
result<<frag
|
199
199
|
}
|
@@ -302,12 +302,12 @@ class Sequence
|
|
302
302
|
|
303
303
|
def scan(pat)
|
304
304
|
holding? {case pat
|
305
|
-
when Integer
|
305
|
+
when Integer
|
306
306
|
pat==read1 and pat.chr
|
307
|
-
#when SetOfChar
|
308
|
-
when String
|
307
|
+
#when SetOfChar; ...
|
308
|
+
when String
|
309
309
|
pat==read(pat.size) and pat
|
310
|
-
when Regexp
|
310
|
+
when Regexp
|
311
311
|
if m=match(pat,true)
|
312
312
|
goto m.end(0)
|
313
313
|
m.to_s
|
@@ -318,12 +318,12 @@ class Sequence
|
|
318
318
|
|
319
319
|
def scanback(pat)
|
320
320
|
holding? {case pat
|
321
|
-
when Integer
|
321
|
+
when Integer
|
322
322
|
pat==readback1 and pat.chr
|
323
|
-
#when SetOfChar
|
324
|
-
when String
|
323
|
+
#when SetOfChar; ...
|
324
|
+
when String
|
325
325
|
pat==readback(pat.size) and pat
|
326
|
-
when Regexp
|
326
|
+
when Regexp
|
327
327
|
if m=matchback(pat,true)
|
328
328
|
goto m.begin(0)
|
329
329
|
m.to_s
|
@@ -335,14 +335,14 @@ class Sequence
|
|
335
335
|
def scan_until(pat)
|
336
336
|
at=index( pat,pos) or return
|
337
337
|
newpos=case pat
|
338
|
-
when Regexp
|
338
|
+
when Regexp
|
339
339
|
m=last_match
|
340
340
|
s=slice(pos...m.begin(0))
|
341
341
|
m.set_pre_match_body{s}
|
342
342
|
m.end(0)
|
343
|
-
when String
|
344
|
-
when Integer
|
345
|
-
#when SetOfChar
|
343
|
+
when String; at+pat.size
|
344
|
+
when Integer; at+1
|
345
|
+
#when SetOfChar; huh
|
346
346
|
else raise ArgumentError
|
347
347
|
end
|
348
348
|
return( read newpos-pos)
|
@@ -364,7 +364,7 @@ class Sequence
|
|
364
364
|
end
|
365
365
|
nil
|
366
366
|
}
|
367
|
-
#elsif SetOfChar===pat
|
367
|
+
#elsif SetOfChar===pat; ...
|
368
368
|
else #string or integer
|
369
369
|
i=index(pat,pos)
|
370
370
|
result=read(i-pos)<<pat
|
@@ -395,7 +395,7 @@ class Sequence
|
|
395
395
|
m=matchback(pat,false) or break
|
396
396
|
goto= m.begin(0)
|
397
397
|
m.to_s+m.post_match
|
398
|
-
#elsif SetOfChar===pat
|
398
|
+
#elsif SetOfChar===pat; ...
|
399
399
|
else #string or integer
|
400
400
|
i=rindex(pat,pos)
|
401
401
|
result=readback(pos-i-pat.size)<<pat
|
data/lib/sequence/subseq.rb
CHANGED
@@ -6,6 +6,7 @@ require 'sequence/usedata'
|
|
6
6
|
class Sequence
|
7
7
|
class SubSeq < Sequence
|
8
8
|
def initialize(seq, first,len)
|
9
|
+
assert first
|
9
10
|
first+len-1>=seq.size and len=seq.size-first
|
10
11
|
@data=seq
|
11
12
|
@pos=0
|
@@ -14,9 +15,10 @@ class Sequence
|
|
14
15
|
|
15
16
|
#ask for notifications on the parent seq...
|
16
17
|
@data.on_change_notify self
|
18
|
+
assert @first
|
19
|
+
#p [:init,__id__]
|
17
20
|
end
|
18
|
-
|
19
|
-
|
21
|
+
|
20
22
|
def change_notification data,first,oldsize,newsize
|
21
23
|
assert @data==data
|
22
24
|
old_first=@first
|
@@ -24,6 +26,8 @@ class Sequence
|
|
24
26
|
@pos=(_adjust_pos_on_change @first+@pos,first,oldsize,newsize)-@first
|
25
27
|
@size=(_adjust_pos_on_change @first+@size,first,oldsize,newsize)-@first
|
26
28
|
@first=_adjust_pos_on_change @first,first,oldsize,newsize
|
29
|
+
assert @first
|
30
|
+
#p [:cn, __id__]
|
27
31
|
|
28
32
|
notify_change(self, first-@first, oldsize, newsize)
|
29
33
|
end
|
@@ -50,7 +54,7 @@ class Sequence
|
|
50
54
|
|
51
55
|
def readback(len)
|
52
56
|
result=readbehind(len)
|
53
|
-
move( -result.size)
|
57
|
+
move( -result.size )
|
54
58
|
result
|
55
59
|
end
|
56
60
|
|
@@ -69,6 +73,7 @@ class Sequence
|
|
69
73
|
attr :data
|
70
74
|
|
71
75
|
def subseq *args
|
76
|
+
#p [:subseq, __id__]
|
72
77
|
first,len,only1=_parse_slice_args( *args)
|
73
78
|
SubSeq.new(@data,@first+first,len)
|
74
79
|
end
|
data/lib/sequence/version.rb
CHANGED
data/lib/sequence/weakrefset.rb
CHANGED
@@ -114,9 +114,17 @@ end
|
|
114
114
|
alias eql? ==
|
115
115
|
|
116
116
|
def hash
|
117
|
+
hashing=Thread.current[:$WeakRefSet_hashing]||=[]
|
118
|
+
return 0 if hashing.include? self
|
119
|
+
hashing<<self
|
120
|
+
|
117
121
|
result=0
|
118
122
|
each{|x| result^=x.hash }
|
119
123
|
result
|
124
|
+
|
125
|
+
ensure
|
126
|
+
hashing.delete(self)
|
127
|
+
Thread.current[:$WeakRefSet_hashing]=nil if hashing.empty?
|
120
128
|
end
|
121
129
|
|
122
130
|
# clear the set (return self)
|
data/lib/sequence.rb
CHANGED
@@ -47,7 +47,7 @@ class Sequence
|
|
47
47
|
undef new #bye-bye
|
48
48
|
def new(seq)
|
49
49
|
case seq
|
50
|
-
when File,IO,Array,String,Enumerable
|
50
|
+
when File,IO,Array,String,Enumerable
|
51
51
|
seq.to_sequence
|
52
52
|
else
|
53
53
|
if seq.respond_to? :to_str
|
@@ -562,18 +562,18 @@ class Sequence
|
|
562
562
|
assert !closed?
|
563
563
|
size=self.size
|
564
564
|
case r=args.first
|
565
|
-
when Range
|
565
|
+
when Range
|
566
566
|
asize==1 or raise ArgumentError
|
567
567
|
first,last=r.first,r.last
|
568
568
|
first=_normalize_pos(first,size)
|
569
569
|
last=_normalize_pos(last,size)
|
570
570
|
len=last-first
|
571
571
|
r.exclude_end? or len+=1
|
572
|
-
when Integer
|
572
|
+
when Integer
|
573
573
|
asize<=2 or raise ArgumentError
|
574
574
|
first=_normalize_pos(r,size)
|
575
575
|
len=args[1] || (only1=1)
|
576
|
-
when nil
|
576
|
+
when nil
|
577
577
|
asize==0 or raise ArgumentError
|
578
578
|
first=nil
|
579
579
|
len=only1=1
|
data/sequence.gemspec
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require './lib/sequence/version'
|
4
|
+
Sequence::Description=open("README.txt"){|f| f.read[/^==+ ?description[^\n]*?\n *\n?(.*?\n *\n.*?)\n *\n/im,1] }
|
5
|
+
Sequence::Latest_changes="###"+open("History.txt"){|f| f.read[/\A===(.*?)(?====)/m,1] }
|
6
|
+
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.name = "sequence"
|
9
|
+
s.version = Sequence::VERSION
|
10
|
+
|
11
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
|
+
s.authors = ["Caleb Clausen"]
|
13
|
+
s.date = Time.now.strftime("%Y-%m-%d")
|
14
|
+
s.email = %q{caleb (at) inforadical (dot) net}
|
15
|
+
s.extra_rdoc_files = ["README.txt", "COPYING", "GPL"]
|
16
|
+
s.files = `git ls-files`.split
|
17
|
+
s.has_rdoc = true
|
18
|
+
s.homepage = %{http://github.com/coatl/sequence}
|
19
|
+
s.rdoc_options = %w[--inline-source --main README.txt]
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
s.rubyforge_project = %q{sequence}
|
22
|
+
s.rubygems_version = %q{1.3.0}
|
23
|
+
s.test_files = %w[test/test_all.rb]
|
24
|
+
s.summary = "A single api for reading and writing sequential data types."
|
25
|
+
s.description = Sequence::Description
|
26
|
+
|
27
|
+
=begin
|
28
|
+
if s.respond_to? :specification_version then
|
29
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
30
|
+
s.specification_version = 2
|
31
|
+
|
32
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
33
|
+
s.add_runtime_dependency(%q<mime-types>, [">= 1.15"])
|
34
|
+
s.add_runtime_dependency(%q<diff-lcs>, [">= 1.1.2"])
|
35
|
+
else
|
36
|
+
s.add_dependency(%q<mime-types>, [">= 1.15"])
|
37
|
+
s.add_dependency(%q<diff-lcs>, [">= 1.1.2"])
|
38
|
+
end
|
39
|
+
else
|
40
|
+
s.add_dependency(%q<mime-types>, [">= 1.15"])
|
41
|
+
s.add_dependency(%q<diff-lcs>, [">= 1.1.2"])
|
42
|
+
end
|
43
|
+
=end
|
44
|
+
end
|
data/test/test_all.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Copyright (C) 2006 Caleb Clausen
|
2
2
|
# Distributed under the terms of Ruby's license.
|
3
|
-
require 'test/test_rexscan.rb'
|
4
|
-
require 'test/test_seqrex.rb'
|
5
|
-
require 'test/test_changes.rb'
|
3
|
+
require './test/test_rexscan.rb'
|
4
|
+
require './test/test_seqrex.rb'
|
5
|
+
require './test/test_changes.rb'
|
6
6
|
|
data/test/test_rexscan.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
# Distributed under the terms of Ruby's license.
|
3
3
|
$VERBOSE=1
|
4
4
|
require 'test/unit'
|
5
|
-
|
5
|
+
require 'socket'
|
6
6
|
|
7
7
|
require 'sequence'
|
8
8
|
require 'sequence/indexed'
|
@@ -143,6 +143,7 @@ $Debug=true
|
|
143
143
|
@@seq and @@seq.data.close(true)
|
144
144
|
|
145
145
|
tf=::Tempfile.new("test_seq#@@count"); @@count+=1
|
146
|
+
tf.binmode
|
146
147
|
|
147
148
|
tf.write DATA
|
148
149
|
|
@@ -239,8 +240,21 @@ $Debug=true
|
|
239
240
|
end
|
240
241
|
|
241
242
|
class IO < Indexed
|
243
|
+
def socketpair
|
244
|
+
BasicSocket.do_not_reverse_lookup=true
|
245
|
+
server_sock=TCPServer.new('127.0.0.1', 0xABCD)
|
246
|
+
client=TCPSocket.new('127.0.0.1', 0xABCD)
|
247
|
+
server=nil
|
248
|
+
begin
|
249
|
+
server.close if server
|
250
|
+
server=server_sock.accept
|
251
|
+
end until server.peeraddr==client.addr
|
252
|
+
return client,server
|
253
|
+
end
|
254
|
+
|
242
255
|
def a_seq
|
243
|
-
r,w
|
256
|
+
r,w=socketpair #was: ::IO.pipe #but windows doesn't allow nonblocking pipes
|
257
|
+
@closeit=w
|
244
258
|
r=Sequence::IO[r]
|
245
259
|
w.write DATA
|
246
260
|
r.read(OFFSET)== DATA[0,OFFSET] or raise "predata mismatch inside pipe"
|
@@ -251,7 +265,7 @@ $Debug=true
|
|
251
265
|
undef_method(*(MOVEPOSMETHODS+MODIFYMETHODS))
|
252
266
|
end
|
253
267
|
|
254
|
-
|
268
|
+
module SmallScanBuffered
|
255
269
|
SequenceTests.constants.each{|k|
|
256
270
|
xk= SequenceTests.const_get(k)
|
257
271
|
next unless (xk.is_a? Class and xk<=::SequenceTests::Indexed)
|
@@ -345,6 +359,7 @@ $Debug=true
|
|
345
359
|
=end
|
346
360
|
|
347
361
|
class Indexed
|
362
|
+
undef_method(*(MOVEPOSMETHODS+MODIFYMETHODS))
|
348
363
|
def test_optional_capture
|
349
364
|
seq=a_seq
|
350
365
|
word=seq.scan /(more of )?that (tough)/
|
@@ -365,7 +380,6 @@ $Debug=true
|
|
365
380
|
|
366
381
|
|
367
382
|
RANDOMIZED_METHODS=[:test_slice,:test_insert,:test_delete,:test_modify]
|
368
|
-
undef test_randomized_methods_some_more
|
369
383
|
def test_randomized_methods_some_more n=50
|
370
384
|
RANDOMIZED_METHODS.each{|m| n.times{send m}}
|
371
385
|
end
|
@@ -379,7 +393,6 @@ $Debug=true
|
|
379
393
|
end
|
380
394
|
|
381
395
|
|
382
|
-
undef_method(*(MOVEPOSMETHODS+MODIFYMETHODS))
|
383
396
|
def test_pos_munging
|
384
397
|
(1..3).each{|n|
|
385
398
|
seq=a_seq
|
@@ -615,23 +628,23 @@ $Debug=true
|
|
615
628
|
def verify_aftermatch_status(seq,pos,matches,starts,pre,post,eof)
|
616
629
|
assert_equal pos, seq.pos
|
617
630
|
assert seq.last_match
|
618
|
-
|
619
|
-
matches.each_with_index{|m,i|
|
631
|
+
ii=nil
|
632
|
+
matches.each_with_index{|m,i| ii=i
|
620
633
|
assert_equal m, seq.last_match[i]
|
621
634
|
}
|
622
|
-
assert_equal nil, seq.last_match[
|
635
|
+
assert_equal nil, seq.last_match[ii+1]
|
623
636
|
assert_equal matches.length, seq.last_match.length
|
624
637
|
assert_equal matches, seq.last_match.to_a
|
625
|
-
starts.each_with_index{|start,i|
|
638
|
+
starts.each_with_index{|start,i| ii=i
|
626
639
|
assert_equal start, seq.last_match.begin(i)
|
627
640
|
assert_equal start+matches[i].size, seq.last_match.end(i)
|
628
641
|
|
629
642
|
assert_equal start, seq.last_match.offset(i).first
|
630
643
|
assert_equal start+matches[i].size, seq.last_match.offset(i).last
|
631
644
|
}
|
632
|
-
assert_equal nil, seq.last_match.begin(
|
633
|
-
assert_equal nil, seq.last_match.end(
|
634
|
-
assert_equal nil, seq.last_match.offset(
|
645
|
+
assert_equal nil, seq.last_match.begin(ii+1)
|
646
|
+
assert_equal nil, seq.last_match.end(ii+1)
|
647
|
+
assert_equal nil, seq.last_match.offset(ii+1)
|
635
648
|
|
636
649
|
assert_equal pre, seq.last_match.pre_match[0..-1]
|
637
650
|
assert_equal post, seq.last_match.post_match[0..-1]
|
@@ -685,7 +698,7 @@ $Debug=true
|
|
685
698
|
}
|
686
699
|
end
|
687
700
|
|
688
|
-
|
701
|
+
def test_scanning
|
689
702
|
|
690
703
|
assert_equal "that ", a_seq.readahead(5)
|
691
704
|
|
data/test/test_seqrex.rb
CHANGED
@@ -85,31 +85,31 @@ end
|
|
85
85
|
oldVERBOSE=$VERBOSE
|
86
86
|
$VERBOSE=nil
|
87
87
|
eval <<'END'
|
88
|
-
_=@cu.group_anchors(/([\A[]|^asdf(df)s)/,true)
|
89
|
-
assert_equal "[/(?-mix:([\\A[]|(^)asdf(df)s))/, [2]]", _.inspect
|
88
|
+
_=@cu.group_anchors(/([\A[~]|^asdf(df)s)/,true)
|
89
|
+
assert_equal "[/(?-mix:([\\A[~]|(^)asdf(df)s))/, [2]]", _.inspect
|
90
90
|
|
91
|
-
_=@cu.group_anchors(/(\A|[z^[]asdf(df)s)/,nil)
|
92
|
-
assert_equal "[/(\\A|[z^[]asdf(df)s)/, []]", _.inspect
|
91
|
+
_=@cu.group_anchors(/(\A|[z^[~]asdf(df)s)/,nil)
|
92
|
+
assert_equal "[/(\\A|[z^[~]asdf(df)s)/, []]", _.inspect
|
93
93
|
|
94
|
-
_=@cu.group_anchors(/(\A|[z^[]asdf(df)s)/,true)
|
95
|
-
assert_equal "[/(?-mix:((?!)|[z^[]asdf(df)s))/, []]", _.inspect
|
94
|
+
_=@cu.group_anchors(/(\A|[z^[~]asdf(df)s)/,true)
|
95
|
+
assert_equal "[/(?-mix:((?!)|[z^[~]asdf(df)s))/, []]", _.inspect
|
96
96
|
|
97
|
-
_=@cu.group_anchors(/([\A[]|^asdf(df)s)/,nil)
|
98
|
-
assert_equal "[/([\\A[]|^asdf(df)s)/, []]", _.inspect
|
97
|
+
_=@cu.group_anchors(/([\A[~]|^asdf(df)s)/,nil)
|
98
|
+
assert_equal "[/([\\A[~]|^asdf(df)s)/, []]", _.inspect
|
99
99
|
END
|
100
100
|
$VERBOSE=oldVERBOSE
|
101
101
|
|
102
|
-
_=@cu.group_anchors(/([\A\[]|^asdf(df)s)/,true)
|
103
|
-
assert_equal "[/(?-mix:([\\A\\[]|(^)asdf(df)s))/, [2]]", _.inspect
|
102
|
+
_=@cu.group_anchors(/([\A\[~]|^asdf(df)s)/,true)
|
103
|
+
assert_equal "[/(?-mix:([\\A\\[~]|(^)asdf(df)s))/, [2]]", _.inspect
|
104
104
|
|
105
|
-
_=@cu.group_anchors(/(\A|[z^\[]asdf(df)s)/,nil)
|
106
|
-
assert_equal "[/(\\A|[z^\\[]asdf(df)s)/, []]", _.inspect
|
105
|
+
_=@cu.group_anchors(/(\A|[z^\[~]asdf(df)s)/,nil)
|
106
|
+
assert_equal "[/(\\A|[z^\\[~]asdf(df)s)/, []]", _.inspect
|
107
107
|
|
108
|
-
_=@cu.group_anchors(/(\A|[z^\[]asdf(df)s)/,true)
|
109
|
-
assert_equal "[/(?-mix:((?!)|[z^\\[]asdf(df)s))/, []]", _.inspect
|
108
|
+
_=@cu.group_anchors(/(\A|[z^\[~]asdf(df)s)/,true)
|
109
|
+
assert_equal "[/(?-mix:((?!)|[z^\\[~]asdf(df)s))/, []]", _.inspect
|
110
110
|
|
111
|
-
_=@cu.group_anchors(/([\A\[]|^asdf(df)s)/,nil)
|
112
|
-
assert_equal "[/([\\A\\[]|^asdf(df)s)/, []]", _.inspect
|
111
|
+
_=@cu.group_anchors(/([\A\[~]|^asdf(df)s)/,nil)
|
112
|
+
assert_equal "[/([\\A\\[~]|^asdf(df)s)/, []]", _.inspect
|
113
113
|
|
114
114
|
|
115
115
|
_=@cu.group_anchors(/([\A(]|^asdf(df)s)/,true)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sequence
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Caleb Clausen
|
@@ -9,30 +9,28 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-08-05 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
|
-
dependencies:
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
version_requirement:
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
20
|
-
requirements:
|
21
|
-
- - ">="
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: 1.12.2
|
24
|
-
version:
|
25
|
-
description: A unified wrapper api for accessing data in Strings, Arrays, Files, IOs, and Enumerations. Each sequence encapsulates some data and a current position within it. There are methods for moving the position, reading and writing data (with or without moving the position) forward or backward from the current position (or anywhere at all), scanning for patterns (like StringScanner, but it works in Files too, among others), and saving a position that will remain valid even after data is deleted or inserted elsewhere within the sequence. There are also some utility classes for making sequences reversed or circular, turning one-way sequences into two-way, buffering, and making sequences that are subsets or aggregations of existing sequences.
|
26
|
-
email: sequence-owner @at@ inforadical .dot. net
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: Sequence provides a unified api for access to sequential data types, like Strings, Arrays, Files, IOs, and Enumerations. Each sequence encapsulates some data and a current position within it. Some operations apply to data at (or relative to) the position, others are independant of position. The api contains operations for moving the position, reading and writing data (with or without moving the position) forward or backward from the current position or anywhere, scanning for patterns (like StringScanner, but it works in Files too, among others), and saving a position that will remain valid even after data is deleted or inserted elsewhere within the sequence. There are also some utility classes for making sequences reversed or circular, turning one-way sequences into two-way, buffering, and making sequences that are subsets or aggregations of existing sequences.
|
17
|
+
email: caleb (at) inforadical (dot) net
|
27
18
|
executables: []
|
28
19
|
|
29
20
|
extensions: []
|
30
21
|
|
31
22
|
extra_rdoc_files:
|
32
|
-
- Manifest.txt
|
33
23
|
- README.txt
|
34
|
-
-
|
24
|
+
- COPYING
|
25
|
+
- GPL
|
35
26
|
files:
|
27
|
+
- COPYING
|
28
|
+
- GPL
|
29
|
+
- History.txt
|
30
|
+
- Makefile
|
31
|
+
- Manifest.txt
|
32
|
+
- README.txt
|
33
|
+
- Rakefile
|
36
34
|
- lib/assert.rb
|
37
35
|
- lib/sequence.rb
|
38
36
|
- lib/sequence/arraylike.rb
|
@@ -57,6 +55,7 @@ files:
|
|
57
55
|
- lib/sequence/usedata.rb
|
58
56
|
- lib/sequence/version.rb
|
59
57
|
- lib/sequence/weakrefset.rb
|
58
|
+
- sequence.gemspec
|
60
59
|
- test/test.rb
|
61
60
|
- test/test_all.rb
|
62
61
|
- test/test_changes.rb
|
@@ -64,16 +63,11 @@ files:
|
|
64
63
|
- test/test_rexscan.rb
|
65
64
|
- test/test_seqrex.rb
|
66
65
|
- test/test_sequences.rb
|
67
|
-
- Rakefile
|
68
|
-
- Manifest.txt
|
69
|
-
- README.txt
|
70
|
-
- COPYING
|
71
|
-
- GPL
|
72
|
-
- History.txt
|
73
66
|
has_rdoc: true
|
74
|
-
homepage: http://
|
67
|
+
homepage: http://github.com/coatl/sequence
|
75
68
|
post_install_message:
|
76
69
|
rdoc_options:
|
70
|
+
- --inline-source
|
77
71
|
- --main
|
78
72
|
- README.txt
|
79
73
|
require_paths:
|