Class: Overcommit::Configuration
- Inherits:
-
Object
- Object
- Overcommit::Configuration
- Includes:
- Singleton
- Defined in:
- lib/overcommit/configuration.rb
Instance Attribute Summary collapse
-
#templates ⇒ Object
readonly
Returns the value of attribute templates.
Instance Method Summary collapse
-
#desired_plugins ⇒ Object
Given the current configuration, return a set of paths which should be loaded as plugins (‘require`d).
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
-
#repo_settings ⇒ Object
Read the repo-specific ‘overcommit.yml’ file to determine what behavior the user wants.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
10 11 12 |
# File 'lib/overcommit/configuration.rb', line 10 def initialize @templates = YAML.load_file(Utils.absolute_path('config/templates.yml')) end |
Instance Attribute Details
#templates ⇒ Object (readonly)
Returns the value of attribute templates.
8 9 10 |
# File 'lib/overcommit/configuration.rb', line 8 def templates @templates end |
Instance Method Details
#desired_plugins ⇒ Object
Given the current configuration, return a set of paths which should be loaded as plugins (‘require`d)
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/overcommit/configuration.rb', line 24 def desired_plugins excludes = repo_settings['excludes'] || {} plugin_directories.map do |dir| Dir[File.join(dir, Utils.hook_name, '*.rb')].map do |plugin| basename = File.basename(plugin, '.rb') if !(excludes[Utils.hook_name] || []).include?(basename) plugin end end.compact end.flatten end |
#repo_settings ⇒ Object
Read the repo-specific ‘overcommit.yml’ file to determine what behavior the user wants.
16 17 18 19 20 |
# File 'lib/overcommit/configuration.rb', line 16 def repo_settings config_file = Utils.repo_path('.git/hooks/overcommit.yml') File.exist?(config_file) ? YAML.load_file(config_file) : {} end |