range_utils 1.3.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8e7990f6efd2ab806a7e7a4e1a5dbacc80f2ba6b
4
- data.tar.gz: e38bd6ca3eb8f2a893ff2ec33ff421ba6e090ac3
3
+ metadata.gz: 85078670a20334ec867fb53aaa706fa53d4bfef4
4
+ data.tar.gz: 19121fbdf103146ff2271ce90265ddf86ffeae07
5
5
  SHA512:
6
- metadata.gz: 229bf992c5826eff60d224829de0a1aaa676b79ae48df8db16277503d06f174efbe20b9f5e1df9fcca04ca2c8aa7995405059bffa013e04c570e8dd1f8ad2ba6
7
- data.tar.gz: a4d48beba8735bc952a8c239b80ccb0535a82f14db83b81a883f49fdbfa63e2ad181c98ebc56fae0d2c10a694b2b770486c722282b436fc758bbff208f235ce8
6
+ metadata.gz: e7aa69429c19cf30d4f4cb25613d1f04bbbd00979e6e9bf059f56bb921b4b8082e54709bd95a50c03a74a5bef1917e649302dfbc193cef61135c56ecb341348e
7
+ data.tar.gz: e040585e49fa1cb58817c72dd235be15b6e3fb40bc77051da28efdf63ffa4366da2dd412578af14504b1b7207fb12874cac1f9d77be03f9823da0705a701ee6a
@@ -0,0 +1,52 @@
1
+ # rcov generated
2
+ coverage
3
+ coverage.data
4
+
5
+ .ruby-version
6
+
7
+ # rdoc generated
8
+ rdoc
9
+
10
+ # yard generated
11
+ doc
12
+ .yardoc
13
+
14
+ # bundler
15
+ .bundle
16
+ Gemfile.lock
17
+
18
+ # jeweler generated
19
+ pkg
20
+
21
+ # Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
22
+ #
23
+ # * Create a file at ~/.gitignore
24
+ # * Include files you want ignored
25
+ # * Run: git config --global core.excludesfile ~/.gitignore
26
+ #
27
+ # After doing this, these files will be ignored in all your git projects,
28
+ # saving you from having to 'pollute' every project you touch with them
29
+ #
30
+ # Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
31
+ #
32
+ # For MacOS:
33
+ #
34
+ #.DS_Store
35
+
36
+ # For TextMate
37
+ #*.tmproj
38
+ #tmtags
39
+
40
+ # For emacs:
41
+ #*~
42
+ #\#*
43
+ #.\#*
44
+
45
+ # For vim:
46
+ #*.swp
47
+
48
+ # For redcar:
49
+ #.redcar
50
+
51
+ # For rubinius:
52
+ #*.rbc
@@ -0,0 +1,6 @@
1
+ inherit_gem:
2
+ wetransfer_style: ruby/default.yml
3
+ Layout/FirstMethodArgumentLineBreak:
4
+ Enabled: false
5
+ Layout/FirstMethodParameterLineBreak:
6
+ Enabled: false
@@ -1,9 +1,14 @@
1
1
  rvm:
2
- - 1.8.7
3
- - 1.9.2
4
- - 1.9.3
5
- - 2.0.0
6
- - 2.1.5
7
- - 2.2.2
2
+ - 2.1
3
+ - 2.2.10
4
+ - 2.3.7
5
+ - 2.4.4
6
+ - 2.5.1
7
+ - jruby-9.0
8
8
  sudo: false
9
- cache: bundler
9
+ cache: bundler
10
+ matrix:
11
+ allow_failures:
12
+ - rvm: jruby-9.0
13
+ script:
14
+ - bundle exec rake
data/Gemfile CHANGED
@@ -1,10 +1,3 @@
1
1
  source "http://rubygems.org"
2
2
 
