guard 1.2.3 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.md +16 -1
- data/README.md +46 -7
- data/lib/guard.rb +45 -44
- data/lib/guard/cli.rb +15 -9
- data/lib/guard/dsl.rb +16 -9
- data/lib/guard/dsl_describer.rb +12 -13
- data/lib/guard/group.rb +4 -1
- data/lib/guard/guard.rb +4 -1
- data/lib/guard/guardfile.rb +3 -0
- data/lib/guard/hook.rb +3 -1
- data/lib/guard/interactor.rb +15 -11
- data/lib/guard/interactors/coolline.rb +7 -5
- data/lib/guard/interactors/helpers/completion.rb +2 -0
- data/lib/guard/interactors/readline.rb +14 -8
- data/lib/guard/interactors/simple.rb +3 -1
- data/lib/guard/notifier.rb +56 -37
- data/lib/guard/notifiers/emacs.rb +69 -0
- data/lib/guard/notifiers/gntp.rb +2 -1
- data/lib/guard/notifiers/growl.rb +1 -0
- data/lib/guard/notifiers/growl_notify.rb +2 -1
- data/lib/guard/notifiers/libnotify.rb +1 -0
- data/lib/guard/notifiers/notifysend.rb +1 -0
- data/lib/guard/notifiers/rb_notifu.rb +1 -0
- data/lib/guard/notifiers/terminal_notifier.rb +65 -0
- data/lib/guard/runner.rb +14 -10
- data/lib/guard/ui.rb +1 -1
- data/lib/guard/version.rb +1 -1
- data/lib/guard/version.rbc +1 -1
- data/lib/guard/watcher.rb +7 -5
- data/man/guard.1 +2 -2
- data/man/guard.1.html +3 -3
- metadata +5 -3
    
        data/CHANGELOG.md
    CHANGED
    
    | @@ -1,5 +1,15 @@ | |
| 1 1 | 
             
            ## Master
         | 
