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

WIP: Reorganization #164

Merged
merged 98 commits into from
Mar 27, 2019
Merged

WIP: Reorganization #164

merged 98 commits into from
Mar 27, 2019

Conversation

kputnam
Copy link
Owner

@kputnam kputnam commented Jan 13, 2019

This isn't quite ready to merge, since there might be a few more potentially breaking changes still coming. Quite a few changes here:

Bug fixes

  • Fix ambiguous grammars (mostly due to incorrect parentheses)
  • Fix errors in Standards::FortyTen::HC837
  • Fix errors in Standards::FiftyTen::BE834
  • Fix errors in Standards::FiftyTen::HB271
  • Fix errors in Standards::FiftyTen::RA820
  • Fix parsing invalid numeric data in Ruby 2.4+. Previously "10B" would be read as 10.0, and "AB10" would be read as 0.0 due to using bigdecimal/util's implementation of String#to_d
  • Fix TimeVal issue in all versions (not only 005010)

Added

  • Added Stupidedi::Parser.build as a shortcut for Stupidedi::Parser::StateMachine.build
  • Added many stub definitions of segments, just the segment name and no elements, which are referred to by RA820 and others.
  • edi-pp can now print different formats with --format html, --format x12, and --format tree (default)

Deprecation notices

  • Remove support for Ruby < 2.0
  • Remove workarounds for broken JRuby refinements
  • Remove Symbol#call and Symbol#to_proc refinements

Renamed

  • Stupidedi::Builder is renamed to Stupidedi::Parser
  • Stupidedi::Guides::*::GuideBuilder is renamed to Stupidedi::TransactionSets::Builder
  • Stupidedi::Versions::Interchanges is renamed to Stupidedi::Interchanges
  • Stupidedi::Versions::FunctionalGroups is renamed to Stupidedi::Versions
    • Lots of common code among versions has been factored into Stupidedi::Versions::Common
  • Rename Guides HC837P and HC837I to HC837
  • Moved all grammars, including Guides and Contrib, to Stupidedi::TransactionSets
    • Each version now has ::Standards and ::Implementations
  • Stupidedi::Schema::Auditor is renamed to Stupidedi::TransactionSets::Validation::Ambiguity

Most of these renames aren't breaking changes (yet), but using the old name will print a warning:

Stupidedi::Contrib is deprecated, use Stupidedi::TransactionSets
Stupidedi::Guides is deprecated, use Stupidedi::TransactionSets::*::Implementations
Stupidedi::TransactionSets::FiftyTen::Implementations::X222::HC837P is deprecated, use HC837 instead
Stupidedi::TransactionSets::FiftyTen::Implementations::X222A1::HC837P is deprecated, use HC837 instead
Stupidedi::TransactionSets::FiftyTen::Implementations::X223::HC837I is deprecated, use HC837 instead
Stupidedi::Versions::Interchanges is deprecated, use Stupidedi::Interchanges instead
Stupidedi::Versions::FunctionalGroups is deprecated, use Stupidedi::TransactionSets::*::Standards instead

