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.
Files changed (184) hide show
  1. data/lib/engineyard-serverside/cli.rb +39 -45
  2. data/lib/engineyard-serverside/configuration.rb +28 -4
  3. data/lib/engineyard-serverside/deploy.rb +5 -4
  4. data/lib/engineyard-serverside/logged_output.rb +3 -5
  5. data/lib/engineyard-serverside/server.rb +26 -2
  6. data/lib/engineyard-serverside/task.rb +2 -4
  7. data/lib/engineyard-serverside/version.rb +1 -1
  8. data/lib/engineyard-serverside.rb +8 -20
  9. data/spec/basic_deploy_spec.rb +1 -1
  10. data/spec/bundler_deploy_spec.rb +1 -1
  11. data/spec/nodejs_deploy_spec.rb +1 -1
  12. data/spec/rails31_deploy_spec.rb +1 -1
  13. data/spec/services_deploy_spec.rb +1 -1
  14. metadata +80 -233
  15. data/lib/vendor/dataflow/HISTORY +0 -52
  16. data/lib/vendor/dataflow/LICENSE +0 -19
  17. data/lib/vendor/dataflow/README.textile +0 -290
  18. data/lib/vendor/dataflow/Rakefile +0 -36
  19. data/lib/vendor/dataflow/dataflow/actor.rb +0 -22
  20. data/lib/vendor/dataflow/dataflow/equality.rb +0 -44
  21. data/lib/vendor/dataflow/dataflow/future_queue.rb +0 -24
  22. data/lib/vendor/dataflow/dataflow/port.rb +0 -54
  23. data/lib/vendor/dataflow/dataflow.rb +0 -124
  24. data/lib/vendor/dataflow/examples/barrier.rb +0 -9
  25. data/lib/vendor/dataflow/examples/data_driven.rb +0 -17
  26. data/lib/vendor/dataflow/examples/dataflow_http_gets.rb +0 -13
  27. data/lib/vendor/dataflow/examples/flow.rb +0 -20
  28. data/lib/vendor/dataflow/examples/future_http_gets.rb +0 -12
  29. data/lib/vendor/dataflow/examples/future_queue.rb +0 -11
  30. data/lib/vendor/dataflow/examples/instance_variables.rb +0 -15
  31. data/lib/vendor/dataflow/examples/laziness.rb +0 -9
  32. data/lib/vendor/dataflow/examples/local_variables.rb +0 -11
  33. data/lib/vendor/dataflow/examples/messages.rb +0 -26
  34. data/lib/vendor/dataflow/examples/port_http_gets.rb +0 -13
  35. data/lib/vendor/dataflow/examples/port_send.rb +0 -10
  36. data/lib/vendor/dataflow/examples/ring.rb +0 -21
  37. data/lib/vendor/dataflow/spec/actor_spec.rb +0 -28
  38. data/lib/vendor/dataflow/spec/anonymous_variables_spec.rb +0 -21
  39. data/lib/vendor/dataflow/spec/barrier_spec.rb +0 -25
  40. data/lib/vendor/dataflow/spec/by_need_spec.rb +0 -55
  41. data/lib/vendor/dataflow/spec/dataflow_spec.rb +0 -151
  42. data/lib/vendor/dataflow/spec/equality_spec.rb +0 -40
  43. data/lib/vendor/dataflow/spec/flow_spec.rb +0 -25
  44. data/lib/vendor/dataflow/spec/forker_spec.rb +0 -28
  45. data/lib/vendor/dataflow/spec/future_queue_spec.rb +0 -31
  46. data/lib/vendor/dataflow/spec/inspect_spec.rb +0 -19
  47. data/lib/vendor/dataflow/spec/need_later_spec.rb +0 -12
  48. data/lib/vendor/dataflow/spec/port_spec.rb +0 -26
  49. data/lib/vendor/dataflow/spec/spec.opts +0 -1
  50. data/lib/vendor/dataflow/spec/spec_helper.rb +0 -10
  51. data/lib/vendor/escape/Readme +0 -21
  52. data/lib/vendor/escape/doc_include/template/qualitysmith.rb +0 -631
  53. data/lib/vendor/json_pure/CHANGES +0 -166
  54. data/lib/vendor/json_pure/COPYING +0 -58
  55. data/lib/vendor/json_pure/GPL +0 -340
  56. data/lib/vendor/json_pure/README +0 -358
  57. data/lib/vendor/json_pure/Rakefile +0 -292
  58. data/lib/vendor/json_pure/TODO +0 -1
  59. data/lib/vendor/json_pure/VERSION +0 -1
  60. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkComparison.log +0 -52
  61. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_fast-autocorrelation.dat +0 -1000
  62. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_fast.dat +0 -1001
  63. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_pretty-autocorrelation.dat +0 -900
  64. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_pretty.dat +0 -901
  65. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_safe-autocorrelation.dat +0 -1000
  66. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_safe.dat +0 -1001
  67. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt.log +0 -261
  68. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_fast-autocorrelation.dat +0 -1000
  69. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_fast.dat +0 -1001
  70. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_pretty-autocorrelation.dat +0 -1000
  71. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_pretty.dat +0 -1001
  72. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_safe-autocorrelation.dat +0 -1000
  73. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_safe.dat +0 -1001
  74. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure.log +0 -262
  75. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails#generator-autocorrelation.dat +0 -1000
  76. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails#generator.dat +0 -1001
  77. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails.log +0 -82
  78. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkComparison.log +0 -34
  79. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt#parser-autocorrelation.dat +0 -900
  80. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt#parser.dat +0 -901
  81. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt.log +0 -81
  82. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure#parser-autocorrelation.dat +0 -1000
  83. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure#parser.dat +0 -1001
  84. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure.log +0 -82
  85. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails#parser-autocorrelation.dat +0 -1000
  86. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails#parser.dat +0 -1001
  87. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails.log +0 -82
  88. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML#parser-autocorrelation.dat +0 -1000
  89. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML#parser.dat +0 -1001
  90. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML.log +0 -82
  91. data/lib/vendor/json_pure/benchmarks/generator2_benchmark.rb +0 -222
  92. data/lib/vendor/json_pure/benchmarks/generator_benchmark.rb +0 -224
  93. data/lib/vendor/json_pure/benchmarks/ohai.json +0 -1216
  94. data/lib/vendor/json_pure/benchmarks/ohai.ruby +0 -1
  95. data/lib/vendor/json_pure/benchmarks/parser2_benchmark.rb +0 -251
  96. data/lib/vendor/json_pure/benchmarks/parser_benchmark.rb +0 -259
  97. data/lib/vendor/json_pure/bin/edit_json.rb +0 -9
  98. data/lib/vendor/json_pure/bin/prettify_json.rb +0 -75
  99. data/lib/vendor/json_pure/data/example.json +0 -1
  100. data/lib/vendor/json_pure/data/index.html +0 -38
  101. data/lib/vendor/json_pure/data/prototype.js +0 -4184
  102. data/lib/vendor/json_pure/ext/json/ext/generator/extconf.rb +0 -16
  103. data/lib/vendor/json_pure/ext/json/ext/generator/generator.c +0 -1323
  104. data/lib/vendor/json_pure/ext/json/ext/generator/generator.h +0 -170
  105. data/lib/vendor/json_pure/ext/json/ext/parser/extconf.rb +0 -15
  106. data/lib/vendor/json_pure/ext/json/ext/parser/parser.c +0 -1935
  107. data/lib/vendor/json_pure/ext/json/ext/parser/parser.h +0 -71
  108. data/lib/vendor/json_pure/ext/json/ext/parser/parser.rl +0 -792
  109. data/lib/vendor/json_pure/install.rb +0 -26
  110. data/lib/vendor/json_pure/tests/fixtures/fail1.json +0 -1
  111. data/lib/vendor/json_pure/tests/fixtures/fail10.json +0 -1
  112. data/lib/vendor/json_pure/tests/fixtures/fail11.json +0 -1
  113. data/lib/vendor/json_pure/tests/fixtures/fail12.json +0 -1
  114. data/lib/vendor/json_pure/tests/fixtures/fail13.json +0 -1
  115. data/lib/vendor/json_pure/tests/fixtures/fail14.json +0 -1
  116. data/lib/vendor/json_pure/tests/fixtures/fail18.json +0 -1
  117. data/lib/vendor/json_pure/tests/fixtures/fail19.json +0 -1
  118. data/lib/vendor/json_pure/tests/fixtures/fail2.json +0 -1
  119. data/lib/vendor/json_pure/tests/fixtures/fail20.json +0 -1
  120. data/lib/vendor/json_pure/tests/fixtures/fail21.json +0 -1
  121. data/lib/vendor/json_pure/tests/fixtures/fail22.json +0 -1
  122. data/lib/vendor/json_pure/tests/fixtures/fail23.json +0 -1
  123. data/lib/vendor/json_pure/tests/fixtures/fail24.json +0 -1
  124. data/lib/vendor/json_pure/tests/fixtures/fail25.json +0 -1
  125. data/lib/vendor/json_pure/tests/fixtures/fail27.json +0 -2
  126. data/lib/vendor/json_pure/tests/fixtures/fail28.json +0 -2
  127. data/lib/vendor/json_pure/tests/fixtures/fail3.json +0 -1
  128. data/lib/vendor/json_pure/tests/fixtures/fail4.json +0 -1
  129. data/lib/vendor/json_pure/tests/fixtures/fail5.json +0 -1
  130. data/lib/vendor/json_pure/tests/fixtures/fail6.json +0 -1
  131. data/lib/vendor/json_pure/tests/fixtures/fail7.json +0 -1
  132. data/lib/vendor/json_pure/tests/fixtures/fail8.json +0 -1
  133. data/lib/vendor/json_pure/tests/fixtures/fail9.json +0 -1
  134. data/lib/vendor/json_pure/tests/fixtures/pass1.json +0 -56
  135. data/lib/vendor/json_pure/tests/fixtures/pass15.json +0 -1
  136. data/lib/vendor/json_pure/tests/fixtures/pass16.json +0 -1
  137. data/lib/vendor/json_pure/tests/fixtures/pass17.json +0 -1
  138. data/lib/vendor/json_pure/tests/fixtures/pass2.json +0 -1
  139. data/lib/vendor/json_pure/tests/fixtures/pass26.json +0 -1
  140. data/lib/vendor/json_pure/tests/fixtures/pass3.json +0 -6
  141. data/lib/vendor/json_pure/tests/test_json.rb +0 -361
  142. data/lib/vendor/json_pure/tests/test_json_addition.rb +0 -162
  143. data/lib/vendor/json_pure/tests/test_json_encoding.rb +0 -68
  144. data/lib/vendor/json_pure/tests/test_json_fixtures.rb +0 -34
  145. data/lib/vendor/json_pure/tests/test_json_generate.rb +0 -122
  146. data/lib/vendor/json_pure/tests/test_json_rails.rb +0 -144
  147. data/lib/vendor/json_pure/tests/test_json_unicode.rb +0 -76
  148. data/lib/vendor/json_pure/tools/fuzz.rb +0 -139
  149. data/lib/vendor/json_pure/tools/server.rb +0 -61
  150. data/lib/vendor/open4/lib/open4.rb +0 -403
  151. data/lib/vendor/thor/CHANGELOG.rdoc +0 -89
  152. data/lib/vendor/thor/LICENSE +0 -20
  153. data/lib/vendor/thor/README.rdoc +0 -297
  154. data/lib/vendor/thor/Thorfile +0 -69
  155. data/lib/vendor/thor/bin/rake2thor +0 -86
  156. data/lib/vendor/thor/bin/thor +0 -6
  157. data/lib/vendor/thor/lib/thor/actions/create_file.rb +0 -103
  158. data/lib/vendor/thor/lib/thor/actions/directory.rb +0 -91
  159. data/lib/vendor/thor/lib/thor/actions/empty_directory.rb +0 -134
  160. data/lib/vendor/thor/lib/thor/actions/file_manipulation.rb +0 -223
  161. data/lib/vendor/thor/lib/thor/actions/inject_into_file.rb +0 -104
  162. data/lib/vendor/thor/lib/thor/actions.rb +0 -275
  163. data/lib/vendor/thor/lib/thor/base.rb +0 -540
  164. data/lib/vendor/thor/lib/thor/core_ext/file_binary_read.rb +0 -9
  165. data/lib/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +0 -75
  166. data/lib/vendor/thor/lib/thor/core_ext/ordered_hash.rb +0 -100
  167. data/lib/vendor/thor/lib/thor/error.rb +0 -30
  168. data/lib/vendor/thor/lib/thor/group.rb +0 -271
  169. data/lib/vendor/thor/lib/thor/invocation.rb +0 -180
  170. data/lib/vendor/thor/lib/thor/parser/argument.rb +0 -67
  171. data/lib/vendor/thor/lib/thor/parser/arguments.rb +0 -150
  172. data/lib/vendor/thor/lib/thor/parser/option.rb +0 -128
  173. data/lib/vendor/thor/lib/thor/parser/options.rb +0 -169
  174. data/lib/vendor/thor/lib/thor/parser.rb +0 -4
  175. data/lib/vendor/thor/lib/thor/rake_compat.rb +0 -66
  176. data/lib/vendor/thor/lib/thor/runner.rb +0 -314
  177. data/lib/vendor/thor/lib/thor/shell/basic.rb +0 -239
  178. data/lib/vendor/thor/lib/thor/shell/color.rb +0 -108
  179. data/lib/vendor/thor/lib/thor/shell.rb +0 -83
  180. data/lib/vendor/thor/lib/thor/task.rb +0 -102
  181. data/lib/vendor/thor/lib/thor/util.rb +0 -230
  182. data/lib/vendor/thor/lib/thor/version.rb +0 -3
  183. data/lib/vendor/thor/lib/thor.rb +0 -244
  184. data/lib/vendor/thor/thor.gemspec +0 -120
