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

Really cool DSL! #1

Open
e2 opened this issue May 30, 2016 · 2 comments
Open

Really cool DSL! #1

e2 opened this issue May 30, 2016 · 2 comments

Comments

@e2
Copy link

e2 commented May 30, 2016

I wish I saw this earlier.

Did you ever ask to get this included in Guard before? It's a shame it didn't replace the current DSL years ago :(

The Guard "paradigm" is quite tricky to convey properly:

# If things were named better in Guard
action(:some_klass, options) do
  match(pattern) { |match| action_params }
end

Ultimately I think the "dsl magic" hurts more than it helps, because Ruby is quite simple already and a DSL only obscures things.

So I'd personally move slightly towards OOP

action = current_group.create_action(:some_klass, options)
action.run_with(action_param).when(pattern)

Of course the old DSL would still have to be supported forever :(

Anyway, thanks for sharing! It's encouraging to know I'm not the only one with the same ideas ;)

@bartoszkopinski
Copy link
Owner

Thanks @e2. Would be great to see this implemented. The current syntax makes Guardfiles a bit difficult to get right at first sight. The biggest issues for me were having to deal with regexps, code repetition and some implicit behaviour.

It shouldn't be too difficult - the code here is in fact very basic. (Although I'm not sure if it still works!)

@e2
Copy link
Author

e2 commented Jul 29, 2016

At some point I'd like to add this to guard in a way that it can be used as the default:

guard/guard#847

If you happen to create a PR for this sooner, I'll be happy to merge, test and release.

If you prefer, I can add this to the Guard GitHub group of projects and add you there as a maintainer.

(I'd like this to be available by default so that this new syntax can be used in all the examples - and plugins that want to default to this new syntax).

Let me know if you have any conditions/objections and how you'd like to be credited for this.

Thanks!

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

No branches or pull requests

2 participants