class LaTeXProjectTemplate::Configuration
Constants
- COMPONENT_DIRECTORY
- DEFAULT_PROFILE_YAML
- TEMPLATE_DIRECTORY
- VARIABLE_DIRECTORY
Public Class Methods
create_new_config(home_path = nil)
click to toggle source
# File lib/latex_project_template.rb, line 19 def self.create_new_config(home_path = nil) begin config = LPTConfig.new(DEFAULT_CONFIG, :home => home_path, :new_directory => true) dir = config.directory Dir.glob(File.expand_path(File.join(File.dirname(__FILE__), '../initial_files/*'))).each do |path| FileUtils.cp_r(path, dir) end git = Git.init(dir) git.add git.commit("Create initial template.") rescue UserConfig::DirectoryExistenceError $stderr.puts "Can not new configuration directory." end end
new(home_path)
click to toggle source
# File lib/latex_project_template.rb, line 34 def initialize(home_path) @user_config = LPTConfig.new(DEFAULT_CONFIG, :home => home_path) end
Public Instance Methods
component(name)
click to toggle source
# File lib/latex_project_template.rb, line 77 def component(name) if path = @user_config.exist?(File.join(COMPONENT_DIRECTORY, name)) return LaTeXProjectTemplate::Component.new(path) end nil end
config_directory()
click to toggle source
# File lib/latex_project_template.rb, line 38 def config_directory @user_config.directory end
delete_template(template)
click to toggle source
# File lib/latex_project_template.rb, line 58 def delete_template(template) if String === template && template.size > 0 @user_config.delete(user_config_template_path(template)) else raise ArgumentError, "Invalid template name to delete: #{template.inspect}" end end
list_template()
click to toggle source
# File lib/latex_project_template.rb, line 42 def list_template @user_config.list_in_directory(TEMPLATE_DIRECTORY) end
template_exist?(template)
click to toggle source
# File lib/latex_project_template.rb, line 51 def template_exist?(template) if path = @user_config.exist?(user_config_template_path(template)) return LaTeXProjectTemplate::Directory.new(path) end false end
user_variables()
click to toggle source
# File lib/latex_project_template.rb, line 66 def user_variables vars = {} if dir = @user_config.exist?('variable') Dir.glob(File.join(dir, '*.yaml')).each do |yaml_path| key = File.basename(yaml_path).sub(/\.yaml$/, '').intern vars[key] = YAML.load_file(yaml_path) end end vars end
Private Instance Methods
user_config_template_path(template_name)
click to toggle source
# File lib/latex_project_template.rb, line 46 def user_config_template_path(template_name) File.join(TEMPLATE_DIRECTORY, template_name) end