Class: ConjureShield::Analyzer

Inherits:
Object
  • Object
show all
Defined in:
lib/conjure_shield/analyzer.rb

Constant Summary collapse

RESTFUL_ACTIONS =
%i[index show new create edit update destroy].freeze
SINGULAR_ACTIONS =
%i[show new create edit update destroy].freeze
ACTION_ROUTE_MAP =
{
  index: [:get_index, :index_pagination, :index_sorting],
  show: [:get_show, :show_with_associations],
  new: [:get_new, :new_form],
  create: [:post_create, :post_create_valid, :post_create_invalid, :post_create_redirect],
  edit: [:get_edit, :edit_form],
  update: [:put_patch_update_valid, :put_patch_update_invalid, :put_patch_update_redirect],
  destroy: [:delete_destroy, :delete_destroy_redirect]
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Analyzer

Returns a new instance of Analyzer.



24
25
26
27
28
29
30
31
32
33
# File 'lib/conjure_shield/analyzer.rb', line 24

def initialize(path)
  @codebase_path = File.expand_path(path)
  @ast_nodes = []
  @missing_tests = []
  @existing_tests = []
  @files = []
  @routes = {}
  @routes_parsed = false
  @devise_model = nil
end

Instance Attribute Details

#ast_nodesObject (readonly)

Returns the value of attribute ast_nodes.



22
23
24
# File 'lib/conjure_shield/analyzer.rb', line 22

def ast_nodes
  @ast_nodes
end

#codebase_pathObject (readonly)

Returns the value of attribute codebase_path.



22
23
24
# File 'lib/conjure_shield/analyzer.rb', line 22

def codebase_path
  @codebase_path
end

#devise_modelObject (readonly)

Returns the value of attribute devise_model.



22
23
24
# File 'lib/conjure_shield/analyzer.rb', line 22

def devise_model
  @devise_model
end

#existing_testsObject (readonly)

Returns the value of attribute existing_tests.



22
23
24
# File 'lib/conjure_shield/analyzer.rb', line 22

def existing_tests
  @existing_tests
end

#filesObject (readonly)

Returns the value of attribute files.



22
23
24
# File 'lib/conjure_shield/analyzer.rb', line 22

def files
  @files
end

#missing_testsObject (readonly)

Returns the value of attribute missing_tests.



22
23
24
# File 'lib/conjure_shield/analyzer.rb', line 22

def missing_tests
  @missing_tests
end

#routesObject (readonly)

Returns the value of attribute routes.



22
23
24
# File 'lib/conjure_shield/analyzer.rb', line 22

def routes
  @routes
end

#routes_parsedObject (readonly)

Returns the value of attribute routes_parsed.



22
23
24
# File 'lib/conjure_shield/analyzer.rb', line 22

def routes_parsed
  @routes_parsed
end

Instance Method Details

#analyzeObject



35
36
37
38
39
40
41
42
# File 'lib/conjure_shield/analyzer.rb', line 35

def analyze
  scan_ruby_files
  scan_existing_tests
  analyze_ast
  parse_routes
  detect_missing_tests
  self
end