Class: Necropsy::Project
- Inherits:
-
Object
- Object
- Necropsy::Project
- Defined in:
- lib/necropsy/project.rb
Constant Summary collapse
- EXCLUDED_DIRECTORIES =
%w[ .bundle .git .serena coverage doc node_modules pkg tmp vendor ].freeze
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Instance Method Summary collapse
- #changed_files(diff_base) ⇒ Object
-
#initialize(root:, config:) ⇒ Project
constructor
A new instance of Project.
- #relative_path(file) ⇒ Object
- #ruby_files ⇒ Object
- #scan_result ⇒ Object
- #test_file?(file) ⇒ Boolean
Constructor Details
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
19 20 21 |
# File 'lib/necropsy/project.rb', line 19 def config @config end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
19 20 21 |
# File 'lib/necropsy/project.rb', line 19 def root @root end |
Instance Method Details
#changed_files(diff_base) ⇒ Object
52 53 54 |
# File 'lib/necropsy/project.rb', line 52 def changed_files(diff_base) Guardrail::Diff.changed_files(root: root, diff_base: diff_base) end |
#relative_path(file) ⇒ Object
48 49 50 |
# File 'lib/necropsy/project.rb', line 48 def relative_path(file) Pathname.new(File.(file)).relative_path_from(Pathname.new(root)).to_s end |
#ruby_files ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/necropsy/project.rb', line 32 def ruby_files @ruby_files ||= begin globbed = Dir.glob(File.join(root, '**', '*.rb')) special = %w[Rakefile].map { |name| File.join(root, name) }.select { |file| File.file?(file) } rake = Dir.glob(File.join(root, '**', '*.rake')) executables = Dir.glob(File.join(root, '{bin,exe}', '*')).select { |file| File.file?(file) } gemspecs = Dir.glob(File.join(root, '*.gemspec')) (globbed + special + rake + executables + gemspecs).uniq.select { |file| analyzable_file?(file) }.sort end end |
#scan_result ⇒ Object
26 27 28 29 30 |
# File 'lib/necropsy/project.rb', line 26 def scan_result @scan_result ||= Cache::ScanCache.new(project: self).fetch(ruby_files) do AstScanner.new(project: self, files: ruby_files).scan end end |
#test_file?(file) ⇒ Boolean
43 44 45 46 |
# File 'lib/necropsy/project.rb', line 43 def test_file?(file) relative = relative_path(file) relative.start_with?('spec/', 'test/') end |