Sha256: 8b6d1f2d3a05e97ae57a788337535ebbcec7333e8b73d63b2693466ac8008620
Contents?: true
Size: 584 Bytes
Versions: 4
Compression:
Stored size: 584 Bytes
Contents
module Project class Template attr_accessor :subject, :replacements REGEX = /%([a-z|A-Z]*)?/ def initialize(subject, replacements) self.subject = subject self.replacements = replacements end def parse matches = self.subject.scan(REGEX) matches.flatten! matches.each do |match| raise MissingTemplateVariable, "No variable named %#{match} was specified in the project #{self.key}" if replacements[match].nil? self.subject.gsub!("%#{match}", replacements[match]) end self.subject end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
project-0.9.3 | lib/project/template.rb |
project-0.9.2 | lib/project/template.rb |
project-0.9.0 | lib/project/template.rb |
project-0.8.0 | lib/project/template.rb |