flex-cartesian 1.2.1 → 1.2.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 +4 -0
  3. data/README.md +14 -1
  4. data/lib/flex-cartesian.rb +14 -2
  5. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f3005b96077c2ec5e9a273bf58c6740fb3715524ca69328523370f1d67db01e9
4
- data.tar.gz: 95c612d95526fa4fa2aafa3fe38ab9861e0bb2b442bdec5a34b74bd45ee3180b
3
+ metadata.gz: 3a2ca7796b432b25c13982324959267a48475d5e9bce840b36309f976e05aa8f
4
+ data.tar.gz: c43b4a80cda5177c29cd7e07c186d6075fa2597ed3fe3e4e886e49b94b76ef49
5
5
  SHA512:
6
- metadata.gz: 0560a624b178dda3526775093e692a3cb09d032a5b00463ec556bd6a24a4bc51281c0294249f6ae2c0a1070bee8eae8ef4f7f686aed4092ea1f8e33295a4da57
7
- data.tar.gz: fabdc19cb4647e2863aceffbf3888c3f274c7df3f1514ff31dd9e94f142506cf67b3715b7d6bac9df8aa504d416ba39282a319d59bb370f9a63e424c389e3e57
6
+ metadata.gz: 8271368f575fdd9dc460d6acb7d37678faf8071293738c9cf421ad7fa3dbc0bcf197590d79e57216cc20ee4b028ffa0b58f84b160dddb900b71d778ba93ef8e8
7
+ data.tar.gz: 4e55180b78619c9ad100c0b6e7db1b19cc7c74871936939340d53af7b6e01eba82bd2bd2e739e0e33c3ef334cfb66f75284aeae1ef2ca1dcebbe00f60eb5843a
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.2.2 - 2025-07-28
4
+ ### Added
5
+ - .dimensions functionality extended to more granular formatting
6
+
3
7
  ## 1.2.1 - 2025-07-28
4
8
  ### Fixed
5
9
  - When adding function, check if its namesake exists
data/README.md CHANGED
@@ -211,6 +211,9 @@ puts "\nPrint Cartesian space as Markdown"
211
211
  s.output(format: :markdown)
212
212
  puts "\nPrint Cartesian space as CSV"
213
213
  s.output(format: :csv)
214
+ puts "\nGranular output of Cartesian space dimensions: #{s.dimensions(values: false)}"
215
+ puts "\nGranular output of Cartesian vectors:"
216
+ s.cartesian { |v| puts s.dimensions(v, separator: ' ') }
214
217
 
215
218
 
216
219
 
@@ -435,7 +438,7 @@ Displays a progress bar using `ruby-progressbar`.
435
438
 
436
439
  ---
437
440
 
438
- ### Print Cartesian
441
+ ### Generate Output
439
442
  ```ruby
440
443
  output(separator: " | ", colorize: false, align: true, format: :plain, limit: nil, file: nil)
441
444
  ```
@@ -455,6 +458,16 @@ Markdown example:
455
458
  | 2 | "b" |
456
459
  ```
457
460
 
461
+ ```ruby
462
+ dimensions(data = @dimensions, raw: false, separator: ', ', dimensions: true, values: true)
463
+ ```
464
+ Generates formatted Cartesian dimensions or vectors of Cartesian space
465
+ - `data`: what to format, either Cartesian vector (usually `s.cartesian { |v| ... }) or entire Cartesian dimensions
466
+ - `raw`: if enabled, overrides any other formarring flags and returns the same as `.inspect`
467
+ - `separator`: how to separate individual components
468
+ - `dimensions`: whether or not show dimension names
469
+ - `values`: whether or not show value(s) associated with dimensions
470
+
458
471
  ---
459
472
 
460
473
  ### Import from JSON or YAML
@@ -25,11 +25,11 @@ module FlexOutput
25
25
  end
26
26
 
27
27
  class FlexCartesian
28
- attr :dimensions
29
28
 
30
29
  def initialize(dimensions = nil, path: nil, format: :json)
31
30
  if dimensions && path
32
- $logger.msg "Please specify either dimensions or path to dimensions", :error
31
+ puts "Please specify either dimensions or path to dimensions"
32
+ exit
33
33
  end
34
34
  @dimensions = dimensions
35
35
  @conditions = []
@@ -39,6 +39,18 @@ class FlexCartesian
39
39
  import(path, format: format) if path
40
40
  end
41
41
 
42
+ def dimensions(data = @dimensions, raw: false, separator: ', ', dimensions: true, values: true)
43
+ return data.inspect if raw # by default, with no data speciaifed, we assume dimensions of Cartesian
44
+ return nil if not dimensions and not values
45
+
46
+ if data.is_a?(Struct) or data.is_a?(Hash) # vector in Cartesian or entire Cartesian
47
+ data.each_pair.map { |k, v| (dimensions ? "#{k}" : "") + ((dimensions and values) ? "=" : "") + (values ? "#{v}" : "") }.join(separator)
48
+ else
49
+ puts "Incorrect type of dimensions: #{data.class}"
50
+ exit
51
+ end
52
+ end
53
+
42
54
  def cond(command = :print, index: nil, &block)
43
55
  case command
44
56
  when :set
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: 1.2.1
4
+ version: 1.2.2
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-27 00:00:00.000000000 Z
11
+ date: 2025-07-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize