overman 0.0.1 → 0.87.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +52 -0
- data/bin/foreman-runner +41 -0
- data/bin/overman +7 -0
- data/data/example/Procfile +4 -0
- data/data/example/Procfile.without_colon +2 -0
- data/data/example/error +7 -0
- data/data/example/log/neverdie.log +4 -0
- data/data/example/spawnee +14 -0
- data/data/example/spawner +7 -0
- data/data/example/ticker +14 -0
- data/data/example/utf8 +11 -0
- data/data/export/bluepill/master.pill.erb +28 -0
- data/data/export/daemon/master.conf.erb +14 -0
- data/data/export/daemon/process.conf.erb +8 -0
- data/data/export/daemon/process_master.conf.erb +2 -0
- data/data/export/launchd/launchd.plist.erb +33 -0
- data/data/export/runit/log/run.erb +7 -0
- data/data/export/runit/run.erb +4 -0
- data/data/export/supervisord/app.conf.erb +31 -0
- data/data/export/systemd/master.target.erb +5 -0
- data/data/export/systemd/process.service.erb +21 -0
- data/data/export/upstart/master.conf.erb +2 -0
- data/data/export/upstart/process.conf.erb +15 -0
- data/data/export/upstart/process_master.conf.erb +2 -0
- data/lib/foreman/cli.rb +162 -0
- data/lib/foreman/distribution.rb +9 -0
- data/lib/foreman/engine/cli.rb +105 -0
- data/lib/foreman/engine.rb +494 -0
- data/lib/foreman/env.rb +29 -0
- data/lib/foreman/export/base.rb +171 -0
- data/lib/foreman/export/bluepill.rb +12 -0
- data/lib/foreman/export/daemon.rb +28 -0
- data/lib/foreman/export/inittab.rb +42 -0
- data/lib/foreman/export/launchd.rb +22 -0
- data/lib/foreman/export/runit.rb +34 -0
- data/lib/foreman/export/supervisord.rb +16 -0
- data/lib/foreman/export/systemd.rb +34 -0
- data/lib/foreman/export/upstart.rb +46 -0
- data/lib/foreman/export.rb +36 -0
- data/lib/foreman/helpers.rb +45 -0
- data/lib/foreman/process.rb +81 -0
- data/lib/foreman/procfile.rb +94 -0
- data/lib/foreman/vendor/thor/lib/thor/actions/create_file.rb +103 -0
- data/lib/foreman/vendor/thor/lib/thor/actions/create_link.rb +59 -0
- data/lib/foreman/vendor/thor/lib/thor/actions/directory.rb +118 -0
- data/lib/foreman/vendor/thor/lib/thor/actions/empty_directory.rb +135 -0
- data/lib/foreman/vendor/thor/lib/thor/actions/file_manipulation.rb +327 -0
- data/lib/foreman/vendor/thor/lib/thor/actions/inject_into_file.rb +103 -0
- data/lib/foreman/vendor/thor/lib/thor/actions.rb +318 -0
- data/lib/foreman/vendor/thor/lib/thor/base.rb +656 -0
- data/lib/foreman/vendor/thor/lib/thor/command.rb +133 -0
- data/lib/foreman/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +85 -0
- data/lib/foreman/vendor/thor/lib/thor/core_ext/io_binary_read.rb +12 -0
- data/lib/foreman/vendor/thor/lib/thor/core_ext/ordered_hash.rb +129 -0
- data/lib/foreman/vendor/thor/lib/thor/error.rb +32 -0
- data/lib/foreman/vendor/thor/lib/thor/group.rb +281 -0
- data/lib/foreman/vendor/thor/lib/thor/invocation.rb +177 -0
- data/lib/foreman/vendor/thor/lib/thor/line_editor/basic.rb +35 -0
- data/lib/foreman/vendor/thor/lib/thor/line_editor/readline.rb +88 -0
- data/lib/foreman/vendor/thor/lib/thor/line_editor.rb +17 -0
- data/lib/foreman/vendor/thor/lib/thor/parser/argument.rb +70 -0
- data/lib/foreman/vendor/thor/lib/thor/parser/arguments.rb +175 -0
- data/lib/foreman/vendor/thor/lib/thor/parser/option.rb +146 -0
- data/lib/foreman/vendor/thor/lib/thor/parser/options.rb +220 -0
- data/lib/foreman/vendor/thor/lib/thor/parser.rb +4 -0
- data/lib/foreman/vendor/thor/lib/thor/rake_compat.rb +71 -0
- data/lib/foreman/vendor/thor/lib/thor/runner.rb +322 -0
- data/lib/foreman/vendor/thor/lib/thor/shell/basic.rb +436 -0
- data/lib/foreman/vendor/thor/lib/thor/shell/color.rb +149 -0
- data/lib/foreman/vendor/thor/lib/thor/shell/html.rb +126 -0
- data/lib/foreman/vendor/thor/lib/thor/shell.rb +81 -0
- data/lib/foreman/vendor/thor/lib/thor/util.rb +268 -0
- data/lib/foreman/vendor/thor/lib/thor/version.rb +3 -0
- data/lib/foreman/vendor/thor/lib/thor.rb +492 -0
- data/lib/foreman/version.rb +5 -0
- data/lib/foreman.rb +17 -0
- data/man/overman.1 +284 -0
- data/spec/foreman/cli_spec.rb +111 -0
- data/spec/foreman/engine_spec.rb +114 -0
- data/spec/foreman/export/base_spec.rb +19 -0
- data/spec/foreman/export/bluepill_spec.rb +37 -0
- data/spec/foreman/export/daemon_spec.rb +97 -0
- data/spec/foreman/export/inittab_spec.rb +40 -0
- data/spec/foreman/export/launchd_spec.rb +31 -0
- data/spec/foreman/export/runit_spec.rb +36 -0
- data/spec/foreman/export/supervisord_spec.rb +38 -0
- data/spec/foreman/export/systemd_spec.rb +155 -0
- data/spec/foreman/export/upstart_spec.rb +118 -0
- data/spec/foreman/export_spec.rb +24 -0
- data/spec/foreman/helpers_spec.rb +26 -0
- data/spec/foreman/process_spec.rb +71 -0
- data/spec/foreman/procfile_spec.rb +57 -0
- data/spec/foreman_spec.rb +16 -0
- data/spec/helper_spec.rb +19 -0
- data/spec/resources/Procfile +5 -0
- data/spec/resources/Procfile.bad +2 -0
- data/spec/resources/bin/echo +2 -0
- data/spec/resources/bin/env +2 -0
- data/spec/resources/bin/test +2 -0
- data/spec/resources/bin/utf8 +2 -0
- data/spec/resources/export/bluepill/app-concurrency.pill +49 -0
- data/spec/resources/export/bluepill/app.pill +81 -0
- data/spec/resources/export/daemon/app-alpha-1.conf +7 -0
- data/spec/resources/export/daemon/app-alpha-2.conf +7 -0
- data/spec/resources/export/daemon/app-alpha.conf +2 -0
- data/spec/resources/export/daemon/app-bravo-1.conf +7 -0
- data/spec/resources/export/daemon/app-bravo.conf +2 -0
- data/spec/resources/export/daemon/app.conf +14 -0
- data/spec/resources/export/inittab/inittab.concurrency +4 -0
- data/spec/resources/export/inittab/inittab.default +6 -0
- data/spec/resources/export/launchd/launchd-a.default +29 -0
- data/spec/resources/export/launchd/launchd-b.default +29 -0
- data/spec/resources/export/launchd/launchd-c.default +30 -0
- data/spec/resources/export/runit/app-alpha-1/log/run +7 -0
- data/spec/resources/export/runit/app-alpha-1/run +4 -0
- data/spec/resources/export/runit/app-alpha-2/log/run +7 -0
- data/spec/resources/export/runit/app-alpha-2/run +4 -0
- data/spec/resources/export/runit/app-bravo-1/log/run +7 -0
- data/spec/resources/export/runit/app-bravo-1/run +4 -0
- data/spec/resources/export/supervisord/app-alpha-1.conf +42 -0
- data/spec/resources/export/supervisord/app-alpha-2.conf +22 -0
- data/spec/resources/export/systemd/app-alpha.1.service +18 -0
- data/spec/resources/export/systemd/app-alpha.2.service +18 -0
- data/spec/resources/export/systemd/app-alpha.target +2 -0
- data/spec/resources/export/systemd/app-bravo.1.service +18 -0
- data/spec/resources/export/systemd/app-bravo.target +2 -0
- data/spec/resources/export/systemd/app.target +5 -0
- data/spec/resources/export/upstart/app-alpha-1.conf +11 -0
- data/spec/resources/export/upstart/app-alpha-2.conf +11 -0
- data/spec/resources/export/upstart/app-alpha.conf +2 -0
- data/spec/resources/export/upstart/app-bravo-1.conf +11 -0
- data/spec/resources/export/upstart/app-bravo.conf +2 -0
- data/spec/resources/export/upstart/app.conf +2 -0
- data/spec/spec_helper.rb +177 -0
- metadata +147 -16
- data/lib/overman/version.rb +0 -5
- data/lib/overman.rb +0 -1
@@ -0,0 +1,81 @@
|
|
1
|
+
require "rbconfig"
|
2
|
+
|
3
|
+
class Foreman::Thor
|
4
|
+
module Base
|
5
|
+
class << self
|
6
|
+
attr_writer :shell
|
7
|
+
|
8
|
+
# Returns the shell used in all Foreman::Thor classes. If you are in a Unix platform
|
9
|
+
# it will use a colored log, otherwise it will use a basic one without color.
|
10
|
+
#
|
11
|
+
def shell
|
12
|
+
@shell ||= if ENV["THOR_SHELL"] && !ENV["THOR_SHELL"].empty?
|
13
|
+
Foreman::Thor::Shell.const_get(ENV["THOR_SHELL"])
|
14
|
+
elsif RbConfig::CONFIG["host_os"] =~ /mswin|mingw/ && !ENV["ANSICON"]
|
15
|
+
Foreman::Thor::Shell::Basic
|
16
|
+
else
|
17
|
+
Foreman::Thor::Shell::Color
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
module Shell
|
24
|
+
SHELL_DELEGATED_METHODS = [:ask, :error, :set_color, :yes?, :no?, :say, :say_status, :print_in_columns, :print_table, :print_wrapped, :file_collision, :terminal_width]
|
25
|
+
attr_writer :shell
|
26
|
+
|
27
|
+
autoload :Basic, "foreman/vendor/thor/lib/thor/shell/basic"
|
28
|
+
autoload :Color, "foreman/vendor/thor/lib/thor/shell/color"
|
29
|
+
autoload :HTML, "foreman/vendor/thor/lib/thor/shell/html"
|
30
|
+
|
31
|
+
# Add shell to initialize config values.
|
32
|
+
#
|
33
|
+
# ==== Configuration
|
34
|
+
# shell<Object>:: An instance of the shell to be used.
|
35
|
+
#
|
36
|
+
# ==== Examples
|
37
|
+
#
|
38
|
+
# class MyScript < Foreman::Thor
|
39
|
+
# argument :first, :type => :numeric
|
40
|
+
# end
|
41
|
+
#
|
42
|
+
# MyScript.new [1.0], { :foo => :bar }, :shell => Foreman::Thor::Shell::Basic.new
|
43
|
+
#
|
44
|
+
def initialize(args = [], options = {}, config = {})
|
45
|
+
super
|
46
|
+
self.shell = config[:shell]
|
47
|
+
shell.base ||= self if shell.respond_to?(:base)
|
48
|
+
end
|
49
|
+
|
50
|
+
# Holds the shell for the given Foreman::Thor instance. If no shell is given,
|
51
|
+
# it gets a default shell from Foreman::Thor::Base.shell.
|
52
|
+
def shell
|
53
|
+
@shell ||= Foreman::Thor::Base.shell.new
|
54
|
+
end
|
55
|
+
|
56
|
+
# Common methods that are delegated to the shell.
|
57
|
+
SHELL_DELEGATED_METHODS.each do |method|
|
58
|
+
module_eval <<-METHOD, __FILE__, __LINE__
|
59
|
+
def #{method}(*args,&block)
|
60
|
+
shell.#{method}(*args,&block)
|
61
|
+
end
|
62
|
+
METHOD
|
63
|
+
end
|
64
|
+
|
65
|
+
# Yields the given block with padding.
|
66
|
+
def with_padding
|
67
|
+
shell.padding += 1
|
68
|
+
yield
|
69
|
+
ensure
|
70
|
+
shell.padding -= 1
|
71
|
+
end
|
72
|
+
|
73
|
+
protected
|
74
|
+
|
75
|
+
# Allow shell to be shared between invocations.
|
76
|
+
#
|
77
|
+
def _shared_configuration #:nodoc:
|
78
|
+
super.merge!(:shell => shell)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,268 @@
|
|
1
|
+
require "rbconfig"
|
2
|
+
|
3
|
+
class Foreman::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
|
+
# Foreman::Thor::Util.namespace_from_thor_class(Foo::Bar::Baz) #=> "foo:bar:baz"
|
12
|
+
#
|
13
|
+
# 2) Loading thor files and sandboxing:
|
14
|
+
#
|
15
|
+
# Foreman::Thor::Util.load_thorfile("~/.thor/foo")
|
16
|
+
#
|
17
|
+
module Util
|
18
|
+
class << self
|
19
|
+
# Receives a namespace and search for it in the Foreman::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
|
+
Foreman::Thor::Base.subclasses.detect { |klass| klass.namespace == namespace }
|
27
|
+
end
|
28
|
+
|
29
|
+
# Receives a constant and converts it to a Foreman::Thor namespace. Since Foreman::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 Foreman::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(/^Foreman::Thor::Sandbox::/, "")
|
45
|
+
constant = snake_case(constant).squeeze(":")
|
46
|
+
constant
|
47
|
+
end
|
48
|
+
|
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 = Foreman::Thor::Base.subclasses.dup
|
60
|
+
Foreman::Thor::Base.subclasses.clear
|
61
|
+
|
62
|
+
load_thorfile(file, contents)
|
63
|
+
|
64
|
+
new_constants = Foreman::Thor::Base.subclasses.dup
|
65
|
+
Foreman::Thor::Base.subclasses.replace(old_constants)
|
66
|
+
|
67
|
+
new_constants.map!(&:namespace)
|
68
|
+
new_constants.compact!
|
69
|
+
new_constants
|
70
|
+
end
|
71
|
+
|
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
|
+
Foreman::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 snake_case(str)
|
91
|
+
return str.downcase if str =~ /^[A-Z_]+$/
|
92
|
+
str.gsub(/\B[A-Z]/, '_\&').squeeze("_") =~ /_*(.*)/
|
93
|
+
$+.downcase
|
94
|
+
end
|
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
|
107
|
+
end
|
108
|
+
|
109
|
+
# Receives a namespace and tries to retrieve a Foreman::Thor or Foreman::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 < Foreman::Thor
|
117
|
+
# def baz
|
118
|
+
# end
|
119
|
+
# end
|
120
|
+
#
|
121
|
+
# class Baz::Foo < Foreman::Thor::Group
|
122
|
+
# end
|
123
|
+
#
|
124
|
+
# Foreman::Thor::Util.namespace_to_thor_class("foo:bar") #=> Foo::Bar, nil # will invoke default command
|
125
|
+
# Foreman::Thor::Util.namespace_to_thor_class("baz:foo") #=> Baz::Foo, nil
|
126
|
+
# Foreman::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 = Foreman::Thor::Util.find_by_namespace(pieces.join(":"))
|
136
|
+
end
|
137
|
+
unless klass # look for a Foreman::Thor::Group with the right name
|
138
|
+
klass = Foreman::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 = Foreman::Thor::Util.find_by_namespace("")
|
144
|
+
end
|
145
|
+
[klass, command]
|
146
|
+
end
|
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)
|
154
|
+
|
155
|
+
begin
|
156
|
+
Foreman::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)
|
161
|
+
else
|
162
|
+
$stderr.puts(e.backtrace.first)
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
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
|
188
|
+
|
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('\\', "/")
|
193
|
+
end
|
194
|
+
|
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)}/*"]
|
204
|
+
|
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 Foreman::Thor files.
|
211
|
+
#
|
212
|
+
def globs_for(path)
|
213
|
+
path = escape_globs(path)
|
214
|
+
["#{path}/Foreman::Thorfile", "#{path}/*.thor", "#{path}/tasks/*.thor", "#{path}/lib/tasks/*.thor"]
|
215
|
+
end
|
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
|
+
# Foreman::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
|
267
|
+
end
|
268
|
+
end
|