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.
Files changed (43) hide show
  1. data/README.rdoc +39 -136
  2. data/bin/ey_perftools +12 -0
  3. data/lib/engineyard.rb +0 -2
  4. data/lib/engineyard/cli.rb +3 -4
  5. data/lib/engineyard/cli/api.rb +3 -2
  6. data/lib/engineyard/commands/deploy.rb +0 -0
  7. data/lib/engineyard/thor.rb +7 -3
  8. data/lib/engineyard/version.rb +1 -1
  9. data/spec/engineyard/cli/api_spec.rb +6 -0
  10. data/spec/ey/deploy_spec.rb +6 -0
  11. data/spec/ey/ssh_spec.rb +6 -6
  12. metadata +24 -37
  13. data/lib/vendor/thor/LICENSE.md +0 -20
  14. data/lib/vendor/thor/README.md +0 -26
  15. data/lib/vendor/thor/lib/thor.rb +0 -379
  16. data/lib/vendor/thor/lib/thor/actions.rb +0 -318
  17. data/lib/vendor/thor/lib/thor/actions/create_file.rb +0 -105
  18. data/lib/vendor/thor/lib/thor/actions/create_link.rb +0 -57
  19. data/lib/vendor/thor/lib/thor/actions/directory.rb +0 -97
  20. data/lib/vendor/thor/lib/thor/actions/empty_directory.rb +0 -153
  21. data/lib/vendor/thor/lib/thor/actions/file_manipulation.rb +0 -308
  22. data/lib/vendor/thor/lib/thor/actions/inject_into_file.rb +0 -109
  23. data/lib/vendor/thor/lib/thor/base.rb +0 -611
  24. data/lib/vendor/thor/lib/thor/core_ext/file_binary_read.rb +0 -9
  25. data/lib/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +0 -75
  26. data/lib/vendor/thor/lib/thor/core_ext/ordered_hash.rb +0 -100
  27. data/lib/vendor/thor/lib/thor/error.rb +0 -35
  28. data/lib/vendor/thor/lib/thor/group.rb +0 -285
  29. data/lib/vendor/thor/lib/thor/invocation.rb +0 -170
  30. data/lib/vendor/thor/lib/thor/parser.rb +0 -4
  31. data/lib/vendor/thor/lib/thor/parser/argument.rb +0 -67
  32. data/lib/vendor/thor/lib/thor/parser/arguments.rb +0 -165
  33. data/lib/vendor/thor/lib/thor/parser/option.rb +0 -121
  34. data/lib/vendor/thor/lib/thor/parser/options.rb +0 -181
  35. data/lib/vendor/thor/lib/thor/rake_compat.rb +0 -71
  36. data/lib/vendor/thor/lib/thor/runner.rb +0 -321
  37. data/lib/vendor/thor/lib/thor/shell.rb +0 -88
  38. data/lib/vendor/thor/lib/thor/shell/basic.rb +0 -331
  39. data/lib/vendor/thor/lib/thor/shell/color.rb +0 -108
  40. data/lib/vendor/thor/lib/thor/shell/html.rb +0 -121
  41. data/lib/vendor/thor/lib/thor/task.rb +0 -132
  42. data/lib/vendor/thor/lib/thor/util.rb +0 -248
  43. data/lib/vendor/thor/lib/thor/version.rb +0 -3
@@ -1,88 +0,0 @@
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, :yes?, :no?, :say, :say_status, :print_table]
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)
66
- shell.#{method}(*args)
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
@@ -1,331 +0,0 @@
1
- require 'tempfile'
2
-
3
- class Thor
4
- module Shell
5
- class Basic
6
- attr_accessor :base, :padding
7
-
8
- # Initialize base, mute and padding to nil.
9
- #
10
- def initialize #:nodoc:
11
- @base, @mute, @padding = nil, false, 0
12
- end
13
-
14
- # Mute everything that's inside given block
15
- #
16
- def mute
17
- @mute = true
18
- yield
19
- ensure
20
- @mute = false
21
- end
22
-
23
- # Check if base is muted
24
- #
25
- def mute?
26
- @mute
27
- end
28
-
29
- # Sets the output padding, not allowing less than zero values.
30
- #
31
- def padding=(value)
32
- @padding = [0, value].max
33
- end
34
-
35
- # Asks something to the user and receives a response.
36
- #
37
- # If asked to limit the correct responses, you can pass in an
38
- # array of acceptable answers. If one of those is not supplied,
39
- # they will be shown a message stating that one of those answers
40
- # must be given and re-asked the question.
41
- #
42
- # ==== Example
43
- # ask("What is your name?")
44
- #
45
- # ask("What is your favorite Neopolitan flavor?", :limited_to => ["strawberry", "chocolate", "vanilla"])
46
- #
47
- def ask(statement, *args)
48
- options = args.last.is_a?(Hash) ? args.pop : {}
49
-
50
- options[:limited_to] ? ask_filtered(statement, options[:limited_to], *args) : ask_simply(statement, *args)
51
- end
52
-
53
- # Say (print) something to the user. If the sentence ends with a whitespace
54
- # or tab character, a new line is not appended (print + flush). Otherwise
55
- # are passed straight to puts (behavior got from Highline).
56
- #
57
- # ==== Example
58
- # say("I know you knew that.")
59
- #
60
- def say(message="", color=nil, force_new_line=(message.to_s !~ /( |\t)$/))
61
- message = message.to_s
62
- message = set_color(message, color) if color
63
-
64
- spaces = " " * padding
65
-
66
- if force_new_line
67
- stdout.puts(spaces + message)
68
- else
69
- stdout.print(spaces + message)
70
- end
71
- stdout.flush
72
- end
73
-
74
- # Say a status with the given color and appends the message. Since this
75
- # method is used frequently by actions, it allows nil or false to be given
76
- # in log_status, avoiding the message from being shown. If a Symbol is
77
- # given in log_status, it's used as the color.
78
- #
79
- def say_status(status, message, log_status=true)
80
- return if quiet? || log_status == false
81
- spaces = " " * (padding + 1)
82
- color = log_status.is_a?(Symbol) ? log_status : :green
83
-
84
- status = status.to_s.rjust(12)
85
- status = set_color status, color, true if color
86
-
87
- stdout.puts "#{status}#{spaces}#{message}"
88
- stdout.flush
89
- end
90
-
91
- # Make a question the to user and returns true if the user replies "y" or
92
- # "yes".
93
- #
94
- def yes?(statement, color=nil)
95
- !!(ask(statement, color) =~ is?(:yes))
96
- end
97
-
98
- # Make a question the to user and returns true if the user replies "n" or
99
- # "no".
100
- #
101
- def no?(statement, color=nil)
102
- !yes?(statement, color)
103
- end
104
-
105
- # Prints a table.
106
- #
107
- # ==== Parameters
108
- # Array[Array[String, String, ...]]
109
- #
110
- # ==== Options
111
- # indent<Integer>:: Indent the first column by indent value.
112
- # colwidth<Integer>:: Force the first column to colwidth spaces wide.
113
- #
114
- def print_table(table, options={})
115
- return if table.empty?
116
-
117
- formats, indent, colwidth = [], options[:indent].to_i, options[:colwidth]
118
- options[:truncate] = terminal_width if options[:truncate] == true
119
-
120
- formats << "%-#{colwidth + 2}s" if colwidth
121
- start = colwidth ? 1 : 0
122
-
123
- colcount = table.max{|a,b| a.size <=> b.size }.size
124
-
125
- start.upto(colcount - 2) do |i|
126
- maxima ||= table.map {|row| row[i] ? row[i].size : 0 }.max
127
- formats << "%-#{maxima + 2}s"
128
- end
129
-
130
- formats[0] = formats[0].insert(0, " " * indent)
131
- formats << "%s"
132
-
133
- table.each do |row|
134
- sentence = ""
135
-
136
- row.each_with_index do |column, i|
137
- sentence << formats[i] % column.to_s
138
- end
139
-
140
- sentence = truncate(sentence, options[:truncate]) if options[:truncate]
141
- stdout.puts sentence
142
- end
143
- end
144
-
145
- # Prints a long string, word-wrapping the text to the current width of the
146
- # terminal display. Ideal for printing heredocs.
147
- #
148
- # ==== Parameters
149
- # String
150
- #
151
- # ==== Options
152
- # indent<Integer>:: Indent each line of the printed paragraph by indent value.
153
- #
154
- def print_wrapped(message, options={})
155
- indent = options[:indent] || 0
156
- width = terminal_width - indent
157
- paras = message.split("\n\n")
158
-
159
- paras.map! do |unwrapped|
160
- unwrapped.strip.gsub(/\n/, " ").squeeze(" ").
161
- gsub(/.{1,#{width}}(?:\s|\Z)/){($& + 5.chr).
162
- gsub(/\n\005/,"\n").gsub(/\005/,"\n")}
163
- end
164
-
165
- paras.each do |para|
166
- para.split("\n").each do |line|
167
- stdout.puts line.insert(0, " " * indent)
168
- end
169
- stdout.puts unless para == paras.last
170
- end
171
- end
172
-
173
- # Deals with file collision and returns true if the file should be
174
- # overwritten and false otherwise. If a block is given, it uses the block
175
- # response as the content for the diff.
176
- #
177
- # ==== Parameters
178
- # destination<String>:: the destination file to solve conflicts
179
- # block<Proc>:: an optional block that returns the value to be used in diff
180
- #
181
- def file_collision(destination)
182
- return true if @always_force
183
- options = block_given? ? "[Ynaqdh]" : "[Ynaqh]"
184
-
185
- while true
186
- answer = ask %[Overwrite #{destination}? (enter "h" for help) #{options}]
187
-
188
- case answer
189
- when is?(:yes), is?(:force), ""
190
- return true
191
- when is?(:no), is?(:skip)
192
- return false
193
- when is?(:always)
194
- return @always_force = true
195
- when is?(:quit)
196
- say 'Aborting...'
197
- raise SystemExit
198
- when is?(:diff)
199
- show_diff(destination, yield) if block_given?
200
- say 'Retrying...'
201
- else
202
- say file_collision_help
203
- end
204
- end
205
- end
206
-
207
- # Called if something goes wrong during the execution. This is used by Thor
208
- # internally and should not be used inside your scripts. If something went
209
- # wrong, you can always raise an exception. If you raise a Thor::Error, it
210
- # will be rescued and wrapped in the method below.
211
- #
212
- def error(statement)
213
- stderr.puts statement
214
- end
215
-
216
- # Apply color to the given string with optional bold. Disabled in the
217
- # Thor::Shell::Basic class.
218
- #
219
- def set_color(string, color, bold=false) #:nodoc:
220
- string
221
- end
222
-
223
- protected
224
-
225
- def stdout
226
- $stdout
227
- end
228
-
229
- def stdin
230
- $stdin
231
- end
232
-
233
- def stderr
234
- $stderr
235
- end
236
-
237
- def is?(value) #:nodoc:
238
- value = value.to_s
239
-
240
- if value.size == 1
241
- /\A#{value}\z/i
242
- else
243
- /\A(#{value}|#{value[0,1]})\z/i
244
- end
245
- end
246
-
247
- def file_collision_help #:nodoc:
248
- <<HELP
249
- Y - yes, overwrite
250
- n - no, do not overwrite
251
- a - all, overwrite this and all others
252
- q - quit, abort
253
- d - diff, show the differences between the old and the new
254
- h - help, show this help
255
- HELP
256
- end
257
-
258
- def show_diff(destination, content) #:nodoc:
259
- diff_cmd = ENV['THOR_DIFF'] || ENV['RAILS_DIFF'] || 'diff -u'
260
-
261
- Tempfile.open(File.basename(destination), File.dirname(destination)) do |temp|
262
- temp.write content
263
- temp.rewind
264
- system %(#{diff_cmd} "#{destination}" "#{temp.path}")
265
- end
266
- end
267
-
268
- def quiet? #:nodoc:
269
- mute? || (base && base.options[:quiet])
270
- end
271
-
272
- # This code was copied from Rake, available under MIT-LICENSE
273
- # Copyright (c) 2003, 2004 Jim Weirich
274
- def terminal_width
275
- if ENV['THOR_COLUMNS']
276
- result = ENV['THOR_COLUMNS'].to_i
277
- else
278
- result = unix? ? dynamic_width : 80
279
- end
280
- (result < 10) ? 80 : result
281
- rescue
282
- 80
283
- end
284
-
285
- # Calculate the dynamic width of the terminal
286
- def dynamic_width
287
- @dynamic_width ||= (dynamic_width_stty.nonzero? || dynamic_width_tput)
288
- end
289
-
290
- def dynamic_width_stty
291
- %x{stty size 2>/dev/null}.split[1].to_i
292
- end
293
-
294
- def dynamic_width_tput
295
- %x{tput cols 2>/dev/null}.to_i
296
- end
297
-
298
- def unix?
299
- RUBY_PLATFORM =~ /(aix|darwin|linux|(net|free|open)bsd|cygwin|solaris|irix|hpux)/i
300
- end
301
-
302
- def truncate(string, width)
303
- if string.length <= width
304
- string
305
- else
306
- ( string[0, width-3] || "" ) + "..."
307
- end
308
- end
309
-
310
- def ask_simply(statement, color = nil)
311
- say("#{statement} ", color)
312
- stdin.gets.strip
313
- end
314
-
315
- def ask_filtered(statement, answer_set, *args)
316
- correct_answer = nil
317
-
318
- until correct_answer
319
- answer = ask_simply("#{statement} #{answer_set.inspect}", *args)
320
-
321
- correct_answer = answer_set.include?(answer) ? answer : nil
322
-
323
- answers = answer_set.map(&:inspect).join(", ")
324
- say("Your response must be one of: [#{answers}]. Please try again.") unless correct_answer
325
- end
326
-
327
- correct_answer
328
- end
329
- end
330
- end
331
- end
@@ -1,108 +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 Color < Basic
9
- # Embed in a String to clear all previous ANSI sequences.
10
- CLEAR = "\e[0m"
11
- # The start of an ANSI bold sequence.
12
- BOLD = "\e[1m"
13
-
14
- # Set the terminal's foreground ANSI color to black.
15
- BLACK = "\e[30m"
16
- # Set the terminal's foreground ANSI color to red.
17
- RED = "\e[31m"
18
- # Set the terminal's foreground ANSI color to green.
19
- GREEN = "\e[32m"
20
- # Set the terminal's foreground ANSI color to yellow.
21
- YELLOW = "\e[33m"
22
- # Set the terminal's foreground ANSI color to blue.
23
- BLUE = "\e[34m"
24
- # Set the terminal's foreground ANSI color to magenta.
25
- MAGENTA = "\e[35m"
26
- # Set the terminal's foreground ANSI color to cyan.
27
- CYAN = "\e[36m"
28
- # Set the terminal's foreground ANSI color to white.
29
- WHITE = "\e[37m"
30
-
31
- # Set the terminal's background ANSI color to black.
32
- ON_BLACK = "\e[40m"
33
- # Set the terminal's background ANSI color to red.
34
- ON_RED = "\e[41m"
35
- # Set the terminal's background ANSI color to green.
36
- ON_GREEN = "\e[42m"
37
- # Set the terminal's background ANSI color to yellow.
38
- ON_YELLOW = "\e[43m"
39
- # Set the terminal's background ANSI color to blue.
40
- ON_BLUE = "\e[44m"
41
- # Set the terminal's background ANSI color to magenta.
42
- ON_MAGENTA = "\e[45m"
43
- # Set the terminal's background ANSI color to cyan.
44
- ON_CYAN = "\e[46m"
45
- # Set the terminal's background ANSI color to white.
46
- ON_WHITE = "\e[47m"
47
-
48
- # Set color by using a string or one of the defined constants. If a third
49
- # option is set to true, it also adds bold to the string. This is based
50
- # on Highline implementation and it automatically appends CLEAR to the end
51
- # of the returned String.
52
- #
53
- def set_color(string, color, bold=false)
54
- color = self.class.const_get(color.to_s.upcase) if color.is_a?(Symbol)
55
- bold = bold ? BOLD : ""
56
- "#{bold}#{color}#{string}#{CLEAR}"
57
- end
58
-
59
- protected
60
-
61
- # Overwrite show_diff to show diff with colors if Diff::LCS is
62
- # available.
63
- #
64
- def show_diff(destination, content) #:nodoc:
65
- if diff_lcs_loaded? && ENV['THOR_DIFF'].nil? && ENV['RAILS_DIFF'].nil?
66
- actual = File.binread(destination).to_s.split("\n")
67
- content = content.to_s.split("\n")
68
-
69
- Diff::LCS.sdiff(actual, content).each do |diff|
70
- output_diff_line(diff)
71
- end
72
- else
73
- super
74
- end
75
- end
76
-
77
- def output_diff_line(diff) #:nodoc:
78
- case diff.action
79
- when '-'
80
- say "- #{diff.old_element.chomp}", :red, true
81
- when '+'
82
- say "+ #{diff.new_element.chomp}", :green, true
83
- when '!'
84
- say "- #{diff.old_element.chomp}", :red, true
85
- say "+ #{diff.new_element.chomp}", :green, true
86
- else
87
- say " #{diff.old_element.chomp}", nil, true
88
- end
89
- end
90
-
91
- # Check if Diff::LCS is loaded. If it is, use it to create pretty output
92
- # for diff.
93
- #
94
- def diff_lcs_loaded? #:nodoc:
95
- return true if defined?(Diff::LCS)
96
- return @diff_lcs_loaded unless @diff_lcs_loaded.nil?
97
-
98
- @diff_lcs_loaded = begin
99
- require 'diff/lcs'
100
- true
101
- rescue LoadError
102
- false
103
- end
104
- end
105
-
106
- end
107
- end
108
- end