swagcov 0.9.0 → 0.10.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6982166b311ad4760552a4d9b867dd0933b08f67e27da868a5b679e3cf93e4f4
4
- data.tar.gz: 27bf743505dd26ce0180e1cfb47cdaba3b08690b746a5577b47e9e3e0f821026
3
+ metadata.gz: 8f7e8120c6da2d859ae0712f523ee0586e9e800c842594ef89c7fdaed3a28ee0
4
+ data.tar.gz: c884efd95e1dc61fba493ba731633087baf546612a00a83489f3d4abc7c38cff
5
5
  SHA512:
6
- metadata.gz: df6f5c0dcd71a4f71954f40c818a831584a964983790bbb25e9aa335f569453b41cd6d6d1a5dc092389dc061338e90e3a44907cbf2c77016f7e43faae0ac2ca6
7
- data.tar.gz: e27a24e341a0fee8d7122c92e778543c9dd64de52b9b7ad74a60f60c808ac96aed4b779945f15221560803094fffe131ebedb72f5a4440b7ad5be54d6ad94034
6
+ metadata.gz: d000402186ba36251cbdc689374979e863dce7b23f154837eba4e177bc484de337bf4928cc8d547bd71d20b7db323ab08cc378590871b2502c72a2398b8749e6
7
+ data.tar.gz: 74144d434fd8ba835564b3fc92a9a63b318b74c438390213a9cd62cfba0705666464d3363d3d732eff05b46ddacb9105547352310ffeb7e166e5a5834efccba3
data/CHANGELOG.md CHANGED
@@ -2,6 +2,29 @@
2
2
  ## main (unreleased)
3
3
  -
4
4
 
