Class: GemXray::CodeScanner
- Inherits:
-
Object
- Object
- GemXray::CodeScanner
- Defined in:
- lib/gemxray/code_scanner.rb
Defined Under Namespace
Classes: Snapshot
Constant Summary collapse
- SCAN_EXTENSIONS =
%w[.rb .erb .haml .slim .rake .thor .gemspec .ru].freeze
- REQUIRE_PATTERN =
/ (?: \brequire(?:_relative)?\s*\(?\s*["']([^"']+)["'] | send\(\s*:require\s*,\s*["']([^"']+)["'] ) /x.freeze
- CONSTANT_PATTERN =
/\b(?:[A-Z][A-Za-z0-9]*)(?:::[A-Z][A-Za-z0-9]*)*\b/.freeze
- GEMSPEC_DEPENDENCY_PATTERN =
/\badd_(?:runtime_)?dependency\s+["']([^"']+)["']/.freeze
Instance Method Summary collapse
-
#initialize(config) ⇒ CodeScanner
constructor
A new instance of CodeScanner.
- #scan ⇒ Object
Constructor Details
#initialize(config) ⇒ CodeScanner
Returns a new instance of CodeScanner.
45 46 47 |
# File 'lib/gemxray/code_scanner.rb', line 45 def initialize(config) @config = config end |
Instance Method Details
#scan ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/gemxray/code_scanner.rb', line 49 def scan requires = Set.new constants = Set.new dependency_names = Set.new files = scan_files scan_payloads(files).each do |payload| payload[:requires].each { |value| requires << value } payload[:constants].each { |value| constants << value } payload[:dependency_names].each { |value| dependency_names << value } end Snapshot.new( requires: requires, constants: constants, dependency_names: dependency_names, files: files ) end |