class Fulmar::Service::HelperService

Provides internal helper methods

Public Class Methods

reverse_file_lookup(path, filename) click to toggle source

Reverse file lookup in path @param path [String] @param filename [String]

# File lib/fulmar/service/helper_service.rb, line 10
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 Class Methods

get_parent_directory_paths(path, paths = []) click to toggle source

Get paths of each parent directory @param path [String] @param paths [Array] @return [Array] A list of paths

# File lib/fulmar/service/helper_service.rb, line 28
def get_parent_directory_paths(path, paths = [])
  paths << path

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

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