Class: Ignorance::IgnoreFile

Inherits:
Object
  • Object
show all
Defined in:
lib/ignorance/ignore_file.rb

Direct Known Subclasses

GitIgnoreFile, HgIgnoreFile, SvnIgnoreFile

Instance Method Summary collapse

Instance Method Details

#exists?Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/ignorance/ignore_file.rb', line 8

def exists?
  File.exists? ignore_file
end

#ignore!(token, comment = nil) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/ignorance/ignore_file.rb', line 24

def ignore!(token, comment=nil)
  return true if ignored?(token)
  if comment
    anchor = commentified comment
    if included? anchor
      insert_after anchor, token
    else
      append "\n"
      append anchor
      append token
    end
  else # There's no comment
    append token
  end

  write_ignore_file
end

#ignored?(token) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/ignorance/ignore_file.rb', line 16

def ignored?(token)
  ignored.include? token
end

#included?(token) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/ignorance/ignore_file.rb', line 20

def included?(token)
  file_contents.include? token
end

#its_a_repo?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/ignorance/ignore_file.rb', line 12

def its_a_repo?
  Dir.exists? repo_dir
end

#nameObject



4
5
6
# File 'lib/ignorance/ignore_file.rb', line 4

def name
  ignore_file
end