guard 1.4.0 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,20 @@
1
+ ## 1.5.0 - 22 October, 2012
2
+
3
+ ### New features
4
+
5
+ - [#327][] Use Pry as interactor. ([@netzpirat][])
6
+ - [#345][] Use Lumberjack as customizable logger. ([@netzpirat][])
7
+ - [#342][] Add notifier for displaying result in terminal title. ([@tomas-zemres][])
8
+ - [#348][] Introduce grouping of the notifiers for better auto-detection. ([@netzpirat][])
9
+
10
+ ### Improvements
11
+
12
+ - [#348][] Introduce grouping of the notifiers. ([@netzpirat][])
13
+ - [#343][] Customize tmux notifier status location. ([@nickmabry][])
14
+ - Adds ability to override default options in emacs notifier. ([@d1][])
15
+ - Use `$stderr` instead of `STDERR` to allow redirection. ([@netzpirat][])
16
+ - [#334][] Extend `:tmux` notifier with use of `tmux display-message` and options to configure them. ([@matthijsgroen][])
17
+
1
18
  ## 1.4.0 - 26 September, 2012
2
19
 
3
20
  - [#331][] Add tmux notifier. ([@royvandewater][])
@@ -600,6 +617,9 @@ The Listen integration has been supervised by [@thibaudgg][] and executed by [@M
600
617
  [#317]: https://github.com/guard/guard/issues/317
601
618
  [#324]: https://github.com/guard/guard/issues/324
602
619
  [#331]: https://github.com/guard/guard/issues/331
620
+ [#334]: https://github.com/guard/guard/issues/334
621
+ [#342]: https://github.com/guard/guard/issues/342
622
+ [#343]: https://github.com/guard/guard/issues/343
603
623
  [@Gazer]: https://github.com/Gazer
604
624
  [@Maher4Ever]: https://github.com/Maher4Ever
605
625
  [@alandipert]: https://github.com/alandipert
@@ -611,6 +631,7 @@ The Listen integration has been supervised by [@thibaudgg][] and executed by [@M
611
631
  [@capotej]: https://github.com/capotej
612
632
  [@ches]: https://github.com/ches
613
633
  [@chrisberkhout]: https://github.com/chrisberkhout
634
+ [@d1]: https://github.com/d1
614
635
  [@dgutov]: https://github.com/dgutov
615
636
  [@dnagir]: https://github.com/dnagir
616
637
  [@docwhat]: https://github.com/docwhat
@@ -639,12 +660,14 @@ The Listen integration has been supervised by [@thibaudgg][] and executed by [@M
639
660
  [@madtrick]: https://github.com/madtrick
640
661
  [@maio]: https://github.com/maio
641
662
  [@mattgreen]: https://github.com/mattgreen
663
+ [@matthijsgroen]: https://github.com/matthijsgroen
642
664
  [@mcmire]: https://github.com/mcmire
643
665
  [@mislav]: https://github.com/mislav
644
666
  [@monocle]: https://github.com/monocle
645
667
  [@mordaroso]: https://github.com/mordaroso
646
668
  [@nestegg]: https://github.com/nestegg
647
669
  [@netzpirat]: https://github.com/netzpirat
670
+ [@nickmabry]: https://github.com/nickmabry
648
671
  [@nicksieger]: https://github.com/nicksieger
649
672
  [@niklas]: https://github.com/niklas
650
673
  [@oliamb]: https://github.com/oliamb
@@ -667,6 +690,7 @@ The Listen integration has been supervised by [@thibaudgg][] and executed by [@M
667
690
  [@thibaudgg]: https://github.com/thibaudgg
668
691
  [@thierryhenrio]: https://github.com/thierryhenrio
669
692
  [@tinogomes]: https://github.com/tinogomes
693
+ [@tomas-zemres]: https://github.com/tomas-zemres
670
694
  [@tpope]: https://github.com/tpope
671
695
  [@uk-ar]: https://github.com/uk-ar
672
696
  [@veged]: https://github.com/veged
data/README.md CHANGED
@@ -101,8 +101,7 @@ end
101
101
 
102
102
  ### System notifications
103
103
 
104
- You can configure Guard to make use of the following system notification libraries, but it's strongly recommended
105
- to use either Ruby GNTP, Libnotify or Notifu:
104
+ You can configure Guard to make use of the following system notification libraries:
106
105
 
107
106
  #### Ruby GNTP
108
107
 
@@ -219,13 +218,45 @@ group :development do
219
218
  end
220
219
  ```
221
220
 
221
+ #### Terminal Title
222
+
223
+ * Runs in every terminal supporting XTerm escape sequences to set the window title.
224
+
222
225
  #### Emacs
223
226
 
224
227
  * Runs on any platform with Emacs + emacsclient (http://www.emacswiki.org/emacs/EmacsClient)
225
228
 
226
- ### Tmux
229
+ ### TMux
230
+
231
+ * To use TMux notifications, you have to start Guard within a [TMux](http://tmux.sourceforge.net/) session.
232
+
233
+ The TMux notifier will color the background of the left part of the
234
+ status bar indicating the status of the notifications. Optionally you
235
+ can set `:display_message => true` to display the Guard notification as
236
+ 'display-message' notification.
237
+
238
+ The way these messages are formatted is configurable.
239
+
240
+ ```ruby
241
+ # Guardfile
242
+ notification :tmux,
243
+ :display_message => true,
244
+ :timeout => 5, # in seconds
245
+ :default_message_format => '%s >> %s',
246
+ # the first %s will show the title, the second the message
247
+ # Alternately you can also configure *success_message_format*,
248
+ # *pending_message_format*, *failed_message_format*
249
+ :line_separator => ' > ', # since we are single line we need a separator
250
+ :color_location => 'status-left-bg' # to customize which tmux element will change color
251
+ ```
252
+
253
+ The result will be for RSpec using example above
254
+
255
+ RSpec >> 15 test, 0 failures > in 0.002 sec
256
+
257
+ You can use nice powerline chars here if you have that configured.
227
258
 
228
- * To use Tmux notifications, you have to start Guard within a [tmux](http://tmux.sourceforge.net/) session.
259
+ You can get the message history by using `Ctrl+b ~` (where `Ctrl+b` is your key to activate TMux).
229
260
 
230
261
  Add Guard plugins
231
262
  -----------------
@@ -457,82 +488,41 @@ read more about these files in the shared configuration section below.
457
488
  Interactions
458
489
  ------------
459
490
 
460
- You can interact with Guard and enter commands when Guard has nothing to do. Guard understands the following commands:
491
+ Guard shows a [Pry](http://pryrepl.org/) console whenever it has nothing to do and comes with some Guard specific Pry
492
+ commands:
461
493
 
462
- * `↩`: Run all plugins.
463
- * `h`, `help`: Show a help of the available interactor commands.
464
- * `r`, `reload`: Reload all plugins.
465
- * `c`, `change`: Trigger a file change to the plugins.
466
- * `s`, `show`: Show the plugin configurations.
467
- * `n`, `notification`: Toggle system notifications on and off.
468
- * `p`, `pause`: Toggles the file modification listener. The prompt will change to `p>` when paused.
469
- This is useful when switching Git branches, rebase Git or change whitespace.
470
- * `e`, `exit`: Stop all plugins and quit Guard.
494
+ * `↩`, `a`, `all`: Run all plugins.
495
+ * `h`, `help`: Show help for all interactor commands.
496
+ * `c`, `change`: Trigger a file change.
497
+ * `n`, `notification`: Toggles the notifications.
498
+ * `p`, `pause`: Toggles the file listener.
499
+ * `r`, `reload`: Reload all plugins.
500
+ * `s`, `show`: Show all Guard plugins.
501
+ * `e`, `exit`: Stop all plugins and quit Guard
471
502
 
472
- Instead of running all plugins with the `↩` key, you can also run a single plugin by entering its name:
503
+ The `all` and `reload` commands supports an optional scope, so you limit the Guard action to either a Guard plugin or
504
+ a Guard group like:
473
505
 
474
506
  ```bash
475
- > rspec
507
+ [1] guard(main)> all rspec
508
+ [2] guard(main)> all frontend
476
509
  ```
477
510
 
478
- It's also possible to run all plugins within a group by entering the group name:
511
+ Remember, you can always use `help` on the Pry command line to see all available commands and `help <command>` for
512
+ more detailed information. `help guard` will show all Guard related commands available
479
513
 
480
- ```bash
481
- > frontend
482
- ```
514
+ Pry supports the Ruby built-in Readline, [rb-readline](https://github.com/luislavena/rb-readline) and
515
+ [Coolline](https://github.com/Mon-Ouie/coolline). Just install the readline implementation of your choice by adding it
516
+ to your `Gemfile.
483
517
 
484
- The same applies to reloading. You can reload a plugin with the following command:
518
+ You can also disable the interactions completely by running Guard with the `--no-interactions` option.
485
519
 
486
- ```bash
487
- > ronn reload
488
- ```
489
-
490
- This will reload only the Ronn plugin. You can also reload all plugins within a group:
491
-
492
- ```bash
493
- > backend reload
494
- ```
495
-
496
- The action and plugin/group name can have any order, so you can also write:
497
-
498
- ```bash
499
- > reload backend
500
- ```
501
-
502
- You can pass a list of filenames to the `change` command to trigger manually a file modification:
503
-
504
- ```bash
505
- > change spec/guard_spec.rb
506
- ```
520
+ ### Customizations
507
521
 
508
- ### Readline support
509
-
510
- With Readline enabled, you'll see a command prompt `>` when Guard is ready to accept a command. The command line
511
- supports history navigation with the `↑` and `↓` arrow keys, and command auto-completion with the `⇥` key.
512
-
513
- Unfortunately Readline [does not work on MRI](http://bugs.ruby-lang.org/issues/5539) on Mac OS X by default. You can
514
- work around the issue by installing a pure Ruby implementation:
515
-
516
- ```ruby
517
- platforms :ruby do
518
- gem 'rb-readline'
519
- end
520
- ```
521
-
522
- Guard will automatically enable Readline support if your environment supports it, but you can disable Readline with the
523
- `interactor` DSL method or turn off completely with the `--no-interactions` option.
524
-
525
- ### Coolline support
526
-
527
- With Ruby 1.9.3 you can use a [Coolline](https://github.com/Mon-Ouie/coolline) based interactor, which uses the new
528
- `io/console` from stdlib. Just add it to your `Gemfile`
529
-
530
- ```ruby
531
- gem 'coolline'
532
- ```
533
-
534
- Guard will automatically enable Coolline support if your environment supports it, but you can disable Coolline with the
535
- `interactor` DSL method or turn off completely with the `--no-interactions` option.
522
+ Further Guard specific customizations can be made in `~/.guardrc` that will be evaluated prior the Pry session is
523
+ started. This allows you to make use of the Pry plugin architecture to provide custom commands and extend Guard for
524
+ your own needs and distribute as a gem. Please have a look at the [Pry Wiki](https://github.com/pry/pry/wiki) for more
525
+ information.
536
526
 
537
527
  ### Signals
538
528
 
@@ -683,15 +673,7 @@ notification :off
683
673
 
684
674
  ### interactor
685
675
 
686
- You can disable the interactor auto detection and select a specific implementation:
687
-
688
- ```ruby
689
- interactor :coolline
690
- interactor :readline
691
- interactor :simple
692
- ```
693
-
694
- If you do not need the keyboard interactions with Guard at all, you can turn them off:
676
+ If you do not need the Pry interactions with Guard at all, you can turn it off:
695
677
 
696
678
  ```ruby
697
679
  interactor :off
@@ -744,6 +726,30 @@ Please note that method only accept regexps. More on the
744
726
  filter /\.txt$/, /.*\.zip/
745
727
  ```
746
728
 
729
+ ### logger
730
+
731
+ The `logger` method allows you to customize the Guard log output to your needs by specifying one or more options like:
732
+
733
+ ```ruby
734
+ logger :level => :warn,
735
+ :template => '[:severity - :time - :progname] :message',
736
+ :time_format => 'at %I:%M%p',
737
+ :only => [:rspec, :jasmine, 'coffeescript'],
738
+ :except => :jammit
739
+ ```
740
+
741
+ Log `:level` option must be either `:debug`, `:info`, `:warn` or `:error`. If Guard is started in debug mode, the log
742
+ level will be automatically set to `:debug`.
743
+
744
+ The `:template` option is a string which can have one or more of the following placeholders: `:time`, `:severity`,
745
+ `:progname`, `:pid`, `:unit_of_work_id` and `:message`. A unit of work is assigned for each action Guard performs on
746
+ multiple Guard plugin.
747
+
748
+ The `:time_format` option directives are the same as Time#strftime or can be `:milliseconds`
749
+
750
+ The `:only` and `:except` are either a string or a symbol, or an array of strings or symbols that matches the name of
751
+ the Guard plugin name that sends the log message. They cannot be specified at the same time.
752
+
747
753
  ### Example
748
754
 
749
755
  ```ruby
data/lib/guard.rb CHANGED
@@ -54,13 +54,16 @@ module Guard
54
54
  setup_listener
55
55
  setup_signal_traps
56
56
 
57
- debug_command_execution if @options[:debug]
58
-
59
57
  ::Guard::Dsl.evaluate_guardfile(options)
60
58
  ::Guard::UI.error 'No guards found in Guardfile, please add at least one.' if @guards.empty?
61
59
 
62
60
  runner.deprecation_warning if @options[:show_deprecations]
63
61
 
62
+ if @options[:debug]
63
+ ::Guard::UI.options[:level] = :debug
64
+ debug_command_execution
65
+ end
66
+
64
67
  setup_notifier
65
68
  setup_interactor
66
69
 
@@ -130,7 +133,7 @@ module Guard
130
133
  #
131
134
  def setup_interactor
132
135
  unless options[:no_interactions]
133
- @interactor = ::Guard::Interactor.fabricate
136
+ @interactor = ::Guard::Interactor.new
134
137
  end
135
138
  end
136
139
 
data/lib/guard/cli.rb CHANGED
@@ -21,13 +21,13 @@ module Guard
21
21
  :type => :boolean,
22
22
  :default => false,
23
23
  :aliases => '-c',
24
- :banner => 'Auto clear shell before each change/run_all/reload'
24
+ :banner => 'Auto clear shell before each action'
25
25
 
26
26
  method_option :notify,
27
27
  :type => :boolean,
28
28
  :default => true,
29
29
  :aliases => '-n',
30
- :banner => 'Notifications feature (growl/libnotify)'
30
+ :banner => 'Notifications feature'
31
31
 
32
32
  method_option :debug,
33
33
  :type => :boolean,
@@ -0,0 +1,34 @@
1
+ module Guard
2
+ class Interactor
3
+
4
+ ALL = Pry::CommandSet.new do
5
+ create_command 'all' do
6
+
7
+ group 'Guard'
8
+ description 'Run all plugins.'
9
+
10
+ banner <<-BANNER
11
+ Usage: all <scope>
12
+
13
+ Run the Guard plugin `run_all` action.
14
+
15
+ You may want to specify an optional scope to the action,
16
+ either the name of a Guard plugin or a plugin group.
17
+ BANNER
18
+
19
+ def process(*entries)
20
+ scopes, rest = ::Guard::Interactor.convert_scope(entries)
21
+
22
+ if rest.length == 0
23
+ ::Guard.run_all scopes
24
+ else
25
+ output.puts "Unkown scope #{ rest.join(', ') }"
26
+ end
27
+ end
28
+ end
29
+ end
30
+
31
+ end
32
+ end
33
+
34
+ Pry.commands.import ::Guard::Interactor::ALL
@@ -0,0 +1,37 @@
1
+ module Guard
2
+ class Interactor
3
+
4
+ CHANGE = Pry::CommandSet.new do
5
+ create_command 'change' do
6
+
7
+ group 'Guard'
8
+ description 'Trigger a file change.'
9
+
10
+ banner <<-BANNER
11
+ Usage: change <scope>
12
+
13
+ Runs the Guard plugin `run_on_changes` action.
14
+
15
+ You may want to specify an optional scope to the action,
16
+ either the name of a Guard plugin or a plugin group.
17
+ BANNER
18
+
19
+ def process(*entries)
20
+ scopes, rest = ::Guard::Interactor.convert_scope(entries)
21
+
22
+ if rest.length != 0
23
+ ::Guard.within_preserved_state do
24
+ ::Guard.runner.run_on_changes(rest, [], [])
25
+ end
26
+ else
27
+ output.puts 'Please specify a file.'
28
+ end
29
+ end
30
+
31
+ end
32
+ end
33
+
34
+ end
35
+ end
36
+
37
+ Pry.commands.import ::Guard::Interactor::CHANGE
@@ -0,0 +1,27 @@
1
+ require 'guard/notifier'
2
+
3
+ module Guard
4
+ class Interactor
5
+
6
+ NOTIFICATION = Pry::CommandSet.new do
7
+ create_command 'notification' do
8
+
9
+ group 'Guard'
10
+ description 'Toggles the notifications.'
11
+
12
+ banner <<-BANNER
13
+ Usage: notification
14
+
15
+ Toggles the notifications on and off.
16
+ BANNER
17
+
18
+ def process
19
+ ::Guard::Notifier.toggle
20
+ end
21
+ end
22
+ end
23
+
24
+ end
25
+ end
26
+
27
+ Pry.commands.import ::Guard::Interactor::NOTIFICATION
@@ -0,0 +1,28 @@
1
+ module Guard
2
+ class Interactor
3
+
4
+ PAUSE = Pry::CommandSet.new do
5
+ create_command 'pause' do
6
+
7
+ group 'Guard'
8
+ description 'Toggles the file listener.'
9
+
10
+ banner <<-BANNER
11
+ Usage: pause
12
+
13
+ Toggles the file listener on and off.
14
+
15
+ When the file listener is paused, the default Guard Pry
16
+ prompt will show the pause sign `[p]`.
17
+ BANNER
18
+
19
+ def process
20
+ ::Guard.pause
21
+ end
22
+ end
23
+ end
24
+
25
+ end
26
+ end
27
+
28
+ Pry.commands.import ::Guard::Interactor::PAUSE