Sha256: 1dda7fc01220fb0c45f6ba3a15d884a2ee4b84c98a51b13af099b0b36fb6a919

Contents?: true

Size: 641 Bytes

Versions: 17

Compression:

Stored size: 641 Bytes

Contents

# frozen_string_literal: true

class Ree::PackagesSchemaLocator
  def call(path)
    find_source_path_in_hierarchy(path)
  end

  private

  def find_source_path_in_hierarchy(some_path)
    some_path = File.expand_path(some_path)

    raise Ree::Error.new("#{Ree::PACKAGES_SCHEMA_FILE} not found", :packages_json_not_found) if some_path == '/'

    return potential_file(some_path) if present?(some_path)

    find_source_path_in_hierarchy(File.dirname(some_path))
  end

  def present?(some_path)
    File.exist?(potential_file(some_path))
  end

  def potential_file(some_path)
    File.join(some_path, Ree::PACKAGES_SCHEMA_FILE)
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
ree-1.1.1 lib/ree/core/packages_schema_locator.rb
ree-1.1.0 lib/ree/core/packages_schema_locator.rb
ree-1.0.47 lib/ree/core/packages_schema_locator.rb
ree-1.0.46 lib/ree/core/packages_schema_locator.rb
ree-1.0.45 lib/ree/core/packages_schema_locator.rb
ree-1.0.44 lib/ree/core/packages_schema_locator.rb
ree-1.0.43 lib/ree/core/packages_schema_locator.rb
ree-1.0.42 lib/ree/core/packages_schema_locator.rb
ree-1.0.41 lib/ree/core/packages_schema_locator.rb
ree-1.0.40 lib/ree/core/packages_schema_locator.rb
ree-1.0.39 lib/ree/core/packages_schema_locator.rb
ree-1.0.38 lib/ree/core/packages_schema_locator.rb
ree-1.0.37 lib/ree/core/packages_schema_locator.rb
ree-1.0.36 lib/ree/core/packages_schema_locator.rb
ree-1.0.35 lib/ree/core/packages_schema_locator.rb
ree-1.0.34 lib/ree/core/packages_schema_locator.rb
ree-1.0.33 lib/ree/core/packages_schema_locator.rb