command_line_boss 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 373be7eee0c1d18087389f4974b750d91f619a3148532a820b642a96a93d554f
4
+ data.tar.gz: a77b6ed4529989587eac6b0e46f293a509691366b6741cd776ddde85e605674b
5
+ SHA512:
6
+ metadata.gz: daa1c02db1176dc01fa4aa447a82cf5b0b54e65434d88e28777686bf78b0451c50ccf0c58549618b1590c11b9741d16eca6efb19dc5cde9e54e64525d5229be5
7
+ data.tar.gz: bd779c0e865f70485e193bbe05c0a6d55095959227f88c958f971f63d2eb3754013570bc9daef2ff249bf62ba919da4d0e66ec14a2436cf32349a147e633fb08
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --require spec_helper
2
+ --color
3
+ --format Fuubar
data/.rubocop.yml ADDED
@@ -0,0 +1,34 @@
1
+ AllCops:
2
+ NewCops: enable
3
+ SuggestExtensions: false
4
+ DefaultFormatter: fuubar
5
+
6
+ # Output extra information for each offense to make it easier to diagnose:
7
+ DisplayCopNames: true
8
+ DisplayStyleGuide: true
9
+ ExtraDetails: true
10
+
11
+ # RuboCop enforces rules depending on the oldest version of Ruby which
12
+ # your project supports:
13
+ TargetRubyVersion: 3.1
14
+
15
+ Gemspec/DevelopmentDependencies:
16
+ Enabled: false
17
+
18
+ Layout/LineLength:
19
+ Max: 120
20
+
21
+ # The DSL for RSpec and the gemspec file make it very hard to limit block length
22
+ Metrics/BlockLength:
23
+ Exclude:
24
+ - '**/*_spec.rb'
25
+ - '*.gemspec'
26
+
27
+ Metrics/ModuleLength:
28
+ CountAsOne: ['hash']
29
+
30
+ Metrics/ClassLength:
31
+ CountAsOne: ['hash']
32
+
33
+ Style/AsciiComments:
34
+ Enabled: false
data/.yardopts ADDED
@@ -0,0 +1 @@
1
+ --exclude examples/**
data/CHANGELOG.md ADDED
@@ -0,0 +1,34 @@
1
+ # Change Log
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## v0.1.0 (2024-07-03)
9
+
10
+ [Full Changelog](https://github.com/main-branch/command_line_boss/compare/6cafbd0..v0.1.0)
11
+
12
+ Changes:
13
+
14
+ * 8051772 Remove JRuby build
15
+ * 6c60ac0 Integrate turnip for testing
16
+ * 07a983d Update CodeClimate test reporter id
17
+ * d605a91 Remove the JRuby windows build
18
+ * da7b1d3 Use minimum supported Ruby (3.1) on Windows
19
+ * bcbddef Define the CI build with Github Actions
20
+ * 0c9be2b Add create_github_release to the project
21
+ * ef55727 Define default rake task
22
+ * 541f2f8 Integrate YARD
23
+ * aa171ea Autocorrect all rubocop offenses
24
+ * c151f47 Integrate Rubocop
25
+ * ba8054e Integrate RSpec
26
+ * 421ea2d Add gem build to Rakefile, exclude /Gemfile.lock, fix rubocop typo
27
+ * d9a9cd6 Integrate Bundler Audit
28
+ * b38761f Start with an empty Rakefile
29
+ * 3972ad8 Define homepage, source, changelog, and doc links
30
+ * 4c1fdf8 Allow the CommandLineBoss gem to be pushed to rubygems
31
+ * 81ea3e2 Require Ruby 3.1.0 or later
32
+ * 4b5fc63 Set gemspec summary and description
33
+ * f5ed145 Move dev dependencies to the gemspec
34
+ * 6cafbd0 Generated version
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at jcouball@yahoo.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2024 James Couball
4
+
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:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
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 FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,340 @@
1
+ # CommandLineBoss
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/command_line_boss.svg)](https://badge.fury.io/rb/command_line_boss)
4
+ [![Documentation](https://img.shields.io/badge/Documentation-Latest-green)](https://rubydoc.info/gems/command_line_boss/)
5
+ [![Change Log](https://img.shields.io/badge/CHANGELOG-Latest-green)](https://rubydoc.info/gems/command_line_boss/file/CHANGELOG.md)
6
+ [![Build Status](https://github.com/main-branch/command_line_boss/actions/workflows/continuous_integration.yml/badge.svg)](https://github.com/main-branch/command_line_boss/actions/workflows/continuous_integration.yml)
7
+ [![Maintainability](https://api.codeclimate.com/v1/badges/513b4d8d95a5e3a77ec6/maintainability)](https://codeclimate.com/github/main-branch/command_line_boss/maintainability)
8
+ [![Test Coverage](https://api.codeclimate.com/v1/badges/513b4d8d95a5e3a77ec6/test_coverage)](https://codeclimate.com/github/main-branch/command_line_boss/test_coverage)
9
+
10
+ CommandLineBoss is built on top of `OptionParser` to make more complex uses of OptionParser easier to manage and test.
11
+
12
+ You are expected to already know how to define options with `OptionParser` in order to use this gem.
13
+
14
+ This gem should be used for traditional options-based command-line interfaces that you would build with `OptionParser`.
15
+
16
+ For defining complex command-line interfaces with multiple commands and subcommands (aka a git-like interface), we recommend using a gem like thor. Other good alternatives also exist.
17
+
18
+ * [Installation](#installation)
19
+ * [Usage](#usage)
20
+ * [Getting started](#getting-started)
21
+ * [Design your command line](#design-your-command-line)
22
+ * [Start your command line parser class](#start-your-command-line-parser-class)
23
+ * [Define options](#define-options)
24
+ * [Define additional validations](#define-additional-validations)
25
+ * [Process with any remaining non-option arguments](#process-with-any-remaining-non-option-arguments)
26
+ * [Optional: define help output](#optional-define-help-output)
27
+ * [Use the parser](#use-the-parser)
28
+ * [Run the command line](#run-the-command-line)
29
+ * [Development](#development)
30
+ * [Contributing](#contributing)
31
+ * [License](#license)
32
+ * [Code of Conduct](#code-of-conduct)
33
+
34
+ ## Installation
35
+
36
+ Install the gem and add to the application's Gemfile by executing:
37
+
38
+ ```shell
39
+ bundle add command_line_boss
40
+ ```
41
+
42
+ If bundler is not being used to manage dependencies, install the gem by executing:
43
+
44
+ ```shell
45
+ gem install command_line_boss
46
+ ```
47
+
48
+ ## Usage
49
+
50
+ More detailed examples are given in the `examples` directory.
51
+
52
+ * `examples/readme_example` - a super-simple example of using this gem. The
53
+ remainder of this section is a walkthrough of this example was constructed.
54
+ * `examples/create_spreadsheet` - a more complicated example complete with
55
+ tests.
56
+
57
+ This section provides a step-by-step guide to building a super simple command line
58
+ using this gem. A parser this simple would probably be easier to implement with
59
+ `OptionParser` directly without this gem. This example is meant to show how you
60
+ can get started.
61
+
62
+ This gem really starts to shine as your command-line interface grows beyond
63
+ something this simple.
64
+
65
+ ### Getting started
66
+
67
+ The end result of this guide can be found in this project in the file
68
+ `examples/readme_example/create-spreadsheet`.
69
+
70
+ Find a suitable directory to create your code in. For this example, all the code
71
+ will live in ONE script file that you create and set its executable permission bit
72
+ via `chmod`.
73
+
74
+ Make sure you have the `command_line_boss` gem installed.
75
+
76
+ ### Design your command line
77
+
78
+ Design the command line following the
79
+ [Google developer documentation style guide for command line syntax](https://developers.google.com/style/code-syntax).
80
+
81
+ Here is what a simple example might look like that creates a spreadsheet with named sheets:
82
+
83
+ ```Text
84
+ Usage:
85
+ create_spreadsheet SPREADSHEET_NAME --sheet=SHEET_NAME [--sheet=SHEET_NAME ...]
86
+ ```
87
+
88
+ ### Start your command line parser class
89
+
90
+ The first step will be to create your own command line parsing class. This class
91
+ must inherit from `CommandLineBoss`.
92
+
93
+ Add the attributess representing the items you want to capture from the command
94
+ line. Set default values for these attributes in a method called `set_defaults`.
95
+
96
+ ```Ruby
97
+ #!/usr/bin/env ruby
98
+
99
+ require 'command_line_boss'
100
+
101
+ class CreateSpreadsheetCli < CommandLineBoss
102
+ attr_reader :spreadsheet_name, :sheet_names
103
+
104
+ private
105
+
106
+ def set_defaults
107
+ @spreadsheet_name = nil
108
+ @sheet_names = []
109
+ end
110
+ end
111
+ ```
112
+
113
+ ### Define options
114
+
115
+ Define private methods whose names follow the pattern `define_*_option`. Methods
116
+ MUST be private or they won't be called.
117
+
118
+ Report any errors by calling `add_error_message` with the text of the error
119
+ message.
120
+
121
+ The return value of these methods is ignored.
122
+
123
+ Continuing the example, add the following code to the `CreateSpreadsheetCli` class:
124
+
125
+ ```Ruby
126
+ class CreateSpreadsheetCli < CommandLineBoss
127
+ # ...
128
+
129
+ private
130
+
131
+ def define_sheet_option
132
+ parser.on('--sheet=SHEET_NAME', 'Name of a sheet to create') do |name|
133
+ add_error_message('Sheet names must be unique!') if sheet_names.include?(name)
134
+ sheet_names << name
135
+ end
136
+ end
137
+ end
138
+ ```
139
+
140
+ ### Define additional validations
141
+
142
+ Define private methods whose names follow the pattern `validate_*`. Methods MUST
143
+ be private or they won't be called.
144
+
145
+ Report any errors by calling `add_error_message` with the text of the error
146
+ message.
147
+
148
+ The return value of these methods is ignored.
149
+
150
+ Continuing the example, add the following code to the `CreateSpreadsheetCli` class:
151
+
152
+ ```Ruby
153
+ class CreateSpreadsheetCli < CommandLineBoss
154
+ # ...
155
+
156
+ private
157
+
158
+ def validate_spreadsheet_name_given
159
+ add_error_message('A spreadsheet name is required') if spreadsheet_name.nil?
160
+ end
161
+
162
+ def validate_at_least_one_sheet_name_given
163
+ add_error_message('At least one sheet name is required') if sheet_names.empty?
164
+ end
165
+ end
166
+ ```
167
+
168
+ ### Process with any remaining non-option arguments
169
+
170
+ Implement `parse_arguments` to deal the remaining non-option arguments from the
171
+ command line. Within this method, the `args` method returns the remaining
172
+ non-option arguments.
173
+
174
+ For example, in the command line `create-spreadsheet "Yearly Sales" --sheet Summary`,
175
+ `args` would return an array `['Yearly Sales']`.
176
+
177
+ Remove any values from `args` that will be used. By default, if `args` is not
178
+ empty after `parse_arguments` returns, an error will result.
179
+
180
+ Report any errors by calling `add_error_message` with the text of the error
181
+ message.
182
+
183
+ The return value of this method is ignored.
184
+
185
+ Continuing the example, add the following code to the `CreateSpreadsheetCli` class:
186
+
187
+ ```Ruby
188
+ class CreateSpreadsheetCli < CommandLineBoss
189
+ # ...
190
+
191
+ private
192
+
193
+ def parse_arguments
194
+ @spreadsheet_name = args.shift
195
+ end
196
+ end
197
+ ```
198
+
199
+ ### Optional: define help output
200
+
201
+ Include the `CommandLineBoss::HelpOption` module add a help option (`-h` and
202
+ `--help`) and structure the help output.
203
+
204
+ Help output is divided into sections that is output as follows:
205
+
206
+ ```text
207
+ BANNER
208
+ HEADER
209
+ OPTIONS
210
+ FOOTER
211
+ ```
212
+
213
+ The OPTIONS section is generated by `OptionsParser`.
214
+
215
+ You may provide the content for the other sections by implementing any or all of the
216
+ methods: `banner`, `header`, and `footer`. These methods are expected to return a
217
+ string with the content.
218
+
219
+ If you do not provide content for the `banner` section, it is generated by
220
+ `OptionsParser`. The default banner looks something like this:
221
+
222
+ ```text
223
+ Usage: create-spreadsheet [options]
224
+ ```
225
+
226
+ If you do not provide content for the `header` or `footer` sections, they are
227
+ omitted from the help output.
228
+
229
+ Continuing the example, add the following code to the `CreateSpreadsheetCli` class:
230
+
231
+ ```Ruby
232
+ class CreateSpreadsheetCli < CommandLineBoss
233
+ include CommandLineBoss::HelpOption
234
+
235
+ # ...
236
+
237
+ private
238
+
239
+ include CommandLineBoss::HelpOption
240
+
241
+ def banner = <<~BANNER
242
+ Create a spreadsheet
243
+
244
+ Usage:
245
+ create_spreadsheet SPREADSHEET_NAME --sheet=SHEET_NAME [--sheet=SHEET_NAME ...]
246
+
247
+ BANNER
248
+ end
249
+ ```
250
+
251
+ The `CreateSpreadsheetCli` class is complete!
252
+
253
+ ### Use the parser
254
+
255
+ Now that the command line parser is fully defined, you just need to use it,
256
+ report errors, and (if successful) do something with the parsed values.
257
+
258
+ Place the following code at the end of your script file, after the
259
+ `CreateSpreadsheetCli` class:
260
+
261
+ ```Ruby
262
+ # Parse the command line arguments
263
+
264
+ options = CreateSpreadsheetCli.new.parse(ARGV)
265
+
266
+ # Report errors
267
+
268
+ if options.failed?
269
+ warn options.error_messages.join("\n")
270
+ exit 1
271
+ end
272
+
273
+ # Do something with the result
274
+ # In this case just output the command line values
275
+
276
+ require 'pp'
277
+
278
+ puts \
279
+ "Creating spreadsheet #{options.spreadsheet_name.pretty_inspect.chomp} " \
280
+ "with sheets #{options.sheet_names.map(&:pretty_inspect).map(&:chomp).join(', ')}"
281
+ ```
282
+
283
+ ### Run the command line
284
+
285
+ Should you have a problem running your script, you can compare your script against
286
+ the expected result which can be found in this project in the file
287
+ `examples/readme_example/create-spreadsheet`.
288
+
289
+ Test your script by running it from the command line. Here are some examples:
290
+
291
+ Show help output:
292
+
293
+ ```shell
294
+ $ ./create-spreadsheet --help
295
+ Create a spreadsheetasdf
296
+
297
+ Usage:
298
+ create_spreadsheet SPREADSHEET_NAME --sheet=SHEET_NAME [--sheet=SHEET_NAME ...]
299
+
300
+ Options:
301
+ --sheet=SHEET_NAME Name of a sheet to create
302
+ -h, --help Show this message
303
+
304
+ $
305
+ ```
306
+
307
+ A happy-path example:
308
+
309
+ ```shell
310
+ $ ./create-spreadsheet 'Yearly Sales' --sheet=Summary --sheet=Details
311
+ Creating spreadsheet "Yearly Sales" with sheets "Summary", "Details"
312
+ $
313
+ ```
314
+
315
+ An example with errors:
316
+
317
+ ```shell
318
+ $ ./create-spreadsheet
319
+ ERROR: A spreadsheet name is required
320
+ ERROR: At least one sheet name is required
321
+ $
322
+ ```
323
+
324
+ ## Development
325
+
326
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
327
+
328
+ To install this gem onto your local machine, run `bundle exec rake install`.
329
+
330
+ ## Contributing
331
+
332
+ Bug reports and pull requests are welcome on GitHub at https://github.com/main_branch/command_line_boss. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/main_branch/command_line_boss/blob/main/CODE_OF_CONDUCT.md).
333
+
334
+ ## License
335
+
336
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
337
+
338
+ ## Code of Conduct
339
+
340
+ Everyone interacting in the CommandLineBoss project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/command_line_boss/blob/main/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,90 @@
1
+ # frozen_string_literal: true
2
+
3
+ desc 'Run the same tasks that the CI build will run'
4
+ if RUBY_PLATFORM == 'java'
5
+ task default: %w[spec rubocop bundle:audit build]
6
+ else
7
+ task default: %w[spec rubocop yard bundle:audit build]
8
+ end
9
+
10
+ # Bundler Audit
11
+
12
+ require 'bundler/audit/task'
13
+ Bundler::Audit::Task.new
14
+
15
+ # Bundler Gem Build
16
+
17
+ require 'bundler'
18
+ require 'bundler/gem_tasks'
19
+
20
+ begin
21
+ Bundler.setup(:default, :development)
22
+ rescue Bundler::BundlerError => e
23
+ warn e.message
24
+ warn 'Run `bundle install` to install missing gems'
25
+ exit e.status_code
26
+ end
27
+
28
+ CLEAN << 'pkg'
29
+ CLOBBER << 'Gemfile.lock'
30
+
31
+ # RSpec
32
+
33
+ require 'rspec/core/rake_task'
34
+
35
+ RSpec::Core::RakeTask.new do |t|
36
+ t.pattern = 'spec/**/*{_spec.rb,.feature}'
37
+ end
38
+
39
+ CLEAN << 'coverage'
40
+ CLEAN << '.rspec_status'
41
+ CLEAN << 'rspec-report.xml'
42
+
43
+ # Rubocop
44
+
45
+ require 'rubocop/rake_task'
46
+
47
+ RuboCop::RakeTask.new do |t|
48
+ t.options = %w[
49
+ --format fuubar
50
+ --format json --out rubocop-report.json
51
+ --display-cop-names
52
+ --config .rubocop.yml
53
+ ]
54
+ end
55
+
56
+ CLEAN << 'rubocop-report.json'
57
+
58
+ unless RUBY_PLATFORM == 'java'
59
+ # yard:build
60
+
61
+ require 'yard'
62
+
63
+ YARD::Rake::YardocTask.new('yard:build') do |t|
64
+ t.files = %w[lib/**/*.rb examples/**/*]
65
+ t.stats_options = ['--list-undoc']
66
+ end
67
+
68
+ CLEAN << '.yardoc'
69
+ CLEAN << 'doc'
70
+
71
+ # yard:audit
72
+
73
+ desc 'Run yardstick to show missing YARD doc elements'
74
+ task :'yard:audit' do
75
+ sh "yardstick 'lib/**/*.rb'"
76
+ end
77
+
78
+ # yard:coverage
79
+
80
+ require 'yardstick/rake/verify'
81
+
82
+ Yardstick::Rake::Verify.new(:'yard:coverage') do |verify|
83
+ verify.threshold = 100
84
+ end
85
+
86
+ # yard
87
+
88
+ desc 'Run all YARD tasks'
89
+ task yard: %i[yard:build yard:audit yard:coverage]
90
+ end
@@ -0,0 +1,21 @@
1
+ Gemfile.lock/.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ /sig/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
13
+
14
+ /Gemfile.lock
15
+
16
+ /rspec-report.xml
17
+ /.rspec_status
18
+
19
+ /rubocop-report.json
20
+
21
+ /.yarddoc
@@ -0,0 +1,3 @@
1
+ --require spec_helper
2
+ --color
3
+ --format Fuubar
@@ -0,0 +1,34 @@
1
+ AllCops:
2
+ NewCops: enable
3
+ SuggestExtensions: false
4
+ DefaultFormatter: fuubar
5
+
6
+ # Output extra information for each offense to make it easier to diagnose:
7
+ DisplayCopNames: true
8
+ DisplayStyleGuide: true
9
+ ExtraDetails: true
10
+
11
+ # RuboCop enforces rules depending on the oldest version of Ruby which
12
+ # your project supports:
13
+ TargetRubyVersion: 3.1
14
+
15
+ Gemspec/DevelopmentDependencies:
16
+ Enabled: false
17
+
18
+ Layout/LineLength:
19
+ Max: 120
20
+
21
+ # The DSL for RSpec and the gemspec file make it very hard to limit block length
22
+ Metrics/BlockLength:
23
+ Exclude:
24
+ - '**/*_spec.rb'
25
+ - '*.gemspec'
26
+
27
+ Metrics/ModuleLength:
28
+ CountAsOne: ['hash']
29
+
30
+ Metrics/ClassLength:
31
+ CountAsOne: ['hash']
32
+
33
+ Style/AsciiComments:
34
+ Enabled: false