Skip to content

Commit

Permalink
'Path#puts' added
Browse files Browse the repository at this point in the history
  • Loading branch information
epitron committed Aug 20, 2016
1 parent 03f7d2e commit fa7d618
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion VERSION
@@ -1 +1 @@
0.5.90
0.5.91
10 changes: 10 additions & 0 deletions lib/epitools/path.rb
Expand Up @@ -691,6 +691,7 @@ def touch
# Append data to this file (accepts a string, an IO, or it can yield the file handle to a block.)
#
def append(data=nil)
# FIXME: copy_stream might be inefficient if you're calling it a lot. Investigate!
self.open("ab") do |f|
if data and not block_given?
if data.is_an? IO
Expand All @@ -706,6 +707,14 @@ def append(data=nil)
end
alias_method :<<, :append

#
# Append data, with a newline at the end
#
def puts(data=nil)
append data
append "\n" unless data and data[-1] == "\n"
end

#
# Overwrite the data in this file (accepts a string, an IO, or it can yield the file handle to a block.)
#
Expand All @@ -723,6 +732,7 @@ def write(data=nil)
end
end


###############################################################################
# Parsing files
###############################################################################
Expand Down

0 comments on commit fa7d618

Please sign in to comment.