Sha256: 2e0bbd4ff9179d5728e0684e4bc8176e59a22cc019b9bfa3a3bce06fee973485
Contents?: true
Size: 971 Bytes
Versions: 3
Compression:
Stored size: 971 Bytes
Contents
require "goa_model_gen" require "goa_model_gen/golang_helper" require "erb" ## Used in templates require "active_support/core_ext/string" module GoaModelGen class Generator # These are used in templates attr_reader :config attr_accessor :source_file def initialize(config) @config = config end def golang_helper @golang_helper ||= GolangHelper.new end def generate(template_path) abs_path = File.expand_path('../' + template_path, __FILE__) erb = ERB.new(File.read(abs_path), nil, "-") erb.filename = abs_path content = erb.result(binding) end def run(template_path, output_path, overwrite: false) return if File.exist?(output_path) && !overwrite content = generate(template_path) open(output_path, 'w'){|f| f.puts(content) } if (File.extname(output_path) == '.go') && !config.gofmt_disabled system("gofmt -w #{output_path}") end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
goa_model_gen-0.4.2 | lib/goa_model_gen/generator.rb |
goa_model_gen-0.4.1 | lib/goa_model_gen/generator.rb |
goa_model_gen-0.4.0 | lib/goa_model_gen/generator.rb |