namo 0.11.0 → 0.11.1

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: 40c2256efac2663b7593bb1f7e4c3ca08fa07e6e225c75fcef3d6d8658f3794b
4
- data.tar.gz: abd7bd9076d7019c245d942425232dcf0966edb076cf6d50fdedf7b74efea90f
3
+ metadata.gz: ad4994109308fd955b2f508afe1f07251bc4287406ed7f27eb8a484a61dfabcf
4
+ data.tar.gz: 04be0a1d0e8f97b86932a3e5e8953bfe3b0e51fe16bcb80b5dec9a5a73aecd36
5
5
  SHA512:
6
- metadata.gz: 2b5045c4160d8812fa3f04f10dc027bf8c6cfaf937405cec0570a31af52babdc1f2dc6e25db249a9b9dea81afc9806f617203ae71dded576974fe9512bd4ec00
7
- data.tar.gz: a553ef0ae27d67bf28d8d91ba9e2e71f217f8ee23ff3d177ad207dd520f30971730774a51660830d98d79a6189cee16f1227dbd168282f3a27c4316912a6f29f
6
+ metadata.gz: 507a77ecfc3d23fe1ad4ef14783b2e4f86ff44b58431cb93b8e4aa41c12bf4778f03c7a3bdca7f8958620b3d2e3bba3292cdfbcd5636c8286661aed100398b30
7
+ data.tar.gz: fa6acfcf416108a871e0697ae998cef8701263446abee9089c62e1cfb24c102d22f002e643f89890a7c40ad2ccedca3dd7d58ebf04125fb4a87d17f58a908abd
data/CHANGELOG CHANGED
@@ -1,6 +1,15 @@
1
1
  CHANGELOG
2
2
  _________
3
3
 
4
+ 20260601
5
+ 0.11.1: Extract the subset Enumerable methods into a Namo::Enumerable module.
6
+
7
+ 1. + lib/Namo/Enumerable.rb: New module Namo::Enumerable holding each and the subset-returning Enumerable methods (select plus its filter/find_all aliases, reject, sort_by, first, last, take, drop, take_while, drop_while, uniq, partition), moved verbatim from Namo. The module does `include ::Enumerable` — the leading :: is required, because under the nested `class Namo; module Enumerable` scope a bare `Enumerable` resolves to Namo::Enumerable itself and raises a cyclic-include error.
8
+ 2. ~ lib/namo.rb: Remove the inline each and the eleven subset methods; remove `include Enumerable`; + `require_relative './Namo/Enumerable'` and `include Namo::Enumerable` (which transitively brings stdlib Enumerable into the ancestor chain below the module, so the overrides win and map/reduce/etc. still fall through). Pure reorganisation — no behaviour change.
9
+ 3. ~ test/namo_test.rb: + Namo::Enumerable module tests — it is a Module, Namo includes it and stdlib Enumerable, and it precedes ::Enumerable in Namo.ancestors so the overrides resolve first. The existing Enumerable subset tests are unchanged and remain green, evidencing the move is behaviour-preserving.
10
+ 4. ~ ROADMAP.md: + note in the 0.11.0 section that, as of 0.11.1, these methods live in the Namo::Enumerable module; bump Date to 20260601.
11
+ 5. ~ Namo::VERSION: /0.11.0/0.11.1/
12
+
4
13
  20260531
5
14
  0.11.0: ~ Subset Enumerable methods (select, reject, sort_by, first, last, take, drop, take_while, drop_while, uniq, partition) return Namos
6
15
 
@@ -0,0 +1,72 @@
1
+ # Namo/Enumerable.rb
2
+ # Namo::Enumerable
3
+
4
+ class Namo
5
+ module Enumerable
6
+ include ::Enumerable
7
+
8
+ def each(&block)
9
+ return enum_for(:each) unless block_given?
10
+ @data.each{|row_data| block.call(Row.new(row_data, @formulae))}
11
+ end
12
+
13
+ def select(&block)
14
+ self.class.new(@data.select{|row| block.call(Row.new(row, @formulae))}, formulae: @formulae.dup)
15
+ end
16
+ alias_method :filter, :select
17
+ alias_method :find_all, :select
18
+
19
+ def reject(&block)
20
+ self.class.new(@data.reject{|row| block.call(Row.new(row, @formulae))}, formulae: @formulae.dup)
21
+ end
22
+
23
+ def sort_by(&block)
24
+ self.class.new(@data.sort_by{|row| block.call(Row.new(row, @formulae))}, formulae: @formulae.dup)
25
+ end
26
+
27
+ def first(n = nil)
28
+ if n
29
+ self.class.new(@data.first(n), formulae: @formulae.dup)
30
+ else
31
+ @data.first ? Row.new(@data.first, @formulae) : nil
32
+ end
33
+ end
34
+
35
+ def last(n = nil)
36
+ if n
37
+ self.class.new(@data.last(n), formulae: @formulae.dup)
38
+ else
39
+ @data.last ? Row.new(@data.last, @formulae) : nil
40
+ end
41
+ end
42
+
43
+ def take(n)
44
+ self.class.new(@data.take(n), formulae: @formulae.dup)
45
+ end
46
+
47
+ def drop(n)
48
+ self.class.new(@data.drop(n), formulae: @formulae.dup)
49
+ end
50
+
51
+ def take_while(&block)
52
+ self.class.new(@data.take_while{|row| block.call(Row.new(row, @formulae))}, formulae: @formulae.dup)
53
+ end
54
+
55
+ def drop_while(&block)
56
+ self.class.new(@data.drop_while{|row| block.call(Row.new(row, @formulae))}, formulae: @formulae.dup)
57
+ end
58
+
59
+ def uniq(&block)
60
+ rows = block ? @data.uniq{|row| block.call(Row.new(row, @formulae))} : @data.uniq
61
+ self.class.new(rows, formulae: @formulae.dup)
62
+ end
63
+
64
+ def partition(&block)
65
+ matches, non_matches = @data.partition{|row| block.call(Row.new(row, @formulae))}
66
+ [
67
+ self.class.new(matches, formulae: @formulae.dup),
68
+ self.class.new(non_matches, formulae: @formulae.dup),
69
+ ]
70
+ end
71
+ end
72
+ end
data/lib/Namo/VERSION.rb CHANGED
@@ -2,5 +2,5 @@
2
2
  # Namo::VERSION