3
- # Add dependencies to develop your gem here.
4
- # Include everything needed to run rake, tests, features, etc.
5
- group :development do
6
- gem "rspec", "~> 3.0"
7
- gem "rdoc", "~> 3.12"
8
- gem "bundler", "~> 1.0"
9
- gem "jeweler"
10
- end
3
+ gemspec
data/Rakefile CHANGED
@@ -1,47 +1,7 @@
1
- # encoding: utf-8
2
-
3
- require 'rubygems'
4
- require 'bundler'
5
- begin
6
- Bundler.setup(:default, :development)
7
- rescue Bundler::BundlerError => e
8
- $stderr.puts e.message
9
- $stderr.puts "Run `bundle install` to install missing gems"
10
- exit e.status_code
11
- end
12
- require 'rake'
13
-
14
- require File.dirname(__FILE__) + '/lib/range_utils'
15
-
16
- require 'jeweler'
17
- Jeweler::Tasks.new do |gem|
18
- # gem is a Gem::Specification... see http://guides.rubygems.org/specification-reference/ for more options
19
- gem.version = RangeUtils::VERSION
20
- gem.name = "range_utils"
21
- gem.homepage = "http://github.com/julik/range_utils"
22
- gem.license = "MIT"
23
- gem.description = %Q{There is a whole range of things you can do with a Range}
24
- gem.summary = %Q{Range splice, split and other niceties}
25
- gem.email = "me@julik.nl"
26
- gem.authors = ["Julik Tarkhanov"]
27
- # dependencies defined in Gemfile
28
- end
29
- Jeweler::RubygemsDotOrgTasks.new
30
-
31
- require 'rspec/core'
1
+ require 'bundler/gem_tasks'
32
2
  require 'rspec/core/rake_task'
33
- RSpec::Core::RakeTask.new(:spec) do |spec|
34
- spec.pattern = FileList['spec/**/*_spec.rb']
35
- end
36
-
37
- task :default => :spec
38
-
39
- require 'rdoc/task'
40
- Rake::RDocTask.new do |rdoc|
41
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
3
+ require 'rubocop/rake_task'
42
4
 
43
- rdoc.rdoc_dir = 'rdoc'
44
- rdoc.title = "range_utils #{version}"
45
- rdoc.rdoc_files.include('README*')
46
- rdoc.rdoc_files.include('lib/**/*.rb')
47
- end
5
+ RSpec::Core::RakeTask.new(:spec)
6
+ RuboCop::RakeTask.new(:rubocop)
7
+ task default: [:spec, :rubocop]
@@ -1,25 +1,24 @@
1
1
  module RangeUtils
2
- VERSION = '1.3.1'
3
-
2
+ require_relative 'range_utils/version'
3
+
4
4
  NegativeRangeSpan = Class.new(ArgumentError)
5
-
5
+
6
6
  # Tells whether the +item+ is included in the +range+, without enumerating
7
7
  # through the +range+ (performing a quick bounds check).
8
8
  # The first value of the range and the +item+ have to support +<=>+
9
9
  def range_includes_item?(range, item)
10
10
  range.begin <= item && item <= range.end
11
11
  end
12
-
12
+
13
13
  # Splits the given Range into subranges of +size+.
14
14
  #
15
15
  # split_range_into_subranges_of(0..7, 3) #=> [0..2, 3..5, 5..7]
16
- #
17
- # Range members must support +<=>+ and aruthmetic with integers.
16
+ #
17
+ # Range members must support +<=>+ and arithmetic with integers.
18
18
  # +size+ has to be > 0.
19
19
  def split_range_into_subranges_of(range, size)
20
20
  raise ArgumentError, "Chunk size should be > 0, was #{size}" unless size > 0
21
-
22
- num_values = range.end - range.begin + 1
21
+
23
22
  ranges = []
24
23
  at = range.begin
25
24
  loop do
@@ -34,7 +33,7 @@ module RangeUtils
34
33
  end
35
34
  end
36
35
  end
37
-
36
+
38
37
  # Returns ranges for the given size. The returned ranges start at zero.
