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
Instance Attribute Summary collapse
-
#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.
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.
13 14 15 16 17 18 19 |
# File 'lib/flatito/finder.rb', line 13 def initialize(paths, = {}) @paths = paths @search = [:search] @extensions = prepare_extensions([:extensions] || DEFAULT_EXTENSIONS) @options = @print_items = PrintItems.new(search) end |
Instance Attribute Details
#extensions ⇒ Object (readonly)
Returns the value of attribute extensions.
11 12 13 |
# File 'lib/flatito/finder.rb', line 11 def extensions @extensions end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
11 12 13 |
# File 'lib/flatito/finder.rb', line 11 def @options end |
#paths ⇒ Object (readonly)
Returns the value of attribute paths.
11 12 13 |
# File 'lib/flatito/finder.rb', line 11 def paths @paths end |
#print_items ⇒ Object (readonly)
Returns the value of attribute print_items.
11 12 13 |
# File 'lib/flatito/finder.rb', line 11 def print_items @print_items end |
#search ⇒ Object (readonly)
Returns the value of attribute search.
11 12 13 |
# File 'lib/flatito/finder.rb', line 11 def search @search end |
Instance Method Details
#call ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/flatito/finder.rb', line 21 def call renderer.prepare paths.each do |path| TreeIterator.new(path, ).each do |pathname| renderer.print_file_progress(pathname) if extensions.include?(pathname.extname) flat_and_filter(pathname) end end end ensure renderer.ending end |