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

introducing `bundle grep` command #2024

Closed
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
3 participants
@amatsuda
Contributor

amatsuda commented Jul 13, 2012

Let me propose a new sub-command, bundle grep.

This is a simple but life changing command that greps the given words within the bundled gem💎 sources.

use case

  • Someone is setting "must-revalidate" to my Rails app's "Cache-Control" response header. But who?
% bundle grep must-revalidate
/Users/a_matsuda/.rvm/gems/ruby-1.9.3-p194/gems/rack-1.4.1/lib/rack/etag.rb:  # defaults to nil, while the second defaults to "max-age=0, private, must-revalidate"
/Users/a_matsuda/.rvm/gems/ruby-1.9.3-p194/gems/rack-1.4.1/lib/rack/etag.rb:    DEFAULT_CACHE_CONTROL = "max-age=0, private, must-revalidate".freeze
/Users/a_matsuda/.rvm/gems/ruby-1.9.3-p194/gems/rack-cache-1.2/lib/rack/cache/cachecontrol.rb:      # of a cache entry on any subsequent use. When the must-revalidate
/Users/a_matsuda/.rvm/gems/ruby-1.9.3-p194/gems/rack-cache-1.2/lib/rack/cache/cachecontrol.rb:      # The must-revalidate directive is necessary to support reliable
/Users/a_matsuda/.rvm/gems/ruby-1.9.3-p194/gems/rack-cache-1.2/lib/rack/cache/cachecontrol.rb:      # HTTP/1.1 cache MUST obey the must-revalidate directive; in
/Users/a_matsuda/.rvm/gems/ruby-1.9.3-p194/gems/rack-cache-1.2/lib/rack/cache/cachecontrol.rb:      # Servers SHOULD send the must-revalidate directive if and only if
/Users/a_matsuda/.rvm/gems/ruby-1.9.3-p194/gems/rack-cache-1.2/lib/rack/cache/cachecontrol.rb:        self['must-revalidate']
/Users/a_matsuda/.rvm/gems/ruby-1.9.3-p194/gems/rack-cache-1.2/lib/rack/cache/context.rb:        # the response; the must-revalidate cache control directive disables
/Users/a_matsuda/.rvm/gems/ruby-1.9.3-p194/gems/rack-cache-1.2/lib/rack/cache/response.rb:    # Valueless parameters (e.g., must-revalidate, no-store) have a Hash value
/Users/a_matsuda/.rvm/gems/ruby-1.9.3-p194/gems/sprockets-2.1.3/lib/sprockets/server.rb:          # Otherwise set `must-revalidate` since the asset could be modified.
/Users/a_matsuda/.rvm/gems/ruby-1.9.3-p194/gems/sprockets-2.1.3/lib/sprockets/server.rb:            headers["Cache-Control"] << ", must-revalidate"
/Users/a_matsuda/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.6/lib/action_dispatch/http/cache.rb:        DEFAULT_CACHE_CONTROL = "max-age=0, private, must-revalidate".freeze
/Users/a_matsuda/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.6/lib/action_dispatch/http/cache.rb:        MUST_REVALIDATE       = "must-revalidate".freeze```
  • Where exactly is link_to_if method defined?
% bundle grep \"def link_to_if\"
/Users/a_matsuda/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.6/lib/action_view/helpers/url_helper.rb:      def link_to_if(condition, name, options = {}, html_options = {}, &block)

OMG this is super useful, isn't it

@travisbot

This comment has been minimized.

Show comment
Hide comment
@travisbot

travisbot Jul 13, 2012

This pull request passes (merged b267b9c into 438ef20).

travisbot commented Jul 13, 2012

This pull request passes (merged b267b9c into 438ef20).

@indirect

This comment has been minimized.

Show comment
Hide comment
@indirect

indirect Jul 13, 2012

Member

Thank you for the patch! There have been several patches in the past to add similar functionality, including both bundle grep and bundle ack. Because we did not want to maintain multiple versions of the same functionality in the core of Bundler, we decided to instead ship a command that could be used with any search utility: bundle show --paths.

I use this command to create a shell alias called back that runs a search against my bundle using ack. The bash function code looks like this:

function () {
  ack "$@" `bundle show --paths`
}

I am currently planning a plugin system for bundler, allowing commands like grep and ack to be provided for anyone who wants it without having to maintain that functionality in the core.

Thank you for the patch, and I hope you can use a shell function as a workaround while we get the plugin system working. :)

Member

indirect commented Jul 13, 2012

Thank you for the patch! There have been several patches in the past to add similar functionality, including both bundle grep and bundle ack. Because we did not want to maintain multiple versions of the same functionality in the core of Bundler, we decided to instead ship a command that could be used with any search utility: bundle show --paths.

I use this command to create a shell alias called back that runs a search against my bundle using ack. The bash function code looks like this:

function () {
  ack "$@" `bundle show --paths`
}

I am currently planning a plugin system for bundler, allowing commands like grep and ack to be provided for anyone who wants it without having to maintain that functionality in the core.

Thank you for the patch, and I hope you can use a shell function as a workaround while we get the plugin system working. :)

@indirect indirect closed this Jan 23, 2013

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