Sha256: 869fef4ca9755599a2ba5df70ebb152c57918448f8c38af21bb4ee20458b5452
Contents?: true
Size: 1013 Bytes
Versions: 1
Compression:
Stored size: 1013 Bytes
Contents
require 'erb' require 'fileutils' require 'core_ext/string/camelize' module GemRelease class Template include GemRelease::Helpers attr_reader :template, :name, :module_name, :module_path def initialize(template, options = {}) @template = template options.each do |key, value| instance_variable_set(:"@#{key}", value) meta_class.send(:attr_reader, key) end @name ||= gem_name_from_directory @module_path ||= name.gsub('-', '_') @module_name ||= module_path.camelize end def write FileUtils.mkdir_p(File.dirname(filename)) File.open(filename, 'w+') { |f| f.write(render) } end protected def filename template end def render ERB.new(read_template, nil, "%").result(binding) end def read_template File.new(File.expand_path("../templates/#{template}", __FILE__)).read end def meta_class class << self; self; end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
gem-release-0.0.17 | lib/gem_release/template.rb |