module SchemaDev::Templates
Public Class Methods
_install(src, dst, bound)
click to toggle source
# File lib/schema_dev/templates.rb, line 24 def self._install(src, dst, bound) src = Pathname(src.to_s + '.erb') unless src.file? dst.sub_ext '' if dst.extname == '.erb' dst.dirname.mkpath dst.write process(src.read, bound: bound) end
install_relative(src:, dst:, bound: nil)
click to toggle source
# File lib/schema_dev/templates.rb, line 18 def self.install_relative(src:, dst:, bound: nil) srcfile = root + src dstfile = dst + src _install(srcfile, dstfile, bound) end
install_subtree(src:, dst:, bound: nil)
click to toggle source
# File lib/schema_dev/templates.rb, line 11 def self.install_subtree(src:, dst:, bound: nil) src = root + src Pathname.glob(src + '**/*').select(&:file?).each do |p| _install(p, dst + p.relative_path_from(src).sub_ext(''), bound) end end
process(text, bound: nil)
click to toggle source
# File lib/schema_dev/templates.rb, line 31 def self.process(text, bound: nil) ERB.new(text).result(bound) end
root()
click to toggle source
# File lib/schema_dev/templates.rb, line 7 def self.root @root ||= Pathname.new(__FILE__).dirname.parent.parent + 'templates' end