Class: Audition::Target
- Inherits:
-
Object
- Object
- Audition::Target
- Defined in:
- lib/audition/target.rb
Overview
Figures out what the user pointed us at and what that means for scanning (which .rb files) and dynamic probing (which entry).
Detection precedence for directories: Rails beats Rack (a Rails root always has a config.ru), Rack beats gem (an app may vendor a gemspec), gem beats plain directory.
Constant Summary collapse
- EXCLUDED_DIRS =
%w[ vendor node_modules tmp log coverage pkg .git .bundle ].freeze
Instance Attribute Summary collapse
-
#entry ⇒ Hash?
readonly
Dynamic probe entry (
:modeplus mode-specific keys), nil for static-only targets. -
#root ⇒ String
readonly
The target's root directory.
-
#ruby_files ⇒ Array<String>
readonly
Ruby files to scan statically.
-
#type ⇒ Symbol
readonly
One of
:script,:gem,:rack,:rails,:directory,:bundle.
Class Method Summary collapse
-
.detect(raw) ⇒ Target
Detects what
rawpoints at and builds the target.
Instance Method Summary collapse
-
#initialize(type:, root:, ruby_files:, entry:) ⇒ Target
constructor
A new instance of Target.
Constructor Details
Instance Attribute Details
#entry ⇒ Hash? (readonly)
Returns dynamic probe entry (:mode plus
mode-specific keys), nil for static-only targets.
27 28 29 |
# File 'lib/audition/target.rb', line 27 def entry @entry end |
#root ⇒ String (readonly)
Returns the target's root directory.
20 21 22 |
# File 'lib/audition/target.rb', line 20 def root @root end |
#ruby_files ⇒ Array<String> (readonly)
Returns Ruby files to scan statically.
23 24 25 |
# File 'lib/audition/target.rb', line 23 def ruby_files @ruby_files end |
#type ⇒ Symbol (readonly)
Returns one of :script, :gem, :rack, :rails,
:directory, :bundle.
17 18 19 |
# File 'lib/audition/target.rb', line 17 def type @type end |
Class Method Details
.detect(raw) ⇒ Target
Detects what raw points at and builds the target.
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/audition/target.rb', line 35 def self.detect(raw) raw = normalize(raw) if File.file?(raw) from_file(raw) elsif File.directory?(raw) from_directory(raw) else from_gem_name(raw) end end |