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 CHANGED
@@ -68,7 +68,7 @@ Clustering overlaps maintains attributes.
68
68
 
69
69
  == Installation
70
70
 
71
- You can install Position Range with the following command:
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 Position Range homepage is http://positionrange.rubyforge.org.
85
+ The PositionRange homepage is http://positionrange.rubyforge.org.
86
86
 
87
- For the latest news on Position Range:
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
- Position Range and these docs are Copyright (c) 2006-2009 The LogiLogi
103
- Foundation. Position Range is licensed under the {GNU Lesser General
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 Position Range in an application that is not Free Software
109
- but Position Range itself remains Free Software.
108
+ You can use PositionRange in an application that is not Free Software
109
+ but PositionRange itself remains Free Software.
data/Rakefile CHANGED
@@ -67,7 +67,7 @@ Rake::GemPackageTask.new(spec) do |p|
67
67
  p.need_zip = true
68
68
  end
69
69
 
70
- desc "Publish the docs, gem, and release files"
70
+ desc "Build and publish the docs, gem, and release files"
71
71
  task :deploy => [:release, :pdoc] do
72
72
  puts 'Published gem'
73
73
  end
@@ -1,15 +1,13 @@
1
1
  #--#
2
- # Copyright: (c) 2006-2008 The LogiLogi Foundation <foundation@logilogi.org>
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 of
7
- # the GNU Affero General Public License version 3. The Affero GPL states
8
- # that running a modified version or a derivative work also requires you to
9
- # make the sourcecode of that work available to everyone that can interact
10
- # with it. We chose the Affero GPL to ensure that PositionRange remains open
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.
@@ -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 non-overlapping borders between
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!
@@ -1,8 +1,8 @@
1
1
  module PositionRange
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
- MINOR = 6
5
- TINY = 7
4
+ MINOR = 7
5
+ TINY = 0
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -1,15 +1,13 @@
1
1
  #--#
2
- # Copyright: (c) 2006-2008 The LogiLogi Foundation <foundation@logilogi.org>
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 of
7
- # the GNU Affero General Public License version 3. The Affero GPL states
8
- # that running a modified version or a derivative work also requires you to
9
- # make the sourcecode of that work available to everyone that can interact
10
- # with it. We chose the Affero GPL to ensure that PositionRange remains open
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,59:15,20'),
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,59'),
384
- PositionRange::List.from_s('11,20'))
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
@@ -1,15 +1,13 @@
1
1
  #--#
2
- # Copyright: (c) 2006-2008 The LogiLogi Foundation <foundation@logilogi.org>
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 of
7
- # the GNU Affero General Public License version 3. The Affero GPL states
8
- # that running a modified version or a derivative work also requires you to
9
- # make the sourcecode of that work available to everyone that can interact
10
- # with it. We chose the Affero GPL to ensure that PositionRange remains open
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.6.7
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: 2009-06-06 00:00:00 +02:00
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.4
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.