samovar 2.4.1 → 2.4.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e1051db069257cf9d25e3599a5ddb5c5547a921cb90d04552a777d3af5c335b2
4
- data.tar.gz: 632d0819eb51db7f9640feb8491e543706721a4313243527bb5380da576a578b
3
+ metadata.gz: 467711ed04ecc759513ab6187d17a8c5208fa24869d202fb23a46217d3ceedab
4
+ data.tar.gz: 293c9e07e9f0ff0b9550b0ad3411b5e10f460a6c72dd8be2bc254d985dec95da
5
5
  SHA512:
6
- metadata.gz: f5daa04c5dff0500f95c9dec3cabe02bbbb10fd5a9d5a06f89f6d9e6687eb11af89325472df628170ea04d0458d3c8600849c4fab1299c83bf523e58e1e268ed
7
- data.tar.gz: 304cc7d54293e3998dae9e3e3247506db3f82d2d0f6d66e988b4ad21cad0150846a1325a039c4dd3f4746fe0903e6e6afd5a6e2f615d724d7e7ee788da49310b
6
+ metadata.gz: bf717af75e91db10dc75008e1421601181168190aa89ea5bd289ca5e832505d1382cee60ac7e1b66d4500673779cc2cc5325dc33110ce4871443fa93c820d817
7
+ data.tar.gz: c7c0f9b82b3ce5502c29da74b7810f69c63687237b2a7550dde8ff5eda35f3db6739848907d9669a2083df9ec186097c90d44e4e119aa1176ca1c6a52c7f6f07
checksums.yaml.gz.sig CHANGED
Binary file
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2017-2023, by Samuel Williams.
4
+ # Copyright, 2017-2026, by Samuel Williams.
5
5
 
6
6
  module Samovar
7
7
  # Represents a runtime failure in command execution.
data/lib/samovar/many.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2016-2023, by Samuel Williams.
4
+ # Copyright, 2016-2026, by Samuel Williams.
5
5
 
6
6
  module Samovar
7
7
  # Represents multiple positional arguments in a command.
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2016-2023, by Samuel Williams.
4
+ # Copyright, 2016-2026, by Samuel Williams.
5
5
 
6
6
  module Samovar
7
7
  # Represents nested sub-commands in a command.
data/lib/samovar/one.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2016-2023, by Samuel Williams.
4
+ # Copyright, 2016-2026, by Samuel Williams.
5
5
 
6
6
  module Samovar
7
7
  # Represents a single positional argument in a command.
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2016-2023, by Samuel Williams.
4
+ # Copyright, 2016-2026, by Samuel Williams.
5
5
 
6
6
  module Samovar
7
7
  # Namespace for output formatting classes.
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2019-2023, by Samuel Williams.
4
+ # Copyright, 2019-2026, by Samuel Williams.
5
5
 
6
6
  module Samovar
7
7
  module Output
@@ -2,8 +2,8 @@
2
2
 
3
3
  # Released under the MIT License.
4
4
  # Copyright, 2019-2025, by Samuel Williams.
5
+ # Copyright, 2026, by Gerhard Schlager.
5
6
 
6
- require "mapping/model"
7
7
  require "console/terminal"
8
8
 
9
9
  require_relative "../error"
@@ -17,8 +17,8 @@ module Samovar
17
17
  module Output
18
18
  # Formats and prints usage information to a terminal.
19
19
  #
20
- # Uses the `mapping` gem to handle different output object types with custom formatting rules.
21
- class UsageFormatter < Mapping::Model
20
+ # Dispatches on the type of each output object to apply custom formatting rules.
21
+ class UsageFormatter
22
22
  # Print usage information to the output.
23
23
  #
24
24
  # @parameter rows [Rows] The rows to format and print.
@@ -39,7 +39,6 @@ module Samovar
39
39
  def initialize(output)
40
40
  @output = output
41
41
  @width = 80
42
- @first = true
43
42
 
44
43
  @terminal = Console::Terminal.for(@output)
45
44
  @terminal[:header] = @terminal.style(nil, nil, :bright)
@@ -47,43 +46,50 @@ module Samovar
47
46
  @terminal[:error] = @terminal.style(:red)
48
47
  end
49
48
 
50
- map(InvalidInputError) do |error|
51
- # This is a little hack which avoids printing out "--help" if it was part of an incomplete parse. In the future I'd prefer if this was handled explicitly.
52
- @terminal.puts("#{error.message} in:", style: :error) unless error.help?
53
- end
54
-
55
- map(MissingValueError) do |error|
56
- @terminal.puts("#{error.message} in:", style: :error)
57
- end
58
-
59
- map(Header) do |header, rows|
60
- if @first
61
- @first = false
49
+ # Format and print the given object according to its type.
50
+ #
51
+ # @parameter object [Object] The object to format (a {Rows}, {Row}, {Header}, or error).
52
+ # @parameter arguments [Array] Extra context passed through to nested rows (the containing {Rows}).
53
+ def map(object, *arguments, first: true)
54
+ case object
55
+ when InvalidInputError
56
+ # This is a little hack which avoids printing out "--help" if it was part of an incomplete parse. In the future I'd prefer if this was handled explicitly.
57
+ @terminal.puts("#{object.message} in:", style: :error) unless object.help?
58
+ when MissingValueError
59
+ @terminal.puts("#{object.message} in:", style: :error)
60
+ when Header
61
+ header, rows = object, arguments.first
62
+
63
+ if first
64
+ first = false
65
+ else
66
+ @terminal.puts
67
+ end
68
+
69
+ command_line = header.object.command_line(header.name)
70
+ @terminal.puts "#{rows.indentation}#{command_line}", style: :header
71
+
72
+ if description = header.object.description
73
+ @terminal.puts "#{rows.indentation}\t#{description}", style: :description
74
+ @terminal.puts
75
+ end
76
+ when Row
77
+ row, rows = object, arguments.first
78
+ @terminal.puts "#{rows.indentation}#{row.align(rows.columns)}"
79
+ when Rows
80
+ object.each do |row, rows|
81
+ first = map(row, rows, first: first)
82
+ end
62
83
  else
