range_utils 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/lib/range_utils.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module RangeUtils
2
- VERSION = '1.2.0'
2
+ VERSION = '1.2.1'
3
3
 
4
4
  # Tells whether the +item+ is included in the +range+, without enumerating
5
5
  # through the +range+ (performing a quick bounds check).
@@ -104,7 +104,7 @@ module RangeUtils
104
104
  # Range members and n_items must support aruthmetic with integers
105
105
  def take(from_range, n_items)
106
106
  end_at = from_range.begin + (n_items - 1)
107
- return [from_range, nil] if end_at > from_range.end
107
+ return [from_range, nil] if end_at >= from_range.end
108
108
  [from_range.begin..end_at, end_at.succ..from_range.end]
109
109
  end
110
110
 
data/range_utils.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "range_utils"
8
- s.version = "1.2.0"
8
+ s.version = "1.2.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Julik Tarkhanov"]
@@ -137,6 +137,12 @@ describe "RangeUtils" do
137
137
  expect(first).to eq(0..12)
138
138
  expect(remainder).to be_nil
139
139
  end
140
+
141
+ it 'handles the 0-item remainder range case correctly' do
142
+ first, remainder = subject.take(0..1, 2)
143
+ expect(first).to eq(0..1)
144
+ expect(remainder).to be_nil
145
+ end
140
146
  end
141
147
 
142
148
  context '.size_from_range' do
@@ -150,5 +156,4 @@ describe "RangeUtils" do
150
156
  expect(subject.size_from_range(0..522753)).to eq(522754)
151
157
  end
152
158
  end
153
-
154
159
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: range_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -108,7 +108,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
108
108
  version: '0'
109
109
  segments:
110
110
  - 0
111
- hash: 3847094652455965733
111
+ hash: 4395321895595223882
112
112
  required_rubygems_version: !ruby/object:Gem::Requirement
113
113
  none: false
114
114
  requirements: