librtree 1.0.1 → 1.0.2

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.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +8 -0
  3. data/README.md +1 -0
  4. data/lib/rtree.rb +31 -20
  5. metadata +16 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7dbcdf3078b84e506da1a5afb4e0f31db7490ef8b57860c3d670dae5422bb283
4
- data.tar.gz: 9c63a1227bbf656f12360acda82a0f7a7c369d27a25ae1352c906af769f5c2d3
3
+ metadata.gz: c35526142564e94d93f091e405467f2ee2df3d294b1a4b8e3a87db66f1229043
4
+ data.tar.gz: dffb928767c821a14460f21d06fc1c90e41a7a17a94a8e700fac0c409d65ca59
5
5
  SHA512:
6
- metadata.gz: 6c54dae2e5b2e4601c6730fd7e3d50e7f87c5af3a067b7b9c2167c8f43c8c43d52429f7db18db17116cfc958f54587b7009ee92a69d59843048ca53b6b422878
7
- data.tar.gz: 1c9aa746ba96bd5413add8a1629a2c84da513e0ed5467d553a10dcfe6f2c776b15d9dd45afac3ff2a33b6cef40633bc7937bffceb0f877c7c03f30ac34bdd8eb
6
+ metadata.gz: 0447a6e59546922ed8d227e0f3589aae7771243c4e16c24ae46cde5075dae4b1f7be2b1a8526d58adc6c3db379719201fcf370f1251e82773f488046ab66caff
7
+ data.tar.gz: 8ed4fd4e3982a4bfbffac9a53f92ae6dfd497ac4e684110d72591e7ec500a4ee2629a5b3a17dad5cc404383eb7aaccf333d7d15a8aeaa943d858a3e973a35d13
data/CHANGELOG.md CHANGED
@@ -1,6 +1,14 @@
1
1
  Changelog
2
2
  ---------
3
3
 
4
+ ### 1.0.2, pending
5
+
6
+ - The `#serialise` method raises if the read from pipe returns
7
+ nil (which it might), so the method (and other methods which
8
+ call it to serialise) now return `String` or raise
9
+ - Added RBS static type signatures and infrastructure for static
10
+ type checking with **steep**
11
+
4
12
  ### 1.0.1, 16-03-2023
5
13
 
6
14
  - Update to 1.1.4 of embedded `librtree`
data/README.md CHANGED
@@ -79,6 +79,7 @@ run the tests:
79
79
 
80
80
  bundle exec rake compile
81
81
  bundle exec rake spec
82
+ bundle exec steep check
82
83
 
83
84
 
84
85
  [1]: http://www.digip.org/jansson/
data/lib/rtree.rb CHANGED
@@ -71,6 +71,10 @@ class RTree < RTreeBase
71
71
 
72
72
  # @!visibility private
73
73
  #
74
+ # The call to exit! here has a true argument, indicationg success,
75
+ # but the value is ignored, so could be omitted; but the sigature
76
+ # for exit! is incorrect: https://github.com/ruby/rbs/issues/1298
77
+ #
74
78
  def deserialise(string, encoding)
75
79
  raise TypeError unless string.is_a? String
76
80
  rd, wr = IO.pipe(encoding)
@@ -89,7 +93,7 @@ class RTree < RTreeBase
89
93
  wr.write(string)
90
94
  ensure
91
95
  wr.close
92
- exit!
96
+ exit! true
93
97
  end
94
98
  end
95
99
  result
@@ -97,13 +101,15 @@ class RTree < RTreeBase
97
101
 
98
102
  # @!visibility private
99
103
  #
104
+ # See note above on argument to exit!
105
+ #
100
106
  def serialise(encoding)
101
107
  rd, wr = IO.pipe(encoding)
102
108
  if fork then
103
109
  wr.close
104
110
  unset_nonblock(rd)
105
111
  begin
106
- result = rd.read
112
+ result = rd.read || raise(IOError, 'reading from pipe')
107
113
  ensure
108
114
  rd.close
109
115
  Process.wait
@@ -114,7 +120,7 @@ class RTree < RTreeBase
114
120
  yield(wr)
115
121
  ensure
116
122
  wr.close
117
- exit!
123
+ exit! true
118
124
  end
119
125
  end
120
126
  result
@@ -233,19 +239,12 @@ class RTree < RTreeBase
233
239
  # https://stackoverflow.com/questions/68122256/ It's still not
234
240
  # clear to me why this qualification is needed, but that's a
235
241
  # problem with my understanding of the Ruby Eigenclass, it is
236
- # the expected behaviour
242
+ # the expected behaviour. Note that self.const_get(:FOO) is
243
+ # the same as self::FOO, but the latter gives a spurious
244
+ # type-warning from steep
237
245
  #
238
246
  def split_flag(split)
239
- case split
240
- when :quadratic
241
- self::SPLIT_QUADRATIC
242
- when :linear
243
- self::SPLIT_LINEAR
244
- when :greene
245
- self::SPLIT_GREENE
246
- else
247
- raise ArgumentError, "bad split value: #{split}"
248
- end
247
+ self.const_get(split_symbol(split))
249
248
  end
250
249
 
251
250
  # @!visibility private
@@ -256,10 +255,22 @@ class RTree < RTreeBase
256
255
 
257
256
  private
258
257
 
259
- def deserialise(*args, &block)
260
- RTree::IOUtil.deserialise(*args, &block)
258
+ def deserialise(string, encoding, &block)
259
+ RTree::IOUtil.deserialise(string, encoding, &block)
261
260
  end
262
261
 
262
+ def split_symbol(split)
263
+ case split
264
+ when :quadratic
265
+ :SPLIT_QUADRATIC
266
+ when :linear
267
+ :SPLIT_LINEAR
268
+ when :greene
269
+ :SPLIT_GREENE
270
+ else
271
+ raise ArgumentError, "bad split value: #{split}"
272
+ end
273
+ end
263
274
  end
264
275
 
265
276
  # Initialize a new (empty) RTree
@@ -512,8 +523,8 @@ class RTree < RTreeBase
512
523
  node_page_flag | split_flag
513
524
  end
514
525
 
515
- def serialise(*args, &block)
516
- RTree::IOUtil.serialise(*args, &block)
526
+ def serialise(encoding, &block)
527
+ RTree::IOUtil.serialise(encoding, &block)
517
528
  end
518
529
 
519
530
  end
@@ -576,8 +587,8 @@ class RTree::Style < RTreeStyleBase
576
587
 
577
588
  private
578
589
 
579
- def deserialise(*args, &block)
580
- RTree::IOUtil.deserialise(*args, &block)
590
+ def deserialise(string, encoding, &block)
591
+ RTree::IOUtil.deserialise(string, encoding, &block)
581
592
  end
582
593
 
583
594
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: librtree
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - J.J. Green
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-16 00:00:00.000000000 Z
11
+ date: 2023-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -108,6 +108,20 @@ dependencies:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: '1.1'
111
+ - !ruby/object:Gem::Dependency
112
+ name: steep
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '1.3'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '1.3'
111
125
  description: |
112
126
  A Ruby extension implementing the R-tree spatial-index of
113
127
  Guttman-Green.