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

writing document fails (no method error "present?") #75

Closed
tamagokun opened this issue Apr 13, 2016 · 3 comments
Closed

writing document fails (no method error "present?") #75

tamagokun opened this issue Apr 13, 2016 · 3 comments

Comments

@tamagokun
Copy link
Contributor

Trying to generate an EDI document using the sample code from the documentation:

b.machine.zipper.tap do |z|
  # The :component, and :repetition parameters can also be specified as elements
  # of the ISA segment, at `b.ISA(...)` above. When generating a document from
  # scratch, :segment and :element must be specified -- if you've parsed the doc
  # from a file, these params will default to whatever was used in the file, or
  # you can override them here.
  separators =
    Stupidedi::Reader::Separators.build :segment    => "~\n",
                                        :element    => "*",
                                        :component  => ":",
                                        :repetition => "^"

  # You can also serialize any subtree within the document (e.g., everything inside
  # some ST..SE transaction set, or a single loop. Here, z.root is the entire tree.
  w = Stupidedi::Writer::Default.new(z.root, separators)
  w.write($stdout)
end

Getting the following no method error:

/Users/mkruk/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/stupidedi-1.2.6/lib/stupidedi/reader/separators.rb:53:in `select': undefined method `present?' for ":":String (NoMethodError)
Did you mean?  prepend
    from /Users/mkruk/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/stupidedi-1.2.6/lib/stupidedi/reader/separators.rb:53:in `characters'
    from /Users/mkruk/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/stupidedi-1.2.6/lib/stupidedi/writer/default.rb:19:in `write'
    from script/generate_997.rb:59:in `block in <main>'
    from /Users/mkruk/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/stupidedi-1.2.6/lib/stupidedi/either.rb:152:in `deconstruct'
    from /Users/mkruk/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/stupidedi-1.2.6/lib/stupidedi/either.rb:127:in `tap'
    from script/generate_997.rb:44:in `<main>'

Thought that it was my ruby version, upgraded to 2.3.0, but still no luck. It seems like maybe this is an issue with refinements? Any help would be appreciated.

@tamagokun tamagokun changed the title generating edi document fails (no method error "present?") writing document fails (no method error "present?") Apr 13, 2016
@kputnam
Copy link
Owner

kputnam commented Apr 13, 2016

Ah, yes it is caused by refinements. It seems indirectly invoking a refinement method via &:present? won't work, but I think this can be fixed by spelling it out .select{|x| x.present? }.

I should have time to address this and other places it might occur within a day or two. Thanks for filing a bug!

kputnam pushed a commit that referenced this issue Apr 14, 2016
@kputnam
Copy link
Owner

kputnam commented Apr 14, 2016

This was the only instance where a refinement method was called indirectly (the others were fixed previously). It's fixed in master and @irobayna or I will do a release soon. Thanks again for the report.

@kputnam kputnam closed this as completed Apr 14, 2016
@tamagokun
Copy link
Contributor Author

Excellent, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants