Class: RSpec::Approvals::Dotfile

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

Class Method Summary collapse

Class Method Details

.append(text) ⇒ Object



20
21
22
23
24
# File 'lib/rspec/approvals/dotfile.rb', line 20

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

.includes?(text) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/rspec/approvals/dotfile.rb', line 26

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

.pathObject



12
13
14
# File 'lib/rspec/approvals/dotfile.rb', line 12

def path
  '.approvals'
end

.resetObject



7
8
9
10
# File 'lib/rspec/approvals/dotfile.rb', line 7

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

.touchObject



16
17
18
# File 'lib/rspec/approvals/dotfile.rb', line 16

def touch
  FileUtils.touch(path)
end

.write(text) ⇒ Object



30
31
32
33
34
# File 'lib/rspec/approvals/dotfile.rb', line 30

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