-
Notifications
You must be signed in to change notification settings - Fork 9
DSL refactor and minor Ruby improvements and fixes #8
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
Conversation
`Param` shouldn’t have to know about subclasses
a7fa860
to
e55bbfe
Compare
@zverok I'm not getting the Rubocop errors that Travis is :-( |
It is the latest Rubocop's newly introduced cops, probably you should update it. |
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.
Thanks for the hard work!
I left a few small comments, but generally it LGTM 👍
examples/demo_base.rb
Outdated
@@ -1,6 +1,6 @@ | |||
require 'pp' | |||
|
|||
$:.unshift 'lib' | |||
$:.unshift '../lib' |
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.
Let's $.LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
or something.
Otherwise, this change will prohibit running ruby examples/example.rb
from TLAW root.
lib/tlaw/dsl/base_wrapper.rb
Outdated
# end | ||
# ``` | ||
# | ||
# See also {#post_process} for some generic explanation of post-processing. |
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.
Please return these docs to dsl.rb
:)
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.
Was a cherry-pick merge issue
lib/tlaw/params.rb
Outdated
@@ -0,0 +1,38 @@ | |||
module TLAW | |||
# TODO: Add docs |
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.
Let's at least add something dummy, like "See Params::Base
for explanations about params." or something?..
end | ||
|
||
private | ||
|
||
def child(symbol, expected_class, **params) | ||
children[symbol] | ||
.tap { |child_class| | ||
.tap do |child_class| |
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.
TBH, I prefer curly braces for "functional" method chains. I will not fight for it furiously, but if it is not a big deal for you,
tap {
...
}.new(...)
...looks more natural for me, even in huge multiline chains.
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.
@zverok I've adopted the do
blocks for multi-line because many other projects have Rubocops that require this style. I've come to prefer it, but will avoid changing them in this project for now :-)
@zverok updates made. That was odd that Rubocop changed defaults. Do you have a way to manage updating gems? Do you just update gems when running tests automatically? |
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.
...on the second thought, I can just do the removal of "description" logic myself. Let's merge 🎉
text | ||
.gsub(/^[ \t]+/, '') | ||
.gsub(/\A\n|\n\s*\Z/, '') | ||
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.
The last thing that I noticed: let's probably remove this logic completely? It just repeats what Ruby 2.3 "squiggly heredoc" do, and as this PR specifies 2.3 as the minimum version, there is no need to replicating language features. One can just
description <<~D
Any description
goes here.
Like a boss!
D
...and be happy.
It is not changed defaults, it is new cops added in new version. Probably tlaw's Gemfile just should specify a particular version of Rubocop, and I should update the version manually from time to time. |
Thank you for the awesome work! |
ok, great! |
@zverok here's the refactored changes without processor/transformation changes as your requested in #7.