class Bundlegem::Configurator
Attributes
config_file_data[RW]
user_defined_templates[RW]
user_downloaded_templates[RW]
Public Class Methods
new()
click to toggle source
# File lib/bundlegem/configurator.rb, line 9 def initialize @config_directory_root = "#{ENV['HOME']}/.bundlegem" @config_file = "#{@config_directory_root}/config" @user_defined_templates_path = "#{@config_directory_root}/templates" create_config_file_if_needed! @user_defined_templates = get_user_defined_templates @user_downloaded_templates = get_user_downloaded_templates # load configurations from config file @config_file_data = YAML.load_file @config_file end
Public Instance Methods
built_in_templates()
click to toggle source
# File lib/bundlegem/configurator.rb, line 32 def built_in_templates end
create_config_file_if_needed!()
click to toggle source
# File lib/bundlegem/configurator.rb, line 68 def create_config_file_if_needed! FileUtils.mkdir_p @user_defined_templates_path FileUtils.cp("#{SOURCE_ROOT}/config/config", @config_file) unless File.exists? @config_file end
create_new_template(template_name)
click to toggle source
# File lib/bundlegem/configurator.rb, line 73 def create_new_template(template_name) puts "i'm still a stub" end
default_template()
click to toggle source
# File lib/bundlegem/configurator.rb, line 23 def default_template @config_file_data["default_template"] end
default_template=(val)
click to toggle source
# File lib/bundlegem/configurator.rb, line 27 def default_template=(val) @config_file_data["default_template"] = val File.write(@config_file, "# Comments made to this file will not be preserved\n#{YAML.dump(@config_file_data)}") end
get_user_defined_templates()
click to toggle source
# File lib/bundlegem/configurator.rb, line 41 def get_user_defined_templates user_definition_directory = @user_defined_templates_path template_dirs = Dir.entries(user_definition_directory).select do |entry| File.directory?(File.join(user_definition_directory, entry)) and !(entry =='.' || entry == '..') end pairs = [] template_dirs.each do |dir| # open the dir and read the .bundlegem file to see what class of file it is # If there's no .bundlegem file in there, mark it misc begin f = File.read("#{@user_defined_templates_path}/#{dir}/.bundlegem") /category:\s*([\w\s]*$)/ =~ f category = $1.chomp rescue category = "MISC" end category = "MISC" if category.nil? pairs << {category => dir } end pairs end
get_user_downloaded_templates()
click to toggle source
not implemented yet
# File lib/bundlegem/configurator.rb, line 37 def get_user_downloaded_templates [] end