Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for more user-friendly enumerators #17

Open
ribose-jeffreylau opened this issue Jul 3, 2018 · 2 comments
Open

Support for more user-friendly enumerators #17

ribose-jeffreylau opened this issue Jul 3, 2018 · 2 comments
Assignees

Comments

@ribose-jeffreylau
Copy link
Contributor

Currently, given this:

rnp = Rnp.new

... the following enumerators are provided:

rnp.each_fingerprint
rnp.each_grip
rnp.each_keyid
rnp.each_userid

Would it be possible to have the following way of working with the rnp object?

rnp.each_key do |key|
  key # ... do something ...
end

or even:

rnp.keys # => returns the collection of all key objects

so one could do these:

rnp.keys
  .filter(&:primary?)
  .filter(&:protected?)
  .filter(&:secret_key_present?)
  .reject(&:expired?)

Thanks!

@dewyatt
Copy link
Contributor

dewyatt commented Jul 4, 2018

It's certainly possible to implement this by just wrapping the other enumerators.

The reason this was not done initially is that, per the RFC, how a key is located (via userid, keyid, fpr, etc) determines what preferences apply. So it might be surprising behaviour.

@skalee
Copy link
Contributor

skalee commented Jul 5, 2018

Actually, Rnp#each_key should return an Enumerator instance. That's enough to chain filters, sorts, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants