Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

file 34 lines (30 sloc) 0.973 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
require "garlic/session"
require "garlic/configurator"
require "garlic/repo"
require "garlic/target"
require "garlic/generator"
require "garlic/shell"

module Garlic
  include Generator
  
  module Version
    String = File.read(File.dirname(File.dirname(__FILE__)) + '/VERSION').strip
    Major, Minor, Patch = String.split('.').map{|i| i.to_i}
  end
  
  # return the current garlic session
  def garlic(config = nil, &block)
    @garlic ||= Garlic::Session.new(self)
    load_config(config)
    @garlic.configure(&block) if block_given?
    @garlic
  end
  
  # load config from
  def load_config(config = nil)
    unless @garlic_config_file
      @garlic_config_file = config || "garlic.rb"
      unless File.exists?(@garlic_config_file)
        raise "garlic requries a configuration file (can't find #{@garlic_config_file}), try:\n garlic generate [#{available_templates.join('|')}] > garlic.rb"
      end
      eval File.read(@garlic_config_file)
    end
  end
end
Something went wrong with that request. Please try again.