Sha256: b31b11ab8909dd551ba755ad1dc7070f00448ffb681180a7c4dd59437c1b223c

Contents?: true

Size: 930 Bytes

Versions: 26

Compression:

Stored size: 930 Bytes

Contents

module Fulmar
  module Service
    # Provides internal helper methods
    class HelperService
      class << self
        ##
        # Reverse file lookup in path
        # @param path [String]
        def reverse_file_lookup(path, filename)
          paths = get_parent_directory_paths(path)

          paths.each do |directory|
            file_path = directory + '/' + filename
            return file_path if File.exist? file_path
          end

          false
        end

        private

        ##
        # Get paths of each parent directory
        # @param path [String]
        # @param paths [Array]
        # @return [Array] A list of paths
        def get_parent_directory_paths(path, paths = [])
          paths << path

          parent_dir_path = File.expand_path('..', path)

          parent_dir_path == '/' ? paths : get_parent_directory_paths(parent_dir_path, paths)
        end
      end
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
fulmar-1.2.0 lib/fulmar/service/helper_service.rb
fulmar-1.1.0 lib/fulmar/service/helper_service.rb
fulmar-1.0.0 lib/fulmar/service/helper_service.rb
fulmar-0.6.5 lib/fulmar/service/helper_service.rb
fulmar-0.6.4 lib/fulmar/service/helper_service.rb
fulmar-0.6.3 lib/fulmar/service/helper_service.rb