range_extd 1.1.1 → 2.0
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.
- checksums.yaml +4 -4
- data/ChangeLog +16 -0
- data/Makefile +7 -3
- data/News +4 -0
- data/README.en.rdoc +1146 -270
- data/README.ja.rdoc +1146 -270
- data/Rakefile +11 -5
- data/lib/range_extd/infinity.rb +426 -0
- data/lib/range_extd/load_all.rb +19 -0
- data/lib/range_extd/nil_class.rb +41 -0
- data/lib/range_extd/nowhere.rb +135 -0
- data/lib/range_extd/numeric.rb +160 -0
- data/lib/range_extd/object.rb +53 -0
- data/lib/range_extd/range.rb +401 -0
- data/lib/{range_extd/range_extd.rb → range_extd.rb} +387 -633
- data/range_extd.gemspec +50 -0
- data/test/all_required_test.rb +173 -0
- data/test/test_range_extd.rb +482 -148
- data/test/test_range_extd_nowhere.rb +84 -0
- metadata +29 -16
- data/lib/range_extd/infinity/infinity.rb +0 -600
@@ -0,0 +1,84 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
$stdout.sync=true
|
4
|
+
$stderr.sync=true
|
5
|
+
# print '$LOAD_PATH=';p $LOAD_PATH
|
6
|
+
arlibbase = %w(range_extd range_extd/nowhere.rb) # range_extd/nowhere.rb is actually loaded from range_extd. But by writing here, the absolute path will be displayed.
|
7
|
+
|
8
|
+
arlibrelbase = arlibbase.map{|i| "../lib/"+i}
|
9
|
+
|
10
|
+
arlibrelbase.each do |elibbase|
|
11
|
+
require_relative elibbase
|
12
|
+
end
|
13
|
+
|
14
|
+
print "NOTE: Running: "; p File.basename(__FILE__)
|
15
|
+
print "NOTE: Library relative paths: "; p arlibrelbase
|
16
|
+
arlibbase4full = arlibbase.map{|i| i.sub(%r@^(../)+@, "")}+%w(range_extd)
|
17
|
+
puts "NOTE: Library full paths for #{arlibbase4full.inspect}: "
|
18
|
+
arlibbase4full.each do |elibbase|
|
19
|
+
ar = $LOADED_FEATURES.grep(/(^|\/)#{Regexp.quote(File.basename(elibbase))}(\.rb)?$/).uniq
|
20
|
+
print elibbase+": " if ar.empty?; p ar
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
#################################################
|
25
|
+
# Unit Test
|
26
|
+
#################################################
|
27
|
+
|
28
|
+
require 'rational' if !defined?(Rational) # For Ruby 1.8
|
29
|
+
|
30
|
+
gem "minitest"
|
31
|
+
require 'minitest/autorun'
|
32
|
+
|
33
|
+
class TestUnitNowhere < MiniTest::Test
|
34
|
+
T = true
|
35
|
+
F = false
|
36
|
+
|
37
|
+
def setup
|
38
|
+
end
|
39
|
+
|
40
|
+
def teardown
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_nowhere
|
44
|
+
nowhere = RangeExtd::Nowhere::NOWHERE
|
45
|
+
assert(RangeExtd::Nowhere.instance.eql?(nowhere), "Const.id=#{RangeExtd::Nowhere::NOWHERE.__id__} nowhere.id=#{nowhere.__id__}; nil=#{RangeExtd::Nowhere::NOWHERE.nil?.inspect}=#{nowhere.nil?.inspect}; nowhere?=#{RangeExtd::Nowhere::NOWHERE.nowhere?.inspect}=#{nowhere.nowhere?.inspect}; hash=#{RangeExtd::Nowhere::NOWHERE.hash}=#{nowhere.hash}")
|
46
|
+
refute(nowhere.eql?(nil))
|
47
|
+
assert( nowhere == nil )
|
48
|
+
assert_equal 0, ( nowhere <=> nil )
|
49
|
+
|
50
|
+
assert nowhere.nowhere?
|
51
|
+
assert_equal RangeExtd::Nowhere, nowhere.class_raw
|
52
|
+
assert_equal NilClass, nowhere.class
|
53
|
+
|
54
|
+
assert( nowhere ) # Unfortunately, there is no way in Ruby to make the object behave like false/nil in the conditional statement: see <https://stackoverflow.com/a/14449380/3577922>
|
55
|
+
assert( nowhere.nil? )
|
56
|
+
refute RangeExtd.valid?(RangeExtd::Nowhere::NOWHERE..nil), 'NOWHERE cannot reside in other than RangeExtd::NONE'
|
57
|
+
end # def test_nowhere
|
58
|
+
|
59
|
+
# 'nil_class.rb' is always required, and so these should hold.
|
60
|
+
def test_nil_class
|
61
|
+
nowhere = RangeExtd::Nowhere::NOWHERE
|
62
|
+
refute(nil.eql?(nowhere))
|
63
|
+
assert( nil == nowhere )
|
64
|
+
assert_equal 0, ( nil <=> nowhere )
|
65
|
+
|
66
|
+
refute nil.nowhere?
|
67
|
+
assert_equal NilClass, nil.class_raw
|
68
|
+
assert_equal NilClass, nil.class
|
69
|
+
end # def test_nil_class
|
70
|
+
|
71
|
+
## when 'nil_class.rb' is not required, these are the cases.
|
72
|
+
#def test_nil_class
|
73
|
+
# nowhere = RangeExtd::Nowhere::NOWHERE
|
74
|
+
# refute(nil.eql?(nowhere))
|
75
|
+
#
|
76
|
+
# refute( nil == nowhere )
|
77
|
+
# assert_nil( nil <=> nowhere )
|
78
|
+
#
|
79
|
+
# refute nil.respond_to?(:nowhere?)
|
80
|
+
# refute nil.respond_to?(:class_raw)
|
81
|
+
# assert_equal NilClass, nil.class
|
82
|
+
#end # def test_nil_class
|
83
|
+
end # class TestUnitNowhere < MiniTest::Test
|
84
|
+
|
metadata
CHANGED
@@ -1,22 +1,24 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: range_extd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: '2.0'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Masa Sakano
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-09-08 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description: Package for a subclass of Range, RangeExtd
|
14
|
-
|
15
|
-
to the end boundary as in the built-in Range, and accepts
|
16
|
-
for either (or both) positive/negative direction. The
|
17
|
-
|
18
|
-
|
19
|
-
|
13
|
+
description: Package for a subclass of Range, RangeExtd, containing RangeExtd::Infinity
|
14
|
+
and RangeExtd::Nowhere. RangeExtd defines ranges that enable an exclusion of the
|
15
|
+
begin boundary, in addition to the end boundary as in the built-in Range, and accepts
|
16
|
+
open-ended ranges to infinity for either (or both) positive/negative direction. The
|
17
|
+
open-ended boundaries are represented by two constant objects, POSITIVE and NEGATIVE
|
18
|
+
of RangeExtd::Infinity, and they are a generalised Infinity of Float::INFINITY to
|
19
|
+
any Comparable objects, which are in practice similar to built-in beginless/endless
|
20
|
+
Ranges.
|
21
|
+
email:
|
20
22
|
executables: []
|
21
23
|
extensions: []
|
22
24
|
extra_rdoc_files:
|
@@ -30,15 +32,24 @@ files:
|
|
30
32
|
- README.en.rdoc
|
31
33
|
- README.ja.rdoc
|
32
34
|
- Rakefile
|
33
|
-
- lib/range_extd
|
34
|
-
- lib/range_extd/
|
35
|
+
- lib/range_extd.rb
|
36
|
+
- lib/range_extd/infinity.rb
|
37
|
+
- lib/range_extd/load_all.rb
|
38
|
+
- lib/range_extd/nil_class.rb
|
39
|
+
- lib/range_extd/nowhere.rb
|
40
|
+
- lib/range_extd/numeric.rb
|
41
|
+
- lib/range_extd/object.rb
|
42
|
+
- lib/range_extd/range.rb
|
43
|
+
- range_extd.gemspec
|
44
|
+
- test/all_required_test.rb
|
35
45
|
- test/test_range_extd.rb
|
46
|
+
- test/test_range_extd_nowhere.rb
|
36
47
|
homepage: https://www.wisebabel.com
|
37
48
|
licenses:
|
38
49
|
- MIT
|
39
50
|
metadata:
|
40
51
|
yard.run: yri
|
41
|
-
post_install_message:
|
52
|
+
post_install_message:
|
42
53
|
rdoc_options:
|
43
54
|
- "--charset=UTF-8"
|
44
55
|
require_paths:
|
@@ -47,16 +58,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
47
58
|
requirements:
|
48
59
|
- - ">="
|
49
60
|
- !ruby/object:Gem::Version
|
50
|
-
version: '2.
|
61
|
+
version: '2.7'
|
51
62
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
52
63
|
requirements:
|
53
64
|
- - ">="
|
54
65
|
- !ruby/object:Gem::Version
|
55
66
|
version: '0'
|
56
67
|
requirements: []
|
57
|
-
rubygems_version: 3.
|
58
|
-
signing_key:
|
68
|
+
rubygems_version: 3.3.7
|
69
|
+
signing_key:
|
59
70
|
specification_version: 4
|
60
71
|
summary: RangeExtd - Extended Range class with exclude_begin and open-ends
|
61
72
|
test_files:
|
73
|
+
- test/all_required_test.rb
|
62
74
|
- test/test_range_extd.rb
|
75
|
+
- test/test_range_extd_nowhere.rb
|