thor 1.0.1 → 1.1.0

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: 2c23d1fdac6ea485b4cbfe91abad33a46e03c00baf2e7e0068c9f8d4ce41e607
4
- data.tar.gz: 368fe9c87e8a426eaf38278acaba2b7a3171c96c99298ca5e2eddf3b1b466ff6
3
+ metadata.gz: 49e18474eddb5dbf02c13be5b42104385928e460511272e7293cc66110d1c3d7
4
+ data.tar.gz: ffea33d8f08051882551af3a444fe68a77ffe0ecfe16404f2ead662364d36b5e
5
5
  SHA512:
6
- metadata.gz: 6f2e3b52a657bc5318fed8a5e3f15368d734f62e7b8039a296add626ff6bdc415e6c8a85cea31bdd591a629960854f0d34e47ef81161c63acf4ef140457a7bdb
7
- data.tar.gz: 8086cd52e16a12fb63dad7df484f0c079feed33d7aa6078d8683f895ddcd92da21be58d26a3b33f89e44d822ae9b01e73ef36672aa77a7befcfa3198523df253
6
+ metadata.gz: bc1a58088c4c7b48166152c1f7cfc0c4dc91e9c3199e583e6085b74a2982f65c0eaa8d8b7595f8f5781c08b0f60818e4a014bb23adbdfb07fd2ded558ceef67e
7
+ data.tar.gz: f9a3c7f81a55d75298e3655569a86f04aa2055088058eb0a30ce5b80e05c6be7ed9c0f1840031dd266c453a4ac1454d8749849b47659d2f53f8b1221b9db2b7b
@@ -1,3 +1,11 @@
1
+ # 1.1.0
2
+ * Don't use ANSI colors when terminal is dumb.
3
+ * Ensure default option/argument is not erroneously aliased.
4
+ * Fixes a bug in the calculation of the print_wrapped method.
5
+ * Obey `:mute` and `options[:quiet]` in `Shell#say`.
6
+ * Support Ruby 3.0.
7
+ * Add force option to the `gsub_file` action.
8
+
1
9
  # 1.0.1
2
10
  * Fix thor when `thor/base` and `thor/group` are required without `thor.rb`.
3
11
  * Handle relative source path in `create_link`.
@@ -1,7 +1,7 @@
1
- require "set"
2
1
  require_relative "thor/base"
3
2
 
4
3
  class Thor
4
+ $thor_runner ||= false
5
5
  class << self
6
6
  # Allows for custom "Command" package naming.
7
7
  #
@@ -323,7 +323,7 @@ class Thor
323
323
  # ==== Parameters
324
324
  # Symbol ...:: A list of commands that should be affected.
325
325
  def stop_on_unknown_option!(*command_names)
326
- stop_on_unknown_option.merge(command_names)
326
+ @stop_on_unknown_option = stop_on_unknown_option | command_names
327
327
  end
328
328
 
329
329
  def stop_on_unknown_option?(command) #:nodoc:
@@ -337,7 +337,7 @@ class Thor
337
337
  # ==== Parameters
338
338
  # Symbol ...:: A list of commands that should be affected.
339
339
  def disable_required_check!(*command_names)
340
- disable_required_check.merge(command_names)
340
+ @disable_required_check = disable_required_check | command_names
341
341
  end
342
342
 
343
343
  def disable_required_check?(command) #:nodoc:
@@ -347,12 +347,12 @@ class Thor
347
347
  protected
348
348
 
349
349
  def stop_on_unknown_option #:nodoc:
350
- @stop_on_unknown_option ||= Set.new
350
+ @stop_on_unknown_option ||= []
351
351
  end
352
352
 
353
353
  # help command has the required check disabled by default.
354
354
  def disable_required_check #:nodoc:
355
- @disable_required_check ||= Set.new([:help])
355
+ @disable_required_check ||= [:help]
356
356
  end
357
357
 
358
358
  # The method responsible for dispatching given the args.
@@ -398,7 +398,6 @@ class Thor
398
398
  # the namespace should be displayed as arguments.
399
399
  #
400
400
  def banner(command, namespace = nil, subcommand = false)
401
- $thor_runner ||= false
402
401
  command.formatted_usage(self, $thor_runner, subcommand).split("\n").map do |formatted_usage|
403
402
  "#{basename} #{formatted_usage}"
404
403
  end.join("\n")
@@ -219,7 +219,7 @@ class Thor
219
219
 
220
220
  contents = if is_uri
221
221
  require "open-uri"
222
- open(path, "Accept" => "application/x-thor-template", &:read)
222
+ URI.open(path, "Accept" => "application/x-thor-template", &:read)
223
223
  else
224
224
  open(path, &:read)
225
225
  end
@@ -251,7 +251,8 @@ class Thor
251
251
  # path<String>:: path of the file to be changed
252
252
  # flag<Regexp|String>:: the regexp or string to be replaced
253
253
  # replacement<String>:: the replacement, can be also given as a block
254
- # config<Hash>:: give :verbose => false to not log the status.
254
+ # config<Hash>:: give :verbose => false to not log the status, and
255
+ # :force => true, to force the replacement regardles of runner behavior.
255
256
  #
256
257
  # ==== Example
257
258
  #
@@ -262,9 +263,10 @@ class Thor
262
263
  # end
