-
Notifications
You must be signed in to change notification settings - Fork 90
Make it possible to reduce available patterns #40
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
Make it possible to reduce available patterns #40
Conversation
I also added |
public | ||
|
||
def initialize | ||
@db = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@patterns
might be a better name, considering it is under an attr_reader
.
Ok. Fixed. |
Rebased. |
Ready to go 🚀 |
Thanks @maxmeyer. I'm going to take a little time to get my head around this one. Hopefully I can do so in the next couple of days. Thanks again for all the work here! |
No problem. You're welcome. Thanks a lot for making this library public. 😃
Would be great! I started using this library in a few projects of mine to generate some small eyecatchers. And spread the word about it. It's quite amazing how beautiful those generated images are. |
BTW: I added a few more tests. While writing them I also found a bug in the previous implementation of mine. Which is fixed now. I also added a proper exception for an invalid pattern which will be raised instead of "SystemExit" which is used by |
@@ -0,0 +1,7 @@ | |||
module GeoPattern | |||
# user errors | |||
class UserError < StandardError; end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think using this kind of pattern for exceptions is a question of style. If you do not like it, I can remove the "intermediate" error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have an opinion on this. @ttaylorr, do you?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I use this pattern all the time -- looks great.
…pattern because of name conflict
The changes here seem ok to me. Much of it effects @ttaylorr's recent restructuring changes, so I want to make sure we have a 👍 from him as well. |
Ok. Thanks for the feedback. |
@ttaylorr ping :-) |
Sorry that took so long, it's been a crazy few days for me! Everything looks fine to me, but I would've implemented a |
Friendly @ttaylorr ping. You aren't busy are you? 😉 |
😄 |
I think I've got an idea what he has got in his mind. @ttaylorr I think we're mixing multiple things in
Correct @ttaylorr? So I will try to splitup |
Yup. What I had suggested earlier (albeit in some fairly ambiguous language) was The Filter class would have one method Make sense? On Sat, Jan 24, 2015 at 3:06 PM, maxmeyer notifications@github.com wrote:
Thanks, ttaylorr.com |
Yes. I put together some more commits and push them as soon as I can. 😁 I think |
Mixing my Java conventions with my Ruby conventions! On Sat, Jan 24, 2015 at 3:12 PM, maxmeyer notifications@github.com wrote:
Thanks, ttaylorr.com |
Maybe I rename |
I would go with On Sat, Jan 24, 2015 at 3:14 PM, maxmeyer notifications@github.com wrote:
Thanks, ttaylorr.com |
@ttaylorr |
One thing I would like you to reconsider: |
I disagree with it revealing too many implementation details, but for the On Sun, Jan 25, 2015 at 1:25 PM, maxmeyer notifications@github.com wrote:
Thanks, ttaylorr.com |
You're revealing the structure of your library in the API by using e.g. The reason I raise this issue is the following: When introducing the |
public | ||
|
||
def initialize( | ||
store = HashStore.new( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is kind of a HashWithIndifferentAccess
. So there's no need to use strings here anymore.
|
||
def [](pattern) | ||
if pattern.kind_of?(String) || pattern.kind_of?(Symbol) | ||
$stderr.puts 'String pattern references are deprecated as of 1.3.0' if pattern.kind_of?(String) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added the deprecation warnings for string + class. I can revert this change @jasonlong. It's just a single commit.
@jasonlong @ttaylorr What do you think about the new structure? |
# | ||
# stream = capture(:stderr) { system('echo error 1>&2') } | ||
# stream # => "error\n" | ||
def capture(stream) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is also in Kernel::capture
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ttaylorr it is, but this method is being deprecated due to it not being thread safe.
You can check it out here https://github.com/rails/rails/blob/346677b3137a35de65c660c230d6fe9e71aa9b0e/activesupport/lib/active_support/core_ext/kernel/reporting.rb
And here is the PR that talks about it rails/rails#13392
Sorry for the random interjection I'm working a similar problem in teachers_pet
@ttaylorr Fixed duplication of code. Yes, it's marked deprecated because of missing thread-safety, but I think this should be ok for testing. What do you think? |
Guys, I apologize for my responsiveness. I've been dealing with some personal/family matters lately and haven't been able to focus much on this. Most of this is lower level Ruby than I'm comfortable with, so I'm happy to defer to @ttaylorr, @tarebyte, and others to collaborate with you (@maxmeyer) on these decisions. |
👍 |
😄 Love to see this merged. |
Hope everything is fine again for you/your familly soon! |
Make it possible to reduce available patterns
This PR is based on rspec-PR and testsuite-PR.
This PR makes it possible to reduce the available patterns. To make this possible it moves code from the
PatternGenerator
-class to a separate class I namedPatternDb
. This class handles all the checks etc. To make the library more testable I also moved some code to helpers methods I can also use in the tests.