toys 0.6.1 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/docs/guide.md +100 -9
- data/lib/toys/standard_cli.rb +13 -6
- data/lib/toys/templates/minitest.rb +23 -5
- data/lib/toys/templates/rspec.rb +193 -0
- data/lib/toys/templates/rubocop.rb +2 -2
- data/lib/toys/version.rb +1 -1
- metadata +19 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f9aca0f88db86e761a9c149409ac63f3abe8965f8bc3ed32c0367f248cfcb953
|
4
|
+
data.tar.gz: 8e23447ec1fb3ccc91d0367bd120bcc388147cd7b114cc9e3d1e91833323076a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 99865d61911d609c1dcf55ba6190f16f4bc00e044b696fed1b6bf202f29e3a0533ce87a971fbe1ae1b9cd83ec57a0a62f1eff49efd7f2801818bd43eafefd07e
|
7
|
+
data.tar.gz: a5ae272ae4585690cf5ab0abf7beabd9ba356203a26ebac976e90f94ca5a2120f62dd7a57b80ddc5907d7c04158e304df0a048dec543121b993de0fd8a7868fd
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
# Release History
|
2
2
|
|
3
|
+
### 0.7.0 / 2019-01-23
|
4
|
+
|
5
|
+
* ADDED: A template for creating tools that invoke RSpec.
|
6
|
+
* ADDED: Flag groups, which enforce policies around which flags are required.
|
7
|
+
* CHANGED: Flags within a group are sorted in the help screens.
|
8
|
+
* IMPROVED: The minitest template now honors all standard minitest flags.
|
9
|
+
|
3
10
|
### 0.6.1 / 2019-01-07
|
4
11
|
|
5
12
|
* FIXED: The presence of aliases caused subtool listing to crash.
|
data/docs/guide.md
CHANGED
@@ -32,7 +32,9 @@ that have **subtools**.
|
|
32
32
|
|
33
33
|
Tools may recognize command line arguments in the form of **flags** and
|
34
34
|
**positional arguments**. Flags can optionally take **values**, while
|
35
|
-
positional arguments may be **required** or **optional**.
|
35
|
+
positional arguments may be **required** or **optional**. Flags may be
|
36
|
+
organized into **flag groups** which support different kinds of constraints on
|
37
|
+
which flags are required.
|
36
38
|
|
37
39
|
The configuration of a tool may include **descriptions**, for the tool itself,
|
38
40
|
and for each command line argument. These descriptions are displayed in the
|
@@ -193,10 +195,13 @@ their own) always behave as though `--help` is invoked. (They do recognize the
|
|
193
195
|
flag, but it has no additional effect.) Namespaces also support the following
|
194
196
|
additional flags:
|
195
197
|
|
198
|
+
* `--all` which displays all subtools, including
|
199
|
+
[hidden subtools](#Hidden_Tools) and namespaces.
|
196
200
|
* `--[no-]recursive` (also `-r`) which displays all subtools recursively,
|
197
201
|
instead of only the immediate subtools.
|
198
202
|
* `--search=TERM` which displays only subtools whose name or description
|
199
203
|
contain the specified search term.
|
204
|
+
* `--tools` which displays just the list of subtools.
|
200
205
|
|
201
206
|
Finally, the root tool also supports:
|
202
207
|
|
@@ -657,6 +662,72 @@ way, Toys provides an alternate syntax for defining flags using a block.
|
|
657
662
|
For detailed info on configuring an flag using a block, see the
|
658
663
|
[Toys::DSL::Flag class](https://www.rubydoc.info/gems/toys-core/Toys/DSL/Flag).
|
659
664
|
|
665
|
+
#### Flag Groups
|
666
|
+
|
667
|
+
Flags may be organized into groups. This serves two functions:
|
668
|
+
|
669
|
+
* Grouping related flags in the help and usage screens
|
670
|
+
* Implementing required flags and other constraints
|
671
|
+
|
672
|
+
To create a simple flag group, use the `flag_group` directive, and provide a
|
673
|
+
block that defines the group's flags. You may also provide a group description
|
674
|
+
that appears in the help screen.
|
675
|
+
|
676
|
+
flag_group desc: "Debug flags" do
|
677
|
+
flag :debug, "-D", desc: "Enable debugger"
|
678
|
+
flag :warnings, "-W[VAL]", desc: "Enable warnings"
|
679
|
+
end
|
680
|
+
|
681
|
+
Flag groups may have a "type" that specifies constraints on the flags contained
|
682
|
+
in the group. Flags in a simple group like the above are ordinary optional
|
683
|
+
flags. However, you may specify that flags in the group are required using the
|
684
|
+
`all_required` directive:
|
685
|
+
|
686
|
+
all_required desc: "Login flags (all required)" do
|
687
|
+
flag :username, "--username=VAL", desc: "Set the username (required)"
|
688
|
+
flag :password, "--password=VAL", desc: "Set the password (required)"
|
689
|
+
end
|
690
|
+
|
691
|
+
If the tool is invoked without providing each of these required flags, it will
|
692
|
+
display an option parsing error.
|
693
|
+
|
694
|
+
The `all_required` directive is actually just shorthand for passing
|
695
|
+
`type: :required` to the `flag_group` directive. So the above is the same as:
|
696
|
+
|
697
|
+
flag_group type: :required, desc: "Login flags (all required)" do
|
698
|
+
flag :username, "--username=VAL", desc: "Set the username (required)"
|
699
|
+
flag :password, "--password=VAL", desc: "Set the password (required)"
|
700
|
+
end
|
701
|
+
|
702
|
+
There are several other types of flag groups:
|
703
|
+
|
704
|
+
* The `:exactly_one` type, which you can create using the directive
|
705
|
+
`exactly_one_required`. Exactly one, and no more than one, flag from the
|
706
|
+
group must be provided on the command line to avoid an error.
|
707
|
+
* The `:at_most_one` type, which you can create using the directive
|
708
|
+
`at_most_one_required`. At most one flag from the group must be provided
|
709
|
+
on the command line to avoid an error.
|
710
|
+
* The `:at_least_one` type, which you can create using the directive
|
711
|
+
`at_least_one_required`. At least one flag from the group must be provided
|
712
|
+
on the command line to avoid an error.
|
713
|
+
|
714
|
+
Flag group types are useful for a variety of tools. For example, suppose you
|
715
|
+
are writing a tool that deploys an app to one of several different kinds of
|
716
|
+
targets---say, a server, a VM, or a container. You could provide this
|
717
|
+
configuration for your tool with a flag group:
|
718
|
+
|
719
|
+
tool "deploy" do
|
720
|
+
exactly_one_required desc: "Deployment targets" do
|
721
|
+
flag :server, "--server=IP_ADDR"
|
722
|
+
flag :vm, "--vm=VM_ID"
|
723
|
+
flag :container, "--container=CONTAINER_ID"
|
724
|
+
end
|
725
|
+
|
726
|
+
def run
|
727
|
+
# Now exactly one of server, vm, or container will be set.
|
728
|
+
end
|
729
|
+
end
|
730
|
+
|
660
731
|
### Tool Execution Basics
|
661
732
|
|
662
733
|
When you run a tool from the command line, Toys will build the tool based on
|
@@ -951,9 +1022,10 @@ When Toys runs, it looks for tools in a **search path**. Specifically:
|
|
951
1022
|
working directory*.
|
952
1023
|
(2) It does the same in the *parent directory* of the current directory, and
|
953
1024
|
then its parent, all the way up to the root of the file system.
|
954
|
-
(3) It does the same in the current user's *home directory
|
1025
|
+
(3) It does the same in the current user's *home directory* (but does not
|
1026
|
+
proceed to parents of the home directory).
|
955
1027
|
(4) It does the same in the system configuration directory (i.e. `/etc` on unix
|
956
|
-
systems)
|
1028
|
+
systems).
|
957
1029
|
|
958
1030
|
It uses the *first* implementation that it finds for the requested tool. For
|
959
1031
|
example, if the tool `greet` is defined in the `.toys.rb` file in the current
|
@@ -1790,7 +1862,7 @@ with:
|
|
1790
1862
|
|
1791
1863
|
toys test
|
1792
1864
|
|
1793
|
-
Similarly, a task named `test:integration` can be
|
1865
|
+
Similarly, a task named `test:integration` can be invoked with either of the
|
1794
1866
|
following:
|
1795
1867
|
|
1796
1868
|
toys test integration
|
@@ -1863,14 +1935,22 @@ can use either or both tools, depending on your needs.
|
|
1863
1935
|
|
1864
1936
|
### Running Tests
|
1865
1937
|
|
1866
|
-
Toys provides a built-in template
|
1867
|
-
|
1868
|
-
|
1869
|
-
uses the minitest template to create a tool called `test`:
|
1938
|
+
Toys provides a built-in template called `:minitest` for running unit tests
|
1939
|
+
with [minitest](https://github.com/seattlerb/minitest). The following example
|
1940
|
+
directive uses the minitest template to create a tool called `test`:
|
1870
1941
|
|
1871
1942
|
expand :minitest, files: ["test/test*.rb"], libs: ["lib", "ext"]
|
1872
1943
|
|
1873
|
-
See the {Toys::Templates::Minitest} documentation for details on the
|
1944
|
+
See the {Toys::Templates::Minitest} documentation for details on the available
|
1945
|
+
options.
|
1946
|
+
|
1947
|
+
Toys also provides a built-in template called `:rspec` for running BDD examples
|
1948
|
+
using [RSpec](http://rspec.info). The following example directive uses this
|
1949
|
+
template to create a tool called `spec`:
|
1950
|
+
|
1951
|
+
expand :rspec, pattern: "spec/**/*_spec.rb", libs: ["lib, "ext"]
|
1952
|
+
|
1953
|
+
See the {Toys::Templates::Rspec} documentation for details on the available
|
1874
1954
|
options.
|
1875
1955
|
|
1876
1956
|
If you want to enforce code style using the
|
@@ -2370,6 +2450,17 @@ context directory to `my-repo/gem1`. Here's what that could look like:
|
|
2370
2450
|
# etc.
|
2371
2451
|
end
|
2372
2452
|
|
2453
|
+
### Hidden Tools
|
2454
|
+
|
2455
|
+
Tools whose name begins with an underscore (e.g. `_foo`) are called "hidden"
|
2456
|
+
tools. They can be executed the same as any other tool, but are normally
|
2457
|
+
omitted from the subtool list displayed in help and usage screens. You may use
|
2458
|
+
hidden tools as "internal" tools that are meant to be called only as part of
|
2459
|
+
the implementation of other tools.
|
2460
|
+
|
2461
|
+
If you pass the `--all` flag when displaying help, the help screen will include
|
2462
|
+
hidden tools in the subtools list.
|
2463
|
+
|
2373
2464
|
## Toys Administration Using the System Tools
|
2374
2465
|
|
2375
2466
|
Toys comes with a few built-in tools, including some that let you administer
|
data/lib/toys/standard_cli.rb
CHANGED
@@ -114,6 +114,12 @@ module Toys
|
|
114
114
|
#
|
115
115
|
DEFAULT_VERSION_FLAG_DESC = "Show the version of Toys."
|
116
116
|
|
117
|
+
##
|
118
|
+
# Name of the toys path environment variable
|
119
|
+
# @return [String]
|
120
|
+
#
|
121
|
+
TOYS_PATH_ENV = "TOYS_PATH"
|
122
|
+
|
117
123
|
##
|
118
124
|
# Create a standard CLI, configured with the appropriate paths and
|
119
125
|
# middleware.
|
@@ -223,12 +229,13 @@ module Toys
|
|
223
229
|
# @return [Array<String>]
|
224
230
|
#
|
225
231
|
def self.default_global_dirs
|
226
|
-
paths = ::ENV[
|
227
|
-
if paths.empty?
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
+
paths = ::ENV[TOYS_PATH_ENV].to_s.split(::File::PATH_SEPARATOR)
|
233
|
+
paths = [::Dir.home, "/etc"] if paths.empty?
|
234
|
+
paths
|
235
|
+
.compact
|
236
|
+
.uniq
|
237
|
+
.select { |path| ::File.directory?(path) && ::File.readable?(path) }
|
238
|
+
.map { |path| ::File.realpath(::File.expand_path(path)) }
|
232
239
|
end
|
233
240
|
|
234
241
|
##
|
@@ -79,11 +79,15 @@ module Toys
|
|
79
79
|
gem_version: nil,
|
80
80
|
libs: nil,
|
81
81
|
files: nil,
|
82
|
+
seed: nil,
|
83
|
+
verbose: false,
|
82
84
|
warnings: true)
|
83
85
|
@name = name || DEFAULT_TOOL_NAME
|
84
86
|
@gem_version = gem_version || DEFAULT_GEM_VERSION_REQUIREMENTS
|
85
87
|
@libs = libs || DEFAULT_LIBS
|
86
88
|
@files = files || DEFAULT_FILES
|
89
|
+
@seed = seed
|
90
|
+
@verbose = verbose
|
87
91
|
@warnings = warnings
|
88
92
|
end
|
89
93
|
|
@@ -91,6 +95,8 @@ module Toys
|
|
91
95
|
attr_accessor :gem_version
|
92
96
|
attr_accessor :libs
|
93
97
|
attr_accessor :files
|
98
|
+
attr_accessor :seed
|
99
|
+
attr_accessor :verbose
|
94
100
|
attr_accessor :warnings
|
95
101
|
|
96
102
|
to_expand do |template|
|
@@ -100,9 +106,15 @@ module Toys
|
|
100
106
|
include :exec
|
101
107
|
include :gems
|
102
108
|
|
109
|
+
flag :seed, "-s", "--seed SEED",
|
110
|
+
default: template.seed, desc: "Sets random seed."
|
103
111
|
flag :warnings, "-w", "--[no-]warnings",
|
104
112
|
default: template.warnings,
|
105
113
|
desc: "Turn on Ruby warnings (defaults to #{template.warnings})"
|
114
|
+
flag :name, "-n", "--name PATTERN",
|
115
|
+
desc: "Filter run on /regexp/ or string."
|
116
|
+
flag :exclude, "-e", "--exclude PATTERN",
|
117
|
+
desc: "Exclude /regexp/ or string from run."
|
106
118
|
|
107
119
|
remaining_args :tests, desc: "Paths to the tests to run (defaults to all tests)"
|
108
120
|
|
@@ -111,11 +123,16 @@ module Toys
|
|
111
123
|
|
112
124
|
::Dir.chdir(context_directory || ::Dir.getwd) do
|
113
125
|
ruby_args = []
|
114
|
-
|
115
|
-
|
116
|
-
ruby_args << "-I#{lib_path}"
|
117
|
-
end
|
126
|
+
libs = Array(template.libs)
|
127
|
+
ruby_args << "-I#{libs.join(::File::PATH_SEPARATOR)}" unless libs.empty?
|
118
128
|
ruby_args << "-w" if warnings
|
129
|
+
ruby_args << "-"
|
130
|
+
ruby_args << "--seed" << seed if seed
|
131
|
+
vv = verbosity
|
132
|
+
vv += 1 if template.verbose
|
133
|
+
ruby_args << "--verbose" if vv.positive?
|
134
|
+
ruby_args << "--name" << name if name
|
135
|
+
ruby_args << "--exclude" << exclude if exclude
|
119
136
|
|
120
137
|
if tests.empty?
|
121
138
|
Array(template.files).each do |pattern|
|
@@ -124,7 +141,8 @@ module Toys
|
|
124
141
|
tests.uniq!
|
125
142
|
end
|
126
143
|
|
127
|
-
result =
|
144
|
+
result = exec_ruby(ruby_args, in: :controller) do |controller|
|
145
|
+
controller.in.puts("require 'minitest/autorun'")
|
128
146
|
tests.each do |file|
|
129
147
|
controller.in.puts("load '#{file}'")
|
130
148
|
end
|
@@ -0,0 +1,193 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright 2018 Daniel Azuma
|
4
|
+
#
|
5
|
+
# All rights reserved.
|
6
|
+
#
|
7
|
+
# Redistribution and use in source and binary forms, with or without
|
8
|
+
# modification, are permitted provided that the following conditions are met:
|
9
|
+
#
|
10
|
+
# * Redistributions of source code must retain the above copyright notice,
|
11
|
+
# this list of conditions and the following disclaimer.
|
12
|
+
# * Redistributions in binary form must reproduce the above copyright notice,
|
13
|
+
# this list of conditions and the following disclaimer in the documentation
|
14
|
+
# and/or other materials provided with the distribution.
|
15
|
+
# * Neither the name of the copyright holder, nor the names of any other
|
16
|
+
# contributors to this software, may be used to endorse or promote products
|
17
|
+
# derived from this software without specific prior written permission.
|
18
|
+
#
|
19
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
20
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
21
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
22
|
+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
23
|
+
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
24
|
+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
25
|
+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
26
|
+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
27
|
+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
28
|
+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
29
|
+
# POSSIBILITY OF SUCH DAMAGE.
|
30
|
+
;
|
31
|
+
|
32
|
+
module Toys
|
33
|
+
module Templates
|
34
|
+
##
|
35
|
+
# A template for tools that run rspec
|
36
|
+
#
|
37
|
+
class Rspec
|
38
|
+
include Template
|
39
|
+
|
40
|
+
##
|
41
|
+
# Default version requirements for the rspec gem.
|
42
|
+
# @return [Array<String>]
|
43
|
+
#
|
44
|
+
DEFAULT_GEM_VERSION_REQUIREMENTS = "~> 3.1"
|
45
|
+
|
46
|
+
##
|
47
|
+
# Default tool name
|
48
|
+
# @return [String]
|
49
|
+
#
|
50
|
+
DEFAULT_TOOL_NAME = "spec"
|
51
|
+
|
52
|
+
##
|
53
|
+
# Default set of library paths
|
54
|
+
# @return [Array<String>]
|
55
|
+
#
|
56
|
+
DEFAULT_LIBS = ["lib"].freeze
|
57
|
+
|
58
|
+
##
|
59
|
+
# Default order type
|
60
|
+
# @return [String]
|
61
|
+
#
|
62
|
+
DEFAULT_ORDER = "defined"
|
63
|
+
|
64
|
+
##
|
65
|
+
# Default spec file glob
|
66
|
+
# @return [String]
|
67
|
+
#
|
68
|
+
DEFAULT_PATTERN = "spec/**/*_spec.rb"
|
69
|
+
|
70
|
+
##
|
71
|
+
# Create the template settings for the RSpec template.
|
72
|
+
#
|
73
|
+
# @param [String] name Name of the tool to create. Defaults to
|
74
|
+
# {DEFAULT_TOOL_NAME}.
|
75
|
+
# @param [String,Array<String>] gem_version Version requirements for
|
76
|
+
# the rspec gem. Defaults to {DEFAULT_GEM_VERSION_REQUIREMENTS}.
|
77
|
+
# @param [Array<String>] libs An array of library paths to add to the
|
78
|
+
# ruby require path. Defaults to {DEFAULT_LIBS}.
|
79
|
+
# @param [String] options The path to a custom options file.
|
80
|
+
# @param [String] order The order in which to run examples. Default is
|
81
|
+
# {DEFAULT_ORDER}.
|
82
|
+
# @param [String] format Choose a formatter code. Default is `p`.
|
83
|
+
# @param [String] out Write output to a file instead of stdout.
|
84
|
+
# @param [Boolean] backtrace Enable full backtrace (default is false).
|
85
|
+
# @param [String] pattern A glob indicating the spec files to load.
|
86
|
+
# Defaults to {DEFAULT_PATTERN}.
|
87
|
+
# @param [Boolean] warnings If true, runs specs with Ruby warnings.
|
88
|
+
# Defaults to true.
|
89
|
+
#
|
90
|
+
def initialize(name: nil,
|
91
|
+
gem_version: nil,
|
92
|
+
libs: nil,
|
93
|
+
options: nil,
|
94
|
+
order: nil,
|
95
|
+
format: nil,
|
96
|
+
out: nil,
|
97
|
+
backtrace: false,
|
98
|
+
pattern: nil,
|
99
|
+
warnings: true)
|
100
|
+
@name = name || DEFAULT_TOOL_NAME
|
101
|
+
@gem_version = gem_version || DEFAULT_GEM_VERSION_REQUIREMENTS
|
102
|
+
@libs = libs || DEFAULT_LIBS
|
103
|
+
@options = options
|
104
|
+
@order = order || DEFAULT_ORDER
|
105
|
+
@format = format || "p"
|
106
|
+
@out = out
|
107
|
+
@backtrace = backtrace
|
108
|
+
@pattern = pattern || DEFAULT_PATTERN
|
109
|
+
@warnings = warnings
|
110
|
+
end
|
111
|
+
|
112
|
+
attr_accessor :name
|
113
|
+
attr_accessor :gem_version
|
114
|
+
attr_accessor :libs
|
115
|
+
attr_accessor :options
|
116
|
+
attr_accessor :order
|
117
|
+
attr_accessor :format
|
118
|
+
attr_accessor :out
|
119
|
+
attr_accessor :backtrace
|
120
|
+
attr_accessor :pattern
|
121
|
+
attr_accessor :warnings
|
122
|
+
|
123
|
+
to_expand do |template|
|
124
|
+
tool(template.name) do
|
125
|
+
desc "Run rspec on the current project."
|
126
|
+
|
127
|
+
include :exec
|
128
|
+
include :gems
|
129
|
+
|
130
|
+
flag :order, "--order TYPE",
|
131
|
+
default: template.order,
|
132
|
+
desc: "Run examples by the specified order type (default: #{template.order})"
|
133
|
+
flag :format, "-f", "--format FORMATTER",
|
134
|
+
default: template.format,
|
135
|
+
desc: "Choose a formatter (default: #{template.format})"
|
136
|
+
flag :out, "-o", "--out FILE",
|
137
|
+
default: template.out,
|
138
|
+
desc: "Write output to a file (default: #{template.out.inspect})"
|
139
|
+
flag :backtrace, "-b", "--[no-]backtrace",
|
140
|
+
default: template.backtrace,
|
141
|
+
desc: "Enable full backtrace (default: #{template.backtrace})"
|
142
|
+
flag :warnings, "-w", "--[no-]warnings",
|
143
|
+
default: template.warnings,
|
144
|
+
desc: "Turn on Ruby warnings (default: #{template.warnings})"
|
145
|
+
flag :pattern, "-P", "--pattern PATTERN",
|
146
|
+
default: template.pattern,
|
147
|
+
desc: "Load files matching pattern (default: #{template.pattern.inspect})"
|
148
|
+
flag :exclude_pattern, "--exclude-pattern PATTERN",
|
149
|
+
desc: "Load files except those matching pattern."
|
150
|
+
flag :example, "-e", "--example STRING",
|
151
|
+
desc: "Run examples whose full nested names include STRING" \
|
152
|
+
" (may be used more than once)."
|
153
|
+
flag :tag, "-t", "--tag TAG",
|
154
|
+
desc: "Run examples with the specified tag, or exclude" \
|
155
|
+
" examples by adding ~ before the tag."
|
156
|
+
|
157
|
+
remaining_args :files, desc: "Paths to the specs to run (defaults to all specs)"
|
158
|
+
|
159
|
+
to_run do
|
160
|
+
gem "rspec", *Array(template.gem_version)
|
161
|
+
|
162
|
+
::Dir.chdir(context_directory || ::Dir.getwd) do
|
163
|
+
ruby_args = []
|
164
|
+
libs = Array(template.libs)
|
165
|
+
ruby_args << "-I#{libs.join(::File::PATH_SEPARATOR)}" unless libs.empty?
|
166
|
+
ruby_args << "-w" if warnings
|
167
|
+
ruby_args << "-"
|
168
|
+
ruby_args << "--options" << template.options if template.options
|
169
|
+
ruby_args << "--order" << order if order
|
170
|
+
ruby_args << "--format" << format if format
|
171
|
+
ruby_args << "--out" << out if out
|
172
|
+
ruby_args << "--backtrace" if backtrace
|
173
|
+
ruby_args << "--pattern" << pattern
|
174
|
+
ruby_args << "--exclude-pattern" << exclude_pattern if exclude_pattern
|
175
|
+
ruby_args << "--example" << example if example
|
176
|
+
ruby_args << "--tag" << tag if tag
|
177
|
+
ruby_args.concat(files)
|
178
|
+
|
179
|
+
result = exec_ruby(ruby_args, in: :controller) do |controller|
|
180
|
+
controller.in.puts("require 'rspec/core'")
|
181
|
+
controller.in.puts("::RSpec::Core::Runner.invoke")
|
182
|
+
end
|
183
|
+
if result.error?
|
184
|
+
logger.error("RSpec failed!")
|
185
|
+
exit(result.exit_code)
|
186
|
+
end
|
187
|
+
end
|
188
|
+
end
|
189
|
+
end
|
190
|
+
end
|
191
|
+
end
|
192
|
+
end
|
193
|
+
end
|
@@ -87,9 +87,9 @@ module Toys
|
|
87
87
|
require "rubocop"
|
88
88
|
|
89
89
|
::Dir.chdir(context_directory || ::Dir.getwd) do
|
90
|
-
|
90
|
+
rubocop = ::RuboCop::CLI.new
|
91
91
|
logger.info "Running RuboCop..."
|
92
|
-
result =
|
92
|
+
result = rubocop.run(template.options)
|
93
93
|
if result.nonzero?
|
94
94
|
logger.error "RuboCop failed!"
|
95
95
|
exit(1) if template.fail_on_error
|
data/lib/toys/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: toys
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Azuma
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-01-
|
11
|
+
date: 2019-01-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: toys-core
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.7.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
26
|
+
version: 0.7.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: highline
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -108,6 +108,20 @@ dependencies:
|
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '3.4'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rspec
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '3.8'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '3.8'
|
111
125
|
- !ruby/object:Gem::Dependency
|
112
126
|
name: rubocop
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -165,6 +179,7 @@ files:
|
|
165
179
|
- lib/toys/templates/minitest.rb
|
166
180
|
- lib/toys/templates/rake.rb
|
167
181
|
- lib/toys/templates/rdoc.rb
|
182
|
+
- lib/toys/templates/rspec.rb
|
168
183
|
- lib/toys/templates/rubocop.rb
|
169
184
|
- lib/toys/templates/yardoc.rb
|
170
185
|
- lib/toys/version.rb
|