Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[2.2][Finder] ->pathContains(), ->pathNotContains() methods (with basic tests) #4739

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

Merged
merged 4 commits into from
Oct 30, 2012
Merged

[2.2][Finder] ->pathContains(), ->pathNotContains() methods (with basic tests) #4739

merged 4 commits into from
Oct 30, 2012

Conversation

gajdaw
Copy link
Contributor

@gajdaw gajdaw commented Jul 4, 2012

Bug fix: no
Feature addition: yes
Backwards compatibility break: no
Symfony2 tests pass: Build Status
Fixes the following tickets: #4581
Todo: -
License of the code: MIT
Documentation PR: -

Two additional methods: Finder->path() and Finder->notPath().
They allow filtering with paths, e.g. ->path('some/special/dir').

if ($this->isRegex($str)) {
return $str;
}
return '/' . str_replace('/', '\/', $str) . '/';
Copy link
Member

Choose a reason for hiding this comment

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

You should use preg_quote to escape the string.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@travisbot
Copy link

This pull request fails (merged eddb35cd into b1618d2).

@travisbot
Copy link

This pull request passes (merged a39d8954 into b1618d2).

@travisbot
Copy link

This pull request passes (merged ce439cb3 into 842b599).

*
* @api
*/
public function pathContains($pattern)
Copy link
Member

Choose a reason for hiding this comment

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

What about just path() and notPath() for the method names? contains is used to check the file content, so it seems wrong to reuse the word here. And path() is more consistent with name() as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@fabpot: Done.

@fabpot
Copy link
Member

fabpot commented Sep 21, 2012

Can you submit a PR on symfony/symfony-docs to update the documentation and reference it here before I merge? Thanks.

@gajdaw
Copy link
Contributor Author

gajdaw commented Sep 21, 2012

I've already done it in PR1527.

symfony/symfony-docs#1527

@stof
Copy link
Member

stof commented Sep 21, 2012

Actually, to be BC in PHPUnit when switching to Finder (this feature is the reason why the switch was reverted in 3.7), they will need the support of the glob syntax. Should it be supported directly in the Finder or should we consider that PHPUnit will have to put the code converting globs to regexes themselves before calling the finder ?

@fabpot
Copy link
Member

fabpot commented Sep 23, 2012

@stof what about supporting globs/patterns for the in() method?

@stof
Copy link
Member

stof commented Sep 23, 2012

yeah, this could be a good idea too

@gajdaw
Copy link
Contributor Author

gajdaw commented Sep 26, 2012

Supporting globs in path(), notPath() methods is trivial: we have Glob::toRegex(). The only thing to do is to convert (when necessary) parameter sent to path(), notPath().

@stof
Copy link
Member

stof commented Oct 13, 2012

@gajdaw can you update this PR with the glob support and rebase it ?

@gajdaw gajdaw mentioned this pull request Oct 13, 2012
* @see Symfony\Component\Finder\Iterator\FilenameFilterIterator
*
* @api
*/
Copy link
Member

Choose a reason for hiding this comment

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

The @api tags must be removed.

@fabpot
Copy link
Member

fabpot commented Oct 29, 2012

@gajdaw You also need to rebase and update the new adapters accordingly. Maybe @jfsimon can help.

@jfsimon
Copy link
Contributor

jfsimon commented Oct 29, 2012

With pleasure! @gajdaw let me know if I can do anything.

@gajdaw
Copy link
Contributor Author

gajdaw commented Oct 29, 2012

I have moved ->path() and ->notPath() methods to PhpAdapter.

This implementation passes all the tests on Windows, but Travis reports failures.

I think that similar methods should be implemented for GnuFindAdapter.

@jfsimon What do you think?

@jfsimon
Copy link
Contributor

jfsimon commented Oct 29, 2012

@gajdaw Travis says class 'Symfony\Component\HttpKernel\Exception\InternalServerErrorHttpException' not found in /home/travis/builds/symfony/symfony/src/Symfony/Component/HttpKernel/Tests/Exception/FlattenExceptionTest.php on line 83. This is weird.

And yes, AdapterInterface and GnuFindAdapter should be updated too. I can work on it if you like.

@fabpot
Copy link
Member

fabpot commented Oct 29, 2012

I've just fixed the unit tests

@gajdaw
Copy link
Contributor Author

gajdaw commented Oct 29, 2012

@jfsimon Can implement path(), notPath() for GnuFindAdapter? I have no time to analyse Gnu's find command at the moment. Thanks!

@jfsimon
Copy link
Contributor

jfsimon commented Oct 29, 2012

@gajdaw okay.

@jfsimon
Copy link
Contributor

jfsimon commented Oct 29, 2012

@gajdaw work complete! I cant make a PR on your repos :-/ Could you merge my repos https://github.com/jfsimon/symfony/tree/component_finder_path_notPath please? Or maybe could I post a new PR on symfony/master.

