guard-notifier-blink1 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -2
- data/README.md +41 -10
- data/lib/guard/notifier/blink1.rb +34 -10
- data/lib/guard-notifier-blink1/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 762c927f895d4dbc4b8d7e6f5300158f6ea5b50d
|
4
|
+
data.tar.gz: f8b837b90fd7dcc27b3fdb33cb649839cacc1ab2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 710255a01d8d58432bae2ec13c5454e56f93ef619f83f594175942ca04469535c812c732084c42b7fa3b211c4ff1d00a5fa8eb9ac7b9154849fce65421ca88c7
|
7
|
+
data.tar.gz: 4313fd316d1247b8b94f0831f617231fae04d453674d6f9277b9bdb132b088932b1d73ce117f0d4bf44d6c3d3892398cceca23b3beb48856efd54644a41b35c9
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -33,17 +33,31 @@ notification :blink1
|
|
33
33
|
|
34
34
|
## Options
|
35
35
|
|
36
|
-
### :
|
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
|
-
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
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:
|
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
|
-
### :
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
24
|
-
|
25
|
-
|
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
|
-
|
36
|
-
|
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
|
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.
|
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-
|
11
|
+
date: 2014-10-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: guard
|