Class: Approvals::Dotfile

Inherits:
Object
  • Object
show all
Defined in:
lib/approvals/utilities/dotfile.rb

Class Method Summary collapse

Class Method Details

.append(text) ⇒ Object



19
20
21
22
23
# File 'lib/approvals/utilities/dotfile.rb', line 19

def append(text)
  unless includes?(text)
    write text
  end
end

.includes?(text) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/approvals/utilities/dotfile.rb', line 25

def includes?(text)
  system("cat #{path} | grep -q \"^#{text}$\"")
end

.pathObject



11
12
13
# File 'lib/approvals/utilities/dotfile.rb', line 11

def path
  File.join(Approvals.project_dir, '.approvals')
end

.resetObject



6
7
8
9
# File 'lib/approvals/utilities/dotfile.rb', line 6

def reset
  File.delete(path) if File.exists?(path)
  touch
end

.touchObject



15
16
17
# File 'lib/approvals/utilities/dotfile.rb', line 15

def touch
  FileUtils.touch(path)
end

.write(text) ⇒ Object



29
30
31
32
33
# File 'lib/approvals/utilities/dotfile.rb', line 29

def write(text)
  File.open(path, 'a+') do |f|
    f.write "#{text}\n"
  end
end