Class: RSpec::Approvals::Dotfile
- Inherits:
-
Object
- Object
- RSpec::Approvals::Dotfile
- Defined in:
- lib/rspec/approvals/dotfile.rb
Class Method Summary collapse
- .append(text) ⇒ Object
- .includes?(text) ⇒ Boolean
- .path ⇒ Object
- .reset ⇒ Object
- .touch ⇒ Object
- .write(text) ⇒ Object
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
26 27 28 |
# File 'lib/rspec/approvals/dotfile.rb', line 26 def includes?(text) system("cat #{path} | grep -q \"^#{text}$\"") end |
.path ⇒ Object
12 13 14 |
# File 'lib/rspec/approvals/dotfile.rb', line 12 def path '.approvals' end |
.reset ⇒ Object
7 8 9 10 |
# File 'lib/rspec/approvals/dotfile.rb', line 7 def reset File.delete(path) if File.exists?(path) touch end |
.touch ⇒ Object
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 |