Open ghost opened 10 years ago
Definitely a good idea - shall look into it tomorrow.
I can write it all up if I have all the necessary hashes so I can test whether the library recognizes them in the right way. I was thinking of something simple like:
describe HashChecker
it 'recognizes a xxx hash' do
HashChecker.new.check('xxx').should eq('yyy')
end
end
Instead of testing the actual command line app and thus output, we could add some kind of ID, like a symbol, to the end of each pattern in hash_data.rb
, and make that file only handle the patterns instead of concatenating them into a human-readable form. The hashdata
executable file should handle that sort of stuff instead. That way, we can just test the API instead of the CLI.
Sorry I forgot about this, its been a hectic month - not sure about separating the naming and the patterns, one of the original goals of this was to also make it easy for people to get regexs for hash functions to use for other projects, since I couldn't find anything offering them previously.
Oh, no that's not what I meant. I just wanted some way of ID-ing each regular expression so we know the correct one was matched when testing. I don't necessarily mean separating these into various documents and certainly not separating the names from the regular expression.
Adding a "verify" function that takes a hash name and verifies the supplied hash if potentially of that type seems like an easier way to do this. On the plus this also provides a valid reason to use hashdata as a library. I can see use cases for verifying a hash type in other programs but spitting out a list of hash types is really only going to be useful as a command line util.
I :+1: this approach.
The library functionality was expanded and the first rspec test case created in commit b01c41084b4e64ae252ba5a69c43f786680174ed I shall continue to expand the hashes covered periodically - finding the hashes is bordering on a treasure hunt because a lot of them are from certain frameworks/OSs etc. So the plan is tag them all with source example code/commands and versions (I missed versions on the first upload shall add imminently).
It would be useful to have some kind of spec/test suit, preferably with RSpec (my favourite), to test whether each hash is recognized as expected.