Class: Tins::Find::Finder

### Home Classes Methods

### In Files

- lib/tins/find.rb

### Parent

Object

### Namespace

- MODULE Tins::Find::Finder::PathExtension

### Methods

- ::new
- #find
- #prepare_path
- #protect_from_errors
- #visit_path?

### Class/Module Index

Quicksearch

- Tins
- Tins
- Tins
- Tins::Annotate
- Tins::AskAndSend
- Tins::Attempt
- Tins::Bijection
- Tins::Blank
- Tins::Blank::Array
- Tins::Blank::FalseClass
- Tins::Blank::Hash
- Tins::Blank::NilClass
- Tins::Blank::Numeric
- Tins::Blank::Object
- Tins::Blank::String
- Tins::Blank::TrueClass
- Tins::BlankSlate
- Tins::BlockSelf
- Tins::CasePredicate
- Tins::ClassMethod
- Tins::Concern
- Tins::Concern::ModuleMixin
- Tins::Constant
- Tins::ConstantMaker
- Tins::CountBy
- Tins::DSLAccessor
- Tins::DateDummy
- Tins::DateTimeDummy
- Tins::DeepConstGet
- Tins::DeepDup
- Tins::Deflect
- Tins::Deflect::DeflectError
- Tins::Deflect::Deflector
- Tins::Deflect::DeflectorCollection
- Tins::Delegate
- Tins::DynamicScope
- Tins::DynamicScope::Context
- Tins::Eigenclass
- Tins::ExtractLastArgumentOptions
- Tins::FileBinary
- Tins::FileBinary::ClassMethods
- Tins::FileBinary::Constants
- Tins::Find
- Tins::Find::Finder
- Tins::Find::Finder::PathExtension
- Tins::FromModule
- Tins::Full
- Tins::GO
- Tins::GO::EnumerableExtension
- Tins::Generator
- Tins::HashSymbolizeKeysRecursive
- Tins::HashUnion
- Tins::IfPredicate
- Tins::InstanceExec
- Tins::Interpreter
- Tins::Limited
- Tins::LinesFile
- Tins::LinesFile::LineExtension
- Tins::Memoize
- Tins::Memoize::CacheMethods
- Tins::MethodDescription
- Tins::MethodMissingDelegator
- Tins::MethodMissingDelegator::DelegatorClass
- Tins::MethodMissingDelegator::DelegatorModule
- Tins::Minimize
- Tins::ModuleGroup
- Tins::NamedSet
- Tins::Null
- Tins::Null::Kernel
- Tins::NullClass
- Tins::NullPlus
- Tins::Once
- Tins::P
- Tins::ParameterizedModule
- Tins::PartialApplication
- Tins::ProcCompose
- Tins::ProcPrelude
- Tins::RangePlus
- Tins::RequireMaybe
- Tins::Responding
- Tins::Rotate
- Tins::Scope
- Tins::SecureWrite
- Tins::SexySingleton
- Tins::SexySingleton::SingletonClassMethods
- Tins::Shuffle
- Tins::StringByteOrderMark
- Tins::StringCamelize
- Tins::StringUnderscore
- Tins::StringVersion
- Tins::StringVersion::Version
- Tins::Subhash
- Tins::SymbolMaker
- Tins::Terminal
- Tins::ThreadGlobal
- Tins::ThreadLocal
- Tins::TimeDummy
- Tins::TimeFreezer
- Tins::To
- Tins::ToProc
- Tins::Token
- Tins::UniqBy
- Tins::Write
- Object
- Object::DSLKit
- Object::Spruz
- Array
- Date
- DateTime
- Enumerable
- File
- Hash
- IO
- IRB
- Method
- Module
- Proc
- Range
- String
- Symbol
- Time
- UnboundMethod

No matching classes.

# Tins::Find::Finder

### Attributes

follow_symlinks[RW]
raise_errors[RW]
show_hidden[RW]
suffix[RW]

### Public Class Methods

new(opts = {}) click to toggle source

    # File lib/tins/find.rb, line 57
    def initialize(opts = {})
      @show_hidden     = opts.fetch(:show_hidden)     { true }
      @raise_errors    = opts.fetch(:raise_errors)    { false }
      @follow_symlinks = opts.fetch(:follow_symlinks) { true }
      opts[:suffix].full? { |s| @suffix = [*s] }
    end

### Public Instance Methods

find(*paths) click to toggle source

    # File lib/tins/find.rb, line 76
    def find(*paths)
      block_given? or return enum_for(__method__, *paths)
      paths.collect! { |d| d.dup }
      while path = paths.shift
        path = prepare_path(path)
        catch(:prune) do
          stat = path.finder_stat or next
          visit_path?(path) and yield path
          if stat.directory?
            ps = protect_from_errors { Dir.entries(path) } or next
            ps.sort!
            ps.reverse_each do |p|
              next if p == "." or p == ".."
              next if !@show_hidden && p.start_with?('.')
              p = File.join(path, p)
              paths.unshift p.untaint
            end
          end
        end
      end
    end

prepare_path(path) click to toggle source

    # File lib/tins/find.rb, line 98
    def prepare_path(path)
      path = path.dup.taint
      path.extend PathExtension
      path.finder = self
      path
    end

protect_from_errors(errors = Find::EXPECTED_STANDARD_ERRORS) click to toggle source

    # File lib/tins/find.rb, line 105
    def protect_from_errors(errors = Find::EXPECTED_STANDARD_ERRORS)
      yield
    rescue errors
      raise_errors and raise
      return
    end

visit_path?(path) click to toggle source

    # File lib/tins/find.rb, line 72
    def visit_path?(path)
      @suffix.nil? || @suffix.include?(path.suffix)
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.