positionrange 0.7.0 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +14 -0
- data/CHANGELOG +14 -5
- data/Gemfile +4 -0
- data/LICENSE +22 -165
- data/{README → README.md} +23 -35
- data/Rakefile +5 -90
- data/lib/position_range.rb +12 -21
- data/lib/position_range/error.rb +0 -14
- data/lib/position_range/list.rb +3 -23
- data/lib/position_range/version.rb +2 -8
- data/positionrange.gemspec +20 -0
- data/test/helper.rb +5 -0
- data/test/{position_range_test.rb → test_position_range.rb} +2 -13
- data/test/{position_range_list_test.rb → test_position_range_list.rb} +2 -15
- metadata +80 -23
- data/install.rb +0 -30
- data/test/test_helper.rb +0 -3
data/.gitignore
ADDED
data/CHANGELOG
CHANGED
@@ -1,13 +1,22 @@
|
|
1
|
-
*0.
|
1
|
+
*0.7.1* (24 June 2012)
|
2
|
+
|
3
|
+
* Fixed bug with sort returning an Array rather than the original List in
|
4
|
+
Ruby 1.9.3
|
5
|
+
* Updated docs
|
6
|
+
* Moved to Github
|
7
|
+
* Re-released using bundler
|
8
|
+
* Re-licensed under MIT license
|
9
|
+
|
10
|
+
|
11
|
+
*0.6.6* (4 June 2009)
|
2
12
|
|
3
13
|
* Fixed rdoc-generation bug in README
|
4
14
|
|
5
15
|
|
6
|
-
*0.6.
|
16
|
+
*0.6.5* (26 May 2009)
|
7
17
|
|
8
|
-
*
|
9
|
-
*
|
10
|
-
* Changed license to LGPL v3
|
18
|
+
* Updated README
|
19
|
+
* Re-licensed to LGPL v3
|
11
20
|
|
12
21
|
|
13
22
|
*0.6.3* (4 February 2009)
|
data/Gemfile
ADDED
data/LICENSE
CHANGED
@@ -1,165 +1,22 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
of this
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
by the Library, but which is not otherwise based on the Library.
|
24
|
-
Defining a subclass of a class defined by the Library is deemed a mode
|
25
|
-
of using an interface provided by the Library.
|
26
|
-
|
27
|
-
A "Combined Work" is a work produced by combining or linking an
|
28
|
-
Application with the Library. The particular version of the Library
|
29
|
-
with which the Combined Work was made is also called the "Linked
|
30
|
-
Version".
|
31
|
-
|
32
|
-
The "Minimal Corresponding Source" for a Combined Work means the
|
33
|
-
Corresponding Source for the Combined Work, excluding any source code
|
34
|
-
for portions of the Combined Work that, considered in isolation, are
|
35
|
-
based on the Application, and not on the Linked Version.
|
36
|
-
|
37
|
-
The "Corresponding Application Code" for a Combined Work means the
|
38
|
-
object code and/or source code for the Application, including any data
|
39
|
-
and utility programs needed for reproducing the Combined Work from the
|
40
|
-
Application, but excluding the System Libraries of the Combined Work.
|
41
|
-
|
42
|
-
1. Exception to Section 3 of the GNU GPL.
|
43
|
-
|
44
|
-
You may convey a covered work under sections 3 and 4 of this License
|
45
|
-
without being bound by section 3 of the GNU GPL.
|
46
|
-
|
47
|
-
2. Conveying Modified Versions.
|
48
|
-
|
49
|
-
If you modify a copy of the Library, and, in your modifications, a
|
50
|
-
facility refers to a function or data to be supplied by an Application
|
51
|
-
that uses the facility (other than as an argument passed when the
|
52
|
-
facility is invoked), then you may convey a copy of the modified
|
53
|
-
version:
|
54
|
-
|
55
|
-
a) under this License, provided that you make a good faith effort to
|
56
|
-
ensure that, in the event an Application does not supply the
|
57
|
-
function or data, the facility still operates, and performs
|
58
|
-
whatever part of its purpose remains meaningful, or
|
59
|
-
|
60
|
-
b) under the GNU GPL, with none of the additional permissions of
|
61
|
-
this License applicable to that copy.
|
62
|
-
|
63
|
-
3. Object Code Incorporating Material from Library Header Files.
|
64
|
-
|
65
|
-
The object code form of an Application may incorporate material from
|
66
|
-
a header file that is part of the Library. You may convey such object
|
67
|
-
code under terms of your choice, provided that, if the incorporated
|
68
|
-
material is not limited to numerical parameters, data structure
|
69
|
-
layouts and accessors, or small macros, inline functions and templates
|
70
|
-
(ten or fewer lines in length), you do both of the following:
|
71
|
-
|
72
|
-
a) Give prominent notice with each copy of the object code that the
|
73
|
-
Library is used in it and that the Library and its use are
|
74
|
-
covered by this License.
|
75
|
-
|
76
|
-
b) Accompany the object code with a copy of the GNU GPL and this license
|
77
|
-
document.
|
78
|
-
|
79
|
-
4. Combined Works.
|
80
|
-
|
81
|
-
You may convey a Combined Work under terms of your choice that,
|
82
|
-
taken together, effectively do not restrict modification of the
|
83
|
-
portions of the Library contained in the Combined Work and reverse
|
84
|
-
engineering for debugging such modifications, if you also do each of
|
85
|
-
the following:
|
86
|
-
|
87
|
-
a) Give prominent notice with each copy of the Combined Work that
|
88
|
-
the Library is used in it and that the Library and its use are
|
89
|
-
covered by this License.
|
90
|
-
|
91
|
-
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
92
|
-
document.
|
93
|
-
|
94
|
-
c) For a Combined Work that displays copyright notices during
|
95
|
-
execution, include the copyright notice for the Library among
|
96
|
-
these notices, as well as a reference directing the user to the
|
97
|
-
copies of the GNU GPL and this license document.
|
98
|
-
|
99
|
-
d) Do one of the following:
|
100
|
-
|
101
|
-
0) Convey the Minimal Corresponding Source under the terms of this
|
102
|
-
License, and the Corresponding Application Code in a form
|
103
|
-
suitable for, and under terms that permit, the user to
|
104
|
-
recombine or relink the Application with a modified version of
|
105
|
-
the Linked Version to produce a modified Combined Work, in the
|
106
|
-
manner specified by section 6 of the GNU GPL for conveying
|
107
|
-
Corresponding Source.
|
108
|
-
|
109
|
-
1) Use a suitable shared library mechanism for linking with the
|
110
|
-
Library. A suitable mechanism is one that (a) uses at run time
|
111
|
-
a copy of the Library already present on the user's computer
|
112
|
-
system, and (b) will operate properly with a modified version
|
113
|
-
of the Library that is interface-compatible with the Linked
|
114
|
-
Version.
|
115
|
-
|
116
|
-
e) Provide Installation Information, but only if you would otherwise
|
117
|
-
be required to provide such information under section 6 of the
|
118
|
-
GNU GPL, and only to the extent that such information is
|
119
|
-
necessary to install and execute a modified version of the
|
120
|
-
Combined Work produced by recombining or relinking the
|
121
|
-
Application with a modified version of the Linked Version. (If
|
122
|
-
you use option 4d0, the Installation Information must accompany
|
123
|
-
the Minimal Corresponding Source and Corresponding Application
|
124
|
-
Code. If you use option 4d1, you must provide the Installation
|
125
|
-
Information in the manner specified by section 6 of the GNU GPL
|
126
|
-
for conveying Corresponding Source.)
|
127
|
-
|
128
|
-
5. Combined Libraries.
|
129
|
-
|
130
|
-
You may place library facilities that are a work based on the
|
131
|
-
Library side by side in a single library together with other library
|
132
|
-
facilities that are not Applications and are not covered by this
|
133
|
-
License, and convey such a combined library under terms of your
|
134
|
-
choice, if you do both of the following:
|
135
|
-
|
136
|
-
a) Accompany the combined library with a copy of the same work based
|
137
|
-
on the Library, uncombined with any other library facilities,
|
138
|
-
conveyed under the terms of this License.
|
139
|
-
|
140
|
-
b) Give prominent notice with the combined library that part of it
|
141
|
-
is a work based on the Library, and explaining where to find the
|
142
|
-
accompanying uncombined form of the same work.
|
143
|
-
|
144
|
-
6. Revised Versions of the GNU Lesser General Public License.
|
145
|
-
|
146
|
-
The Free Software Foundation may publish revised and/or new versions
|
147
|
-
of the GNU Lesser General Public License from time to time. Such new
|
148
|
-
versions will be similar in spirit to the present version, but may
|
149
|
-
differ in detail to address new problems or concerns.
|
150
|
-
|
151
|
-
Each version is given a distinguishing version number. If the
|
152
|
-
Library as you received it specifies that a certain numbered version
|
153
|
-
of the GNU Lesser General Public License "or any later version"
|
154
|
-
applies to it, you have the option of following the terms and
|
155
|
-
conditions either of that published version or of any later version
|
156
|
-
published by the Free Software Foundation. If the Library as you
|
157
|
-
received it does not specify a version number of the GNU Lesser
|
158
|
-
General Public License, you may choose any version of the GNU Lesser
|
159
|
-
General Public License ever published by the Free Software Foundation.
|
160
|
-
|
161
|
-
If the Library as you received it specifies that a proxy can decide
|
162
|
-
whether future versions of the GNU Lesser General Public License shall
|
163
|
-
apply, that proxy's public statement of acceptance of any version is
|
164
|
-
permanent authorization for you to choose that version for the
|
165
|
-
Library.
|
1
|
+
Copyright (c) 2012 Wybo Wiersma
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/{README → README.md}
RENAMED
@@ -1,19 +1,19 @@
|
|
1
|
-
|
1
|
+
# Position Range
|
2
2
|
"Ranges with attributes that can be juggled"
|
3
3
|
|
4
|
-
Allows
|
5
|
-
lists. Also adds parsing from string, but most
|
4
|
+
Allows one to assign random attributes to ranges and juggle them in
|
5
|
+
lists. Also adds parsing from string, but most interesting when used in
|
6
6
|
a PositionRange::List.
|
7
7
|
|
8
|
-
|
9
|
-
|
8
|
+
In lists standard set operations can be applied to them, like
|
9
|
+
addition, substraction and intersection. In addition one can also get the
|
10
10
|
combined size of all the ranges in the list. And cluster overlapping
|
11
11
|
ranges, maintaining the attributes (more below).
|
12
12
|
|
13
13
|
PositionRange is a library by the LogiLogi Foundation, extracted from
|
14
14
|
http://www.logilogi.org (http://foundation.logilogi.org).
|
15
15
|
|
16
|
-
|
16
|
+
## Usage
|
17
17
|
|
18
18
|
First require it.
|
19
19
|
|
@@ -66,44 +66,32 @@ Clustering overlaps maintains attributes.
|
|
66
66
|
> l.cluster_overlaps == output
|
67
67
|
=> true
|
68
68
|
|
69
|
-
|
69
|
+
## Installation
|
70
70
|
|
71
|
-
|
71
|
+
Add this line to your application's Gemfile:
|
72
72
|
|
73
|
-
|
73
|
+
gem 'positionrange'
|
74
74
|
|
75
|
-
|
75
|
+
And then execute:
|
76
76
|
|
77
|
-
|
77
|
+
$ bundle
|
78
78
|
|
79
|
-
|
79
|
+
Or install it yourself as:
|
80
80
|
|
81
|
-
|
81
|
+
$ gem install positionrange
|
82
82
|
|
83
|
-
|
84
|
-
|
85
|
-
The PositionRange homepage is http://positionrange.rubyforge.org.
|
86
|
-
|
87
|
-
For the latest news on PositionRange:
|
83
|
+
Feel free to report issues and to ask questions. For the latest news on
|
84
|
+
PositionRange:
|
88
85
|
|
89
86
|
* http://foundation.logilogi.org/tags/PositionRange
|
90
87
|
|
91
|
-
|
92
|
-
remember to update the corresponding unit tests.
|
93
|
-
|
94
|
-
== This Documentation
|
95
|
-
|
96
|
-
This documentation can be browsed online at:
|
97
|
-
|
98
|
-
* http://positionrange.rubyforge.org
|
99
|
-
|
100
|
-
== Copyrights
|
88
|
+
## Contributing
|
101
89
|
|
102
|
-
|
103
|
-
|
104
|
-
Public License}[http://www.gnu.org/licenses/lgpl-3.0-standalone.html].
|
105
|
-
These docs are available under the {Creative Commons Attribution-Share
|
106
|
-
Alike License}[http://creativecommons.org/licenses/by-sa/3.0/].
|
90
|
+
If you wish to contribute, please create a pull-request and remember to update
|
91
|
+
the corresponding unit test(s).
|
107
92
|
|
108
|
-
|
109
|
-
|
93
|
+
1. Fork it
|
94
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
95
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
96
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
97
|
+
5. Create new Pull Request
|
data/Rakefile
CHANGED
@@ -1,91 +1,6 @@
|
|
1
|
-
|
2
|
-
require
|
3
|
-
require 'rake/testtask'
|
4
|
-
require 'rake/rdoctask'
|
5
|
-
require 'rake/packagetask'
|
6
|
-
require 'rake/gempackagetask'
|
7
|
-
require 'rake/contrib/sshpublisher'
|
8
|
-
require File.join(File.dirname(__FILE__), 'lib', 'position_range', 'version')
|
9
|
-
|
10
|
-
PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
|
11
|
-
PKG_NAME = 'positionrange'
|
12
|
-
PKG_VERSION = PositionRange::VERSION::STRING + PKG_BUILD
|
13
|
-
PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
|
14
|
-
|
15
|
-
RELEASE_NAME = "REL #{PKG_VERSION}"
|
16
|
-
|
17
|
-
RUBY_FORGE_PROJECT = "positionrange"
|
18
|
-
RUBY_FORGE_USER = "wybow"
|
19
|
-
|
20
|
-
desc "Default Task"
|
21
|
-
task :default => [ :test ]
|
22
|
-
|
23
|
-
# Run the unit tests
|
24
|
-
Rake::TestTask.new { |t|
|
25
|
-
t.libs << "test"
|
26
|
-
t.pattern = 'test/*_test.rb'
|
27
|
-
t.verbose = true
|
28
|
-
t.warning = false
|
29
|
-
}
|
30
|
-
|
31
|
-
# Generate the RDoc documentation
|
32
|
-
Rake::RDocTask.new { |rdoc|
|
33
|
-
rdoc.rdoc_dir = 'doc'
|
34
|
-
rdoc.title = "Position Range -- Ranges with attributes that can be juggled"
|
35
|
-
rdoc.options << '--line-numbers' << '--inline-source' << '-A cattr_accessor=object'
|
36
|
-
rdoc.options << '--charset' << 'utf-8'
|
37
|
-
rdoc.rdoc_files.include('README', 'CHANGELOG')
|
38
|
-
rdoc.rdoc_files.include('lib/position_range.rb')
|
39
|
-
rdoc.rdoc_files.include('lib/position_range/*.rb')
|
40
|
-
}
|
41
|
-
|
42
|
-
# Create compressed packages
|
43
|
-
spec = Gem::Specification.new do |s|
|
44
|
-
s.platform = Gem::Platform::RUBY
|
45
|
-
s.name = PKG_NAME
|
46
|
-
s.summary = "Ranges with attributes that can be juggled."
|
47
|
-
s.description = %q{Allows you to assign random attributes to ranges and juggle them in lists.}
|
48
|
-
s.version = PKG_VERSION
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
require "bundler/gem_tasks"
|
49
3
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
s.homepage = "http://positionrange.rubyforge.org"
|
54
|
-
|
55
|
-
s.has_rdoc = true
|
56
|
-
s.requirements << 'none'
|
57
|
-
s.require_path = 'lib'
|
58
|
-
|
59
|
-
s.files = [ "Rakefile", "install.rb", "README", "CHANGELOG", "LICENSE" ]
|
60
|
-
s.files = s.files + Dir.glob( "lib/**/*" ).delete_if { |item| item.include?( "\.svn" ) }
|
61
|
-
s.files = s.files + Dir.glob( "test/**/*" ).delete_if { |item| item.include?( "\.svn" ) }
|
62
|
-
end
|
63
|
-
|
64
|
-
Rake::GemPackageTask.new(spec) do |p|
|
65
|
-
p.gem_spec = spec
|
66
|
-
p.need_tar = true
|
67
|
-
p.need_zip = true
|
68
|
-
end
|
69
|
-
|
70
|
-
desc "Build and publish the docs, gem, and release files"
|
71
|
-
task :deploy => [:release, :pdoc] do
|
72
|
-
puts 'Published gem'
|
73
|
-
end
|
74
|
-
|
75
|
-
desc "Publish the API documentation"
|
76
|
-
task :pdoc => [:rdoc] do
|
77
|
-
sh "rsync -azv --no-perms --no-times doc/*" +
|
78
|
-
" rubyforge.org:/var/www/gforge-projects/positionrange"
|
79
|
-
end
|
80
|
-
|
81
|
-
desc "Publish the release files to RubyForge."
|
82
|
-
task :release => [ :package ] do
|
83
|
-
require 'rubyforge'
|
84
|
-
require 'rake/contrib/rubyforgepublisher'
|
85
|
-
|
86
|
-
packages = %w( gem tgz zip ).collect{ |ext| "pkg/#{PKG_NAME}-#{PKG_VERSION}.#{ext}" }
|
87
|
-
|
88
|
-
rubyforge = RubyForge.new.configure
|
89
|
-
rubyforge.login
|
90
|
-
rubyforge.add_release(PKG_NAME, PKG_NAME, "REL #{PKG_VERSION}", *packages)
|
91
|
-
end
|
4
|
+
task :default => :test
|
5
|
+
require 'rake/testtask'
|
6
|
+
Rake::TestTask.new
|
data/lib/position_range.rb
CHANGED
@@ -1,13 +1,7 @@
|
|
1
1
|
#--#
|
2
|
-
# Copyright: (c) 2006-
|
2
|
+
# Copyright: (c) 2006-2012 Wybo Wiersma <mail@wybowiersma.net>
|
3
3
|
#
|
4
|
-
#
|
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).
|
4
|
+
# MIT Licensed
|
11
5
|
#++#
|
12
6
|
#
|
13
7
|
# PositionRanges allow one to model ranges of text.
|
@@ -25,20 +19,9 @@
|
|
25
19
|
#
|
26
20
|
# first...last, not first..last
|
27
21
|
|
28
|
-
|
29
|
-
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
30
|
-
|
31
|
-
class PositionRange < Range
|
32
|
-
include Comparable
|
33
|
-
|
34
|
-
@@attributes = []
|
35
|
-
|
36
|
-
def attributes
|
37
|
-
return @@attributes
|
38
|
-
end
|
39
|
-
|
40
|
-
### Constants
|
22
|
+
require 'position_range/version'
|
41
23
|
|
24
|
+
class PositionRange # < Range (set in version)
|
42
25
|
# Mainly used by PositionRange::List
|
43
26
|
MaximumSize = 2 ** 31
|
44
27
|
|
@@ -55,6 +38,14 @@ require 'position_range/error'
|
|
55
38
|
require 'position_range/list'
|
56
39
|
|
57
40
|
class PositionRange
|
41
|
+
include Comparable
|
42
|
+
|
43
|
+
@@attributes = []
|
44
|
+
|
45
|
+
def attributes
|
46
|
+
return @@attributes
|
47
|
+
end
|
48
|
+
|
58
49
|
### Constructors
|
59
50
|
|
60
51
|
# Initializes a new PositionRange.
|
data/lib/position_range/error.rb
CHANGED
@@ -1,17 +1,3 @@
|
|
1
|
-
#--#
|
2
|
-
# Copyright: (c) 2006-2009 The LogiLogi Foundation <foundation@logilogi.org>
|
3
|
-
#
|
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
|
-
# 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).
|
11
|
-
#++#
|
12
|
-
#
|
13
|
-
# This Error is raised if positions are out of range.
|
14
|
-
|
15
1
|
class PositionRange::Error < StandardError
|
16
2
|
attr_accessor :from_range, :to_range
|
17
3
|
|
data/lib/position_range/list.rb
CHANGED
@@ -1,24 +1,4 @@
|
|
1
|
-
#--#
|
2
|
-
# Copyright: (c) 2006-2008 The LogiLogi Foundation <foundation@logilogi.org>
|
3
|
-
#
|
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).
|
13
|
-
#++#
|
14
|
-
#
|
15
|
-
# Keeps a list of PositionRanges.
|
16
|
-
#
|
17
|
-
# Supports basic set operations, as well as many others, like
|
18
|
-
# clustering overlaps and getting sizes.
|
19
|
-
|
20
1
|
class PositionRange::List < Array
|
21
|
-
|
22
2
|
###### Regular expressions
|
23
3
|
|
24
4
|
# Check-regexps
|
@@ -163,9 +143,9 @@ class PositionRange::List < Array
|
|
163
143
|
def substract!(other, options = {})
|
164
144
|
ignore_attributes = options[:ignore_attributes]
|
165
145
|
|
166
|
-
sorted_self = self.sort
|
146
|
+
sorted_self = self.dup.sort!
|
167
147
|
if sorted_self.size > 0 and other.size > 0
|
168
|
-
other = other.sort
|
148
|
+
other = other.dup.sort!.merge_adjacents!
|
169
149
|
|
170
150
|
last_i = 0
|
171
151
|
other.each do |p_r|
|
@@ -593,7 +573,7 @@ class PositionRange::List < Array
|
|
593
573
|
# Parses a PositionRange::List to a string
|
594
574
|
#
|
595
575
|
def to_s
|
596
|
-
self.sort
|
576
|
+
self.sort!
|
597
577
|
p_r_l_string = ''
|
598
578
|
self.each {|p_r|
|
599
579
|
p_r_l_string += p_r.to_s + ':'
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/position_range/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ['Wybo Wiersma']
|
6
|
+
gem.email = ['mail@wybowiersma.net']
|
7
|
+
gem.description = 'Allows one to assign random attributes to ranges and juggle them in lists. Also adds parsing from string, but most interesting when used in a PositionRange::List. In lists standard set operations can be applied to them, like addition, substraction and intersection. In addition one can also get the combined size of all the ranges in the list. And cluster overlapping ranges, maintaining the attributes.'
|
8
|
+
gem.summary = 'Ranges that can have dynamic attributes'
|
9
|
+
gem.homepage = 'https://github.com/wybo/positionrange'
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.test_files = gem.files.grep(%r{^test/test_.*})
|
13
|
+
gem.name = 'positionrange'
|
14
|
+
gem.require_paths = ['lib']
|
15
|
+
gem.version = PositionRange::VERSION
|
16
|
+
|
17
|
+
gem.add_development_dependency 'rake'
|
18
|
+
gem.add_development_dependency 'test-unit'
|
19
|
+
gem.add_development_dependency 'require_relative'
|
20
|
+
end
|
data/test/helper.rb
ADDED
@@ -1,16 +1,5 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
#
|
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
|
-
# 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).
|
11
|
-
#++#
|
12
|
-
|
13
|
-
require File.dirname(__FILE__) + '/test_helper.rb'
|
1
|
+
['rubygems', 'require_relative'].each {|g| require g} if RUBY_VERSION =~ /1\.8/
|
2
|
+
require_relative 'helper'
|
14
3
|
|
15
4
|
class PositionRangeTest < Test::Unit::TestCase
|
16
5
|
### Initialization
|
@@ -1,18 +1,5 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
#
|
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).
|
13
|
-
#++#
|
14
|
-
|
15
|
-
require File.dirname(__FILE__) + '/test_helper.rb'
|
1
|
+
['rubygems', 'require_relative'].each {|g| require g} if RUBY_VERSION =~ /1\.8/
|
2
|
+
require_relative 'helper'
|
16
3
|
|
17
4
|
class PositionRangeListTest < Test::Unit::TestCase
|
18
5
|
### Parsing & Creating
|
metadata
CHANGED
@@ -1,7 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: positionrange
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 1
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 7
|
9
|
+
- 1
|
10
|
+
version: 0.7.1
|
5
11
|
platform: ruby
|
6
12
|
authors:
|
7
13
|
- Wybo Wiersma
|
@@ -9,12 +15,54 @@ autorequire:
|
|
9
15
|
bindir: bin
|
10
16
|
cert_chain: []
|
11
17
|
|
12
|
-
date:
|
18
|
+
date: 2012-06-24 00:00:00 -07:00
|
13
19
|
default_executable:
|
14
|
-
dependencies:
|
15
|
-
|
16
|
-
|
17
|
-
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
23
|
+
none: false
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
hash: 3
|
28
|
+
segments:
|
29
|
+
- 0
|
30
|
+
version: "0"
|
31
|
+
version_requirements: *id001
|
32
|
+
name: rake
|
33
|
+
prerelease: false
|
34
|
+
type: :development
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
37
|
+
none: false
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
hash: 3
|
42
|
+
segments:
|
43
|
+
- 0
|
44
|
+
version: "0"
|
45
|
+
version_requirements: *id002
|
46
|
+
name: test-unit
|
47
|
+
prerelease: false
|
48
|
+
type: :development
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
hash: 3
|
56
|
+
segments:
|
57
|
+
- 0
|
58
|
+
version: "0"
|
59
|
+
version_requirements: *id003
|
60
|
+
name: require_relative
|
61
|
+
prerelease: false
|
62
|
+
type: :development
|
63
|
+
description: Allows one to assign random attributes to ranges and juggle them in lists. Also adds parsing from string, but most interesting when used in a PositionRange::List. In lists standard set operations can be applied to them, like addition, substraction and intersection. In addition one can also get the combined size of all the ranges in the list. And cluster overlapping ranges, maintaining the attributes.
|
64
|
+
email:
|
65
|
+
- mail@wybowiersma.net
|
18
66
|
executables: []
|
19
67
|
|
20
68
|
extensions: []
|
@@ -22,21 +70,23 @@ extensions: []
|
|
22
70
|
extra_rdoc_files: []
|
23
71
|
|
24
72
|
files:
|
25
|
-
-
|
26
|
-
- install.rb
|
27
|
-
- README
|
73
|
+
- .gitignore
|
28
74
|
- CHANGELOG
|
75
|
+
- Gemfile
|
29
76
|
- LICENSE
|
77
|
+
- README.md
|
78
|
+
- Rakefile
|
79
|
+
- lib/position_range.rb
|
30
80
|
- lib/position_range/error.rb
|
31
81
|
- lib/position_range/list.rb
|
32
82
|
- lib/position_range/version.rb
|
33
|
-
- lib/position_range.rb
|
34
83
|
- lib/positionrange.rb
|
35
|
-
-
|
36
|
-
- test/
|
37
|
-
- test/
|
84
|
+
- positionrange.gemspec
|
85
|
+
- test/helper.rb
|
86
|
+
- test/test_position_range.rb
|
87
|
+
- test/test_position_range_list.rb
|
38
88
|
has_rdoc: true
|
39
|
-
homepage:
|
89
|
+
homepage: https://github.com/wybo/positionrange
|
40
90
|
licenses: []
|
41
91
|
|
42
92
|
post_install_message:
|
@@ -45,23 +95,30 @@ rdoc_options: []
|
|
45
95
|
require_paths:
|
46
96
|
- lib
|
47
97
|
required_ruby_version: !ruby/object:Gem::Requirement
|
98
|
+
none: false
|
48
99
|
requirements:
|
49
100
|
- - ">="
|
50
101
|
- !ruby/object:Gem::Version
|
102
|
+
hash: 3
|
103
|
+
segments:
|
104
|
+
- 0
|
51
105
|
version: "0"
|
52
|
-
version:
|
53
106
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
|
+
none: false
|
54
108
|
requirements:
|
55
109
|
- - ">="
|
56
110
|
- !ruby/object:Gem::Version
|
111
|
+
hash: 3
|
112
|
+
segments:
|
113
|
+
- 0
|
57
114
|
version: "0"
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
rubygems_version: 1.3.5
|
115
|
+
requirements: []
|
116
|
+
|
117
|
+
rubyforge_project:
|
118
|
+
rubygems_version: 1.6.2
|
63
119
|
signing_key:
|
64
120
|
specification_version: 3
|
65
|
-
summary: Ranges
|
66
|
-
test_files:
|
67
|
-
|
121
|
+
summary: Ranges that can have dynamic attributes
|
122
|
+
test_files:
|
123
|
+
- test/test_position_range.rb
|
124
|
+
- test/test_position_range_list.rb
|
data/install.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
require 'rbconfig'
|
2
|
-
require 'find'
|
3
|
-
require 'ftools'
|
4
|
-
|
5
|
-
include Config
|
6
|
-
|
7
|
-
# this was adapted from rdoc's install.rb by way of Log4r
|
8
|
-
|
9
|
-
$sitedir = CONFIG["sitelibdir"]
|
10
|
-
unless $sitedir
|
11
|
-
version = CONFIG["MAJOR"] + "." + CONFIG["MINOR"]
|
12
|
-
$libdir = File.join(CONFIG["libdir"], "ruby", version)
|
13
|
-
$sitedir = $:.find {|x| x =~ /site_ruby/ }
|
14
|
-
if !$sitedir
|
15
|
-
$sitedir = File.join($libdir, "site_ruby")
|
16
|
-
elsif $sitedir !~ Regexp.quote(version)
|
17
|
-
$sitedir = File.join($sitedir, version)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
# the actual gruntwork
|
22
|
-
Dir.chdir("lib")
|
23
|
-
|
24
|
-
Find.find("position_range", "position_range.rb") { |f|
|
25
|
-
if f[-3..-1] == ".rb"
|
26
|
-
File::install(f, File.join($sitedir, *f.split(/\//)), 0644, true)
|
27
|
-
else
|
28
|
-
File::makedirs(File.join($sitedir, *f.split(/\//)))
|
29
|
-
end
|
30
|
-
}
|
data/test/test_helper.rb
DELETED