39
38
  # Can be used to split a Content-Length of an HTTP resource into
40
39
  # ranges usable in Range: header for instance.
@@ -44,14 +43,14 @@ module RangeUtils
44
43
  #
45
44
  # ranges_of_offfsets_for_size(3, 1) #=> [0..0, 1..1, 2..2]
46
45
  # ranges_of_offfsets_for_size(3, 2) #=> [0..1, 2..2]
47
- #
48
- # Range members must support +<=>+ and aruthmetic with integers.
46
+ #
47
+ # Range members must support +<=>+ and arithmetic with integers.
49
48
  # +size+ has to be > 0.
50
49
  def ranges_of_offfsets_for_size(number_of_items, chunk_size)
51
50
  raise ArgumentError, "Chunk size should be > 0, was #{chunk_size}" unless chunk_size > 0
52
51
  split_range_into_subranges_of(range_for_size_of(number_of_items), chunk_size)
53
52
  end
54
-
53
+
55
54
  # Creates a Range that can be used to grab N first elements from, say,
56
55
  # an Array or a String.
57
56
  # range_for_size(14) #=> 0..13
@@ -63,19 +62,20 @@ module RangeUtils
63
62
  raise ArgumentError, "Number of items should be at least 0, was #{number_of_items}" if number_of_items < 0
64
63
  (0..(number_of_items - 1))
65
64
  end
66
-
65
+
67
66
  # Combine ranges with adjacent or overlapping values (create a union range).
68
67
  # splice([0..0, 0..4, 5..14, 16..20]) #=> [0..14, 16..20]
69
- # Range members must support +<=>+ and aruthmetic with integers.
68
+ # Range members must support +<=>+ and arithmetic with integers.
70
69
  def splice(ranges)
71
- ranges.sort_by(&:begin).inject([]) do | spliced, r |
70
+ ranges.sort_by(&:begin).inject([]) do |spliced, r|
72
71
  if spliced.empty?
73
72
  spliced + [r]
74
73
  else
75
74
  last = spliced.pop
76
75
  if last.end >= (r.begin - 1)
77
76
  ends = [last.end, last.begin, r.begin, r.end].sort
78
- new_end, new_begin = ends.shift, ends.pop
77
+ new_end = ends.shift
78
+ new_begin = ends.pop
79
79
  spliced + [(new_end..new_begin)]
80
80
  else
81
81
  spliced + [last, r]
@@ -83,17 +83,17 @@ module RangeUtils
83
83
  end
84
84
  end
85
85
  end
86
-
86
+
87
87
  # Returns the number of members of the given Range.
88
88
  # size_from_range(0..0) #=> 1
89
89
  # size_from_range(12..123) #=> 112
90
- # Range members must support aruthmetic with integers.
90
+ # Range members must support arithmetic with integers.
91
91
  def size_from_range(range)
92
92
  size = range.end - range.begin + 1
93
93
  raise NegativeRangeSpan, "The resulting size for range #{range} is negative" if size < 0
94
94
  size
95
95
  end
96
-
96
+
97
97
  # Take N items from the range, and return two Ranges
98
98
  # the first being the range containing N items requested,
99
99
  # and the other containing the remainder
@@ -103,13 +103,29 @@ module RangeUtils
103
103
  #
104
104
  # take(4..514, 1024) #=> [4..514, nil]
105
105
  #
106
- # Range members and n_items must support aruthmetic with integers
106
+ # Range members and n_items must support arithmetic with integers
107
107
  def take(from_range, n_items)
108
108
  end_at = from_range.begin + (n_items - 1)
109
109
  return [from_range, nil] if end_at >= from_range.end
110
110
  [from_range.begin..end_at, end_at.succ..from_range.end]
111
111
  end
