Module: SpecyDocs

Defined in:
lib/specy_docs.rb,
lib/specy_docs/engine.rb,
lib/specy_docs/version.rb,
lib/specy_docs/capturable.rb,
lib/specy_docs/configuration.rb,
lib/specy_docs/report_generator.rb,
app/controllers/specy_docs/docs_controller.rb,
app/controllers/specy_docs/application_controller.rb

Defined Under Namespace

Modules: Capturable Classes: ApplicationController, Configuration, DocsController, Engine, ReportGenerator

Constant Summary collapse

VERSION =
'0.1.0'

Class Method Summary collapse

Class Method Details

.capture_paths_pattern(paths = configuration.capture_paths) ⇒ Object



37
38
39
40
41
42
43
44
# File 'lib/specy_docs.rb', line 37

def capture_paths_pattern(paths = configuration.capture_paths)
  Regexp.union(
    Array(paths).map(&:to_s).reject(&:empty?).map do |path|
      escaped = Regexp.escape(path.sub(%r{\A\./}, '').delete_suffix('/'))
      %r{(?:\A|/|\./)#{escaped}/}
    end
  )
end

.configurationObject



11
12
13
# File 'lib/specy_docs.rb', line 11

def configuration
  @configuration ||= Configuration.new
end

.configure {|configuration| ... } ⇒ Object

Yields:



15
16
17
# File 'lib/specy_docs.rb', line 15

def configure
  yield configuration
end

.reset_configuration!Object



19
20
21
# File 'lib/specy_docs.rb', line 19

def reset_configuration!
  @configuration = Configuration.new
end

.setup_rspec(rspec_config) ⇒ Object

Install Capturable into RSpec. When capture_paths is configured, includes by file path so specs without type: :request (e.g. legacy controller specs) can still be captured. Otherwise includes for type: :request only.



27
28
29
30
31
32
33
34
35
# File 'lib/specy_docs.rb', line 27

def setup_rspec(rspec_config)
  paths = Array(configuration.capture_paths).map(&:to_s).reject(&:empty?)

  if paths.empty?
    rspec_config.include Capturable, type: :request
  else
    rspec_config.include Capturable, file_path: capture_paths_pattern(paths)
  end
end