Sha256: 4c00fb558f801c8d4af2aeb9bbbb4211cda526ad7a4ad545d7e2b446b7d8b676

Contents?: true

Size: 647 Bytes

Versions: 33

Compression:

Stored size: 647 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

33 entries across 33 versions & 1 rubygems

Version Path
ree-1.0.32 lib/ree/core/packages_schema_locator.rb
ree-1.0.31 lib/ree/core/packages_schema_locator.rb
ree-1.0.30 lib/ree/core/packages_schema_locator.rb
ree-1.0.29 lib/ree/core/packages_schema_locator.rb
ree-1.0.28 lib/ree/core/packages_schema_locator.rb
ree-1.0.27 lib/ree/core/packages_schema_locator.rb
ree-1.0.26 lib/ree/core/packages_schema_locator.rb
ree-1.0.25 lib/ree/core/packages_schema_locator.rb
ree-1.0.24 lib/ree/core/packages_schema_locator.rb
ree-1.0.23 lib/ree/core/packages_schema_locator.rb
ree-1.0.22 lib/ree/core/packages_schema_locator.rb
ree-1.0.21 lib/ree/core/packages_schema_locator.rb
ree-1.0.20 lib/ree/core/packages_schema_locator.rb
ree-1.0.19 lib/ree/core/packages_schema_locator.rb
ree-1.0.18 lib/ree/core/packages_schema_locator.rb
ree-1.0.17 lib/ree/core/packages_schema_locator.rb
ree-1.0.16 lib/ree/core/packages_schema_locator.rb
ree-1.0.15 lib/ree/core/packages_schema_locator.rb
ree-1.0.14 lib/ree/core/packages_schema_locator.rb
ree-1.0.13 lib/ree/core/packages_schema_locator.rb