Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

introducing bundle grep command #2024

Closed
wants to merge 1 commit into from
Closed

introducing bundle grep command #2024

wants to merge 1 commit into from

Conversation

amatsuda
Copy link
Member

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: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:question:

@travisbot
Copy link

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

@indirect
Copy link
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. :)

@indirect indirect closed this Jan 23, 2013
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants