acquia_toolbelt 2.3.0 → 2.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +7 -0
- data/.ruby-version +1 -0
- data/.travis.yml +7 -0
- data/CONTRIBUTING.md +11 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +55 -0
- data/Guardfile +5 -0
- data/LICENSE +19 -0
- data/README.md +149 -0
- data/Rakefile +1 -0
- data/acquia_toolbelt.gemspec +34 -0
- data/bin/acquia +9 -0
- data/lib/acquia_toolbelt/cli/api.rb +164 -0
- data/lib/acquia_toolbelt/cli/auth.rb +31 -0
- data/lib/acquia_toolbelt/cli/database.rb +237 -0
- data/lib/acquia_toolbelt/cli/deploy.rb +36 -0
- data/lib/acquia_toolbelt/cli/domain.rb +177 -0
- data/lib/acquia_toolbelt/cli/environment.rb +71 -0
- data/lib/acquia_toolbelt/cli/file.rb +31 -0
- data/lib/acquia_toolbelt/cli/server.rb +67 -0
- data/lib/acquia_toolbelt/cli/site.rb +28 -0
- data/lib/acquia_toolbelt/cli/ssh.rb +78 -0
- data/lib/acquia_toolbelt/cli/svn.rb +73 -0
- data/lib/acquia_toolbelt/cli/task.rb +74 -0
- data/lib/acquia_toolbelt/cli/ui.rb +44 -0
- data/lib/acquia_toolbelt/cli.rb +103 -0
- data/lib/acquia_toolbelt/error.rb +4 -0
- data/lib/acquia_toolbelt/thor.rb +95 -0
- data/lib/acquia_toolbelt/version.rb +3 -0
- data/lib/acquia_toolbelt.rb +4 -0
- data/lib/vendor/thor/CHANGELOG.md +139 -0
- data/lib/vendor/thor/Gemfile +20 -0
- data/lib/vendor/thor/LICENSE.md +20 -0
- data/lib/vendor/thor/README.md +35 -0
- data/lib/vendor/thor/lib/thor/actions/create_file.rb +105 -0
- data/lib/vendor/thor/lib/thor/actions/create_link.rb +60 -0
- data/lib/vendor/thor/lib/thor/actions/directory.rb +119 -0
- data/lib/vendor/thor/lib/thor/actions/empty_directory.rb +137 -0
- data/lib/vendor/thor/lib/thor/actions/file_manipulation.rb +317 -0
- data/lib/vendor/thor/lib/thor/actions/inject_into_file.rb +109 -0
- data/lib/vendor/thor/lib/thor/actions.rb +318 -0
- data/lib/vendor/thor/lib/thor/base.rb +654 -0
- data/lib/vendor/thor/lib/thor/command.rb +136 -0
- data/lib/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +80 -0
- data/lib/vendor/thor/lib/thor/core_ext/io_binary_read.rb +12 -0
- data/lib/vendor/thor/lib/thor/core_ext/ordered_hash.rb +100 -0
- data/lib/vendor/thor/lib/thor/error.rb +32 -0
- data/lib/vendor/thor/lib/thor/group.rb +282 -0
- data/lib/vendor/thor/lib/thor/invocation.rb +172 -0
- data/lib/vendor/thor/lib/thor/parser/argument.rb +74 -0
- data/lib/vendor/thor/lib/thor/parser/arguments.rb +171 -0
- data/lib/vendor/thor/lib/thor/parser/option.rb +121 -0
- data/lib/vendor/thor/lib/thor/parser/options.rb +218 -0
- data/lib/vendor/thor/lib/thor/parser.rb +4 -0
- data/lib/vendor/thor/lib/thor/rake_compat.rb +72 -0
- data/lib/vendor/thor/lib/thor/runner.rb +322 -0
- data/lib/vendor/thor/lib/thor/shell/basic.rb +422 -0
- data/lib/vendor/thor/lib/thor/shell/color.rb +148 -0
- data/lib/vendor/thor/lib/thor/shell/html.rb +127 -0
- data/lib/vendor/thor/lib/thor/shell.rb +88 -0
- data/lib/vendor/thor/lib/thor/util.rb +270 -0
- data/lib/vendor/thor/lib/thor/version.rb +3 -0
- data/lib/vendor/thor/lib/thor.rb +474 -0
- data/lib/vendor/thor/spec/actions/create_file_spec.rb +170 -0
- data/lib/vendor/thor/spec/actions/create_link_spec.rb +95 -0
- data/lib/vendor/thor/spec/actions/directory_spec.rb +169 -0
- data/lib/vendor/thor/spec/actions/empty_directory_spec.rb +129 -0
- data/lib/vendor/thor/spec/actions/file_manipulation_spec.rb +382 -0
- data/lib/vendor/thor/spec/actions/inject_into_file_spec.rb +135 -0
- data/lib/vendor/thor/spec/actions_spec.rb +331 -0
- data/lib/vendor/thor/spec/base_spec.rb +291 -0
- data/lib/vendor/thor/spec/command_spec.rb +80 -0
- data/lib/vendor/thor/spec/core_ext/hash_with_indifferent_access_spec.rb +48 -0
- data/lib/vendor/thor/spec/core_ext/ordered_hash_spec.rb +115 -0
- data/lib/vendor/thor/spec/exit_condition_spec.rb +19 -0
- data/lib/vendor/thor/spec/fixtures/application.rb +2 -0
- data/lib/vendor/thor/spec/fixtures/app{1}/README +3 -0
- data/lib/vendor/thor/spec/fixtures/bundle/execute.rb +6 -0
- data/lib/vendor/thor/spec/fixtures/bundle/main.thor +1 -0
- data/lib/vendor/thor/spec/fixtures/command.thor +10 -0
- data/lib/vendor/thor/spec/fixtures/doc/%file_name%.rb.tt +1 -0
- data/lib/vendor/thor/spec/fixtures/doc/COMMENTER +11 -0
- data/lib/vendor/thor/spec/fixtures/doc/README +3 -0
- data/lib/vendor/thor/spec/fixtures/doc/block_helper.rb +3 -0
- data/lib/vendor/thor/spec/fixtures/doc/components/.empty_directory +0 -0
- data/lib/vendor/thor/spec/fixtures/doc/config.rb +1 -0
- data/lib/vendor/thor/spec/fixtures/doc/config.yaml.tt +1 -0
- data/lib/vendor/thor/spec/fixtures/doc/excluding/%file_name%.rb.tt +1 -0
- data/lib/vendor/thor/spec/fixtures/enum.thor +10 -0
- data/lib/vendor/thor/spec/fixtures/group.thor +128 -0
- data/lib/vendor/thor/spec/fixtures/invoke.thor +118 -0
- data/lib/vendor/thor/spec/fixtures/path with spaces +0 -0
- data/lib/vendor/thor/spec/fixtures/preserve/script.sh +3 -0
- data/lib/vendor/thor/spec/fixtures/script.thor +220 -0
- data/lib/vendor/thor/spec/fixtures/subcommand.thor +17 -0
- data/lib/vendor/thor/spec/group_spec.rb +222 -0
- data/lib/vendor/thor/spec/helper.rb +67 -0
- data/lib/vendor/thor/spec/invocation_spec.rb +108 -0
- data/lib/vendor/thor/spec/parser/argument_spec.rb +53 -0
- data/lib/vendor/thor/spec/parser/arguments_spec.rb +66 -0
- data/lib/vendor/thor/spec/parser/option_spec.rb +202 -0
- data/lib/vendor/thor/spec/parser/options_spec.rb +400 -0
- data/lib/vendor/thor/spec/rake_compat_spec.rb +72 -0
- data/lib/vendor/thor/spec/register_spec.rb +197 -0
- data/lib/vendor/thor/spec/runner_spec.rb +241 -0
- data/lib/vendor/thor/spec/shell/basic_spec.rb +330 -0
- data/lib/vendor/thor/spec/shell/color_spec.rb +95 -0
- data/lib/vendor/thor/spec/shell/html_spec.rb +31 -0
- data/lib/vendor/thor/spec/shell_spec.rb +47 -0
- data/lib/vendor/thor/spec/subcommand_spec.rb +30 -0
- data/lib/vendor/thor/spec/thor_spec.rb +499 -0
- data/lib/vendor/thor/spec/util_spec.rb +196 -0
- data/lib/vendor/thor/thor.gemspec +24 -0
- data/script/release +50 -0
- data/script/setup_build +6 -0
- data/script/test +23 -0
- data/spec/auth_spec.rb +15 -0
- data/spec/cassettes/databases/all_databases.json +1 -0
- data/spec/cassettes/databases/copy_database_from_dev_to_stage.json +1 -0
- data/spec/cassettes/databases/create_a_database_backup.json +1 -0
- data/spec/cassettes/databases/create_a_new_database.json +1 -0
- data/spec/cassettes/databases/delete_a_database.json +1 -0
- data/spec/cassettes/databases/get_all_existing_databases.json +1 -0
- data/spec/cassettes/databases/list_all_database_backups.json +1 -0
- data/spec/cassettes/databases/view_database_instance_details.json +1 -0
- data/spec/cassettes/deploy/release_vcs_branch.json +1 -0
- data/spec/cassettes/domains/create_new_domain.json +1 -0
- data/spec/cassettes/domains/delete_a_domain.json +1 -0
- data/spec/cassettes/domains/get_all_existing_domains.json +1 -0
- data/spec/cassettes/domains/list_all_dev_domains.json +1 -0
- data/spec/cassettes/domains/move_from_dev_to_stage.json +1 -0
- data/spec/cassettes/domains/purge_varnish_cache.json +1 -0
- data/spec/cassettes/environments/all_environments.json +1 -0
- data/spec/cassettes/environments/disable_live_development.json +1 -0
- data/spec/cassettes/environments/enable_live_development.json +1 -0
- data/spec/cassettes/files/copy_from_dev_to_stage.json +1 -0
- data/spec/cassettes/servers/all_dev_servers.json +1 -0
- data/spec/cassettes/servers/all_prod_servers.json +1 -0
- data/spec/cassettes/sites/all_sites.json +1 -0
- data/spec/cassettes/ssh/all_sshkeys.json +1 -0
- data/spec/cassettes/svn/all_svnusers.json +1 -0
- data/spec/cassettes/tasks/all_tasks.json +1 -0
- data/spec/databases_spec.rb +78 -0
- data/spec/deploy_spec.rb +12 -0
- data/spec/domains_spec.rb +59 -0
- data/spec/environments_spec.rb +35 -0
- data/spec/files_spec.rb +11 -0
- data/spec/helper.rb +104 -0
- data/spec/servers_spec.rb +59 -0
- data/spec/sites_spec.rb +19 -0
- data/spec/ssh_spec.rb +19 -0
- data/spec/svn_spec.rb +11 -0
- data/spec/tasks_spec.rb +11 -0
- metadata +158 -4
@@ -0,0 +1,88 @@
|
|
1
|
+
require 'rbconfig'
|
2
|
+
|
3
|
+
class Thor
|
4
|
+
module Base
|
5
|
+
# Returns the shell used in all Thor classes. If you are in a Unix platform
|
6
|
+
# it will use a colored log, otherwise it will use a basic one without color.
|
7
|
+
#
|
8
|
+
def self.shell
|
9
|
+
@shell ||= if ENV['THOR_SHELL'] && ENV['THOR_SHELL'].size > 0
|
10
|
+
Thor::Shell.const_get(ENV['THOR_SHELL'])
|
11
|
+
elsif ((RbConfig::CONFIG['host_os'] =~ /mswin|mingw/) && !(ENV['ANSICON']))
|
12
|
+
Thor::Shell::Basic
|
13
|
+
else
|
14
|
+
Thor::Shell::Color
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
# Sets the shell used in all Thor classes.
|
19
|
+
#
|
20
|
+
def self.shell=(klass)
|
21
|
+
@shell = klass
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
module Shell
|
26
|
+
SHELL_DELEGATED_METHODS = [:ask, :error, :set_color, :yes?, :no?, :say, :say_status, :print_in_columns, :print_table, :print_wrapped, :file_collision, :terminal_width]
|
27
|
+
|
28
|
+
autoload :Basic, 'thor/shell/basic'
|
29
|
+
autoload :Color, 'thor/shell/color'
|
30
|
+
autoload :HTML, 'thor/shell/html'
|
31
|
+
|
32
|
+
# Add shell to initialize config values.
|
33
|
+
#
|
34
|
+
# ==== Configuration
|
35
|
+
# shell<Object>:: An instance of the shell to be used.
|
36
|
+
#
|
37
|
+
# ==== Examples
|
38
|
+
#
|
39
|
+
# class MyScript < Thor
|
40
|
+
# argument :first, :type => :numeric
|
41
|
+
# end
|
42
|
+
#
|
43
|
+
# MyScript.new [1.0], { :foo => :bar }, :shell => Thor::Shell::Basic.new
|
44
|
+
#
|
45
|
+
def initialize(args=[], options={}, config={})
|
46
|
+
super
|
47
|
+
self.shell = config[:shell]
|
48
|
+
self.shell.base ||= self if self.shell.respond_to?(:base)
|
49
|
+
end
|
50
|
+
|
51
|
+
# Holds the shell for the given Thor instance. If no shell is given,
|
52
|
+
# it gets a default shell from Thor::Base.shell.
|
53
|
+
def shell
|
54
|
+
@shell ||= Thor::Base.shell.new
|
55
|
+
end
|
56
|
+
|
57
|
+
# Sets the shell for this thor class.
|
58
|
+
def shell=(shell)
|
59
|
+
@shell = shell
|
60
|
+
end
|
61
|
+
|
62
|
+
# Common methods that are delegated to the shell.
|
63
|
+
SHELL_DELEGATED_METHODS.each do |method|
|
64
|
+
module_eval <<-METHOD, __FILE__, __LINE__
|
65
|
+
def #{method}(*args,&block)
|
66
|
+
shell.#{method}(*args,&block)
|
67
|
+
end
|
68
|
+
METHOD
|
69
|
+
end
|
70
|
+
|
71
|
+
# Yields the given block with padding.
|
72
|
+
def with_padding
|
73
|
+
shell.padding += 1
|
74
|
+
yield
|
75
|
+
ensure
|
76
|
+
shell.padding -= 1
|
77
|
+
end
|
78
|
+
|
79
|
+
protected
|
80
|
+
|
81
|
+
# Allow shell to be shared between invocations.
|
82
|
+
#
|
83
|
+
def _shared_configuration #:nodoc:
|
84
|
+
super.merge!(:shell => self.shell)
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,270 @@
|
|
1
|
+
require 'rbconfig'
|
2
|
+
|
3
|
+
class Thor
|
4
|
+
module Sandbox #:nodoc:
|
5
|
+
end
|
6
|
+
|
7
|
+
# This module holds several utilities:
|
8
|
+
#
|
9
|
+
# 1) Methods to convert thor namespaces to constants and vice-versa.
|
10
|
+
#
|
11
|
+
# Thor::Util.namespace_from_thor_class(Foo::Bar::Baz) #=> "foo:bar:baz"
|
12
|
+
#
|
13
|
+
# 2) Loading thor files and sandboxing:
|
14
|
+
#
|
15
|
+
# Thor::Util.load_thorfile("~/.thor/foo")
|
16
|
+
#
|
17
|
+
module Util
|
18
|
+
|
19
|
+
class << self
|
20
|
+
|
21
|
+
# Receives a namespace and search for it in the Thor::Base subclasses.
|
22
|
+
#
|
23
|
+
# ==== Parameters
|
24
|
+
# namespace<String>:: The namespace to search for.
|
25
|
+
#
|
26
|
+
def find_by_namespace(namespace)
|
27
|
+
namespace = "default#{namespace}" if namespace.empty? || namespace =~ /^:/
|
28
|
+
Thor::Base.subclasses.find { |klass| klass.namespace == namespace }
|
29
|
+
end
|
30
|
+
|
31
|
+
# Receives a constant and converts it to a Thor namespace. Since Thor
|
32
|
+
# commands can be added to a sandbox, this method is also responsable for
|
33
|
+
# removing the sandbox namespace.
|
34
|
+
#
|
35
|
+
# This method should not be used in general because it's used to deal with
|
36
|
+
# older versions of Thor. On current versions, if you need to get the
|
37
|
+
# namespace from a class, just call namespace on it.
|
38
|
+
#
|
39
|
+
# ==== Parameters
|
40
|
+
# constant<Object>:: The constant to be converted to the thor path.
|
41
|
+
#
|
42
|
+
# ==== Returns
|
43
|
+
# String:: If we receive Foo::Bar::Baz it returns "foo:bar:baz"
|
44
|
+
#
|
45
|
+
def namespace_from_thor_class(constant)
|
46
|
+
constant = constant.to_s.gsub(/^Thor::Sandbox::/, "")
|
47
|
+
constant = snake_case(constant).squeeze(":")
|
48
|
+
constant
|
49
|
+
end
|
50
|
+
|
51
|
+
# Given the contents, evaluate it inside the sandbox and returns the
|
52
|
+
# namespaces defined in the sandbox.
|
53
|
+
#
|
54
|
+
# ==== Parameters
|
55
|
+
# contents<String>
|
56
|
+
#
|
57
|
+
# ==== Returns
|
58
|
+
# Array[Object]
|
59
|
+
#
|
60
|
+
def namespaces_in_content(contents, file=__FILE__)
|
61
|
+
old_constants = Thor::Base.subclasses.dup
|
62
|
+
Thor::Base.subclasses.clear
|
63
|
+
|
64
|
+
load_thorfile(file, contents)
|
65
|
+
|
66
|
+
new_constants = Thor::Base.subclasses.dup
|
67
|
+
Thor::Base.subclasses.replace(old_constants)
|
68
|
+
|
69
|
+
new_constants.map!{ |c| c.namespace }
|
70
|
+
new_constants.compact!
|
71
|
+
new_constants
|
72
|
+
end
|
73
|
+
|
74
|
+
# Returns the thor classes declared inside the given class.
|
75
|
+
#
|
76
|
+
def thor_classes_in(klass)
|
77
|
+
stringfied_constants = klass.constants.map { |c| c.to_s }
|
78
|
+
Thor::Base.subclasses.select do |subclass|
|
79
|
+
next unless subclass.name
|
80
|
+
stringfied_constants.include?(subclass.name.gsub("#{klass.name}::", ''))
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
# Receives a string and convert it to snake case. SnakeCase returns snake_case.
|
85
|
+
#
|
86
|
+
# ==== Parameters
|
87
|
+
# String
|
88
|
+
#
|
89
|
+
# ==== Returns
|
90
|
+
# String
|
91
|
+
#
|
92
|
+
def snake_case(str)
|
93
|
+
return str.downcase if str =~ /^[A-Z_]+$/
|
94
|
+
str.gsub(/\B[A-Z]/, '_\&').squeeze('_') =~ /_*(.*)/
|
95
|
+
return $+.downcase
|
96
|
+
end
|
97
|
+
|
98
|
+
# Receives a string and convert it to camel case. camel_case returns CamelCase.
|
99
|
+
#
|
100
|
+
# ==== Parameters
|
101
|
+
# String
|
102
|
+
#
|
103
|
+
# ==== Returns
|
104
|
+
# String
|
105
|
+
#
|
106
|
+
def camel_case(str)
|
107
|
+
return str if str !~ /_/ && str =~ /[A-Z]+.*/
|
108
|
+
str.split('_').map { |i| i.capitalize }.join
|
109
|
+
end
|
110
|
+
|
111
|
+
# Receives a namespace and tries to retrieve a Thor or Thor::Group class
|
112
|
+
# from it. It first searches for a class using the all the given namespace,
|
113
|
+
# if it's not found, removes the highest entry and searches for the class
|
114
|
+
# again. If found, returns the highest entry as the class name.
|
115
|
+
#
|
116
|
+
# ==== Examples
|
117
|
+
#
|
118
|
+
# class Foo::Bar < Thor
|
119
|
+
# def baz
|
120
|
+
# end
|
121
|
+
# end
|
122
|
+
#
|
123
|
+
# class Baz::Foo < Thor::Group
|
124
|
+
# end
|
125
|
+
#
|
126
|
+
# Thor::Util.namespace_to_thor_class("foo:bar") #=> Foo::Bar, nil # will invoke default command
|
127
|
+
# Thor::Util.namespace_to_thor_class("baz:foo") #=> Baz::Foo, nil
|
128
|
+
# Thor::Util.namespace_to_thor_class("foo:bar:baz") #=> Foo::Bar, "baz"
|
129
|
+
#
|
130
|
+
# ==== Parameters
|
131
|
+
# namespace<String>
|
132
|
+
#
|
133
|
+
def find_class_and_command_by_namespace(namespace, fallback = true)
|
134
|
+
if namespace.include?(?:) # look for a namespaced command
|
135
|
+
pieces = namespace.split(":")
|
136
|
+
command = pieces.pop
|
137
|
+
klass = Thor::Util.find_by_namespace(pieces.join(":"))
|
138
|
+
end
|
139
|
+
unless klass # look for a Thor::Group with the right name
|
140
|
+
klass, command = Thor::Util.find_by_namespace(namespace), nil
|
141
|
+
end
|
142
|
+
if !klass && fallback # try a command in the default namespace
|
143
|
+
command = namespace
|
144
|
+
klass = Thor::Util.find_by_namespace('')
|
145
|
+
end
|
146
|
+
return klass, command
|
147
|
+
end
|
148
|
+
alias find_class_and_task_by_namespace find_class_and_command_by_namespace
|
149
|
+
|
150
|
+
# Receives a path and load the thor file in the path. The file is evaluated
|
151
|
+
# inside the sandbox to avoid namespacing conflicts.
|
152
|
+
#
|
153
|
+
def load_thorfile(path, content=nil, debug=false)
|
154
|
+
content ||= File.binread(path)
|
155
|
+
|
156
|
+
begin
|
157
|
+
Thor::Sandbox.class_eval(content, path)
|
158
|
+
rescue Exception => e
|
159
|
+
$stderr.puts("WARNING: unable to load thorfile #{path.inspect}: #{e.message}")
|
160
|
+
if debug
|
161
|
+
$stderr.puts(*e.backtrace)
|
162
|
+
else
|
163
|
+
$stderr.puts(e.backtrace.first)
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
def user_home
|
169
|
+
@@user_home ||= if ENV["HOME"]
|
170
|
+
ENV["HOME"]
|
171
|
+
elsif ENV["USERPROFILE"]
|
172
|
+
ENV["USERPROFILE"]
|
173
|
+
elsif ENV["HOMEDRIVE"] && ENV["HOMEPATH"]
|
174
|
+
File.join(ENV["HOMEDRIVE"], ENV["HOMEPATH"])
|
175
|
+
elsif ENV["APPDATA"]
|
176
|
+
ENV["APPDATA"]
|
177
|
+
else
|
178
|
+
begin
|
179
|
+
File.expand_path("~")
|
180
|
+
rescue
|
181
|
+
if File::ALT_SEPARATOR
|
182
|
+
"C:/"
|
183
|
+
else
|
184
|
+
"/"
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
# Returns the root where thor files are located, depending on the OS.
|
191
|
+
#
|
192
|
+
def thor_root
|
193
|
+
File.join(user_home, ".thor").gsub(/\\/, '/')
|
194
|
+
end
|
195
|
+
|
196
|
+
# Returns the files in the thor root. On Windows thor_root will be something
|
197
|
+
# like this:
|
198
|
+
#
|
199
|
+
# C:\Documents and Settings\james\.thor
|
200
|
+
#
|
201
|
+
# If we don't #gsub the \ character, Dir.glob will fail.
|
202
|
+
#
|
203
|
+
def thor_root_glob
|
204
|
+
files = Dir["#{escape_globs(thor_root)}/*"]
|
205
|
+
|
206
|
+
files.map! do |file|
|
207
|
+
File.directory?(file) ? File.join(file, "main.thor") : file
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
# Where to look for Thor files.
|
212
|
+
#
|
213
|
+
def globs_for(path)
|
214
|
+
path = escape_globs(path)
|
215
|
+
["#{path}/Thorfile", "#{path}/*.thor", "#{path}/tasks/*.thor", "#{path}/lib/tasks/*.thor"]
|
216
|
+
end
|
217
|
+
|
218
|
+
# Return the path to the ruby interpreter taking into account multiple
|
219
|
+
# installations and windows extensions.
|
220
|
+
#
|
221
|
+
def ruby_command
|
222
|
+
@ruby_command ||= begin
|
223
|
+
ruby_name = RbConfig::CONFIG['ruby_install_name']
|
224
|
+
ruby = File.join(RbConfig::CONFIG['bindir'], ruby_name)
|
225
|
+
ruby << RbConfig::CONFIG['EXEEXT']
|
226
|
+
|
227
|
+
# avoid using different name than ruby (on platforms supporting links)
|
228
|
+
if ruby_name != 'ruby' && File.respond_to?(:readlink)
|
229
|
+
begin
|
230
|
+
alternate_ruby = File.join(RbConfig::CONFIG['bindir'], 'ruby')
|
231
|
+
alternate_ruby << RbConfig::CONFIG['EXEEXT']
|
232
|
+
|
233
|
+
# ruby is a symlink
|
234
|
+
if File.symlink? alternate_ruby
|
235
|
+
linked_ruby = File.readlink alternate_ruby
|
236
|
+
|
237
|
+
# symlink points to 'ruby_install_name'
|
238
|
+
ruby = alternate_ruby if linked_ruby == ruby_name || linked_ruby == ruby
|
239
|
+
end
|
240
|
+
rescue NotImplementedError
|
241
|
+
# just ignore on windows
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
245
|
+
# escape string in case path to ruby executable contain spaces.
|
246
|
+
ruby.sub!(/.*\s.*/m, '"\&"')
|
247
|
+
ruby
|
248
|
+
end
|
249
|
+
end
|
250
|
+
|
251
|
+
# Returns a string that has had any glob characters escaped.
|
252
|
+
# The glob characters are `* ? { } [ ]`.
|
253
|
+
#
|
254
|
+
# ==== Examples
|
255
|
+
#
|
256
|
+
# Thor::Util.escape_globs('[apps]') # => '\[apps\]'
|
257
|
+
#
|
258
|
+
# ==== Parameters
|
259
|
+
# String
|
260
|
+
#
|
261
|
+
# ==== Returns
|
262
|
+
# String
|
263
|
+
#
|
264
|
+
def escape_globs(path)
|
265
|
+
path.to_s.gsub(/[*?{}\[\]]/, '\\\\\\&')
|
266
|
+
end
|
267
|
+
|
268
|
+
end
|
269
|
+
end
|
270
|
+
end
|