toys 0.7.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,81 +1,97 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2018 Daniel Azuma
3
+ # Copyright 2019 Daniel Azuma
4
4
  #
5
- # All rights reserved.
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
6
11
  #
7
- # Redistribution and use in source and binary forms, with or without
8
- # modification, are permitted provided that the following conditions are met:
12
+ # The above copyright notice and this permission notice shall be included in
13
+ # all copies or substantial portions of the Software.
9
14
  #
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.
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20
+ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21
+ # IN THE SOFTWARE.
30
22
  ;
31
23
 
32
24
  module Toys
33
25
  module Templates
34
26
  ##
35
- # A template for tools that build and release gems
27
+ # A template for tools that build, install, and release gems
36
28
  #
37
29
  class GemBuild
38
30
  include Template
39
31
 
40
32
  ##
41
- # Default tool name
33
+ # Default tool name.
42
34
  # @return [String]
43
35
  #
44
36
  DEFAULT_TOOL_NAME = "build"
45
37
 
38
+ ##
39
+ # Default output flags. If `output_flags` is set to `true`, this is the
40
+ # value used.
41
+ # @return [Array<String>]
42
+ #
43
+ DEFAULT_OUTPUT_FLAGS = ["-o", "--output"].freeze
44
+
46
45
  ##
47
46
  # Create the template settings for the GemBuild template.
48
47
  #
49
- # @param [String] name Name of the tool to create. Defaults to
48
+ # @param name [String] Name of the tool to create. Defaults to
50
49
  # {DEFAULT_TOOL_NAME}.
51
- # @param [String] gem_name Name of the gem to build. If not provided,
50
+ # @param gem_name [String] Name of the gem to build. If not provided,
52
51
  # defaults to the first gemspec file it finds.
53
- # @param [Boolean] push_gem If true, pushes the built gem to rubygems.
54
- # @param [Boolean] tag If true, tags the git repo with the gem version.
55
- # @param [Boolean,String] push_tag If truthy, pushes the new tag to
52
+ # @param output [String] Path to the gem package to generate. Optional.
53
+ # If not provided, generates a default file name based on the gem
54
+ # name and version, under the "pkg" directory.
55
+ # @param output_flags [Array<String>,true] Provide flags on the tool that
56
+ # set the output path. Optional. If not provided, no flags are
57
+ # created. You may set this to an array of flags (e.g. `["-o"]`) or
58
+ # set to `true` to choose {DEFAULT_OUTPUT_FLAGS}.
59
+ # @param push_gem [Boolean] If true, pushes the built gem to rubygems.
60
+ # @param install_gem [Boolean] If true, installs the built gem locally.
61
+ # @param tag [Boolean] If true, tags the git repo with the gem version.
62
+ # @param push_tag [Boolean,String] If truthy, pushes the new tag to
56
63
  # a git remote. You may specify which remote by setting the value to
57
64
  # a string. Otherwise, if the value is simply `true`, the "origin"
58
65
  # remote is used by default.
59
66
  #
60
67
  def initialize(name: DEFAULT_TOOL_NAME,
61
68
  gem_name: nil,
69
+ output: nil,
70
+ output_flags: nil,
62
71
  push_gem: false,
72
+ install_gem: false,
63
73
  tag: false,
64
74
  push_tag: false)
65
75
  @name = name
66
76
  @gem_name = gem_name
77
+ @output = output
78
+ @output_flags = output_flags == true ? DEFAULT_OUTPUT_FLAGS : output_flags
67
79
  @push_gem = push_gem
80
+ @install_gem = install_gem
68
81
  @tag = tag
69
82
  @push_tag = push_tag
70
83
  end
71
84
 
72
85
  attr_accessor :name
73
86
  attr_accessor :gem_name
87
+ attr_accessor :output
88
+ attr_accessor :output_flags
74
89
  attr_accessor :push_gem
90
+ attr_accessor :install_gem
75
91
  attr_accessor :tag
76
92
  attr_accessor :push_tag
77
93
 
78
- to_expand do |template|
94
+ on_expand do |template|
79
95
  unless template.gem_name
80
96
  candidates = ::Dir.chdir(context_directory || ::Dir.getwd) do
81
97
  ::Dir.glob("*.gemspec")
@@ -85,12 +101,25 @@ module Toys
85
101
  end
86
102
  template.gem_name = candidates.first.sub(/\.gemspec$/, "")
87
103
  end
