namo 0.27.0 → 0.28.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
  SHA256:
3
- metadata.gz: 5649b6afb8e1272273a87286f053376ad42caddec81eed0610a672f26bc7e66a
4
- data.tar.gz: 77a5e0c6499c3d600b76753e28c5e600b0dcd6dc0968d93069a56e3b10fc7652
3
+ metadata.gz: cf138a52a691a4d50f093e506e5018d652a66ab23846593e2622cbe23710c8ef
4
+ data.tar.gz: a8bbdc8cdf8af2b8c3df9881d468cc0445ffca7dd1f4523c614a2e71a8acc4c5
5
5
  SHA512:
6
- metadata.gz: 33c03e6c39cee1242a576a8355928b041464c9049a5bbb54900b7654dc36a9dec44741edaf28a8408eb293f4fcf4b702736841e8cf3b3bae7ce43e6684b098f1
7
- data.tar.gz: d0ad82d6b415a09ba086a9d6a7b0f06c24d1dfad8bb3eaad72e1a40c878f9a431ccfb093f781836a94d0d4f4ab6bdf8b7917ddb61123012bf1fd0455168e3e05
6
+ metadata.gz: 58c3cb00aee14efb44155a9a4a8e5eaa748aa51389f0ac19c27f4d8a077970cac3b605e7d1ffad2c95329782fdf04755ee1e8975b9e2d34209705a1e8f780014
7
+ data.tar.gz: 7492096f83494f4c5a976b602796e3611c4eef1e920cc6b6179ff1b63e7f7fcd7a7f1e12ab2d637d3a1ef8fb4a0eeeb0364a0068ff3cbe12332b8e4b0e0d20c2
data/CHANGELOG CHANGED
@@ -1,5 +1,18 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 20260711
4
+
5
+ 0.28.0: ~ Namo::Collection#detail/#as_detail: Accept the by label positionally or by keyword.
6
+
7
+ Accept the by label positionally or by keyword (positional winning), per the constructor precedent — resolving the detail/as_detail calling-convention asymmetry.
8
+
9
+ 1. ~ Namo::Collection#detail(positional_by = nil, by: :member), #as_detail(positional_by = nil, by: :member): resolve by = positional_by || by, mirroring the constructor's @data = positional_data || data; positional wins. summary/as_summary unchanged — dimension stays their positional, by: the keyword modifier.
10
+ 2. ~ test/Namo/Collection_test.rb: + detail and as_detail each take the by label positionally or by keyword, positional winning over a conflicting keyword.
11
+ 3. ~ README.md: ~ the view-methods note — detail/as_detail take the label positionally or by keyword (the constructor's shape); replaces the "carries no dimension, so positional" rationale.
12
+ 4. ~ ROADMAP.md: + the 0.28.0 entry (twin asymmetry, constructor precedent, primary-dual/modifier-keyword scope); current-state bumped to 0.28.0; a forward-reference on the 0.18.0 note superseding its positional rationale.
13
+ 5. ~ docs/: regenerate the print-ready PDFs.
14
+ 6. ~ Namo::VERSION: /0.27.0/0.28.0/
15
+
3
16
  ## 20260710
4
17
 
5
18
  0.27.0: ~ Namo::Collection#summary/#as_summary: + an optional block for a per-member reduction beyond a single named reducer.
data/README.md CHANGED
@@ -1075,7 +1075,7 @@ Detail is the lazy view because a Collection's rows simply *are* its members' ro
1075
1075
  The views come in a non-mutating pair and a mutating pair:
1076
1076
 
1077
1077
  - `summary(dimension = nil, by:, reducer:, &block)` and `detail(by:)` are **non-mutating** — each returns a fresh `Namo` derived from the members, leaving the Collection untouched. Use these when you want a view to keep: assign the result to a variable and operate on it independently.
1078
- - `as_summary(dimension = nil, by:, reducer:, &block)` and `as_detail(by)` are **mutating** — each sets the Collection's data to the chosen view and returns `self`, for a fluent step. (`as_detail` carries no `dimension`, so its label argument is positional: `as_detail(:assembly)`.)
1078
+ - `as_summary(dimension = nil, by:, reducer:, &block)` and `as_detail(by = :member)` are **mutating** — each sets the Collection's data to the chosen view and returns `self`, for a fluent step. (`detail` and `as_detail` take the origin label either positionally or by the `by:` keyword, positional winning the same shape the constructor gives `data` — so `as_detail(:assembly)` and `as_detail(by: :assembly)` are one call. `summary`/`as_summary` keep `by:` a keyword beside their `dimension` positional.)
1079
1079
 
1080
1080
  ```ruby
1081
1081
  gt.summary(:cost, reducer: :mean) # a fresh Namo; gt is unchanged
@@ -34,7 +34,8 @@ class Namo
34
34
  Namo.new(rows)
35
35
  end
36
36
 
37
- def detail(by: :member)
37
+ def detail(positional_by = nil, by: :member)
38
+ by = positional_by || by
38
39
  rows = @members.flat_map do |member|
39
40
  member.data.map{|row| row.key?(by) ? row : row.merge(by => member.name)}
40
41
  end
@@ -46,8 +47,9 @@ class Namo
46
47
  self
47
48
  end
48
49
 
49
- def as_detail(by = :member)
50
- @data = detail(by: by).data
50
+ def as_detail(positional_by = nil, by: :member)
51
+ by = positional_by || by
52
+ @data = detail(by).data
51
53
  self
52
54
  end
53
55
 
data/lib/Namo/VERSION.rb CHANGED
@@ -2,5 +2,5 @@
2
2
  # Namo::VERSION
3
3
 
4
4
  class Namo
5
- VERSION = '0.27.0'
5
+ VERSION = '0.28.0'
6
6
  end
@@ -245,6 +245,12 @@ describe Namo::Collection do
245
245
  collection.detail(by: :assembly)
246
246
  _(collection.dimensions).wont_include :assembly
247
247
  end
248
+
249
+ it "takes the by label positionally or by keyword, positional winning" do
250
+ _(collection.detail(:assembly).values(:assembly)).must_equal [:powertrain, :powertrain, :chassis, :body]
251
+ _(collection.detail(by: :assembly).values(:assembly)).must_equal [:powertrain, :powertrain, :chassis, :body]
252
+ _(collection.detail(:assembly, by: :ignored).values(:assembly)).must_equal [:powertrain, :powertrain, :chassis, :body]
253
+ end
248
254
  end
249
255
 
250
256
  describe "live recomputation (no memoisation in 1.x)" do
@@ -285,6 +291,14 @@ describe Namo::Collection do
285
291
  _(collection.values(:assembly)).must_equal [:powertrain, :chassis, :body]
286
292
  _(collection.values(:count)).must_equal [2, 1, 1]
287
293
  end
294
+
295
+ it "as_detail takes the by label positionally or by keyword, positional winning" do
296
+ positional = Namo::Collection.new.tap{|c| c << [powertrain, chassis]}.as_detail(:assembly)
297
+ keyword = Namo::Collection.new.tap{|c| c << [powertrain, chassis]}.as_detail(by: :assembly)
298
+ _(positional.values(:assembly)).must_equal [:powertrain, :powertrain, :chassis]
299
+ _(keyword.values(:assembly)).must_equal positional.values(:assembly)
300
+ _(Namo::Collection.new.tap{|c| c << powertrain}.as_detail(:assembly, by: :ignored).values(:assembly)).must_equal [:powertrain, :powertrain]
301
+ end
288
302
  end
289
303
 
290
304
  describe "as_* view lifetime (rebuild-on-<<: persists until the next <<)" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: namo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.27.0
4
+ version: 0.28.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - thoran
@@ -98,7 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
98
98
  - !ruby/object:Gem::Version
99
99
  version: '0'
100
100
  requirements: []
101
- rubygems_version: 4.0.15
101
+ rubygems_version: 4.0.16
102
102
  specification_version: 4
103
103
  summary: Named dimensional data for Ruby.
104
104
  test_files: []