avit / stockboy

A helpful gem to receive and unpack data into your organization from anywhere
MIT License
40 stars 7 forks source link

let pick accept proc with single argument #18

Closed dvee closed 7 years ago

dvee commented 8 years ago

The documentation for pick suggests that a proc accepting just the file list as a parameter can be used (https://github.com/avit/stockboy/blob/master/lib/stockboy/provider.rb#L183 , https://github.com/avit/stockboy/blob/master/lib/stockboy/providers/ftp.rb#L22). However reduce requires a proc taking two arguments.

Suggested change conforms to examples in docs and shouldn't break existing usage.

avit commented 8 years ago

I'm a little concerned that this would behave differently based on the block arity (which can be a bit strange in ruby with splat arguments: `proc { |a, b| }.arity == -2`) but maybe that's unwarranted...

It looks like that pick ->(list) { documentation is just wrong anyway, it should just work with a standard reduce like this:

https://github.com/dvee/stockboy/blob/fix_pick/lib/stockboy/provider.rb#L155

Your point makes sense though, there might be room for improvement, let me know what you're trying to accomplish if reduce can't do it.

avit commented 8 years ago

See also: https://github.com/avit/stockboy/issues/1 if it's specifically about FTP.