質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.50%
Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

Q&A

解決済

3回答

214閲覧

Rubyで作られたツールの設定ファイル内で使われている関数がどこで定義されているか調べる方法

退会済みユーザー

退会済みユーザー

総合スコア0

Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

0グッド

0クリップ

投稿2018/11/26 09:46

guard init livereload

でこんなGuardfileが出てきたんですがwatch関数がどこで定義されているのかわかりません。
調べる方法を教えてください。

ruby

1# A sample Guardfile 2# More info at https://github.com/guard/guard#readme 3 4## Uncomment and set this to only include directories you want to watch 5# directories %w(app lib config test spec features) \ 6# .select{|d| Dir.exist?(d) ? d : UI.warning("Directory #{d} does not exist")} 7 8## Note: if you are using the `directories` clause above and you are not 9## watching the project directory ('.'), then you will want to move 10## the Guardfile to a watched dir and symlink it back, e.g. 11# 12# $ mkdir config 13# $ mv Guardfile config/ 14# $ ln -s config/Guardfile . 15# 16# and, you'll have to watch "config/Guardfile" instead of "Guardfile" 17 18guard 'livereload' do 19 extensions = { 20 css: :css, 21 scss: :css, 22 sass: :css, 23 js: :js, 24 coffee: :js, 25 html: :html, 26 png: :png, 27 gif: :gif, 28 jpg: :jpg, 29 jpeg: :jpeg, 30 # less: :less, # uncomment if you want LESS stylesheets done in browser 31 } 32 33 rails_view_exts = %w(erb haml slim) 34 35 # file types LiveReload may optimize refresh for 36 compiled_exts = extensions.values.uniq 37 watch(%r{public/.+.(#{compiled_exts * '|'})}) 38 39 extensions.each do |ext, type| 40 watch(%r{ 41 (?:app|vendor) 42 (?:/assets/\w+/(?<path>[^.]+) # path+base without extension 43 (?<ext>.#{ext})) # matching extension (must be first encountered) 44 (?:.\w+|$) # other extensions 45 }x) do |m| 46 path = m[1] 47 "/assets/#{path}.#{type}" 48 end 49 end 50 51 # file needing a full reload of the page anyway 52 watch(%r{app/views/.+.(#{rails_view_exts * '|'})$}) 53 watch(%r{app/helpers/.+.rb}) 54 watch(%r{config/locales/.+.yml}) 55end

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答3

0

https://github.com/guard/guard で検索をします。

この場合は "def watch" を ruby ファイル中から検索してみました。

イメージ説明

local マシン上に git clone してきてから、 grep してもよいとおもいます。
ag というコマンドを私はよく使います。
(grep -r だと .git 以下などもヒットしてしまうが、 ag だとそれらは除外される)

https://github.com/ggreer/the_silver_searcher

投稿2018/11/26 14:49

katoy

総合スコア22324

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

0

1.統合開発環境の機能を使う。(関数の宣言個所にジャンプできる機能があれば。)
2.関数名を条件にしてGrepする。(「grepツール おすすめ」でWEB検索)

投稿2018/11/26 10:38

編集2018/11/26 10:39
退会済みユーザー

退会済みユーザー

総合スコア0

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

0

ベストアンサー

どうやって、と言われても適当としか答えられない
ちなみにwatchが定義されているのはここ

lib/guardから適当にそれっぽいファイル(設定ファイル風RubyスクリプトをDSLと呼ぶのでdsl.rb)を探しただけ

投稿2018/11/26 09:54

asm

総合スコア15147

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.50%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問