Skip to content

Commit

Permalink
Parser#initialize: read file when filename given
Browse files Browse the repository at this point in the history
It seems natural to pass a filename to initialize, so if whatever we're
given is a file that exists, read its contents instead of using it as
string data directly.

(It occurs to me that we may want to duplicate the string otherwise, but
I'm unsure what other use cases might be present that I'm not thinking
of, so I'm leaving that out for now.)

Fixes francois#2

Note: Chosing to bump version to 0.2.2 because rubygems has a 0.2.1 from
somewhere that I couldn't find.

This change technically Copyright 2021 by David Lindes, and I agree to
license it under the same terms as the rest of this repository.
  • Loading branch information
lindes committed Dec 30, 2021
1 parent 9489855 commit 10fa8c6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/quicken_parser/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
module QuickenParser
class Parser #:nodoc:
def initialize(source)
@input = source.respond_to?(:read) ? source.read : source
@input = source.respond_to?(:read) ? source.read :
File.exists?(source) ? File.open(source).read : source
end

def parse
Expand Down
2 changes: 1 addition & 1 deletion lib/quicken_parser/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module QuickenParser
VERSION = "0.2.0"
VERSION = "0.2.2"
end

0 comments on commit 10fa8c6

Please sign in to comment.