aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/evented_file_update_checker.rb
Commit message (Collapse)AuthorAgeFilesLines
* Enable `Layout/EmptyLinesAroundAccessModifier` copRyuta Kamizono2019-06-131-1/+0
| | | | | | | | | | | We sometimes say "✂️ newline after `private`" in a code review (e.g. https://github.com/rails/rails/pull/18546#discussion_r23188776, https://github.com/rails/rails/pull/34832#discussion_r244847195). Now `Layout/EmptyLinesAroundAccessModifier` cop have new enforced style `EnforcedStyle: only_before` (https://github.com/rubocop-hq/rubocop/pull/7059). That cop and enforced style will reduce the our code review cost.
* Don't call listen with empty directory listJohn Hawthorn2019-06-031-1/+4
| | | | | | | Listen interprets an empty list of directories as "watch the current directory". Since EventedFileUpdateChecker doesn't share these semantics, we should not initialize listen if we end up with an empty directory list.
* Merge pull request #36340 from jhawthorn/evented_file_checker_symlinkKasper Timm Hansen2019-05-241-0/+7
|\ | | | | Fix EventedFileUpdateChecker through a symlink
| * Fix EventedFileUpdateChecker through a symlinkJohn Hawthorn2019-05-231-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | On MacOS, Dir.tmpdir gives me a folder inside "/var/folders/". However, /var is a symlink to /private/var. Previously, the nonexistent directory test would fail because it was initialized with /var/folders/... but the filenames from listen would be the realpaths. This commit normalizes the dirs by calling realpath on them if they exist. This is done on boot!, so it will work with newly directories through the symlink.
* | Delete evented_file_update_checker existing_parentJohn Hawthorn2019-05-231-7/+0
|/ | | | This is no longer used as of caa3cc8868206f8109e0d633efb09d31e94ef635
* Match evented checker behavior on dir with no extsJohn Hawthorn2019-03-151-1/+3
| | | | | | | | | | When FileUpdateChecker is passed a directory and given an empty array of extensions to match on, it will match any extension. Previously, EventedFileUpdateChecker would never match any files when given an empty array. This commit makes it EventedFileUpdateChecker match FileUpdateChecker, and watch all extensions when given an empty array.
* Merge pull request #34764 from kamipo/avoid_redundant_beginRyuta Kamizono2018-12-211-5/+3
|\ | | | | Enable `Style/RedundantBegin` cop to avoid newly adding redundant begin block
| * Enable `Style/RedundantBegin` cop to avoid newly adding redundant begin blockRyuta Kamizono2018-12-211-5/+3
| | | | | | | | | | | | | | | | | | | | Currently we sometimes find a redundant begin block in code review (e.g. https://github.com/rails/rails/pull/33604#discussion_r209784205). I'd like to enable `Style/RedundantBegin` cop to avoid that, since rescue/else/ensure are allowed inside do/end blocks in Ruby 2.5 (https://bugs.ruby-lang.org/issues/12906), so we'd probably meets with that situation than before.
* | Do not add parent directory to file system monitoringyuuji.yaginuma2018-12-181-2/+22
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `EventedFileUpdateChecker` will search the parent directory if the specified directory does not exist. Since `test/mailers/previews` is included in the watch target by default, if there is no test directory (e.g. using `rspec`), the Rails root directory will be included in the watch target. ``` $ rails new app $ cd app $ ./bin/rails r "p Rails.application.reloaders.last.send(:directories_to_watch).include?(Rails.root)" false $ rm -rf test $ ./bin/rails r "p Rails.application.reloaders.last.send(:directories_to_watch).include?(Rails.root)" true ``` This causes `node_modules` to be included in watch target. Adding parent directories to watch target may include unexpected directories. In order to avoid this, fixed that parents of nonexistent directories are not added to the watch targets, instead checking that the directory exists when checking changes. Related to #32700. [Matthew Draper & Yuji Yaginuma]
* [Active Support] `rubocop -a --only Layout/EmptyLineAfterMagicComment`Koichi ITO2017-07-111-0/+1
|
* Use frozen-string-literal in ActiveSupportKir Shatrov2017-07-091-0/+1
|
* Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"Matthew Draper2017-07-021-1/+0
| | | | | This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
* Enforce frozen string in RubocopKir Shatrov2017-07-011-0/+1
|
* starts_with? is removed in Ruby 2.4Rafael Mendonça França2017-03-281-1/+1
|
* Merge pull request #1 from radiospiel/tickets/26955-listen-pathsRafael Mendonça França2017-03-281-0/+5
|\ | | | | | | No longer listens to dirs outside of the app directory.
| * No longer listens to dirs inside of installed gemseno2016-11-081-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | rails5 uses the listen gem to watch for changes from autoload directories and from i18n directories. Changes there would be reflected by the running app, in development mode usually. However, files outside of the application directory or locally installed gems should not change during development, and rails does not need to reflect changes there if they do. This change makes sure only those paths that do not originate from the app itself are watched. This can help especially with the situation on OSX, where rb-fsevent - which implements file watching - is quite a resource hog.
* | Raise in the initialize not in the executeRafael Mendonça França2017-01-311-5/+5
| |
* | Merge pull request #27824 from kenta-s/raise-an-error-if-no-block-givenRafael França2017-01-311-1/+5
|\ \ | | | | | | Raise an error if FileUpdateChecker#execute is called with no block
| * | Raise an error if FileUpdateChecker#execute is called with no blockkenta-s2017-01-281-1/+5
| |/
* / Fix broken sample code for EventedFileUpdateChecker [ci skip]kenta-s2017-01-281-1/+1
|/
* normalizes indentation and whitespace across the projectXavier Noria2016-08-061-50/+50
|
* applies new string literal convention in activesupport/libXavier Noria2016-08-061-5/+5
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Lock the whole boot step, get rid of unneeded hashschneems2016-06-131-5/+9
|
* Listen earlier in EventedFileUpdateCheckerschneems2016-06-061-6/+8
| | | | | | Some files like routes.rb may be very large and vary between the initialization of the app and the first request. In these scenarios if we are using a forked process we cannot rely on the files to be unchanged between when the code is booted and the listener is started. For that reason we start a listener on the main process immediately, when we detect that a process does not have a listener started we force the updated state to be true, so we are guaranteed to catch any changes made between the code initialization and the fork.
* [ci skip] document EventedFileUpdateCheckerschneems2016-06-061-0/+28
|
* EventedFileUpdateChecker boots once per processschneems2016-06-061-5/+10
| | | | | | | | | | We need one file checker booted per process as talked about in #24990. Before we do a check to see if any updates have been registered by the listener we first check to make sure that the current process has booted a listener. We are intentionally not starting a listener when the checker is created. This way we can avoid #25259 in which puma warns of multiple threads created before fork. As written the listener for each process will be invoked by the `ActionDispatch::Executor` middleware when the `updated?` method is called. This is the first middleware on the stack and will be invoked before application code is read into memory. The downside of this approach is that the API is a little less obvious. I.e. that you have to call `updated?` to get the listener to start is not intuitive. We could make `boot!` not private if we want to make the API a little nicer. Alternatively we could boot when the checker is initialized however this reintroduces the puma threads warning, and also means that in cases of `rails server` or when using `preload!` that we have extra threads notifying of changes on a process that we don't care about. [close #24990] [close #25259]
* fix boot performance issueAaron Patterson2016-04-221-12/+10
| | | | | Slight refactor to improve boot performance on some Ruby implementations (for now).
* friendly error message if missing listenJerry Cheung2016-03-081-1/+7
|
* Publish AS::Executor and AS::Reloader APIsMatthew Draper2016-03-021-0/+1
| | | | | | These should allow external code to run blocks of user code to do "work", at a similar unit size to a web request, without needing to get intimate with ActionDipatch.
* lazy load listen in coreXavier Noria2015-12-131-1/+4
| | | | See the rationale in the comment present in this patch.
* renames AS::FileEventedUpdateChecker to AS::EventedFileUpdateCheckerXavier Noria2015-12-091-0/+147
Better English.