class RuboCop::Git::Options
Constants
- HOUND_DEFAULT_CONFIG_FILE
Attributes
cached[R]
config[RW]
hound[R]
rubocop[R]
Public Class Methods
new(hash_options = nil)
click to toggle source
# File lib/rubocop/git/options.rb, line 12 def initialize(hash_options = nil) @config = nil @cached = false @hound = false @rubocop = {} @commits = [] from_hash(hash_options) if hash_options end
Public Instance Methods
cached=(cached_)
click to toggle source
# File lib/rubocop/git/options.rb, line 22 def cached=(cached_) if cached_ && !@commits.empty? fail Invalid, 'cached and commit cannot be specified together' end @cached = !!cached_ end
commit_first()
click to toggle source
# File lib/rubocop/git/options.rb, line 62 def commit_first @commits.first end
commit_last()
click to toggle source
# File lib/rubocop/git/options.rb, line 66 def commit_last @commits.length == 1 ? false : @commits.last end
commits=(commits)
click to toggle source
# File lib/rubocop/git/options.rb, line 40 def commits=(commits) unless commits.is_a?(Array) && commits.length <= 2 fail Invalid, "invalid commits: #{commits.inspect}" end if !commits.empty? && cached fail Invalid, 'cached and commit cannot be specified together' end @commits = commits end
config_file()
click to toggle source
# File lib/rubocop/git/options.rb, line 50 def config_file if hound HOUND_DEFAULT_CONFIG_FILE elsif config config elsif File.exist?(RuboCop::ConfigLoader::DOTFILE) RuboCop::ConfigLoader::DOTFILE else RuboCop::ConfigLoader::DEFAULT_FILE end end
hound=(hound_)
click to toggle source
# File lib/rubocop/git/options.rb, line 29 def hound=(hound_) @hound = !!hound_ end
rubocop=(rubocop_)
click to toggle source
# File lib/rubocop/git/options.rb, line 33 def rubocop=(rubocop_) unless rubocop_.is_a?(Hash) fail Invalid, "invalid rubocop: #{rubocop_.inspect}" end @rubocop = rubocop_ end
Private Instance Methods
from_hash(hash_options)
click to toggle source
# File lib/rubocop/git/options.rb, line 72 def from_hash(hash_options) hash_options = hash_options.dup %w(config cached hound rubocop commits).each do |key| value = hash_options.delete(key) || hash_options.delete(key.to_sym) public_send("#{key}=", value) end unless hash_options.empty? fail Invalid, "invalid keys: #{hash_options.keys.join(' ')}" end end