guard 2.0.1 → 2.0.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b5f98e7ee3f48051531b01f09d182aa98f4e72a5
4
- data.tar.gz: 6b6ea9cc3d917469c588049826d81113c22deb43
3
+ metadata.gz: 2904fe4ebe6903b8c0c69b0c9b6fd419041552fe
4
+ data.tar.gz: bdf69fc777ed5a8ebdc63822d3013d04663cc913
5
5
  SHA512:
6
- metadata.gz: 473962947d938558ee966d8215d77cb76c2de65255e81baba1f90bbcc71654d9c0ed5aa25366c125fe4bce6fe05ece34be44e75b010c7c041aeadab3871207fe
7
- data.tar.gz: 1a2566513ff891bf79d29f406aea3f7e16dd940c54d1af607629e9e6070e7183f8379ba6dafedc5dcc98edd34e1b48b7154437f7deb3a136e23a0826be744fa6
6
+ metadata.gz: 348997dc9b494a611354c55a179187d052331d7538b22ec9b76093e5a56c1d03a216fd048cee7508636804a296251f260aef218c951aee73f5fe3788ce692050
7
+ data.tar.gz: 75e6bb26d53e19d4cfe24561e465be64de99e4a49c7254cf0f37a6ebd1368221ba1e5cd5dbaf1e2e02aaff7f667438e0422193b2541ed1ed3c4ea01e57919cc9
@@ -90,7 +90,7 @@ module Guard
90
90
  name = definition[0]
91
91
  clazz = definition[1]
92
92
  available = clazz.available?(silent: true) ? '✔' : '✘'
93
- notifier = ::Guard::Notifier.notifiers.find{ |n| n[:name] == name }
93
+ notifier = ::Guard::Notifier.notifiers.find { |n| n[:name] == name }
94
94
  used = notifier ? '✔' : '✘'
95
95
  options = notifier ? notifier[:options] : {}
96
96
  defaults = clazz.const_defined?(:DEFAULTS) ? clazz.const_get(:DEFAULTS) : {}
@@ -43,21 +43,20 @@ module Guard
43
43
  # @return [Boolean] the availability status
44
44
  #
45
45
  def self.available?(opts = {})
46
- options = { silent: false }.merge(opts)
47
-
48
46
  unless _supported_host?
49
47
  hosts = supported_hosts.map { |host| HOSTS[host.to_sym] }.join(', ')
50
- ::Guard::UI.error "The :#{name} notifier runs only on #{hosts}." unless options[:silent]
48
+ ::Guard::UI.error "The :#{name} notifier runs only on #{hosts}." unless opts.fetch(:silent) { false }
51
49
  return false
52
50
  end
53
51
 
54
52
  true
55
53
  end
56
54
 
57
- # This method must be implemented.
55
+ # This method must be overriden.
58
56
  #
59
57
  def notify(message, opts = {})
60
- raise NotImplementedError
58
+ opts.replace(options.merge(opts))
59
+ normalize_standard_options!(opts)
61
60
  end
62
61
 
63
62
  # Returns the title of the notifier.
@@ -47,7 +47,7 @@ module Guard
47
47
  # (default is 0)
48
48
  #
49
49
  def notify(message, opts = {})
50
- normalize_standard_options!(opts)
50
+ super
51
51
 
52
52
  opts = DEFAULTS.merge(opts)
53
53
  color = emacs_color(opts[:type], opts)
@@ -36,7 +36,7 @@ module Guard
36
36
  # @option opts [String] path the path of where to write the file
37
37
  #
38
38
  def notify(message, opts = {})
39
- normalize_standard_options!(opts)
39
+ super
40
40
 
41
41
  if opts[:path]
42
42
  format = opts.fetch(:format, DEFAULTS[:format])
@@ -69,8 +69,8 @@ module Guard
69
69
  # @option opts [Boolean] sticky make the notification sticky
70
70
  #
71
71
  def notify(message, opts = {})
72
+ super
72
73
  self.class.require_gem_safely
73
- normalize_standard_options!(opts)
74
74
 
