class Genio::Parser::Format::Base

Attributes

data_types[RW]
endpoint[RW]
enum_types[RW]
files[RW]
options[RW]
services[RW]

Public Class Methods

new(options = {}) click to toggle source
# File lib/genio/parser/format/base.rb, line 29
def initialize(options = {})
  @options = options

  @files      = Types::Base.new( "#" => "self" )
  @services   = Types::Base.new
  @data_types = Types::Base.new
  @enum_types = Types::Base.new
end

Public Instance Methods

expand_path(file) click to toggle source
# File lib/genio/parser/format/base.rb, line 51
def expand_path(file)
  if load_files.any? and file !~ /^(\/|https?:\/\/)/
    parent_file = load_files.last
    if parent_file =~ /^https?:/
      file = URI.join(parent_file, file).to_s
    else
      file = File.expand_path(file, File.dirname(parent_file))
    end
  end
  file
end
load_files() click to toggle source
# File lib/genio/parser/format/base.rb, line 47
def load_files
  @load_files ||= []
end
open(file, options = {}) click to toggle source
Calls superclass method
# File lib/genio/parser/format/base.rb, line 42
def open(file, options = {})
  options[:ssl_verify_mode] ||= 0
  super(file, options)
end
read_file(file, &block) click to toggle source
# File lib/genio/parser/format/base.rb, line 63
def read_file(file, &block)
  file = expand_path(file)
  load_files.push(file)
  logger.info("GET #{file}")
  block.call(open(file).read)
ensure
  load_files.pop
end
to_iodocs() click to toggle source
# File lib/genio/parser/format/base.rb, line 38
def to_iodocs
  IODocs.to_iodocs(self)
end