112
-
112
+
113
+ # Returns the intersection of two given Ranges or `nil` if they do not intersect.
114
+ # Adjacent ranges do not get merged.
115
+ #
116
+ # intersection_of(0..456, 26..12889) #=> 26..456
117
+ # intersection_of(0..456, 7811..12889) #=> nil
118
+ # intersection_of(0..0, 1..1) #=> nil
119
+ #
120
+ # Range members and n_items must support arithmetic with integers
121
+ def intersection_of(range_a, range_b)
122
+ range_a, range_b = [range_a, range_b].sort_by(&:begin)
123
+ return if range_a.end < range_b.begin
124
+ heads_and_tails = [range_a.begin, range_b.begin, range_a.end, range_b.end].sort
125
+ middle = heads_and_tails[1..-2]
126
+ middle[0]..middle[1]
127
+ end
128
+
113
129
  alias_method :http_ranges_for_size, :ranges_of_offfsets_for_size
114
130
  extend self
115
131
  end
@@ -0,0 +1,3 @@
1
+ module RangeUtils
2
+ VERSION = '2.0.0'
3
+ end
@@ -1,59 +1,34 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
- # -*- encoding: utf-8 -*-
5
- # stub: range_utils 1.3.1 ruby lib
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'range_utils/version'
6
4
 
7
- Gem::Specification.new do |s|
8
- s.name = "range_utils"
9
- s.version = "1.3.1"
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'range_utils'
7
+ spec.version = RangeUtils::VERSION
8
+ spec.authors = ['Julik Tarkhanov']
9
+ spec.email = ['me@julik.nl']
10
10
 
11
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
- s.require_paths = ["lib"]
13
- s.authors = ["Julik Tarkhanov"]
14
- s.date = "2015-11-26"
15
- s.description = "There is a whole range of things you can do with a Range"
16
- s.email = "me@julik.nl"
17
- s.extra_rdoc_files = [
18
- "LICENSE.txt",
19
- "README.md"
20
- ]
21
- s.files = [
22
- ".document",
23
- ".rspec",
24
- ".travis.yml",
25
- "Gemfile",
26
- "LICENSE.txt",
27
- "README.md",
28
- "Rakefile",
29
- "lib/range_utils.rb",
30
- "range_utils.gemspec",
31
- "spec/range_utils_spec.rb"
32
- ]
33
- s.homepage = "http://github.com/julik/range_utils"
34
- s.licenses = ["MIT"]
35
- s.rubygems_version = "2.2.2"
36
- s.summary = "Range splice, split and other niceties"
11
+ spec.description = %q{There is a whole range of things you can do with a Range}
12
+ spec.summary = %q{Range splice, split and other niceties}
13
+ spec.homepage = 'http://github.com/wetransfer/range_utils'
37
14
 
38
- if s.respond_to? :specification_version then
39
- s.specification_version = 4
40
-
41
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
42
- s.add_development_dependency(%q<rspec>, ["~> 3.0"])
43
- s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
44
- s.add_development_dependency(%q<bundler>, ["~> 1.0"])
45
- s.add_development_dependency(%q<jeweler>, [">= 0"])
46
- else
47
- s.add_dependency(%q<rspec>, ["~> 3.0"])
48
- s.add_dependency(%q<rdoc>, ["~> 3.12"])
49
- s.add_dependency(%q<bundler>, ["~> 1.0"])
50
- s.add_dependency(%q<jeweler>, [">= 0"])
51
- end
15
+ # Prevent pushing this gem to RubyGems.org.
16
+ # To allow pushes either set the 'allowed_push_host'
17
+ # To allow pushing to a single host or delete this section to allow pushing to any host.
18
+ if spec.respond_to?(:metadata)
19
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
52
20
  else
53
- s.add_dependency(%q<rspec>, ["~> 3.0"])
54
- s.add_dependency(%q<rdoc>, ["~> 3.12"])
55
- s.add_dependency(%q<bundler>, ["~> 1.0"])
56
- s.add_dependency(%q<jeweler>, [">= 0"])
21
+ raise 'RubyGems 2.0 or newer is required to protect against ' \
22
+ 'public gem pushes.'
57
23
  end
58
- end
59
24
 
25
+ spec.files = `git ls-files -z`.split("\x0")
26
+ spec.bindir = 'exe'
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ['lib']
29
+
30
+ spec.add_development_dependency 'bundler'
31
+ spec.add_development_dependency 'rake', '~> 12.2'
32
+ spec.add_development_dependency 'rspec', '~> 3'
33
+ spec.add_development_dependency 'wetransfer_style', '0.6.0'
34
+ end
@@ -3,96 +3,96 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
3
  require 'rspec'
4
4
  require 'range_utils'
5
5
 
6
- RSpec.configure {|c| c.order = 'random' }
6
+ RSpec.configure { |c| c.order = 'random' }
7
7
 
8
8
  describe "RangeUtils" do
9
9
  let(:subject) { RangeUtils }
10
-
10
+
11
11
  context '.range_includes_item?' do
12
12
  it 'properly detects inclusion' do
13
13
  range = 5..98
14
14
  expect(subject.range_includes_item?(range, 5)).to eq(true)
15
15
  expect(subject.range_includes_item?(range, 98)).to eq(true)
16
16
  expect(subject.range_includes_item?(range, 97)).to eq(true)
17
-
17
+
18
18
  expect(subject.range_includes_item?(range, 1)).to eq(false)
19
19
  expect(subject.range_includes_item?(range, 4)).to eq(false)
20
20
  end
21
21
  end
22
-
22
+
23
23
  context '.split_range_into_subranges_of' do
24
24
  it 'raises an ArgumentError when the size is < 1' do
25
25
  expect {
26
26
  subject.split_range_into_subranges_of(15..456, -2)
27
27
  }.to raise_error(ArgumentError, 'Chunk size should be > 0, was -2')
28
-
28
+
29
29
  expect {
30
30
  subject.split_range_into_subranges_of(15..456, 0)
31
31
  }.to raise_error(ArgumentError, 'Chunk size should be > 0, was 0')
32
32
  end
33
-
33
+
34
34
  it 'splits a range into ranges' do
35
35
  expect(subject.split_range_into_subranges_of(0..7, 3)).to eq([0..2, 3..5, 6..7])
36
36
  expect(subject.split_range_into_subranges_of(0..786, 324)).to eq([0..323, 324..647, 648..786])
37
37
  expect(subject.split_range_into_subranges_of(245..786, 324)).to eq([245..568, 569..786])
38
38
  end
39
-
39
+
40
40
  it 'yields each subrange in succession' do
41
41
  expect { |b|
42
42
  subject.split_range_into_subranges_of(0..786, 324, &b)
43
43
  }.to yield_successive_args(0..323, 324..647, 648..786)
44
44
  end
45
-
45
+
46
46
  it 'splits a range that spans 1 item' do
47
47
  expect(subject.split_range_into_subranges_of(0..0, 1)).to eq([0..0])
48
48
  expect(subject.split_range_into_subranges_of(0..0, 15)).to eq([0..0])
49
49
  end
50
-
50
+
51
51
  it 'handles all division cases without raising exceptions' do
52
- (1..300).each do | chunk_size |
52
+ (1..300).each do |chunk_size|
53
53
  subject.split_range_into_subranges_of(0..786, chunk_size)
54
54
  end
55
55
  end
56
-
56
+
57
57
  it 'is usable for HTTP ranges' do
58
58
  bytes_total = 3087
59
59
  chunk_size = 991
60
60
  range = 128..(bytes_total + 128)
61
-
61
+
62
62
  ranges = subject.split_range_into_subranges_of(range, chunk_size)
63
63
  expect(ranges).to eq([128..1118, 1119..2109, 2110..3100, 3101..3215])
64
64
  end
65
65
  end
66
-
66
+
67
67
  context '.splice' do
68
68
  it 'splices adjacent and overlapping ranges, regardless of their ordering in the argument array' do