75
75
  opts = DEFAULTS.merge(
76
76
  name: opts.delete(:type).to_s,
@@ -71,9 +71,9 @@ module Guard
71
71
  # notifications
72
72
  #
73
73
  def notify(message, opts = {})
74
- self.class.require_gem_safely
75
- normalize_standard_options!(opts)
74
+ super
76
75
  opts.delete(:type)
76
+ self.class.require_gem_safely
77
77
 
78
78
  opts = DEFAULTS.merge(opts).merge(name: 'Guard')
79
79
 
@@ -49,8 +49,8 @@ module Guard
49
49
  # low) to 2 (emergency)
50
50
  #
51
51
  def notify(message, opts = {})
52
+ super
52
53
  self.class.require_gem_safely
53
- normalize_standard_options!(opts)
54
54
 
55
55
  opts = DEFAULTS.merge(
56
56
  application_name: 'Guard',
@@ -54,8 +54,8 @@ module Guard
54
54
  # (1.5 (s), 1000 (ms), false)
55
55
  #
56
56
  def notify(message, opts = {})
57
+ super
57
58
  self.class.require_gem_safely
58
- normalize_standard_options!(opts)
59
59
 
60
60
  opts = DEFAULTS.merge(
61
61
  summary: opts.delete(:title),
@@ -42,7 +42,7 @@ module Guard
42
42
  # 3000)
43
43
  #
44
44
  def notify(message, opts = {})
45
- normalize_standard_options!(opts)
45
+ super
46
46
 
47
47
  command = [title, message]
48
48
  opts = DEFAULTS.merge(
@@ -67,8 +67,8 @@ module Guard
67
67
  # IUserNotification2 is available
68
68
  #
69
69
  def notify(message, opts = {})
70
+ super
70
71
  self.class.require_gem_safely
71
- normalize_standard_options!(opts)
72
72
 
73
73
  opts = DEFAULTS.merge(
74
74
  type: _notifu_type(opts.delete(:type)),
@@ -50,9 +50,9 @@ module Guard
50
50
  # @option opts [String] open some url or file
51
51
  #
52
52
  def notify(message, opts = {})
53
+ title = opts[:title] || options[:title]
54
+ super
53
55
  self.class.require_gem_safely
54
- title = opts[:title]
55
- normalize_standard_options!(opts)
56
56
 
57
57
  opts.delete(:image)
58
58
  opts[:title] = title || [opts.delete(:app_name) { 'Guard' }, opts[:type].downcase.capitalize].join(' ')
@@ -16,7 +16,7 @@ module Guard
16
16
  # @option opts [String] title the notification title
17
17
  #
18
18
  def notify(message, opts = {})
19
- normalize_standard_options!(opts)
19
+ super
20
20
 
21
21
  first_line = message.sub(/^\n/, '').sub(/\n.*/m, '')
22
22
 
@@ -30,6 +30,7 @@ module Guard
30
30
  default_message_format: '%s - %s',
31
31
  default_message_color: 'white',
32
32
  line_separator: ' - ',
33
+ change_color: true,
33
34
  color_location: 'status-left-bg'
34
35
  }
35
36
 
@@ -52,8 +53,10 @@ module Guard
52
53
  # use of a color based notification, changing the background color of the
53
54
  # `color_location` to the color defined in either the `success`,
54
55
  # `failed`, `pending` or `default`, depending on the notification type.
55
- # If you also want display a text message, you have to enable it explicit
56
- # by setting `display_message` to `true`.
56
+ #
57
+ # You may enable an extra explicit message by setting `display_message`
58
+ # to true, and may further disable the colorization by setting
59
+ # `change_color` to false.
57
60
  #
58
61
  # @param [String] title the notification title
59
62
  # @param [Hash] opts additional notification library options
@@ -61,19 +64,23 @@ module Guard
61
64
  # 'pending', 'failed' or 'notify'
62
65
  # @option opts [String] message the notification message body
63
66
  # @option opts [String] image the path to the notification image
67
+ # @option opts [Boolean] change_color whether to show a color
68
+ # notification
64
69
  # @option opts [String] color_location the location where to draw the
65
70
  # color notification
66
71
  # @option opts [Boolean] display_message whether to display a message
67
72
  # or not
68
73
  #
69
74
  def notify(message, opts = {})
70
- normalize_standard_options!(opts)
75
+ super
71
76
  opts.delete(:image)
72
77
 
73
- color_location = opts.fetch(:color_location, DEFAULTS[:color_location])
74
- color = tmux_color(opts[:type], opts)
78
+ if opts.fetch(:change_color, DEFAULTS[:change_color])
79
+ color_location = opts.fetch(:color_location, DEFAULTS[:color_location])
80
+ color = tmux_color(opts[:type], opts)
75
81
 
76
- _run_client "set #{ color_location } #{ color }"
82
+ _run_client "set #{ color_location } #{ color }"
83
+ end
77
84
 
78
85
  if opts.fetch(:display_message, DEFAULTS[:display_message])
79
86
  display_message(opts.delete(:type).to_s, opts.delete(:title), message, opts)
data/lib/guard/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Guard
2
- VERSION = '2.0.1'
2
+ VERSION = '2.0.2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guard
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thibaud Guillaume-Gentil