Class: Mate::TmProperties::Ignores
- Inherits:
-
Object
- Object
- Mate::TmProperties::Ignores
- Defined in:
- lib/mate/tm_properties/ignores.rb
Constant Summary collapse
- GENERATED_SUFFIX =
'## GENERATED ##'- GENERATED_R =
/^exclude(?:Directories)? = .* #{Regexp.escape(GENERATED_SUFFIX)}$/
Instance Attribute Summary collapse
-
#dir ⇒ Object
readonly
Returns the value of attribute dir.
Instance Method Summary collapse
-
#initialize(dir, options) ⇒ Ignores
constructor
A new instance of Ignores.
- #lines ⇒ Object
Constructor Details
#initialize(dir, options) ⇒ Ignores
Returns a new instance of Ignores.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/mate/tm_properties/ignores.rb', line 9 def initialize(dir, ) @dir = dir @exclude = ['**/.git'] @exclude_directories = [] process('.', Git.excludesfile(dir)) process('.', Git.global_tmignore) if ![:skip_info_exclude] && (git_dir = Git.git_dir(dir)) process('.', git_dir + 'info/exclude') end dir.find do |path| next unless path.lstat.directory? toplevel = dir == path if !toplevel && (path + '.git').exist? TmProperties.new(path, ).save Find.prune else relative_path = path.relative_path_from(dir).to_s Find.prune if ignore_dir?(relative_path) %w[.gitignore .tmignore].each do |ignore_file_name| process(relative_path, path + ignore_file_name) end if !toplevel && (path + '.tm_properties').exist? TmProperties.new(path, ).cleanup end end end end |
Instance Attribute Details
#dir ⇒ Object (readonly)
Returns the value of attribute dir.
8 9 10 |
# File 'lib/mate/tm_properties/ignores.rb', line 8 def dir @dir end |
Instance Method Details
#lines ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/mate/tm_properties/ignores.rb', line 42 def lines escaped_dir = glob_escape(dir.to_s) [ "exclude = '#{escaped_dir}/#{glob_join(@exclude)}' #{GENERATED_SUFFIX}", "excludeDirectories = '#{escaped_dir}/#{glob_join(@exclude_directories)}' #{GENERATED_SUFFIX}", ].map{ |line| line.gsub("\r", '\r') } end |