Skip to content

Allow for all US state comparison and fix specified state comparison - #95

Merged
siaw23-retired merged 7 commits into
siaw23:masterfrom
dylanandrews:feature/all-us-state-comparison
Apr 5, 2020
Merged

siaw23-retired merged 7 commits into
siaw23:masterfrom
dylanandrews:feature/all-us-state-comparison

Conversation

@dylanandrews

@dylanandrews dylanandrews commented Apr 4, 2020 •

Copy link
Copy Markdown
Contributor

Sorry to do 2 things in 1 pr, but it seemed to make sense because they both rely on the fetch_state_data method I added.

Adding All State Comparison

Output is the following:
image

Fixing specified US state comparison.

Prior to this change running kovid states Florida Tennessee, for example, would output the following.
image

Now the output is as follows:
image

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.

@dylanandrews dylanandrews changed the title Allow for all us state comparison and fix specified state comparison Allow for all US state comparison and fix specified state comparison Apr 4, 2020
Comment thread lib/kovid/cli.rb
def states(*states)
puts Kovid.states(states)
# This ensures this command is case insensitive.
downcased_states = states.map(&:downcase)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Comment thread lib/kovid/cli.rb
end

desc 'all_us_states', 'Returns full comparison table for all US states'
def all_us_states

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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 :)

@siaw23-retired

Copy link
Copy Markdown
Collaborator

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!

@dylanandrews

dylanandrews commented Apr 5, 2020 •

Copy link
Copy Markdown
Contributor Author

@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 select is a bit cleaner than using collect and compact. If you would like to discuss further let me know.

@siaw23-retired

Copy link
Copy Markdown
Collaborator

Perfect. Thank you for working on this :).

@siaw23-retired
siaw23-retired merged commit 2726fff into siaw23:master Apr 5, 2020
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