engineyard-serverside 1.5.21 → 1.5.23.ruby19
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/engineyard-serverside/cli.rb +39 -45
- data/lib/engineyard-serverside/configuration.rb +28 -4
- data/lib/engineyard-serverside/deploy.rb +5 -4
- data/lib/engineyard-serverside/logged_output.rb +3 -5
- data/lib/engineyard-serverside/server.rb +26 -2
- data/lib/engineyard-serverside/task.rb +2 -4
- data/lib/engineyard-serverside/version.rb +1 -1
- data/lib/engineyard-serverside.rb +8 -20
- data/spec/basic_deploy_spec.rb +1 -1
- data/spec/bundler_deploy_spec.rb +1 -1
- data/spec/nodejs_deploy_spec.rb +1 -1
- data/spec/rails31_deploy_spec.rb +1 -1
- data/spec/services_deploy_spec.rb +1 -1
- metadata +80 -233
- data/lib/vendor/dataflow/HISTORY +0 -52
- data/lib/vendor/dataflow/LICENSE +0 -19
- data/lib/vendor/dataflow/README.textile +0 -290
- data/lib/vendor/dataflow/Rakefile +0 -36
- data/lib/vendor/dataflow/dataflow/actor.rb +0 -22
- data/lib/vendor/dataflow/dataflow/equality.rb +0 -44
- data/lib/vendor/dataflow/dataflow/future_queue.rb +0 -24
- data/lib/vendor/dataflow/dataflow/port.rb +0 -54
- data/lib/vendor/dataflow/dataflow.rb +0 -124
- data/lib/vendor/dataflow/examples/barrier.rb +0 -9
- data/lib/vendor/dataflow/examples/data_driven.rb +0 -17
- data/lib/vendor/dataflow/examples/dataflow_http_gets.rb +0 -13
- data/lib/vendor/dataflow/examples/flow.rb +0 -20
- data/lib/vendor/dataflow/examples/future_http_gets.rb +0 -12
- data/lib/vendor/dataflow/examples/future_queue.rb +0 -11
- data/lib/vendor/dataflow/examples/instance_variables.rb +0 -15
- data/lib/vendor/dataflow/examples/laziness.rb +0 -9
- data/lib/vendor/dataflow/examples/local_variables.rb +0 -11
- data/lib/vendor/dataflow/examples/messages.rb +0 -26
- data/lib/vendor/dataflow/examples/port_http_gets.rb +0 -13
- data/lib/vendor/dataflow/examples/port_send.rb +0 -10
- data/lib/vendor/dataflow/examples/ring.rb +0 -21
- data/lib/vendor/dataflow/spec/actor_spec.rb +0 -28
- data/lib/vendor/dataflow/spec/anonymous_variables_spec.rb +0 -21
- data/lib/vendor/dataflow/spec/barrier_spec.rb +0 -25
- data/lib/vendor/dataflow/spec/by_need_spec.rb +0 -55
- data/lib/vendor/dataflow/spec/dataflow_spec.rb +0 -151
- data/lib/vendor/dataflow/spec/equality_spec.rb +0 -40
- data/lib/vendor/dataflow/spec/flow_spec.rb +0 -25
- data/lib/vendor/dataflow/spec/forker_spec.rb +0 -28
- data/lib/vendor/dataflow/spec/future_queue_spec.rb +0 -31
- data/lib/vendor/dataflow/spec/inspect_spec.rb +0 -19
- data/lib/vendor/dataflow/spec/need_later_spec.rb +0 -12
- data/lib/vendor/dataflow/spec/port_spec.rb +0 -26
- data/lib/vendor/dataflow/spec/spec.opts +0 -1
- data/lib/vendor/dataflow/spec/spec_helper.rb +0 -10
- data/lib/vendor/escape/Readme +0 -21
- data/lib/vendor/escape/doc_include/template/qualitysmith.rb +0 -631
- data/lib/vendor/json_pure/CHANGES +0 -166
- data/lib/vendor/json_pure/COPYING +0 -58
- data/lib/vendor/json_pure/GPL +0 -340
- data/lib/vendor/json_pure/README +0 -358
- data/lib/vendor/json_pure/Rakefile +0 -292
- data/lib/vendor/json_pure/TODO +0 -1
- data/lib/vendor/json_pure/VERSION +0 -1
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkComparison.log +0 -52
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_fast-autocorrelation.dat +0 -1000
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_fast.dat +0 -1001
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_pretty-autocorrelation.dat +0 -900
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_pretty.dat +0 -901
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_safe-autocorrelation.dat +0 -1000
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_safe.dat +0 -1001
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt.log +0 -261
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_fast-autocorrelation.dat +0 -1000
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_fast.dat +0 -1001
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_pretty-autocorrelation.dat +0 -1000
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_pretty.dat +0 -1001
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_safe-autocorrelation.dat +0 -1000
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_safe.dat +0 -1001
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure.log +0 -262
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails#generator-autocorrelation.dat +0 -1000
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails#generator.dat +0 -1001
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails.log +0 -82
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkComparison.log +0 -34
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt#parser-autocorrelation.dat +0 -900
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt#parser.dat +0 -901
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt.log +0 -81
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure#parser-autocorrelation.dat +0 -1000
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure#parser.dat +0 -1001
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure.log +0 -82
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails#parser-autocorrelation.dat +0 -1000
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails#parser.dat +0 -1001
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails.log +0 -82
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML#parser-autocorrelation.dat +0 -1000
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML#parser.dat +0 -1001
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML.log +0 -82
- data/lib/vendor/json_pure/benchmarks/generator2_benchmark.rb +0 -222
- data/lib/vendor/json_pure/benchmarks/generator_benchmark.rb +0 -224
- data/lib/vendor/json_pure/benchmarks/ohai.json +0 -1216
- data/lib/vendor/json_pure/benchmarks/ohai.ruby +0 -1
- data/lib/vendor/json_pure/benchmarks/parser2_benchmark.rb +0 -251
- data/lib/vendor/json_pure/benchmarks/parser_benchmark.rb +0 -259
- data/lib/vendor/json_pure/bin/edit_json.rb +0 -9
- data/lib/vendor/json_pure/bin/prettify_json.rb +0 -75
- data/lib/vendor/json_pure/data/example.json +0 -1
- data/lib/vendor/json_pure/data/index.html +0 -38
- data/lib/vendor/json_pure/data/prototype.js +0 -4184
- data/lib/vendor/json_pure/ext/json/ext/generator/extconf.rb +0 -16
- data/lib/vendor/json_pure/ext/json/ext/generator/generator.c +0 -1323
- data/lib/vendor/json_pure/ext/json/ext/generator/generator.h +0 -170
- data/lib/vendor/json_pure/ext/json/ext/parser/extconf.rb +0 -15
- data/lib/vendor/json_pure/ext/json/ext/parser/parser.c +0 -1935
- data/lib/vendor/json_pure/ext/json/ext/parser/parser.h +0 -71
- data/lib/vendor/json_pure/ext/json/ext/parser/parser.rl +0 -792
- data/lib/vendor/json_pure/install.rb +0 -26
- data/lib/vendor/json_pure/tests/fixtures/fail1.json +0 -1
- data/lib/vendor/json_pure/tests/fixtures/fail10.json +0 -1
- data/lib/vendor/json_pure/tests/fixtures/fail11.json +0 -1
- data/lib/vendor/json_pure/tests/fixtures/fail12.json +0 -1
- data/lib/vendor/json_pure/tests/fixtures/fail13.json +0 -1
- data/lib/vendor/json_pure/tests/fixtures/fail14.json +0 -1
- data/lib/vendor/json_pure/tests/fixtures/fail18.json +0 -1
- data/lib/vendor/json_pure/tests/fixtures/fail19.json +0 -1
- data/lib/vendor/json_pure/tests/fixtures/fail2.json +0 -1
- data/lib/vendor/json_pure/tests/fixtures/fail20.json +0 -1
- data/lib/vendor/json_pure/tests/fixtures/fail21.json +0 -1
- data/lib/vendor/json_pure/tests/fixtures/fail22.json +0 -1
- data/lib/vendor/json_pure/tests/fixtures/fail23.json +0 -1
- data/lib/vendor/json_pure/tests/fixtures/fail24.json +0 -1
- data/lib/vendor/json_pure/tests/fixtures/fail25.json +0 -1
- data/lib/vendor/json_pure/tests/fixtures/fail27.json +0 -2
- data/lib/vendor/json_pure/tests/fixtures/fail28.json +0 -2
- data/lib/vendor/json_pure/tests/fixtures/fail3.json +0 -1
- data/lib/vendor/json_pure/tests/fixtures/fail4.json +0 -1
- data/lib/vendor/json_pure/tests/fixtures/fail5.json +0 -1
- data/lib/vendor/json_pure/tests/fixtures/fail6.json +0 -1
- data/lib/vendor/json_pure/tests/fixtures/fail7.json +0 -1
- data/lib/vendor/json_pure/tests/fixtures/fail8.json +0 -1
- data/lib/vendor/json_pure/tests/fixtures/fail9.json +0 -1
- data/lib/vendor/json_pure/tests/fixtures/pass1.json +0 -56
- data/lib/vendor/json_pure/tests/fixtures/pass15.json +0 -1
- data/lib/vendor/json_pure/tests/fixtures/pass16.json +0 -1
- data/lib/vendor/json_pure/tests/fixtures/pass17.json +0 -1
- data/lib/vendor/json_pure/tests/fixtures/pass2.json +0 -1
- data/lib/vendor/json_pure/tests/fixtures/pass26.json +0 -1
- data/lib/vendor/json_pure/tests/fixtures/pass3.json +0 -6
- data/lib/vendor/json_pure/tests/test_json.rb +0 -361
- data/lib/vendor/json_pure/tests/test_json_addition.rb +0 -162
- data/lib/vendor/json_pure/tests/test_json_encoding.rb +0 -68
- data/lib/vendor/json_pure/tests/test_json_fixtures.rb +0 -34
- data/lib/vendor/json_pure/tests/test_json_generate.rb +0 -122
- data/lib/vendor/json_pure/tests/test_json_rails.rb +0 -144
- data/lib/vendor/json_pure/tests/test_json_unicode.rb +0 -76
- data/lib/vendor/json_pure/tools/fuzz.rb +0 -139
- data/lib/vendor/json_pure/tools/server.rb +0 -61
- data/lib/vendor/open4/lib/open4.rb +0 -403
- data/lib/vendor/thor/CHANGELOG.rdoc +0 -89
- data/lib/vendor/thor/LICENSE +0 -20
- data/lib/vendor/thor/README.rdoc +0 -297
- data/lib/vendor/thor/Thorfile +0 -69
- data/lib/vendor/thor/bin/rake2thor +0 -86
- data/lib/vendor/thor/bin/thor +0 -6
- data/lib/vendor/thor/lib/thor/actions/create_file.rb +0 -103
- data/lib/vendor/thor/lib/thor/actions/directory.rb +0 -91
- data/lib/vendor/thor/lib/thor/actions/empty_directory.rb +0 -134
- data/lib/vendor/thor/lib/thor/actions/file_manipulation.rb +0 -223
- data/lib/vendor/thor/lib/thor/actions/inject_into_file.rb +0 -104
- data/lib/vendor/thor/lib/thor/actions.rb +0 -275
- data/lib/vendor/thor/lib/thor/base.rb +0 -540
- 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 -30
- data/lib/vendor/thor/lib/thor/group.rb +0 -271
- data/lib/vendor/thor/lib/thor/invocation.rb +0 -180
- data/lib/vendor/thor/lib/thor/parser/argument.rb +0 -67
- data/lib/vendor/thor/lib/thor/parser/arguments.rb +0 -150
- data/lib/vendor/thor/lib/thor/parser/option.rb +0 -128
- data/lib/vendor/thor/lib/thor/parser/options.rb +0 -169
- data/lib/vendor/thor/lib/thor/parser.rb +0 -4
- data/lib/vendor/thor/lib/thor/rake_compat.rb +0 -66
- data/lib/vendor/thor/lib/thor/runner.rb +0 -314
- data/lib/vendor/thor/lib/thor/shell/basic.rb +0 -239
- data/lib/vendor/thor/lib/thor/shell/color.rb +0 -108
- data/lib/vendor/thor/lib/thor/shell.rb +0 -83
- data/lib/vendor/thor/lib/thor/task.rb +0 -102
- data/lib/vendor/thor/lib/thor/util.rb +0 -230
- data/lib/vendor/thor/lib/thor/version.rb +0 -3
- data/lib/vendor/thor/lib/thor.rb +0 -244
- data/lib/vendor/thor/thor.gemspec +0 -120
@@ -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)
|
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
|
@@ -1,180 +0,0 @@
|
|
1
|
-
class Thor
|
2
|
-
module Invocation
|
3
|
-
def self.included(base) #:nodoc:
|
4
|
-
base.extend ClassMethods
|
5
|
-
end
|
6
|
-
|
7
|
-
module ClassMethods
|
8
|
-
# This method is responsible for receiving a name and find the proper
|
9
|
-
# class and task for it. The key is an optional parameter which is
|
10
|
-
# available only in class methods invocations (i.e. in Thor::Group).
|
11
|
-
def prepare_for_invocation(key, name) #:nodoc:
|
12
|
-
case name
|
13
|
-
when Symbol, String
|
14
|
-
Thor::Util.find_class_and_task_by_namespace(name.to_s)
|
15
|
-
else
|
16
|
-
name
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
# Make initializer aware of invocations and the initialization args.
|
22
|
-
def initialize(args=[], options={}, config={}, &block) #:nodoc:
|
23
|
-
@_invocations = config[:invocations] || Hash.new { |h,k| h[k] = [] }
|
24
|
-
@_initializer = [ args, options, config ]
|
25
|
-
super
|
26
|
-
end
|
27
|
-
|
28
|
-
# Receives a name and invokes it. The name can be a string (either "task" or
|
29
|
-
# "namespace:task"), a Thor::Task, a Class or a Thor instance. If the task
|
30
|
-
# cannot be guessed by name, it can also be supplied as second argument.
|
31
|
-
#
|
32
|
-
# You can also supply the arguments, options and configuration values for
|
33
|
-
# the task to be invoked, if none is given, the same values used to
|
34
|
-
# initialize the invoker are used to initialize the invoked.
|
35
|
-
#
|
36
|
-
# When no name is given, it will invoke the default task of the current class.
|
37
|
-
#
|
38
|
-
# ==== Examples
|
39
|
-
#
|
40
|
-
# class A < Thor
|
41
|
-
# def foo
|
42
|
-
# invoke :bar
|
43
|
-
# invoke "b:hello", ["José"]
|
44
|
-
# end
|
45
|
-
#
|
46
|
-
# def bar
|
47
|
-
# invoke "b:hello", ["José"]
|
48
|
-
# end
|
49
|
-
# end
|
50
|
-
#
|
51
|
-
# class B < Thor
|
52
|
-
# def hello(name)
|
53
|
-
# puts "hello #{name}"
|
54
|
-
# end
|
55
|
-
# end
|
56
|
-
#
|
57
|
-
# You can notice that the method "foo" above invokes two tasks: "bar",
|
58
|
-
# which belongs to the same class and "hello" which belongs to the class B.
|
59
|
-
#
|
60
|
-
# By using an invocation system you ensure that a task is invoked only once.
|
61
|
-
# In the example above, invoking "foo" will invoke "b:hello" just once, even
|
62
|
-
# if it's invoked later by "bar" method.
|
63
|
-
#
|
64
|
-
# When class A invokes class B, all arguments used on A initialization are
|
65
|
-
# supplied to B. This allows lazy parse of options. Let's suppose you have
|
66
|
-
# some rspec tasks:
|
67
|
-
#
|
68
|
-
# class Rspec < Thor::Group
|
69
|
-
# class_option :mock_framework, :type => :string, :default => :rr
|
70
|
-
#
|
71
|
-
# def invoke_mock_framework
|
72
|
-
# invoke "rspec:#{options[:mock_framework]}"
|
73
|
-
# end
|
74
|
-
# end
|
75
|
-
#
|
76
|
-
# As you noticed, it invokes the given mock framework, which might have its
|
77
|
-
# own options:
|
78
|
-
#
|
79
|
-
# class Rspec::RR < Thor::Group
|
80
|
-
# class_option :style, :type => :string, :default => :mock
|
81
|
-
# end
|
82
|
-
#
|
83
|
-
# Since it's not rspec concern to parse mock framework options, when RR
|
84
|
-
# is invoked all options are parsed again, so RR can extract only the options
|
85
|
-
# that it's going to use.
|
86
|
-
#
|
87
|
-
# If you want Rspec::RR to be initialized with its own set of options, you
|
88
|
-
# have to do that explicitely:
|
89
|
-
#
|
90
|
-
# invoke "rspec:rr", [], :style => :foo
|
91
|
-
#
|
92
|
-
# Besides giving an instance, you can also give a class to invoke:
|
93
|
-
#
|
94
|
-
# invoke Rspec::RR, [], :style => :foo
|
95
|
-
#
|
96
|
-
def invoke(name=nil, *args)
|
97
|
-
args.unshift(nil) if Array === args.first || NilClass === args.first
|
98
|
-
task, args, opts, config = args
|
99
|
-
|
100
|
-
object, task = _prepare_for_invocation(name, task)
|
101
|
-
klass, instance = _initialize_klass_with_initializer(object, args, opts, config)
|
102
|
-
|
103
|
-
method_args = []
|
104
|
-
current = @_invocations[klass]
|
105
|
-
|
106
|
-
iterator = proc do |_, task|
|
107
|
-
unless current.include?(task.name)
|
108
|
-
current << task.name
|
109
|
-
task.run(instance, method_args)
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
if task
|
114
|
-
args ||= []
|
115
|
-
method_args = args[Range.new(klass.arguments.size, -1)] || []
|
116
|
-
iterator.call(nil, task)
|
117
|
-
else
|
118
|
-
klass.all_tasks.map(&iterator)
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
# Invokes using shell padding.
|
123
|
-
def invoke_with_padding(*args)
|
124
|
-
with_padding { invoke(*args) }
|
125
|
-
end
|
126
|
-
|
127
|
-
protected
|
128
|
-
|
129
|
-
# Configuration values that are shared between invocations.
|
130
|
-
def _shared_configuration #:nodoc:
|
131
|
-
{ :invocations => @_invocations }
|
132
|
-
end
|
133
|
-
|
134
|
-
# This method can receive several different types of arguments and it's then
|
135
|
-
# responsible to normalize them by returning the object where the task should
|
136
|
-
# be invoked and a Thor::Task object.
|
137
|
-
def _prepare_for_invocation(name, sent_task=nil) #:nodoc:
|
138
|
-
if name.is_a?(Thor::Task)
|
139
|
-
task = name
|
140
|
-
elsif task = self.class.all_tasks[name.to_s]
|
141
|
-
object = self
|
142
|
-
else
|
143
|
-
object, task = self.class.prepare_for_invocation(nil, name)
|
144
|
-
task ||= sent_task
|
145
|
-
end
|
146
|
-
|
147
|
-
# If the object was not set, use self and use the name as task.
|
148
|
-
object, task = self, name unless object
|
149
|
-
return object, _validate_task(object, task)
|
150
|
-
end
|
151
|
-
|
152
|
-
# Check if the object given is a Thor class object and get a task object
|
153
|
-
# for it.
|
154
|
-
def _validate_task(object, task) #:nodoc:
|
155
|
-
klass = object.is_a?(Class) ? object : object.class
|
156
|
-
raise "Expected Thor class, got #{klass}" unless klass <= Thor::Base
|
157
|
-
|
158
|
-
task ||= klass.default_task if klass.respond_to?(:default_task)
|
159
|
-
task = klass.all_tasks[task.to_s] || Thor::Task::Dynamic.new(task) if task && !task.is_a?(Thor::Task)
|
160
|
-
task
|
161
|
-
end
|
162
|
-
|
163
|
-
# Initialize klass using values stored in the @_initializer.
|
164
|
-
def _initialize_klass_with_initializer(object, args, opts, config) #:nodoc:
|
165
|
-
if object.is_a?(Class)
|
166
|
-
klass = object
|
167
|
-
|
168
|
-
stored_args, stored_opts, stored_config = @_initializer
|
169
|
-
args ||= stored_args.dup
|
170
|
-
opts ||= stored_opts.dup
|
171
|
-
|
172
|
-
config ||= {}
|
173
|
-
config = stored_config.merge(_shared_configuration).merge!(config)
|
174
|
-
[ klass, klass.new(args, opts, config) ]
|
175
|
-
else
|
176
|
-
[ object.class, object ]
|
177
|
-
end
|
178
|
-
end
|
179
|
-
end
|
180
|
-
end
|
@@ -1,67 +0,0 @@
|
|
1
|
-
class Thor
|
2
|
-
class Argument #:nodoc:
|
3
|
-
VALID_TYPES = [ :numeric, :hash, :array, :string ]
|
4
|
-
|
5
|
-
attr_reader :name, :description, :required, :type, :default, :banner
|
6
|
-
alias :human_name :name
|
7
|
-
|
8
|
-
def initialize(name, description=nil, required=true, type=:string, default=nil, banner=nil)
|
9
|
-
class_name = self.class.name.split("::").last
|
10
|
-
|
11
|
-
raise ArgumentError, "#{class_name} name can't be nil." if name.nil?
|
12
|
-
raise ArgumentError, "Type :#{type} is not valid for #{class_name.downcase}s." if type && !valid_type?(type)
|
13
|
-
|
14
|
-
@name = name.to_s
|
15
|
-
@description = description
|
16
|
-
@required = required || false
|
17
|
-
@type = (type || :string).to_sym
|
18
|
-
@default = default
|
19
|
-
@banner = banner || default_banner
|
20
|
-
|
21
|
-
validate! # Trigger specific validations
|
22
|
-
end
|
23
|
-
|
24
|
-
def usage
|
25
|
-
required? ? banner : "[#{banner}]"
|
26
|
-
end
|
27
|
-
|
28
|
-
def required?
|
29
|
-
required
|
30
|
-
end
|
31
|
-
|
32
|
-
def show_default?
|
33
|
-
case default
|
34
|
-
when Array, String, Hash
|
35
|
-
!default.empty?
|
36
|
-
else
|
37
|
-
default
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
protected
|
42
|
-
|
43
|
-
def validate!
|
44
|
-
raise ArgumentError, "An argument cannot be required and have default value." if required? && !default.nil?
|
45
|
-
end
|
46
|
-
|
47
|
-
def valid_type?(type)
|
48
|
-
VALID_TYPES.include?(type.to_sym)
|
49
|
-
end
|
50
|
-
|
51
|
-
def default_banner
|
52
|
-
case type
|
53
|
-
when :boolean
|
54
|
-
nil
|
55
|
-
when :string, :default
|
56
|
-
human_name.upcase
|
57
|
-
when :numeric
|
58
|
-
"N"
|
59
|
-
when :hash
|
60
|
-
"key:value"
|
61
|
-
when :array
|
62
|
-
"one two three"
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
end
|
67
|
-
end
|