specy_docs 0.1.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.
data/lib/specy_docs.rb ADDED
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'specy_docs/version'
4
+ require 'specy_docs/configuration'
5
+ require 'specy_docs/capturable'
6
+ require 'specy_docs/report_generator'
7
+ require 'specy_docs/engine'
8
+
9
+ module SpecyDocs
10
+ class << self
11
+ def configuration
12
+ @configuration ||= Configuration.new
13
+ end
14
+
15
+ def configure
16
+ yield configuration
17
+ end
18
+
19
+ def reset_configuration!
20
+ @configuration = Configuration.new
21
+ end
22
+
23
+ # Install Capturable into RSpec.
24
+ # When +capture_paths+ is configured, includes by file path so specs without
25
+ # +type: :request+ (e.g. legacy controller specs) can still be captured.
26
+ # Otherwise includes for +type: :request+ only.
27
+ def setup_rspec(rspec_config)
28
+ paths = Array(configuration.capture_paths).map(&:to_s).reject(&:empty?)
29
+
30
+ if paths.empty?
31
+ rspec_config.include Capturable, type: :request
32
+ else
33
+ rspec_config.include Capturable, file_path: capture_paths_pattern(paths)
34
+ end
35
+ end
36
+
37
+ def capture_paths_pattern(paths = configuration.capture_paths)
38
+ Regexp.union(
39
+ Array(paths).map(&:to_s).reject(&:empty?).map do |path|
40
+ escaped = Regexp.escape(path.sub(%r{\A\./}, '').delete_suffix('/'))
41
+ %r{(?:\A|/|\./)#{escaped}/}
42
+ end
43
+ )
44
+ end
45
+ end
46
+ end
metadata ADDED
@@ -0,0 +1,78 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: specy_docs
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Thabo Titus
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2026-07-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '7.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '7.0'
27
+ description: Capture request/response examples from RSpec request specs and serve
28
+ a browsable docs UI from a mountable Rails engine.
29
+ email:
30
+ - hello@thabotitus.co.za
31
+ executables: []
32
+ extensions: []
33
+ extra_rdoc_files: []
34
+ files:
35
+ - CHANGELOG.md
36
+ - MIT-LICENSE
37
+ - README.md
38
+ - app/controllers/specy_docs/application_controller.rb
39
+ - app/controllers/specy_docs/docs_controller.rb
40
+ - app/frontend/app.js
41
+ - app/frontend/styles.css
42
+ - app/views/specy_docs/docs/show.html.erb
43
+ - config/routes.rb
44
+ - lib/specy_docs.rb
45
+ - lib/specy_docs/capturable.rb
46
+ - lib/specy_docs/configuration.rb
47
+ - lib/specy_docs/engine.rb
48
+ - lib/specy_docs/report_generator.rb
49
+ - lib/specy_docs/tasks/specy_docs_tasks.rake
50
+ - lib/specy_docs/version.rb
51
+ homepage: https://github.com/thabotitus/specy_docs
52
+ licenses:
53
+ - MIT
54
+ metadata:
55
+ allowed_push_host: https://rubygems.org
56
+ homepage_uri: https://github.com/thabotitus/specy_docs
57
+ source_code_uri: https://github.com/thabotitus/specy_docs
58
+ changelog_uri: https://github.com/thabotitus/specy_docs/blob/main/CHANGELOG.md
59
+ post_install_message:
60
+ rdoc_options: []
61
+ require_paths:
62
+ - lib
63
+ required_ruby_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: 3.2.0
68
+ required_rubygems_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ requirements: []
74
+ rubygems_version: 3.5.11
75
+ signing_key:
76
+ specification_version: 4
77
+ summary: Mountable API docs generated from RSpec request captures
78
+ test_files: []