sequence 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -0
- data/History.txt +10 -0
- data/Makefile +1 -0
- data/README.txt +17 -13
- data/lib/assert.rb +1 -1
- data/lib/sequence.rb +591 -591
- data/lib/sequence/arraylike.rb +1 -1
- data/lib/sequence/buffered.rb +1 -1
- data/lib/sequence/circular.rb +48 -48
- data/lib/sequence/enum.rb +1 -1
- data/lib/sequence/file.rb +1 -8
- data/lib/sequence/functional.rb +2 -2
- data/lib/sequence/generator.rb +1 -0
- data/lib/sequence/indexed.rb +1 -1
- data/lib/sequence/io.rb +1 -1
- data/lib/sequence/list.rb +23 -10
- data/lib/sequence/ofhash.rb +1 -1
- data/lib/sequence/ofobjectivars.rb +1 -1
- data/lib/sequence/ofobjectmethods.rb +1 -1
- data/lib/sequence/position.rb +2 -2
- data/lib/sequence/reversed.rb +1 -1
- data/lib/sequence/shifting.rb +1 -1
- data/lib/sequence/singleitem.rb +1 -1
- data/lib/sequence/stringio.rb +9 -0
- data/lib/sequence/stringlike.rb +4 -2
- data/lib/sequence/subseq.rb +1 -1
- data/lib/sequence/usedata.rb +3 -3
- data/lib/sequence/version.rb +2 -2
- data/lib/sequence/weakrefset.rb +2 -2
- data/sequence.gemspec +5 -4
- data/test/test_all.rb +1 -1
- data/test/test_changes.rb +1 -1
- data/test/test_rexscan.rb +14 -17
- data/test/test_seqrex.rb +23 -16
- metadata +34 -31
data/lib/sequence/version.rb
CHANGED
data/lib/sequence/weakrefset.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# $Id$
|
2
|
-
# Copyright (C) 2006,2008 Caleb Clausen
|
2
|
+
# Copyright (C) 2006,2008, 2011 Caleb Clausen
|
3
3
|
# Distributed under the terms of Ruby's license.
|
4
4
|
|
5
5
|
#require 'yaml'
|
@@ -65,7 +65,7 @@ end
|
|
65
65
|
|
66
66
|
# add a weak reference to the set
|
67
67
|
def add(obj)
|
68
|
-
return self if include? obj
|
68
|
+
# return self if include? obj
|
69
69
|
# Symbol===obj || Fixnum===obj || nil==obj || true==obj || false==obj and
|
70
70
|
# raise ArgumentError, "no immediates in weakrefset"
|
71
71
|
id=ref obj
|
data/sequence.gemspec
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
|
-
require "#{
|
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] }
|
2
|
+
dir=File.dirname(__FILE__)
|
3
|
+
require "#{dir}/lib/sequence/version"
|
4
|
+
Sequence::Description=open("#{dir}/README.txt"){|f| f.read[/^==+ ?description[^\n]*?\n *\n?(.*?\n *\n.*?)\n *\n/im,1] }
|
5
|
+
Sequence::Latest_changes="###"+open("#{dir}/History.txt"){|f| f.read[/\A===(.*?)(?====)/m,1] }
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "sequence"
|
@@ -23,6 +23,7 @@ Gem::Specification.new do |s|
|
|
23
23
|
s.test_files = %w[test/test_all.rb]
|
24
24
|
s.summary = "A single api for reading and writing sequential data types."
|
25
25
|
s.description = Sequence::Description
|
26
|
+
s.license="GPL-2.0"
|
26
27
|
|
27
28
|
=begin
|
28
29
|
if s.respond_to? :specification_version then
|
data/test/test_all.rb
CHANGED
data/test/test_changes.rb
CHANGED
data/test/test_rexscan.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2006,2008 Caleb Clausen
|
1
|
+
# Copyright (C) 2006,2008, 2011 Caleb Clausen
|
2
2
|
# Distributed under the terms of Ruby's license.
|
3
3
|
$VERBOSE=1
|
4
4
|
require 'test/unit'
|
@@ -158,34 +158,31 @@ $Debug=true
|
|
158
158
|
end
|
159
159
|
|
160
160
|
class List < Indexed
|
161
|
-
def a_seq
|
162
|
-
|
163
|
-
seq = Sequence::List.new(DATA.scan(/.{1,8}/m).map{|str| str.to_sequence})
|
161
|
+
def a_seq
|
162
|
+
seq = Sequence::List.new(DATA.scan(chunk_regex).map{|str| str.to_sequence})
|
164
163
|
seq.pos=OFFSET
|
165
164
|
seq
|
166
165
|
end
|
167
166
|
|
167
|
+
def idx2chunknum(i,seq)
|
168
|
+
i/8
|
169
|
+
end
|
170
|
+
def chunk_regex; /.{1,8}/m end
|
171
|
+
|
168
172
|
def test__lookup_idx
|
169
173
|
seq=a_seq
|
170
174
|
(0..DATA.size).map{|i|
|
171
|
-
assert_equal i
|
175
|
+
assert_equal idx2chunknum(i,seq), seq._lookup_idx(i)
|
172
176
|
}
|
173
177
|
end
|
174
178
|
|
175
179
|
end
|
176
180
|
|
177
|
-
class ListMaxxed <
|
178
|
-
def
|
179
|
-
|
180
|
-
seq
|
181
|
-
|
182
|
-
seq
|
183
|
-
end
|
184
|
-
def test__lookup_idx
|
185
|
-
seq=a_seq
|
186
|
-
(0...DATA.size).map{|i|
|
187
|
-
assert_equal i, seq._lookup_idx(i)
|
188
|
-
}
|
181
|
+
class ListMaxxed < List
|
182
|
+
def chunk_regex; /./m end
|
183
|
+
def idx2chunknum(i,seq)
|
184
|
+
return seq.size-1 if i>=seq.size
|
185
|
+
i
|
189
186
|
end
|
190
187
|
end
|
191
188
|
|
data/test/test_seqrex.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2006 Caleb Clausen
|
1
|
+
# Copyright (C) 2006, 2011 Caleb Clausen
|
2
2
|
# Distributed under the terms of Ruby's license.
|
3
3
|
$VERBOSE=1
|
4
4
|
|
@@ -82,29 +82,36 @@ end
|
|
82
82
|
assert_equal "[/([\\A]|^asdf(df)s)/, []]", _.inspect
|
83
83
|
|
84
84
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
85
|
+
#yuck! supporting old ruby versions (<2.0) in this block.
|
86
|
+
#maybe just delete this?
|
87
|
+
begin
|
88
|
+
eval %{ /[[]/ }
|
89
|
+
rescue SyntaxError
|
90
|
+
open_bracket_in_char_class_needs_bs=true
|
91
|
+
end
|
92
|
+
oldVERBOSE=$VERBOSE
|
93
|
+
$VERBOSE=nil
|
94
|
+
eval <<-'END' unless open_bracket_in_char_class_needs_bs
|
95
|
+
_=@cu.group_anchors(/([\A[~]|^asdf(df)s)/,true)
|
96
|
+
assert_equal "[/(?-mix:([\\A[~]|(^)asdf(df)s))/, [2]]", _.inspect
|
90
97
|
|
91
|
-
|
92
|
-
|
98
|
+
_=@cu.group_anchors(/(\A|[z^[~]asdf(df)s)/,nil)
|
99
|
+
assert_equal "[/(\\A|[z^[~]asdf(df)s)/, []]", _.inspect
|
93
100
|
|
94
|
-
|
95
|
-
|
101
|
+
_=@cu.group_anchors(/(\A|[z^[~]asdf(df)s)/,true)
|
102
|
+
assert_equal "[/(?-mix:((?!)|[z^[~]asdf(df)s))/, []]", _.inspect
|
96
103
|
|
97
|
-
|
98
|
-
|
99
|
-
END
|
100
|
-
$VERBOSE=oldVERBOSE
|
104
|
+
_=@cu.group_anchors(/([\A[~]|^asdf(df)s)/,nil)
|
105
|
+
assert_equal "[/([\\A[~]|^asdf(df)s)/, []]", _.inspect
|
106
|
+
END
|
107
|
+
$VERBOSE=oldVERBOSE
|
101
108
|
|
102
109
|
_=@cu.group_anchors(/([\A\[~]|^asdf(df)s)/,true)
|
103
110
|
assert_equal "[/(?-mix:([\\A\\[~]|(^)asdf(df)s))/, [2]]", _.inspect
|
104
|
-
|
111
|
+
|
105
112
|
_=@cu.group_anchors(/(\A|[z^\[~]asdf(df)s)/,nil)
|
106
113
|
assert_equal "[/(\\A|[z^\\[~]asdf(df)s)/, []]", _.inspect
|
107
|
-
|
114
|
+
|
108
115
|
_=@cu.group_anchors(/(\A|[z^\[~]asdf(df)s)/,true)
|
109
116
|
assert_equal "[/(?-mix:((?!)|[z^\\[~]asdf(df)s))/, []]", _.inspect
|
110
117
|
|
metadata
CHANGED
@@ -1,29 +1,32 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: sequence
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
|
-
authors:
|
6
|
+
authors:
|
7
7
|
- Caleb Clausen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
|
12
|
-
date: 2010-01-03 00:00:00 -08:00
|
13
|
-
default_executable:
|
11
|
+
date: 2016-05-19 00:00:00.000000000 Z
|
14
12
|
dependencies: []
|
15
|
-
|
16
|
-
|
13
|
+
description: "Sequence provides a unified api for access to sequential data types,
|
14
|
+
like\nStrings, Arrays, Files, IOs, and Enumerations. This is the external \niterator
|
15
|
+
pattern (ruby's usual iterators are internal). Each sequence \nencapsulates some
|
16
|
+
data and a current position within it. Some operations \napply to data at (or relative
|
17
|
+
to) the position, others are independant \nof position. The api contains operations
|
18
|
+
for moving the position, and \nreading and writing data (with or without moving
|
19
|
+
the position) forward \nor backward from the current position or anywhere.\n\nIts
|
20
|
+
perhaps most unusual feature is the ability to scan for Regexps in\nnot just Strings,
|
21
|
+
but Files and any other type of sequence. "
|
17
22
|
email: caleb (at) inforadical (dot) net
|
18
23
|
executables: []
|
19
|
-
|
20
24
|
extensions: []
|
21
|
-
|
22
|
-
extra_rdoc_files:
|
25
|
+
extra_rdoc_files:
|
23
26
|
- README.txt
|
24
27
|
- COPYING
|
25
28
|
- GPL
|
26
|
-
files:
|
29
|
+
files:
|
27
30
|
- COPYING
|
28
31
|
- GPL
|
29
32
|
- History.txt
|
@@ -49,6 +52,7 @@ files:
|
|
49
52
|
- lib/sequence/reversed.rb
|
50
53
|
- lib/sequence/shifting.rb
|
51
54
|
- lib/sequence/singleitem.rb
|
55
|
+
- lib/sequence/stringio.rb
|
52
56
|
- lib/sequence/stringlike.rb
|
53
57
|
- lib/sequence/subseq.rb
|
54
58
|
- lib/sequence/usedata.rb
|
@@ -62,32 +66,31 @@ files:
|
|
62
66
|
- test/test_rexscan.rb
|
63
67
|
- test/test_seqrex.rb
|
64
68
|
- test/test_sequences.rb
|
65
|
-
has_rdoc: true
|
66
69
|
homepage: http://github.com/coatl/sequence
|
70
|
+
licenses:
|
71
|
+
- GPL-2.0
|
72
|
+
metadata: {}
|
67
73
|
post_install_message:
|
68
|
-
rdoc_options:
|
69
|
-
- --main
|
74
|
+
rdoc_options:
|
75
|
+
- "--main"
|
70
76
|
- README.txt
|
71
|
-
require_paths:
|
77
|
+
require_paths:
|
72
78
|
- lib
|
73
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
74
|
-
requirements:
|
79
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
75
81
|
- - ">="
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
version:
|
78
|
-
|
79
|
-
|
80
|
-
requirements:
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
81
86
|
- - ">="
|
82
|
-
- !ruby/object:Gem::Version
|
83
|
-
version:
|
84
|
-
version:
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
85
89
|
requirements: []
|
86
|
-
|
87
90
|
rubyforge_project: sequence
|
88
|
-
rubygems_version:
|
91
|
+
rubygems_version: 2.5.1
|
89
92
|
signing_key:
|
90
|
-
specification_version:
|
93
|
+
specification_version: 4
|
91
94
|
summary: A single api for reading and writing sequential data types.
|
92
|
-
test_files:
|
95
|
+
test_files:
|
93
96
|
- test/test_all.rb
|