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.


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

def initialize(analysed_modules)
  @analysed_modules = analysed_modules
end

Instance Method Details

#dataObject


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

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

#file_directoryObject


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

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

#file_pathnameObject


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

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

#renderObject


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

def render
  JSON.dump(data)
end