bmg 0.21.3 → 0.21.4

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: 83f3d7ebfe5587af85b9823b7ab5a9d11d6e9b30
4
- data.tar.gz: 34418e3d5ccfe156c3b0320e6821030a09ba1cdc
3
+ metadata.gz: 59da4b61f1d6c332de148552eab6277032df750c
4
+ data.tar.gz: b65877260b6a5eca59fb864f52a08dad26f917f4
5
5
  SHA512:
6
- metadata.gz: f1e68f36ad0cd1a5c9ba2d2dd5fdcd8f02220c3588e5ef995439db58c46dab2bb6fa91ff249f3541ae2096e9d12f3c0d9a9d424c99310c7e90fef7cd4f460994
7
- data.tar.gz: 0c9c97791462f47799be4ae510d5be7b0aa3c30360592899fbfb336f31c25762d8fe5d35d87202413f85916ce8fc9199c48d40a26a22b480fc72d497edbe1f1d
6
+ metadata.gz: fd85e6e179eb6e1a4d9ffe2f074db3c0d856d239bc65b8d535d6d14cff987a0af1eed75046aed0538726ff87925b9a2a400153a1acec7d7ecc3cc7fdc50d0e87
7
+ data.tar.gz: 5954aad879e293d34eb175ff54055473e3a983e6a16ec816694eb0b16fd90897cbf9d31bcdf53bfdef664891abb42cb538c7962954d76331c291411e816c956b
data/README.md CHANGED
@@ -245,6 +245,7 @@ r.allbut([:a, :b, ...]) # remove specified attributes
245
245
  r.autowrap(split: '_') # structure a flat relation, split: '_' is the default
246
246
  r.autosummarize([:a, :b, ...], x: :sum) # (experimental) usual summarizers supported
247
247
  r.constants(x: 12, ...) # add constant attributes (sometimes useful in unions)
248
+ r.cross_product(right) # cross product, alias `cross_join`
248
249
  r.extend(x: ->(t){ ... }, ...) # add computed attributes
249
250
  r.extend(x: :y) # shortcut for r.extend(x: ->(t){ t[:y] })
250
251
  r.exclude(predicate) # shortcut for restrict(!predicate)
@@ -57,6 +57,14 @@ module Bmg
57
57
  self.left_join(right.rename(renaming), on.keys, *args)
58
58
  end
59
59
 
60
+ def cross_product(right)
61
+ return join(right) unless self.type.typechecked? || right.type.typechecked?
62
+ return join(right) unless self.type.knows_attrlist? && right.type.knows_attrlist?
63
+
64
+ self.type.cross_join_compatible!(right)
65
+ return join(right)
66
+ end
67
+
60
68
  def matching(right, on = [])
61
69
  return super unless on.is_a?(Hash)
62
70
  renaming = Hash[on.map{|k,v| [v,k] }]
data/lib/bmg/type.rb CHANGED
@@ -310,7 +310,7 @@ module Bmg
310
310
  }
311
311
  end
312
312
 
313
- private
313
+ public
314
314
 
315
315
  def known_attributes!(attrs)
316
316
  extra = attrs - self.attrlist
@@ -331,5 +331,12 @@ module Bmg
331
331
  end
332
332
  end
333
333
 
334
+ def cross_join_compatible!(right)
335
+ shared = self.attrlist & right.type.attrlist
336
+ unless shared.empty?
337
+ raise TypeError, "Cross product incompatible — duplicate attribute(s): #{shared.join(', ')}"
338
+ end
339
+ end
340
+
334
341
  end # class Type
335
342
  end # module Bmg
data/lib/bmg/version.rb CHANGED
@@ -2,7 +2,7 @@ module Bmg
2
2
  module Version
3
3
  MAJOR = 0
4
4
  MINOR = 21
5
- TINY = 3
5
+ TINY = 4
6
6
  end
7
7
  VERSION = "#{Version::MAJOR}.#{Version::MINOR}.#{Version::TINY}"
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bmg
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.21.3
4
+ version: 0.21.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bernard Lambeau
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-18 00:00:00.000000000 Z
11
+ date: 2024-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: predicate