88
- task_type = template.push_gem ? "Release" : "Build"
104
+ task_names = []
105
+ task_names << "Install" if template.install_gem
106
+ task_names << "Release" if template.push_gem
107
+ task_names = task_names.empty? ? "Build" : task_names.join(" and ")
89
108
 
90
109
  tool(template.name) do
91
- desc "#{task_type} the gem: #{template.gem_name}"
110
+ desc "#{task_names} the gem: #{template.gem_name}"
92
111
 
93
112
  flag :yes, "-y", "--yes", desc: "Do not ask for interactive confirmation"
113
+ if template.output_flags
114
+ flag :output do
115
+ flags(Array(template.output_flags).map { |f| "#{f} VAL" })
116
+ desc "output gem with the given filename"
117
+ default template.output
118
+ complete_values :file_system
119
+ end
120
+ else
121
+ static :output, template.output
122
+ end
94
123
 
95
124
  include :exec, exit_on_nonzero_status: true
96
125
  include :fileutils
@@ -99,19 +128,27 @@ module Toys
99
128
  to_run do
100
129
  require "rubygems/package"
101
130
  ::Dir.chdir(context_directory || ::Dir.getwd) do
102
- gemspec = ::Gem::Specification.load("#{template.gem_name}.gemspec")
103
- version = gemspec.version
104
- gemfile = "#{template.gem_name}-#{version}.gem"
131
+ gem_name = template.gem_name
132
+ gemspec = ::Gem::Specification.load("#{gem_name}.gemspec")
105
133
  ::Gem::Package.build(gemspec)
106
- mkdir_p("pkg")
107
- mv(gemfile, "pkg")
134
+ version = gemspec.version
135
+ archive_name = "#{gem_name}-#{version}.gem"
136
+ archive_path = output || "pkg/#{archive_name}"
137
+ if archive_name != archive_path
138
+ mkdir_p(::File.dirname(archive_path))
139
+ mv(archive_name, archive_path)
140
+ end
141
+ if template.install_gem
142
+ exit(1) unless yes || confirm("Install #{gem_name} #{version}? ", default: true)
143
+ exec ["gem", "install", archive_path]
144
+ end
108
145
  if template.push_gem
109
146
  if ::File.directory?(".git") && capture("git status -s").strip != ""
110
147
  logger.error "Cannot push the gem when there are uncommited changes"
111
148
  exit(1)
112
149
  end
113
- exit(1) unless yes || confirm("Release #{gemfile}?", default: true)
114
- exec(["gem", "push", "pkg/#{gemfile}"])
150
+ exit(1) unless yes || confirm("Release #{gem_name} #{version}? ", default: true)
151
+ exec(["gem", "push", archive_path])
115
152
  if template.tag
116
153
  exec(["git", "tag", "v#{version}"])
117
154
  if template.push_tag
@@ -1,32 +1,24 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2018 Daniel Azuma
3
+ # Copyright 2019 Daniel Azuma
4
4
  #
5
- # All rights reserved.
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
6
11
  #
7
- # Redistribution and use in source and binary forms, with or without
8
- # modification, are permitted provided that the following conditions are met:
12
+ # The above copyright notice and this permission notice shall be included in
13
+ # all copies or substantial portions of the Software.
9
14
  #
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.
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20
+ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21
+ # IN THE SOFTWARE.
30
22
  ;
31
23
 
32
24
  module Toys
@@ -64,15 +56,15 @@ module Toys
64
56
  ##
65
57
  # Create the template settings for the Minitest template.
66
58
  #
67
- # @param [String] name Name of the tool to create. Defaults to
59
+ # @param name [String] Name of the tool to create. Defaults to
68
60
  # {DEFAULT_TOOL_NAME}.
69
- # @param [String,Array<String>] gem_version Version requirements for
61
+ # @param gem_version [String,Array<String>] Version requirements for
70
62
  # the minitest gem. Defaults to {DEFAULT_GEM_VERSION_REQUIREMENTS}.
71
- # @param [Array<String>] libs An array of library paths to add to the
63
+ # @param libs [Array<String>] An array of library paths to add to the
72
64
  # ruby require path. Defaults to {DEFAULT_LIBS}.
73
- # @param [Array<String>] files An array of globs indicating the test
65
+ # @param files [Array<String>] An array of globs indicating the test
74
66
  # files to load. Defaults to {DEFAULT_FILES}.
75
- # @param [Boolean] warnings If true, runs tests with Ruby warnings.
67
+ # @param warnings [Boolean] If true, runs tests with Ruby warnings.
76
68
  # Defaults to true.
