thor 1.3.0 → 1.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f24a2dd00001feb1d7f9d68b1cf8aff06dd9f347e230846eda8662595a514ac9
4
- data.tar.gz: 5fcf2e12c1a1f7112b72286f3eded990dc6f00df0ecc45a5e32465915c10b515
3
+ metadata.gz: 9b49f263d36f84d82f17f16852671ff9e2f529ea0adec4b664a2b8660923d091
4
+ data.tar.gz: 2df9cade7c368e064377ec0f38737d5b379b38265f23d878cb4976588b94564c
5
5
  SHA512:
6
- metadata.gz: 03d0bd2991357425d2ceeeaf3a538f280e9a1a2ce7d35cc210c5413744940f022602339ce721aff4bad5c51ebde0a071d533a06c7c697dee8fabbcb468671dc5
7
- data.tar.gz: 1fe2bbce8f427aaa3a9a314b647796927d8dbaf52b2873c1def2d072c3fd98076abcbc50890d913f195a30835208f5f2d272d59969a89e3821f1ff6c1080d073
6
+ metadata.gz: c4cca8a5e388509dd8a45a6484c13fa80d89f15c7bfde65ccc3d48d3f86c299269ce6019af1dfe3d2f6f172aff5ae7d7ef8f49ca69de189dcd721d5c9d48269f
7
+ data.tar.gz: 85b9b4834a91e7fab98ee9f555461cee740bebcbcee3e0efffc9d117d1b8dce6f9967db594225cd32a3d82462b5edc2d6e4c77bb4ef799d6253f3e66f4f88042
data/README.md CHANGED
@@ -15,7 +15,7 @@ users.
15
15
 
16
16
  Please note: Thor, by design, is a system tool created to allow seamless file and url
17
17
  access, which should not receive application user input. It relies on [open-uri][open-uri],
18
- which combined with application user input would provide a command injection attack
18
+ which, combined with application user input, would provide a command injection attack
19
19
  vector.
20
20
 
21
21
  [rake]: https://github.com/ruby/rake
@@ -27,7 +27,7 @@ Installation
27
27
 
28
28
  Usage and documentation
29
29
  -----------------------
30
- Please see the [wiki][] for basic usage and other documentation on using Thor. You can also checkout the [official homepage][homepage].
30
+ Please see the [wiki][] for basic usage and other documentation on using Thor. You can also check out the [official homepage][homepage].
31
31
 
32
32
  [wiki]: https://github.com/rails/thor/wiki
33
33
  [homepage]: http://whatisthor.com/
@@ -10,7 +10,6 @@ class Thor
10
10
  # destination<String>:: the relative path to the destination root.
11
11
  # config<Hash>:: give :verbose => false to not log the status, and
12
12
  # :mode => :preserve, to preserve the file mode from the source.
13
-
14
13
  #
15
14
  # ==== Examples
16
15
  #
@@ -275,9 +274,8 @@ class Thor
275
274
  end
276
275
  end
277
276
 
278
- # Uncomment all lines matching a given regex. It will leave the space
279
- # which existed before the comment hash in tact but will remove any spacing
280
- # between the comment hash and the beginning of the line.
277
+ # Uncomment all lines matching a given regex. Preserves indentation before
278
+ # the comment hash and removes the hash and any immediate following space.
281
279
  #
282
280
  # ==== Parameters
283
281
  # path<String>:: path of the file to be changed
@@ -291,7 +289,7 @@ class Thor
291
289
  def uncomment_lines(path, flag, *args)
292
290
  flag = flag.respond_to?(:source) ? flag.source : flag
293
291
 
