Sha256: 9ace719c9304733b41ceade309a70f0e7d4ee7a98ad17312264c447cd7927bff
Contents?: true
Size: 1.64 KB
Versions: 2
Compression:
Stored size: 1.64 KB
Contents
# frozen_string_literal: true require_relative "utils" require "fileutils" require "expressir" module Suma class ExpressSchema attr_accessor :path, :id, :parsed, :output_path def initialize(id:, path:, output_path:) @path = Pathname.new(path).expand_path @id = id @output_path = output_path end def type case @path.to_s when %r{.*/resources/.*} "resources" when %r{.*/modules/.*} "modules" else "unknown_type" end end def parsed return @parsed if @parsed @parsed = Expressir::Express::Parser.from_file(@path.to_s) Utils.log "Loaded EXPRESS schema: #{path}" @id = @parsed.schemas.first.id @parsed end def to_plain parsed.to_s(no_remarks: true) end def filename_plain File.join(@output_path, type, id, File.basename(@path)) end def save_exp relative_path = Pathname.new(filename_plain).relative_path_from(Dir.pwd) Utils.log "Save plain schema: #{relative_path}" # return if File.exist?(filename_plain) FileUtils.mkdir_p(File.dirname(filename_plain)) File.open(filename_plain, "w") do |file| file.write(to_plain) end end end end # col = Suma::SchemaCollection.new( # config_yaml: 'suma-schemas.yaml', # output_path_docs: 'schema_docs', # output_path_schemas: 'plain_schemas' # ) # docs = col.compile # paths = col.schemas.map do |schema| # { # plain_schema_path: schema.filename_plain, # schema_doc_path: col.doc_from_schema_name(schema.id).output_xml_path # } # end # Utils.log "COMPILED FILES ARE AT:" # pp paths
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
suma-0.1.7 | lib/suma/express_schema.rb |
suma-0.1.6 | lib/suma/express_schema.rb |