@gajdaw
Copy link
Contributor Author

gajdaw commented Oct 30, 2012

@jfsimon I have pulled your changes. I don't know wheather you should post a new PR.

fabpot added a commit that referenced this pull request Oct 30, 2012
This PR was merged into the master branch.

Commits
-------

4e21bf2 [Finder] Added path & notPath support to gnu find adapter.
6258d12 [Finder] Fixed expression classes.
5c6dbeb [Finder] Fixed tests.
c36dfc1 [Component][Finder] ->path(), ->notPath() methods (with basic tests)

Discussion
----------

[2.2][Finder] ->pathContains(), ->pathNotContains() methods (with basic tests)

Bug fix: no
Feature addition: yes
Backwards compatibility break: no
Symfony2 tests pass: [![Build Status](https://secure.travis-ci.org/gajdaw/symfony.png?branch=component_finder_path_notPath)](http://travis-ci.org/gajdaw/symfony)
Fixes the following tickets: #4581
Todo: -
License of the code: MIT
Documentation PR: -

Two additional methods: `Finder->path()` and `Finder->notPath()`.
They allow filtering with paths, e.g. `->path('some/special/dir')`.

---------------------------------------------------------------------------

by fabpot at 2012-09-21T05:52:01Z

Can you submit a PR on symfony/symfony-docs to update the documentation and reference it here before I merge? Thanks.

---------------------------------------------------------------------------

by gajdaw at 2012-09-21T10:54:50Z

I've already done it in PR1527.

symfony/symfony-docs#1527

---------------------------------------------------------------------------

by stof at 2012-09-21T22:15:46Z

Actually, to be BC in PHPUnit when switching to Finder (this feature is the reason why the switch was reverted in 3.7), they will need the support of the glob syntax. Should it be supported directly in the Finder or should we consider that PHPUnit will have to put the code converting globs to regexes themselves before calling the finder ?

---------------------------------------------------------------------------

by fabpot at 2012-09-23T13:15:08Z

@stof what about supporting globs/patterns for the `in()` method?

---------------------------------------------------------------------------

by stof at 2012-09-23T13:38:00Z

yeah, this could be a good idea too

---------------------------------------------------------------------------

by gajdaw at 2012-09-26T06:11:56Z

Supporting globs in `path(), notPath()` methods is trivial: we have `Glob::toRegex()`. The only thing to do is to convert (when necessary) parameter sent to `path(), notPath()`.

---------------------------------------------------------------------------

by stof at 2012-10-13T17:19:08Z

@gajdaw can you update this PR with the glob support and rebase it ?

---------------------------------------------------------------------------

by fabpot at 2012-10-29T11:20:55Z

@gajdaw You also need to rebase and update the new adapters accordingly. Maybe @jfsimon can help.

---------------------------------------------------------------------------

by jfsimon at 2012-10-29T16:22:25Z

With pleasure! @gajdaw let me know if I can do anything.

---------------------------------------------------------------------------

by gajdaw at 2012-10-29T16:48:10Z

I have moved `->path()` and `->notPath()` methods to `PhpAdapter`.

This implementation passes all the tests on Windows, but Travis reports failures.

I think that similar methods should be implemented for `GnuFindAdapter`.

@jfsimon What do you think?

---------------------------------------------------------------------------

by jfsimon at 2012-10-29T17:03:36Z

@gajdaw Travis says class 'Symfony\Component\HttpKernel\Exception\InternalServerErrorHttpException' not found in /home/travis/builds/symfony/symfony/src/Symfony/Component/HttpKernel/Tests/Exception/FlattenExceptionTest.php on line 83. This is weird.

And yes, `AdapterInterface` and `GnuFindAdapter` should be updated too. I can work on it if you like.

---------------------------------------------------------------------------

by fabpot at 2012-10-29T17:07:46Z

I've just fixed the unit tests

---------------------------------------------------------------------------

by gajdaw at 2012-10-29T17:25:43Z

@jfsimon Can implement `path(), notPath()` for `GnuFindAdapter`? I have no time to analyse Gnu's `find` command at the moment. Thanks!

---------------------------------------------------------------------------

by jfsimon at 2012-10-29T17:30:13Z

@gajdaw okay.

---------------------------------------------------------------------------

by jfsimon at 2012-10-29T19:05:26Z

@gajdaw work complete! I cant make a PR on your repos :-/ Could you merge my repos https://github.com/jfsimon/symfony/tree/component_finder_path_notPath please? Or maybe could I post a new PR on symfony/master.

---------------------------------------------------------------------------

by gajdaw at 2012-10-30T05:34:17Z

@jfsimon I have pulled your changes. I don't know wheather you should post a new PR.
@fabpot fabpot merged commit 4e21bf2 into symfony:master Oct 30, 2012
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.

5 participants