module Musket

Constants

CONFIG_DIR
CONFIG_FILE
TEMPLATE_DIR
VERSION

Public Class Methods

generate(template, filename) click to toggle source
# File lib/musket.rb, line 29
def generate(template, filename)
  self.load_config
  filename = "musket" if filename == ''
  template_file = TEMPLATE_DIR + "#{template}.mote"
  f = File.open(template_file)
  output = Mote.parse(f.read, self, @config.keys).call(@config)
  current_dir = Dir.pwd
  new_file = File.open(current_dir + "/#{filename}.#{template}", 'w')
  new_file.puts(output)
  new_file.close
end
install() click to toggle source
# File lib/musket.rb, line 49
def install
  Musket::Configuration.create unless File.exists?CONFIG_FILE
  Musket::Configuration.copy_templates unless File.exists?TEMPLATE_DIR
end
load_config() click to toggle source
# File lib/musket.rb, line 14
def load_config
  @config = Musket::Configuration.read if File.exists?CONFIG_FILE
end
new(template) click to toggle source
# File lib/musket.rb, line 41
def new(template)
  self.load_config
  template_file = TEMPLATE_DIR + "#{template}.mote"
  new_file = File.new(template_file, 'w')
  new_file.close
  puts "#{template_file} created."
end
templates() click to toggle source
# File lib/musket.rb, line 18
def templates
  d = Dir.new(TEMPLATE_DIR)
  template_list = []
  d.each {
    |f|
    template_name = File.basename(f, '.mote')
    template_list.push(template_name) if template_name != '.' and template_name != '..'
  }
  return template_list
end