Sha256: 2424e03385583682f791d727767e17c6eddc1afa1defb5aad3ceeb74c2b032c8
Contents?: true
Size: 1.47 KB
Versions: 3
Compression:
Stored size: 1.47 KB
Contents
require 'yaml' require 'retrospec/plugins/v1/module_helpers' require 'uri' module Retrospec class Config include Retrospec::Plugins::V1::ModuleHelpers include Retrospec::Plugins::V1 attr_accessor :config_file # we should be able to lookup where the user stores the config map # so the user doesn't have to pass this info each time def initialize(file=nil, opts={}) setup_config_file(file) end # create a blank yaml config file it file does not exist def setup_config_file(file=nil) if file.nil? or ! File.exists?(file) # config does not exist setup_config_dir dst_file = File.join(default_retrospec_dir, 'config.yaml.sample') src_file = File.join(gem_dir,'config.yaml.sample') safe_copy_file(src_file, dst_file) file = dst_file end @config_file = file end # loads the config data into a ruby object def config_data @config_data ||= YAML.load_file(config_file) end def self.config_data(file) new(file).config_data end # returns the configs that are only related to the plugin name def self.plugin_context(config, plugin_name) context = config.select {|k,v| k.downcase =~ /#{plugin_name}/ } end def gem_dir File.expand_path("../../../", __FILE__) end private def setup_config_dir FileUtils.mkdir_p(File.expand_path(default_retrospec_dir)) unless File.directory?(default_retrospec_dir) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
retrospec-0.2.1 | lib/retrospec/config.rb |
retrospec-0.2.0 | lib/retrospec/config.rb |
retrospec-0.1.0 | lib/retrospec/config.rb |