Module: Musket

Defined in:
lib/musket.rb,
lib/musket/cli.rb,
lib/musket/version.rb,
lib/musket/configuration.rb

Defined Under Namespace

Classes: CLI, Configuration

Constant Summary collapse

CONFIG_DIR =
Dir.home + '/.musket/'
CONFIG_FILE =
CONFIG_DIR + 'config.yml'
TEMPLATE_DIR =
CONFIG_DIR + 'templates/'
VERSION =
"0.0.2"

Class Method Summary collapse

Class Method Details

.generate(template, filename) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
# 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

.installObject



41
42
43
44
# File 'lib/musket.rb', line 41

def install
  Musket::Configuration.create unless File.exists?CONFIG_FILE
  Musket::Configuration.copy_templates unless File.exists?TEMPLATE_DIR
end

.load_configObject



14
15
16
# File 'lib/musket.rb', line 14

def load_config
  @config = Musket::Configuration.read if File.exists?CONFIG_FILE
end

.templatesObject



18
19
20
21
22
23
24
25
26
27
# 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