rangesmaller 1.0.2 → 1.0.3
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 +36 -0
- data/README.rdoc +5 -2
- data/lib/rangesmaller/rangesmaller.rb +33 -17
- data/rangesmaller.gemspec +5 -2
- data/test/test_rangesmaller.rb +7 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bb2dd52eccdf235b18ce0aa93c9a55fb4816eaf7
|
4
|
+
data.tar.gz: bccb5a3d21d6f41ee58cca2692cc06c77178df69
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 187dd3c240b5cad7f8f084bcca0ba36f242d5a7d8ff9272e1fac16b36f535dc64c650ff66c88fc870ebec0e4b9afd7098edc430bcb11f6237d60d3d8350455dc
|
7
|
+
data.tar.gz: 6f3f41877a00fb9e17e5c4d8216c9b7224dd53289e42e2a257555fb01d1d3a7bcecd77abcca0176f32e251e07e98e58574c075aabd8cc6541d7c6e3af6dafbf4
|
data/ChangeLog
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
-----
|
2
|
+
(Version: v1.0.3)
|
3
|
+
2014-04-24 Masa Saskano
|
4
|
+
* Cosmetic minor changes.
|
5
|
+
|
6
|
+
-----
|
7
|
+
2014-04-23 Masa Sakano
|
8
|
+
|
9
|
+
* Rangesmaller#to_s changed behaviour in the previous version, hence modified it back to the original.
|
10
|
+
|
11
|
+
-----
|
12
|
+
2014-04-23 Masa Sakano
|
13
|
+
|
14
|
+
* ChangeLog is added. Minor bug-fix: Rangesmaller#inspect used to use #to_s() but now uses #inspect() for its elements.
|
15
|
+
|
16
|
+
-----
|
17
|
+
(Version: v1.0.2)
|
18
|
+
2014-04-22 Masa Sakano
|
19
|
+
|
20
|
+
* v1.0.2 (No change other than Version statement in rangesmaller.gemspec)
|
21
|
+
|
22
|
+
-----
|
23
|
+
2014-04-22 Masa Sakano
|
24
|
+
|
25
|
+
* Eliminate the wrong warning issued when the option of any object but true/false is given for :exclude_end, together with a Range, in Rangesmaller.new().
|
26
|
+
|
27
|
+
-----
|
28
|
+
2014-04-22 Masa Sakano
|
29
|
+
|
30
|
+
* v1.0.1: Minor bug fixes of rangesmaller. Now each() and step() return Enumerator when no block is given, the same as Range, and step() returns self if not (In the previous version it returned Range object if exclude_begin is true). Fixes of the comments in the source code rangesmaller.rb so yard interprets them correctly.
|
31
|
+
|
32
|
+
-----
|
33
|
+
(Version: v1.0.0)
|
34
|
+
2014-04-22 Masa Sakano
|
35
|
+
|
36
|
+
* Initial commit of rangesmaller.
|
data/README.rdoc
CHANGED
@@ -25,6 +25,8 @@ Alternatively get it from
|
|
25
25
|
http://rubygems.org/gems/rangesmaller
|
26
26
|
|
27
27
|
Then all you need to do is
|
28
|
+
require 'rangesmaller/rangesmaller'
|
29
|
+
or, possibly as follows, if you manually install it
|
28
30
|
require 'rangesmaller'
|
29
31
|
in your Ruby script (or irb).
|
30
32
|
|
@@ -89,10 +91,11 @@ They are evaluated as follows:
|
|
89
91
|
|
90
92
|
Nothing planned.
|
91
93
|
|
94
|
+
== Miscellaneous
|
95
|
+
|
92
96
|
== Copyright etc
|
93
97
|
|
94
98
|
Author:: Masa Sakano < imagine a_t sakano dot co dot uk >
|
95
99
|
License:: MIT.
|
96
100
|
Warranty:: No warranty whatsoever.
|
97
|
-
|
98
|
-
|
101
|
+
Versions:: The versions of this package follow Semantic Versioning (2.0.0) http://semver.org/
|
@@ -38,8 +38,8 @@ class Rangesmaller < Range
|
|
38
38
|
# @param obj_begin [Object] Any object (preferably {#Comparable})
|
39
39
|
# @param obj_end [Object] Any object, compatible with begin
|
40
40
|
# @param opts [Hash] see below
|
41
|
-
# @option opts [Object] :exclude_end the end boundary is excluded,
|
42
|
-
# @option opts [Object] :exclude_begin the begin boundary is excluded,
|
41
|
+
# @option opts [Object] :exclude_end the end boundary is excluded, or false (Default)
|
42
|
+
# @option opts [Object] :exclude_begin the begin boundary is excluded, or false (Default)
|
43
43
|
#
|
44
44
|
# @note The here-mentioned "any" object means any object that can consist of {Range}.
|
45
45
|
# For example, (nil..nil) is accepted, but (Complex(2,3)..Complex(2,3)) is not.
|
@@ -60,7 +60,7 @@ class Rangesmaller < Range
|
|
60
60
|
r = inar[0]
|
61
61
|
if defined?(r.rangepart) && defined?(r.exclude_begin?)
|
62
62
|
# Rangesmaller
|
63
|
-
@exclude_begin = r.exclude_begin?
|
63
|
+
@exclude_begin = (r.exclude_begin? && true)
|
64
64
|
@rangepart = r.rangepart
|
65
65
|
r = @rangepart
|
66
66
|
super(r.begin, r.end, r.exclude_end?)
|
@@ -70,7 +70,7 @@ class Rangesmaller < Range
|
|
70
70
|
super(r.begin, r.end, r.exclude_end?)
|
71
71
|
@rangepart = r
|
72
72
|
else
|
73
|
-
raise ArgumentError, "bad
|
73
|
+
raise ArgumentError, "bad value for Rangesmaller"
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
@@ -79,10 +79,10 @@ class Rangesmaller < Range
|
|
79
79
|
if defined? r.exclude_end?
|
80
80
|
# Arg: (Range, :exclude_begin => false)
|
81
81
|
begin
|
82
|
-
@exclude_begin = inar[1][:exclude_begin]
|
82
|
+
@exclude_begin = (inar[1][:exclude_begin] && true)
|
83
83
|
rescue
|
84
84
|
# cf., Rangesmaller.new(nil,5) # => ArgumentError: bad value for range
|
85
|
-
raise ArgumentError, "bad
|
85
|
+
raise ArgumentError, "bad value for Rangesmaller"
|
86
86
|
end
|
87
87
|
|
88
88
|
if defined?(r.begin) && defined?(r.end) # && defined?(r.exclude_end?)
|
@@ -99,7 +99,7 @@ class Rangesmaller < Range
|
|
99
99
|
# The above is just a warning, hence no exception should be raised here, whatever the reason.
|
100
100
|
end
|
101
101
|
else # Very unlikely, but possible.
|
102
|
-
raise ArgumentError, "bad
|
102
|
+
raise ArgumentError, "bad value for Rangesmaller"
|
103
103
|
end
|
104
104
|
else # Arg: (Num(Begin), Num(End))
|
105
105
|
super
|
@@ -108,7 +108,7 @@ class Rangesmaller < Range
|
|
108
108
|
when 3
|
109
109
|
flag_end = false
|
110
110
|
begin
|
111
|
-
@exclude_begin = inar[2][:exclude_begin]
|
111
|
+
@exclude_begin = (inar[2][:exclude_begin] && true)
|
112
112
|
|
113
113
|
if inar[2].has_key?(:exclude_end)
|
114
114
|
flag_end = true
|
@@ -350,7 +350,7 @@ class Rangesmaller < Range
|
|
350
350
|
end
|
351
351
|
|
352
352
|
else
|
353
|
-
raise ArgumentError, "wrong number of arguments (#{rest.size} for
|
353
|
+
raise ArgumentError, "wrong number of arguments (#{rest.size} for 0..1)"
|
354
354
|
end
|
355
355
|
end # if ! @exclude_begin
|
356
356
|
end # def first(*rest)
|
@@ -367,21 +367,28 @@ class Rangesmaller < Range
|
|
367
367
|
end
|
368
368
|
|
369
369
|
|
370
|
-
#
|
370
|
+
# Return eg., '("a"<..."c")', '("a"<.."c")', if {#exclude_begin?} is true,
|
371
371
|
# or else, identical to those for {Range}.
|
372
|
+
# @return [String]
|
372
373
|
def inspect
|
373
374
|
if @exclude_begin
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
375
|
+
self.begin.inspect + midstr_when_exclude_begin() + self.end.inspect
|
376
|
+
else
|
377
|
+
super
|
378
|
+
end
|
379
|
+
end
|
380
|
+
|
381
|
+
|
382
|
+
# Return eg., "(a<...c)", "(a<..c)", if {#exclude_begin?} is true,
|
383
|
+
# or else, identical to those for {Range}.
|
384
|
+
# @return [String]
|
385
|
+
def to_s
|
386
|
+
if @exclude_begin
|
387
|
+
self.begin.to_s + midstr_when_exclude_begin() + self.end.to_s
|
380
388
|
else
|
381
389
|
super
|
382
390
|
end
|
383
391
|
end
|
384
|
-
alias :to_s :inspect
|
385
392
|
|
386
393
|
|
387
394
|
# See {#first} for the definition when {#exclude_begin?} is true.
|
@@ -538,7 +545,16 @@ class Rangesmaller < Range
|
|
538
545
|
end
|
539
546
|
end
|
540
547
|
|
548
|
+
private
|
541
549
|
|
550
|
+
# Middle string for {#inspect} and {#to_s}
|
551
|
+
def midstr_when_exclude_begin
|
552
|
+
if exclude_end?
|
553
|
+
"<..."
|
554
|
+
else
|
555
|
+
"<.."
|
556
|
+
end
|
557
|
+
end
|
542
558
|
end # class Rangesmaller < Range
|
543
559
|
|
544
560
|
|
data/rangesmaller.gemspec
CHANGED
@@ -2,12 +2,12 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{rangesmaller}
|
5
|
-
s.version = "1.0.
|
5
|
+
s.version = "1.0.3"
|
6
6
|
# s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
7
7
|
# s.executables << 'hola'
|
8
8
|
# s.bindir = 'bin'
|
9
9
|
s.authors = ["Masa Sakano"]
|
10
|
-
s.date = %q{2014-04-
|
10
|
+
s.date = %q{2014-04-24}
|
11
11
|
s.summary = %q{Rangesmaller class -- Range with include_begin?()}
|
12
12
|
s.description = %q{This defines a subclass of Range, Rangesmaller class. Users can define whether the begin boundary is exclusive or inclusive, in addition to the end boundary as in the standard Range.}
|
13
13
|
# s.email = %q{abc@example.com}
|
@@ -20,12 +20,15 @@ Gem::Specification.new do |s|
|
|
20
20
|
#".document",
|
21
21
|
#".gitignore",
|
22
22
|
#"VERSION",
|
23
|
+
"ChangeLog",
|
23
24
|
"README.rdoc",
|
24
25
|
"Rakefile",
|
25
26
|
"rangesmaller.gemspec",
|
26
27
|
"lib/rangesmaller/rangesmaller.rb",
|
27
28
|
"test/test_rangesmaller.rb",
|
28
29
|
]
|
30
|
+
# s.add_runtime_dependency 'library', '~> 2.2', '>= 2.2.1' # 2.2.1 <= Ver < 2.3.0
|
31
|
+
# s.add_development_dependency "bourne", [">= 0"]
|
29
32
|
# s.homepage = %q{http://}
|
30
33
|
s.rdoc_options = ["--charset=UTF-8"]
|
31
34
|
# s.require_paths = ["lib"]
|
data/test/test_rangesmaller.rb
CHANGED
@@ -516,6 +516,13 @@ p $LOADED_FEATURES.grep(/#{Regexp.quote(libfilebase)}$/)
|
|
516
516
|
end # def test_step
|
517
517
|
|
518
518
|
|
519
|
+
def test_to_s
|
520
|
+
assert_equal 'a...c', Rangesmaller(?a...?c).to_s
|
521
|
+
assert_equal 'a<..c', Rangesmaller(?a..?c, :exclude_begin => true).to_s
|
522
|
+
assert_equal 'a<...c', Rangesmaller(?a...?c, :exclude_begin => true).to_s
|
523
|
+
assert_equal '"a"<.."c"', Rangesmaller(?a..?c, :exclude_begin => true).inspect
|
524
|
+
end
|
525
|
+
|
519
526
|
end # class TestFoo < MiniTest::Unit::TestCase
|
520
527
|
|
521
528
|
#end # if $0 == __FILE__
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rangesmaller
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Masa Sakano
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-24 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: This defines a subclass of Range, Rangesmaller class. Users can define
|
14
14
|
whether the begin boundary is exclusive or inclusive, in addition to the end boundary
|
@@ -19,6 +19,7 @@ extensions: []
|
|
19
19
|
extra_rdoc_files:
|
20
20
|
- README.rdoc
|
21
21
|
files:
|
22
|
+
- ChangeLog
|
22
23
|
- README.rdoc
|
23
24
|
- Rakefile
|
24
25
|
- rangesmaller.gemspec
|