Class: FiberAudit::Project

Inherits:
Object
  • Object
show all
Defined in:
lib/fiber_audit/project.rb

Constant Summary collapse

MARKERS =
%w[Gemfile gems.rb config/application.rb].freeze
CONFIG_FILENAME =
'.fiber-audit.yml'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root:, invocation_path:, known:, note:) ⇒ Project

Returns a new instance of Project.



12
13
14
15
16
17
18
# File 'lib/fiber_audit/project.rb', line 12

def initialize(root:, invocation_path:, known:, note:)
  @root = root.freeze
  @invocation_path = invocation_path.freeze
  @known = known
  @note = note&.freeze
  freeze
end

Instance Attribute Details

#invocation_pathObject (readonly)

Returns the value of attribute invocation_path.



10
11
12
# File 'lib/fiber_audit/project.rb', line 10

def invocation_path
  @invocation_path
end

#noteObject (readonly)

Returns the value of attribute note.



10
11
12
# File 'lib/fiber_audit/project.rb', line 10

def note
  @note
end

#rootObject (readonly)

Returns the value of attribute root.



10
11
12
# File 'lib/fiber_audit/project.rb', line 10

def root
  @root
end

Class Method Details

.detect(start_path: Dir.pwd) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/fiber_audit/project.rb', line 33

def detect(start_path: Dir.pwd)
  validate_start_path(start_path)

  invocation_path = resolve_invocation_path(start_path)
  detected_root = find_project_root(invocation_path)

  if detected_root
    new(
      root: detected_root,
      invocation_path: invocation_path,
      known: true,
      note: nil
    )
  else
    new(
      root: invocation_path,
      invocation_path: invocation_path,
      known: false,
      note: :unknown_project
    )
  end
end

Instance Method Details

#config_path(override = nil) ⇒ Object



24
25
26
27
28
29
30
# File 'lib/fiber_audit/project.rb', line 24

def config_path(override = nil)
  if override
    resolve_override(override)
  else
    File.join(root, CONFIG_FILENAME)
  end
end

#known?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/fiber_audit/project.rb', line 20

def known?
  @known
end