Specs

  • Grammar specs automatically created when a fixture is added to spec/fixtures/<version>/<name>/pass/*.x12
  • Remove support for rcov. Use only simplecov now
  • Update all specs to use expect(value).to matcher syntax, instead of value.should matcher
  • New specs to ensure element names match their id (eg, E123.id == :E123)
  • New specs to ensure segment names match their id (eg ST.id == :ST)
  • New specs to ensure Config.hipaa, Config.contrib, and Config.default reference valid definitions
  • New specs for Stupidedi::TransactionSets::Validation::Ambiguity
  • Fix fixture files that used \n as a segment terminator but didn't have one after IEA

Miscellaneous

  • Create new examples in examples/ that demonstrate undocumented IdentifierStack, and more
  • Made whitespace and other formatting more consistent
  • Stupidedi::TransactionSets::Builder.build no longer requires a TransactionSetDef argument
  • Fix Travis CI to build older versions of Ruby < 2.3
  • Ignore large definition files in Code Climate

kputnam added 25 commits January 2, 2019 16:36
…s, revealing a couple more instances of ambiguous grammar
…:FunctionalGroups, Stupidedi::Versions::Interchanges
@kputnam kputnam force-pushed the pr-reorganize branch 2 times, most recently from afde1ed to 132abf0 Compare January 13, 2019 03:46
specs for IdentifierStack and fix a bug; Change Navigation#elementn to
strictly validate its arguments, even when corresponding data is not
present; Fix validation in Navigation#iterate (#126); Write many more
specs
… ID, Nn, R, TM)

- Invalid#map and Invalid#copy always return Invalid
- Invaild#== is now #eql?, so it will not == nil any longer
- Empty#map and Empty#copy always call the type's .value constructor;
  previously sometimes it only constructed another Empty
- Empty#== is true for "" on AN and ID, and nil on DT, Nn, R, TM
- Empty#value is now implemented and returns "" for AN and ID, and nil
  for DT, Nn, R, and TM
- Empty#map now yields #value, which is either nil or ""
- All non-Invalid values implement #coerce
- Each type now has a case in .value for when the argument is already
  the correct type (similar to a copy constructor), this is used in
  #coerce
- Each type also has a case in .value for the data in #value of the
  corresponding type, so eg. DateVal.value(date_val.value) == date_val
- DateVal::Improper#value is now [year, month, day], and now #map yields
  this single argument (a three-element array) instead of three arguments
- TimeVal::Valid#value is now [hour, minute, second], and now #map
  yields this single argument instead of three arguments
- Greatly reduce duplication of specs for each element type by using
  shared_examples for invalid, empty, and non-empty cases
improve the style of existing specs by using expect { } instead of
expect(lambda { })
@kputnam kputnam requested a review from irobayna February 18, 2019 04:12
@kputnam
Copy link
Owner Author

kputnam commented Feb 18, 2019

Hey @irobayna, this is probably ready to merge, but I'm hoping you can try it out first. There are lot more specs, but it's still possible I missed something among all the changes in this branch.

The goal is to be backward compatible with the current release. So let me know if you're able to do any smoke testing and find a problem. I will take a day or so to make sure all the changes are documented in the PR description above, then it should be good to merge.

@irobayna
Copy link
Collaborator

@kputnam I will try it out and let you know

@irobayna
Copy link
Collaborator

irobayna commented Mar 5, 2019

@kputnam seeing this issue with this release while parsing a document

stupidedi-1.3.23/lib/stupidedi/zipper/abstract_cursor.rb:170:in `down': cannot descend into leaf node (Stupidedi::Exceptions::ZipperError)
from stupidedi-1.3.23/lib/stupidedi/zipper/abstract_cursor.rb:207:in `child'
from stupidedi-1.3.23/lib/stupidedi/parser/navigation.rb:169:in `block in element'
from stupidedi-1.3.23/lib/stupidedi/either.rb:151:in `call'
from stupidedi-1.3.23/lib/stupidedi/either.rb:151:in `deconstruct'
from stupidedi-1.3.23/lib/stupidedi/either.rb:103:in `flatmap'
from stupidedi-1.3.23/lib/stupidedi/parser/navigation.rb:130:in `element'

This is the culprit (worked on previous version)

service[:code]                = svc.element(6, 2).map(&:node).fetch(0).to_s

@kputnam
Copy link
Owner Author

kputnam commented Mar 7, 2019

I have a hunch what's going on. Do you know if that particular SVC segment has an empty value in SVC02? I'll see if I can reproduce it, but if you can past the SVC segment then I can be more certain of fixing the right thing.

@irobayna
Copy link
Collaborator

irobayna commented Mar 7, 2019

@kputnam SVC02 does have a value

SVC*HC:98943*60*16.69~

@kputnam
Copy link
Owner Author

kputnam commented Mar 7, 2019

Oops, I should have said SVC06. Looks like that isn't present. Definitely a regression, apparently caused by not checking that SVC06 occurs before trying to get SVC06-02. Thanks, I should be able to fix it soon!

@kputnam
Copy link
Owner Author

kputnam commented Mar 9, 2019

Should be fixed now, @irobayna

@irobayna
Copy link
Collaborator

@kputnam That problem is fixed now.

On another project that leverages stupidEDI I have 6 specs failing. Will take a look as to what's the problem and report back.

@kputnam kputnam changed the title Reorganization WIP: Reorganization Mar 11, 2019
@irobayna
Copy link
Collaborator

@kputnam So far so good, I have exercised the system and I am happy to report, it works. I get a lot of deprecations warnings (rightly so). Did not try to get rid of them now as I will have to it once we merge this code. Thanks!

@kputnam
Copy link
Owner Author

kputnam commented Mar 21, 2019

@irobayna thanks for testing the waters! I spent a few hours trying to clean up the commit history a little, but gave up and decided it wasn't worth the time. Now that I've let it sit for a couple weeks, I'll review everything one last time with fresh eyes and make sure it's well-documented. We can probably merge this weekend.

@kputnam kputnam merged commit f4beb3d into master Mar 27, 2019
@irobayna
Copy link
Collaborator

irobayna commented Mar 27, 2019

@kputnam seems like you merged this PR already, I have updated the version to 1.4.0 so people using the gem know this is a major release

@kputnam
Copy link
Owner Author

kputnam commented Mar 27, 2019

Yep, I just merged. Thanks for updating the version, and feel free to release whenever you like. Hopefully this goes smoothly! 😓

@irobayna
Copy link
Collaborator

@kputnam All set!

@kputnam kputnam deleted the pr-reorganize branch May 13, 2019 21:08
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

Successfully merging this pull request may close these issues.

2 participants