Gentoo Archives: gentoo-commits

From: Sam James <sam@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-ruby/thor/files/, dev-ruby/thor/
Date: Sat, 18 Mar 2023 00:03:09
Message-Id: 1679097721.557922daa276be471bff9f1fbfc9e4ee3fbbe6c9.sam@gentoo
1 commit: 557922daa276be471bff9f1fbfc9e4ee3fbbe6c9
2 Author: Sam James <sam <AT> gentoo <DOT> org>
3 AuthorDate: Wed Mar 15 07:37:12 2023 +0000
4 Commit: Sam James <sam <AT> gentoo <DOT> org>
5 CommitDate: Sat Mar 18 00:02:01 2023 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=557922da
7
8 dev-ruby/thor: enable ruby32
9
10 ```
11 Finished in 0.6724 seconds (files took 0.35272 seconds to load)
12 800 examples, 0 failures, 1 pending
13 ```
14
15 Signed-off-by: Sam James <sam <AT> gentoo.org>
16
17 dev-ruby/thor/files/thor-1.2.1-tests.patch | 211 +++++++++++++++++++++++++++++
18 dev-ruby/thor/thor-1.2.1-r1.ebuild | 74 ++++++++++
19 2 files changed, 285 insertions(+)
20
21 diff --git a/dev-ruby/thor/files/thor-1.2.1-tests.patch b/dev-ruby/thor/files/thor-1.2.1-tests.patch
22 new file mode 100644
23 index 000000000000..bd59deda2338
24 --- /dev/null
25 +++ b/dev-ruby/thor/files/thor-1.2.1-tests.patch
26 @@ -0,0 +1,211 @@
27 +https://github.com/rails/thor/issues/817
28 +https://github.com/rails/thor/commit/0def4cfba5bf470f76877eb3b8a8895f0018e574
29 +https://github.com/rails/thor/commit/46d1422902e1c66b31fae79be7dca79ff8b2e81b
30 +
31 +From 0def4cfba5bf470f76877eb3b8a8895f0018e574 Mon Sep 17 00:00:00 2001
32 +From: Tim Diggins <tim@×××××.uk>
33 +Date: Fri, 4 Mar 2022 12:16:58 +0000
34 +Subject: [PATCH] fix expectations for ruby 3 treatment of hash arg
35 +
36 +--- a/spec/line_editor_spec.rb
37 ++++ b/spec/line_editor_spec.rb
38 +@@ -13,7 +13,7 @@
39 + describe ".readline" do
40 + it "uses the Readline line editor" do
41 + editor = double("Readline")
42 +- expect(Thor::LineEditor::Readline).to receive(:new).with("Enter your name ", :default => "Brian").and_return(editor)
43 ++ expect(Thor::LineEditor::Readline).to receive(:new).with("Enter your name ", {:default => "Brian"}).and_return(editor)
44 + expect(editor).to receive(:readline).and_return("George")
45 + expect(Thor::LineEditor.readline("Enter your name ", :default => "Brian")).to eq("George")
46 + end
47 +@@ -35,7 +35,7 @@
48 + describe ".readline" do
49 + it "uses the Basic line editor" do
50 + editor = double("Basic")
51 +- expect(Thor::LineEditor::Basic).to receive(:new).with("Enter your name ", :default => "Brian").and_return(editor)
52 ++ expect(Thor::LineEditor::Basic).to receive(:new).with("Enter your name ", {:default => "Brian"}).and_return(editor)
53 + expect(editor).to receive(:readline).and_return("George")
54 + expect(Thor::LineEditor.readline("Enter your name ", :default => "Brian")).to eq("George")
55 + end
56 +--- a/spec/shell/basic_spec.rb
57 ++++ b/spec/shell/basic_spec.rb
58 +@@ -70,80 +70,80 @@ def shell
59 +
60 + it "prints a message to the user with the available options, expects case-sensitive matching, and determines the correctness of the answer" do
61 + flavors = %w(strawberry chocolate vanilla)
62 +- expect(Thor::LineEditor).to receive(:readline).with('What\'s your favorite Neopolitan flavor? [strawberry, chocolate, vanilla] ', :limited_to => flavors).and_return("chocolate")
63 ++ expect(Thor::LineEditor).to receive(:readline).with('What\'s your favorite Neopolitan flavor? [strawberry, chocolate, vanilla] ', {:limited_to => flavors}).and_return("chocolate")
64 + expect(shell.ask('What\'s your favorite Neopolitan flavor?', :limited_to => flavors)).to eq("chocolate")
65 + end
66 +
67 + it "prints a message to the user with the available options, expects case-sensitive matching, and reasks the question after an incorrect response" do
68 + flavors = %w(strawberry chocolate vanilla)
69 + expect($stdout).to receive(:print).with("Your response must be one of: [strawberry, chocolate, vanilla]. Please try again.\n")
70 +- expect(Thor::LineEditor).to receive(:readline).with('What\'s your favorite Neopolitan flavor? [strawberry, chocolate, vanilla] ', :limited_to => flavors).and_return("moose tracks", "chocolate")
71 ++ expect(Thor::LineEditor).to receive(:readline).with('What\'s your favorite Neopolitan flavor? [strawberry, chocolate, vanilla] ', {:limited_to => flavors}).and_return("moose tracks", "chocolate")
72 + expect(shell.ask('What\'s your favorite Neopolitan flavor?', :limited_to => flavors)).to eq("chocolate")
73 + end
74 +
75 + it "prints a message to the user with the available options, expects case-sensitive matching, and reasks the question after a case-insensitive match" do
76 + flavors = %w(strawberry chocolate vanilla)
77 + expect($stdout).to receive(:print).with("Your response must be one of: [strawberry, chocolate, vanilla]. Please try again.\n")
78 +- expect(Thor::LineEditor).to receive(:readline).with('What\'s your favorite Neopolitan flavor? [strawberry, chocolate, vanilla] ', :limited_to => flavors).and_return("cHoCoLaTe", "chocolate")
79 ++ expect(Thor::LineEditor).to receive(:readline).with('What\'s your favorite Neopolitan flavor? [strawberry, chocolate, vanilla] ', {:limited_to => flavors}).and_return("cHoCoLaTe", "chocolate")
80 + expect(shell.ask('What\'s your favorite Neopolitan flavor?', :limited_to => flavors)).to eq("chocolate")
81 + end
82 +
83 + it "prints a message to the user with the available options, expects case-insensitive matching, and determines the correctness of the answer" do
84 + flavors = %w(strawberry chocolate vanilla)
85 +- expect(Thor::LineEditor).to receive(:readline).with('What\'s your favorite Neopolitan flavor? [strawberry, chocolate, vanilla] ', :limited_to => flavors, :case_insensitive => true).and_return("CHOCOLATE")
86 ++ expect(Thor::LineEditor).to receive(:readline).with('What\'s your favorite Neopolitan flavor? [strawberry, chocolate, vanilla] ', {:limited_to => flavors, :case_insensitive => true}).and_return("CHOCOLATE")
87 + expect(shell.ask('What\'s your favorite Neopolitan flavor?', :limited_to => flavors, :case_insensitive => true)).to eq("chocolate")
88 + end
89 +
90 + it "prints a message to the user with the available options, expects case-insensitive matching, and reasks the question after an incorrect response" do
91 + flavors = %w(strawberry chocolate vanilla)
92 + expect($stdout).to receive(:print).with("Your response must be one of: [strawberry, chocolate, vanilla]. Please try again.\n")
93 +- expect(Thor::LineEditor).to receive(:readline).with('What\'s your favorite Neopolitan flavor? [strawberry, chocolate, vanilla] ', :limited_to => flavors, :case_insensitive => true).and_return("moose tracks", "chocolate")
94 ++ expect(Thor::LineEditor).to receive(:readline).with('What\'s your favorite Neopolitan flavor? [strawberry, chocolate, vanilla] ', {:limited_to => flavors, :case_insensitive => true}).and_return("moose tracks", "chocolate")
95 + expect(shell.ask('What\'s your favorite Neopolitan flavor?', :limited_to => flavors, :case_insensitive => true)).to eq("chocolate")
96 + end
97 +
98 + it "prints a message to the user containing a default and sets the default if only enter is pressed" do
99 +- expect(Thor::LineEditor).to receive(:readline).with('What\'s your favorite Neopolitan flavor? (vanilla) ', :default => "vanilla").and_return("")
100 ++ expect(Thor::LineEditor).to receive(:readline).with('What\'s your favorite Neopolitan flavor? (vanilla) ', {:default => "vanilla"}).and_return("")
101 + expect(shell.ask('What\'s your favorite Neopolitan flavor?', :default => "vanilla")).to eq("vanilla")
102 + end
103 +
104 + it "prints a message to the user with the available options and reasks the question after an incorrect response and then returns the default" do
105 + flavors = %w(strawberry chocolate vanilla)
106 + expect($stdout).to receive(:print).with("Your response must be one of: [strawberry, chocolate, vanilla]. Please try again.\n")
107 +- expect(Thor::LineEditor).to receive(:readline).with('What\'s your favorite Neopolitan flavor? [strawberry, chocolate, vanilla] (vanilla) ', :default => "vanilla", :limited_to => flavors).and_return("moose tracks", "")
108 ++ expect(Thor::LineEditor).to receive(:readline).with('What\'s your favorite Neopolitan flavor? [strawberry, chocolate, vanilla] (vanilla) ', {:default => "vanilla", :limited_to => flavors}).and_return("moose tracks", "")
109 + expect(shell.ask("What's your favorite Neopolitan flavor?", :default => "vanilla", :limited_to => flavors)).to eq("vanilla")
110 + end
111 + end
112 +
113 + describe "#yes?" do
114 + it "asks the user and returns true if the user replies yes" do
115 +- expect(Thor::LineEditor).to receive(:readline).with("Should I overwrite it? ", :add_to_history => false).and_return("y")
116 ++ expect(Thor::LineEditor).to receive(:readline).with("Should I overwrite it? ", {:add_to_history => false}).and_return("y")
117 + expect(shell.yes?("Should I overwrite it?")).to be true
118 + end
119 +
120 + it "asks the user and returns false if the user replies no" do
121 +- expect(Thor::LineEditor).to receive(:readline).with("Should I overwrite it? ", :add_to_history => false).and_return("n")
122 ++ expect(Thor::LineEditor).to receive(:readline).with("Should I overwrite it? ", {:add_to_history => false}).and_return("n")
123 + expect(shell.yes?("Should I overwrite it?")).not_to be true
124 + end
125 +
126 + it "asks the user and returns false if the user replies with an answer other than yes or no" do
127 +- expect(Thor::LineEditor).to receive(:readline).with("Should I overwrite it? ", :add_to_history => false).and_return("foobar")
128 ++ expect(Thor::LineEditor).to receive(:readline).with("Should I overwrite it? ", {:add_to_history => false}).and_return("foobar")
129 + expect(shell.yes?("Should I overwrite it?")).to be false
130 + end
131 + end
132 +
133 + describe "#no?" do
134 + it "asks the user and returns true if the user replies no" do
135 +- expect(Thor::LineEditor).to receive(:readline).with("Should I overwrite it? ", :add_to_history => false).and_return("n")
136 ++ expect(Thor::LineEditor).to receive(:readline).with("Should I overwrite it? ", {:add_to_history => false}).and_return("n")
137 + expect(shell.no?("Should I overwrite it?")).to be true
138 + end
139 +
140 + it "asks the user and returns false if the user replies yes" do
141 +- expect(Thor::LineEditor).to receive(:readline).with("Should I overwrite it? ", :add_to_history => false).and_return("Yes")
142 ++ expect(Thor::LineEditor).to receive(:readline).with("Should I overwrite it? ", {:add_to_history => false}).and_return("Yes")
143 + expect(shell.no?("Should I overwrite it?")).to be false
144 + end
145 +
146 + it "asks the user and returns false if the user replies with an answer other than yes or no" do
147 +- expect(Thor::LineEditor).to receive(:readline).with("Should I overwrite it? ", :add_to_history => false).and_return("foobar")
148 ++ expect(Thor::LineEditor).to receive(:readline).with("Should I overwrite it? ", {:add_to_history => false}).and_return("foobar")
149 + expect(shell.no?("Should I overwrite it?")).to be false
150 + end
151 + end
152 +@@ -431,13 +431,13 @@ def #456 Lanç...
153 + expect(content).to eq(<<-TABLE)
154 + Name Number Color
155 + Erik 1234567890123 green
156 +-TABLE
157 ++ TABLE
158 + end
159 + end
160 +
161 + describe "#file_collision" do
162 + it "shows a menu with options" do
163 +- expect(Thor::LineEditor).to receive(:readline).with('Overwrite foo? (enter "h" for help) [Ynaqh] ', :add_to_history => false).and_return("n")
164 ++ expect(Thor::LineEditor).to receive(:readline).with('Overwrite foo? (enter "h" for help) [Ynaqh] ', {:add_to_history => false}).and_return("n")
165 + shell.file_collision("foo")
166 + end
167 +
168 +@@ -478,7 +478,7 @@ def #456 Lanç...
169 + end
170 +
171 + it "always returns true if the user chooses always" do
172 +- expect(Thor::LineEditor).to receive(:readline).with('Overwrite foo? (enter "h" for help) [Ynaqh] ', :add_to_history => false).and_return("a")
173 ++ expect(Thor::LineEditor).to receive(:readline).with('Overwrite foo? (enter "h" for help) [Ynaqh] ', {:add_to_history => false}).and_return("a")
174 +
175 + expect(shell.file_collision("foo")).to be true
176 +
177 +@@ -488,7 +488,7 @@ def #456 Lanç...
178 +
179 + describe "when a block is given" do
180 + it "displays diff and merge options to the user" do
181 +- expect(Thor::LineEditor).to receive(:readline).with('Overwrite foo? (enter "h" for help) [Ynaqdhm] ', :add_to_history => false).and_return("s")
182 ++ expect(Thor::LineEditor).to receive(:readline).with('Overwrite foo? (enter "h" for help) [Ynaqdhm] ', {:add_to_history => false}).and_return("s")
183 + shell.file_collision("foo") {}
184 + end
185 +
186 +From 46d1422902e1c66b31fae79be7dca79ff8b2e81b Mon Sep 17 00:00:00 2001
187 +From: =?UTF-8?q?David=20Rodr=C3=ADguez?= <deivid.rodriguez@××××××.net>
188 +Date: Wed, 15 Jun 2022 19:35:27 +0200
189 +Subject: [PATCH] Reimplement did_you_mean suggestions to keep behaviour
190 + accross rubies
191 +
192 +Ruby 3.2 will introduce `Exception#detailed_message` and `did_you_mean`
193 +has been already updated in Ruby 3.2 to use that.
194 +
195 +The new behaviour means not changing the original `Exception#message`.
196 +That means it is hard to get the previous error output, because
197 +`Exception#detailed_message` includes not only `did_you_mean`
198 +decorations, but also additional information like the exception class.
199 +
200 +To fix this, I bring the old did_you_mean behavior into Thor, so that
201 +the above changes do not affect us.
202 +--- a/lib/thor/error.rb
203 ++++ b/lib/thor/error.rb
204 +@@ -11,7 +11,15 @@ def initialize(dictionary)
205 + end
206 + end
207 +
208 +- DidYouMean::Correctable
209 ++ Module.new do
210 ++ def to_s
211 ++ super + DidYouMean.formatter.message_for(corrections)
212 ++ end
213 ++
214 ++ def corrections
215 ++ @corrections ||= self.class.const_get(:SpellChecker).new(self).corrections
216 ++ end
217 ++ end
218 + end
219 +
220 + # Thor::Error is raised when it's caused by wrong usage of thor classes. Those
221 +@@ -100,16 +108,4 @@ class RequiredArgumentMissingError < InvocationError
222 +
223 + class MalformattedArgumentError < InvocationError
224 + end
225 +-
226 +- if Correctable
227 +- if DidYouMean.respond_to?(:correct_error)
228 +- DidYouMean.correct_error(Thor::UndefinedCommandError, UndefinedCommandError::SpellChecker)
229 +- DidYouMean.correct_error(Thor::UnknownArgumentError, UnknownArgumentError::SpellChecker)
230 +- else
231 +- DidYouMean::SPELL_CHECKERS.merge!(
232 +- 'Thor::UndefinedCommandError' => UndefinedCommandError::SpellChecker,
233 +- 'Thor::UnknownArgumentError' => UnknownArgumentError::SpellChecker
234 +- )
235 +- end
236 +- end
237 + end
238
239 diff --git a/dev-ruby/thor/thor-1.2.1-r1.ebuild b/dev-ruby/thor/thor-1.2.1-r1.ebuild
240 new file mode 100644
241 index 000000000000..42cd077c6593
242 --- /dev/null
243 +++ b/dev-ruby/thor/thor-1.2.1-r1.ebuild
244 @@ -0,0 +1,74 @@
245 +# Copyright 2000-2023 Gentoo Authors
246 +# Distributed under the terms of the GNU General Public License v2
247 +
248 +EAPI=8
249 +USE_RUBY="ruby27 ruby30 ruby31 ruby32"
250 +
251 +RUBY_FAKEGEM_RECIPE_TEST="rspec3"
252 +RUBY_FAKEGEM_DOCDIR="rdoc"
253 +RUBY_FAKEGEM_EXTRADOC="README.md"
254 +RUBY_FAKEGEM_BINWRAP="thor"
255 +
256 +RUBY_FAKEGEM_GEMSPEC="thor.gemspec"
257 +
258 +inherit ruby-fakegem
259 +
260 +DESCRIPTION="A scripting framework that replaces rake and sake"
261 +HOMEPAGE="http://whatisthor.com/"
262 +
263 +SRC_URI="https://github.com/erikhuda/${PN}/archive/v${PV}.tar.gz -> ${PN}-git-${PV}.tgz"
264 +
265 +LICENSE="MIT"
266 +SLOT="$(ver_cut 1)"
267 +KEYWORDS="~amd64 ~arm ~arm64 ~hppa ~loong ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~amd64-linux"
268 +IUSE="doc"
269 +
270 +USE_RUBY="ruby27" ruby_add_bdepend "
271 + test? (
272 + dev-ruby/childlabor
273 + dev-ruby/webmock
274 + )"
275 +
276 +RDEPEND+=" !<dev-ruby/thor-0.20.3-r1:0"
277 +
278 +PATCHES=(
279 + "${FILESDIR}"/thor-1.2.1-tests.patch
280 +)
281 +
282 +all_ruby_prepare() {
283 + # Remove rspec default options (as we might not have the last
284 + # rspec).
285 + rm .rspec || die
286 +
287 + # Remove Bundler
288 + #rm Gemfile || die
289 + sed -i -e '/[Bb]undler/d' Thorfile || die
290 +
291 + # Remove mandatory coverage collection using simplecov which is not
292 + # packaged.
293 + sed -i -e '/require .simplecov/,/^end/ s:^:#:' spec/helper.rb || die
294 +
295 + # Avoid a spec that requires UTF-8 support, so LANG=C still works,
296 + # bug 430402
297 + sed -i -e '/uses maximum terminal width/,/end/ s:^:#:' spec/shell/basic_spec.rb || die
298 +
299 + # Avoid specs depending on git, bug 724058
300 + rm -f spec/quality_spec.rb || die
301 +
302 + # Avoid currently broken readline specs (already fixed upstream)
303 + #rm -f spec/line_editor/readline_spec.rb spec/line_editor_spec.rb || die
304 +
305 + # Avoid spec failing on whitespace difference in error message
306 + sed -i -e '/raises an error for unknown switches/askip "whitespace differences"' spec/parser/options_spec.rb || die
307 +}
308 +
309 +each_ruby_test() {
310 + case ${RUBY} in
311 + *ruby30|*ruby31|*ruby32)
312 + einfo "Skipping tests due to circular dependencies"
313 + ;;
314 + *)
315 + RSPEC_VERSION=3 ruby-ng_rspec spec || die
316 + ;;
317 + esac
318 +}