interval_set 0.1.0.pre.SNAPSHOT → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dcccff0b79c5c4336c91dae3bb64341dce4eba50
4
- data.tar.gz: a9af7af763952619b651bc5a014b50a6d9622ecc
3
+ metadata.gz: e161c0a76439ab2e80de1567dfd7a4b4613a7340
4
+ data.tar.gz: 83fcb9323b1b21792bb8db45aaf2b1d202117055
5
5
  SHA512:
6
- metadata.gz: f9abbfbb43e9da0be6c8c7daef8444e978f9c91c5443b759f2d62283b46174b5ee3f746e8b58466a8261106c328f13de61d051064e688f816673db274e379980
7
- data.tar.gz: 5310ee26f32e2ddb203aa0b9a0abbc225ce2fdd6f3f90895ff92359dc0db4d317ad5dd6b0626ac7d7b2678cd84c5996570f5b63a476d6cd314449c9d0dbe5aa6
6
+ metadata.gz: 46f4169b72e0a1ce24cffedf7fe56f3fd058ecff04d4db92660ad77e94816844d63b044cf21e363a7abf73ffc0765d64df3cadd2dc0e45a90566fed54de0b0a0
7
+ data.tar.gz: c99c4d21c9bdd2a03b23d5cc7e904dd6222a3884e38142bf90789abaa0e64a5910ff62dc3e7a5fc5083cc029f8f4d0ceb2bee6b285e6a9d8c2dbfd1efc7ef055
data/.gitignore CHANGED
@@ -7,3 +7,4 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+ *.gem
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --require spec_helper
data/Gemfile CHANGED
@@ -4,3 +4,5 @@ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
4
 
5
5
  # Specify your gem's dependencies in interval_set.gemspec
6
6
  gemspec
7
+
8
+ gem 'rspec', '~> 3.7'
data/Gemfile.lock CHANGED
@@ -1,14 +1,28 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- interval_set (0.1.0.pre.SNAPSHOT)
4
+ interval_set (0.1.0)
5
5
  treemap-fork (~> 1.0, >= 1.0.4.2)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
+ diff-lcs (1.3)
10
11
  minitest (5.10.3)
11
12
  rake (10.5.0)
13
+ rspec (3.7.0)
14
+ rspec-core (~> 3.7.0)
15
+ rspec-expectations (~> 3.7.0)
16
+ rspec-mocks (~> 3.7.0)
17
+ rspec-core (3.7.0)
18
+ rspec-support (~> 3.7.0)
19
+ rspec-expectations (3.7.0)
20
+ diff-lcs (>= 1.2.0, < 2.0)
21
+ rspec-support (~> 3.7.0)
22
+ rspec-mocks (3.7.0)
23
+ diff-lcs (>= 1.2.0, < 2.0)
24
+ rspec-support (~> 3.7.0)
25
+ rspec-support (3.7.0)
12
26
  treemap-fork (1.0.4.2)
13
27
 
14
28
  PLATFORMS
@@ -19,6 +33,7 @@ DEPENDENCIES
19
33
  interval_set!
20
34
  minitest (~> 5.0)
21
35
  rake (~> 10.0)
36
+ rspec (~> 3.7)
22
37
 
23
38
  BUNDLED WITH
24
39
  1.16.0
data/README.md CHANGED
@@ -16,11 +16,11 @@ And then execute:
16
16
 
17
17
  Or install it yourself as:
18
18
 
19
- $ gem install rangeset
19
+ $ gem install interval_set
20
20
 
21
21
  ## Documentation
22
22
 
23
- http://www.rubydoc.info/github/rjasper/rangeset
23
+ http://www.rubydoc.info/gems/interval_set
24
24
 
25
25
  ## Usage
26
26
 
@@ -254,13 +254,13 @@ i.shift!(1) # -> [2000-01-02...2000-01-04]
254
254
 
255
255
  ## Development
256
256
 
257
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
257
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the specs. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
258
258
 
259
259
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
260
260
 
261
261
  ## Contributing
262
262
 
263
- Bug reports and pull requests are welcome on GitHub at https://github.com/rjasper/rangeset. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
263
+ Bug reports and pull requests are welcome on GitHub at https://github.com/rjasper/ruby-interval_set. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
264
264
 
265
265
  ## License
266
266
 
@@ -268,4 +268,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
268
268
 
269
269
  ## Code of Conduct
270
270
 
271
- Everyone interacting in the Rangeset project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/rjasper/rangeset/blob/master/CODE_OF_CONDUCT.md).
271
+ Everyone interacting in the IntervalSet project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/rjasper/ruby-interval_set/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile CHANGED
@@ -1,10 +1,11 @@
1
1
  require "bundler/gem_tasks"
2
- require "rake/testtask"
3
2
 
4
- Rake::TestTask.new(:test) do |t|
5
- t.libs << "test"
6
- t.libs << "lib"
7
- t.test_files = FileList["test/**/*_test.rb"]
8
- end
3
+ begin
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
9
7
 
10
- task :default => :test
8
+ task :default => :spec
9
+ rescue LoadError
10
+ # no rspec available
11
+ end
data/bin/console CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require "bundler/setup"
4
- require "rangeset"
4
+ require "interval_set"
5
5
 
6
6
  # You can add fixtures and/or initialization code here to make experimenting
7
7
  # with your gem easier. You can also use a different console, if you like.
data/interval_set.gemspec CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ['jasper.rico@gmail.com']
11
11
 
12
12
  spec.summary = 'Set of sorted non-overlapping ranges'
13
- spec.homepage = 'https://github.com/rjasper/interval_set'
13
+ spec.homepage = 'https://github.com/rjasper/ruby-interval_set'
14
14
  spec.license = 'MIT'
15
15
 
16
16
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
@@ -1,3 +1,3 @@
1
1
  class IntervalSet
2
- VERSION = '0.1.0-SNAPSHOT'
2
+ VERSION = '0.1.0'
3
3
  end
data/lib/interval_set.rb CHANGED
@@ -15,8 +15,8 @@ class IntervalSet
15
15
  # array = [0...1, 2...3]
16
16
  # IntervalSet[*array] # -> [0...1, 2...3]
17
17
  #
18
- # @param ranges [Range[]] a list of ranges to be added to the new Rangeset
19
- # @return [IntervalSet] a new RangeSet containing the supplied ranges.
18
+ # @param ranges [Range[]] a list of ranges to be added to the new IntervalSet
19
+ # @return [IntervalSet] a new IntervalSet containing the supplied ranges.
20
20
  def self.[](*ranges)
21
21
  IntervalSet.new.tap do |interval_set|
22
22
  ranges.each {|range| interval_set << range}
@@ -70,15 +70,14 @@ class IntervalSet
70
70
  empty? ? nil : min...max
71
71
  end
72
72
 
73
- # Returns +true+ if two RangeSets are equal.
73
+ # Returns +true+ if two IntervalSets are equal.
74
74
  #
75
75
  # IntervalSet[0...1] == IntervalSet[0...1] # -> true
76
76
  # IntervalSet[0...1] == IntervalSet[1...2] # -> false
77
77
  #
78
- # @param other [IntervalSet] the other RangeSet.
78
+ # @param other [Object] the other object.
79
79
  def eql?(other)
80
- return false if count != other.count
81
- return false if bounds != other.bounds
80
+ return false if other.nil? || !other.is_a?(IntervalSet) || count != other.count || bounds != other.bounds
82
81
 
83
82
  lhs_iter = enum_for
84
83
  rhs_iter = other.enum_for
@@ -114,8 +113,13 @@ class IntervalSet
114
113
  # i.include?(0.5) # -> true
115
114
  # i.include?(1) # -> false ; a range's end is exclusive
116
115
  #
116
+ # Note that the given element must be comparable to elements already in this
117
+ # set. Otherwise, the behavior is undefined.
118
+ #
117
119
  # @param element [Object]
118
120
  def include?(element)
