Skip to content

fix: handle abbreviations and numbers in feature name#11

Merged
lanej merged 5 commits intoEasyPost:masterfrom
lanej:lanej/const-lookup/irregular-numbers
Aug 19, 2021
Merged

fix: handle abbreviations and numbers in feature name#11
lanej merged 5 commits intoEasyPost:masterfrom
lanej:lanej/const-lookup/irregular-numbers

Conversation

@lanej
Copy link
Copy Markdown
Member

@lanej lanej commented Aug 16, 2021

No description provided.

@lanej lanej requested a review from kgraves August 16, 2021 21:06
@lanej lanej requested a review from kgraves August 17, 2021 19:56
Comment on lines +29 to +32
key = sym.to_s
key.gsub!(/([A-Z\d]+)([A-Z][a-z])/, '\1_\2'.freeze)
key.gsub!(/([a-z\d])([A-Z])/, '\1_\2'.freeze)
key.downcase!
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still seeing that we're having some issues with translation of potential keys, but let me know if you don't see it as an issue right now, or something we'll fix later.

[2] pry(main)> def tr(str)
[2] pry(main)*   str.gsub!(/([A-Z\d]+)([A-Z][a-z])/, '\1_\2'.freeze)
[2] pry(main)*   str.gsub!(/([a-z\d])([A-Z])/, '\1_\2'.freeze)
[2] pry(main)*   str.downcase!
[2] pry(main)*   return str
[2] pry(main)* end
=> :tr
[3] pry(main)>
[4] pry(main)> tr("CN22")
=> "cn22"
[5] pry(main)> tr("Allow2DayAir")
=> "allow2_day_air"
[6] pry(main)> tr("Allow2ndDaySomething")
=> "allow2nd_day_something"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As this a transitionary release and there is a workaround for it, I'm inclined to improve it within reason and then move on to a major release that removes support for module-based access entirely.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool, works for me

Comment on lines +29 to +32
key = sym.to_s
key.gsub!(/([A-Z\d]+)([A-Z][a-z])/, '\1_\2'.freeze)
key.gsub!(/([a-z\d])([A-Z])/, '\1_\2'.freeze)
key.downcase!
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool, works for me

@lanej lanej merged commit 159bca5 into EasyPost:master Aug 19, 2021
@lanej lanej deleted the lanej/const-lookup/irregular-numbers branch August 19, 2021 20:00
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