69
- expect( subject.splice([500..600, 601..999]) ).to eq([500..999])
70
- expect( subject.splice([601..999, 500..600]) ).to eq([500..999])
71
- expect( subject.splice([500..700, 601..999]) ).to eq([500..999])
69
+ expect(subject.splice([500..600, 601..999])).to eq([500..999])
70
+ expect(subject.splice([601..999, 500..600])).to eq([500..999])
71
+ expect(subject.splice([500..700, 601..999])).to eq([500..999])
72
72
  end
73
-
73
+
74
74
  it 'creates gaps when the ranges cannot be spliced' do
75
- expect( subject.splice([500..600, 602..999]) ).to eq([500..600, 602..999])
76
- expect( subject.splice([601..999, 500..600, 10..44]) ).to eq([10..44, 500..999])
75
+ expect(subject.splice([500..600, 602..999])).to eq([500..600, 602..999])
76
+ expect(subject.splice([601..999, 500..600, 10..44])).to eq([10..44, 500..999])
77
77
  end
78
78
  end
79
-
79
+
80
80
  context '.ranges_of_offfsets_for_size' do
81
81
  it 'raises with a size < 1' do
82
82
  expect {
83
83
  subject.ranges_of_offfsets_for_size(3, 0)
84
84
  }.to raise_error(ArgumentError, 'Chunk size should be > 0, was 0')
85
-
85
+
86
86
  expect {
87
87
  subject.ranges_of_offfsets_for_size(3, -1)
88
88
  }.to raise_error(ArgumentError, 'Chunk size should be > 0, was -1')
89
89
  end
90
-
90
+
91
91
  it 'creates the ranges that cover the given number of elements' do
92
92
  expect(subject.ranges_of_offfsets_for_size(3, 1)).to eq([0..0, 1..1, 2..2])
93
93
  expect(subject.ranges_of_offfsets_for_size(3, 2)).to eq([0..1, 2..2])
94
94
  end
95
-
95
+
96
96
  it 'splits a bigger size' do
97
97
  bytes_total = 3087
98
98
  chunk_size = 991
@@ -100,29 +100,29 @@ describe "RangeUtils" do
100
100
  expect(ranges).to eq([0..990, 991..1981, 1982..2972, 2973..3086])
101
101
  end
102
102
  end
103
-
103
+
104
104
  context '.range_for_size_of' do
105
105
  it 'raises on size being < 0' do
106
106
  expect {
107
107
  subject.range_for_size_of(-4)
108
108
  }.to raise_error(ArgumentError)
109
109
  end
110
-
110
+
111
111
  it 'returns a special range for size 0 case' do
112
112
  expect(subject.range_for_size_of(0)).to eq(0..-1)
113
113
  end
114
-
114
+
115
115
  it 'returns the right range for the size' do
116
116
  expect(subject.range_for_size_of(456)).to eq(0..455)
117
117
  end
118
118
  end
119
-
119
+
120
120
  context '.http_ranges_for_resource_size' do
121
121
  it 'get returned without including the last value' do
122
122
  expect(subject.http_ranges_for_size(785, 324)).to eq([0..323, 324..647, 648..784])
123
123
  end
124
124
  end
125
-
125
+
126
126
  context '.take' do
127
127
  it 'returns the first range and the remainder' do
128
128
  first, remainder = subject.take(0..12, 3)
@@ -131,29 +131,42 @@ describe "RangeUtils" do
131
131
  expect(remainder).to eq(3..12)
132
132
  expect(subject.splice([first, remainder])).to eq([0..12])
133
133
  end
134
-
134
+
135
135
  it 'returns nil as the remainder if n_items exceeds the whole range' do
136
136
  first, remainder = subject.take(0..12, 15)
137
137
  expect(first).to eq(0..12)
138
138
  expect(remainder).to be_nil
139
139
  end
140
-
140
+
141
141
  it 'handles the 0-item remainder range case correctly' do