3
3
 
4
4
  class Namo
5
- VERSION = '0.11.0'
5
+ VERSION = '0.11.1'
6
6
  end
data/lib/namo.rb CHANGED
@@ -3,11 +3,12 @@
3
3
 
4
4
  require_relative './Namo/NegatedDimension'
5
5
  require_relative './Namo/Row'
6
+ require_relative './Namo/Enumerable'
6
7
  require_relative './Namo/VERSION'
7
8
  require_relative './Symbol'
8
9
 
9
10
  class Namo
10
- include Enumerable
11
+ include Namo::Enumerable
11
12
 
12
13
  attr_accessor :data
13
14
  attr_accessor :formulae
@@ -76,70 +77,6 @@ class Namo
76
77
  @formulae[name] = proc
77
78
  end
78
79
 
79
- def each(&block)
80
- return enum_for(:each) unless block_given?
81
- @data.each{|row_data| block.call(Row.new(row_data, @formulae))}
82
- end
83
-
84
- def select(&block)
85
- self.class.new(@data.select{|row| block.call(Row.new(row, @formulae))}, formulae: @formulae.dup)
86
- end
87
- alias_method :filter, :select
88
- alias_method :find_all, :select
89
-
90
- def reject(&block)
91
- self.class.new(@data.reject{|row| block.call(Row.new(row, @formulae))}, formulae: @formulae.dup)
92
- end
93
-
94
- def sort_by(&block)
95
- self.class.new(@data.sort_by{|row| block.call(Row.new(row, @formulae))}, formulae: @formulae.dup)
96
- end
97
-
98
- def first(n = nil)
99
- if n
100
- self.class.new(@data.first(n), formulae: @formulae.dup)
101
- else
102
- @data.first ? Row.new(@data.first, @formulae) : nil
103
- end
104
- end
105
-
106
- def last(n = nil)
107
- if n
108
- self.class.new(@data.last(n), formulae: @formulae.dup)
109
- else
110
- @data.last ? Row.new(@data.last, @formulae) : nil
111
- end
112
- end
113
-
114
- def take(n)
115
- self.class.new(@data.take(n), formulae: @formulae.dup)
116
- end
117
-
118
- def drop(n)
119
- self.class.new(@data.drop(n), formulae: @formulae.dup)
120
- end
121
-
122
- def take_while(&block)
123
- self.class.new(@data.take_while{|row| block.call(Row.new(row, @formulae))}, formulae: @formulae.dup)
124
- end
125
-
126
- def drop_while(&block)
127
- self.class.new(@data.drop_while{|row| block.call(Row.new(row, @formulae))}, formulae: @formulae.dup)
128
- end
129
-
130
- def uniq(&block)
131
- rows = block ? @data.uniq{|row| block.call(Row.new(row, @formulae))} : @data.uniq
132
- self.class.new(rows, formulae: @formulae.dup)
133
- end
134
-
135
- def partition(&block)
136
- matches, non_matches = @data.partition{|row| block.call(Row.new(row, @formulae))}
137
- [
138
- self.class.new(matches, formulae: @formulae.dup),
139
- self.class.new(non_matches, formulae: @formulae.dup),
140
- ]
141
- end
142
-
143
80
  def +(other)
144
81
  raise_unless_namo(other)
145
82
  raise_unless_matching_data_dimensions(other)
data/test/namo_test.rb CHANGED
@@ -913,6 +913,22 @@ describe Namo do
913
913
  end
914
914
  end
915
915
 
916
+ describe "Namo::Enumerable module" do
917
+ it "is a Module supplying the subset methods" do
918
+ _(Namo::Enumerable).must_be_kind_of Module
919
+ end
920
+
921
+ it "is included in Namo, transitively including stdlib Enumerable" do
922
+ _(Namo.include?(Namo::Enumerable)).must_equal true
923
+ _(Namo.include?(Enumerable)).must_equal true
924
+ end
925
+
926
+ it "sits above stdlib Enumerable so its overrides win" do
927
+ ancestors = Namo.ancestors
928
+ _(ancestors.index(Namo::Enumerable) < ancestors.index(::Enumerable)).must_equal true
929
+ end
930
+ end
931
+
916
932
  describe "#+" do
917
933
  let(:more_data) do
918
934
  [
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.11.0
4
+ version: 0.11.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - thoran
@@ -64,6 +64,7 @@ files:
64
64
  - LICENSE
65
65
  - README.md
66
66
  - Rakefile
67
+ - lib/Namo/Enumerable.rb
67
68
  - lib/Namo/NegatedDimension.rb
68
69
  - lib/Namo/Row.rb
69
70
  - lib/Namo/VERSION.rb