Class: RubyCritic::Generator::Json::Simple

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

Constant Summary collapse

FILE_NAME =
'report.json'.freeze

Instance Method Summary collapse

Constructor Details

#initialize(analysed_modules) ⇒ Simple

Returns a new instance of Simple.


10
11
12
# File 'lib/rubycritic/generators/json/simple.rb', line 10

def initialize(analysed_modules)
  @analysed_modules = analysed_modules
end

Instance Method Details

#dataObject


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

def data
  {
    metadata: {
      rubycritic: {
        version: RubyCritic::VERSION
      }
    },
    analysed_modules: @analysed_modules,
    score: @analysed_modules.score
  }
end

#file_directoryObject


32
33
34
# File 'lib/rubycritic/generators/json/simple.rb', line 32

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

#file_pathnameObject


36
37
38
# File 'lib/rubycritic/generators/json/simple.rb', line 36

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

#renderObject


16
17
18
# File 'lib/rubycritic/generators/json/simple.rb', line 16

def render
  JSON.dump(data)
end