Class: Mudguard::Domain::Source

Inherits:
Object
  • Object
show all
Defined in:
lib/mudguard/domain/source.rb

Overview

Represents a Ruby source file

Instance Method Summary collapse

Constructor Details

#initialize(location:, code_loader: -> { "" }) ⇒ Source

Returns a new instance of Source.



21
22
23
24
# File 'lib/mudguard/domain/source.rb', line 21

def initialize(location:, code_loader: -> { "" })
  @code_loader = code_loader
  @location = location
end

Instance Method Details

#==(other) ⇒ Object



26
27
28
# File 'lib/mudguard/domain/source.rb', line 26

def ==(other)
  @location == other.instance_eval { @location }
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/mudguard/domain/source.rb', line 34

def eql?(other)
  @location.eql?(other.instance_eval { @location })
end

#find_constsObject



48
49
50
51
52
# File 'lib/mudguard/domain/source.rb', line 48

def find_consts
  visitor = ConstVisitor.new
  visit_ast(visitor)
  visitor.consts
end

#find_mod_dependencies(consts) ⇒ Object



42
43
44
45
46
# File 'lib/mudguard/domain/source.rb', line 42

def find_mod_dependencies(consts)
  visitor = DependencyVisitor.new(consts: consts)
  visit_ast(visitor)
  visitor.dependencies
end

#hashObject



30
31
32
# File 'lib/mudguard/domain/source.rb', line 30

def hash
  @location.hash
end

#inspectObject



38
39
40
# File 'lib/mudguard/domain/source.rb', line 38

def inspect
  @location
end

#location?(glob) ⇒ Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/mudguard/domain/source.rb', line 54

def location?(glob)
  @location == glob
end