Repository navigation
Allow for all US state comparison and fix specified state comparison - #95
Conversation
| def states(*states) | ||
| puts Kovid.states(states) | ||
| # This ensures this command is case insensitive. | ||
| downcased_states = states.map(&:downcase) |
There was a problem hiding this comment.
This was the key to fixing state comparison and making the comparison case insensitive. Without this list.include?(state['state'].downcase) here was never true if a user did kovid states Florida Tennessee, as the downcase call on the fetched state data would never match the capitalized state that was passed as an argument in the terminal.
| end | ||
|
|
||
| desc 'all_us_states', 'Returns full comparison table for all US states' | ||
| def all_us_states |
There was a problem hiding this comment.
Can you please make an alias for this so it works with say kovid aus? To type kovid all_us_states every time seems tedious, a shortcut would be nice :)
|
Nice work! I think this will be good to go once you add the alias. I agree with you on the tests and naming. I intended to fix those later and everything else gradually but you know...other projects and time constraints. Thanks for this PR! |
|
@siaw23 I added the alias method and this should be good to go (good call on that). One thing to note is that this commit, specifically this, caused a merge conflict with the refactor I did here. I resolved the conflict by selecting the version I created, as I think using |
|
Perfect. Thank you for working on this :). |
Sorry to do 2 things in 1 pr, but it seemed to make sense because they both rely on the
fetch_state_datamethod I added.Adding All State Comparison
Output is the following:

Fixing specified US state comparison.
Prior to this change running

kovid states Florida Tennessee, for example, would output the following.Now the output is as follows:

Notes on Specs
This spec may seem strange, but I made it this way because I feel strongly that we should move in the direction of using stubs. I plan to create another pr very soon that addresses the need for stubbing in other areas of the spec file and ensure this added functionality has full spec coverage, but for now I just added this.
Notes on variable and argument name changes
I did this for the sake of clarity. In general I think it will be best if we avoid names like
array, as it is less clear than alternatives. Happy to discuss further if you like.Thanks again for doing the work on the gem. It's awesome.