Sha256: 5b3ff1fc124dc6c2c8ee96665f217a7f7c3666efb14da75e78c362ccf61d067d
Contents?: true
Size: 695 Bytes
Versions: 2
Compression:
Stored size: 695 Bytes
Contents
require "mustache" module Licenza class Template EXTNAME = ".mustache" def initialize @templates = find_templates @licenses = @templates.map{|t| File.basename(t, EXTNAME) } @template_table = Hash[@licenses.zip(@templates)] end attr_reader :licenses def render(license, name, year) unless @licenses.include?(license) raise ArgumentError, "Given license `#{license}' is not supported. Try `--list' option to see all available licenses." end Mustache.render(File.read(@template_table[license]), name: name, year: year) end private def find_templates Dir["#{__dir__}/templates/*#{EXTNAME}"] end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
licenza-0.2.1 | lib/licenza/template.rb |
licenza-0.2.0 | lib/licenza/template.rb |