77
69
  #
78
70
  def initialize(name: nil,
@@ -99,7 +91,7 @@ module Toys
99
91
  attr_accessor :verbose
100
92
  attr_accessor :warnings
101
93
 
102
- to_expand do |template|
94
+ on_expand do |template|
103
95
  tool(template.name) do
104
96
  desc "Run minitest on the current project."
105
97
 
@@ -116,7 +108,9 @@ module Toys
116
108
  flag :exclude, "-e", "--exclude PATTERN",
117
109
  desc: "Exclude /regexp/ or string from run."
118
110
 
119
- remaining_args :tests, desc: "Paths to the tests to run (defaults to all tests)"
111
+ remaining_args :tests,
112
+ complete: :file_system,
113
+ desc: "Paths to the tests to run (defaults to all tests)"
120
114
 
121
115
  to_run do
122
116
  gem "minitest", *Array(template.gem_version)
@@ -1,32 +1,24 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2018 Daniel Azuma
3
+ # Copyright 2019 Daniel Azuma
4
4
  #
5
- # All rights reserved.
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
6
11
  #
7
- # Redistribution and use in source and binary forms, with or without
8
- # modification, are permitted provided that the following conditions are met:
12
+ # The above copyright notice and this permission notice shall be included in
13
+ # all copies or substantial portions of the Software.
9
14
  #
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.
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20
+ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21
+ # IN THE SOFTWARE.
30
22
  ;
31
23
 
32
24
  module Toys
@@ -46,13 +38,13 @@ module Toys
46
38
  ##
47
39
  # Create the template settings for the rake template.
48
40
  #
49
- # @param [String,Array<String>,nil] gem_version Version requirements for
41
+ # @param gem_version [String,Array<String>,nil] Version requirements for
50
42
  # the rake gem. Defaults to nil, indicating no version requirement.
51
- # @param [String] rakefile_path Path to the Rakefile. Defaults to
43
+ # @param rakefile_path [String] Path to the Rakefile. Defaults to
52
44
  # {DEFAULT_RAKEFILE_PATH}.
53
- # @param [Boolean] only_described If true, tools are generated only for
45
+ # @param only_described [Boolean] If true, tools are generated only for
54
46
  # rake tasks with descriptions. Default is false.
55
- # @param [Boolean] use_flags Generated tools use flags instead of
47
+ # @param use_flags [Boolean] Generated tools use flags instead of
56
48
  # positional arguments to pass arguments to rake tasks. Default is
57
49
  # false.
58
50
  #
@@ -71,7 +63,7 @@ module Toys
71
63
  attr_accessor :only_described
72
64
  attr_accessor :use_flags
73
65
 
74
- to_expand do |template|
66
+ on_expand do |template|
75
67
  gem "rake", *Array(template.gem_version)
76
68
  require "rake"
77
69
  rakefile_path = Templates::Rake.find_rakefile(template.rakefile_path, context_directory)
@@ -1,32 +1,24 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2018 Daniel Azuma
3
+ # Copyright 2019 Daniel Azuma
4
4
  #
5
- # All rights reserved.
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
6
11
  #
7
- # Redistribution and use in source and binary forms, with or without
8
- # modification, are permitted provided that the following conditions are met:
12
+ # The above copyright notice and this permission notice shall be included in
13
+ # all copies or substantial portions of the Software.
9
14
  #
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.
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20
+ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21
+ # IN THE SOFTWARE.
30
22
  ;
31
23
 
32
24
  module Toys
@@ -58,25 +50,25 @@ module Toys
58
50
  ##
59
51
  # Create the template settings for the Rdoc template.
60
52
  #
61
- # @param [String] name Name of the tool to create. Defaults to
53
+ # @param name [String] Name of the tool to create. Defaults to
62
54
  # {DEFAULT_TOOL_NAME}.
63
- # @param [String,Array<String>] gem_version Version requirements for
55
+ # @param gem_version [String,Array<String>] Version requirements for
64
56
  # the rdoc gem. Defaults to {DEFAULT_GEM_VERSION_REQUIREMENTS}.
65
- # @param [Array<String>] files An array of globs indicating the files
57
+ # @param files [Array<String>] An array of globs indicating the files
66
58
  # to document.
67
- # @param [String] output_dir Name of directory to receive html output
59
+ # @param output_dir [String] Name of directory to receive html output
68
60
  # files. Defaults to {DEFAULT_OUTPUT_DIR}.
69
- # @param [String,nil] markup Markup format. Allowed values include
61
+ # @param markup [String,nil] Markup format. Allowed values include
70
62
  # "rdoc", "rd", and "tomdoc". Default is "rdoc".
71
- # @param [String,nil] title Title of RDoc documentation. If `nil`, RDoc
63
+ # @param title [String,nil] Title of RDoc documentation. If `nil`, RDoc
72
64
  # will use a default title.
73
- # @param [String,nil] main Name of the file to use as the main top level
65
+ # @param main [String,nil] Name of the file to use as the main top level
74
66
  # document. Default is none.
75
- # @param [String,nil] template Name of the template to use. If `nil`,
67
+ # @param template [String,nil] Name of the template to use. If `nil`,
76
68
  # RDoc will use its default template.
77
- # @param [String,nil] generator Name of the format generator. If `nil`,
69
+ # @param generator [String,nil] Name of the format generator. If `nil`,
78
70
  # RDoc will use its default generator.
79
- # @param [Array<String>] options Additional options to pass to RDoc.
71
+ # @param options [Array<String>] Additional options to pass to RDoc.
80
72
  #
81
73
  def initialize(name: nil,
82
74
  gem_version: nil,
@@ -111,7 +103,7 @@ module Toys
111
103
  attr_accessor :generator
112
104
  attr_accessor :options
113
105
 
114
- to_expand do |template|
106
+ on_expand do |template|
115
107
  tool(template.name) do
116
108
  desc "Run rdoc on the current project."
117
109
 
@@ -1,32 +1,24 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2018 Daniel Azuma
3
+ # Copyright 2019 Daniel Azuma
4
4
  #
5
- # All rights reserved.
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
6
11
  #
7
- # Redistribution and use in source and binary forms, with or without
8
- # modification, are permitted provided that the following conditions are met:
12
+ # The above copyright notice and this permission notice shall be included in
13
+ # all copies or substantial portions of the Software.
9
14
  #
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.
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20
+ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21
+ # IN THE SOFTWARE.
30
22
  ;
31
23
 
32
24
  module Toys
@@ -70,21 +62,21 @@ module Toys
70
62
  ##
71
63
  # Create the template settings for the RSpec template.
72
64
  #
73
- # @param [String] name Name of the tool to create. Defaults to
65
+ # @param name [String] Name of the tool to create. Defaults to
74
66
  # {DEFAULT_TOOL_NAME}.
75
- # @param [String,Array<String>] gem_version Version requirements for
67
+ # @param gem_version [String,Array<String>] Version requirements for
76
68
  # the rspec gem. Defaults to {DEFAULT_GEM_VERSION_REQUIREMENTS}.
77
- # @param [Array<String>] libs An array of library paths to add to the
69
+ # @param libs [Array<String>] An array of library paths to add to the
78
70
  # 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
71
+ # @param options [String] The path to a custom options file.
72
+ # @param order [String] The order in which to run examples. Default is
81
73
  # {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.
74
+ # @param format [String] Choose a formatter code. Default is `p`.
75
+ # @param out [String] Write output to a file instead of stdout.
76
+ # @param backtrace [Boolean] Enable full backtrace (default is false).
77
+ # @param pattern [String] A glob indicating the spec files to load.
86
78
  # Defaults to {DEFAULT_PATTERN}.
87
- # @param [Boolean] warnings If true, runs specs with Ruby warnings.
79
+ # @param warnings [Boolean] If true, runs specs with Ruby warnings.
88
80
  # Defaults to true.
89
81
  #
90
82
  def initialize(name: nil,
@@ -120,7 +112,7 @@ module Toys
120
112
  attr_accessor :pattern
121
113
  attr_accessor :warnings
122
114
 
123
- to_expand do |template|
115
+ on_expand do |template|
124
116
  tool(template.name) do
125
117
  desc "Run rspec on the current project."
126
118
 
@@ -154,7 +146,9 @@ module Toys
154
146
  desc: "Run examples with the specified tag, or exclude" \
155
147
  " examples by adding ~ before the tag."
156
148
 
157
- remaining_args :files, desc: "Paths to the specs to run (defaults to all specs)"
149
+ remaining_args :files,
150
+ complete: :file_system,
151
+ desc: "Paths to the specs to run (defaults to all specs)"
158
152
 
159
153
  to_run do
160
154
  gem "rspec", *Array(template.gem_version)