guard-notifier-blink1 0.1.0 → 0.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f83ab4aae2ac5a6a46ad345482c1fb6004f0b62b
4
- data.tar.gz: 38784a9c0a6b10ca3b682e782b990bb41e0c6e44
3
+ metadata.gz: 762c927f895d4dbc4b8d7e6f5300158f6ea5b50d
4
+ data.tar.gz: f8b837b90fd7dcc27b3fdb33cb649839cacc1ab2
5
5
  SHA512:
6
- metadata.gz: 12aef90e74c6a22104e972543002fc6142ec13d762c4e9342eb46c34f0466d1a25d959acf11399c44fec9b54fbb1cca8eb564010ff0dea8d82907c5202d477f6
7
- data.tar.gz: 46a29db762d9c3d13a9b4021d8cbafdfa8284ee328bb141a5016b1f4a29065420de58027603f0af8d71589c62eb8ecf41343eaa48d3396c987b14028df670d8f
6
+ metadata.gz: 710255a01d8d58432bae2ec13c5454e56f93ef619f83f594175942ca04469535c812c732084c42b7fa3b211c4ff1d00a5fa8eb9ac7b9154849fce65421ca88c7
7
+ data.tar.gz: 4313fd316d1247b8b94f0831f617231fae04d453674d6f9277b9bdb132b088932b1d73ce117f0d4bf44d6c3d3892398cceca23b3beb48856efd54644a41b35c9
data/CHANGELOG.md CHANGED
@@ -1,8 +1,10 @@
1
1
  # Changelog
2
2
 
3
- ## Development
3
+ ## 0.2.0
4
4
 
5
- ## v0.1.0
5
+ * Add some option for more flexible configuration. - [@Sixeight]
6
+
7
+ ## 0.1.0
6
8
 
7
9
  * Initial release. - [@Sixeight]
8
10
 
data/README.md CHANGED
@@ -33,17 +33,31 @@ notification :blink1
33
33
 
34
34
  ## Options
35
35
 
36
- ### :method
36
+ ### :methods
37
37
 
38
38
  This option is used as flash method of `blink(1)`.
39
+ You can set color of result types individually.
39
40
 
40
- |name|description|
41
- |--|--|
42
- |:emission|LED emits until is sent `--off` option.|
43
- |:blink|use `--blink` option|
44
- |:glimmer|use `--glimer` option|
41
+ | NAME | DESCRIPTION |
42
+ | :-- | :-- |
43
+ | `:emission` | LED emits until is sent `--off` option |
44
+ | `:blink` | use `--blink` option |
45
+ | `:glimmer` | use `--glimer` option |
46
+ | `:off` | use `--off` option |
45
47
 
46
- Default: `:blink`
48
+ Default:
49
+ ```ruby
50
+ {
51
+ success: "blink",
52
+ pending: "blink",
53
+ failed: "blink",
54
+ notify: "blink",
55
+ }
56
+ ```
57
+
58
+ ### :method
59
+
60
+ Set method for all result type.
47
61
 
48
62
  ### :colors
49
63
 
@@ -60,18 +74,35 @@ Default:
60
74
  }
61
75
  ```
62
76
 
63
- ### :count
77
+ ### :color
78
+
79
+ Set color for all result type.
80
+
81
+ ### :counts
64
82
 
65
83
  This option is used as the number of flashes when the `:method` is set to `blink` or `glimmer`.
84
+ You can set color of result types individually.
85
+
86
+ Default:
87
+ ```ruby
88
+ {
89
+ success: 3,
90
+ pending: 3,
91
+ failed: 3,
92
+ notify: 3,
93
+ }
94
+ ```
95
+
96
+ ### :count
66
97
 
67
- Default: `3`
98
+ Set count for all result type.
68
99
 
69
100
  ## Sample
70
101
 
71
102
  ```ruby
72
103
  notification :blink1,
73
104
  method: :glimmer,
74
- count: 5
105
+ count: 5,
75
106
  colors: {
76
107
  success: "#003200",
77
108
  pending: "#323200",
@@ -4,14 +4,26 @@ module Guard
4
4
  class Blink1 < Base
5
5
  require "colorable"
6
6
 
7
- DEFAULT_METHOD = :blink
7
+ DEFAULT_METHODS = {
8
+ success: "blink",
9
+ pending: "blink",
10
+ failed: "blink",
11
+ notify: "blink",
12
+ }.freeze
13
+
8
14
  DEFAULT_COLORS = {
9
15
  success: "#00ff00",
10
16
  pending: "#ffff00",
11
17
  failed: "#ff0000",
12
18
  notify: "#0000ff",
13
19
  }.freeze
14
- DEFAULT_COUNT = 3
20
+
21
+ DEFAULT_COUNTS = {
22
+ success: 3,
23
+ pending: 3,
24
+ failed: 3,
25
+ notify: 3,
26
+ }.freeze
15
27
 
16
28
  def self.available?(opts = {})
17
29
  super && command?("blink1-tool")
@@ -20,21 +32,21 @@ module Guard
20
32
  def notify(message, opts = {})
21
33
  super
22
34
 
23
- type = opts[:type]
24
- method = opts[:method] || DEFAULT_METHOD
25
- colors = opts[:colors] || {}
26
- color = colors[type] || DEFAULT_COLORS[type]
27
- color = color.to_color.rgb.join(",")
28
- count = opts[:count] || DEFAULT_COUNT
35
+ method = fetch_config :method, opts, DEFAULT_METHODS
36
+ color = fetch_config :color, opts, DEFAULT_COLORS
37
+ count = fetch_config :count, opts, DEFAULT_COUNTS
29
38
 
30
39
  execute method, color, count
31
40
  end
32
41
 
33
42
  private
34
43
  def execute(method, color, count)
35
- __send__ method, color, count
36
- rescue
44
+ rbg_color = color.to_color.rgb.join(", ")
45
+ __send__ method, rbg_color, count
46
+ rescue NoMethodError
37
47
  ::Guard::UI.error 'unrecognized method is set to :method option.'
48
+ rescue
49
+ ::Guard::UI.error 'unexpected error occured.'
38
50
  end
39
51
 
40
52
  def emission(color, count)
@@ -49,6 +61,18 @@ module Guard
49
61
  system "blink1-tool", "--rgb=#{color}", "--glimmer=#{count}"
50
62
  end
51
63
 
64
+ def off
65
+ system "blink1-tool", "--off"
66
+ end
67
+
68
+ def fetch_config(name, opts, defaults)
69
+ type = opts[:type]
70
+ config = opts[name]
71
+ config ||= (opts[:"#{name}s"] || {})[type]
72
+ config ||= defaults[type]
73
+ config
74
+ end
75
+
52
76
  def self.command?(name)
53
77
  system "type #{name} > /dev/null 2>&1"
54
78
  end
@@ -1,5 +1,5 @@
1
1
 
2
2
  module GuardNotifierBlink1
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guard-notifier-blink1
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomohiro Nishimura
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-05 00:00:00.000000000 Z
11
+ date: 2014-10-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: guard