toys 0.11.5 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +27 -0
- data/README.md +1 -1
- data/builtins/system/bash-completion.rb +89 -0
- data/builtins/system/test.rb +96 -0
- data/builtins/system/update.rb +48 -0
- data/docs/guide.md +91 -3
- data/lib/toys/standard_cli.rb +2 -5
- data/lib/toys/templates/clean.rb +17 -1
- data/lib/toys/templates/gem_build.rb +22 -4
- data/lib/toys/templates/minitest.rb +17 -1
- data/lib/toys/templates/rake.rb +18 -2
- data/lib/toys/templates/rdoc.rb +22 -3
- data/lib/toys/templates/rspec.rb +17 -1
- data/lib/toys/templates/rubocop.rb +22 -3
- data/lib/toys/templates/yardoc.rb +30 -10
- data/lib/toys/testing.rb +197 -0
- data/lib/toys/version.rb +1 -1
- metadata +12 -9
- data/builtins/system.rb +0 -152
@@ -49,6 +49,8 @@ module Toys
|
|
49
49
|
# a git remote. You may specify which remote by setting the value to
|
50
50
|
# a string. Otherwise, if the value is simply `true`, the "origin"
|
51
51
|
# remote is used by default.
|
52
|
+
# @param context_directory [String] A custom context directory to use
|
53
|
+
# when executing this tool.
|
52
54
|
#
|
53
55
|
def initialize(name: nil,
|
54
56
|
gem_name: nil,
|
@@ -57,7 +59,8 @@ module Toys
|
|
57
59
|
push_gem: false,
|
58
60
|
install_gem: false,
|
59
61
|
tag: false,
|
60
|
-
push_tag: false
|
62
|
+
push_tag: false,
|
63
|
+
context_directory: nil)
|
61
64
|
@name = name
|
62
65
|
@gem_name = gem_name
|
63
66
|
@output = output
|
@@ -66,6 +69,7 @@ module Toys
|
|
66
69
|
@install_gem = install_gem
|
67
70
|
@tag = tag
|
68
71
|
@push_tag = push_tag
|
72
|
+
@context_directory = context_directory
|
69
73
|
end
|
70
74
|
|
71
75
|
##
|
@@ -137,6 +141,14 @@ module Toys
|
|
137
141
|
#
|
138
142
|
attr_writer :push_tag
|
139
143
|
|
144
|
+
##
|
145
|
+
# Custom context directory for this tool.
|
146
|
+
#
|
147
|
+
# @param value [String]
|
148
|
+
# @return [String]
|
149
|
+
#
|
150
|
+
attr_writer :context_directory
|
151
|
+
|
140
152
|
# @private
|
141
153
|
attr_reader :output
|
142
154
|
# @private
|
@@ -145,6 +157,8 @@ module Toys
|
|
145
157
|
attr_reader :install_gem
|
146
158
|
# @private
|
147
159
|
attr_reader :tag
|
160
|
+
# @private
|
161
|
+
attr_reader :context_directory
|
148
162
|
|
149
163
|
# @private
|
150
164
|
def name
|
@@ -152,9 +166,11 @@ module Toys
|
|
152
166
|
end
|
153
167
|
|
154
168
|
# @private
|
155
|
-
def gem_name
|
169
|
+
def gem_name(context_dir = nil)
|
156
170
|
return @gem_name if @gem_name
|
157
|
-
|
171
|
+
glob = "*.gemspec"
|
172
|
+
glob = ::File.join(context_dir, glob) if context_dir
|
173
|
+
candidates = ::Dir.glob(glob)
|
158
174
|
if candidates.empty?
|
159
175
|
raise ToolDefinitionError, "Could not find a gemspec"
|
160
176
|
end
|
@@ -181,7 +197,9 @@ module Toys
|
|
181
197
|
|
182
198
|
on_expand do |template|
|
183
199
|
tool(template.name) do
|
184
|
-
|
200
|
+
set_context_directory template.context_directory if template.context_directory
|
201
|
+
|
202
|
+
desc "#{template.task_names} the gem: #{template.gem_name(context_directory)}"
|
185
203
|
|
186
204
|
flag :yes, "-y", "--yes", desc: "Do not ask for interactive confirmation"
|
187
205
|
if template.output_flags.empty?
|
@@ -55,6 +55,8 @@ module Toys
|
|
55
55
|
# enabled. See the documentation for the
|
56
56
|
# [bundler mixin](https://dazuma.github.io/toys/gems/toys-core/latest/Toys/StandardMixins/Bundler)
|
57
57
|
# for information on available options.
|
58
|
+
# @param context_directory [String] A custom context directory to use
|
59
|
+
# when executing this tool.
|
58
60
|
#
|
59
61
|
def initialize(name: nil,
|
60
62
|
gem_version: nil,
|
@@ -63,7 +65,8 @@ module Toys
|
|
63
65
|
seed: nil,
|
64
66
|
verbose: false,
|
65
67
|
warnings: true,
|
66
|
-
bundler: false
|
68
|
+
bundler: false,
|
69
|
+
context_directory: nil)
|
67
70
|
@name = name
|
68
71
|
@gem_version = gem_version
|
69
72
|
@libs = libs
|
@@ -72,6 +75,7 @@ module Toys
|
|
72
75
|
@verbose = verbose
|
73
76
|
@warnings = warnings
|
74
77
|
@bundler = bundler
|
78
|
+
@context_directory = context_directory
|
75
79
|
end
|
76
80
|
|
77
81
|
##
|
@@ -135,6 +139,14 @@ module Toys
|
|
135
139
|
#
|
136
140
|
attr_writer :warnings
|
137
141
|
|
142
|
+
##
|
143
|
+
# Custom context directory for this tool.
|
144
|
+
#
|
145
|
+
# @param value [String]
|
146
|
+
# @return [String]
|
147
|
+
#
|
148
|
+
attr_writer :context_directory
|
149
|
+
|
138
150
|
##
|
139
151
|
# Set the bundler state and options for this tool.
|
140
152
|
#
|
@@ -169,6 +181,8 @@ module Toys
|
|
169
181
|
attr_reader :verbose
|
170
182
|
# @private
|
171
183
|
attr_reader :warnings
|
184
|
+
# @private
|
185
|
+
attr_reader :context_directory
|
172
186
|
|
173
187
|
# @private
|
174
188
|
def name
|
@@ -204,6 +218,8 @@ module Toys
|
|
204
218
|
tool(template.name) do
|
205
219
|
desc "Run minitest on the current project."
|
206
220
|
|
221
|
+
set_context_directory template.context_directory if template.context_directory
|
222
|
+
|
207
223
|
include :exec
|
208
224
|
include :gems
|
209
225
|
|
data/lib/toys/templates/rake.rb
CHANGED
@@ -31,17 +31,21 @@ module Toys
|
|
31
31
|
# enabled. See the documentation for the
|
32
32
|
# [bundler mixin](https://dazuma.github.io/toys/gems/toys-core/latest/Toys/StandardMixins/Bundler)
|
33
33
|
# for information on available options.
|
34
|
+
# @param context_directory [String] A custom context directory to use
|
35
|
+
# when executing this tool.
|
34
36
|
#
|
35
37
|
def initialize(gem_version: nil,
|
36
38
|
rakefile_path: nil,
|
37
39
|
only_described: false,
|
38
40
|
use_flags: false,
|
39
|
-
bundler: false
|
41
|
+
bundler: false,
|
42
|
+
context_directory: nil)
|
40
43
|
@gem_version = gem_version
|
41
44
|
@rakefile_path = rakefile_path
|
42
45
|
@only_described = only_described
|
43
46
|
@use_flags = use_flags
|
44
47
|
@bundler = bundler
|
48
|
+
@context_directory = context_directory
|
45
49
|
end
|
46
50
|
|
47
51
|
##
|
@@ -80,6 +84,14 @@ module Toys
|
|
80
84
|
#
|
81
85
|
attr_writer :use_flags
|
82
86
|
|
87
|
+
##
|
88
|
+
# Custom context directory for this tool.
|
89
|
+
#
|
90
|
+
# @param value [String]
|
91
|
+
# @return [String]
|
92
|
+
#
|
93
|
+
attr_writer :context_directory
|
94
|
+
|
83
95
|
##
|
84
96
|
# Set the bundler state and options for all Rake tools.
|
85
97
|
#
|
@@ -112,6 +124,8 @@ module Toys
|
|
112
124
|
attr_reader :only_described
|
113
125
|
# @private
|
114
126
|
attr_reader :use_flags
|
127
|
+
# @private
|
128
|
+
attr_reader :context_directory
|
115
129
|
|
116
130
|
# @private
|
117
131
|
def gem_version
|
@@ -135,7 +149,9 @@ module Toys
|
|
135
149
|
on_expand do |template|
|
136
150
|
gem "rake", *template.gem_version
|
137
151
|
require "rake"
|
138
|
-
rakefile_path = Templates::Rake.find_rakefile(
|
152
|
+
rakefile_path = Templates::Rake.find_rakefile(
|
153
|
+
template.rakefile_path, template.context_directory || context_directory
|
154
|
+
)
|
139
155
|
raise "Cannot find #{template.rakefile_path}" unless rakefile_path
|
140
156
|
context_dir = ::File.dirname(rakefile_path)
|
141
157
|
rake = Templates::Rake.prepare_rake(rakefile_path, context_dir)
|
data/lib/toys/templates/rdoc.rb
CHANGED
@@ -60,6 +60,8 @@ module Toys
|
|
60
60
|
# enabled. See the documentation for the
|
61
61
|
# [bundler mixin](https://dazuma.github.io/toys/gems/toys-core/latest/Toys/StandardMixins/Bundler)
|
62
62
|
# for information on available options.
|
63
|
+
# @param context_directory [String] A custom context directory to use
|
64
|
+
# when executing this tool.
|
63
65
|
#
|
64
66
|
def initialize(name: nil,
|
65
67
|
gem_version: nil,
|
@@ -71,7 +73,8 @@ module Toys
|
|
71
73
|
template: nil,
|
72
74
|
generator: nil,
|
73
75
|
options: [],
|
74
|
-
bundler: false
|
76
|
+
bundler: false,
|
77
|
+
context_directory: nil)
|
75
78
|
@name = name
|
76
79
|
@gem_version = gem_version
|
77
80
|
@files = files
|
@@ -83,6 +86,7 @@ module Toys
|
|
83
86
|
@generator = generator
|
84
87
|
@options = options
|
85
88
|
@bundler = bundler
|
89
|
+
@context_directory = context_directory
|
86
90
|
end
|
87
91
|
|
88
92
|
##
|
@@ -174,6 +178,14 @@ module Toys
|
|
174
178
|
#
|
175
179
|
attr_writer :options
|
176
180
|
|
181
|
+
##
|
182
|
+
# Custom context directory for this tool.
|
183
|
+
#
|
184
|
+
# @param value [String]
|
185
|
+
# @return [String]
|
186
|
+
#
|
187
|
+
attr_writer :context_directory
|
188
|
+
|
177
189
|
##
|
178
190
|
# Set the bundler state and options for this tool.
|
179
191
|
#
|
@@ -213,7 +225,7 @@ module Toys
|
|
213
225
|
# @private
|
214
226
|
attr_reader :generator
|
215
227
|
# @private
|
216
|
-
attr_reader :
|
228
|
+
attr_reader :context_directory
|
217
229
|
|
218
230
|
# @private
|
219
231
|
def name
|
@@ -236,6 +248,11 @@ module Toys
|
|
236
248
|
@output_dir || DEFAULT_OUTPUT_DIR
|
237
249
|
end
|
238
250
|
|
251
|
+
# @private
|
252
|
+
def options
|
253
|
+
Array(@options)
|
254
|
+
end
|
255
|
+
|
239
256
|
# @private
|
240
257
|
def bundler_settings
|
241
258
|
if @bundler && !@bundler.is_a?(::Hash)
|
@@ -249,6 +266,8 @@ module Toys
|
|
249
266
|
tool(template.name) do
|
250
267
|
desc "Run rdoc on the current project."
|
251
268
|
|
269
|
+
set_context_directory template.context_directory if template.context_directory
|
270
|
+
|
252
271
|
include :exec, exit_on_nonzero_status: true
|
253
272
|
include :gems
|
254
273
|
|
@@ -256,7 +275,7 @@ module Toys
|
|
256
275
|
include :bundler, **bundler_settings if bundler_settings
|
257
276
|
|
258
277
|
to_run do
|
259
|
-
gem_requirements =
|
278
|
+
gem_requirements = template.gem_version
|
260
279
|
gem "rdoc", *gem_requirements
|
261
280
|
|
262
281
|
::Dir.chdir(context_directory || ::Dir.getwd) do
|
data/lib/toys/templates/rspec.rb
CHANGED
@@ -68,6 +68,8 @@ module Toys
|
|
68
68
|
# enabled. See the documentation for the
|
69
69
|
# [bundler mixin](https://dazuma.github.io/toys/gems/toys-core/latest/Toys/StandardMixins/Bundler)
|
70
70
|
# for information on available options.
|
71
|
+
# @param context_directory [String] A custom context directory to use
|
72
|
+
# when executing this tool.
|
71
73
|
#
|
72
74
|
def initialize(name: nil,
|
73
75
|
gem_version: nil,
|
@@ -79,7 +81,8 @@ module Toys
|
|
79
81
|
backtrace: false,
|
80
82
|
pattern: nil,
|
81
83
|
warnings: true,
|
82
|
-
bundler: false
|
84
|
+
bundler: false,
|
85
|
+
context_directory: nil)
|
83
86
|
@name = name
|
84
87
|
@gem_version = gem_version
|
85
88
|
@libs = libs
|
@@ -91,6 +94,7 @@ module Toys
|
|
91
94
|
@pattern = pattern
|
92
95
|
@warnings = warnings
|
93
96
|
@bundler = bundler
|
97
|
+
@context_directory = context_directory
|
94
98
|
end
|
95
99
|
|
96
100
|
##
|
@@ -181,6 +185,14 @@ module Toys
|
|
181
185
|
#
|
182
186
|
attr_writer :warnings
|
183
187
|
|
188
|
+
##
|
189
|
+
# Custom context directory for this tool.
|
190
|
+
#
|
191
|
+
# @param value [String]
|
192
|
+
# @return [String]
|
193
|
+
#
|
194
|
+
attr_writer :context_directory
|
195
|
+
|
184
196
|
##
|
185
197
|
# Set the bundler state and options for this tool.
|
186
198
|
#
|
@@ -217,6 +229,8 @@ module Toys
|
|
217
229
|
attr_reader :backtrace
|
218
230
|
## @private
|
219
231
|
attr_reader :warnings
|
232
|
+
# @private
|
233
|
+
attr_reader :context_directory
|
220
234
|
|
221
235
|
# @private
|
222
236
|
def name
|
@@ -262,6 +276,8 @@ module Toys
|
|
262
276
|
tool(template.name) do
|
263
277
|
desc "Run rspec on the current project."
|
264
278
|
|
279
|
+
set_context_directory template.context_directory if template.context_directory
|
280
|
+
|
265
281
|
include :exec
|
266
282
|
include :gems
|
267
283
|
|
@@ -36,17 +36,21 @@ module Toys
|
|
36
36
|
# enabled. See the documentation for the
|
37
37
|
# [bundler mixin](https://dazuma.github.io/toys/gems/toys-core/latest/Toys/StandardMixins/Bundler)
|
38
38
|
# for information on available options.
|
39
|
+
# @param context_directory [String] A custom context directory to use
|
40
|
+
# when executing this tool.
|
39
41
|
#
|
40
42
|
def initialize(name: DEFAULT_TOOL_NAME,
|
41
43
|
gem_version: nil,
|
42
44
|
fail_on_error: true,
|
43
45
|
options: [],
|
44
|
-
bundler: false
|
46
|
+
bundler: false,
|
47
|
+
context_directory: nil)
|
45
48
|
@name = name
|
46
49
|
@gem_version = gem_version
|
47
50
|
@fail_on_error = fail_on_error
|
48
51
|
@options = options
|
49
52
|
@bundler = bundler
|
53
|
+
@context_directory = context_directory
|
50
54
|
end
|
51
55
|
|
52
56
|
##
|
@@ -84,6 +88,14 @@ module Toys
|
|
84
88
|
#
|
85
89
|
attr_writer :options
|
86
90
|
|
91
|
+
##
|
92
|
+
# Custom context directory for this tool.
|
93
|
+
#
|
94
|
+
# @param value [String]
|
95
|
+
# @return [String]
|
96
|
+
#
|
97
|
+
attr_writer :context_directory
|
98
|
+
|
87
99
|
##
|
88
100
|
# Set the bundler state and options for this tool.
|
89
101
|
#
|
@@ -114,8 +126,8 @@ module Toys
|
|
114
126
|
|
115
127
|
## @private
|
116
128
|
attr_reader :fail_on_error
|
117
|
-
|
118
|
-
attr_reader :
|
129
|
+
# @private
|
130
|
+
attr_reader :context_directory
|
119
131
|
|
120
132
|
# @private
|
121
133
|
def name
|
@@ -128,6 +140,11 @@ module Toys
|
|
128
140
|
@bundler ? [] : DEFAULT_GEM_VERSION_REQUIREMENTS
|
129
141
|
end
|
130
142
|
|
143
|
+
# @private
|
144
|
+
def options
|
145
|
+
Array(@options)
|
146
|
+
end
|
147
|
+
|
131
148
|
# @private
|
132
149
|
def bundler_settings
|
133
150
|
if @bundler && !@bundler.is_a?(::Hash)
|
@@ -141,6 +158,8 @@ module Toys
|
|
141
158
|
tool(template.name) do
|
142
159
|
desc "Run rubocop on the current project."
|
143
160
|
|
161
|
+
set_context_directory template.context_directory if template.context_directory
|
162
|
+
|
144
163
|
include :gems
|
145
164
|
include :exec
|
146
165
|
|
@@ -78,6 +78,8 @@ module Toys
|
|
78
78
|
# enabled. See the documentation for the
|
79
79
|
# [bundler mixin](https://dazuma.github.io/toys/gems/toys-core/latest/Toys/StandardMixins/Bundler)
|
80
80
|
# for information on available options.
|
81
|
+
# @param context_directory [String] A custom context directory to use
|
82
|
+
# when executing this tool.
|
81
83
|
#
|
82
84
|
def initialize(name: nil,
|
83
85
|
gem_version: nil,
|
@@ -98,7 +100,8 @@ module Toys
|
|
98
100
|
format: nil,
|
99
101
|
options: [],
|
100
102
|
stats_options: [],
|
101
|
-
bundler: false
|
103
|
+
bundler: false,
|
104
|
+
context_directory: nil)
|
102
105
|
@name = name
|
103
106
|
@gem_version = gem_version
|
104
107
|
@files = files
|
@@ -119,6 +122,7 @@ module Toys
|
|
119
122
|
@options = options
|
120
123
|
@stats_options = stats_options
|
121
124
|
@bundler = bundler
|
125
|
+
@context_directory = context_directory
|
122
126
|
end
|
123
127
|
|
124
128
|
##
|
@@ -286,6 +290,14 @@ module Toys
|
|
286
290
|
#
|
287
291
|
attr_writer :stats_options
|
288
292
|
|
293
|
+
##
|
294
|
+
# Custom context directory for this tool.
|
295
|
+
#
|
296
|
+
# @param value [String]
|
297
|
+
# @return [String]
|
298
|
+
#
|
299
|
+
attr_writer :context_directory
|
300
|
+
|
289
301
|
##
|
290
302
|
# Set the bundler state and options for this tool.
|
291
303
|
#
|
@@ -341,9 +353,7 @@ module Toys
|
|
341
353
|
# @private
|
342
354
|
attr_reader :format
|
343
355
|
# @private
|
344
|
-
attr_reader :
|
345
|
-
# @private
|
346
|
-
attr_reader :stats_options
|
356
|
+
attr_reader :context_directory
|
347
357
|
|
348
358
|
# @private
|
349
359
|
def name
|
@@ -366,6 +376,16 @@ module Toys
|
|
366
376
|
@output_dir || DEFAULT_OUTPUT_DIR
|
367
377
|
end
|
368
378
|
|
379
|
+
# @private
|
380
|
+
def options
|
381
|
+
Array(@options)
|
382
|
+
end
|
383
|
+
|
384
|
+
# @private
|
385
|
+
def stats_options
|
386
|
+
Array(@stats_options)
|
387
|
+
end
|
388
|
+
|
369
389
|
# @private
|
370
390
|
def bundler_settings
|
371
391
|
if @bundler && !@bundler.is_a?(::Hash)
|
@@ -379,6 +399,8 @@ module Toys
|
|
379
399
|
tool(template.name) do
|
380
400
|
desc "Run yardoc on the current project."
|
381
401
|
|
402
|
+
set_context_directory template.context_directory if template.context_directory
|
403
|
+
|
382
404
|
if template.generate_output_flag
|
383
405
|
flag :generate_output, "--[no-]output",
|
384
406
|
default: template.generate_output,
|
@@ -447,13 +469,11 @@ module Toys
|
|
447
469
|
exit(1)
|
448
470
|
end
|
449
471
|
exit_on_nonzero_status(result)
|
450
|
-
if template.fail_on_undocumented_objects
|
451
|
-
|
452
|
-
|
453
|
-
puts("Yardoc encountered undocumented objects", :red, :bold)
|
454
|
-
end
|
455
|
-
exit(1)
|
472
|
+
if template.fail_on_undocumented_objects && result.captured_out =~ /Undocumented\sObjects:/
|
473
|
+
unless verbosity.negative?
|
474
|
+
puts("Yardoc encountered undocumented objects", :red, :bold)
|
456
475
|
end
|
476
|
+
exit(1)
|
457
477
|
end
|
458
478
|
end
|
459
479
|
end
|