class PreCommit::Configuration
Attributes
pluginator[R]
providers[R]
Public Class Methods
new(pluginator, providers = nil)
click to toggle source
# File lib/pre-commit/configuration.rb, line 9 def initialize(pluginator, providers = nil) @pluginator = (pluginator or PreCommit.pluginator) @providers = (providers or Providers.new(@pluginator)) end
Public Instance Methods
disable(plugin_name, type, check1, *checks)
click to toggle source
# File lib/pre-commit/configuration.rb, line 42 def disable(plugin_name, type, check1, *checks) checks.unshift(check1) # check1 is ArgumentError triger checks.map!(&:to_sym) @providers.update( plugin_name, "#{type}_add", :-, checks ) @providers.update( plugin_name, "#{type}_remove", :+, checks ) true rescue PreCommit::PluginNotFound => e warn e.message false end
enable(plugin_name, type, check1, *checks)
click to toggle source
# File lib/pre-commit/configuration.rb, line 31 def enable(plugin_name, type, check1, *checks) checks.unshift(check1) # check1 is ArgumentError triger checks.map!(&:to_sym) @providers.update( plugin_name, "#{type}_remove", :-, checks ) @providers.update( plugin_name, "#{type}_add", :+, (checks or []) - (@providers.default(type) or []) ) true rescue PreCommit::PluginNotFound => e $stderr.puts e false end
get(name)
click to toggle source
# File lib/pre-commit/configuration.rb, line 14 def get(name) @providers[name.to_sym] end
get_arr(name)
click to toggle source
# File lib/pre-commit/configuration.rb, line 18 def get_arr(name) value = get(name) case value when nil then [] when Array then value else raise PreCommit::NotAnArray.new end end
get_combined(name)
click to toggle source
# File lib/pre-commit/configuration.rb, line 27 def get_combined(name) get_arr(name) + get_arr("#{name}_add") end