Class: Pinspec::Batch
- Inherits:
-
Object
- Object
- Pinspec::Batch
- Defined in:
- lib/pinspec/batch.rb
Defined Under Namespace
Constant Summary collapse
- SKIP_PATTERNS =
[%r{/concerns/}, %r{_spec\.rb\z}, %r{/spec/}, %r{/test/}].freeze
Class Method Summary collapse
-
.targets_in(path) ⇒ Object
Patterns match the path RELATIVE to the directory being pinned.
Instance Method Summary collapse
-
#initialize(files, &pin) ⇒ Batch
constructor
A new instance of Batch.
-
#run ⇒ Object
A refusal is information, not a stop: one target that takes a block must not end a run over a directory of forty.
Constructor Details
#initialize(files, &pin) ⇒ Batch
Returns a new instance of Batch.
50 51 52 53 |
# File 'lib/pinspec/batch.rb', line 50 def initialize(files, &pin) @files = files @pin = pin end |
Class Method Details
.targets_in(path) ⇒ Object
Patterns match the path RELATIVE to the directory being pinned. Matching the
absolute path means an app that happens to live under a directory called
spec has every one of its files skipped.
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/pinspec/batch.rb', line 38 def self.targets_in(path) return [path] if File.file?(path) root = File.(path) Dir.glob(File.join(root, "**", "*.rb")).reject do |file| relative = file.delete_prefix("#{root}/") SKIP_PATTERNS.any? { |pattern| "/#{relative}".match?(pattern) } end.sort end |