Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/lazy load encode improvements #21

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Change EstrattoParser#perform to return an Enumerator::Lazy
  • Loading branch information
de-farias committed Oct 30, 2020
commit 8c273f9cb7e0bab2757b40168bb61f52c4cdd97f
8 changes: 2 additions & 6 deletions lib/estratto/parser.rb
Original file line number Diff line number Diff line change
@@ -1,5 1,5 @@
require_relative 'register'
require_relative 'content'
require_relative 'helpers/register_enumerator'

module Estratto
class Parser
Expand All @@ -11,11 11,7 @@ def initialize(file_path, layout)
end

def perform
@data ||= raw_content.each_with_index.map do |line, index|
register_layout = layout.register_fields_for(line[layout.prefix_range])
next if register_layout.nil?
Register.new(line, index, register_layout).refine
end.reject{ |line| line.nil? }
@data ||= Helpers::RegisterEnumerator.new(raw_content, layout)
end

def raw_content
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/estratto/parser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 30,7 @@
end

it "returns an Enumerator::Lazy object" do
expect(subject.perform).to be_a Enumerator::Lazy
expect(subject.perform).to be_a Estratto::Helpers::RegisterEnumerator
end

it "returns the right content" do
Expand Down