Class: Textus::Protocol::Links::Resolver
- Inherits:
-
Object
- Object
- Textus::Protocol::Links::Resolver
- Defined in:
- lib/textus/protocol/links/resolver.rb
Defined Under Namespace
Classes: UnknownKeyError
Instance Method Summary collapse
-
#initialize(manifest:) ⇒ Resolver
constructor
A new instance of Resolver.
- #resolve(key:, from_path:) ⇒ Object
Constructor Details
#initialize(manifest:) ⇒ Resolver
Returns a new instance of Resolver.
10 11 12 |
# File 'lib/textus/protocol/links/resolver.rb', line 10 def initialize(manifest:) @manifest = manifest end |
Instance Method Details
#resolve(key:, from_path:) ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/textus/protocol/links/resolver.rb', line 14 def resolve(key:, from_path:) entry = @manifest.data.entries.find { |e| e.key == key } raise UnknownKeyError.new("unknown key: #{key}") unless entry to = Array(entry.publish_to).first return "`textus get #{key}`" if to.nil? relative_path(from: from_path, to: to) end |