142
142
  first, remainder = subject.take(0..1, 2)
143
143
  expect(first).to eq(0..1)
144
144
  expect(remainder).to be_nil
145
145
  end
146
146
  end
147
-
147
+
148
148
  context '.size_from_range' do
149
149
  it 'raises an ArgumentError when the range goes into negative' do
150
- expect{
150
+ expect {
151
151
  subject.size_from_range(0..-15)
152
152
  }.to raise_error(RangeUtils::NegativeRangeSpan, 'The resulting size for range 0..-15 is negative')
153
153
  end
154
-
154
+
155
155
  it 'computes the right size from the given Range' do
156
156
  expect(subject.size_from_range(0..522753)).to eq(522754)
157
157
  end
158
158
  end
159
+
160
+ context '.range_intersection_of' do
161
+ it 'computes range intersections' do
162
+ expect(RangeUtils.intersection_of(0..123, 456..456)).to be_nil
163
+ expect(RangeUtils.intersection_of(0..123, 245..245)).to be_nil
164
+
165
+ expect(RangeUtils.intersection_of(0..0, 1..1)).to be_nil
166
+ expect(RangeUtils.intersection_of(0..1, 1..1)).to eq(1..1)
167
+
168
+ expect(RangeUtils.intersection_of(15..145859, 85..564)).to eq(85..564)
169
+ expect(RangeUtils.intersection_of(15..145859, 85..145870)).to eq(85..145859)
170
+ end
171
+ end
159
172
  end
metadata CHANGED
@@ -1,93 +1,95 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: range_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julik Tarkhanov
8
8
  autorequire:
9
- bindir: bin
9
+ bindir: exe
10
10
  cert_chain: []
11
- date: 2015-11-26 00:00:00.000000000 Z
11
+ date: 2019-01-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rspec
14
+ name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '3.0'
19
+ version: '0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '3.0'
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: rdoc
28
+ name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '3.12'
33
+ version: '12.2'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '3.12'
40
+ version: '12.2'
41
41
  - !ruby/object:Gem::Dependency
42
- name: bundler
42
+ name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '1.0'
47
+ version: '3'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '1.0'
54
+ version: '3'
55
55
  - !ruby/object:Gem::Dependency
56
- name: jeweler
56
+ name: wetransfer_style
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - '='
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: 0.6.0
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - '='
67
67
  - !ruby/object:Gem::Version
68
- version: '0'
68
+ version: 0.6.0
69
69
  description: There is a whole range of things you can do with a Range
70
- email: me@julik.nl
70
+ email:
71
+ - me@julik.nl
71
72
  executables: []
72
73
  extensions: []
73
- extra_rdoc_files:
74
- - LICENSE.txt
75
- - README.md
74
+ extra_rdoc_files: []
76
75
  files:
77
76
  - ".document"
77
+ - ".gitignore"
78
78
  - ".rspec"
79
+ - ".rubocop.yml"
79
80
  - ".travis.yml"
80
81
  - Gemfile
81
82
  - LICENSE.txt
82
83
  - README.md
83
84
  - Rakefile
84
85
  - lib/range_utils.rb
86
+ - lib/range_utils/version.rb
85
87
  - range_utils.gemspec
86
88
  - spec/range_utils_spec.rb
87
- homepage: http://github.com/julik/range_utils
88
- licenses:
89
- - MIT
90
- metadata: {}
89
+ homepage: http://github.com/wetransfer/range_utils
90
+ licenses: []
91
+ metadata:
92
+ allowed_push_host: https://rubygems.org
91
93
  post_install_message:
92
94
  rdoc_options: []
93
95
  require_paths:
@@ -104,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
104
106
  version: '0'
105
107
  requirements: []
106
108
  rubyforge_project:
107
- rubygems_version: 2.2.2
109
+ rubygems_version: 2.6.11
108
110
  signing_key:
109
111
  specification_version: 4
110
112
  summary: Range splice, split and other niceties