lib/io_streams/builder.rb in iostreams-1.1.0 vs lib/io_streams/builder.rb in iostreams-1.1.1
- old
+ new
@@ -1,7 +1,7 @@
module IOStreams
-# Build the streams that need to be applied to a path druing reading or writing.
+ # Build the streams that need to be applied to a path druing reading or writing.
class Builder
attr_accessor :file_name
attr_reader :streams, :options
def initialize(file_name = nil)
@@ -59,10 +59,11 @@
end
# Return the options set for either a stream or option.
def setting(stream)
return streams[stream] if streams
+
options[stream] if options
end
def reader(io_stream, &block)
execute(:reader, pipeline, io_stream, &block)
@@ -94,11 +95,11 @@
ext.send("#{type}_class") || raise(ArgumentError, "No #{type} registered for Stream type: #{stream.inspect}")
end
# Returns the streams for the supplied file_name
def parse_extensions
- parts = ::File.basename(file_name).split('.')
+ parts = ::File.basename(file_name).split(".")
extensions = []
while extension = parts.pop
sym = extension.downcase.to_sym
break unless IOStreams.extensions[sym]
@@ -107,10 +108,10 @@
extensions
end
# Executes the streams that need to be executed.
def execute(type, pipeline, io_stream, &block)
- raise(ArgumentError, 'IOStreams call is missing mandatory block') if block.nil?
+ raise(ArgumentError, "IOStreams call is missing mandatory block") if block.nil?
if pipeline.empty?
block.call(io_stream)
elsif pipeline.size == 1
stream, opts = pipeline.first