121
+ return false if element.nil?
122
+
119
123
  floor_entry = @range_map.floor_entry(element)
120
124
 
121
125
  !floor_entry.nil? && floor_entry.value.last > element
@@ -237,17 +241,17 @@ class IntervalSet
237
241
  #
238
242
  # i = IntervalSet[0...1] # -> [0...1]
239
243
  #
240
- # # Ranges only need a single common element with the range set
244
+ # # Ranges only need a single common element with the interval set
241
245
  # i.intersect?(0...1) # -> true
242
246
  # i.intersect?(0...2) # -> true
243
247
  # i.intersect?(1...2) # -> false ; the start of a range is inclusive but the end exclusive
244
248
  #
245
- # # The same applies for range sets
249
+ # # The same applies for interval sets
246
250
  # i.intersect?(IntervalSet[0...1]) # -> true
247
251
  # i.intersect?(IntervalSet[0...1, 2...3]) # -> true
248
252
  # i.intersect?(IntervalSet[2...3]) # -> false
249
253
  #
250
- # @param other [Range | IntervalSet | #<=>] the other object.
254
+ # @param other [Range | IntervalSet] the other object.
251
255
  def intersect?(other)
252
256
  case other
253
257
  when Range
@@ -270,7 +274,7 @@ class IntervalSet
270
274
  # i << (1...2) # -> [0...3]
271
275
  # i.count # -> 1
272
276
  #
273
- # @return [Integer] the number of ranges.
277
+ # @return [Fixnum] the number of ranges.
274
278
  def count
275
279
  @range_map.count
276
280
  end
@@ -353,7 +357,7 @@ class IntervalSet
353
357
  # IntervalSet[0...2, 3...5] & IntervalSet[1...4, 5...6] # -> [1...2, 3...4]
354
358
  #
355
359
  # @param other [Range, IntervalSet] the other object.
356
- # @return [IntervalSet] a new RangeSet containing the intersection.
360
+ # @return [IntervalSet] a new IntervalSet containing the intersection.
357
361
  def intersection(other)
358
362
  case other
359
363
  when Range
@@ -376,7 +380,7 @@ class IntervalSet
376
380
  # <code>+=</code> or <code>|=</code>.
377
381
  #
378
382
  # @param other [Range, IntervalSet] the other object.
379
- # @return [IntervalSet] a new RangeSet containing the union.
383
+ # @return [IntervalSet] a new IntervalSet containing the union.
380
384
  def union(other)
381
385
  case other
382
386
  when Range
@@ -400,7 +404,7 @@ class IntervalSet
400
404
  # than <code>-=</code>.
401
405
  #
402
406
  # @param other [Range, IntervalSet] the other object.
403
- # @return [IntervalSet] a new RangeSet containing the difference.
407
+ # @return [IntervalSet] a new IntervalSet containing the difference.
404
408
  def difference(other)
405
409
  case other
406
410
  when Range
@@ -424,7 +428,7 @@ class IntervalSet
424
428
  # IntervalSet[0...1] ^ IntervalSet[0...1] # -> []
425
429
  #
426
430
  # @param other [Range, IntervalSet]
427
- # @return [IntervalSet] a new RangeSet containing the exclusive set.
431
+ # @return [IntervalSet] a new IntervalSet containing the exclusive set.
428
432
  def xor(other)
429
433
  clone.xor!(other)
430
434
  end
@@ -442,7 +446,7 @@ class IntervalSet
442
446
  # IntervalSet[0...1].xor!(IntervalSet[0...1]) # -> []
443
447
  #
444
448
  # @param other [Range, IntervalSet]
445
- # @return [IntervalSet] a new RangeSet containing the exclusive set.
449
+ # @return [IntervalSet] a new IntervalSet containing the exclusive set.
446
450
  def xor!(other)
447
451
  intersection = self & other
448
452
 
@@ -462,7 +466,7 @@ class IntervalSet
462
466
  # IntervalSet[0...4].convolve!(0...0) # -> []
463
467
  # IntervalSet[0...4].convolve!(1...0) # -> []
464
468
  #
465
- # # Convolve with a range set
469
+ # # Convolve with a interval set
466
470
  # IntervalSet[0...1, 10...12].convolve!(IntervalSet[-2...1, 1...2]) # -> [-2...3, 8...14]
467
471
  #
468
472
  # @param other [Range | IntervalSet] the other object.
@@ -491,11 +495,11 @@ class IntervalSet
491
495
  # IntervalSet[0...4] * (0...0) # -> []
492
496
  # IntervalSet[0...4] * (1...0) # -> []
493
497
  #
494
- # # Convolve with a range set
498
+ # # Convolve with a interval set
495
499
  # IntervalSet[0...1, 10...12] * IntervalSet[-2...1, 1...2] # -> [-2...3, 8...14]
496
500
  #
497
501
  # @param other [Range | IntervalSet] the other object.
498
- # @return [IntervalSet] a new RangeSet containing the convolution.
502
+ # @return [IntervalSet] a new IntervalSet containing the convolution.
499
503
  def convolve(other)
500
504
  clone.convolve!(other)
501
505
  end
@@ -530,7 +534,7 @@ class IntervalSet
530
534
  # not assume numbers as element type.
531
535
  #
532
536
  # @param amount [Object]
533
- # @return [IntervalSet] a new RangeSet shifted by +amount+.
537
+ # @return [IntervalSet] a new IntervalSet shifted by +amount+.
534
538
  def shift(amount)
535
539
  clone.shift!(amount)
536
540
  end
@@ -571,7 +575,7 @@ class IntervalSet
571
575
  #
572
576
  # @param left [Object] margin added to the left side of each range.
573
577
  # @param right [Object] margin added to the right side of each range.
574
- # @return [IntervalSet] a new RangeSet containing the buffered ranges.
578
+ # @return [IntervalSet] a new IntervalSet containing the buffered ranges.
575
579
  def buffer(left, right)
576
580
  clone.buffer!(left, right)
577
581
  end
@@ -601,7 +605,7 @@ class IntervalSet
601
605
  end
602
606
 
603
607
  # Replaces the content of this IntervalSet by the content of the given IntervalSet.
604
- # @param interval_set [IntervalSet] the other RangeSet to be copied
608
+ # @param interval_set [IntervalSet] the other IntervalSet to be copied
605
609
  # @return [IntervalSet] self.
606
610
  def copy(interval_set)
607
611
  clear
@@ -983,7 +987,7 @@ class IntervalSet
983
987
  def self.normalize_range(range)
984
988
  range.exclude_end? ? range : range.first...range.last
985
989
  end
986
-
990
+
987
991
  def self.unexpected_object(object)
988
992
  raise ArgumentError.new("unexpected object #{object}")
989
993
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: interval_set
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.pre.SNAPSHOT
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rico Jasper
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-12-12 00:00:00.000000000 Z
11
+ date: 2017-12-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -80,6 +80,7 @@ extensions: []
80
80
  extra_rdoc_files: []
81
81
  files:
82
82
  - ".gitignore"
83
+ - ".rspec"
83
84
  - ".travis.yml"
84
85
  - CODE_OF_CONDUCT.md
85
86
  - Gemfile
@@ -92,7 +93,7 @@ files:
92
93
  - interval_set.gemspec
93
94
  - lib/interval_set.rb
94
95
  - lib/interval_set/version.rb
95
- homepage: https://github.com/rjasper/interval_set
96
+ homepage: https://github.com/rjasper/ruby-interval_set
96
97
  licenses:
97
98
  - MIT
98
99
  metadata: {}
@@ -107,9 +108,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
107
108
  version: '0'
108
109
  required_rubygems_version: !ruby/object:Gem::Requirement
109
110
  requirements:
110
- - - ">"
111
+ - - ">="
111
112
  - !ruby/object:Gem::Version
112
- version: 1.3.1
113
+ version: '0'
113
114
  requirements: []
114
115
  rubyforge_project:
115
116
  rubygems_version: 2.6.12