class RubyDetective::JSONBuilder

Attributes

classes[R]

Public Class Methods

build(*args) click to toggle source
# File lib/ruby_detective/json_builder.rb, line 12
def self.build(*args)
  new(*args).build
end
new() click to toggle source
# File lib/ruby_detective/json_builder.rb, line 7
def initialize
  data_store = SourceRepresentation::DataStore.instance
  @classes = data_store.classes
end

Public Instance Methods

build() click to toggle source
# File lib/ruby_detective/json_builder.rb, line 16
def build
  classes_data_as_json = classes.map do |c|
    {
      name: c.name,
      full_name: c.path_as_text,
      namespace: c.namespace_as_text,
      lines_of_code: c.lines_of_code,
      dependencies: c.dependencies.map(&:path_as_text),
      dependents: c.dependents.map(&:path_as_text),
      file_path: c.file_path
    }
  end.to_json
end