class Schematrix::Generators::DslParserSupport
Run-once companion of DslParser: writes parser/runtime.rb, the embedded walker, and parser/parse_error.rb, the shared error class, into the output directory.
Public Class Methods
Source
# File lib/schematrix/generators/dsl_parser.rb, line 33 def self.file_extension = ".rb"
Source
# File lib/schematrix/generators/dsl_parser.rb, line 34 def self.immutable_supported? = false
Source
# File lib/schematrix/generators/dsl_parser.rb, line 35 def self.maybe_supported? = false
Source
# File lib/schematrix/generators/dsl_parser.rb, line 32 def self.run_once? = true
Public Instance Methods
Source
# File lib/schematrix/generators/dsl_parser.rb, line 50 def run_once_render runtime = <<~RUBY require "prism" module #{module_name} module Parser module Runtime #{Templates::DslParserRuntime::BODY} end end end RUBY error = <<~RUBY require_relative "runtime" module #{module_name} module Parser ParseError = Runtime::ParseError end end RUBY { "runtime.rb" => with_banner( format_code(runtime), "#{module_name}::Parser::Runtime", "module", ), "parse_error.rb" => with_banner( format_code(error), "#{module_name}::Parser::ParseError", "class", ), } end
Source
# File lib/schematrix/generators/dsl_parser.rb, line 37 def run_once_target_paths %w[runtime parse_error].map do |name| File.join(output_dir, "parser", "#{name}.rb") end end
Source
# File lib/schematrix/generators/dsl_parser.rb, line 43 def write_run_once(_objects) FileUtils.mkdir_p(File.join(output_dir, "parser")) run_once_render.each do |name, code| File.write(File.join(output_dir, "parser", name), code) end end