thor 0.14.6 → 0.19.4
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 +7 -0
- data/.document +5 -0
- data/{CHANGELOG.rdoc → CHANGELOG.md} +91 -31
- data/CONTRIBUTING.md +15 -0
- data/{LICENSE → LICENSE.md} +2 -2
- data/README.md +36 -296
- data/bin/thor +1 -1
- data/lib/thor/actions/create_file.rb +33 -35
- data/lib/thor/actions/create_link.rb +7 -5
- data/lib/thor/actions/directory.rb +49 -24
- data/lib/thor/actions/empty_directory.rb +68 -67
- data/lib/thor/actions/file_manipulation.rb +85 -28
- data/lib/thor/actions/inject_into_file.rb +26 -32
- data/lib/thor/actions.rb +70 -66
- data/lib/thor/base.rb +314 -237
- data/lib/thor/command.rb +133 -0
- data/lib/thor/core_ext/hash_with_indifferent_access.rb +34 -24
- data/lib/thor/core_ext/io_binary_read.rb +12 -0
- data/lib/thor/core_ext/ordered_hash.rb +94 -65
- data/lib/thor/error.rb +10 -8
- data/lib/thor/group.rb +74 -66
- data/lib/thor/invocation.rb +65 -56
- data/lib/thor/line_editor/basic.rb +35 -0
- data/lib/thor/line_editor/readline.rb +88 -0
- data/lib/thor/line_editor.rb +17 -0
- data/lib/thor/parser/argument.rb +32 -29
- data/lib/thor/parser/arguments.rb +107 -93
- data/lib/thor/parser/option.rb +39 -13
- data/lib/thor/parser/options.rb +144 -97
- data/lib/thor/parser.rb +4 -4
- data/lib/thor/rake_compat.rb +21 -16
- data/lib/thor/runner.rb +166 -153
- data/lib/thor/shell/basic.rb +268 -122
- data/lib/thor/shell/color.rb +84 -43
- data/lib/thor/shell/html.rb +71 -66
- data/lib/thor/shell.rb +30 -37
- data/lib/thor/util.rb +227 -188
- data/lib/thor/version.rb +1 -1
- data/lib/thor.rb +289 -131
- data/thor.gemspec +21 -0
- metadata +50 -189
- data/Thorfile +0 -24
- data/bin/rake2thor +0 -86
- data/lib/thor/core_ext/file_binary_read.rb +0 -9
- data/lib/thor/task.rb +0 -114
- data/spec/actions/create_file_spec.rb +0 -170
- data/spec/actions/directory_spec.rb +0 -136
- data/spec/actions/empty_directory_spec.rb +0 -98
- data/spec/actions/file_manipulation_spec.rb +0 -310
- data/spec/actions/inject_into_file_spec.rb +0 -135
- data/spec/actions_spec.rb +0 -322
- data/spec/base_spec.rb +0 -269
- data/spec/core_ext/hash_with_indifferent_access_spec.rb +0 -43
- data/spec/core_ext/ordered_hash_spec.rb +0 -115
- data/spec/fixtures/application.rb +0 -2
- data/spec/fixtures/bundle/execute.rb +0 -6
- data/spec/fixtures/bundle/main.thor +0 -1
- data/spec/fixtures/doc/%file_name%.rb.tt +0 -1
- data/spec/fixtures/doc/README +0 -3
- data/spec/fixtures/doc/block_helper.rb +0 -3
- data/spec/fixtures/doc/components/.empty_directory +0 -0
- data/spec/fixtures/doc/config.rb +0 -1
- data/spec/fixtures/group.thor +0 -114
- data/spec/fixtures/invoke.thor +0 -112
- data/spec/fixtures/path with spaces +0 -0
- data/spec/fixtures/script.thor +0 -184
- data/spec/fixtures/task.thor +0 -10
- data/spec/group_spec.rb +0 -178
- data/spec/invocation_spec.rb +0 -100
- data/spec/parser/argument_spec.rb +0 -47
- data/spec/parser/arguments_spec.rb +0 -64
- data/spec/parser/option_spec.rb +0 -202
- data/spec/parser/options_spec.rb +0 -319
- data/spec/rake_compat_spec.rb +0 -68
- data/spec/register_spec.rb +0 -92
- data/spec/runner_spec.rb +0 -210
- data/spec/shell/basic_spec.rb +0 -223
- data/spec/shell/color_spec.rb +0 -41
- data/spec/shell/html_spec.rb +0 -27
- data/spec/shell_spec.rb +0 -47
- data/spec/spec_helper.rb +0 -54
- data/spec/task_spec.rb +0 -69
- data/spec/thor_spec.rb +0 -334
- data/spec/util_spec.rb +0 -163
data/lib/thor/util.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require
|
|
1
|
+
require "rbconfig"
|
|
2
2
|
|
|
3
3
|
class Thor
|
|
4
4
|
module Sandbox #:nodoc:
|
|
@@ -8,222 +8,261 @@ class Thor
|
|
|
8
8
|
#
|
|
9
9
|
# 1) Methods to convert thor namespaces to constants and vice-versa.
|
|
10
10
|
#
|
|
11
|
-
# Thor::
|
|
11
|
+
# Thor::Util.namespace_from_thor_class(Foo::Bar::Baz) #=> "foo:bar:baz"
|
|
12
12
|
#
|
|
13
13
|
# 2) Loading thor files and sandboxing:
|
|
14
14
|
#
|
|
15
|
-
# Thor::
|
|
15
|
+
# Thor::Util.load_thorfile("~/.thor/foo")
|
|
16
16
|
#
|
|
17
17
|
module Util
|
|
18
|
+
class << self
|
|
19
|
+
# Receives a namespace and search for it in the Thor::Base subclasses.
|
|
20
|
+
#
|
|
21
|
+
# ==== Parameters
|
|
22
|
+
# namespace<String>:: The namespace to search for.
|
|
23
|
+
#
|
|
24
|
+
def find_by_namespace(namespace)
|
|
25
|
+
namespace = "default#{namespace}" if namespace.empty? || namespace =~ /^:/
|
|
26
|
+
Thor::Base.subclasses.detect { |klass| klass.namespace == namespace }
|
|
27
|
+
end
|
|
18
28
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
namespace
|
|
26
|
-
|
|
27
|
-
|
|
29
|
+
# Receives a constant and converts it to a Thor namespace. Since Thor
|
|
30
|
+
# commands can be added to a sandbox, this method is also responsable for
|
|
31
|
+
# removing the sandbox namespace.
|
|
32
|
+
#
|
|
33
|
+
# This method should not be used in general because it's used to deal with
|
|
34
|
+
# older versions of Thor. On current versions, if you need to get the
|
|
35
|
+
# namespace from a class, just call namespace on it.
|
|
36
|
+
#
|
|
37
|
+
# ==== Parameters
|
|
38
|
+
# constant<Object>:: The constant to be converted to the thor path.
|
|
39
|
+
#
|
|
40
|
+
# ==== Returns
|
|
41
|
+
# String:: If we receive Foo::Bar::Baz it returns "foo:bar:baz"
|
|
42
|
+
#
|
|
43
|
+
def namespace_from_thor_class(constant)
|
|
44
|
+
constant = constant.to_s.gsub(/^Thor::Sandbox::/, "")
|
|
45
|
+
constant = snake_case(constant).squeeze(":")
|
|
46
|
+
constant
|
|
47
|
+
end
|
|
28
48
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
# String:: If we receive Foo::Bar::Baz it returns "foo:bar:baz"
|
|
42
|
-
#
|
|
43
|
-
def self.namespace_from_thor_class(constant)
|
|
44
|
-
constant = constant.to_s.gsub(/^Thor::Sandbox::/, "")
|
|
45
|
-
constant = snake_case(constant).squeeze(":")
|
|
46
|
-
constant
|
|
47
|
-
end
|
|
49
|
+
# Given the contents, evaluate it inside the sandbox and returns the
|
|
50
|
+
# namespaces defined in the sandbox.
|
|
51
|
+
#
|
|
52
|
+
# ==== Parameters
|
|
53
|
+
# contents<String>
|
|
54
|
+
#
|
|
55
|
+
# ==== Returns
|
|
56
|
+
# Array[Object]
|
|
57
|
+
#
|
|
58
|
+
def namespaces_in_content(contents, file = __FILE__)
|
|
59
|
+
old_constants = Thor::Base.subclasses.dup
|
|
60
|
+
Thor::Base.subclasses.clear
|
|
48
61
|
|
|
49
|
-
|
|
50
|
-
# namespaces defined in the sandbox.
|
|
51
|
-
#
|
|
52
|
-
# ==== Parameters
|
|
53
|
-
# contents<String>
|
|
54
|
-
#
|
|
55
|
-
# ==== Returns
|
|
56
|
-
# Array[Object]
|
|
57
|
-
#
|
|
58
|
-
def self.namespaces_in_content(contents, file=__FILE__)
|
|
59
|
-
old_constants = Thor::Base.subclasses.dup
|
|
60
|
-
Thor::Base.subclasses.clear
|
|
61
|
-
|
|
62
|
-
load_thorfile(file, contents)
|
|
63
|
-
|
|
64
|
-
new_constants = Thor::Base.subclasses.dup
|
|
65
|
-
Thor::Base.subclasses.replace(old_constants)
|
|
66
|
-
|
|
67
|
-
new_constants.map!{ |c| c.namespace }
|
|
68
|
-
new_constants.compact!
|
|
69
|
-
new_constants
|
|
70
|
-
end
|
|
62
|
+
load_thorfile(file, contents)
|
|
71
63
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
def self.thor_classes_in(klass)
|
|
75
|
-
stringfied_constants = klass.constants.map { |c| c.to_s }
|
|
76
|
-
Thor::Base.subclasses.select do |subclass|
|
|
77
|
-
next unless subclass.name
|
|
78
|
-
stringfied_constants.include?(subclass.name.gsub("#{klass.name}::", ''))
|
|
79
|
-
end
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
# Receives a string and convert it to snake case. SnakeCase returns snake_case.
|
|
83
|
-
#
|
|
84
|
-
# ==== Parameters
|
|
85
|
-
# String
|
|
86
|
-
#
|
|
87
|
-
# ==== Returns
|
|
88
|
-
# String
|
|
89
|
-
#
|
|
90
|
-
def self.snake_case(str)
|
|
91
|
-
return str.downcase if str =~ /^[A-Z_]+$/
|
|
92
|
-
str.gsub(/\B[A-Z]/, '_\&').squeeze('_') =~ /_*(.*)/
|
|
93
|
-
return $+.downcase
|
|
94
|
-
end
|
|
64
|
+
new_constants = Thor::Base.subclasses.dup
|
|
65
|
+
Thor::Base.subclasses.replace(old_constants)
|
|
95
66
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
#
|
|
101
|
-
# ==== Returns
|
|
102
|
-
# String
|
|
103
|
-
#
|
|
104
|
-
def self.camel_case(str)
|
|
105
|
-
return str if str !~ /_/ && str =~ /[A-Z]+.*/
|
|
106
|
-
str.split('_').map { |i| i.capitalize }.join
|
|
107
|
-
end
|
|
67
|
+
new_constants.map!(&:namespace)
|
|
68
|
+
new_constants.compact!
|
|
69
|
+
new_constants
|
|
70
|
+
end
|
|
108
71
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
# def baz
|
|
118
|
-
# end
|
|
119
|
-
# end
|
|
120
|
-
#
|
|
121
|
-
# class Baz::Foo < Thor::Group
|
|
122
|
-
# end
|
|
123
|
-
#
|
|
124
|
-
# Thor::Util.namespace_to_thor_class("foo:bar") #=> Foo::Bar, nil # will invoke default task
|
|
125
|
-
# Thor::Util.namespace_to_thor_class("baz:foo") #=> Baz::Foo, nil
|
|
126
|
-
# Thor::Util.namespace_to_thor_class("foo:bar:baz") #=> Foo::Bar, "baz"
|
|
127
|
-
#
|
|
128
|
-
# ==== Parameters
|
|
129
|
-
# namespace<String>
|
|
130
|
-
#
|
|
131
|
-
def self.find_class_and_task_by_namespace(namespace, fallback = true)
|
|
132
|
-
if namespace.include?(?:) # look for a namespaced task
|
|
133
|
-
pieces = namespace.split(":")
|
|
134
|
-
task = pieces.pop
|
|
135
|
-
klass = Thor::Util.find_by_namespace(pieces.join(":"))
|
|
72
|
+
# Returns the thor classes declared inside the given class.
|
|
73
|
+
#
|
|
74
|
+
def thor_classes_in(klass)
|
|
75
|
+
stringfied_constants = klass.constants.map(&:to_s)
|
|
76
|
+
Thor::Base.subclasses.select do |subclass|
|
|
77
|
+
next unless subclass.name
|
|
78
|
+
stringfied_constants.include?(subclass.name.gsub("#{klass.name}::", ""))
|
|
79
|
+
end
|
|
136
80
|
end
|
|
137
|
-
|
|
138
|
-
|
|
81
|
+
|
|
82
|
+
# Receives a string and convert it to snake case. SnakeCase returns snake_case.
|
|
83
|
+
#
|
|
84
|
+
# ==== Parameters
|
|
85
|
+
# String
|
|
86
|
+
#
|
|
87
|
+
# ==== Returns
|
|
88
|
+
# String
|
|
89
|
+
#
|
|
90
|
+
def snake_case(str)
|
|
91
|
+
return str.downcase if str =~ /^[A-Z_]+$/
|
|
92
|
+
str.gsub(/\B[A-Z]/, '_\&').squeeze("_") =~ /_*(.*)/
|
|
93
|
+
$+.downcase
|
|
139
94
|
end
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
95
|
+
|
|
96
|
+
# Receives a string and convert it to camel case. camel_case returns CamelCase.
|
|
97
|
+
#
|
|
98
|
+
# ==== Parameters
|
|
99
|
+
# String
|
|
100
|
+
#
|
|
101
|
+
# ==== Returns
|
|
102
|
+
# String
|
|
103
|
+
#
|
|
104
|
+
def camel_case(str)
|
|
105
|
+
return str if str !~ /_/ && str =~ /[A-Z]+.*/
|
|
106
|
+
str.split("_").map(&:capitalize).join
|
|
143
107
|
end
|
|
144
|
-
return klass, task
|
|
145
|
-
end
|
|
146
108
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
109
|
+
# Receives a namespace and tries to retrieve a Thor or Thor::Group class
|
|
110
|
+
# from it. It first searches for a class using the all the given namespace,
|
|
111
|
+
# if it's not found, removes the highest entry and searches for the class
|
|
112
|
+
# again. If found, returns the highest entry as the class name.
|
|
113
|
+
#
|
|
114
|
+
# ==== Examples
|
|
115
|
+
#
|
|
116
|
+
# class Foo::Bar < Thor
|
|
117
|
+
# def baz
|
|
118
|
+
# end
|
|
119
|
+
# end
|
|
120
|
+
#
|
|
121
|
+
# class Baz::Foo < Thor::Group
|
|
122
|
+
# end
|
|
123
|
+
#
|
|
124
|
+
# Thor::Util.namespace_to_thor_class("foo:bar") #=> Foo::Bar, nil # will invoke default command
|
|
125
|
+
# Thor::Util.namespace_to_thor_class("baz:foo") #=> Baz::Foo, nil
|
|
126
|
+
# Thor::Util.namespace_to_thor_class("foo:bar:baz") #=> Foo::Bar, "baz"
|
|
127
|
+
#
|
|
128
|
+
# ==== Parameters
|
|
129
|
+
# namespace<String>
|
|
130
|
+
#
|
|
131
|
+
def find_class_and_command_by_namespace(namespace, fallback = true)
|
|
132
|
+
if namespace.include?(":") # look for a namespaced command
|
|
133
|
+
pieces = namespace.split(":")
|
|
134
|
+
command = pieces.pop
|
|
135
|
+
klass = Thor::Util.find_by_namespace(pieces.join(":"))
|
|
161
136
|
end
|
|
137
|
+
unless klass # look for a Thor::Group with the right name
|
|
138
|
+
klass = Thor::Util.find_by_namespace(namespace)
|
|
139
|
+
command = nil
|
|
140
|
+
end
|
|
141
|
+
if !klass && fallback # try a command in the default namespace
|
|
142
|
+
command = namespace
|
|
143
|
+
klass = Thor::Util.find_by_namespace("")
|
|
144
|
+
end
|
|
145
|
+
[klass, command]
|
|
162
146
|
end
|
|
163
|
-
|
|
147
|
+
alias_method :find_class_and_task_by_namespace, :find_class_and_command_by_namespace
|
|
148
|
+
|
|
149
|
+
# Receives a path and load the thor file in the path. The file is evaluated
|
|
150
|
+
# inside the sandbox to avoid namespacing conflicts.
|
|
151
|
+
#
|
|
152
|
+
def load_thorfile(path, content = nil, debug = false)
|
|
153
|
+
content ||= File.binread(path)
|
|
164
154
|
|
|
165
|
-
def self.user_home
|
|
166
|
-
@@user_home ||= if ENV["HOME"]
|
|
167
|
-
ENV["HOME"]
|
|
168
|
-
elsif ENV["USERPROFILE"]
|
|
169
|
-
ENV["USERPROFILE"]
|
|
170
|
-
elsif ENV["HOMEDRIVE"] && ENV["HOMEPATH"]
|
|
171
|
-
File.join(ENV["HOMEDRIVE"], ENV["HOMEPATH"])
|
|
172
|
-
elsif ENV["APPDATA"]
|
|
173
|
-
ENV["APPDATA"]
|
|
174
|
-
else
|
|
175
155
|
begin
|
|
176
|
-
|
|
177
|
-
rescue
|
|
178
|
-
|
|
179
|
-
|
|
156
|
+
Thor::Sandbox.class_eval(content, path)
|
|
157
|
+
rescue StandardError => e
|
|
158
|
+
$stderr.puts("WARNING: unable to load thorfile #{path.inspect}: #{e.message}")
|
|
159
|
+
if debug
|
|
160
|
+
$stderr.puts(*e.backtrace)
|
|
180
161
|
else
|
|
181
|
-
|
|
162
|
+
$stderr.puts(e.backtrace.first)
|
|
182
163
|
end
|
|
183
164
|
end
|
|
184
165
|
end
|
|
185
|
-
end
|
|
186
166
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
167
|
+
def user_home
|
|
168
|
+
@@user_home ||= if ENV["HOME"]
|
|
169
|
+
ENV["HOME"]
|
|
170
|
+
elsif ENV["USERPROFILE"]
|
|
171
|
+
ENV["USERPROFILE"]
|
|
172
|
+
elsif ENV["HOMEDRIVE"] && ENV["HOMEPATH"]
|
|
173
|
+
File.join(ENV["HOMEDRIVE"], ENV["HOMEPATH"])
|
|
174
|
+
elsif ENV["APPDATA"]
|
|
175
|
+
ENV["APPDATA"]
|
|
176
|
+
else
|
|
177
|
+
begin
|
|
178
|
+
File.expand_path("~")
|
|
179
|
+
rescue
|
|
180
|
+
if File::ALT_SEPARATOR
|
|
181
|
+
"C:/"
|
|
182
|
+
else
|
|
183
|
+
"/"
|
|
184
|
+
end
|
|
185
|
+
end
|
|
186
|
+
end
|
|
187
|
+
end
|
|
192
188
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
#
|
|
198
|
-
# If we don't #gsub the \ character, Dir.glob will fail.
|
|
199
|
-
#
|
|
200
|
-
def self.thor_root_glob
|
|
201
|
-
files = Dir["#{thor_root}/*"]
|
|
202
|
-
|
|
203
|
-
files.map! do |file|
|
|
204
|
-
File.directory?(file) ? File.join(file, "main.thor") : file
|
|
189
|
+
# Returns the root where thor files are located, depending on the OS.
|
|
190
|
+
#
|
|
191
|
+
def thor_root
|
|
192
|
+
File.join(user_home, ".thor").tr('\\', "/")
|
|
205
193
|
end
|
|
206
|
-
end
|
|
207
194
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
195
|
+
# Returns the files in the thor root. On Windows thor_root will be something
|
|
196
|
+
# like this:
|
|
197
|
+
#
|
|
198
|
+
# C:\Documents and Settings\james\.thor
|
|
199
|
+
#
|
|
200
|
+
# If we don't #gsub the \ character, Dir.glob will fail.
|
|
201
|
+
#
|
|
202
|
+
def thor_root_glob
|
|
203
|
+
files = Dir["#{escape_globs(thor_root)}/*"]
|
|
213
204
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
ruby
|
|
205
|
+
files.map! do |file|
|
|
206
|
+
File.directory?(file) ? File.join(file, "main.thor") : file
|
|
207
|
+
end
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
# Where to look for Thor files.
|
|
211
|
+
#
|
|
212
|
+
def globs_for(path)
|
|
213
|
+
path = escape_globs(path)
|
|
214
|
+
["#{path}/Thorfile", "#{path}/*.thor", "#{path}/tasks/*.thor", "#{path}/lib/tasks/*.thor"]
|
|
225
215
|
end
|
|
226
|
-
end
|
|
227
216
|
|
|
217
|
+
# Return the path to the ruby interpreter taking into account multiple
|
|
218
|
+
# installations and windows extensions.
|
|
219
|
+
#
|
|
220
|
+
def ruby_command
|
|
221
|
+
@ruby_command ||= begin
|
|
222
|
+
ruby_name = RbConfig::CONFIG["ruby_install_name"]
|
|
223
|
+
ruby = File.join(RbConfig::CONFIG["bindir"], ruby_name)
|
|
224
|
+
ruby << RbConfig::CONFIG["EXEEXT"]
|
|
225
|
+
|
|
226
|
+
# avoid using different name than ruby (on platforms supporting links)
|
|
227
|
+
if ruby_name != "ruby" && File.respond_to?(:readlink)
|
|
228
|
+
begin
|
|
229
|
+
alternate_ruby = File.join(RbConfig::CONFIG["bindir"], "ruby")
|
|
230
|
+
alternate_ruby << RbConfig::CONFIG["EXEEXT"]
|
|
231
|
+
|
|
232
|
+
# ruby is a symlink
|
|
233
|
+
if File.symlink? alternate_ruby
|
|
234
|
+
linked_ruby = File.readlink alternate_ruby
|
|
235
|
+
|
|
236
|
+
# symlink points to 'ruby_install_name'
|
|
237
|
+
ruby = alternate_ruby if linked_ruby == ruby_name || linked_ruby == ruby
|
|
238
|
+
end
|
|
239
|
+
rescue NotImplementedError # rubocop:disable HandleExceptions
|
|
240
|
+
# just ignore on windows
|
|
241
|
+
end
|
|
242
|
+
end
|
|
243
|
+
|
|
244
|
+
# escape string in case path to ruby executable contain spaces.
|
|
245
|
+
ruby.sub!(/.*\s.*/m, '"\&"')
|
|
246
|
+
ruby
|
|
247
|
+
end
|
|
248
|
+
end
|
|
249
|
+
|
|
250
|
+
# Returns a string that has had any glob characters escaped.
|
|
251
|
+
# The glob characters are `* ? { } [ ]`.
|
|
252
|
+
#
|
|
253
|
+
# ==== Examples
|
|
254
|
+
#
|
|
255
|
+
# Thor::Util.escape_globs('[apps]') # => '\[apps\]'
|
|
256
|
+
#
|
|
257
|
+
# ==== Parameters
|
|
258
|
+
# String
|
|
259
|
+
#
|
|
260
|
+
# ==== Returns
|
|
261
|
+
# String
|
|
262
|
+
#
|
|
263
|
+
def escape_globs(path)
|
|
264
|
+
path.to_s.gsub(/[*?{}\[\]]/, '\\\\\\&')
|
|
265
|
+
end
|
|
266
|
+
end
|
|
228
267
|
end
|
|
229
268
|
end
|
data/lib/thor/version.rb
CHANGED