294
- gsub_file(path, /^(\s*)#[[:blank:]]*(.*#{flag})/, '\1\2', *args)
292
+ gsub_file(path, /^(\s*)#[[:blank:]]?(.*#{flag})/, '\1\2', *args)
295
293
  end
296
294
 
297
295
  # Comment all lines matching a given regex. It will leave the space
data/lib/thor/group.rb CHANGED
@@ -211,6 +211,17 @@ class Thor::Group
211
211
  raise error, msg
212
212
  end
213
213
 
214
+ # Checks if a specified command exists.
215
+ #
216
+ # ==== Parameters
217
+ # command_name<String>:: The name of the command to check for existence.
218
+ #
219
+ # ==== Returns
220
+ # Boolean:: +true+ if the command exists, +false+ otherwise.
221
+ def command_exists?(command_name) #:nodoc:
222
+ commands.keys.include?(command_name)
223
+ end
224
+
214
225
  protected
215
226
 
216
227
  # The method responsible for dispatching given the args.
@@ -26,10 +26,7 @@ class Thor
26
26
 
27
27
  def print_default
28
28
  if @type == :array and @default.is_a?(Array)
29
- @default.map { |x|
30
- p = x.gsub('"','\\"')
31
- "\"#{p}\""
32
- }.join(" ")
29
+ @default.map(&:dump).join(" ")
33
30
  else
34
31
  @default
35
32
  end
@@ -89,8 +89,8 @@ class Thor
89
89
 
90
90
  sample = "[#{sample}]".dup unless required?
91
91
 
92
- if boolean?
93
- sample << ", [#{dasherize('no-' + human_name)}]" unless (name == "force") || name.match(/\Ano[\-_]/)
92
+ if boolean? && name != "force" && !name.match(/\A(no|skip)[\-_]/)
93
+ sample << ", [#{dasherize('no-' + human_name)}], [#{dasherize('skip-' + human_name)}]"
94
94
  end
95
95
 
96
96
  aliases_for_usage.ljust(padding) + sample
@@ -250,7 +250,8 @@ class Thor
250
250
  @parsing_options
251
251
  end
252
252
 
253
- # Parse boolean values which can be given as --foo=true, --foo or --no-foo.
253
+ # Parse boolean values which can be given as --foo=true or --foo for true values, or
254
+ # --foo=false, --no-foo or --skip-foo for false values.
254
255
  #
255
256
  def parse_boolean(switch)
256
257
  if current_is_value?
@@ -67,15 +67,15 @@ class Thor
67
67
  # Readline.
68
68
  #
69
69
  # ==== Example
70
- # ask("What is your name?")
70
+ # ask("What is your name?")
71
71
  #
72
- # ask("What is the planet furthest from the sun?", :default => "Pluto")
72
+ # ask("What is the planet furthest from the sun?", :default => "Neptune")
73
73
  #
74
- # ask("What is your favorite Neopolitan flavor?", :limited_to => ["strawberry", "chocolate", "vanilla"])
74
+ # ask("What is your favorite Neopolitan flavor?", :limited_to => ["strawberry", "chocolate", "vanilla"])
75
75
  #
76
- # ask("What is your password?", :echo => false)
76
+ # ask("What is your password?", :echo => false)
77
77
  #
78
- # ask("Where should the file be saved?", :path => true)
78
+ # ask("Where should the file be saved?", :path => true)
79
79
  #
80
80
  def ask(statement, *args)
81
81
  options = args.last.is_a?(Hash) ? args.pop : {}
@@ -93,7 +93,7 @@ class Thor
93
93
  # are passed straight to puts (behavior got from Highline).
94
94
  #
95
95
  # ==== Example
96
- # say("I know you knew that.")
96
+ # say("I know you knew that.")
97
97
  #
98
98
  def say(message = "", color = nil, force_new_line = (message.to_s !~ /( |\t)\Z/))
99
99
  return if quiet?
@@ -110,7 +110,7 @@ class Thor
110
110
  # are passed straight to puts (behavior got from Highline).
111
111
  #
112
112
  # ==== Example
113
- # say_error("error: something went wrong")
113
+ # say_error("error: something went wrong")
114
114
  #
115
115
  def say_error(message = "", color = nil, force_new_line = (message.to_s !~ /( |\t)\Z/))
116
116
  return if quiet?
@@ -143,14 +143,14 @@ class Thor
143
143
  stdout.flush
144
144
  end
145
145
 
146
- # Make a question the to user and returns true if the user replies "y" or
146
+ # Asks the user a question and returns true if the user replies "y" or
147
147
  # "yes".
148
148
  #
149
149
  def yes?(statement, color = nil)
150
150
  !!(ask(statement, color, add_to_history: false) =~ is?(:yes))
151
151
  end
152
152
 
153
- # Make a question the to user and returns true if the user replies "n" or
153
+ # Asks the user a question and returns true if the user replies "n" or
154
154
  # "no".
155
155
  #
156
156
  def no?(statement, color = nil)
@@ -67,7 +67,7 @@ class Thor
67
67
  # Ask something to the user and receives a response.
68
68
  #
69
69
  # ==== Example
70
- # ask("What is your name?")
70
+ # ask("What is your name?")
71
71
  #
72
72
  # TODO: Implement #ask for Thor::Shell::HTML
73
73
  def ask(statement, color = nil)
@@ -102,33 +102,17 @@ class Thor
102
102
 
103
103
  def truncate(string)
104
104
  return string unless @truncate
105
- as_unicode do
106
- chars = string.chars.to_a
107
- if chars.length <= @truncate
108
- chars.join
109
- else
110
- chars[0, @truncate - 3 - @indent].join + "..."
111
- end
105
+ chars = string.chars.to_a
106
+ if chars.length <= @truncate
107
+ chars.join
108
+ else
109
+ chars[0, @truncate - 3 - @indent].join + "..."
112
110
  end
113
111
  end
114
112
 
115
113
  def indentation
116
114
  " " * @indent
117
115
  end
118
-
119
- if "".respond_to?(:encode)
120
- def as_unicode
121
- yield
122
- end
123
- else
124
- def as_unicode
125
- old = $KCODE # rubocop:disable Style/GlobalVars
126
- $KCODE = "U" # rubocop:disable Style/GlobalVars
127
- yield
128
- ensure
129
- $KCODE = old # rubocop:disable Style/GlobalVars
130
- end
131
- end
132
116
  end
133
117
  end
134
118
  end
data/lib/thor/util.rb CHANGED
@@ -133,7 +133,7 @@ class Thor
133
133
  *pieces, command = namespace.split(":")
134
134
  namespace = pieces.join(":")
135
135
  namespace = "default" if namespace.empty?
136
- klass = Thor::Base.subclasses.detect { |thor| thor.namespace == namespace && thor.commands.keys.include?(command) }
136
+ klass = Thor::Base.subclasses.detect { |thor| thor.namespace == namespace && thor.command_exists?(command) }
137
137
  end
138
138
  unless klass # look for a Thor::Group with the right name
139
139
  klass = Thor::Util.find_by_namespace(namespace)
data/lib/thor/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Thor
2
- VERSION = "1.3.0"
2
+ VERSION = "1.3.2"
3
3
  end
data/lib/thor.rb CHANGED
@@ -439,6 +439,17 @@ class Thor
439
439
  command && disable_required_check.include?(command.name.to_sym)
440
440
  end
441
441
 
442
+ # Checks if a specified command exists.
443
+ #
444
+ # ==== Parameters
445
+ # command_name<String>:: The name of the command to check for existence.
446
+ #
447
+ # ==== Returns
448
+ # Boolean:: +true+ if the command exists, +false+ otherwise.
449
+ def command_exists?(command_name) #:nodoc:
450
+ commands.keys.include?(normalize_command_name(command_name))
451
+ end
452
+
442
453
  protected
443
454
 
444
455
  # Returns this class exclusive options array set.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thor
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yehuda Katz
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-10-18 00:00:00.000000000 Z
12
+ date: 2024-08-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -85,9 +85,9 @@ licenses:
85
85
  - MIT
86
86
  metadata:
87
87
  bug_tracker_uri: https://github.com/rails/thor/issues
88
- changelog_uri: https://github.com/rails/thor/releases/tag/v1.3.0
88
+ changelog_uri: https://github.com/rails/thor/releases/tag/v1.3.2
89
89
  documentation_uri: http://whatisthor.com/
90
- source_code_uri: https://github.com/rails/thor/tree/v1.3.0
90
+ source_code_uri: https://github.com/rails/thor/tree/v1.3.2
91
91
  wiki_uri: https://github.com/rails/thor/wiki
92
92
  rubygems_mfa_required: 'true'
93
93
  post_install_message:
@@ -105,7 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
105
105
  - !ruby/object:Gem::Version
106
106
  version: 1.3.5
107
107
  requirements: []
108
- rubygems_version: 3.4.21
108
+ rubygems_version: 3.5.11
109
109
  signing_key:
110
110
  specification_version: 4
111
111
  summary: Thor is a toolkit for building powerful command-line interfaces.