5
+ ## 0.10.0 (2025-05-08)
6
+ ### Enhancement
7
+ - Added executable for streamlined command line usage ([#120](https://github.com/smridge/swagcov/pull/120))
8
+ - The below options are now available:
9
+ ```
10
+ swagcov
11
+ swagcov --init
12
+ swagcov --todo
13
+ swagcov --help
14
+ ```
15
+ - **Note**: This is experimental as it may not work for all use cases. Use `rake swagcov` as a fallback
16
+ - Added command line options to the existing `rake swagcov` task ([#121](https://github.com/smridge/swagcov/pull/121), [#122](https://github.com/smridge/swagcov/pull/122), [#123](https://github.com/smridge/swagcov/pull/123))
17
+ - The below options are now available:
18
+ ```
19
+ rake swagcov
20
+ rake swagcov -- --init
21
+ rake swagcov -- --todo
22
+ rake swagcov -- --help
23
+ ```
24
+ - **Note**: This refactor involved `BREAKING CHANGES`:
25
+ - `rake swagcov:generate_todo` is now `rake swagcov -- --todo`
26
+ - `rake swagcov:install` is now `rake swagcov -- --init`
27
+
5
28
  ## 0.9.0 (2025-05-07)
6
29
  ### Enhancement
7
30
  - Add support for `.json` OpenAPI file types ([#112](https://github.com/smridge/swagcov/pull/112), [#113](https://github.com/smridge/swagcov/pull/113))
data/README.md CHANGED
@@ -9,17 +9,32 @@
9
9
  ![CodeQL Build](https://github.com/smridge/swagcov/actions/workflows/codeql-analysis.yml/badge.svg)
10
10
  [![Coverage Status](https://coveralls.io/repos/github/smridge/swagcov/badge.svg?branch=main)](https://coveralls.io/github/smridge/swagcov?branch=main)
11
11
 
12
- See OpenAPI documentation coverage report for Rails Routes.
12
+ OpenAPI documentation coverage report for Rails Routes.
13
13
 
14
14
  ## Usages
15
15
  - See overview of different endpoints covered, missing and what you choose to ignore.
16
- - Add pass/fail to your build pipeline when missing Documentation Coverage.
16
+ - Add pass/fail to your build pipeline when missing documentation coverage.
17
17
 
18
- | `rake task` | `rails console` | Description |
19
- | :--- | :--- | :--- |
20
- | `rake swagcov` | `Swagcov::Command::ReportCoverage.new.run` | Check OpenAPI documentation coverage for Rails Route endpoints |
21
- | `rake swagcov:install` | `Swagcov::Command::GenerateDotfile.new.run` | Generate required `.swagcov.yml` config file |
22
- | `rake swagcov:generate_todo` | `Swagcov::Command::GenerateTodoFile.new.run` | Generate optional `.swagcov_todo.yml` config file |
18
+ **Check OpenAPI documentation coverage for Rails Route endpoints**
19
+ | `executable ` | `rake task ` | `rails console ` |
20
+ | :--- | :--- | :--- |
21
+ | `swagcov` | `rake swagcov` | `Swagcov::Command::ReportCoverage.new.run` |
22
+
23
+ **Generate required `.swagcov.yml` config file**
24
+ | `executable ` | `rake task ` | `rails console ` |
25
+ | :--- | :--- | :--- |
26
+ | `swagcov --init` | `rake swagcov -- --init` | `Swagcov::Command::GenerateDotfile.new.run` |
27
+
28
+
29
+ **Generate optional `.swagcov_todo.yml` config file**
30
+ | `executable ` | `rake task ` | `rails console ` |
31
+ | :--- | :--- | :--- |
32
+ | `swagcov --todo` | `rake swagcov -- --todo` | `Swagcov::Command::GenerateTodoFile.new.run` |
33
+
34
+ **See command line usage options**
35
+ | `executable ` | `rake task ` | `rails console ` |
36
+ | :--- | :--- | :--- |
37
+ | `swagcov --help` | `rake swagcov -- --help` | n/a |
23
38
 
24
39
  ## Ruby and Rails Version Support
25
40
  Versioning support from a test coverage perspective, see [tests.yml](/.github/workflows/tests.yml) for detail
data/exe/swagcov ADDED
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ # Experimental executable
5
+ #
6
+ # Booting rails approach should work for most applications
7
+ # Rake task option as an alternative should always work as expected
8
+
9
+ # Load logger before rails
10
+ # Fix for booting rails 6.0-7.0 apps (uninitialized constant ActiveSupport::LoggerThreadSafeLevel::Logger)
11
+ require "logger"
12
+
13
+ require "swagcov"
14
+
15
+ RAILS_APP_PATH = File.expand_path("config/application", Dir.pwd)
16
+
17
+ def boot_rails_application!
18
+ require RAILS_APP_PATH
19
+ Rails.application.initialize!
20
+ rescue LoadError, NoMethodError
21
+ warn "Unable to load Rails application, try running `rake swagcov` instead"
22
+ exit Swagcov::STATUS_ERROR
23
+ end
24
+
25
+ boot_rails_application!
26
+
27
+ Swagcov::Runner.new(args: ARGV).run
@@ -2,8 +2,8 @@
2
2
 
3
3
  module Swagcov
4
4
  class Dotfile
5
- DEFAULT_CONFIG_FILE_NAME = ".swagcov.yml"
6
- TODO_CONFIG_FILE_NAME = ".swagcov_todo.yml"
5
+ DEFAULT_CONFIG_FILE_NAME = ::ENV.fetch("SWAGCOV_DOTFILE", ".swagcov.yml")
6
+ TODO_CONFIG_FILE_NAME = ::ENV.fetch("SWAGCOV_TODOFILE", ".swagcov_todo.yml")
7
7
 
8
8
  def initialize basename: DEFAULT_CONFIG_FILE_NAME, todo_basename: TODO_CONFIG_FILE_NAME, skip_todo: false
9
9
  @dotfile = load_yaml(basename, required: true)
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "optparse"
4
+
5
+ module Swagcov
6
+ class Options
7
+ def initialize args: ::ARGV
8
+ @args = args
9
+ end
10
+
11
+ def define
12
+ options = {}
13
+
14
+ ::OptionParser.new do |opts|
15
+ opts.banner = <<~MESSAGE
16
+ Usage:
17
+ * as executable: swagcov [options]
18
+ * as rake task: rake swagcov -- [options]
19
+ MESSAGE
20
+
21
+ opts.on("-i", "--init", "Generate required .swagcov.yml config file") do |opt|
22
+ options[:init] = opt
23
+ end
24
+
25
+ opts.on("-t", "--todo", "Generate optional .swagcov_todo.yml config file") do |opt|
26
+ options[:todo] = opt
27
+ end
28
+ end.parse!(@args)
29
+
30
+ options
31
+ rescue ::OptionParser::InvalidOption => e
32
+ warn e.message
33
+ warn "For usage information, use --help"
34
+ exit ::Swagcov::STATUS_ERROR
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Swagcov
4
+ class Runner
5
+ attr_reader :options
6
+
7
+ def initialize args: ::ARGV
8
+ @args = args
9
+ @options = ::Swagcov::Options.new(args: @args).define
10
+ end
11
+
12
+ def run
13
+ exit ::Swagcov::Command::GenerateDotfile.new.run if options[:init]
14
+ exit ::Swagcov::Command::GenerateTodoFile.new.run if options[:todo]
15
+ exit ::Swagcov::Command::ReportCoverage.new.run
16
+ end
17
+ end
18
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Swagcov
4
4
  module Version
5
- STRING = "0.9.0"
5
+ STRING = "0.10.0"
6
6
  end
7
7
  end
data/lib/swagcov.rb CHANGED
@@ -11,7 +11,9 @@ require "swagcov/coverage"
11
11
  require "swagcov/dotfile"
12
12
  require "swagcov/errors"
13
13
  require "swagcov/openapi_files"
14
+ require "swagcov/options"
14
15
  require "swagcov/railtie"
16
+ require "swagcov/runner"
15
17
  require "swagcov/version"
16
18
 
17
19
  module Swagcov
@@ -2,5 +2,6 @@
2
2
 
3
3
  desc "Check OpenAPI documentation coverage for Rails Route endpoints"
4
4
  task swagcov: :environment do
5
- exit Swagcov::Command::ReportCoverage.new.run
5
+ args = ARGV.drop(2) # Remove "swagcov" and "--" to ignore standard rake arguments
6
+ Swagcov::Runner.new(args: args).run
6
7
  end
metadata CHANGED
@@ -1,11 +1,11 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: swagcov
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sarah Ridge
8
- bindir: bin
8
+ bindir: exe
9
9
  cert_chain: []
10
10
  date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
@@ -25,13 +25,15 @@ dependencies:
25
25
  version: '4.2'
26
26
  email:
27
27
  - sarahmarie@hey.com
28
- executables: []
28
+ executables:
29
+ - swagcov
29
30
  extensions: []
30
31
  extra_rdoc_files: []
31
32
  files:
32
33
  - CHANGELOG.md
33
34
  - LICENSE
34
35
  - README.md
36
+ - exe/swagcov
35
37
  - lib/swagcov.rb
36
38
  - lib/swagcov/command/generate_dotfile.rb
37
39
  - lib/swagcov/command/generate_todo_file.rb
@@ -42,11 +44,11 @@ files:
42
44
  - lib/swagcov/errors.rb
43
45
  - lib/swagcov/formatter/console.rb
44
46
  - lib/swagcov/openapi_files.rb
47
+ - lib/swagcov/options.rb
45
48
  - lib/swagcov/railtie.rb
49
+ - lib/swagcov/runner.rb
46
50
  - lib/swagcov/version.rb
47
51
  - lib/tasks/swagcov.rake
48
- - lib/tasks/swagcov/generate_todo.rake
49
- - lib/tasks/swagcov/install.rake
50
52
  homepage: https://github.com/smridge/swagcov
51
53
  licenses:
52
54
  - MIT
@@ -72,5 +74,5 @@ required_rubygems_version: !ruby/object:Gem::Requirement
72
74
  requirements: []
73
75
  rubygems_version: 3.6.8
74
76
  specification_version: 4
75
- summary: OpenAPI documentation coverage for Rails Routes
77
+ summary: OpenAPI documentation coverage report for Rails Route endpoints
76
78
  test_files: []
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- namespace :swagcov do
4
- desc "Generate optional .swagcov_todo.yml config file acting as a TODO list"
5
- task generate_todo: :environment do
6
- exit Swagcov::Command::GenerateTodoFile.new.run
7
- end
8
- end
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- namespace :swagcov do
4
- desc "Generate required .swagcov.yml config file"
5
- task install: :environment do
6
- exit Swagcov::Command::GenerateDotfile.new.run
7
- end
8
- end