Class: Retrospec::Config
- Inherits:
-
Object
- Object
- Retrospec::Config
- Includes:
- Plugins::V1, Plugins::V1::ModuleHelpers
- Defined in:
- lib/retrospec/config.rb
Instance Attribute Summary collapse
-
#config_file ⇒ Object
Returns the value of attribute config_file.
Class Method Summary collapse
- .config_data(file) ⇒ Object
-
.plugin_context(config, plugin_name) ⇒ Object
returns the configs that are only related to the plugin name.
Instance Method Summary collapse
-
#config_data ⇒ Object
loads the config data into a ruby object.
- #gem_dir ⇒ Object
-
#initialize(file = default_config_file, opts = {}) ⇒ Config
constructor
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.
-
#setup_config_file(file = nil) ⇒ Object
create a blank yaml config file it file does not exist.
Methods included from Plugins::V1::ModuleHelpers
#create_content, #default_retrospec_dir, #notify, #overwrite?, #overwrite_all, #overwrite_enabled?, #prompt_for_overwrite, #retrospec_file?, #retrospec_repos_dir, #safe_copy_file, #safe_create_directory_files, #safe_create_file, #safe_create_module_files, #safe_create_symlink, #safe_create_template_file, #safe_mkdir, #safe_move_file, #safe_touch, #should_create?, #sync_file?
Constructor Details
#initialize(file = default_config_file, opts = {}) ⇒ Config
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
13 14 15 |
# File 'lib/retrospec/config.rb', line 13 def initialize(file=default_config_file, opts={}) setup_config_file(file) end |
Instance Attribute Details
#config_file ⇒ Object
Returns the value of attribute config_file.
9 10 11 |
# File 'lib/retrospec/config.rb', line 9 def config_file @config_file end |
Class Method Details
.config_data(file) ⇒ Object
35 36 37 |
# File 'lib/retrospec/config.rb', line 35 def self.config_data(file) new(file).config_data end |
.plugin_context(config, plugin_name) ⇒ Object
returns the configs that are only related to the plugin name
40 41 42 |
# File 'lib/retrospec/config.rb', line 40 def self.plugin_context(config, plugin_name) context = config.select {|k,v| k.downcase =~ /#{plugin_name}/ } end |
Instance Method Details
#config_data ⇒ Object
loads the config data into a ruby object
31 32 33 |
# File 'lib/retrospec/config.rb', line 31 def config_data @config_data ||= YAML.load_file(config_file) || {} end |
#gem_dir ⇒ Object
44 45 46 |
# File 'lib/retrospec/config.rb', line 44 def gem_dir File.("../../../", __FILE__) end |
#setup_config_file(file = nil) ⇒ Object
create a blank yaml config file it file does not exist
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/retrospec/config.rb', line 18 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') src_file = File.join(gem_dir,'config.yaml.sample') safe_copy_file(src_file, dst_file) file = dst_file end @config_file = file end |