Sha256: cdce214836bfac2dd6506a5f12c0e20deaf1ff3270a40407512951fb66bd61e0

Contents?: true

Size: 704 Bytes

Versions: 1

Compression:

Stored size: 704 Bytes

Contents

require_relative "fshelpyhelp"
require_relative "file_marker"

module Stowaway
  class Locator
    include FSHelpyHelp

    def initialize(extensions)
      @extensions = extensions
      @ignore = [/^\./]
    end

    def find_all(target_context)
      @context = target_context
      @files = []
      ignore_special_directories(@context.root)
      recursively(@context.root) do |file_p|
        push_if_ext_match(file_p)
      end
      @files
    end

    def push_if_ext_match(file_p)
      @files << FileMarker.new(file_p, @context.root) if type?(file_p)
    end

    def type?(file)
      @extensions.each do |e|
        return true if file.match(/#{e}$/)
      end
      false
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
stowaway-0.2.5 lib/stowaway/locator.rb