263
264
  #
264
265
  def gsub_file(path, flag, *args, &block)
265
- return unless behavior == :invoke
266
266
  config = args.last.is_a?(Hash) ? args.pop : {}
267
267
 
268
+ return unless behavior == :invoke || config.fetch(:force, false)
269
+
268
270
  path = File.expand_path(path, destination_root)
269
271
  say_status :gsub, relative_to_original_destination_root(path), config.fetch(:verbose, true)
270
272
 
@@ -1,5 +1,5 @@
1
1
  class Thor
2
- Correctable = if defined?(DidYouMean::SpellChecker) && defined?(DidYouMean::Correctable)
2
+ Correctable = if defined?(DidYouMean::SpellChecker) && defined?(DidYouMean::Correctable) # rubocop:disable Naming/ConstantName
3
3
  # In order to support versions of Ruby that don't have keyword
4
4
  # arguments, we need our own spell checker class that doesn't take key
5
5
  # words. Even though this code wouldn't be hit because of the check
@@ -30,7 +30,11 @@ class Thor
30
30
 
31
31
  arguments.each do |argument|
32
32
  if !argument.default.nil?
33
- @assigns[argument.human_name] = argument.default
33
+ begin
34
+ @assigns[argument.human_name] = argument.default.dup
35
+ rescue TypeError # Compatibility shim for un-dup-able Fixnum in Ruby < 2.4
36
+ @assigns[argument.human_name] = argument.default
37
+ end
34
38
  elsif argument.required?
35
39
  @non_assigned_required << argument
36
40
  end
@@ -133,15 +133,16 @@ class Thor
133
133
 
134
134
  protected
135
135
 
136
- def assign_result!(option, result)
137
- if option.repeatable && option.type == :hash
138
- (@assigns[option.human_name] ||= {}).merge!(result)
139
- elsif option.repeatable
140
- (@assigns[option.human_name] ||= []) << result
141
- else
142
- @assigns[option.human_name] = result
136
+ def assign_result!(option, result)
137
+ if option.repeatable && option.type == :hash
138
+ (@assigns[option.human_name] ||= {}).merge!(result)
139
+ elsif option.repeatable
140
+ (@assigns[option.human_name] ||= []) << result
141
+ else
142
+ @assigns[option.human_name] = result
143
+ end
143
144
  end
144
- end
145
+
145
146
  # Check if the current value in peek is a registered switch.
146
147
  #
147
148
  # Two booleans are returned. The first is true if the current value
@@ -94,6 +94,8 @@ class Thor
94
94
  # say("I know you knew that.")
95
95
  #
96
96
  def say(message = "", color = nil, force_new_line = (message.to_s !~ /( |\t)\Z/))
97
+ return if quiet?
98
+
97
99
  buffer = prepare_message(message, *color)
98
100
  buffer << "\n" if force_new_line && !message.to_s.end_with?("\n")
99
101
 
@@ -230,8 +232,9 @@ class Thor
230
232
  paras = message.split("\n\n")
231
233
 
232
234
  paras.map! do |unwrapped|
233
- counter = 0
234
- unwrapped.split(" ").inject do |memo, word|
235
+ words = unwrapped.split(" ")
236
+ counter = words.first.length
237
+ words.inject do |memo, word|
235
238
  word = word.gsub(/\n\005/, "\n").gsub(/\005/, "\n")
236
239
  counter = 0 if word.include? "\n"
237
240
  if (counter + word.length + 1) < width
@@ -97,7 +97,11 @@ class Thor
97
97
  protected
98
98
 
99
99
  def can_display_colors?
100
- stdout.tty? && !are_colors_disabled?
100
+ are_colors_supported? && !are_colors_disabled?
101
+ end
102
+
103
+ def are_colors_supported?
104
+ stdout.tty? && ENV["TERM"] != "dumb"
101
105
  end
102
106
 
103
107
  def are_colors_disabled?
@@ -1,3 +1,3 @@
1
1
  class Thor
2
- VERSION = "1.0.1"
2
+ VERSION = "1.1.0"
3
3
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thor
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yehuda Katz
8
8
  - José Valim
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-12-17 00:00:00.000000000 Z
12
+ date: 2021-01-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -83,9 +83,9 @@ metadata:
83
83
  bug_tracker_uri: https://github.com/erikhuda/thor/issues
84
84
  changelog_uri: https://github.com/erikhuda/thor/blob/master/CHANGELOG.md
85
85
  documentation_uri: http://whatisthor.com/
86
- source_code_uri: https://github.com/erikhuda/thor/tree/v1.0.1
86
+ source_code_uri: https://github.com/erikhuda/thor/tree/v1.1.0
87
87
  wiki_uri: https://github.com/erikhuda/thor/wiki
88
- post_install_message:
88
+ post_install_message:
89
89
  rdoc_options: []
90
90
  require_paths:
91
91
  - lib
@@ -100,8 +100,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
100
100
  - !ruby/object:Gem::Version
101
101
  version: 1.3.5
102
102
  requirements: []
103
- rubygems_version: 3.0.3
104
- signing_key:
103
+ rubygems_version: 3.2.3
104
+ signing_key:
105
105
  specification_version: 4
106
106
  summary: Thor is a toolkit for building powerful command-line interfaces.
107
107
  test_files: []