@@ -1,83 +0,0 @@
1
- require 'rbconfig'
2
- require 'thor/shell/color'
3
-
4
- class Thor
5
- module Base
6
- # Returns the shell used in all Thor classes. If you are in a Unix platform
7
- # it will use a colored log, otherwise it will use a basic one without color.
8
- #
9
- def self.shell
10
- @shell ||= if Config::CONFIG['host_os'] =~ /mswin|mingw/
11
- Thor::Shell::Basic
12
- else
13
- Thor::Shell::Color
14
- end
15
- end
16
-
17
- # Sets the shell used in all Thor classes.
18
- #
19
- def self.shell=(klass)
20
- @shell = klass
21
- end
22
- end
23
-
24
- module Shell
25
- SHELL_DELEGATED_METHODS = [:ask, :yes?, :no?, :say, :say_status, :print_table]
26
-
27
- # Add shell to initialize config values.
28
- #
29
- # ==== Configuration
30
- # shell<Object>:: An instance of the shell to be used.
31
- #
32
- # ==== Examples
33
- #
34
- # class MyScript < Thor
35
- # argument :first, :type => :numeric
36
- # end
37
- #
38
- # MyScript.new [1.0], { :foo => :bar }, :shell => Thor::Shell::Basic.new
39
- #
40
- def initialize(args=[], options={}, config={})
41
- super
42
- self.shell = config[:shell]
43
- self.shell.base ||= self if self.shell.respond_to?(:base)
44
- end
45
-
46
- # Holds the shell for the given Thor instance. If no shell is given,
47
- # it gets a default shell from Thor::Base.shell.
48
- def shell
49
- @shell ||= Thor::Base.shell.new
50
- end
51
-
52
- # Sets the shell for this thor class.
53
- def shell=(shell)
54
- @shell = shell
55
- end
56
-
57
- # Common methods that are delegated to the shell.
58
- SHELL_DELEGATED_METHODS.each do |method|
59
- module_eval <<-METHOD, __FILE__, __LINE__
60
- def #{method}(*args)
61
- shell.#{method}(*args)
62
- end
63
- METHOD
64
- end
65
-
66
- # Yields the given block with padding.
67
- def with_padding
68
- shell.padding += 1
69
- yield
70
- ensure
71
- shell.padding -= 1
72
- end
73
-
74
- protected
75
-
76
- # Allow shell to be shared between invocations.
77
- #
78
- def _shared_configuration #:nodoc:
79
- super.merge!(:shell => self.shell)
80
- end
81
-
82
- end
83
- end
@@ -1,102 +0,0 @@
1
- class Thor
2
- class Task < Struct.new(:name, :description, :usage, :options)
3
- FILE_REGEXP = /^#{Regexp.escape(File.dirname(__FILE__))}/
4
-
5
- # A dynamic task that handles method missing scenarios.
6
- class Dynamic < Task
7
- def initialize(name, options=nil)
8
- super(name.to_s, "A dynamically-generated task", name.to_s, options)
9
- end
10
-
11
- def run(instance, args=[])
12
- if (instance.methods & [name.to_s, name.to_sym]).empty?
13
- super
14
- else
15
- instance.class.handle_no_task_error(name)
16
- end
17
- end
18
- end
19
-
20
- def initialize(name, description, usage, options=nil)
21
- super(name.to_s, description, usage, options || {})
22
- end
23
-
24
- def initialize_copy(other) #:nodoc:
25
- super(other)
26
- self.options = other.options.dup if other.options
27
- end
28
-
29
- # By default, a task invokes a method in the thor class. You can change this
30
- # implementation to create custom tasks.
31
- def run(instance, args=[])
32
- public_method?(instance) ?
33
- instance.send(name, *args) : instance.class.handle_no_task_error(name)
34
- rescue ArgumentError => e
35
- handle_argument_error?(instance, e, caller) ?
36
- instance.class.handle_argument_error(self, e) : (raise e)
37
- rescue NoMethodError => e
38
- handle_no_method_error?(instance, e, caller) ?
39
- instance.class.handle_no_task_error(name) : (raise e)
40
- end
41
-
42
- # Returns the formatted usage by injecting given required arguments
43
- # and required options into the given usage.
44
- def formatted_usage(klass, namespace=true)
45
- namespace = klass.namespace unless namespace == false
46
-
47
- # Add namespace
48
- formatted = if namespace
49
- "#{namespace.gsub(/^(default|thor:runner:)/,'')}:"
50
- else
51
- ""
52
- end
53
-
54
- # Add usage with required arguments
55
- formatted << if klass && !klass.arguments.empty?
56
- usage.to_s.gsub(/^#{name}/) do |match|
57
- match << " " << klass.arguments.map{ |a| a.usage }.compact.join(' ')
58
- end
59
- else
60
- usage.to_s
61
- end
62
-
63
- # Add required options
64
- formatted << " #{required_options}"
65
-
66
- # Strip and go!
67
- formatted.strip
68
- end
69
-
70
- protected
71
-
72
- def not_debugging?(instance)
73
- !(instance.class.respond_to?(:debugging) && instance.class.debugging)
74
- end
75
-
76
- def required_options
77
- @required_options ||= options.map{ |_, o| o.usage if o.required? }.compact.sort.join(" ")
78
- end
79
-
80
- # Given a target, checks if this class name is not a private/protected method.
81
- def public_method?(instance) #:nodoc:
82
- collection = instance.private_methods + instance.protected_methods
83
- (collection & [name.to_s, name.to_sym]).empty?
84
- end
85
-
86
- def sans_backtrace(backtrace, caller) #:nodoc:
87
- saned = backtrace.reject { |frame| frame =~ FILE_REGEXP }
88
- saned -= caller
89
- end
90
-
91
- def handle_argument_error?(instance, error, caller)
92
- not_debugging?(instance) && error.message =~ /wrong number of arguments/ &&
93
- sans_backtrace(error.backtrace, caller).empty?
94
- end
95
-
96
- def handle_no_method_error?(instance, error, caller)
97
- not_debugging?(instance) &&
98
- error.message =~ /^undefined method `#{name}' for #{Regexp.escape(instance.to_s)}$/
99
- end
100
-
101
- end
102
- end
@@ -1,230 +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::Utils.namespace_from_thor_class(Foo::Bar::Baz) #=> "foo:bar:baz"
12
- #
13
- # 2) Loading thor files and sandboxing:
14
- #
15
- # Thor::Utils.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)
132
- if namespace.include?(?:)
133
- pieces = namespace.split(":")
134
- task = pieces.pop
135
- klass = Thor::Util.find_by_namespace(pieces.join(":"))
136
- end
137
-
138
- unless klass
139
- klass, task = Thor::Util.find_by_namespace(namespace), nil
140
- end
141
-
142
- return klass, task
143
- end
144
-
145
- # The same as namespace_to_thor_class_and_task!, but raises an error if a klass
146
- # could not be found.
147
- def self.find_class_and_task_by_namespace!(namespace)
148
- klass, task = find_class_and_task_by_namespace(namespace)
149
- raise Error, "Could not find namespace or task #{namespace.inspect}." unless klass
150
- return klass, task
151
- end
152
-
153
- # Receives a path and load the thor file in the path. The file is evaluated
154
- # inside the sandbox to avoid namespacing conflicts.
155
- #
156
- def self.load_thorfile(path, content=nil)
157
- content ||= File.binread(path)
158
-
159
- begin
160
- Thor::Sandbox.class_eval(content, path)
161
- rescue Exception => e
162
- $stderr.puts "WARNING: unable to load thorfile #{path.inspect}: #{e.message}"
163
- end
164
- end
165
-
166
- def self.user_home
167
- @@user_home ||= if ENV["HOME"]
168
- ENV["HOME"]
169
- elsif ENV["USERPROFILE"]
170
- ENV["USERPROFILE"]
171
- elsif ENV["HOMEDRIVE"] && ENV["HOMEPATH"]
172
- File.join(ENV["HOMEDRIVE"], ENV["HOMEPATH"])
173
- elsif ENV["APPDATA"]
174
- ENV["APPDATA"]
175
- else
176
- begin
177
- File.expand_path("~")
178
- rescue
179
- if File::ALT_SEPARATOR
180
- "C:/"
181
- else
182
- "/"
183
- end
184
- end
185
- end
186
- end
187
-
188
- # Returns the root where thor files are located, dependending on the OS.
189
- #
190
- def self.thor_root
191
- File.join(user_home, ".thor").gsub(/\\/, '/')
192
- end
193
-
194
- # Returns the files in the thor root. On Windows thor_root will be something
195
- # like this:
196
- #
197
- # C:\Documents and Settings\james\.thor
198
- #
199
- # If we don't #gsub the \ character, Dir.glob will fail.
200
- #
201
- def self.thor_root_glob
202
- files = Dir["#{thor_root}/*"]
203
-
204
- files.map! do |file|
205
- File.directory?(file) ? File.join(file, "main.thor") : file
206
- end
207
- end
208
-
209
- # Where to look for Thor files.
210
- #
211
- def self.globs_for(path)
212
- ["#{path}/Thorfile", "#{path}/*.thor", "#{path}/tasks/*.thor", "#{path}/lib/tasks/*.thor"]
213
- end
214
-
215
- # Return the path to the ruby interpreter taking into account multiple
216
- # installations and windows extensions.
217
- #
218
- def self.ruby_command
219
- @ruby_command ||= begin
220
- ruby = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])
221
- ruby << Config::CONFIG['EXEEXT']
222
-
223
- # escape string in case path to ruby executable contain spaces.
224
- ruby.sub!(/.*\s.*/m, '"\&"')
225
- ruby
226
- end
227
- end
228
-
229
- end
230
- end
@@ -1,3 +0,0 @@
1
- class Thor
2
- VERSION = "0.13.3".freeze
3
- end
@@ -1,244 +0,0 @@
1
- require 'thor/base'
2
-
3
- # TODO: Update thor to allow for git-style CLI (git bisect run)
4
- class Thor
5
- class << self
6
- # Sets the default task when thor is executed without an explicit task to be called.
7
- #
8
- # ==== Parameters
9
- # meth<Symbol>:: name of the defaut task
10
- #
11
- def default_task(meth=nil)
12
- case meth
13
- when :none
14
- @default_task = 'help'
15
- when nil
16
- @default_task ||= from_superclass(:default_task, 'help')
17
- else
18
- @default_task = meth.to_s
19
- end
20
- end
21
-
22
- # Defines the usage and the description of the next task.
23
- #
24
- # ==== Parameters
25
- # usage<String>
26
- # description<String>
27
- #
28
- def desc(usage, description, options={})
29
- if options[:for]
30
- task = find_and_refresh_task(options[:for])
31
- task.usage = usage if usage
32
- task.description = description if description
33
- else
34
- @usage, @desc = usage, description
35
- end
36
- end
37
-
38
- # Maps an input to a task. If you define:
39
- #
40
- # map "-T" => "list"
41
- #
42
- # Running:
43
- #
44
- # thor -T
45
- #
46
- # Will invoke the list task.
47
- #
48
- # ==== Parameters
49
- # Hash[String|Array => Symbol]:: Maps the string or the strings in the array to the given task.
50
- #
51
- def map(mappings=nil)
52
- @map ||= from_superclass(:map, {})
53
-
54
- if mappings
55
- mappings.each do |key, value|
56
- if key.respond_to?(:each)
57
- key.each {|subkey| @map[subkey] = value}
58
- else
59
- @map[key] = value
60
- end
61
- end
62
- end
63
-
64
- @map
65
- end
66
-
67
- # Declares the options for the next task to be declared.
68
- #
69
- # ==== Parameters
70
- # Hash[Symbol => Object]:: The hash key is the name of the option and the value
71
- # is the type of the option. Can be :string, :array, :hash, :boolean, :numeric
72
- # or :required (string). If you give a value, the type of the value is used.
73
- #
74
- def method_options(options=nil)
75
- @method_options ||= {}
76
- build_options(options, @method_options) if options
77
- @method_options
78
- end
79
-
80
- # Adds an option to the set of method options. If :for is given as option,
81
- # it allows you to change the options from a previous defined task.
82
- #
83
- # def previous_task
84
- # # magic
85
- # end
86
- #
87
- # method_option :foo => :bar, :for => :previous_task
88
- #
89
- # def next_task
90
- # # magic
91
- # end
92
- #
93
- # ==== Parameters
94
- # name<Symbol>:: The name of the argument.
95
- # options<Hash>:: Described below.
96
- #
97
- # ==== Options
98
- # :desc - Description for the argument.
99
- # :required - If the argument is required or not.
100
- # :default - Default value for this argument. It cannot be required and have default values.
101
- # :aliases - Aliases for this option.
102
- # :type - The type of the argument, can be :string, :hash, :array, :numeric or :boolean.
103
- # :banner - String to show on usage notes.
104
- #
105
- def method_option(name, options={})
106
- scope = if options[:for]
107
- find_and_refresh_task(options[:for]).options
108
- else
109
- method_options
110
- end
111
-
112
- build_option(name, options, scope)
113
- end
114
-
115
- # Parses the task and options from the given args, instantiate the class
116
- # and invoke the task. This method is used when the arguments must be parsed
117
- # from an array. If you are inside Ruby and want to use a Thor class, you
118
- # can simply initialize it:
119
- #
120
- # script = MyScript.new(args, options, config)
121
- # script.invoke(:task, first_arg, second_arg, third_arg)
122
- #
123
- def start(original_args=ARGV, config={})
124
- super do |given_args|
125
- meth = normalize_task_name(given_args.shift)
126
- task = all_tasks[meth]
127
-
128
- if task
129
- args, opts = Thor::Options.split(given_args)
130
- config.merge!(:task_options => task.options)
131
- else
132
- args, opts = given_args, {}
133
- end
134
-
135
- task ||= Thor::Task::Dynamic.new(meth)
136
- trailing = args[Range.new(arguments.size, -1)]
137
- new(args, opts, config).invoke(task, trailing || [])
138
- end
139
- end
140
-
141
- # Prints help information for the given task.
142
- #
143
- # ==== Parameters
144
- # shell<Thor::Shell>
145
- # task_name<String>
146
- #
147
- def task_help(shell, task_name)
148
- meth = normalize_task_name(task_name)
149
- task = all_tasks[meth]
150
- handle_no_task_error(meth) unless task
151
-
152
- shell.say "Usage:"
153
- shell.say " #{banner(task)}"
154
- shell.say
155
- class_options_help(shell, nil => task.options.map { |_, o| o })
156
- shell.say task.description
157
- end
158
-
159
- # Prints help information for this class.
160
- #
161
- # ==== Parameters
162
- # shell<Thor::Shell>
163
- #
164
- def help(shell)
165
- list = printable_tasks
166
- Thor::Util.thor_classes_in(self).each do |klass|
167
- list += klass.printable_tasks(false)
168
- end
169
- list.sort!{ |a,b| a[0] <=> b[0] }
170
-
171
- shell.say "Tasks:"
172
- shell.print_table(list, :ident => 2, :truncate => true)
173
- shell.say
174
- class_options_help(shell)
175
- end
176
-
177
- # Returns tasks ready to be printed.
178
- def printable_tasks(all=true)
179
- (all ? all_tasks : tasks).map do |_, task|
180
- item = []
181
- item << banner(task)
182
- item << (task.description ? "# #{task.description.gsub(/\s+/m,' ')}" : "")
183
- item
184
- end
185
- end
186
-
187
- def handle_argument_error(task, error) #:nodoc:
188
- raise InvocationError, "#{task.name.inspect} was called incorrectly. Call as #{task.formatted_usage(self, banner_base == "thor").inspect}."
189
- end
190
-
191
- protected
192
-
193
- # The banner for this class. You can customize it if you are invoking the
194
- # thor class by another ways which is not the Thor::Runner. It receives
195
- # the task that is going to be invoked and a boolean which indicates if
196
- # the namespace should be displayed as arguments.
197
- #
198
- def banner(task)
199
- "#{banner_base} #{task.formatted_usage(self, banner_base == "thor")}"
200
- end
201
-
202
- def baseclass #:nodoc:
203
- Thor
204
- end
205
-
206
- def create_task(meth) #:nodoc:
207
- if @usage && @desc
208
- tasks[meth.to_s] = Thor::Task.new(meth, @desc, @usage, method_options)
209
- @usage, @desc, @method_options = nil
210
- true
211
- elsif self.all_tasks[meth.to_s] || meth.to_sym == :method_missing
212
- true
213
- else
214
- puts "[WARNING] Attempted to create task #{meth.inspect} without usage or description. " <<
215
- "Call desc if you want this method to be available as task or declare it inside a " <<
216
- "no_tasks{} block. Invoked from #{caller[1].inspect}."
217
- false
218
- end
219
- end
220
-
221
- def initialize_added #:nodoc:
222
- class_options.merge!(method_options)
223
- @method_options = nil
224
- end
225
-
226
- # Receives a task name (can be nil), and try to get a map from it.
227
- # If a map can't be found use the sent name or the default task.
228
- #
229
- def normalize_task_name(meth) #:nodoc:
230
- mapping = map[meth.to_s]
231
- meth = mapping || meth || default_task
232
- meth.to_s.gsub('-','_') # treat foo-bar > foo_bar
233
- end
234
- end
235
-
236
- include Thor::Base
237
-
238
- map HELP_MAPPINGS => :help
239
-
240
- desc "help [TASK]", "Describe available tasks or one specific task"
241
- def help(task=nil)
242
- task ? self.class.task_help(shell, task) : self.class.help(shell)
243
- end
244
- end