Class: Approvals::Dotfile
- Inherits:
-
Object
- Object
- Approvals::Dotfile
- Defined in:
- lib/approvals/utilities/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
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
25 26 27 |
# File 'lib/approvals/utilities/dotfile.rb', line 25 def includes?(text) system("cat #{path} | grep -q \"^#{text}$\"") end |
.path ⇒ Object
11 12 13 |
# File 'lib/approvals/utilities/dotfile.rb', line 11 def path File.join(Approvals.project_dir, '.approvals') end |
.reset ⇒ Object
6 7 8 9 |
# File 'lib/approvals/utilities/dotfile.rb', line 6 def reset File.delete(path) if File.exists?(path) touch end |
.touch ⇒ Object
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 |