| 2 2 |  | 
| 3 | 
            +
            ### Bug fix
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            - [#299][] Fix Readline interactor on JRruby. ([@netzpirat][])
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            ### Improvements
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            - Add support for OS X notification center ([@foxycoder][])
         | 
| 10 | 
            +
            - Add support for Emacs notifications ([@maio][])
         | 
| 11 | 
            +
            - Add support for multiple guards being passed to `guard init`. ([@jredville][])
         | 
| 12 | 
            +
             | 
| 3 13 | 
             
            ### 1.2.1 - 2 Juli, 2012
         | 
| 4 14 |  | 
| 5 15 | 
             
            ### Bug fix
         | 
| @@ -561,6 +571,8 @@ The Listen integration has been supervised by [@thibaudgg][] and executed by [@M | |
| 561 571 | 
             
            [#274]: https://github.com/guard/guard/issues/274
         | 
| 562 572 | 
             
            [#275]: https://github.com/guard/guard/issues/275
         | 
| 563 573 | 
             
            [#283]: https://github.com/guard/guard/issues/283
         | 
| 574 | 
            +
            [#298]: https://github.com/guard/guard/issues/298
         | 
| 575 | 
            +
            [#299]: https://github.com/guard/guard/issues/299
         | 
| 564 576 | 
             
            [@Gazer]: https://github.com/Gazer
         | 
| 565 577 | 
             
            [@Maher4Ever]: https://github.com/Maher4Ever
         | 
| 566 578 | 
             
            [@alandipert]: https://github.com/alandipert
         | 
| @@ -581,6 +593,7 @@ The Listen integration has been supervised by [@thibaudgg][] and executed by [@M | |
| 581 593 | 
             
            [@f1sherman]: https://github.com/f1sherman
         | 
| 582 594 | 
             
            [@fabioyamate]: https://github.com/fabioyamate
         | 
| 583 595 | 
             
            [@fnichol]: https://github.com/fnichol
         | 
| 596 | 
            +
            [@foxycoder]: https://github.com/foxycoder
         | 
| 584 597 | 
             
            [@gix]: https://github.com/gix
         | 
| 585 598 | 
             
            [@hardipe]: https://github.com/hardipe
         | 
| 586 599 | 
             
            [@hashrocketeer]: https://github.com/hashrocketeer
         | 
| @@ -590,11 +603,13 @@ The Listen integration has been supervised by [@thibaudgg][] and executed by [@M | |
| 590 603 | 
             
            [@indirect]: https://github.com/indirect
         | 
| 591 604 | 
             
            [@jeffutter]: https://github.com/jeffutter
         | 
| 592 605 | 
             
            [@johnbintz]: https://github.com/johnbintz
         | 
| 606 | 
            +
            [@jredville]: https://github.com/jredville
         | 
| 593 607 | 
             
            [@jrsacks]: https://github.com/jrsacks
         | 
| 594 608 | 
             
            [@koshigoe]: https://github.com/koshigoe
         | 
| 595 609 | 
             
            [@laserlemon]: https://github.com/laserlemon
         | 
| 596 610 | 
             
            [@limeyd]: https://github.com/limeyd
         | 
| 597 611 | 
             
            [@madtrick]: https://github.com/madtrick
         | 
| 612 | 
            +
            [@maio]: https://github.com/maio
         | 
| 598 613 | 
             
            [@mcmire]: https://github.com/mcmire
         | 
| 599 614 | 
             
            [@mislav]: https://github.com/mislav
         | 
| 600 615 | 
             
            [@monocle]: https://github.com/monocle
         | 
| @@ -629,4 +644,4 @@ The Listen integration has been supervised by [@thibaudgg][] and executed by [@M | |
| 629 644 | 
             
            [@waldo]: https://github.com/waldo
         | 
| 630 645 | 
             
            [@wereHamster]: https://github.com/wereHamster
         | 
| 631 646 | 
             
            [@yannlugrin]: https://github.com/yannlugrin
         | 
| 632 | 
            -
            [@zonque]: https://github.com/zonque
         | 
| 647 | 
            +
            [@zonque]: https://github.com/zonque
         | 
    
        data/README.md
    CHANGED
    
    | @@ -171,6 +171,26 @@ group :development do | |
| 171 171 | 
             
            end
         | 
| 172 172 | 
             
            ```
         | 
| 173 173 |  | 
| 174 | 
            +
            #### Emacs
         | 
| 175 | 
            +
             | 
| 176 | 
            +
            * Runs on any platform with Emacs + emacsclient (http://www.emacswiki.org/emacs/EmacsClient)
         | 
| 177 | 
            +
             | 
| 178 | 
            +
            #### Terminal Notifier
         | 
| 179 | 
            +
             | 
| 180 | 
            +
            * Runs on Mac OS X 10.8 only
         | 
| 181 | 
            +
             | 
| 182 | 
            +
            The [terminal notifier](https://github.com/alloy/terminal-notifier) sends notifications to the OS X Notification Center.
         | 
| 183 | 
            +
            The notification center doesn't support different icons for different message types, and it even shows only the icon
         | 
| 184 | 
            +
            from Terminal.app.
         | 
| 185 | 
            +
             | 
| 186 | 
            +
            To use `terminal_notifier` you have to add it to your `Gemfile` and run bundler:
         | 
| 187 | 
            +
             | 
| 188 | 
            +
            ```ruby
         | 
| 189 | 
            +
            group :development do
         | 
| 190 | 
            +
              gem 'terminal_notifier'
         | 
| 191 | 
            +
            end
         | 
| 192 | 
            +
            ```
         | 
| 193 | 
            +
             | 
| 174 194 | 
             
            Add Guard plugins
         | 
| 175 195 | 
             
            -----------------
         | 
| 176 196 |  | 
| @@ -225,6 +245,13 @@ in the generated Guardfile: | |
| 225 245 | 
             
            $ guard init <guard-name>
         | 
| 226 246 | 
             
            ```
         | 
| 227 247 |  | 
| 248 | 
            +
            You can also specify the names of multiple plugins to only get those plugin templates
         | 
| 249 | 
            +
            in the generated Guardfile:
         | 
| 250 | 
            +
             | 
| 251 | 
            +
            ```bash
         | 
| 252 | 
            +
            $ guard init <guard1-name> <guard2-name>
         | 
| 253 | 
            +
            ```
         | 
| 254 | 
            +
             | 
| 228 255 | 
             
            You can also define your own templates in `~/.guard/templates/` which can be appended in the same way to your existing
         | 
| 229 256 | 
             
            `Guardfile`:
         | 
| 230 257 |  | 
| @@ -399,7 +426,7 @@ You can interact with Guard and enter commands when Guard has nothing to do. Gua | |
| 399 426 | 
             
            * `↩`:                 Run all plugins.
         | 
| 400 427 | 
             
            * `h`, `help`:         Show a help of the available interactor commands.
         | 
| 401 428 | 
             
            * `r`, `reload`:       Reload all plugins.
         | 
| 402 | 
            -
            * `c`, `change`:        | 
| 429 | 
            +
            * `c`, `change`:       Trigger a file change to the plugins.
         | 
| 403 430 | 
             
            * `s`, `show`:         Show the plugin configurations.
         | 
| 404 431 | 
             
            * `n`, `notification`: Toggle system notifications on and off.
         | 
| 405 432 | 
             
            * `p`, `pause`:        Toggles the file modification listener. The prompt will change to `p>` when paused.
         | 
| @@ -473,7 +500,7 @@ Guard will automatically enable Coolline support if your environment supports it | |
| 473 500 |  | 
| 474 501 | 
             
            ### Signals
         | 
| 475 502 |  | 
| 476 | 
            -
            You can also interact with Guard by sending POSIX signals to the Guard process (all but Windows).
         | 
| 503 | 
            +
            You can also interact with Guard by sending POSIX signals to the Guard process (all but Windows and JRuby).
         | 
| 477 504 |  | 
| 478 505 | 
             
            #### Pause watching
         | 
| 479 506 |  | 
| @@ -605,6 +632,7 @@ notification :gntp, :sticky => true, :host => '192.168.1.5', :password => 'secre | |
| 605 632 | 
             
            notification :growl_notify, :sticky => true, :priority => 0
         | 
| 606 633 | 
             
            notification :libnotify, :timeout => 5, :transient => true, :append => false, :urgency => :critical
         | 
| 607 634 | 
             
            notification :notifu, :time => 5, :nosound => true, :xp => true
         | 
| 635 | 
            +
            notification :emacs
         | 
| 608 636 | 
             
            ```
         | 
| 609 637 |  | 
| 610 638 | 
             
            It's possible to use more than one notifier. This allows you to configure different notifiers for different OS if your
         | 
| @@ -652,9 +680,16 @@ more details. | |
| 652 680 |  | 
| 653 681 | 
             
            ### ignore
         | 
| 654 682 |  | 
| 655 | 
            -
            The `ignore` method  | 
| 656 | 
            -
             | 
| 657 | 
            -
             | 
| 683 | 
            +
            The `ignore` method can be used to exclude files and directories from the set of files being watched. Let's say you have
         | 
| 684 | 
            +
            used the `watch` method to monitor a directory, but you are not interested in changes happening to images, you could use
         | 
| 685 | 
            +
            the ignore method to exclude them.
         | 
| 686 | 
            +
             | 
| 687 | 
            +
            This comes in handy when you have large amounts of non-source data in you project. By default
         | 
| 688 | 
            +
            [`.rbx`, `.bundle`, `.git`, `.svn`, `log`, `tmp`, `vendor`](https://github.com/guard/listen/blob/master/lib/listen/directory_record.rb#L14)
         | 
| 689 | 
            +
            are ignored.
         | 
| 690 | 
            +
             | 
| 691 | 
            +
            Please note that method only accept regexps. More on the
         | 
| 692 | 
            +
            [Listen README](https://github.com/guard/listen#the-patterns-for-filtering-and-ignoring-paths).
         | 
| 658 693 |  | 
| 659 694 | 
             
            ```ruby
         | 
| 660 695 | 
             
            ignore %r{^ignored/path/}, /public/
         | 
| @@ -662,8 +697,12 @@ ignore %r{^ignored/path/}, /public/ | |
| 662 697 |  | 
| 663 698 | 
             
            ### filter
         | 
| 664 699 |  | 
| 665 | 
            -
            The `filter` method allows you to  | 
| 666 | 
            -
             | 
| 700 | 
            +
            The `filter` method allows you to focus by filtering files and directories without having to specify them by hand in the
         | 
| 701 | 
            +
            `watch` method. E.g. if you are watching multiple directories but only interested in changes to the Ruby files, then use
         | 
| 702 | 
            +
            the `filter` method.
         | 
| 703 | 
            +
             | 
| 704 | 
            +
            Please note that method only accept regexps. More on the
         | 
| 705 | 
            +
            [Listen README](https://github.com/guard/listen#the-patterns-for-filtering-and-ignoring-paths).
         | 
| 667 706 |  | 
| 668 707 | 
             
            ```ruby
         | 
| 669 708 | 
             
            filter /\.txt$/, /.*\.zip/
         | 
    
        data/lib/guard.rb
    CHANGED
    
    | @@ -6,19 +6,18 @@ require 'listen' | |
| 6 6 | 
             
            #
         | 
| 7 7 | 
             
            module Guard
         | 
| 8 8 |  | 
| 9 | 
            -
               | 
| 10 | 
            -
               | 
| 11 | 
            -
               | 
| 12 | 
            -
               | 
| 13 | 
            -
               | 
| 14 | 
            -
               | 
| 15 | 
            -
               | 
| 16 | 
            -
               | 
| 17 | 
            -
              autoload :Runner,       'guard/runner'
         | 
| 18 | 
            -
              autoload :Hook,         'guard/hook'
         | 
| 9 | 
            +
              require 'guard/dsl'
         | 
| 10 | 
            +
              require 'guard/guardfile'
         | 
| 11 | 
            +
              require 'guard/group'
         | 
| 12 | 
            +
              require 'guard/interactor'
         | 
| 13 | 
            +
              require 'guard/notifier'
         | 
| 14 | 
            +
              require 'guard/runner'
         | 
| 15 | 
            +
              require 'guard/ui'
         | 
| 16 | 
            +
              require 'guard/watcher'
         | 
| 19 17 |  | 
| 20 18 | 
             
              # The Guardfile template for `guard init`
         | 
| 21 19 | 
             
              GUARDFILE_TEMPLATE = File.expand_path('../guard/templates/Guardfile', __FILE__)
         | 
| 20 | 
            +
             | 
| 22 21 | 
             
              # The location of user defined templates
         | 
| 23 22 | 
             
              HOME_TEMPLATES = File.expand_path('~/.guard/templates')
         | 
| 24 23 |  | 
| @@ -44,10 +43,10 @@ module Guard | |
| 44 43 | 
             
                  @lock       = Mutex.new
         | 
| 45 44 | 
             
                  @options    = options
         | 
| 46 45 | 
             
                  @watchdir   = (options[:watchdir] && File.expand_path(options[:watchdir])) || Dir.pwd
         | 
| 47 | 
            -
                  @runner     = Runner.new
         | 
| 46 | 
            +
                  @runner     = ::Guard::Runner.new
         | 
| 48 47 | 
             
                  @allow_stop = Listen::Turnstile.new
         | 
| 49 48 |  | 
| 50 | 
            -
                  UI.clear
         | 
| 49 | 
            +
                  ::Guard::UI.clear
         | 
| 51 50 | 
             
                  deprecated_options_warning
         | 
| 52 51 |  | 
| 53 52 | 
             
                  setup_groups
         | 
| @@ -57,8 +56,8 @@ module Guard | |
| 57 56 |  | 
| 58 57 | 
             
                  debug_command_execution if @options[:debug]
         | 
| 59 58 |  | 
| 60 | 
            -
                  Dsl.evaluate_guardfile(options)
         | 
| 61 | 
            -
                  UI.error 'No guards found in Guardfile, please add at least one.' if @guards.empty?
         | 
| 59 | 
            +
                  ::Guard::Dsl.evaluate_guardfile(options)
         | 
| 60 | 
            +
                  ::Guard::UI.error 'No guards found in Guardfile, please add at least one.' if @guards.empty?
         | 
| 62 61 |  | 
| 63 62 | 
             
                  runner.deprecation_warning if @options[:show_deprecations]
         | 
| 64 63 |  | 
| @@ -84,19 +83,21 @@ module Guard | |
| 84 83 | 
             
                  @guards = []
         | 
| 85 84 | 
             
                end
         | 
| 86 85 |  | 
| 87 | 
            -
                # Sets up traps to catch  | 
| 86 | 
            +
                # Sets up traps to catch signals used to control Guard.
         | 
| 88 87 | 
             
                #
         | 
| 89 | 
            -
                # Currently two signals are  | 
| 88 | 
            +
                # Currently two signals are caught:
         | 
| 90 89 | 
             
                # - `USR1` which pauses listening to changes.
         | 
| 91 90 | 
             
                # - `USR2` which resumes listening to changes.
         | 
| 92 91 | 
             
                #
         | 
| 93 92 | 
             
                def setup_signal_traps
         | 
| 94 | 
            -
                   | 
| 95 | 
            -
                    Signal. | 
| 96 | 
            -
             | 
| 97 | 
            -
             | 
| 98 | 
            -
             | 
| 99 | 
            -
                    Signal. | 
| 93 | 
            +
                  unless defined?(JRUBY_VERSION)
         | 
| 94 | 
            +
                    if Signal.list.keys.include?('USR1')
         | 
| 95 | 
            +
                      Signal.trap('USR1') { ::Guard.pause unless @listener.paused? }
         | 
| 96 | 
            +
                    end
         | 
| 97 | 
            +
              
         | 
| 98 | 
            +
                    if Signal.list.keys.include?('USR2')
         | 
| 99 | 
            +
                      Signal.trap('USR2') { ::Guard.pause if @listener.paused? }
         | 
| 100 | 
            +
                    end
         | 
| 100 101 | 
             
                  end
         | 
| 101 102 | 
             
                end
         | 
| 102 103 |  | 
| @@ -104,7 +105,7 @@ module Guard | |
| 104 105 | 
             
                #
         | 
| 105 106 | 
             
                def setup_listener
         | 
| 106 107 | 
             
                  listener_callback = lambda do |modified, added, removed|
         | 
| 107 | 
            -
                    Dsl.reevaluate_guardfile if Watcher.match_guardfile?(modified)
         | 
| 108 | 
            +
                    ::Guard::Dsl.reevaluate_guardfile if ::Guard::Watcher.match_guardfile?(modified)
         | 
| 108 109 |  | 
| 109 110 | 
             
                    ::Guard.within_preserved_state do
         | 
| 110 111 | 
             
                      runner.run_on_changes(modified, added, removed)
         | 
| @@ -122,19 +123,19 @@ module Guard | |
| 122 123 | 
             
                # Enables or disables the notifier based on user's configurations.
         | 
| 123 124 | 
             
                #
         | 
| 124 125 | 
             
                def setup_notifier
         | 
| 125 | 
            -
                  options[:notify] && ENV['GUARD_NOTIFY'] != 'false' ? Notifier.turn_on : Notifier.turn_off
         | 
| 126 | 
            +
                  options[:notify] && ENV['GUARD_NOTIFY'] != 'false' ? ::Guard::Notifier.turn_on : ::Guard::Notifier.turn_off
         | 
| 126 127 | 
             
                end
         | 
| 127 128 |  | 
| 128 129 | 
             
                # Initializes the interactor unless the user has specified not to.
         | 
| 129 130 | 
             
                #
         | 
| 130 131 | 
             
                def setup_interactor
         | 
| 131 132 | 
             
                  unless options[:no_interactions]
         | 
| 132 | 
            -
                    @interactor = Interactor.fabricate
         | 
| 133 | 
            +
                    @interactor = ::Guard::Interactor.fabricate
         | 
| 133 134 | 
             
                  end
         | 
| 134 135 | 
             
                end
         | 
| 135 136 |  | 
| 136 | 
            -
                # Start Guard by  | 
| 137 | 
            -
                # and  | 
| 137 | 
            +
                # Start Guard by evaluating the `Guardfile`, initializing declared Guard plugins
         | 
| 138 | 
            +
                # and starting the available file change listener.
         | 
| 138 139 | 
             
                # Main method for Guard that is called from the CLI when Guard starts.
         | 
| 139 140 | 
             
                #
         | 
| 140 141 | 
             
                # - Setup Guard internals
         | 
| @@ -152,7 +153,7 @@ module Guard | |
| 152 153 | 
             
                #
         | 
| 153 154 | 
             
                def start(options = {})
         | 
| 154 155 | 
             
                  setup(options)
         | 
| 155 | 
            -
                  UI.info "Guard is now watching at '#{ @watchdir }'"
         | 
| 156 | 
            +
                  ::Guard::UI.info "Guard is now watching at '#{ @watchdir }'"
         | 
| 156 157 |  | 
| 157 158 | 
             
                  within_preserved_state do
         | 
| 158 159 | 
             
                    runner.run(:start)
         | 
| @@ -169,32 +170,32 @@ module Guard | |
| 169 170 | 
             
                  listener.stop
         | 
| 170 171 | 
             
                  interactor.stop if interactor
         | 
| 171 172 | 
             
                  runner.run(:stop)
         | 
| 172 | 
            -
                  UI.info 'Bye bye...', :reset => true
         | 
| 173 | 
            +
                  ::Guard::UI.info 'Bye bye...', :reset => true
         | 
| 173 174 |  | 
| 174 175 | 
             
                  @allow_stop.signal if @allow_stop
         | 
| 175 176 | 
             
                end
         | 
| 176 177 |  | 
| 177 178 | 
             
                # Reload Guardfile and all Guard plugins currently enabled.
         | 
| 178 179 | 
             
                #
         | 
| 179 | 
            -
                # @param [Hash] scopes  | 
| 180 | 
            +
                # @param [Hash] scopes hash with a Guard plugin or a group scope
         | 
| 180 181 | 
             
                #
         | 
| 181 182 | 
             
                def reload(scopes)
         | 
| 182 183 | 
             
                  within_preserved_state do
         | 
| 183 | 
            -
                    UI.clear
         | 
| 184 | 
            -
                    UI.action_with_scopes('Reload', scopes)
         | 
| 185 | 
            -
                    Dsl.reevaluate_guardfile if scopes.empty?
         | 
| 184 | 
            +
                    ::Guard::UI.clear
         | 
| 185 | 
            +
                    ::Guard::UI.action_with_scopes('Reload', scopes)
         | 
| 186 | 
            +
                    ::Guard::Dsl.reevaluate_guardfile if scopes.empty?
         | 
| 186 187 | 
             
                    runner.run(:reload, scopes)
         | 
| 187 188 | 
             
                  end
         | 
| 188 189 | 
             
                end
         | 
| 189 190 |  | 
| 190 191 | 
             
                # Trigger `run_all` on all Guard plugins currently enabled.
         | 
| 191 192 | 
             
                #
         | 
| 192 | 
            -
                # @param [Hash] scopes  | 
| 193 | 
            +
                # @param [Hash] scopes hash with a Guard plugin or a group scope
         | 
| 193 194 | 
             
                #
         | 
| 194 195 | 
             
                def run_all(scopes)
         | 
| 195 196 | 
             
                  within_preserved_state do
         | 
| 196 | 
            -
                    UI.clear
         | 
| 197 | 
            -
                    UI.action_with_scopes('Run', scopes)
         | 
| 197 | 
            +
                    ::Guard::UI.clear
         | 
| 198 | 
            +
                    ::Guard::UI.action_with_scopes('Run', scopes)
         | 
| 198 199 | 
             
                    runner.run(:run_all, scopes)
         | 
| 199 200 | 
             
                  end
         | 
| 200 201 | 
             
                end
         | 
| @@ -203,10 +204,10 @@ module Guard | |
| 203 204 | 
             
                #
         | 
| 204 205 | 
             
                def pause
         | 
| 205 206 | 
             
                  if listener.paused?
         | 
| 206 | 
            -
                    UI.info 'Un-paused files modification listening', :reset => true
         | 
| 207 | 
            +
                    ::Guard::UI.info 'Un-paused files modification listening', :reset => true
         | 
| 207 208 | 
             
                    listener.unpause
         | 
| 208 209 | 
             
                  else
         | 
| 209 | 
            -
                    UI.info 'Paused files modification listening', :reset => true
         | 
| 210 | 
            +
                    ::Guard::UI.info 'Paused files modification listening', :reset => true
         | 
| 210 211 | 
             
                    listener.pause
         | 
| 211 212 | 
             
                  end
         | 
| 212 213 | 
             
                end
         | 
| @@ -284,7 +285,7 @@ module Guard | |
| 284 285 | 
             
                #
         | 
| 285 286 | 
             
                def add_guard(name, watchers = [], callbacks = [], options = {})
         | 
| 286 287 | 
             
                  if name.to_sym == :ego
         | 
| 287 | 
            -
                    UI.deprecation('Guard::Ego is now part of Guard. You can remove it from your Guardfile.')
         | 
| 288 | 
            +
                    ::Guard::UI.deprecation('Guard::Ego is now part of Guard. You can remove it from your Guardfile.')
         | 
| 288 289 | 
             
                  else
         | 
| 289 290 | 
             
                    guard_class = get_guard_class(name)
         | 
| 290 291 | 
             
                    callbacks.each { |callback| Hook.add_callback(callback[:listener], guard_class, callback[:events]) }
         | 
| @@ -304,7 +305,7 @@ module Guard | |
| 304 305 | 
             
                def add_group(name, options = {})
         | 
| 305 306 | 
             
                  group = groups(name)
         | 
| 306 307 | 
             
                  if group.nil?
         | 
| 307 | 
            -
                    group = Group.new(name, options)
         | 
| 308 | 
            +
                    group = ::Guard::Group.new(name, options)
         | 
| 308 309 | 
             
                    @groups << group
         | 
| 309 310 | 
             
                  end
         | 
| 310 311 | 
             
                  group
         | 
| @@ -357,12 +358,12 @@ module Guard | |
| 357 358 | 
             
                      try_require = true
         | 
| 358 359 | 
             
                      retry
         | 
| 359 360 | 
             
                    else
         | 
| 360 | 
            -
                      UI.error "Could not find class Guard::#{ const_name.capitalize }"
         | 
| 361 | 
            +
                      ::Guard::UI.error "Could not find class Guard::#{ const_name.capitalize }"
         | 
| 361 362 | 
             
                    end
         | 
| 362 363 | 
             
                  rescue LoadError => loadError
         | 
| 363 364 | 
             
                    unless fail_gracefully
         | 
| 364 | 
            -
                      UI.error "Could not load 'guard/#{ name.downcase }' or find class Guard::#{ const_name.capitalize }"
         | 
| 365 | 
            -
                      UI.error loadError.to_s
         | 
| 365 | 
            +
                      ::Guard::UI.error "Could not load 'guard/#{ name.downcase }' or find class Guard::#{ const_name.capitalize }"
         | 
| 366 | 
            +
                      ::Guard::UI.error loadError.to_s
         | 
| 366 367 | 
             
                    end
         | 
| 367 368 | 
             
                  end
         | 
| 368 369 | 
             
                end
         | 
| @@ -379,7 +380,7 @@ module Guard | |
| 379 380 | 
             
                    Gem.source_index.find_name("guard-#{ name }").last.full_gem_path
         | 
| 380 381 | 
             
                  end
         | 
| 381 382 | 
             
                rescue
         | 
| 382 | 
            -
                  UI.error "Could not find 'guard-#{ name }' gem path."
         | 
| 383 | 
            +
                  ::Guard::UI.error "Could not find 'guard-#{ name }' gem path."
         | 
| 383 384 | 
             
                end
         | 
| 384 385 |  | 
| 385 386 | 
             
                # Returns a list of Guard plugin Gem names installed locally.
         | 
    
        data/lib/guard/cli.rb
    CHANGED
    
    | @@ -1,5 +1,4 @@ | |
| 1 1 | 
             
            require 'thor'
         | 
| 2 | 
            -
            require 'guard/version'
         | 
| 3 2 |  | 
| 4 3 | 
             
            module Guard
         | 
| 5 4 |  | 
| @@ -9,6 +8,11 @@ module Guard | |
| 9 8 | 
             
              #
         | 
| 10 9 | 
             
              class CLI < Thor
         | 
| 11 10 |  | 
| 11 | 
            +
                require 'guard'
         | 
| 12 | 
            +
                require 'guard/version'
         | 
| 13 | 
            +
                require 'guard/dsl_describer'
         | 
| 14 | 
            +
                require 'guard/guardfile'
         | 
| 15 | 
            +
             | 
| 12 16 | 
             
                default_task :start
         | 
| 13 17 |  | 
| 14 18 | 
             
                desc 'start', 'Starts Guard'
         | 
| @@ -90,7 +94,7 @@ module Guard | |
| 90 94 | 
             
                              :aliases => '-p',
         | 
| 91 95 | 
             
                              :banner  => 'Force usage of the Listen polling listener'
         | 
| 92 96 |  | 
| 93 | 
            -
                # Start Guard by  | 
| 97 | 
            +
                # Start Guard by initializing the defined Guard plugins and watch the file system.
         | 
| 94 98 | 
             
                # This is the default task, so calling `guard` is the same as calling `guard start`.
         | 
| 95 99 | 
             
                #
         | 
| 96 100 | 
             
                # @see Guard.start
         | 
| @@ -127,7 +131,7 @@ module Guard | |
| 127 131 | 
             
                  ::Guard::UI.info "Guard version #{ ::Guard::VERSION }"
         | 
| 128 132 | 
             
                end
         | 
| 129 133 |  | 
| 130 | 
            -
                desc 'init [ | 
| 134 | 
            +
                desc 'init [GUARDS]', 'Generates a Guardfile at the current directory (if it is not already there) and adds all installed guards or the given GUARDS into it'
         | 
| 131 135 |  | 
| 132 136 | 
             
                method_option :bare,
         | 
| 133 137 | 
             
                              :type => :boolean,
         | 
| @@ -135,26 +139,28 @@ module Guard | |
| 135 139 | 
             
                              :aliases => '-b',
         | 
| 136 140 | 
             
                              :banner => 'Generate a bare Guardfile without adding any installed guard into it'
         | 
| 137 141 |  | 
| 138 | 
            -
                # Initializes the templates of all installed Guard  | 
| 142 | 
            +
                # Initializes the templates of all installed Guard plugins and adds them
         | 
| 139 143 | 
             
                # to the `Guardfile` when no Guard name is passed. When passing
         | 
| 140 | 
            -
                #  | 
| 144 | 
            +
                # Guard plugin names it does the same but only for those Guard plugins.
         | 
| 141 145 | 
             
                #
         | 
| 142 146 | 
             
                # @see Guard::Guard.initialize_template
         | 
| 143 147 | 
             
                # @see Guard::Guard.initialize_all_templates
         | 
| 144 148 | 
             
                #
         | 
| 145 | 
            -
                # @param [String]  | 
| 149 | 
            +
                # @param [Array<String>] guard_names the name of the Guard plugins to initialize
         | 
| 146 150 | 
             
                #
         | 
| 147 | 
            -
                def init( | 
| 151 | 
            +
                def init(*guard_names)
         | 
| 148 152 | 
             
                  verify_bundler_presence
         | 
| 149 153 |  | 
| 150 154 | 
             
                  ::Guard::Guardfile.create_guardfile(:abort_on_existence => options[:bare])
         | 
| 151 155 |  | 
| 152 156 | 
             
                  return if options[:bare]
         | 
| 153 157 |  | 
| 154 | 
            -
                  if  | 
| 158 | 
            +
                  if guard_names.empty?
         | 
| 155 159 | 
             
                    ::Guard::Guardfile::initialize_all_templates
         | 
| 156 160 | 
             
                  else
         | 
| 157 | 
            -
                     | 
| 161 | 
            +
                    guard_names.each do |guard_name|
         | 
| 162 | 
            +
                      ::Guard::Guardfile.initialize_template(guard_name)
         | 
| 163 | 
            +
                    end
         | 
| 158 164 | 
             
                  end
         | 
| 159 165 | 
             
                end
         | 
| 160 166 |  | 
    
        data/lib/guard/dsl.rb
    CHANGED
    
    | @@ -84,6 +84,13 @@ module Guard | |
| 84 84 | 
             
              #
         | 
| 85 85 | 
             
              class Dsl
         | 
| 86 86 |  | 
| 87 | 
            +
                require 'guard'
         | 
| 88 | 
            +
                require 'guard/dsl'
         | 
| 89 | 
            +
                require 'guard/interactor'
         | 
| 90 | 
            +
                require 'guard/notifier'
         | 
| 91 | 
            +
                require 'guard/ui'
         | 
| 92 | 
            +
                require 'guard/watcher'
         | 
| 93 | 
            +
             | 
| 87 94 | 
             
                # Deprecation message for the `ignore_paths` method
         | 
| 88 95 | 
             
                IGNORE_PATHS_DEPRECATION = <<-EOS.gsub(/^\s*/, '')
         | 
| 89 96 | 
             
                  Starting with Guard v1.1 the use of the 'ignore_paths' Guardfile dsl method is deprecated.
         | 
| @@ -116,7 +123,7 @@ module Guard | |
| 116 123 | 
             
                  #
         | 
| 117 124 | 
             
                  def reevaluate_guardfile
         | 
| 118 125 | 
             
                    before_reevaluate_guardfile
         | 
| 119 | 
            -
                    Dsl.evaluate_guardfile(@@options)
         | 
| 126 | 
            +
                    ::Guard::Dsl.evaluate_guardfile(@@options)
         | 
| 120 127 | 
             
                    after_reevaluate_guardfile
         | 
| 121 128 | 
             
                  end
         | 
| 122 129 |  | 
| @@ -156,7 +163,7 @@ module Guard | |
| 156 163 | 
             
                  def instance_eval_guardfile(contents)
         | 
| 157 164 | 
             
                    new.instance_eval(contents, @@options[:guardfile_path], 1)
         | 
| 158 165 | 
             
                  rescue
         | 
| 159 | 
            -
                    UI.error "Invalid Guardfile, original error is:\n#{ $! }"
         | 
| 166 | 
            +
                    ::Guard::UI.error "Invalid Guardfile, original error is:\n#{ $! }"
         | 
| 160 167 | 
             
                  end
         | 
| 161 168 |  | 
| 162 169 | 
             
                  # Test if the current `Guardfile` contains a specific Guard plugin.
         | 
| @@ -176,7 +183,7 @@ module Guard | |
| 176 183 | 
             
                    @@options[:guardfile_path]     = guardfile_path
         | 
| 177 184 | 
             
                    @@options[:guardfile_contents] = File.read(guardfile_path)
         | 
| 178 185 | 
             
                  rescue
         | 
| 179 | 
            -
                    UI.error("Error reading file #{ guardfile_path }")
         | 
| 186 | 
            +
                    ::Guard::UI.error("Error reading file #{ guardfile_path }")
         | 
| 180 187 | 
             
                    exit 1
         | 
| 181 188 | 
             
                  end
         | 
| 182 189 |  | 
| @@ -185,15 +192,15 @@ module Guard | |
| 185 192 | 
             
                  #
         | 
| 186 193 | 
             
                  def fetch_guardfile_contents
         | 
| 187 194 | 
             
                    if @@options[:guardfile_contents]
         | 
| 188 | 
            -
                      UI.info 'Using inline Guardfile.'
         | 
| 195 | 
            +
                      ::Guard::UI.info 'Using inline Guardfile.'
         | 
| 189 196 | 
             
                      @@options[:guardfile_path] = 'Inline Guardfile'
         | 
| 190 197 |  | 
| 191 198 | 
             
                    elsif @@options[:guardfile]
         | 
| 192 199 | 
             
                      if File.exist?(@@options[:guardfile])
         | 
| 193 200 | 
             
                        read_guardfile(@@options[:guardfile])
         | 
| 194 | 
            -
                        UI.info "Using Guardfile at #{ @@options[:guardfile] }."
         | 
| 201 | 
            +
                        ::Guard::UI.info "Using Guardfile at #{ @@options[:guardfile] }."
         | 
| 195 202 | 
             
                      else
         | 
| 196 | 
            -
                        UI.error "No Guardfile exists at #{ @@options[:guardfile] }."
         | 
| 203 | 
            +
                        ::Guard::UI.error "No Guardfile exists at #{ @@options[:guardfile] }."
         | 
| 197 204 | 
             
                        exit 1
         | 
| 198 205 | 
             
                      end
         | 
| 199 206 |  | 
| @@ -201,13 +208,13 @@ module Guard | |
| 201 208 | 
             
                      if File.exist?(guardfile_default_path)
         | 
| 202 209 | 
             
                        read_guardfile(guardfile_default_path)
         | 
| 203 210 | 
             
                      else
         | 
| 204 | 
            -
                        UI.error 'No Guardfile found, please create one with `guard init`.'
         | 
| 211 | 
            +
                        ::Guard::UI.error 'No Guardfile found, please create one with `guard init`.'
         | 
| 205 212 | 
             
                        exit 1
         | 
| 206 213 | 
             
                      end
         | 
| 207 214 | 
             
                    end
         | 
| 208 215 |  | 
| 209 216 | 
             
                    unless guardfile_contents_usable?
         | 
| 210 | 
            -
                      UI.error 'No Guard plugins found in Guardfile, please add at least one.'
         | 
| 217 | 
            +
                      ::Guard::UI.error 'No Guard plugins found in Guardfile, please add at least one.'
         | 
| 211 218 | 
             
                    end
         | 
| 212 219 | 
             
                  end
         | 
| 213 220 |  | 
| @@ -433,7 +440,7 @@ module Guard | |
| 433 440 | 
             
                # @param [Array] paths the list of paths to ignore
         | 
| 434 441 | 
             
                #
         | 
| 435 442 | 
             
                def ignore_paths(*paths)
         | 
| 436 | 
            -
                  UI.deprecation(IGNORE_PATHS_DEPRECATION)
         | 
| 443 | 
            +
                  ::Guard::UI.deprecation(IGNORE_PATHS_DEPRECATION)
         | 
| 437 444 | 
             
                end
         | 
| 438 445 |  | 
| 439 446 | 
             
                # Ignore certain patterns paths globally.
         |