class Roject::FileMaker
Creates files according to the given credentials
Author: Anshul Kharbanda Created: 7 - 21 - 2016
Attributes
extension[RW]
Read extension, directory, and template
Public Class Methods
new(project, hash)
click to toggle source
Initializes a FileMaker
from the given hash
Parameter: hash - the hash to parse
# File lib/makers.rb, line 53 def initialize project, hash @path = General::GTemplate.new hash[:path] @template = General::GIO.load "#{project.config[:directory][:templates]}/#{hash[:template]}" @extension = hash[:extension] end
Public Instance Methods
make(project, args)
click to toggle source
Creates a file of the filetype with the given args
Parameter: project - the project running the task Parameter: args - the args being used to create the file
# File lib/makers.rb, line 63 def make project, args # merge args with project args.merge! project.config # Get path path = "#{@path.apply(args)}" + (@extension.nil? ? "" : ".#{@extension}") # Create directory dir = File.dirname(path) FileUtils.mkdir_p dir unless Dir.exist? dir # Write template to path @template.write(path, args) end