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
data/lib/vendor/thor/README.rdoc
DELETED
@@ -1,297 +0,0 @@
|
|
1
|
-
= thor
|
2
|
-
|
3
|
-
Map options to a class. Simply create a class with the appropriate annotations
|
4
|
-
and have options automatically map to functions and parameters.
|
5
|
-
|
6
|
-
Example:
|
7
|
-
|
8
|
-
class App < Thor # [1]
|
9
|
-
map "-L" => :list # [2]
|
10
|
-
|
11
|
-
desc "install APP_NAME", "install one of the available apps" # [3]
|
12
|
-
method_options :force => :boolean, :alias => :string # [4]
|
13
|
-
def install(name)
|
14
|
-
user_alias = options[:alias]
|
15
|
-
if options.force?
|
16
|
-
# do something
|
17
|
-
end
|
18
|
-
# other code
|
19
|
-
end
|
20
|
-
|
21
|
-
desc "list [SEARCH]", "list all of the available apps, limited by SEARCH"
|
22
|
-
def list(search="")
|
23
|
-
# list everything
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
Thor automatically maps commands as such:
|
28
|
-
|
29
|
-
thor app:install myname --force
|
30
|
-
|
31
|
-
That gets converted to:
|
32
|
-
|
33
|
-
App.new.install("myname")
|
34
|
-
# with {'force' => true} as options hash
|
35
|
-
|
36
|
-
1. Inherit from Thor to turn a class into an option mapper
|
37
|
-
2. Map additional non-valid identifiers to specific methods. In this case, convert -L to :list
|
38
|
-
3. Describe the method immediately below. The first parameter is the usage information, and the second parameter is the description
|
39
|
-
4. Provide any additional options that will be available the instance method options.
|
40
|
-
|
41
|
-
== Types for <tt>method_options</tt>
|
42
|
-
|
43
|
-
* :boolean - is parsed as <tt>--option</tt> or <tt>--option=true</tt>
|
44
|
-
* :string - is parsed as <tt>--option=VALUE</tt>
|
45
|
-
* :numeric - is parsed as <tt>--option=N</tt>
|
46
|
-
* :array - is parsed as <tt>--option=one two three</tt>
|
47
|
-
* :hash - is parsed as <tt>--option=name:string age:integer</tt>
|
48
|
-
|
49
|
-
Besides, method_option allows a default value to be given, examples:
|
50
|
-
|
51
|
-
method_options :force => false
|
52
|
-
#=> Creates a boolean option with default value false
|
53
|
-
|
54
|
-
method_options :alias => "bar"
|
55
|
-
#=> Creates a string option with default value "bar"
|
56
|
-
|
57
|
-
method_options :threshold => 3.0
|
58
|
-
#=> Creates a numeric option with default value 3.0
|
59
|
-
|
60
|
-
You can also supply <tt>:option => :required</tt> to mark an option as required. The
|
61
|
-
type is assumed to be string. If you want a required hash with default values
|
62
|
-
as option, you can use <tt>method_option</tt> which uses a more declarative style:
|
63
|
-
|
64
|
-
method_option :attributes, :type => :hash, :default => {}, :required => true
|
65
|
-
|
66
|
-
All arguments can be set to nil (except required arguments), by suppling a no or
|
67
|
-
skip variant. For example:
|
68
|
-
|
69
|
-
thor app name --no-attributes
|
70
|
-
|
71
|
-
In previous versions, aliases for options were created automatically, but now
|
72
|
-
they should be explicit. You can supply aliases in both short and declarative
|
73
|
-
styles:
|
74
|
-
|
75
|
-
method_options %w( force -f ) => :boolean
|
76
|
-
|
77
|
-
Or:
|
78
|
-
|
79
|
-
method_option :force, :type => :boolean, :aliases => "-f"
|
80
|
-
|
81
|
-
You can supply as many aliases as you want.
|
82
|
-
|
83
|
-
NOTE: Type :optional available in Thor 0.9.0 was deprecated. Use :string or :boolean instead.
|
84
|
-
|
85
|
-
== Namespaces
|
86
|
-
|
87
|
-
By default, your Thor tasks are invoked using Ruby namespace. In the example
|
88
|
-
above, tasks are invoked as:
|
89
|
-
|
90
|
-
thor app:install name --force
|
91
|
-
|
92
|
-
However, you could namespace your class as:
|
93
|
-
|
94
|
-
module Sinatra
|
95
|
-
class App < Thor
|
96
|
-
# tasks
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
And then you should invoke your tasks as:
|
101
|
-
|
102
|
-
thor sinatra:app:install name --force
|
103
|
-
|
104
|
-
If desired, you can change the namespace:
|
105
|
-
|
106
|
-
module Sinatra
|
107
|
-
class App < Thor
|
108
|
-
namespace :myapp
|
109
|
-
# tasks
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
And then your tasks hould be invoked as:
|
114
|
-
|
115
|
-
thor myapp:install name --force
|
116
|
-
|
117
|
-
== Invocations
|
118
|
-
|
119
|
-
Thor comes with a invocation-dependency system as well which allows a task to be
|
120
|
-
invoked only once. For example:
|
121
|
-
|
122
|
-
class Counter < Thor
|
123
|
-
desc "one", "Prints 1, 2, 3"
|
124
|
-
def one
|
125
|
-
puts 1
|
126
|
-
invoke :two
|
127
|
-
invoke :three
|
128
|
-
end
|
129
|
-
|
130
|
-
desc "two", "Prints 2, 3"
|
131
|
-
def two
|
132
|
-
puts 2
|
133
|
-
invoke :three
|
134
|
-
end
|
135
|
-
|
136
|
-
desc "three", "Prints 3"
|
137
|
-
def three
|
138
|
-
puts 3
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
|
-
When invoking the task one:
|
143
|
-
|
144
|
-
thor counter:one
|
145
|
-
|
146
|
-
The output is "1 2 3", which means that the three task was invoked only once.
|
147
|
-
You can even invoke tasks from another class, so be sure to check the
|
148
|
-
documentation[http://rdoc.info/rdoc/wycats/thor/blob/f939a3e8a854616784cac1dcff04ef4f3ee5f7ff/Thor.html].
|
149
|
-
|
150
|
-
== Thor::Group
|
151
|
-
|
152
|
-
Thor has a special class called Thor::Group. The main difference to Thor class
|
153
|
-
is that it invokes all tasks at once. The example above could be rewritten in
|
154
|
-
Thor::Group as this:
|
155
|
-
|
156
|
-
class Counter < Thor::Group
|
157
|
-
desc "Prints 1, 2, 3"
|
158
|
-
|
159
|
-
def one
|
160
|
-
puts 1
|
161
|
-
end
|
162
|
-
|
163
|
-
def two
|
164
|
-
puts 2
|
165
|
-
end
|
166
|
-
|
167
|
-
def three
|
168
|
-
puts 3
|
169
|
-
end
|
170
|
-
end
|
171
|
-
|
172
|
-
When invoked:
|
173
|
-
|
174
|
-
thor counter
|
175
|
-
|
176
|
-
It prints "1 2 3" as well. Notice you should describe (using the method <tt>desc</tt>)
|
177
|
-
only the class and not each task anymore. Thor::Group is a great tool to create
|
178
|
-
generators, since you can define several steps which are invoked in the order they
|
179
|
-
are defined (Thor::Group is the tool use in generators in Rails 3.0).
|
180
|
-
|
181
|
-
Besides, Thor::Group can parse arguments and options as Thor tasks:
|
182
|
-
|
183
|
-
class Counter < Thor::Group
|
184
|
-
# number will be available as attr_accessor
|
185
|
-
argument :number, :type => :numeric, :desc => "The number to start counting"
|
186
|
-
desc "Prints the 'number' given upto 'number+2'"
|
187
|
-
|
188
|
-
def one
|
189
|
-
puts number + 0
|
190
|
-
end
|
191
|
-
|
192
|
-
def two
|
193
|
-
puts number + 1
|
194
|
-
end
|
195
|
-
|
196
|
-
def three
|
197
|
-
puts number + 2
|
198
|
-
end
|
199
|
-
end
|
200
|
-
|
201
|
-
The counter above expects one parameter and has the folling outputs:
|
202
|
-
|
203
|
-
thor counter 5
|
204
|
-
# Prints "5 6 7"
|
205
|
-
|
206
|
-
thor counter 11
|
207
|
-
# Prints "11 12 13"
|
208
|
-
|
209
|
-
You can also give options to Thor::Group, but instead of using <tt>method_option</tt>
|
210
|
-
and <tt>method_options</tt>, you should use <tt>class_option</tt> and <tt>class_options</tt>.
|
211
|
-
Both argument and class_options methods are available to Thor class as well.
|
212
|
-
|
213
|
-
== Actions
|
214
|
-
|
215
|
-
Thor comes with several actions which helps with script and generator tasks. You
|
216
|
-
might be familiar with them since some came from Rails Templates. They are:
|
217
|
-
<tt>say</tt>, <tt>ask</tt>, <tt>yes?</tt>, <tt>no?</tt>, <tt>add_file</tt>,
|
218
|
-
<tt>remove_file</tt>, <tt>copy_file</tt>, <tt>template</tt>, <tt>directory</tt>,
|
219
|
-
<tt>inside</tt>, <tt>run</tt>, <tt>inject_into_file</tt> and a couple more.
|
220
|
-
|
221
|
-
To use them, you just need to include Thor::Actions in your Thor classes:
|
222
|
-
|
223
|
-
class App < Thor
|
224
|
-
include Thor::Actions
|
225
|
-
# tasks
|
226
|
-
end
|
227
|
-
|
228
|
-
Some actions like copy file requires that a class method called source_root is
|
229
|
-
defined in your class. This is the directory where your templates should be
|
230
|
-
placed. Be sure to check the documentation on actions[http://rdoc.info/rdoc/wycats/thor/blob/f939a3e8a854616784cac1dcff04ef4f3ee5f7ff/Thor/Actions.html].
|
231
|
-
|
232
|
-
== Generators
|
233
|
-
|
234
|
-
A great use for Thor is creating custom generators. Combining Thor::Group,
|
235
|
-
Thor::Actions and ERB templates makes this very easy. Here is an example:
|
236
|
-
|
237
|
-
class Newgem < Thor::Group
|
238
|
-
include Thor::Actions
|
239
|
-
|
240
|
-
# Define arguments and options
|
241
|
-
argument :name
|
242
|
-
class_option :test_framework, :default => :test_unit
|
243
|
-
|
244
|
-
def self.source_root
|
245
|
-
File.dirname(__FILE__)
|
246
|
-
end
|
247
|
-
|
248
|
-
def create_lib_file
|
249
|
-
template('templates/newgem.tt', "#{name}/lib/#{name}.rb")
|
250
|
-
end
|
251
|
-
|
252
|
-
def create_test_file
|
253
|
-
test = options[:test_framework] == "rspec" ? :spec : :test
|
254
|
-
create_file "#{name}/#{test}/#{name}_#{test}.rb"
|
255
|
-
end
|
256
|
-
|
257
|
-
def copy_licence
|
258
|
-
if yes?("Use MIT license?")
|
259
|
-
# Make a copy of the MITLICENSE file at the source root
|
260
|
-
copy_file "MITLICENSE", "#{name}/MITLICENSE"
|
261
|
-
else
|
262
|
-
say "Shame on you…", :red
|
263
|
-
end
|
264
|
-
end
|
265
|
-
end
|
266
|
-
|
267
|
-
Doing a <tt>thor -T</tt> will show how to run our generator. It should read:
|
268
|
-
<tt>thor newgem NAME</tt>. This shows that we have to supply a NAME
|
269
|
-
argument for our generator to run.
|
270
|
-
|
271
|
-
The <tt>create_lib_file</tt> uses an ERB template. This is what it looks like:
|
272
|
-
|
273
|
-
class <%= name.camelize %>
|
274
|
-
end
|
275
|
-
|
276
|
-
The arguments that you set in your generator will automatically be passed in
|
277
|
-
when <tt>template</tt> gets called. Be sure to read the documentation[http://rdoc.info/rdoc/wycats/thor/blob/f939a3e8a854616784cac1dcff04ef4f3ee5f7ff/Thor/Actions.html] for
|
278
|
-
more options.
|
279
|
-
|
280
|
-
Running the generator with <tt>thor newgem devise</tt> will
|
281
|
-
create two files: "devise/lib/devise.rb",
|
282
|
-
"devise/test/devise_test.rb". The user will then be prompt (with the
|
283
|
-
use of the method <tt>yes?</tt>) if he wants to copy the MITLICENSE. If you
|
284
|
-
want to change the test framework, you can add the option:
|
285
|
-
<tt>thor newgem devise --test-framework=rspec</tt>
|
286
|
-
This will generate: "devise/lib/devise.rb" and
|
287
|
-
"devise/spec/devise_spec.rb".
|
288
|
-
|
289
|
-
== Further Reading
|
290
|
-
|
291
|
-
Thor has many scripting possibilities beyond these examples. Be sure to read
|
292
|
-
through the documentation[http://rdoc.info/rdoc/wycats/thor/blob/f939a3e8a854616784cac1dcff04ef4f3ee5f7ff/Thor.html] and specs[http://github.com/wycats/thor/tree/master/spec/] to get a better understanding of all the
|
293
|
-
options Thor offers.
|
294
|
-
|
295
|
-
== License
|
296
|
-
|
297
|
-
See MIT LICENSE.
|
data/lib/vendor/thor/Thorfile
DELETED
@@ -1,69 +0,0 @@
|
|
1
|
-
# enconding: utf-8
|
2
|
-
|
3
|
-
require File.join(File.dirname(__FILE__), "lib", "thor", "version")
|
4
|
-
require 'rubygems'
|
5
|
-
require 'thor/rake_compat'
|
6
|
-
require 'spec/rake/spectask'
|
7
|
-
begin
|
8
|
-
require 'rdoc/task'
|
9
|
-
rescue LoadError
|
10
|
-
end
|
11
|
-
|
12
|
-
GEM_NAME = 'thor'
|
13
|
-
EXTRA_RDOC_FILES = ["README.rdoc", "LICENSE", "CHANGELOG.rdoc", "VERSION", "Thorfile"]
|
14
|
-
|
15
|
-
class Default < Thor
|
16
|
-
include Thor::RakeCompat
|
17
|
-
|
18
|
-
Spec::Rake::SpecTask.new(:spec) do |t|
|
19
|
-
t.libs << 'lib'
|
20
|
-
t.spec_opts = ['--options', "spec/spec.opts"]
|
21
|
-
t.spec_files = FileList['spec/**/*_spec.rb']
|
22
|
-
end
|
23
|
-
|
24
|
-
Spec::Rake::SpecTask.new(:rcov) do |t|
|
25
|
-
t.libs << 'lib'
|
26
|
-
t.spec_opts = ['--options', "spec/spec.opts"]
|
27
|
-
t.spec_files = FileList['spec/**/*_spec.rb']
|
28
|
-
t.rcov = true
|
29
|
-
t.rcov_dir = "rcov"
|
30
|
-
end
|
31
|
-
|
32
|
-
if defined?(RDoc)
|
33
|
-
RDoc::Task.new do |rdoc|
|
34
|
-
rdoc.main = "README.rdoc"
|
35
|
-
rdoc.rdoc_dir = "rdoc"
|
36
|
-
rdoc.title = GEM_NAME
|
37
|
-
rdoc.rdoc_files.include(*EXTRA_RDOC_FILES)
|
38
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
39
|
-
rdoc.options << '--line-numbers' << '--inline-source'
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
begin
|
44
|
-
require 'jeweler'
|
45
|
-
Jeweler::Tasks.new do |s|
|
46
|
-
s.name = GEM_NAME
|
47
|
-
s.version = Thor::VERSION
|
48
|
-
s.rubyforge_project = "textmate"
|
49
|
-
s.platform = Gem::Platform::RUBY
|
50
|
-
s.summary = "A scripting framework that replaces rake, sake and rubigen"
|
51
|
-
s.email = "ruby-thor@googlegroups.com"
|
52
|
-
s.homepage = "http://yehudakatz.com"
|
53
|
-
s.description = "A scripting framework that replaces rake, sake and rubigen"
|
54
|
-
s.authors = ['Yehuda Katz', 'José Valim']
|
55
|
-
s.has_rdoc = true
|
56
|
-
s.extra_rdoc_files = EXTRA_RDOC_FILES
|
57
|
-
s.require_path = 'lib'
|
58
|
-
s.bindir = "bin"
|
59
|
-
s.executables = %w( thor rake2thor )
|
60
|
-
s.files = s.extra_rdoc_files + Dir.glob("{bin,lib}/**/*")
|
61
|
-
s.test_files.include 'spec/**/*'
|
62
|
-
s.test_files.exclude 'spec/sandbox/**/*'
|
63
|
-
end
|
64
|
-
|
65
|
-
Jeweler::GemcutterTasks.new
|
66
|
-
rescue LoadError
|
67
|
-
puts "Jeweler, or one of its dependencies, is not available. Install it with: gem install jeweler"
|
68
|
-
end
|
69
|
-
end
|
@@ -1,86 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'ruby2ruby'
|
4
|
-
require 'parse_tree'
|
5
|
-
if Ruby2Ruby::VERSION >= "1.2.0"
|
6
|
-
require 'parse_tree_extensions'
|
7
|
-
end
|
8
|
-
require 'rake'
|
9
|
-
|
10
|
-
input = ARGV[0] || 'Rakefile'
|
11
|
-
output = ARGV[1] || 'Thorfile'
|
12
|
-
|
13
|
-
$requires = []
|
14
|
-
|
15
|
-
module Kernel
|
16
|
-
def require_with_record(file)
|
17
|
-
$requires << file if caller[1] =~ /rake2thor:/
|
18
|
-
require_without_record file
|
19
|
-
end
|
20
|
-
alias_method :require_without_record, :require
|
21
|
-
alias_method :require, :require_with_record
|
22
|
-
end
|
23
|
-
|
24
|
-
load input
|
25
|
-
|
26
|
-
@private_methods = []
|
27
|
-
|
28
|
-
def file_task_name(name)
|
29
|
-
"compile_" + name.gsub('/', '_slash_').gsub('.', '_dot_').gsub(/\W/, '_')
|
30
|
-
end
|
31
|
-
|
32
|
-
def method_for_task(task)
|
33
|
-
file_task = task.is_a?(Rake::FileTask)
|
34
|
-
comment = task.instance_variable_get('@comment')
|
35
|
-
prereqs = task.instance_variable_get('@prerequisites').select(&Rake::Task.method(:task_defined?))
|
36
|
-
actions = task.instance_variable_get('@actions')
|
37
|
-
name = task.name.gsub(/^([^:]+:)+/, '')
|
38
|
-
name = file_task_name(name) if file_task
|
39
|
-
meth = ''
|
40
|
-
|
41
|
-
meth << "desc #{name.inspect}, #{comment.inspect}\n" if comment
|
42
|
-
meth << "def #{name}\n"
|
43
|
-
|
44
|
-
meth << prereqs.map do |pre|
|
45
|
-
pre = pre.to_s
|
46
|
-
pre = file_task_name(pre) if Rake::Task[pre].is_a?(Rake::FileTask)
|
47
|
-
' ' + pre
|
48
|
-
end.join("\n")
|
49
|
-
|
50
|
-
meth << "\n\n" unless prereqs.empty? || actions.empty?
|
51
|
-
|
52
|
-
meth << actions.map do |act|
|
53
|
-
act = act.to_ruby
|
54
|
-
unless act.gsub!(/^proc \{ \|(\w+)\|\n/,
|
55
|
-
" \\1 = Struct.new(:name).new(#{name.inspect}) # A crude mock Rake::Task object\n")
|
56
|
-
act.gsub!(/^proc \{\n/, '')
|
57
|
-
end
|
58
|
-
act.gsub(/\n\}$/, '')
|
59
|
-
end.join("\n")
|
60
|
-
|
61
|
-
meth << "\nend"
|
62
|
-
|
63
|
-
if file_task
|
64
|
-
@private_methods << meth
|
65
|
-
return
|
66
|
-
end
|
67
|
-
|
68
|
-
meth
|
69
|
-
end
|
70
|
-
|
71
|
-
body = Rake::Task.tasks.map(&method(:method_for_task)).compact.map { |meth| meth.gsub(/^/, ' ') }.join("\n\n")
|
72
|
-
|
73
|
-
unless @private_methods.empty?
|
74
|
-
body << "\n\n private\n\n"
|
75
|
-
body << @private_methods.map { |meth| meth.gsub(/^/, ' ') }.join("\n\n")
|
76
|
-
end
|
77
|
-
|
78
|
-
requires = $requires.map { |r| "require #{r.inspect}" }.join("\n")
|
79
|
-
|
80
|
-
File.open(output, 'w') { |f| f.write(<<END.lstrip) }
|
81
|
-
#{requires}
|
82
|
-
|
83
|
-
class Default < Thor
|
84
|
-
#{body}
|
85
|
-
end
|
86
|
-
END
|
data/lib/vendor/thor/bin/thor
DELETED
@@ -1,103 +0,0 @@
|
|
1
|
-
require 'thor/actions/empty_directory'
|
2
|
-
|
3
|
-
class Thor
|
4
|
-
module Actions
|
5
|
-
|
6
|
-
# Create a new file relative to the destination root with the given data,
|
7
|
-
# which is the return value of a block or a data string.
|
8
|
-
#
|
9
|
-
# ==== Parameters
|
10
|
-
# destination<String>:: the relative path to the destination root.
|
11
|
-
# data<String|NilClass>:: the data to append to the file.
|
12
|
-
# config<Hash>:: give :verbose => false to not log the status.
|
13
|
-
#
|
14
|
-
# ==== Examples
|
15
|
-
#
|
16
|
-
# create_file "lib/fun_party.rb" do
|
17
|
-
# hostname = ask("What is the virtual hostname I should use?")
|
18
|
-
# "vhost.name = #{hostname}"
|
19
|
-
# end
|
20
|
-
#
|
21
|
-
# create_file "config/apach.conf", "your apache config"
|
22
|
-
#
|
23
|
-
def create_file(destination, data=nil, config={}, &block)
|
24
|
-
action CreateFile.new(self, destination, block || data.to_s, config)
|
25
|
-
end
|
26
|
-
alias :add_file :create_file
|
27
|
-
|
28
|
-
# AddFile is a subset of Template, which instead of rendering a file with
|
29
|
-
# ERB, it gets the content from the user.
|
30
|
-
#
|
31
|
-
class CreateFile < EmptyDirectory #:nodoc:
|
32
|
-
attr_reader :data
|
33
|
-
|
34
|
-
def initialize(base, destination, data, config={})
|
35
|
-
@data = data
|
36
|
-
super(base, destination, config)
|
37
|
-
end
|
38
|
-
|
39
|
-
# Checks if the content of the file at the destination is identical to the rendered result.
|
40
|
-
#
|
41
|
-
# ==== Returns
|
42
|
-
# Boolean:: true if it is identical, false otherwise.
|
43
|
-
#
|
44
|
-
def identical?
|
45
|
-
exists? && File.binread(destination) == render
|
46
|
-
end
|
47
|
-
|
48
|
-
# Holds the content to be added to the file.
|
49
|
-
#
|
50
|
-
def render
|
51
|
-
@render ||= if data.is_a?(Proc)
|
52
|
-
data.call
|
53
|
-
else
|
54
|
-
data
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
def invoke!
|
59
|
-
invoke_with_conflict_check do
|
60
|
-
FileUtils.mkdir_p(File.dirname(destination))
|
61
|
-
File.open(destination, 'wb') { |f| f.write render }
|
62
|
-
end
|
63
|
-
given_destination
|
64
|
-
end
|
65
|
-
|
66
|
-
protected
|
67
|
-
|
68
|
-
# Now on conflict we check if the file is identical or not.
|
69
|
-
#
|
70
|
-
def on_conflict_behavior(&block)
|
71
|
-
if identical?
|
72
|
-
say_status :identical, :blue
|
73
|
-
else
|
74
|
-
options = base.options.merge(config)
|
75
|
-
force_or_skip_or_conflict(options[:force], options[:skip], &block)
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
# If force is true, run the action, otherwise check if it's not being
|
80
|
-
# skipped. If both are false, show the file_collision menu, if the menu
|
81
|
-
# returns true, force it, otherwise skip.
|
82
|
-
#
|
83
|
-
def force_or_skip_or_conflict(force, skip, &block)
|
84
|
-
if force
|
85
|
-
say_status :force, :yellow
|
86
|
-
block.call unless pretend?
|
87
|
-
elsif skip
|
88
|
-
say_status :skip, :yellow
|
89
|
-
else
|
90
|
-
say_status :conflict, :red
|
91
|
-
force_or_skip_or_conflict(force_on_collision?, true, &block)
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
# Shows the file collision menu to the user and gets the result.
|
96
|
-
#
|
97
|
-
def force_on_collision?
|
98
|
-
base.shell.file_collision(destination){ render }
|
99
|
-
end
|
100
|
-
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
@@ -1,91 +0,0 @@
|
|
1
|
-
require 'thor/actions/empty_directory'
|
2
|
-
|
3
|
-
class Thor
|
4
|
-
module Actions
|
5
|
-
|
6
|
-
# Copies recursively the files from source directory to root directory.
|
7
|
-
# If any of the files finishes with .tt, it's considered to be a template
|
8
|
-
# and is placed in the destination without the extension .tt. If any
|
9
|
-
# empty directory is found, it's copied and all .empty_directory files are
|
10
|
-
# ignored. Remember that file paths can also be encoded, let's suppose a doc
|
11
|
-
# directory with the following files:
|
12
|
-
#
|
13
|
-
# doc/
|
14
|
-
# components/.empty_directory
|
15
|
-
# README
|
16
|
-
# rdoc.rb.tt
|
17
|
-
# %app_name%.rb
|
18
|
-
#
|
19
|
-
# When invoked as:
|
20
|
-
#
|
21
|
-
# directory "doc"
|
22
|
-
#
|
23
|
-
# It will create a doc directory in the destination with the following
|
24
|
-
# files (assuming that the app_name is "blog"):
|
25
|
-
#
|
26
|
-
# doc/
|
27
|
-
# components/
|
28
|
-
# README
|
29
|
-
# rdoc.rb
|
30
|
-
# blog.rb
|
31
|
-
#
|
32
|
-
# ==== Parameters
|
33
|
-
# source<String>:: the relative path to the source root.
|
34
|
-
# destination<String>:: the relative path to the destination root.
|
35
|
-
# config<Hash>:: give :verbose => false to not log the status.
|
36
|
-
# If :recursive => false, does not look for paths recursively.
|
37
|
-
#
|
38
|
-
# ==== Examples
|
39
|
-
#
|
40
|
-
# directory "doc"
|
41
|
-
# directory "doc", "docs", :recursive => false
|
42
|
-
#
|
43
|
-
def directory(source, destination=nil, config={}, &block)
|
44
|
-
action Directory.new(self, source, destination || source, config, &block)
|
45
|
-
end
|
46
|
-
|
47
|
-
class Directory < EmptyDirectory #:nodoc:
|
48
|
-
attr_reader :source
|
49
|
-
|
50
|
-
def initialize(base, source, destination=nil, config={}, &block)
|
51
|
-
@source = File.expand_path(base.find_in_source_paths(source.to_s))
|
52
|
-
@block = block
|
53
|
-
super(base, destination, { :recursive => true }.merge(config))
|
54
|
-
end
|
55
|
-
|
56
|
-
def invoke!
|
57
|
-
base.empty_directory given_destination, config
|
58
|
-
execute!
|
59
|
-
end
|
60
|
-
|
61
|
-
def revoke!
|
62
|
-
execute!
|
63
|
-
end
|
64
|
-
|
65
|
-
protected
|
66
|
-
|
67
|
-
def execute!
|
68
|
-
lookup = config[:recursive] ? File.join(source, '**') : source
|
69
|
-
lookup = File.join(lookup, '{*,.[a-z]*}')
|
70
|
-
|
71
|
-
Dir[lookup].each do |file_source|
|
72
|
-
next if File.directory?(file_source)
|
73
|
-
file_destination = File.join(given_destination, file_source.gsub(source, '.'))
|
74
|
-
file_destination.gsub!('/./', '/')
|
75
|
-
|
76
|
-
case file_source
|
77
|
-
when /\.empty_directory$/
|
78
|
-
dirname = File.dirname(file_destination).gsub(/\/\.$/, '')
|
79
|
-
next if dirname == given_destination
|
80
|
-
base.empty_directory(dirname, config)
|
81
|
-
when /\.tt$/
|
82
|
-
destination = base.template(file_source, file_destination[0..-4], config, &@block)
|
83
|
-
else
|
84
|
-
destination = base.copy_file(file_source, file_destination, config, &@block)
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|