Skip to content
This repository has been archived by the owner on Jun 8, 2023. It is now read-only.

factoids shouldn't be case-sensitive #1196

Merged

Conversation

patcon
Copy link
Contributor

@patcon patcon commented Oct 27, 2013

Title says it all. Will aim to split this script out per #1113 if I work on it.

@RobLoach
Copy link

Leaving myself a note here.... @RobLoach

@patcon
Copy link
Contributor Author

patcon commented Oct 27, 2013

Just about to push this fix :) Thanks though rob

@patcon
Copy link
Contributor Author

patcon commented Oct 27, 2013

OK, so now all the keys in the system are lowercase, but it will print back whatever you wrote it as so as not to surprise:

Hubot> ~CSI is Centre for Social Innovation
Hubot> Shell: OK. CSI is Centre for Social Innovation 
Hubot> hubot factoids list
Hubot> csi
Hubot> hubot factoid delete "CSI"
Hubot> Shell: OK. I forgot about CSI

Will we need to add something to convert all existing keys to lowercase? That might be destructive, so maybe the best way is to simply remove the toLowerCase() conversion on delFactoid, so people can clean up easily and replace them with properly lower-cased keys...

Thoughts?

@technicalpickles
Copy link
Contributor

You could try looking for the keys as they are entered as well as whatever
is lower cases, and then make the setter make sure only the lower cased key
exists.

Also worth noting that this script sounds pretty familiar to
remember.coffee.

On Sunday, October 27, 2013, Patrick Connolly wrote:

OK, so now all the keys in the system are lowercase, but it will print
back whatever you wrote it as so as not to surprise:

Hubot> ~CSI is Centre for Social Innovation
Hubot> Shell: OK. CSI is Centre for Social Innovation
Hubot> hubot factoids list
Hubot> csi
Hubot> hubot factoid delete "CSI"
Hubot> Shell: OK. I forgot about CSI

Will we need to add something to convert all existing keys to lowercase?
That might be destructive, so maybe the best way is to simply remove the
toLowerCase() conversion on delFactoid, so people can clean up easily and
replace them with properly lower-cased keys...

Thoughts?


Reply to this email directly or view it on GitHubhttps://github.com//pull/1196#issuecomment-27180941
.

Josh

These messy additions should be removed after the next major version bump. It might make sense to leave the "get" and "del" functions like this so that people can clean up extra keys regardless.
@patcon
Copy link
Contributor Author

patcon commented Nov 19, 2013

Does this work well enough? Added unless @cache[key]? to avoid downcasing for lookup and storage if the caps-sensitive version matches. Should preserve backwards compat.

@technicalpickles
Copy link
Contributor

It looks about right, but hard to tell if it'll work as expected without testing. How has your own testing gone? What uses cases have you tried?

@patcon
Copy link
Contributor Author

patcon commented Nov 23, 2013

You know, what -- maybe I'll take the time to use yo hubot-script, split this out, and get some real tests on it. Haven't done that for any hubot script packages yet, so it'll be good practice :)

technicalpickles added a commit that referenced this pull request Jun 5, 2015
@technicalpickles technicalpickles merged commit bd810f9 into github:master Jun 5, 2015
@technicalpickles
Copy link
Contributor

We are actually moving away from adding scripts to repository in favor of separate npm packages per scripts. We have already stopped accepting new scripts, and will stop accepting pull requests on this repository after hubot 3.0.

See #1113 for details. If you are interested in maintaining this longer term, check npm in case someone already made a package for it, and if not, check out https://hubot.github.com/docs/scripting/ for creating a package of your own.

# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants