positionrange 0.6.7 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README +7 -7
- data/Rakefile +1 -1
- data/lib/position_range/error.rb +7 -9
- data/lib/position_range/list.rb +35 -1
- data/lib/position_range/version.rb +2 -2
- data/lib/position_range.rb +7 -9
- data/test/position_range_list_test.rb +26 -3
- data/test/position_range_test.rb +7 -9
- metadata +6 -6
data/README
CHANGED
@@ -68,7 +68,7 @@ Clustering overlaps maintains attributes.
|
|
68
68
|
|
69
69
|
== Installation
|
70
70
|
|
71
|
-
You can install
|
71
|
+
You can install PositionRange with the following command:
|
72
72
|
|
73
73
|
% [sudo] gem install positionrange
|
74
74
|
|
@@ -82,9 +82,9 @@ And then from its distribution directory installed with:
|
|
82
82
|
|
83
83
|
== Support
|
84
84
|
|
85
|
-
The
|
85
|
+
The PositionRange homepage is http://positionrange.rubyforge.org.
|
86
86
|
|
87
|
-
For the latest news on
|
87
|
+
For the latest news on PositionRange:
|
88
88
|
|
89
89
|
* http://foundation.logilogi.org/tags/PositionRange
|
90
90
|
|
@@ -99,11 +99,11 @@ This documentation can be browsed online at:
|
|
99
99
|
|
100
100
|
== Copyrights
|
101
101
|
|
102
|
-
|
103
|
-
Foundation.
|
102
|
+
PositionRange and these docs are Copyright (c) 2006-2009 The LogiLogi
|
103
|
+
Foundation. PositionRange is licensed under the {GNU Lesser General
|
104
104
|
Public License}[http://www.gnu.org/licenses/lgpl-3.0-standalone.html].
|
105
105
|
These docs are available under the {Creative Commons Attribution-Share
|
106
106
|
Alike License}[http://creativecommons.org/licenses/by-sa/3.0/].
|
107
107
|
|
108
|
-
You can use
|
109
|
-
but
|
108
|
+
You can use PositionRange in an application that is not Free Software
|
109
|
+
but PositionRange itself remains Free Software.
|
data/Rakefile
CHANGED
data/lib/position_range/error.rb
CHANGED
@@ -1,15 +1,13 @@
|
|
1
1
|
#--#
|
2
|
-
# Copyright: (c) 2006-
|
2
|
+
# Copyright: (c) 2006-2009 The LogiLogi Foundation <foundation@logilogi.org>
|
3
3
|
#
|
4
4
|
# License:
|
5
|
-
# This file is part of the PositionRange Library. PositionRange is Free
|
6
|
-
# Software. You can run/distribute/modify PositionRange under the terms
|
7
|
-
# the GNU
|
8
|
-
# that
|
9
|
-
#
|
10
|
-
#
|
11
|
-
# and libre (LICENSE.txt contains the full text of the legally binding
|
12
|
-
# license).
|
5
|
+
# This file is part of the PositionRange Library. PositionRange is Free
|
6
|
+
# Software. You can run/distribute/modify PositionRange under the terms
|
7
|
+
# of the GNU Lesser General Public License version 3. This license
|
8
|
+
# states that you can use PositionRange in applications that are not Free
|
9
|
+
# Software but PositionRange itself remains Free Software. (LICENSE contains
|
10
|
+
# the full text of the legally binding license).
|
13
11
|
#++#
|
14
12
|
#
|
15
13
|
# This Error is raised if positions are out of range.
|
data/lib/position_range/list.rb
CHANGED
@@ -270,7 +270,7 @@ class PositionRange::List < Array
|
|
270
270
|
self.dup.invert!(maximum_size)
|
271
271
|
end
|
272
272
|
|
273
|
-
# Makes sure that there are no
|
273
|
+
# Makes sure that there are no overlapping borders between
|
274
274
|
# PositionRanges.
|
275
275
|
#
|
276
276
|
# The guaranteed situation after calling this method:
|
@@ -401,6 +401,9 @@ class PositionRange::List < Array
|
|
401
401
|
'of different range_sizes: ' + ranges_to_insert.to_s + ', ' +
|
402
402
|
ranges_at_which_to_insert.to_s
|
403
403
|
end
|
404
|
+
ranges_to_insert.align_chunks!(ranges_at_which_to_insert)
|
405
|
+
ranges_at_which_to_insert.align_chunks!(ranges_to_insert)
|
406
|
+
|
404
407
|
ranges_to_act = ranges_at_which_to_insert.each {|p_r| p_r.action = :ins}.concat(
|
405
408
|
ranges_to_skip).sort!
|
406
409
|
|
@@ -433,6 +436,37 @@ class PositionRange::List < Array
|
|
433
436
|
return self
|
434
437
|
end
|
435
438
|
|
439
|
+
# Ensures that the other list and this list don't have any
|
440
|
+
# overlapping chunks, considering their size.
|
441
|
+
#
|
442
|
+
# So PositionRange::List.from_s('10,20:50,70').align_chunks!(
|
443
|
+
# PositionRange::List.from_s('20,30:200,210,550,560'))
|
444
|
+
#
|
445
|
+
# will result in:
|
446
|
+
# PositionRange::List.from_s('10,20:50,60:60,70')
|
447
|
+
#
|
448
|
+
def align_chunks!(other_ranges)
|
449
|
+
i = -1
|
450
|
+
self_p = 0
|
451
|
+
other_p = 0
|
452
|
+
other_ranges.each {|p_r|
|
453
|
+
i += 1
|
454
|
+
if !self[i]
|
455
|
+
return self
|
456
|
+
end
|
457
|
+
other_p += p_r.size
|
458
|
+
self_p += self[i].size
|
459
|
+
if self_p > other_p
|
460
|
+
copy = self[i]
|
461
|
+
cut = self[i].begin + p_r.size
|
462
|
+
self[i] = copy.new_dup(copy.begin, cut)
|
463
|
+
self.insert(i + 1, copy.new_dup(cut, copy.end))
|
464
|
+
self_p = other_p
|
465
|
+
end
|
466
|
+
}
|
467
|
+
return self
|
468
|
+
end
|
469
|
+
|
436
470
|
# Inserting at ranges returning a new list.
|
437
471
|
#
|
438
472
|
# See insert_at_ranges!
|
data/lib/position_range.rb
CHANGED
@@ -1,15 +1,13 @@
|
|
1
1
|
#--#
|
2
|
-
# Copyright: (c) 2006-
|
2
|
+
# Copyright: (c) 2006-2009 The LogiLogi Foundation <foundation@logilogi.org>
|
3
3
|
#
|
4
4
|
# License:
|
5
|
-
# This file is part of the PositionRange Library. PositionRange is Free
|
6
|
-
# Software. You can run/distribute/modify PositionRange under the terms
|
7
|
-
# the GNU
|
8
|
-
# that
|
9
|
-
#
|
10
|
-
#
|
11
|
-
# and libre (LICENSE.txt contains the full text of the legally binding
|
12
|
-
# license).
|
5
|
+
# This file is part of the PositionRange Library. PositionRange is Free
|
6
|
+
# Software. You can run/distribute/modify PositionRange under the terms
|
7
|
+
# of the GNU Lesser General Public License version 3. This license
|
8
|
+
# states that you can use PositionRange in applications that are not Free
|
9
|
+
# Software but PositionRange itself remains Free Software. (LICENSE contains
|
10
|
+
# the full text of the legally binding license).
|
13
11
|
#++#
|
14
12
|
#
|
15
13
|
# PositionRanges allow one to model ranges of text.
|
@@ -378,10 +378,10 @@ class PositionRangeListTest < Test::Unit::TestCase
|
|
378
378
|
|
379
379
|
def test_insert_at_ranges
|
380
380
|
# Without skipping
|
381
|
-
assert_equal PositionRange::List.from_s('0,10:50,
|
381
|
+
assert_equal PositionRange::List.from_s('0,10:50,60:15,20'),
|
382
382
|
PositionRange::List.from_s('0,10:15,20').insert_at_ranges!(
|
383
|
-
PositionRange::List.from_s('50,
|
384
|
-
PositionRange::List.from_s('
|
383
|
+
PositionRange::List.from_s('50,60'),
|
384
|
+
PositionRange::List.from_s('10,20'))
|
385
385
|
|
386
386
|
# With skipping
|
387
387
|
assert_equal PositionRange::List.from_s('39,49:100,102:6,7:16,20'),
|
@@ -414,6 +414,12 @@ class PositionRangeListTest < Test::Unit::TestCase
|
|
414
414
|
PositionRange::List.from_s('20,30:40,50'),
|
415
415
|
PositionRange::List.from_s('800,810:850,860'))
|
416
416
|
|
417
|
+
# error-case
|
418
|
+
assert_equal PositionRange::List.from_s('0,10:50,59:15,20:59,68'),
|
419
|
+
PositionRange::List.from_s('0,10:15,20').insert_at_ranges!(
|
420
|
+
PositionRange::List.from_s('50,68'),
|
421
|
+
PositionRange::List.from_s('11,20:25,34'))
|
422
|
+
|
417
423
|
# dup-alternatives
|
418
424
|
p = PositionRange::List.from_s('0,10:15,20')
|
419
425
|
to_p = PositionRange::List.from_s('0,10:50,59:15,20')
|
@@ -429,6 +435,23 @@ class PositionRangeListTest < Test::Unit::TestCase
|
|
429
435
|
assert_equal p, to_p
|
430
436
|
end
|
431
437
|
|
438
|
+
def test_align_chunks
|
439
|
+
# standard case
|
440
|
+
assert_equal PositionRange::List.from_s('10,20:50,60:60,70'),
|
441
|
+
PositionRange::List.from_s('10,20:50,70').align_chunks!(
|
442
|
+
PositionRange::List.from_s('20,30:200,210:550,560'))
|
443
|
+
|
444
|
+
# self longer
|
445
|
+
assert_equal PositionRange::List.from_s('10,20:50,60:60,70:70,80'),
|
446
|
+
PositionRange::List.from_s('10,20:50,80').align_chunks!(
|
447
|
+
PositionRange::List.from_s('20,30:200,210:550,560'))
|
448
|
+
|
449
|
+
# other longer
|
450
|
+
assert_equal PositionRange::List.from_s('10,20:50,60:60,70'),
|
451
|
+
PositionRange::List.from_s('10,20:50,70').align_chunks!(
|
452
|
+
PositionRange::List.from_s('20,30:200,210:550,590'))
|
453
|
+
end
|
454
|
+
|
432
455
|
### Highlevel methods
|
433
456
|
|
434
457
|
def test_translate_to_view
|
data/test/position_range_test.rb
CHANGED
@@ -1,15 +1,13 @@
|
|
1
1
|
#--#
|
2
|
-
# Copyright: (c) 2006-
|
2
|
+
# Copyright: (c) 2006-2009 The LogiLogi Foundation <foundation@logilogi.org>
|
3
3
|
#
|
4
4
|
# License:
|
5
|
-
# This file is part of the PositionRange Library. PositionRange is
|
6
|
-
#
|
7
|
-
# the GNU
|
8
|
-
# that
|
9
|
-
#
|
10
|
-
#
|
11
|
-
# and libre (LICENSE.txt contains the full text of the legally binding
|
12
|
-
# license).
|
5
|
+
# This file is part of the PositionRange Library. PositionRange is Free
|
6
|
+
# Software. You can run/distribute/modify PositionRange under the terms
|
7
|
+
# of the GNU Lesser General Public License version 3. This license
|
8
|
+
# states that you can use PositionRange in applications that are not Free
|
9
|
+
# Software but PositionRange itself remains Free Software. (LICENSE contains
|
10
|
+
# the full text of the legally binding license).
|
13
11
|
#++#
|
14
12
|
|
15
13
|
require File.dirname(__FILE__) + '/test_helper.rb'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: positionrange
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wybo Wiersma
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2010-02-02 00:00:00 +00:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -27,14 +27,14 @@ files:
|
|
27
27
|
- README
|
28
28
|
- CHANGELOG
|
29
29
|
- LICENSE
|
30
|
-
- lib/position_range.rb
|
31
|
-
- lib/position_range/version.rb
|
32
30
|
- lib/position_range/error.rb
|
33
31
|
- lib/position_range/list.rb
|
32
|
+
- lib/position_range/version.rb
|
33
|
+
- lib/position_range.rb
|
34
34
|
- lib/positionrange.rb
|
35
|
+
- test/test_helper.rb
|
35
36
|
- test/position_range_list_test.rb
|
36
37
|
- test/position_range_test.rb
|
37
|
-
- test/test_helper.rb
|
38
38
|
has_rdoc: true
|
39
39
|
homepage: http://positionrange.rubyforge.org
|
40
40
|
licenses: []
|
@@ -59,7 +59,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
59
59
|
requirements:
|
60
60
|
- none
|
61
61
|
rubyforge_project: positionrange
|
62
|
-
rubygems_version: 1.3.
|
62
|
+
rubygems_version: 1.3.5
|
63
63
|
signing_key:
|
64
64
|
specification_version: 3
|
65
65
|
summary: Ranges with attributes that can be juggled.
|