engineyard 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. data/lib/engineyard/cli.rb +11 -2
  2. data/lib/engineyard/model/environment.rb +36 -3
  3. data/lib/engineyard/model/instance.rb +1 -1
  4. data/lib/engineyard/thor.rb +50 -68
  5. data/lib/engineyard/version.rb +1 -1
  6. data/spec/ey/deploy_spec.rb +66 -0
  7. metadata +23 -36
  8. data/lib/engineyard/vendor/thor.rb +0 -270
  9. data/lib/engineyard/vendor/thor/actions.rb +0 -297
  10. data/lib/engineyard/vendor/thor/actions/create_file.rb +0 -105
  11. data/lib/engineyard/vendor/thor/actions/directory.rb +0 -93
  12. data/lib/engineyard/vendor/thor/actions/empty_directory.rb +0 -134
  13. data/lib/engineyard/vendor/thor/actions/file_manipulation.rb +0 -229
  14. data/lib/engineyard/vendor/thor/actions/inject_into_file.rb +0 -104
  15. data/lib/engineyard/vendor/thor/base.rb +0 -540
  16. data/lib/engineyard/vendor/thor/core_ext/file_binary_read.rb +0 -9
  17. data/lib/engineyard/vendor/thor/core_ext/hash_with_indifferent_access.rb +0 -75
  18. data/lib/engineyard/vendor/thor/core_ext/ordered_hash.rb +0 -100
  19. data/lib/engineyard/vendor/thor/error.rb +0 -30
  20. data/lib/engineyard/vendor/thor/group.rb +0 -271
  21. data/lib/engineyard/vendor/thor/invocation.rb +0 -180
  22. data/lib/engineyard/vendor/thor/parser.rb +0 -4
  23. data/lib/engineyard/vendor/thor/parser/argument.rb +0 -67
  24. data/lib/engineyard/vendor/thor/parser/arguments.rb +0 -161
  25. data/lib/engineyard/vendor/thor/parser/option.rb +0 -128
  26. data/lib/engineyard/vendor/thor/parser/options.rb +0 -164
  27. data/lib/engineyard/vendor/thor/rake_compat.rb +0 -66
  28. data/lib/engineyard/vendor/thor/runner.rb +0 -314
  29. data/lib/engineyard/vendor/thor/shell.rb +0 -83
  30. data/lib/engineyard/vendor/thor/shell/basic.rb +0 -268
  31. data/lib/engineyard/vendor/thor/shell/color.rb +0 -108
  32. data/lib/engineyard/vendor/thor/task.rb +0 -102
  33. data/lib/engineyard/vendor/thor/util.rb +0 -229
  34. data/lib/engineyard/vendor/thor/version.rb +0 -3
