thor 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.
- checksums.yaml +4 -4
- data/lib/thor/actions/create_file.rb +1 -1
- data/lib/thor/actions/file_manipulation.rb +2 -2
- data/lib/thor/actions/inject_into_file.rb +1 -1
- data/lib/thor/actions.rb +4 -3
- data/lib/thor/base.rb +4 -5
- data/lib/thor/error.rb +9 -13
- data/lib/thor/group.rb +1 -1
- data/lib/thor/parser/arguments.rb +1 -1
- data/lib/thor/parser/option.rb +7 -3
- data/lib/thor/parser/options.rb +4 -4
- data/lib/thor/rake_compat.rb +2 -2
- data/lib/thor/runner.rb +32 -22
- data/lib/thor/shell/basic.rb +2 -2
- data/lib/thor/shell/color.rb +1 -1
- data/lib/thor/util.rb +4 -4
- data/lib/thor/version.rb +1 -1
- data/lib/thor.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 51ab2cb4ae4ac2fe79583c377aa7385d47206d1e47ac0de5090f6a02de60f603
|
4
|
+
data.tar.gz: 8ec9bc5cb0cb2288d8c0909aff4d05e649e48404d97ea339f9db6cf7498c05da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ed6c11335f2f33c1fe2f49f4552110b1fad06c59547bd06b92e49fd01fa5b5a261d5298d7fabf5ca8ff9a8708e2f2d4ecb26e330b8aa2a4e20514c2e113cb94
|
7
|
+
data.tar.gz: 912dfd2214bad858c184ce1a8994e1eab38acb9ccecf6aaf68f257dbfaa586fa7e427ff0e234ee5b99b738dae2539194a2d2c1943aed9bc3bfd2c527e941a12c
|
@@ -60,7 +60,7 @@ class Thor
|
|
60
60
|
invoke_with_conflict_check do
|
61
61
|
require "fileutils"
|
62
62
|
FileUtils.mkdir_p(File.dirname(destination))
|
63
|
-
File.open(destination, "wb") { |f| f.write render }
|
63
|
+
File.open(destination, "wb", config[:perm]) { |f| f.write render }
|
64
64
|
end
|
65
65
|
given_destination
|
66
66
|
end
|
@@ -85,7 +85,7 @@ class Thor
|
|
85
85
|
URI.send(:open, source) { |input| input.binmode.read }
|
86
86
|
else
|
87
87
|
source = File.expand_path(find_in_source_paths(source.to_s))
|
88
|
-
open(source) { |input| input.binmode.read }
|
88
|
+
File.open(source) { |input| input.binmode.read }
|
89
89
|
end
|
90
90
|
|
91
91
|
destination ||= if block_given?
|
@@ -252,7 +252,7 @@ class Thor
|
|
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
254
|
# config<Hash>:: give :verbose => false to not log the status, and
|
255
|
-
# :force => true, to force the replacement
|
255
|
+
# :force => true, to force the replacement regardless of runner behavior.
|
256
256
|
#
|
257
257
|
# ==== Example
|
258
258
|
#
|
@@ -21,7 +21,7 @@ class Thor
|
|
21
21
|
# gems.split(" ").map{ |gem| " config.gem :#{gem}" }.join("\n")
|
22
22
|
# end
|
23
23
|
#
|
24
|
-
WARNINGS = { unchanged_no_flag: 'File unchanged!
|
24
|
+
WARNINGS = { unchanged_no_flag: 'File unchanged! Either the supplied flag value not found or the content has already been inserted!' }
|
25
25
|
|
26
26
|
def insert_into_file(destination, *args, &block)
|
27
27
|
data = block_given? ? block : args.shift
|
data/lib/thor/actions.rb
CHANGED
@@ -175,7 +175,7 @@ class Thor
|
|
175
175
|
shell.padding += 1 if verbose
|
176
176
|
@destination_stack.push File.expand_path(dir, destination_root)
|
177
177
|
|
178
|
-
# If the directory
|
178
|
+
# If the directory doesn't exist and we're not pretending
|
179
179
|
if !File.exist?(destination_root) && !pretend
|
180
180
|
require "fileutils"
|
181
181
|
FileUtils.mkdir_p(destination_root)
|
@@ -223,9 +223,10 @@ class Thor
|
|
223
223
|
|
224
224
|
contents = if is_uri
|
225
225
|
require "open-uri"
|
226
|
-
|
226
|
+
# for ruby 2.1-2.4
|
227
|
+
URI.send(:open, path, "Accept" => "application/x-thor-template", &:read)
|
227
228
|
else
|
228
|
-
open(path, &:read)
|
229
|
+
File.open(path, &:read)
|
229
230
|
end
|
230
231
|
|
231
232
|
instance_eval(contents, path)
|
data/lib/thor/base.rb
CHANGED
@@ -506,7 +506,7 @@ class Thor
|
|
506
506
|
#
|
507
507
|
def public_command(*names)
|
508
508
|
names.each do |name|
|
509
|
-
class_eval "def #{name}(*); super end"
|
509
|
+
class_eval "def #{name}(*); super end", __FILE__, __LINE__
|
510
510
|
end
|
511
511
|
end
|
512
512
|
alias_method :public_task, :public_command
|
@@ -558,8 +558,7 @@ class Thor
|
|
558
558
|
return if options.empty?
|
559
559
|
|
560
560
|
list = []
|
561
|
-
padding = options.map { |o| o.
|
562
|
-
|
561
|
+
padding = options.map { |o| o.aliases_for_usage.size }.max.to_i
|
563
562
|
options.each do |option|
|
564
563
|
next if option.hide
|
565
564
|
item = [option.usage(padding)]
|
@@ -610,7 +609,7 @@ class Thor
|
|
610
609
|
def find_and_refresh_command(name) #:nodoc:
|
611
610
|
if commands[name.to_s]
|
612
611
|
commands[name.to_s]
|
613
|
-
elsif command = all_commands[name.to_s] # rubocop:disable AssignmentInCondition
|
612
|
+
elsif command = all_commands[name.to_s] # rubocop:disable Lint/AssignmentInCondition
|
614
613
|
commands[name.to_s] = command.clone
|
615
614
|
else
|
616
615
|
raise ArgumentError, "You supplied :for => #{name.inspect}, but the command #{name.inspect} could not be found."
|
@@ -618,7 +617,7 @@ class Thor
|
|
618
617
|
end
|
619
618
|
alias_method :find_and_refresh_task, :find_and_refresh_command
|
620
619
|
|
621
|
-
#
|
620
|
+
# Every time someone inherits from a Thor class, register the klass
|
622
621
|
# and file into baseclass.
|
623
622
|
def inherited(klass)
|
624
623
|
super(klass)
|
data/lib/thor/error.rb
CHANGED
@@ -11,7 +11,15 @@ class Thor
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
-
|
14
|
+
Module.new do
|
15
|
+
def to_s
|
16
|
+
super + DidYouMean.formatter.message_for(corrections)
|
17
|
+
end
|
18
|
+
|
19
|
+
def corrections
|
20
|
+
@corrections ||= self.class.const_get(:SpellChecker).new(self).corrections
|
21
|
+
end
|
22
|
+
end
|
15
23
|
end
|
16
24
|
|
17
25
|
# Thor::Error is raised when it's caused by wrong usage of thor classes. Those
|
@@ -100,16 +108,4 @@ class Thor
|
|
100
108
|
|
101
109
|
class MalformattedArgumentError < InvocationError
|
102
110
|
end
|
103
|
-
|
104
|
-
if Correctable
|
105
|
-
if DidYouMean.respond_to?(:correct_error)
|
106
|
-
DidYouMean.correct_error(Thor::UndefinedCommandError, UndefinedCommandError::SpellChecker)
|
107
|
-
DidYouMean.correct_error(Thor::UnknownArgumentError, UnknownArgumentError::SpellChecker)
|
108
|
-
else
|
109
|
-
DidYouMean::SPELL_CHECKERS.merge!(
|
110
|
-
'Thor::UndefinedCommandError' => UndefinedCommandError::SpellChecker,
|
111
|
-
'Thor::UnknownArgumentError' => UnknownArgumentError::SpellChecker
|
112
|
-
)
|
113
|
-
end
|
114
|
-
end
|
115
111
|
end
|
data/lib/thor/group.rb
CHANGED
@@ -169,7 +169,7 @@ class Thor::Group
|
|
169
169
|
# options are added to group_options hash. Options that already exists
|
170
170
|
# in base_options are not added twice.
|
171
171
|
#
|
172
|
-
def get_options_from_invocations(group_options, base_options) #:nodoc:
|
172
|
+
def get_options_from_invocations(group_options, base_options) #:nodoc:
|
173
173
|
invocations.each do |name, from_option|
|
174
174
|
value = if from_option
|
175
175
|
option = class_options[name]
|
data/lib/thor/parser/option.rb
CHANGED
@@ -58,7 +58,7 @@ class Thor
|
|
58
58
|
default = nil
|
59
59
|
if VALID_TYPES.include?(value)
|
60
60
|
value
|
61
|
-
elsif required = (value == :required) # rubocop:disable AssignmentInCondition
|
61
|
+
elsif required = (value == :required) # rubocop:disable Lint/AssignmentInCondition
|
62
62
|
:string
|
63
63
|
end
|
64
64
|
when TrueClass, FalseClass
|
@@ -93,10 +93,14 @@ class Thor
|
|
93
93
|
sample << ", [#{dasherize('no-' + human_name)}]" unless (name == "force") || name.start_with?("no-")
|
94
94
|
end
|
95
95
|
|
96
|
+
aliases_for_usage.ljust(padding) + sample
|
97
|
+
end
|
98
|
+
|
99
|
+
def aliases_for_usage
|
96
100
|
if aliases.empty?
|
97
|
-
|
101
|
+
""
|
98
102
|
else
|
99
|
-
"#{aliases.join(', ')},
|
103
|
+
"#{aliases.join(', ')}, "
|
100
104
|
end
|
101
105
|
end
|
102
106
|
|
data/lib/thor/parser/options.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
class Thor
|
2
|
-
class Options < Arguments #:nodoc:
|
2
|
+
class Options < Arguments #:nodoc:
|
3
3
|
LONG_RE = /^(--\w+(?:-\w+)*)$/
|
4
4
|
SHORT_RE = /^(-[a-z])$/i
|
5
5
|
EQ_RE = /^(--\w+(?:-\w+)*|-[a-z])=(.*)$/i
|
@@ -85,7 +85,7 @@ class Thor
|
|
85
85
|
super(arg)
|
86
86
|
end
|
87
87
|
|
88
|
-
def parse(args) # rubocop:disable MethodLength
|
88
|
+
def parse(args) # rubocop:disable Metrics/MethodLength
|
89
89
|
@pile = args.dup
|
90
90
|
@is_treated_as_value = false
|
91
91
|
@parsing_options = true
|
@@ -101,7 +101,7 @@ class Thor
|
|
101
101
|
unshift($1.split("").map { |f| "-#{f}" })
|
102
102
|
next
|
103
103
|
when EQ_RE
|
104
|
-
unshift($2, is_value
|
104
|
+
unshift($2, :is_value => true)
|
105
105
|
switch = $1
|
106
106
|
when SHORT_NUM
|
107
107
|
unshift($2)
|
@@ -194,7 +194,7 @@ class Thor
|
|
194
194
|
end
|
195
195
|
|
196
196
|
def switch_option(arg)
|
197
|
-
if match = no_or_skip?(arg) # rubocop:disable AssignmentInCondition
|
197
|
+
if match = no_or_skip?(arg) # rubocop:disable Lint/AssignmentInCondition
|
198
198
|
@switches[arg] || @switches["--#{match}"]
|
199
199
|
else
|
200
200
|
@switches[arg]
|
data/lib/thor/rake_compat.rb
CHANGED
@@ -41,7 +41,7 @@ instance_eval do
|
|
41
41
|
def task(*)
|
42
42
|
task = super
|
43
43
|
|
44
|
-
if klass = Thor::RakeCompat.rake_classes.last # rubocop:disable AssignmentInCondition
|
44
|
+
if klass = Thor::RakeCompat.rake_classes.last # rubocop:disable Lint/AssignmentInCondition
|
45
45
|
non_namespaced_name = task.name.split(":").last
|
46
46
|
|
47
47
|
description = non_namespaced_name
|
@@ -59,7 +59,7 @@ instance_eval do
|
|
59
59
|
end
|
60
60
|
|
61
61
|
def namespace(name)
|
62
|
-
if klass = Thor::RakeCompat.rake_classes.last # rubocop:disable AssignmentInCondition
|
62
|
+
if klass = Thor::RakeCompat.rake_classes.last # rubocop:disable Lint/AssignmentInCondition
|
63
63
|
const_name = Thor::Util.camel_case(name.to_s).to_sym
|
64
64
|
klass.const_set(const_name, Class.new(Thor))
|
65
65
|
new_klass = klass.const_get(const_name)
|
data/lib/thor/runner.rb
CHANGED
@@ -2,12 +2,10 @@ require_relative "../thor"
|
|
2
2
|
require_relative "group"
|
3
3
|
|
4
4
|
require "yaml"
|
5
|
-
require "digest/
|
5
|
+
require "digest/sha2"
|
6
6
|
require "pathname"
|
7
7
|
|
8
|
-
class Thor::Runner < Thor #:nodoc:
|
9
|
-
autoload :OpenURI, "open-uri"
|
10
|
-
|
8
|
+
class Thor::Runner < Thor #:nodoc:
|
11
9
|
map "-T" => :list, "-i" => :install, "-u" => :update, "-v" => :version
|
12
10
|
|
13
11
|
def self.banner(command, all = false, subcommand = false)
|
@@ -45,25 +43,37 @@ class Thor::Runner < Thor #:nodoc: # rubocop:disable ClassLength
|
|
45
43
|
|
46
44
|
desc "install NAME", "Install an optionally named Thor file into your system commands"
|
47
45
|
method_options :as => :string, :relative => :boolean, :force => :boolean
|
48
|
-
def install(name) # rubocop:disable MethodLength
|
46
|
+
def install(name) # rubocop:disable Metrics/MethodLength
|
49
47
|
initialize_thorfiles
|
50
48
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
49
|
+
is_uri = name =~ %r{^https?\://}
|
50
|
+
|
51
|
+
if is_uri
|
52
|
+
base = name
|
53
|
+
package = :file
|
54
|
+
require "open-uri"
|
55
|
+
begin
|
56
|
+
contents = URI.send(:open, name, &:read) # Using `send` for Ruby 2.4- support
|
57
|
+
rescue OpenURI::HTTPError
|
58
|
+
raise Error, "Error opening URI '#{name}'"
|
59
|
+
end
|
60
|
+
else
|
61
|
+
# If a directory name is provided as the argument, look for a 'main.thor'
|
62
|
+
# command in said directory.
|
63
|
+
begin
|
64
|
+
if File.directory?(File.expand_path(name))
|
65
|
+
base = File.join(name, "main.thor")
|
66
|
+
package = :directory
|
67
|
+
contents = File.open(base, &:read)
|
68
|
+
else
|
69
|
+
base = name
|
70
|
+
package = :file
|
71
|
+
require "open-uri"
|
72
|
+
contents = URI.send(:open, name, &:read) # for ruby 2.1-2.4
|
73
|
+
end
|
74
|
+
rescue Errno::ENOENT
|
75
|
+
raise Error, "Error opening file '#{name}'"
|
62
76
|
end
|
63
|
-
rescue OpenURI::HTTPError
|
64
|
-
raise Error, "Error opening URI '#{name}'"
|
65
|
-
rescue Errno::ENOENT
|
66
|
-
raise Error, "Error opening file '#{name}'"
|
67
77
|
end
|
68
78
|
|
69
79
|
say "Your Thorfile contains:"
|
@@ -84,14 +94,14 @@ class Thor::Runner < Thor #:nodoc: # rubocop:disable ClassLength
|
|
84
94
|
as = basename if as.empty?
|
85
95
|
end
|
86
96
|
|
87
|
-
location = if options[:relative] ||
|
97
|
+
location = if options[:relative] || is_uri
|
88
98
|
name
|
89
99
|
else
|
90
100
|
File.expand_path(name)
|
91
101
|
end
|
92
102
|
|
93
103
|
thor_yaml[as] = {
|
94
|
-
:filename => Digest::
|
104
|
+
:filename => Digest::SHA256.hexdigest(name + as),
|
95
105
|
:location => location,
|
96
106
|
:namespaces => Thor::Util.namespaces_in_content(contents, base)
|
97
107
|
}
|
data/lib/thor/shell/basic.rb
CHANGED
@@ -182,7 +182,7 @@ class Thor
|
|
182
182
|
# indent<Integer>:: Indent the first column by indent value.
|
183
183
|
# colwidth<Integer>:: Force the first column to colwidth spaces wide.
|
184
184
|
#
|
185
|
-
def print_table(array, options = {}) # rubocop:disable MethodLength
|
185
|
+
def print_table(array, options = {}) # rubocop:disable Metrics/MethodLength
|
186
186
|
return if array.empty?
|
187
187
|
|
188
188
|
formats = []
|
@@ -425,7 +425,7 @@ class Thor
|
|
425
425
|
end
|
426
426
|
|
427
427
|
def unix?
|
428
|
-
RUBY_PLATFORM =~ /(aix|darwin|linux|(net|free|open)bsd|cygwin|solaris
|
428
|
+
RUBY_PLATFORM =~ /(aix|darwin|linux|(net|free|open)bsd|cygwin|solaris)/i
|
429
429
|
end
|
430
430
|
|
431
431
|
def truncate(string, width)
|
data/lib/thor/shell/color.rb
CHANGED
data/lib/thor/util.rb
CHANGED
@@ -90,7 +90,7 @@ class Thor
|
|
90
90
|
def snake_case(str)
|
91
91
|
return str.downcase if str =~ /^[A-Z_]+$/
|
92
92
|
str.gsub(/\B[A-Z]/, '_\&').squeeze("_") =~ /_*(.*)/
|
93
|
-
|
93
|
+
Regexp.last_match(-1).downcase
|
94
94
|
end
|
95
95
|
|
96
96
|
# Receives a string and convert it to camel case. camel_case returns CamelCase.
|
@@ -150,7 +150,7 @@ class Thor
|
|
150
150
|
# inside the sandbox to avoid namespacing conflicts.
|
151
151
|
#
|
152
152
|
def load_thorfile(path, content = nil, debug = false)
|
153
|
-
content ||= File.
|
153
|
+
content ||= File.read(path)
|
154
154
|
|
155
155
|
begin
|
156
156
|
Thor::Sandbox.class_eval(content, path)
|
@@ -189,7 +189,7 @@ class Thor
|
|
189
189
|
# Returns the root where thor files are located, depending on the OS.
|
190
190
|
#
|
191
191
|
def thor_root
|
192
|
-
File.join(user_home, ".thor").tr(
|
192
|
+
File.join(user_home, ".thor").tr("\\", "/")
|
193
193
|
end
|
194
194
|
|
195
195
|
# Returns the files in the thor root. On Windows thor_root will be something
|
@@ -236,7 +236,7 @@ class Thor
|
|
236
236
|
# symlink points to 'ruby_install_name'
|
237
237
|
ruby = alternate_ruby if linked_ruby == ruby_name || linked_ruby == ruby
|
238
238
|
end
|
239
|
-
rescue NotImplementedError # rubocop:disable HandleExceptions
|
239
|
+
rescue NotImplementedError # rubocop:disable Lint/HandleExceptions
|
240
240
|
# just ignore on windows
|
241
241
|
end
|
242
242
|
end
|
data/lib/thor/version.rb
CHANGED
data/lib/thor.rb
CHANGED
@@ -356,7 +356,7 @@ class Thor
|
|
356
356
|
end
|
357
357
|
|
358
358
|
# The method responsible for dispatching given the args.
|
359
|
-
def dispatch(meth, given_args, given_opts, config) #:nodoc:
|
359
|
+
def dispatch(meth, given_args, given_opts, config) #:nodoc:
|
360
360
|
meth ||= retrieve_command_name(given_args)
|
361
361
|
command = all_commands[normalize_command_name(meth)]
|
362
362
|
|
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.2.
|
4
|
+
version: 1.2.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:
|
12
|
+
date: 2023-05-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -80,9 +80,9 @@ licenses:
|
|
80
80
|
- MIT
|
81
81
|
metadata:
|
82
82
|
bug_tracker_uri: https://github.com/rails/thor/issues
|
83
|
-
changelog_uri: https://github.com/rails/thor/releases/tag/v1.2.
|
83
|
+
changelog_uri: https://github.com/rails/thor/releases/tag/v1.2.2
|
84
84
|
documentation_uri: http://whatisthor.com/
|
85
|
-
source_code_uri: https://github.com/rails/thor/tree/v1.2.
|
85
|
+
source_code_uri: https://github.com/rails/thor/tree/v1.2.2
|
86
86
|
wiki_uri: https://github.com/rails/thor/wiki
|
87
87
|
rubygems_mfa_required: 'true'
|
88
88
|
post_install_message:
|
@@ -100,7 +100,7 @@ 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.
|
103
|
+
rubygems_version: 3.4.10
|
104
104
|
signing_key:
|
105
105
|
specification_version: 4
|
106
106
|
summary: Thor is a toolkit for building powerful command-line interfaces.
|