Class: Debtective::Comments::Export

Inherits:
Object
  • Object
show all
Includes:
StderrHelper
Defined in:
lib/debtective/comments/export.rb

Overview

Export comments in a JSON file and to stdout

Constant Summary collapse

OPTIONS =
{
  user_name: nil,
  quiet: false,
  included_types: [],
  excluded_types: [],
  included_paths: [],
  excluded_paths: []
}.freeze
FILE_PATH =
"comments.json"

Instance Method Summary collapse

Methods included from StderrHelper

#suppress_stderr

Constructor Details

#initialize(**options) ⇒ Export

Returns a new instance of Export.

Parameters:

  • user_name (String)

    git user email to filter

  • quiet (boolean)
  • included_types (Array<String>)

    types of comment to export

  • excluded_types (Array<String>)

    types of comment to skip

  • included_paths (Array<String>)

    paths to explore

  • excluded_paths (Array<String>)

    paths to skip



33
34
35
36
37
# File 'lib/debtective/comments/export.rb', line 33

def initialize(**options)
  OPTIONS.each do |key, default|
    instance_variable_set(:"@#{key}", options[key] || default)
  end
end

Instance Method Details

#callvoid

This method returns an undefined value.



40
41
42
43
44
45
46
47
48
49
# File 'lib/debtective/comments/export.rb', line 40

def call
  # suppress_stderr prevents stderr outputs from compilations
  suppress_stderr do
    @comments = @quiet ? find_comments : log_table
  end
  filter_comments!
  log_counts unless @quiet
  write_json_file
  puts(FILE_PATH) unless @quiet
end