Class: Skunk::Generator::Json::Simple

Inherits:
Object
  • Object
show all
Defined in:
lib/skunk/generators/json/simple.rb

Overview

Generates a JSON report for the analysed modules.

Constant Summary collapse

FILE_NAME =
"skunk_report.json"

Instance Method Summary collapse

Constructor Details

#initialize(analysed_modules) ⇒ Simple

Returns a new instance of Simple.



12
13
14
# File 'lib/skunk/generators/json/simple.rb', line 12

def initialize(analysed_modules)
  @analysed_modules = analysed_modules
end

Instance Method Details

#dataObject



22
23
24
25
26
27
28
29
30
31
# File 'lib/skunk/generators/json/simple.rb', line 22

def data
  {
    analysed_modules_count: analysed_modules_count,
    skunk_score_total: skunk_score_total,
    skunk_score_average: calculate_average,
    worst_pathname: find_worst_module&.pathname,
    worst_score: find_worst_module&.skunk_score,
    files: build_files
  }
end

#file_directoryObject



33
34
35
# File 'lib/skunk/generators/json/simple.rb', line 33

def file_directory
  @file_directory ||= Pathname.new(RubyCritic::Config.root)
end

#file_pathnameObject



37
38
39
# File 'lib/skunk/generators/json/simple.rb', line 37

def file_pathname
  Pathname.new(file_directory).join(FILE_NAME)
end

#renderObject



18
19
20
# File 'lib/skunk/generators/json/simple.rb', line 18

def render
  JSON.dump(data)
end