Skip to content

Generate unique address#7

Merged
askn merged 6 commits into
askn:masterfrom
rickychilcott:feature/unique
Jun 26, 2019
Merged

Generate unique address#7
askn merged 6 commits into
askn:masterfrom
rickychilcott:feature/unique

Conversation

@rickychilcott

Copy link
Copy Markdown
Contributor

This is a WIP branch that generates unique values similar to how the ruby gem provides unique values.

I'm not sure I like this approach but it's the only thing I could come up with.

The API will expand to provide unique_* methods. (e.g. Faker::Address.city and Faker::Address.unique_city)

I use a crystal macro to generate both versions. Can you give this a review @askn and see if you like this approach? If not, can you share an alternative approach that might be better and I can investigate or submit another PR?

When complete, this will fix #4

@rickychilcott

Copy link
Copy Markdown
Contributor Author

Also, to clarify, this is only done for one method at the moment. I'll expand it to work with all classes and modularize when the approach is settled.

@askn

askn commented Sep 24, 2018

Copy link
Copy Markdown
Owner

Thanks for your contribution 🎉Looks nice. I can't find a different solution, it is ok for me 👍

@rickychilcott rickychilcott force-pushed the feature/unique branch 2 times, most recently from 42059c6 to 0718905 Compare September 24, 2018 11:27
@rickychilcott

Copy link
Copy Markdown
Contributor Author

Ok. Thanks. I'm making progress on this, but I have to determine how to build a macro that will allow an arbitrary number of arguments to be passed through it.

I now have each of the builders inherit from Faker::Base (https://github.com/askn/faker/pull/7/files#diff-80675a4903ffbf06d19c5f72efa31dd3) so we can easily add more functionality there

@watzon

watzon commented Jun 18, 2019

Copy link
Copy Markdown

This would be really nice to get merged in if it's working

@rickychilcott

Copy link
Copy Markdown
Contributor Author

Super funny, I was thinking about Crystal earlier today (before this request was made). Let me see if I can work in trying to make this work for all/most of the methods and go from there.

I'm not sure I actually think this is really the most idiomatic way to do this with a typed language, but it's worth it to have the feature working for people at this time.

@rickychilcott

Copy link
Copy Markdown
Contributor Author

I worked on this a bit last night and have something that kinda works. Can I get a review @askn?

I think I've got an issue where my macro doesn't actually pass in the arguments to the non-uniqued version. Do you know macros well enough to determine how to do this properly?

@rickychilcott rickychilcott changed the title WIP Generate unique address Generate unique address Jun 19, 2019
@rickychilcott

Copy link
Copy Markdown
Contributor Author

@askn Do you have time to review and merge or provide feedback?

@askn askn merged commit 83c9388 into askn:master Jun 26, 2019
@askn

askn commented Jun 26, 2019

Copy link
Copy Markdown
Owner

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow requesting unique values

3 participants