Class: Lurker::RefObject

Inherits:
Object
  • Object
show all
Defined in:
lib/lurker/ref_object.rb

Instance Method Summary collapse

Constructor Details

#initialize(ref_path, root_path) ⇒ RefObject

Returns a new instance of RefObject.



2
3
4
5
# File 'lib/lurker/ref_object.rb', line 2

def initialize(ref_path, root_path)
  @ref_path = ref_path
  @root_path = root_path
end

Instance Method Details

#abs_pathObject



19
20
21
# File 'lib/lurker/ref_object.rb', line 19

def abs_path
  @abs_path ||= @root_path.merge(URI.parse(@ref_path)).tap { |u| u.fragment = nil }
end

#schemaObject



7
8
9
10
11
# File 'lib/lurker/ref_object.rb', line 7

def schema
  return @ref_schema if @ref_schema
  return {} if @ref_path.nil? || @root_path.nil?
  @ref_schema = JSON.parse(schema_descriptor.read)
end

#schema_descriptorObject



13
14
15
16
17
# File 'lib/lurker/ref_object.rb', line 13

def schema_descriptor
  open(abs_path.to_s)
rescue Errno::ENOENT
  Lurker::JamlDescriptor.new(abs_path.to_s)
end