Method: Milkode::IgnoreSetting#initialize
- Defined in:
- lib/milkode/common/ignore_setting.rb
#initialize(path, ignores) ⇒ IgnoreSetting
Returns a new instance of IgnoreSetting.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/milkode/common/ignore_setting.rb', line 25 def initialize(path, ignores) @path = path @ignores = [] @not_ignores = [] ignores.each do |v| v = v.sub(/\/\Z/, "") unless v.start_with?('!') @ignores << v else @not_ignores << v.sub(/\A!/, "") end end # 除外設定 -> 正規表現 @regexps = @ignores.map {|v| convert_regexp(v)} # 非除外設定 -> 展開 -> 正規表現 new_not_ignores = [] @not_regexps = [] @not_ignores.each do |v| last_regexp = "(\/|\\Z)" # 自分自身は後方マッチ可 Pathname.new(v).ascend do |pathname| txt = pathname.to_s new_not_ignores << txt @not_regexps << convert_regexp(txt, last_regexp) last_regexp = "\\Z" # 親ディクレクリは後方マッチ不可 end end @not_ignores = new_not_ignores end |