engineyard 2.0.0.pre1 → 2.0.0.pre2
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.
- data/README.rdoc +39 -136
- data/bin/ey_perftools +12 -0
- data/lib/engineyard.rb +0 -2
- data/lib/engineyard/cli.rb +3 -4
- data/lib/engineyard/cli/api.rb +3 -2
- data/lib/engineyard/commands/deploy.rb +0 -0
- data/lib/engineyard/thor.rb +7 -3
- data/lib/engineyard/version.rb +1 -1
- data/spec/engineyard/cli/api_spec.rb +6 -0
- data/spec/ey/deploy_spec.rb +6 -0
- data/spec/ey/ssh_spec.rb +6 -6
- metadata +24 -37
- data/lib/vendor/thor/LICENSE.md +0 -20
- data/lib/vendor/thor/README.md +0 -26
- data/lib/vendor/thor/lib/thor.rb +0 -379
- data/lib/vendor/thor/lib/thor/actions.rb +0 -318
- data/lib/vendor/thor/lib/thor/actions/create_file.rb +0 -105
- data/lib/vendor/thor/lib/thor/actions/create_link.rb +0 -57
- data/lib/vendor/thor/lib/thor/actions/directory.rb +0 -97
- data/lib/vendor/thor/lib/thor/actions/empty_directory.rb +0 -153
- data/lib/vendor/thor/lib/thor/actions/file_manipulation.rb +0 -308
- data/lib/vendor/thor/lib/thor/actions/inject_into_file.rb +0 -109
- data/lib/vendor/thor/lib/thor/base.rb +0 -611
- data/lib/vendor/thor/lib/thor/core_ext/file_binary_read.rb +0 -9
- data/lib/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +0 -75
- data/lib/vendor/thor/lib/thor/core_ext/ordered_hash.rb +0 -100
- data/lib/vendor/thor/lib/thor/error.rb +0 -35
- data/lib/vendor/thor/lib/thor/group.rb +0 -285
- data/lib/vendor/thor/lib/thor/invocation.rb +0 -170
- data/lib/vendor/thor/lib/thor/parser.rb +0 -4
- data/lib/vendor/thor/lib/thor/parser/argument.rb +0 -67
- data/lib/vendor/thor/lib/thor/parser/arguments.rb +0 -165
- data/lib/vendor/thor/lib/thor/parser/option.rb +0 -121
- data/lib/vendor/thor/lib/thor/parser/options.rb +0 -181
- data/lib/vendor/thor/lib/thor/rake_compat.rb +0 -71
- data/lib/vendor/thor/lib/thor/runner.rb +0 -321
- data/lib/vendor/thor/lib/thor/shell.rb +0 -88
- data/lib/vendor/thor/lib/thor/shell/basic.rb +0 -331
- data/lib/vendor/thor/lib/thor/shell/color.rb +0 -108
- data/lib/vendor/thor/lib/thor/shell/html.rb +0 -121
- data/lib/vendor/thor/lib/thor/task.rb +0 -132
- data/lib/vendor/thor/lib/thor/util.rb +0 -248
- data/lib/vendor/thor/lib/thor/version.rb +0 -3
@@ -1,121 +0,0 @@
|
|
1
|
-
require 'thor/shell/basic'
|
2
|
-
|
3
|
-
class Thor
|
4
|
-
module Shell
|
5
|
-
# Inherit from Thor::Shell::Basic and add set_color behavior. Check
|
6
|
-
# Thor::Shell::Basic to see all available methods.
|
7
|
-
#
|
8
|
-
class HTML < Basic
|
9
|
-
# The start of an HTML bold sequence.
|
10
|
-
BOLD = "<strong>"
|
11
|
-
# The end of an HTML bold sequence.
|
12
|
-
END_BOLD = "</strong>"
|
13
|
-
|
14
|
-
# Embed in a String to clear previous color selection.
|
15
|
-
CLEAR = "</span>"
|
16
|
-
|
17
|
-
# Set the terminal's foreground HTML color to black.
|
18
|
-
BLACK = '<span style="color: black;">'
|
19
|
-
# Set the terminal's foreground HTML color to red.
|
20
|
-
RED = '<span style="color: red;">'
|
21
|
-
# Set the terminal's foreground HTML color to green.
|
22
|
-
GREEN = '<span style="color: green;">'
|
23
|
-
# Set the terminal's foreground HTML color to yellow.
|
24
|
-
YELLOW = '<span style="color: yellow;">'
|
25
|
-
# Set the terminal's foreground HTML color to blue.
|
26
|
-
BLUE = '<span style="color: blue;">'
|
27
|
-
# Set the terminal's foreground HTML color to magenta.
|
28
|
-
MAGENTA = '<span style="color: magenta;">'
|
29
|
-
# Set the terminal's foreground HTML color to cyan.
|
30
|
-
CYAN = '<span style="color: cyan;">'
|
31
|
-
# Set the terminal's foreground HTML color to white.
|
32
|
-
WHITE = '<span style="color: white;">'
|
33
|
-
|
34
|
-
# Set the terminal's background HTML color to black.
|
35
|
-
ON_BLACK = '<span style="background-color: black">'
|
36
|
-
# Set the terminal's background HTML color to red.
|
37
|
-
ON_RED = '<span style="background-color: red">'
|
38
|
-
# Set the terminal's background HTML color to green.
|
39
|
-
ON_GREEN = '<span style="background-color: green">'
|
40
|
-
# Set the terminal's background HTML color to yellow.
|
41
|
-
ON_YELLOW = '<span style="background-color: yellow">'
|
42
|
-
# Set the terminal's background HTML color to blue.
|
43
|
-
ON_BLUE = '<span style="background-color: blue">'
|
44
|
-
# Set the terminal's background HTML color to magenta.
|
45
|
-
ON_MAGENTA = '<span style="background-color: magenta">'
|
46
|
-
# Set the terminal's background HTML color to cyan.
|
47
|
-
ON_CYAN = '<span style="background-color: cyan">'
|
48
|
-
# Set the terminal's background HTML color to white.
|
49
|
-
ON_WHITE = '<span style="background-color: white">'
|
50
|
-
|
51
|
-
# Set color by using a string or one of the defined constants. If a third
|
52
|
-
# option is set to true, it also adds bold to the string. This is based
|
53
|
-
# on Highline implementation and it automatically appends CLEAR to the end
|
54
|
-
# of the returned String.
|
55
|
-
#
|
56
|
-
def set_color(string, color, bold=false)
|
57
|
-
color = self.class.const_get(color.to_s.upcase) if color.is_a?(Symbol)
|
58
|
-
bold, end_bold = bold ? [BOLD, END_BOLD] : ['', '']
|
59
|
-
"#{bold}#{color}#{string}#{CLEAR}#{end_bold}"
|
60
|
-
end
|
61
|
-
|
62
|
-
# Ask something to the user and receives a response.
|
63
|
-
#
|
64
|
-
# ==== Example
|
65
|
-
# ask("What is your name?")
|
66
|
-
#
|
67
|
-
# TODO: Implement #ask for Thor::Shell::HTML
|
68
|
-
def ask(statement, color=nil)
|
69
|
-
raise NotImplementedError, "Implement #ask for Thor::Shell::HTML"
|
70
|
-
end
|
71
|
-
|
72
|
-
protected
|
73
|
-
|
74
|
-
# Overwrite show_diff to show diff with colors if Diff::LCS is
|
75
|
-
# available.
|
76
|
-
#
|
77
|
-
def show_diff(destination, content) #:nodoc:
|
78
|
-
if diff_lcs_loaded? && ENV['THOR_DIFF'].nil? && ENV['RAILS_DIFF'].nil?
|
79
|
-
actual = File.binread(destination).to_s.split("\n")
|
80
|
-
content = content.to_s.split("\n")
|
81
|
-
|
82
|
-
Diff::LCS.sdiff(actual, content).each do |diff|
|
83
|
-
output_diff_line(diff)
|
84
|
-
end
|
85
|
-
else
|
86
|
-
super
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
def output_diff_line(diff) #:nodoc:
|
91
|
-
case diff.action
|
92
|
-
when '-'
|
93
|
-
say "- #{diff.old_element.chomp}", :red, true
|
94
|
-
when '+'
|
95
|
-
say "+ #{diff.new_element.chomp}", :green, true
|
96
|
-
when '!'
|
97
|
-
say "- #{diff.old_element.chomp}", :red, true
|
98
|
-
say "+ #{diff.new_element.chomp}", :green, true
|
99
|
-
else
|
100
|
-
say " #{diff.old_element.chomp}", nil, true
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
# Check if Diff::LCS is loaded. If it is, use it to create pretty output
|
105
|
-
# for diff.
|
106
|
-
#
|
107
|
-
def diff_lcs_loaded? #:nodoc:
|
108
|
-
return true if defined?(Diff::LCS)
|
109
|
-
return @diff_lcs_loaded unless @diff_lcs_loaded.nil?
|
110
|
-
|
111
|
-
@diff_lcs_loaded = begin
|
112
|
-
require 'diff/lcs'
|
113
|
-
true
|
114
|
-
rescue LoadError
|
115
|
-
false
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
end
|
120
|
-
end
|
121
|
-
end
|
@@ -1,132 +0,0 @@
|
|
1
|
-
class Thor
|
2
|
-
class Task < Struct.new(:name, :description, :long_description, :usage, :options)
|
3
|
-
FILE_REGEXP = /^#{Regexp.escape(File.dirname(__FILE__))}/
|
4
|
-
|
5
|
-
def initialize(name, description, long_description, usage, options=nil)
|
6
|
-
super(name.to_s, description, long_description, usage, options || {})
|
7
|
-
end
|
8
|
-
|
9
|
-
def initialize_copy(other) #:nodoc:
|
10
|
-
super(other)
|
11
|
-
self.options = other.options.dup if other.options
|
12
|
-
end
|
13
|
-
|
14
|
-
def hidden?
|
15
|
-
false
|
16
|
-
end
|
17
|
-
|
18
|
-
# By default, a task invokes a method in the thor class. You can change this
|
19
|
-
# implementation to create custom tasks.
|
20
|
-
def run(instance, args=[])
|
21
|
-
arity = nil
|
22
|
-
|
23
|
-
if private_method?(instance)
|
24
|
-
instance.class.handle_no_task_error(name)
|
25
|
-
elsif public_method?(instance)
|
26
|
-
arity = instance.method(name).arity
|
27
|
-
instance.send(name, *args)
|
28
|
-
elsif local_method?(instance, :method_missing)
|
29
|
-
instance.send(:method_missing, name.to_sym, *args)
|
30
|
-
else
|
31
|
-
instance.class.handle_no_task_error(name)
|
32
|
-
end
|
33
|
-
rescue ArgumentError => e
|
34
|
-
handle_argument_error?(instance, e, caller) ?
|
35
|
-
instance.class.handle_argument_error(self, e, arity) : (raise e)
|
36
|
-
rescue NoMethodError => e
|
37
|
-
handle_no_method_error?(instance, e, caller) ?
|
38
|
-
instance.class.handle_no_task_error(name) : (raise e)
|
39
|
-
end
|
40
|
-
|
41
|
-
# Returns the formatted usage by injecting given required arguments
|
42
|
-
# and required options into the given usage.
|
43
|
-
def formatted_usage(klass, namespace = true, subcommand = false)
|
44
|
-
if namespace
|
45
|
-
namespace = klass.namespace
|
46
|
-
formatted = "#{namespace.gsub(/^(default)/,'')}:"
|
47
|
-
end
|
48
|
-
formatted = "#{klass.namespace.split(':').last} " if subcommand
|
49
|
-
|
50
|
-
formatted ||= ""
|
51
|
-
|
52
|
-
# Add usage with required arguments
|
53
|
-
formatted << if klass && !klass.arguments.empty?
|
54
|
-
usage.to_s.gsub(/^#{name}/) do |match|
|
55
|
-
match << " " << klass.arguments.map{ |a| a.usage }.compact.join(' ')
|
56
|
-
end
|
57
|
-
else
|
58
|
-
usage.to_s
|
59
|
-
end
|
60
|
-
|
61
|
-
# Add required options
|
62
|
-
formatted << " #{required_options}"
|
63
|
-
|
64
|
-
# Strip and go!
|
65
|
-
formatted.strip
|
66
|
-
end
|
67
|
-
|
68
|
-
protected
|
69
|
-
|
70
|
-
def not_debugging?(instance)
|
71
|
-
!(instance.class.respond_to?(:debugging) && instance.class.debugging)
|
72
|
-
end
|
73
|
-
|
74
|
-
def required_options
|
75
|
-
@required_options ||= options.map{ |_, o| o.usage if o.required? }.compact.sort.join(" ")
|
76
|
-
end
|
77
|
-
|
78
|
-
# Given a target, checks if this class name is a public method.
|
79
|
-
def public_method?(instance) #:nodoc:
|
80
|
-
!(instance.public_methods & [name.to_s, name.to_sym]).empty?
|
81
|
-
end
|
82
|
-
|
83
|
-
def private_method?(instance)
|
84
|
-
!(instance.private_methods & [name.to_s, name.to_sym]).empty?
|
85
|
-
end
|
86
|
-
|
87
|
-
def local_method?(instance, name)
|
88
|
-
methods = instance.public_methods(false) + instance.private_methods(false) + instance.protected_methods(false)
|
89
|
-
!(methods & [name.to_s, name.to_sym]).empty?
|
90
|
-
end
|
91
|
-
|
92
|
-
def sans_backtrace(backtrace, caller) #:nodoc:
|
93
|
-
saned = backtrace.reject { |frame| frame =~ FILE_REGEXP || (frame =~ /\.java:/ && RUBY_PLATFORM =~ /java/) }
|
94
|
-
saned -= caller
|
95
|
-
end
|
96
|
-
|
97
|
-
def handle_argument_error?(instance, error, caller)
|
98
|
-
not_debugging?(instance) && error.message =~ /wrong number of arguments/ && begin
|
99
|
-
saned = sans_backtrace(error.backtrace, caller)
|
100
|
-
# Ruby 1.9 always include the called method in the backtrace
|
101
|
-
saned.empty? || (saned.size == 1 && RUBY_VERSION >= "1.9")
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
def handle_no_method_error?(instance, error, caller)
|
106
|
-
not_debugging?(instance) &&
|
107
|
-
error.message =~ /^undefined method `#{name}' for #{Regexp.escape(instance.to_s)}$/
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
# A task that is hidden in help messages but still invocable.
|
112
|
-
class HiddenTask < Task
|
113
|
-
def hidden?
|
114
|
-
true
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
|
-
# A dynamic task that handles method missing scenarios.
|
119
|
-
class DynamicTask < Task
|
120
|
-
def initialize(name, options=nil)
|
121
|
-
super(name.to_s, "A dynamically-generated task", name.to_s, name.to_s, options)
|
122
|
-
end
|
123
|
-
|
124
|
-
def run(instance, args=[])
|
125
|
-
if (instance.methods & [name.to_s, name.to_sym]).empty?
|
126
|
-
super
|
127
|
-
else
|
128
|
-
instance.class.handle_no_task_error(name)
|
129
|
-
end
|
130
|
-
end
|
131
|
-
end
|
132
|
-
end
|
@@ -1,248 +0,0 @@
|
|
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
|
-
# 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 self.find_by_namespace(namespace)
|
25
|
-
namespace = "default#{namespace}" if namespace.empty? || namespace =~ /^:/
|
26
|
-
Thor::Base.subclasses.find { |klass| klass.namespace == namespace }
|
27
|
-
end
|
28
|
-
|
29
|
-
# Receives a constant and converts it to a Thor namespace. Since Thor tasks
|
30
|
-
# can be added to a sandbox, this method is also responsable for removing
|
31
|
-
# 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 self.namespace_from_thor_class(constant)
|
44
|
-
constant = constant.to_s.gsub(/^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 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
|
71
|
-
|
72
|
-
# Returns the thor classes declared inside the given class.
|
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
|
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 self.camel_case(str)
|
105
|
-
return str if str !~ /_/ && str =~ /[A-Z]+.*/
|
106
|
-
str.split('_').map { |i| i.capitalize }.join
|
107
|
-
end
|
108
|
-
|
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 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(":"))
|
136
|
-
end
|
137
|
-
unless klass # look for a Thor::Group with the right name
|
138
|
-
klass, task = Thor::Util.find_by_namespace(namespace), nil
|
139
|
-
end
|
140
|
-
if !klass && fallback # try a task in the default namespace
|
141
|
-
task = namespace
|
142
|
-
klass = Thor::Util.find_by_namespace('')
|
143
|
-
end
|
144
|
-
return klass, task
|
145
|
-
end
|
146
|
-
|
147
|
-
# Receives a path and load the thor file in the path. The file is evaluated
|
148
|
-
# inside the sandbox to avoid namespacing conflicts.
|
149
|
-
#
|
150
|
-
def self.load_thorfile(path, content=nil, debug=false)
|
151
|
-
content ||= File.binread(path)
|
152
|
-
|
153
|
-
begin
|
154
|
-
Thor::Sandbox.class_eval(content, path)
|
155
|
-
rescue Exception => e
|
156
|
-
$stderr.puts("WARNING: unable to load thorfile #{path.inspect}: #{e.message}")
|
157
|
-
if debug
|
158
|
-
$stderr.puts(*e.backtrace)
|
159
|
-
else
|
160
|
-
$stderr.puts(e.backtrace.first)
|
161
|
-
end
|
162
|
-
end
|
163
|
-
end
|
164
|
-
|
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
|
-
begin
|
176
|
-
File.expand_path("~")
|
177
|
-
rescue
|
178
|
-
if File::ALT_SEPARATOR
|
179
|
-
"C:/"
|
180
|
-
else
|
181
|
-
"/"
|
182
|
-
end
|
183
|
-
end
|
184
|
-
end
|
185
|
-
end
|
186
|
-
|
187
|
-
# Returns the root where thor files are located, depending on the OS.
|
188
|
-
#
|
189
|
-
def self.thor_root
|
190
|
-
File.join(user_home, ".thor").gsub(/\\/, '/')
|
191
|
-
end
|
192
|
-
|
193
|
-
# Returns the files in the thor root. On Windows thor_root will be something
|
194
|
-
# like this:
|
195
|
-
#
|
196
|
-
# C:\Documents and Settings\james\.thor
|
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
|
205
|
-
end
|
206
|
-
end
|
207
|
-
|
208
|
-
# Where to look for Thor files.
|
209
|
-
#
|
210
|
-
def self.globs_for(path)
|
211
|
-
["#{path}/Thorfile", "#{path}/*.thor", "#{path}/tasks/*.thor", "#{path}/lib/tasks/*.thor"]
|
212
|
-
end
|
213
|
-
|
214
|
-
# Return the path to the ruby interpreter taking into account multiple
|
215
|
-
# installations and windows extensions.
|
216
|
-
#
|
217
|
-
def self.ruby_command
|
218
|
-
@ruby_command ||= begin
|
219
|
-
ruby_name = RbConfig::CONFIG['ruby_install_name']
|
220
|
-
ruby = File.join(RbConfig::CONFIG['bindir'], ruby_name)
|
221
|
-
ruby << RbConfig::CONFIG['EXEEXT']
|
222
|
-
|
223
|
-
# avoid using different name than ruby (on platforms supporting links)
|
224
|
-
if ruby_name != 'ruby' && File.respond_to?(:readlink)
|
225
|
-
begin
|
226
|
-
alternate_ruby = File.join(RbConfig::CONFIG['bindir'], 'ruby')
|
227
|
-
alternate_ruby << RbConfig::CONFIG['EXEEXT']
|
228
|
-
|
229
|
-
# ruby is a symlink
|
230
|
-
if File.symlink? alternate_ruby
|
231
|
-
linked_ruby = File.readlink alternate_ruby
|
232
|
-
|
233
|
-
# symlink points to 'ruby_install_name'
|
234
|
-
ruby = alternate_ruby if linked_ruby == ruby_name || linked_ruby == ruby
|
235
|
-
end
|
236
|
-
rescue NotImplementedError
|
237
|
-
# just ignore on windows
|
238
|
-
end
|
239
|
-
end
|
240
|
-
|
241
|
-
# escape string in case path to ruby executable contain spaces.
|
242
|
-
ruby.sub!(/.*\s.*/m, '"\&"')
|
243
|
-
ruby
|
244
|
-
end
|
245
|
-
end
|
246
|
-
|
247
|
-
end
|
248
|
-
end
|