Class: Flatito::Finder
- Inherits:
-
Object
- Object
- Flatito::Finder
- Includes:
- RegexFromSearch
- Defined in:
- lib/flatito/finder.rb
Constant Summary collapse
- DEFAULT_EXTENSIONS =
%w[json yml yaml].freeze
- FORK_THRESHOLD =
100
Instance Attribute Summary collapse
-
#case_sensitive ⇒ Object
readonly
Returns the value of attribute case_sensitive.
-
#extensions ⇒ Object
readonly
Returns the value of attribute extensions.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#paths ⇒ Object
readonly
Returns the value of attribute paths.
-
#print_items ⇒ Object
readonly
Returns the value of attribute print_items.
-
#search ⇒ Object
readonly
Returns the value of attribute search.
-
#search_value ⇒ Object
readonly
Returns the value of attribute search_value.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(paths, options = {}) ⇒ Finder
constructor
A new instance of Finder.
Methods included from RegexFromSearch
Constructor Details
#initialize(paths, options = {}) ⇒ Finder
Returns a new instance of Finder.
16 17 18 19 20 21 22 23 24 |
# File 'lib/flatito/finder.rb', line 16 def initialize(paths, = {}) @paths = paths @search = [:search] @search_value = [:search_value] @case_sensitive = [:case_sensitive] @extensions = prepare_extensions([:extensions] || DEFAULT_EXTENSIONS) @options = @print_items = PrintItems.new(search, search_value, case_sensitive: case_sensitive) end |
Instance Attribute Details
#case_sensitive ⇒ Object (readonly)
Returns the value of attribute case_sensitive.
14 15 16 |
# File 'lib/flatito/finder.rb', line 14 def case_sensitive @case_sensitive end |
#extensions ⇒ Object (readonly)
Returns the value of attribute extensions.
14 15 16 |
# File 'lib/flatito/finder.rb', line 14 def extensions @extensions end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
14 15 16 |
# File 'lib/flatito/finder.rb', line 14 def @options end |
#paths ⇒ Object (readonly)
Returns the value of attribute paths.
14 15 16 |
# File 'lib/flatito/finder.rb', line 14 def paths @paths end |
#print_items ⇒ Object (readonly)
Returns the value of attribute print_items.
14 15 16 |
# File 'lib/flatito/finder.rb', line 14 def print_items @print_items end |
#search ⇒ Object (readonly)
Returns the value of attribute search.
14 15 16 |
# File 'lib/flatito/finder.rb', line 14 def search @search end |
#search_value ⇒ Object (readonly)
Returns the value of attribute search_value.
14 15 16 |
# File 'lib/flatito/finder.rb', line 14 def search_value @search_value end |
Instance Method Details
#call ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/flatito/finder.rb', line 28 def call @matched = false renderer.prepare files = collect_candidate_files if files.size >= FORK_THRESHOLD && Process.respond_to?(:fork) process_with_forks(files) else files.each { |pathname| flat_and_filter(pathname) } end @matched ensure renderer.ending end |