flex-cartesian 0.1.3 → 0.1.5

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 (3) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +104 -2
  3. metadata +3 -21
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6da0e2d7afc6efca08b21663c3a4d7e80a924fb1707b02aae11c866a515fc067
4
- data.tar.gz: dfd7f4fb1f71ec9ed4f469831a3efca245e43fe379fc7af51b6a708842906bdf
3
+ metadata.gz: 365e591e60a0c174cbfec4f2b80cf1e6f2cd6e2c57b27be341fc16bf10a6ac98
4
+ data.tar.gz: 86030f2e3c14e8bb2e9042bcf6b639211ab65a24095d158c15f002047d7d3c99
5
5
  SHA512:
6
- metadata.gz: 5afd71db98e0446c6e32478ec41db552811d68b3e40b915d34193c7d6ca9065ab19ebe154612886fa755074ace224b8db6799a9657710ca658af64671f4fc327
7
- data.tar.gz: 49affdbb1e79d165f51f4e1698d3948dfb5e0e3de543711f39696cf0a7ab5bb355f8cb35eb98d7cfd64cfd69db228a473744de27e647e61a6ebbf6bd01a0aada
6
+ metadata.gz: 69e18d211995c7f5f5325fe0146bcf580bcbee923444aa524ec8ac13e773264d8b3fe66f8dcaed84f2b29409c9b089b00d5f4a19f7f0b74fbf25f8ed3936ba16
7
+ data.tar.gz: 2395bf3d93663c0d39ea8126498b68c8e02f805ee2183387071f278f1bf8bddf44822ac80ff41bce33e88732959ff9c79017ceeea69f19609b1818e2fdf86d3f
data/README.md CHANGED
@@ -24,10 +24,10 @@
24
24
 
25
25
  ## Installation
26
26
 
27
- Install dependencies:
28
-
29
27
  ```bash
30
28
  bundle install
29
+ gem build flex-cartesian.gemspec
30
+ gem install flex-cartesian-*.gem
31
31
  ```
32
32
 
33
33
  ## Usage
@@ -77,6 +77,108 @@ s.output(format: :markdown, align: true)
77
77
  s.output(format: :csv)
78
78
  ```
79
79
 
80
+ ## API Overview
81
+
82
+ ### Initialization
83
+ ```ruby
84
+ FlexCartesian.new(dimensions_hash)
85
+ ```
86
+ - `dimensions_hash`: a hash with named dimensions; each value can be an `Enumerable` (e.g., arrays, ranges).
87
+
88
+ Example:
89
+ ```ruby
90
+ dimensions = {
91
+ dim1: [1, 2],
92
+ dim2: ['x', 'y'],
93
+ dim3: [true, false]
94
+ }
95
+
96
+ FlexCartesian.new(dimensions)
97
+ ```
98
+
99
+ ---
100
+
101
+ ### Iterate Over All Combinations
102
+ ```ruby
103
+ # With block
104
+ cartesian(dims = nil, lazy: false) { |vector| ... }
105
+
106
+ # Without block: returns Enumerator
107
+ cartesian(dims = nil, lazy: false)
108
+ ```
109
+ - `dims`: optional dimensions hash (default is the one provided at initialization).
110
+ - `lazy`: if true, returns a lazy enumerator.
111
+
112
+ Each combination is passed as a `Struct` with fields matching the dimension names:
113
+ ```ruby
114
+ s.cartesian { |v| puts "#{v.dim1} - #{v.dim2}" }
115
+ ```
116
+
117
+ ---
118
+
119
+ ### Count Total Combinations
120
+ ```ruby
121
+ size(dims = nil) → Integer
122
+ ```
123
+ Returns the number of possible combinations.
124
+
125
+ ---
126
+
127
+ ### Convert to Array
128
+ ```ruby
129
+ to_a(limit: nil) → Array
130
+ ```
131
+ - `limit`: maximum number of combinations to collect.
132
+
133
+ ---
134
+
135
+ ### Iterate with Progress Bar
136
+ ```ruby
137
+ progress_each(dims = nil, lazy: false, title: "Processing") { |v| ... }
138
+ ```
139
+ Displays a progress bar using `ruby-progressbar`.
140
+
141
+ ---
142
+
143
+ ### Print Table to Console
144
+ ```ruby
145
+ output(
146
+ separator: " | ",
147
+ colorize: false,
148
+ align: false,
149
+ format: :plain # or :markdown, :csv
150
+ limit: nil
151
+ )
152
+ ```
153
+ Prints all combinations in table form (plain/markdown/CSV).
154
+ Markdown example:
155
+ ```
156
+ | dim1 | dim2 |
157
+ |------|------|
158
+ | 1 | "a" |
159
+ | 2 | "b" |
160
+ ```
161
+
162
+ ---
163
+
164
+ ### Load from JSON or YAML
165
+ ```ruby
166
+ FlexCartesian.from_json("file.json")
167
+ FlexCartesian.from_yaml("file.yaml")
168
+ ```
169
+
170
+ ---
171
+
172
+ ### Output from Vectors
173
+ Each yielded combination is a `Struct` extended with:
174
+ ```ruby
175
+ output(separator: " | ", colorize: false, align: false)
176
+ ```
177
+ Example:
178
+ ```ruby
179
+ s.cartesian { |v| v.output(colorize: true, align: true) }
180
+ ```
181
+
80
182
  ## License
81
183
 
82
184
  This project is licensed under the terms of the GNU General Public License v3.0.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flex-cartesian
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yury Rassokhin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-07-02 00:00:00.000000000 Z
11
+ date: 2025-07-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize
@@ -52,26 +52,8 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '2.0'
55
- - !ruby/object:Gem::Dependency
56
- name: yaml
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :runtime
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: '0'
69
- description: |
70
- Flexible and human-friendly Cartesian product enumerator for Ruby.
71
- Supports dimension-agnostic iteration, named dimensions, structured output,
55
+ description: Supports dimension-agnostic iterators, named dimensions, tabular output,
72
56
  lazy/eager evaluation, progress bar, JSON/YAML loading, and export to Markdown/CSV.
73
-
74
- Code example: https://github.com/Yuri-Rassokhin/flex-cartesian/blob/main/README.md#usage
75
57
  email:
76
58
  - yuri.rassokhin@gmail.com
77
59
  executables: []