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,150 +0,0 @@
1
- class Thor
2
- class Arguments #:nodoc:
3
- NUMERIC = /(\d*\.\d+|\d+)/
4
-
5
- # Receives an array of args and returns two arrays, one with arguments
6
- # and one with switches.
7
- #
8
- def self.split(args)
9
- arguments = []
10
-
11
- args.each do |item|
12
- break if item =~ /^-/
13
- arguments << item
14
- end
15
-
16
- return arguments, args[Range.new(arguments.size, -1)]
17
- end
18
-
19
- def self.parse(*args)
20
- to_parse = args.pop
21
- new(*args).parse(to_parse)
22
- end
23
-
24
- # Takes an array of Thor::Argument objects.
25
- #
26
- def initialize(arguments=[])
27
- @assigns, @non_assigned_required = {}, []
28
- @switches = arguments
29
-
30
- arguments.each do |argument|
31
- if argument.default
32
- @assigns[argument.human_name] = argument.default
33
- elsif argument.required?
34
- @non_assigned_required << argument
35
- end
36
- end
37
- end
38
-
39
- def parse(args)
40
- @pile = args.dup
41
-
42
- @switches.each do |argument|
43
- break unless peek
44
- @non_assigned_required.delete(argument)
45
- @assigns[argument.human_name] = send(:"parse_#{argument.type}", argument.human_name)
46
- end
47
-
48
- check_requirement!
49
- @assigns
50
- end
51
-
52
- private
53
-
54
- def last?
55
- @pile.empty?
56
- end
57
-
58
- def peek
59
- @pile.first
60
- end
61
-
62
- def shift
63
- @pile.shift
64
- end
65
-
66
- def unshift(arg)
67
- unless arg.kind_of?(Array)
68
- @pile.unshift(arg)
69
- else
70
- @pile = arg + @pile
71
- end
72
- end
73
-
74
- def current_is_value?
75
- peek && peek.to_s !~ /^-/
76
- end
77
-
78
- # Runs through the argument array getting strings that contains ":" and
79
- # mark it as a hash:
80
- #
81
- # [ "name:string", "age:integer" ]
82
- #
83
- # Becomes:
84
- #
85
- # { "name" => "string", "age" => "integer" }
86
- #
87
- def parse_hash(name)
88
- return shift if peek.is_a?(Hash)
89
- hash = {}
90
-
91
- while current_is_value? && peek.include?(?:)
92
- key, value = shift.split(':')
93
- hash[key] = value
94
- end
95
- hash
96
- end
97
-
98
- # Runs through the argument array getting all strings until no string is
99
- # found or a switch is found.
100
- #
101
- # ["a", "b", "c"]
102
- #
103
- # And returns it as an array:
104
- #
105
- # ["a", "b", "c"]
106
- #
107
- def parse_array(name)
108
- return shift if peek.is_a?(Array)
109
- array = []
110
-
111
- while current_is_value?
112
- array << shift
113
- end
114
- array
115
- end
116
-
117
- # Check if the peel is numeric ofrmat and return a Float or Integer.
118
- # Otherwise raises an error.
119
- #
120
- def parse_numeric(name)
121
- return shift if peek.is_a?(Numeric)
122
-
123
- unless peek =~ NUMERIC && $& == peek
124
- raise MalformattedArgumentError, "Expected numeric value for '#{name}'; got #{peek.inspect}"
125
- end
126
-
127
- $&.index('.') ? shift.to_f : shift.to_i
128
- end
129
-
130
- # Parse string, i.e., just return the current value in the pile.
131
- #
132
- def parse_string(name)
133
- shift
134
- end
135
-
136
- # Raises an error if @non_assigned_required array is not empty.
137
- #
138
- def check_requirement!
139
- unless @non_assigned_required.empty?
140
- names = @non_assigned_required.map do |o|
141
- o.respond_to?(:switch_name) ? o.switch_name : o.human_name
142
- end.join("', '")
143
-
144
- class_name = self.class.name.split('::').last.downcase
145
- raise RequiredArgumentMissingError, "No value provided for required #{class_name} '#{names}'"
146
- end
147
- end
148
-
149
- end
150
- end
@@ -1,128 +0,0 @@
1
- class Thor
2
- class Option < Argument #:nodoc:
3
- attr_reader :aliases, :group
4
-
5
- VALID_TYPES = [:boolean, :numeric, :hash, :array, :string]
6
-
7
- def initialize(name, description=nil, required=nil, type=nil, default=nil, banner=nil, group=nil, aliases=nil)
8
- super(name, description, required, type, default, banner)
9
- @aliases = [*aliases].compact
10
- @group = group.to_s.capitalize if group
11
- end
12
-
13
- # This parse quick options given as method_options. It makes several
14
- # assumptions, but you can be more specific using the option method.
15
- #
16
- # parse :foo => "bar"
17
- # #=> Option foo with default value bar
18
- #
19
- # parse [:foo, :baz] => "bar"
20
- # #=> Option foo with default value bar and alias :baz
21
- #
22
- # parse :foo => :required
23
- # #=> Required option foo without default value
24
- #
25
- # parse :foo => 2
26
- # #=> Option foo with default value 2 and type numeric
27
- #
28
- # parse :foo => :numeric
29
- # #=> Option foo without default value and type numeric
30
- #
31
- # parse :foo => true
32
- # #=> Option foo with default value true and type boolean
33
- #
34
- # The valid types are :boolean, :numeric, :hash, :array and :string. If none
35
- # is given a default type is assumed. This default type accepts arguments as
36
- # string (--foo=value) or booleans (just --foo).
37
- #
38
- # By default all options are optional, unless :required is given.
39
- #
40
- def self.parse(key, value)
41
- if key.is_a?(Array)
42
- name, *aliases = key
43
- else
44
- name, aliases = key, []
45
- end
46
-
47
- name = name.to_s
48
- default = value
49
-
50
- type = case value
51
- when Symbol
52
- default = nil
53
-
54
- if VALID_TYPES.include?(value)
55
- value
56
- elsif required = (value == :required)
57
- :string
58
- end
59
- when TrueClass, FalseClass
60
- :boolean
61
- when Numeric
62
- :numeric
63
- when Hash, Array, String
64
- value.class.name.downcase.to_sym
65
- end
66
-
67
- self.new(name.to_s, nil, required, type, default, nil, nil, aliases)
68
- end
69
-
70
- def switch_name
71
- @switch_name ||= dasherized? ? name : dasherize(name)
72
- end
73
-
74
- def human_name
75
- @human_name ||= dasherized? ? undasherize(name) : name
76
- end
77
-
78
- def usage(padding=0)
79
- sample = if banner && !banner.to_s.empty?
80
- "#{switch_name}=#{banner}"
81
- else
82
- switch_name
83
- end
84
-
85
- sample = "[#{sample}]" unless required?
86
-
87
- if aliases.empty?
88
- (" " * padding) << sample
89
- else
90
- "#{aliases.join(', ')}, #{sample}"
91
- end
92
- end
93
-
94
- # Allow some type predicates as: boolean?, string? and etc.
95
- #
96
- def method_missing(method, *args, &block)
97
- given = method.to_s.sub(/\?$/, '').to_sym
98
- if valid_type?(given)
99
- self.type == given
100
- else
101
- super
102
- end
103
- end
104
-
105
- protected
106
-
107
- def validate!
108
- raise ArgumentError, "An option cannot be boolean and required." if boolean? && required?
109
- end
110
-
111
- def valid_type?(type)
112
- VALID_TYPES.include?(type.to_sym)
113
- end
114
-
115
- def dasherized?
116
- name.index('-') == 0
117
- end
118
-
119
- def undasherize(str)
120
- str.sub(/^-{1,2}/, '')
121
- end
122
-
123
- def dasherize(str)
124
- (str.length > 1 ? "--" : "-") + str.gsub('_', '-')
125
- end
126
-
127
- end
128
- end
@@ -1,169 +0,0 @@
1
- class Thor
2
- # This is a modified version of Daniel Berger's Getopt::Long class, licensed
3
- # under Ruby's license.
4
- #
5
- class Options < Arguments #:nodoc:
6
- LONG_RE = /^(--\w+(?:-\w+)*)$/
7
- SHORT_RE = /^(-[a-z])$/i
8
- EQ_RE = /^(--\w+(?:-\w+)*|-[a-z])=(.*)$/i
9
- SHORT_SQ_RE = /^-([a-z]{2,})$/i # Allow either -x -v or -xv style for single char args
10
- SHORT_NUM = /^(-[a-z])#{NUMERIC}$/i
11
-
12
- # Receives a hash and makes it switches.
13
- def self.to_switches(options)
14
- options.map do |key, value|
15
- case value
16
- when true
17
- "--#{key}"
18
- when Array
19
- "--#{key} #{value.map{ |v| v.inspect }.join(' ')}"
20
- when Hash
21
- "--#{key} #{value.map{ |k,v| "#{k}:#{v}" }.join(' ')}"
22
- when nil, false
23
- ""
24
- else
25
- "--#{key} #{value.inspect}"
26
- end
27
- end.join(" ")
28
- end
29
-
30
- # Takes a hash of Thor::Option and a hash with defaults.
31
- def initialize(hash_options={}, defaults={})
32
- options = hash_options.values
33
- super(options)
34
-
35
- # Add defaults
36
- defaults.each do |key, value|
37
- @assigns[key.to_s] = value
38
- @non_assigned_required.delete(hash_options[key])
39
- end
40
-
41
- @shorts, @switches, @unknown = {}, {}, []
42
-
43
- options.each do |option|
44
- @switches[option.switch_name] = option
45
-
46
- option.aliases.each do |short|
47
- @shorts[short.to_s] ||= option.switch_name
48
- end
49
- end
50
- end
51
-
52
- def parse(args)
53
- @pile = args.dup
54
-
55
- while peek
56
- if current_is_switch?
57
- case shift
58
- when SHORT_SQ_RE
59
- unshift($1.split('').map { |f| "-#{f}" })
60
- next
61
- when EQ_RE, SHORT_NUM
62
- unshift($2)
63
- switch = $1
64
- when LONG_RE, SHORT_RE
65
- switch = $1
66
- end
67
-
68
- switch = normalize_switch(switch)
69
- option = switch_option(switch)
70
- @assigns[option.human_name] = parse_peek(switch, option)
71
- elsif current_is_switch_formatted?
72
- @unknown << shift
73
- else
74
- shift
75
- end
76
- end
77
-
78
- check_requirement!
79
-
80
- assigns = Thor::CoreExt::HashWithIndifferentAccess.new(@assigns)
81
- assigns.freeze
82
- assigns
83
- end
84
-
85
- def check_unknown!
86
- raise UnknownArgumentError, "Unknown switches '#{@unknown.join(', ')}'" unless @unknown.empty?
87
- end
88
-
89
- protected
90
-
91
- # Returns true if the current value in peek is a registered switch.
92
- #
93
- def current_is_switch?
94
- case peek
95
- when LONG_RE, SHORT_RE, EQ_RE, SHORT_NUM
96
- switch?($1)
97
- when SHORT_SQ_RE
98
- $1.split('').any? { |f| switch?("-#{f}") }
99
- end
100
- end
101
-
102
- def switch_formatted?(arg)
103
- case arg
104
- when LONG_RE, SHORT_RE, EQ_RE, SHORT_NUM, SHORT_SQ_RE
105
- true
106
- else
107
- false
108
- end
109
- end
110
-
111
- def current_is_switch_formatted?
112
- switch_formatted? peek
113
- end
114
-
115
- def switch?(arg)
116
- switch_option(arg) || @shorts.key?(arg)
117
- end
118
-
119
- def switch_option(arg)
120
- if match = no_or_skip?(arg)
121
- @switches[arg] || @switches["--#{match}"]
122
- else
123
- @switches[arg]
124
- end
125
- end
126
-
127
- def no_or_skip?(arg)
128
- arg =~ /^--(no|skip)-([-\w]+)$/
129
- $2
130
- end
131
-
132
- # Check if the given argument is actually a shortcut.
133
- #
134
- def normalize_switch(arg)
135
- @shorts.key?(arg) ? @shorts[arg] : arg
136
- end
137
-
138
- # Parse boolean values which can be given as --foo=true, --foo or --no-foo.
139
- #
140
- def parse_boolean(switch)
141
- if current_is_value?
142
- ["true", "TRUE", "t", "T", true].include?(shift)
143
- else
144
- @switches.key?(switch) || !no_or_skip?(switch)
145
- end
146
- end
147
-
148
- # Parse the value at the peek analyzing if it requires an input or not.
149
- #
150
- def parse_peek(switch, option)
151
- if current_is_switch_formatted? || last?
152
- if option.boolean?
153
- # No problem for boolean types
154
- elsif no_or_skip?(switch)
155
- return nil # User set value to nil
156
- elsif option.string? && !option.required?
157
- # Return the default if there is one, else the human name
158
- return option.default || option.human_name
159
- else
160
- raise MalformattedArgumentError, "No value provided for option '#{switch}'"
161
- end
162
- end
163
-
164
- @non_assigned_required.delete(option)
165
- send(:"parse_#{option.type}", switch)
166
- end
167
-
168
- end
169
- end
@@ -1,4 +0,0 @@
1
- require 'thor/parser/argument'
2
- require 'thor/parser/arguments'
3
- require 'thor/parser/option'
4
- require 'thor/parser/options'
@@ -1,66 +0,0 @@
1
- require 'rake'
2
-
3
- class Thor
4
- # Adds a compatibility layer to your Thor classes which allows you to use
5
- # rake package tasks. For example, to use rspec rake tasks, one can do:
6
- #
7
- # require 'thor/rake_compat'
8
- #
9
- # class Default < Thor
10
- # include Thor::RakeCompat
11
- #
12
- # Spec::Rake::SpecTask.new(:spec) do |t|
13
- # t.spec_opts = ['--options', "spec/spec.opts"]
14
- # t.spec_files = FileList['spec/**/*_spec.rb']
15
- # end
16
- # end
17
- #
18
- module RakeCompat
19
- def self.rake_classes
20
- @rake_classes ||= []
21
- end
22
-
23
- def self.included(base)
24
- # Hack. Make rakefile point to invoker, so rdoc task is generated properly.
25
- rakefile = File.basename(caller[0].match(/(.*):\d+/)[1])
26
- Rake.application.instance_variable_set(:@rakefile, rakefile)
27
- self.rake_classes << base
28
- end
29
- end
30
- end
31
-
32
- class Object #:nodoc:
33
- alias :rake_task :task
34
- alias :rake_namespace :namespace
35
-
36
- def task(*args, &block)
37
- task = rake_task(*args, &block)
38
-
39
- if klass = Thor::RakeCompat.rake_classes.last
40
- non_namespaced_name = task.name.split(':').last
41
-
42
- description = non_namespaced_name
43
- description << task.arg_names.map{ |n| n.to_s.upcase }.join(' ')
44
- description.strip!
45
-
46
- klass.desc description, task.comment || non_namespaced_name
47
- klass.send :define_method, non_namespaced_name do |*args|
48
- Rake::Task[task.name.to_sym].invoke(*args)
49
- end
50
- end
51
-
52
- task
53
- end
54
-
55
- def namespace(name, &block)
56
- if klass = Thor::RakeCompat.rake_classes.last
57
- const_name = Thor::Util.camel_case(name.to_s).to_sym
58
- klass.const_set(const_name, Class.new(Thor))
59
- new_klass = klass.const_get(const_name)
60
- Thor::RakeCompat.rake_classes << new_klass
61
- end
62
-
63
- rake_namespace(name, &block)
64
- Thor::RakeCompat.rake_classes.pop
65
- end
66
- end