@@ -1,9 +0,0 @@
1
- class File #:nodoc:
2
-
3
- unless File.respond_to?(:binread)
4
- def self.binread(file)
5
- File.open(file, 'rb') { |f| f.read }
6
- end
7
- end
8
-
9
- end
@@ -1,75 +0,0 @@
1
- class Thor
2
- module CoreExt #:nodoc:
3
-
4
- # A hash with indifferent access and magic predicates.
5
- #
6
- # hash = Thor::CoreExt::HashWithIndifferentAccess.new 'foo' => 'bar', 'baz' => 'bee', 'force' => true
7
- #
8
- # hash[:foo] #=> 'bar'
9
- # hash['foo'] #=> 'bar'
10
- # hash.foo? #=> true
11
- #
12
- class HashWithIndifferentAccess < ::Hash #:nodoc:
13
-
14
- def initialize(hash={})
15
- super()
16
- hash.each do |key, value|
17
- self[convert_key(key)] = value
18
- end
19
- end
20
-
21
- def [](key)
22
- super(convert_key(key))
23
- end
24
-
25
- def []=(key, value)
26
- super(convert_key(key), value)
27
- end
28
-
29
- def delete(key)
30
- super(convert_key(key))
31
- end
32
-
33
- def values_at(*indices)
34
- indices.collect { |key| self[convert_key(key)] }
35
- end
36
-
37
- def merge(other)
38
- dup.merge!(other)
39
- end
40
-
41
- def merge!(other)
42
- other.each do |key, value|
43
- self[convert_key(key)] = value
44
- end
45
- self
46
- end
47
-
48
- protected
49
-
50
- def convert_key(key)
51
- key.is_a?(Symbol) ? key.to_s : key
52
- end
53
-
54
- # Magic predicates. For instance:
55
- #
56
- # options.force? # => !!options['force']
57
- # options.shebang # => "/usr/lib/local/ruby"
58
- # options.test_framework?(:rspec) # => options[:test_framework] == :rspec
59
- #
60
- def method_missing(method, *args, &block)
61
- method = method.to_s
62
- if method =~ /^(\w+)\?$/
63
- if args.empty?
64
- !!self[$1]
65
- else
66
- self[$1] == args.first
67
- end
68
- else
69
- self[method]
70
- end
71
- end
72
-
73
- end
74
- end
75
- end
@@ -1,100 +0,0 @@
1
- class Thor
2
- module CoreExt #:nodoc:
3
-
4
- if RUBY_VERSION >= '1.9'
5
- class OrderedHash < ::Hash
6
- end
7
- else
8
- # This class is based on the Ruby 1.9 ordered hashes.
9
- #
10
- # It keeps the semantics and most of the efficiency of normal hashes
11
- # while also keeping track of the order in which elements were set.
12
- #
13
- class OrderedHash #:nodoc:
14
- include Enumerable
15
-
16
- Node = Struct.new(:key, :value, :next, :prev)
17
-
18
- def initialize
19
- @hash = {}
20
- end
21
-
22
- def [](key)
23
- @hash[key] && @hash[key].value
24
- end
25
-
26
- def []=(key, value)
27
- if node = @hash[key]
28
- node.value = value
29
- else
30
- node = Node.new(key, value)
31
-
32
- if @first.nil?
33
- @first = @last = node
34
- else
35
- node.prev = @last
36
- @last.next = node
37
- @last = node
38
- end
39
- end
40
-
41
- @hash[key] = node
42
- value
43
- end
44
-
45
- def delete(key)
46
- if node = @hash[key]
47
- prev_node = node.prev
48
- next_node = node.next
49
-
50
- next_node.prev = prev_node if next_node
51
- prev_node.next = next_node if prev_node
52
-
53
- @first = next_node if @first == node
54
- @last = prev_node if @last == node
55
-
56
- value = node.value
57
- end
58
-
59
- @hash.delete(key)
60
- value
61
- end
62
-
63
- def keys
64
- self.map { |k, v| k }
65
- end
66
-
67
- def values
68
- self.map { |k, v| v }
69
- end
70
-
71
- def each
72
- return unless @first
73
- yield [@first.key, @first.value]
74
- node = @first
75
- yield [node.key, node.value] while node = node.next
76
- self
77
- end
78
-
79
- def merge(other)
80
- hash = self.class.new
81
-
82
- self.each do |key, value|
83
- hash[key] = value
84
- end
85
-
86
- other.each do |key, value|
87
- hash[key] = value
88
- end
89
-
90
- hash
91
- end
92
-
93
- def empty?
94
- @hash.empty?
95
- end
96
- end
97
- end
98
-
99
- end
100
- end
@@ -1,30 +0,0 @@
1
- class Thor
2
- # Thor::Error is raised when it's caused by wrong usage of thor classes. Those
3
- # errors have their backtrace supressed and are nicely shown to the user.
4
- #
5
- # Errors that are caused by the developer, like declaring a method which
6
- # overwrites a thor keyword, it SHOULD NOT raise a Thor::Error. This way, we
7
- # ensure that developer errors are shown with full backtrace.
8
- #
9
- class Error < StandardError
10
- end
11
-
12
- # Raised when a task was not found.
13
- #
14
- class UndefinedTaskError < Error
15
- end
16
-
17
- # Raised when a task was found, but not invoked properly.
18
- #
19
- class InvocationError < Error
20
- end
21
-
22
- class UnknownArgumentError < Error
23
- end
24
-
25
- class RequiredArgumentMissingError < InvocationError
26
- end
27
-
28
- class MalformattedArgumentError < InvocationError
29
- end
30
- end
@@ -1,271 +0,0 @@
1
- require 'thor/base'
2
-
3
- # Thor has a special class called Thor::Group. The main difference to Thor class
4
- # is that it invokes all tasks at once. It also include some methods that allows
5
- # invocations to be done at the class method, which are not available to Thor
6
- # tasks.
7
- class Thor::Group
8
- class << self
9
- # The descrition for this Thor::Group. If none is provided, but a source root
10
- # exists, tries to find the USAGE one folder above it, otherwise searches
11
- # in the superclass.
12
- #
13
- # ==== Parameters
14
- # description<String>:: The description for this Thor::Group.
15
- #
16
- def desc(description=nil)
17
- case description
18
- when nil
19
- @desc ||= from_superclass(:desc, nil)
20
- else
21
- @desc = description
22
- end
23
- end
24
-
25
- # Start works differently in Thor::Group, it simply invokes all tasks
26
- # inside the class.
27
- #
28
- def start(original_args=ARGV, config={})
29
- super do |given_args|
30
- if Thor::HELP_MAPPINGS.include?(given_args.first)
31
- help(config[:shell])
32
- return
33
- end
34
-
35
- args, opts = Thor::Options.split(given_args)
36
- new(args, opts, config).invoke
37
- end
38
- end
39
-
40
- # Prints help information.
41
- #
42
- # ==== Options
43
- # short:: When true, shows only usage.
44
- #
45
- def help(shell)
46
- shell.say "Usage:"
47
- shell.say " #{banner}\n"
48
- shell.say
49
- class_options_help(shell)
50
- shell.say self.desc if self.desc
51
- end
52
-
53
- # Stores invocations for this class merging with superclass values.
54
- #
55
- def invocations #:nodoc:
56
- @invocations ||= from_superclass(:invocations, {})
57
- end
58
-
59
- # Stores invocation blocks used on invoke_from_option.
60
- #
61
- def invocation_blocks #:nodoc:
62
- @invocation_blocks ||= from_superclass(:invocation_blocks, {})
63
- end
64
-
65
- # Invoke the given namespace or class given. It adds an instance
66
- # method that will invoke the klass and task. You can give a block to
67
- # configure how it will be invoked.
68
- #
69
- # The namespace/class given will have its options showed on the help
70
- # usage. Check invoke_from_option for more information.
71
- #
72
- def invoke(*names, &block)
73
- options = names.last.is_a?(Hash) ? names.pop : {}
74
- verbose = options.fetch(:verbose, true)
75
-
76
- names.each do |name|
77
- invocations[name] = false
78
- invocation_blocks[name] = block if block_given?
79
-
80
- class_eval <<-METHOD, __FILE__, __LINE__
81
- def _invoke_#{name.to_s.gsub(/\W/, '_')}
82
- klass, task = self.class.prepare_for_invocation(nil, #{name.inspect})
83
-
84
- if klass
85
- say_status :invoke, #{name.inspect}, #{verbose.inspect}
86
- block = self.class.invocation_blocks[#{name.inspect}]
87
- _invoke_for_class_method klass, task, &block
88
- else
89
- say_status :error, %(#{name.inspect} [not found]), :red
90
- end
91
- end
92
- METHOD
93
- end
94
- end
95
-
96
- # Invoke a thor class based on the value supplied by the user to the
97
- # given option named "name". A class option must be created before this
98
- # method is invoked for each name given.
99
- #
100
- # ==== Examples
101
- #
102
- # class GemGenerator < Thor::Group
103
- # class_option :test_framework, :type => :string
104
- # invoke_from_option :test_framework
105
- # end
106
- #
107
- # ==== Boolean options
108
- #
109
- # In some cases, you want to invoke a thor class if some option is true or
110
- # false. This is automatically handled by invoke_from_option. Then the
111
- # option name is used to invoke the generator.
112
- #
113
- # ==== Preparing for invocation
114
- #
115
- # In some cases you want to customize how a specified hook is going to be
116
- # invoked. You can do that by overwriting the class method
117
- # prepare_for_invocation. The class method must necessarily return a klass
118
- # and an optional task.
119
- #
120
- # ==== Custom invocations
121
- #
122
- # You can also supply a block to customize how the option is giong to be
123
- # invoked. The block receives two parameters, an instance of the current
124
- # class and the klass to be invoked.
125
- #
126
- def invoke_from_option(*names, &block)
127
- options = names.last.is_a?(Hash) ? names.pop : {}
128
- verbose = options.fetch(:verbose, :white)
129
-
130
- names.each do |name|
131
- unless class_options.key?(name)
132
- raise ArgumentError, "You have to define the option #{name.inspect} " <<
133
- "before setting invoke_from_option."
134
- end
135
-
136
- invocations[name] = true
137
- invocation_blocks[name] = block if block_given?
138
-
139
- class_eval <<-METHOD, __FILE__, __LINE__
140
- def _invoke_from_option_#{name.to_s.gsub(/\W/, '_')}
141
- return unless options[#{name.inspect}]
142
-
143
- value = options[#{name.inspect}]
144
- value = #{name.inspect} if TrueClass === value
145
- klass, task = self.class.prepare_for_invocation(#{name.inspect}, value)
146
-
147
- if klass
148
- say_status :invoke, value, #{verbose.inspect}
149
- block = self.class.invocation_blocks[#{name.inspect}]
150
- _invoke_for_class_method klass, task, &block
151
- else
152
- say_status :error, %(\#{value} [not found]), :red
153
- end
154
- end
155
- METHOD
156
- end
157
- end
158
-
159
- # Remove a previously added invocation.
160
- #
161
- # ==== Examples
162
- #
163
- # remove_invocation :test_framework
164
- #
165
- def remove_invocation(*names)
166
- names.each do |name|
167
- remove_task(name)
168
- remove_class_option(name)
169
- invocations.delete(name)
170
- invocation_blocks.delete(name)
171
- end
172
- end
173
-
174
- # Overwrite class options help to allow invoked generators options to be
175
- # shown recursively when invoking a generator.
176
- #
177
- def class_options_help(shell, groups={}) #:nodoc:
178
- get_options_from_invocations(groups, class_options) do |klass|
179
- klass.send(:get_options_from_invocations, groups, class_options)
180
- end
181
- super(shell, groups)
182
- end
183
-
184
- # Get invocations array and merge options from invocations. Those
185
- # options are added to group_options hash. Options that already exists
186
- # in base_options are not added twice.
187
- #
188
- def get_options_from_invocations(group_options, base_options) #:nodoc:
189
- invocations.each do |name, from_option|
190
- value = if from_option
191
- option = class_options[name]
192
- option.type == :boolean ? name : option.default
193
- else
194
- name
195
- end
196
- next unless value
197
-
198
- klass, task = prepare_for_invocation(name, value)
199
- next unless klass && klass.respond_to?(:class_options)
200
-
201
- value = value.to_s
202
- human_name = value.respond_to?(:classify) ? value.classify : value
203
-
204
- group_options[human_name] ||= []
205
- group_options[human_name] += klass.class_options.values.select do |option|
206
- base_options[option.name.to_sym].nil? && option.group.nil? &&
207
- !group_options.values.flatten.any? { |i| i.name == option.name }
208
- end
209
-
210
- yield klass if block_given?
211
- end
212
- end
213
-
214
- # Returns tasks ready to be printed.
215
- def printable_tasks(*)
216
- item = []
217
- item << banner
218
- item << (desc ? "# #{desc.gsub(/\s+/m,' ')}" : "")
219
- [item]
220
- end
221
-
222
- def handle_argument_error(task, error) #:nodoc:
223
- raise error, "#{task.name.inspect} was called incorrectly. Are you sure it has arity equals to 0?"
224
- end
225
-
226
- protected
227
-
228
- # The banner for this class. You can customize it if you are invoking the
229
- # thor class by another ways which is not the Thor::Runner.
230
- def banner
231
- "#{banner_base} #{self_task.formatted_usage(self, false)}"
232
- end
233
-
234
- # Represents the whole class as a task.
235
- def self_task #:nodoc:
236
- Thor::Task::Dynamic.new(self.namespace, class_options)
237
- end
238
-
239
- def baseclass #:nodoc:
240
- Thor::Group
241
- end
242
-
243
- def create_task(meth) #:nodoc:
244
- tasks[meth.to_s] = Thor::Task.new(meth, nil, nil, nil, nil)
245
- true
246
- end
247
- end
248
-
249
- include Thor::Base
250
-
251
- protected
252
-
253
- # Shortcut to invoke with padding and block handling. Use internally by
254
- # invoke and invoke_from_option class methods.
255
- def _invoke_for_class_method(klass, task=nil, *args, &block) #:nodoc:
256
- with_padding do
257
- if block
258
- case block.arity
259
- when 3
260
- block.call(self, klass, task)
261
- when 2
262
- block.call(self, klass)
263
- when 1
264
- instance_exec(klass, &block)
265
- end
266
- else
267
- invoke klass, task, *args
268
- end
269
- end
270
- end
271
- end