63
- @terminal.puts
84
+ raise ArgumentError, "Unable to format #{object.class}!"
64
85
  end
65
86
 
66
- command_line = header.object.command_line(header.name)
67
- @terminal.puts "#{rows.indentation}#{command_line}", style: :header
68
-
69
- if description = header.object.description
70
- @terminal.puts "#{rows.indentation}\t#{description}", style: :description
71
- @terminal.puts
72
- end
73
- end
74
-
75
- map(Row) do |row, rows|
76
- @terminal.puts "#{rows.indentation}#{row.align(rows.columns)}"
77
- end
78
-
79
- map(Rows) do |items|
80
- items.collect{|row, rows| map(row, rows)}
87
+ return first
81
88
  end
82
89
 
83
90
  # Print the formatted usage output.
84
- def print(rows, first: @first)
85
- @first = first
86
- map(rows)
91
+ def print(rows, first: true)
92
+ map(rows, first: first)
87
93
  end
88
94
  end
89
95
  end
@@ -6,5 +6,5 @@
6
6
 
7
7
  # @namespace
8
8
  module Samovar
9
- VERSION = "2.4.1"
9
+ VERSION = "2.4.2"
10
10
  end
data/license.md CHANGED
@@ -1,7 +1,8 @@
1
1
  # MIT License
2
2
 
3
- Copyright, 2016-2025, by Samuel Williams.
3
+ Copyright, 2016-2026, by Samuel Williams.
4
4
  Copyright, 2018, by Gabriel Mazetto.
5
+ Copyright, 2026, by Gerhard Schlager.
5
6
 
6
7
  Permission is hereby granted, free of charge, to any person obtaining a copy
7
8
  of this software and associated documentation files (the "Software"), to deal
data/readme.md CHANGED
@@ -22,7 +22,9 @@ Please see the [project documentation](https://ioquatix.github.io/samovar/) for
22
22
 
23
23
  Please see the [project releases](https://ioquatix.github.io/samovar/releases/index) for all releases.
24
24
 
25
- ### v2.4.1
25
+ ### v2.4.2
26
+
27
+ - Drop dependency on `mapping` gem.
26
28
 
27
29
  ### v2.4.0
28
30
 
@@ -58,6 +60,22 @@ We welcome contributions to this project.
58
60
  4. Push to the branch (`git push origin my-new-feature`).
59
61
  5. Create new Pull Request.
60
62
 
63
+ ### Running Tests
64
+
65
+ To run the test suite:
66
+
67
+ ``` shell
68
+ bundle exec sus
69
+ ```
70
+
71
+ ### Making Releases
72
+
73
+ To make a new release:
74
+
75
+ ``` shell
76
+ bundle exec bake gem:release:patch # or minor or major
77
+ ```
78
+
61
79
  ### Developer Certificate of Origin
62
80
 
63
81
  In order to protect users of this project, we require all contributors to comply with the [Developer Certificate of Origin](https://developercertificate.org/). This ensures that all contributions are properly licensed and attributed.
@@ -66,7 +84,7 @@ In order to protect users of this project, we require all contributors to comply
66
84
 
67
85
  This project is best served by a collaborative and respectful environment. Treat each other professionally, respect differing viewpoints, and engage constructively. Harassment, discrimination, or harmful behavior is not tolerated. Communicate clearly, listen actively, and support one another. If any issues arise, please inform the project maintainers.
68
86
 
69
- ### Future Work
87
+ ## Future Work
70
88
 
71
89
  ### Multi-value Options
72
90
 
data/releases.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # Releases
2
2
 
3
- ## v2.4.1
3
+ ## v2.4.2
4
+
5
+ - Drop dependency on `mapping` gem.
4
6
 
5
7
  ## v2.4.0
6
8
 
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,11 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: samovar
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.1
4
+ version: 2.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
8
  - Gabriel Mazetto
9
+ - Gerhard Schlager
9
10
  bindir: bin
10
11
  cert_chain:
11
12
  - |
@@ -53,20 +54,6 @@ dependencies:
53
54
  - - "~>"
54
55
  - !ruby/object:Gem::Version
55
56
  version: '1.0'
56
- - !ruby/object:Gem::Dependency
57
- name: mapping
58
- requirement: !ruby/object:Gem::Requirement
59
- requirements:
60
- - - "~>"
61
- - !ruby/object:Gem::Version
62
- version: '1.0'
63
- type: :runtime
64
- prerelease: false
65
- version_requirements: !ruby/object:Gem::Requirement
66
- requirements:
67
- - - "~>"
68
- - !ruby/object:Gem::Version
69
- version: '1.0'
70
57
  executables: []
71
58
  extensions: []
72
59
  extra_rdoc_files: []
@@ -109,14 +96,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
109
96
  requirements:
110
97
  - - ">="
111
98
  - !ruby/object:Gem::Version
112
- version: '3.2'
99
+ version: '3.3'
113
100
  required_rubygems_version: !ruby/object:Gem::Requirement
114
101
  requirements:
115
102
  - - ">="
116
103
  - !ruby/object:Gem::Version
117
104
  version: '0'
118
105
  requirements: []
119
- rubygems_version: 3.6.9
106
+ rubygems_version: 4.0.10
120
107
  specification_version: 4
121
108
  summary: Samovar is a flexible option parser excellent support for sub-commands and
122
109
  help documentation.
metadata.gz.sig CHANGED
Binary file