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

Implemented ReadPointedScalar #111

Merged
merged 2 commits into from Apr 14, 2017
Merged

Conversation

SherifWaly
Copy link
Contributor

PR for #109

@coveralls
Copy link

coveralls commented Apr 13, 2017

Coverage Status

Coverage decreased (-2.006%) to 88.456% when pulling 0277e48 on SherifWaly:#109 into 4b45110 on decorators-squad:master.

@amihaiemil
Copy link
Member

@SherifWaly You did quite a lot of work here :D next time break it down in puzzles, it will also easier for me to review. Plus, in the tasks estimation, you should also calculate the time you spend doing code review changes :)

Copy link
Member

@amihaiemil amihaiemil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SherifWaly I think you misunderstood the requirement (or maybe I got it wrong). The algorithm you wrote seems way too complicated :D

* @return String
*/
public String value() {
StringBuilder builder = new StringBuilder();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SherifWaly are you sure this algorithm is correct? It seems too complicated to me.
The requirement is: newlines are ignored (turned into spaces), unless it is at the end of an empty line, or a more intended line

All that needs to be done is: iterate over the lines and concatenate the ones that are at the same indentation, but with the condition that their numbers are consecutive. So basically, this line number constraint is the only difference from the other wrapped scalar (piped).

With the other lines, which are empty or more indented, you don't have to do anything, their line endings stay the same. And the same indentation lines' numbers have to be consecutive, because you don't want to concatenate lines which have nested nodes/empty lines between them:

>
  Sammy Sosa completed another (0)
  fine season with great stats. (1)
(2)
    63 Home Runs (3)
    0.288 Batting Average (4)
(5)
  What a year! (6)

turns into

>
  Sammy Sosa completed another (0) fine season with great stats. (1)
(2)
    63 Home Runs (3)
    0.288 Batting Average (4)
(5)
  What a year! (6)

You don't concatenate lines 1 and 6 :D

Is this what your algorithm does, or am I missing something?

*/
@Test
@Ignore
public void returnsValueWithSeveralIndentation() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SherifWaly I think this test should pass if the algorithm is correct (see my comment above)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@amihaiemil This test should pass but lines that are indented are dropped by the YamlLines iterator() because they have different indentation from the first line :D .
So I ignored the test only :)
Should we add a decorator class to modify the iterator such that it returns all the line with any indentation?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SherifWaly But why are you interested in the lines that have inner indentation? As I understand, you are not supposed to touch them (they keep their line endings). So it's okay that they are skipped, no? :D

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SherifWaly AAh, you need it only for these test purposes, to see that those lines weren't affected.... well, I would say we can leave it like that for now, maybe add a puzzle :D

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@amihaiemil Yes, I need it for testing :D
As the first case tests pass can I add a puzzle for the decorator class?
For the algorithm I think it works properly as the normal case for concatenation works properly and the second case I add \n at lines 84 to separate from previous lines and other one at line 93 to separate from the next lines.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SherifWaly Yes, add a puzzle for that test case.. but it's not going to be a decorator necessarily (at least, right now I can't imagine how that would work).

If the algorithm works then it's ok, but also add a puzzle for refactoring -- I will take a look later, maybe I can make it shorter :)

@coveralls
Copy link

coveralls commented Apr 14, 2017

Coverage Status

Coverage decreased (-2.006%) to 88.456% when pulling c9a119e on SherifWaly:#109 into 4b45110 on decorators-squad:master.

@amihaiemil
Copy link
Member

@rultor merge

@rultor
Copy link
Collaborator

rultor commented Apr 14, 2017

@rultor merge

@amihaiemil OK, I'll try to merge now. You can check the progress of the merge here

@rultor rultor merged commit c9a119e into decorators-squad:master Apr 14, 2017
@rultor
Copy link
Collaborator

rultor commented Apr 14, 2017

@rultor merge

@amihaiemil Done! FYI, the full log is here (took me 1min)

@SherifWaly SherifWaly deleted the #109 branch April 16, 2017 01:19
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.

None yet

4 participants