guard-compat 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +17 -0
- data/lib/guard/compat/plugin.rb +42 -11
- data/lib/guard/compat/version.rb +1 -1
- data/spec/guard/compat/no_guard_spec.rb +63 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8bea3b0b5cc442c2c5b10976c87ad36407e5066d
|
4
|
+
data.tar.gz: df406a03c512afab623264e68c8fba0f926a9ceb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 01036358dd3830011dbeceac79ecdc19ef6a7788369d8f20f1314445bf187627b7214f23cde5330fa0bce6977431bdedee3e6f1ea5bc6a8dc2df2f5f2461c239
|
7
|
+
data.tar.gz: 32bf5202d15a4480394311cc5799e231ac9c3bf37b20e288507f609cc0159b8806090e48eb8723903cea6d9a709625dee0e0a643fbc073e01a5e533b128d40a7
|
data/README.md
CHANGED
@@ -43,6 +43,21 @@ require 'guard/myplugin'
|
|
43
43
|
|
44
44
|
(OPTIONAL: if your plugin consists of many files, you may prefer to add the two above requires to your `spec/spec_helper.rb` or test setup files)
|
45
45
|
|
46
|
+
### Migrating your API calls
|
47
|
+
|
48
|
+
`Guard::UI` => `Guard::Compat::UI` (or Compat::UI for short)
|
49
|
+
`Guard::Notifier.notify` => `Guard::Compat::UI.notify`
|
50
|
+
|
51
|
+
`Guard::Watcher.match_files` => `Guard::Compat.matching_files` (Watcher is otherwise unavailable - see Guard::Less template for passing patterns as plugin options)
|
52
|
+
|
53
|
+
### New API
|
54
|
+
|
55
|
+
* `Guard::UI.color` => for creating ANSI colored text if currently enabled in Guard
|
56
|
+
* `Guard::UI.color_enabled?` => for checking if ANSI color output is currently enabled in Guard
|
57
|
+
* `Guard::UI.watched_directories` => compatible way of obtaining watched_directories (recommended instead of accessing Watcher patterns or pattern subgroup hacks)
|
58
|
+
|
59
|
+
(Open an issue if you feel something important is missing)
|
60
|
+
|
46
61
|
|
47
62
|
## Example
|
48
63
|
|
@@ -50,6 +65,8 @@ See [lib/guard/compat/example.rb](https://github.com/guard/guard-compat/blob/mas
|
|
50
65
|
|
51
66
|
See [spec/guard/compat/example_spec.rb](https://github.com/guard/guard-compat/blob/master/spec/guard/compat/example_spec.rb) for an example on how to test plugins using Guard::Compat.
|
52
67
|
|
68
|
+
See [spec/guard/compat/example_template_spec.rb](https://github.com/guard/guard-compat/blob/master/spec/guard/compat/example_template_spec.rb) for an example on how to test plugin templates.
|
69
|
+
|
53
70
|
## Contributing
|
54
71
|
|
55
72
|
1. Fork it ( https://github.com/guard/guard-compat/fork )
|
data/lib/guard/compat/plugin.rb
CHANGED
@@ -38,9 +38,8 @@ module Guard
|
|
38
38
|
|
39
39
|
def self.watched_directories
|
40
40
|
unless Guard.const_defined?('CLI')
|
41
|
-
|
42
|
-
' stub this method in your plugin tests'
|
43
|
-
fail NotImplementedError, msg
|
41
|
+
fail NotImplementedError, 'either Guard has not been required or'\
|
42
|
+
' you did not stub this method in your plugin tests'
|
44
43
|
end
|
45
44
|
|
46
45
|
if Guard.respond_to?(:state)
|
@@ -54,35 +53,67 @@ module Guard
|
|
54
53
|
|
55
54
|
module UI
|
56
55
|
def self.color(text, *colors)
|
57
|
-
Guard
|
56
|
+
if Guard.const_defined?(:UI)
|
57
|
+
Guard::UI.send(:color, text, *colors)
|
58
|
+
else
|
59
|
+
text
|
60
|
+
end
|
58
61
|
end
|
59
62
|
|
60
63
|
def self.color_enabled?
|
61
|
-
Guard
|
64
|
+
if Guard.const_defined?(:UI)
|
65
|
+
Guard::UI.send(:color_enabled?)
|
66
|
+
else
|
67
|
+
false
|
68
|
+
end
|
62
69
|
end
|
63
70
|
|
64
71
|
def self.info(message, options = {})
|
65
|
-
Guard
|
72
|
+
if Guard.const_defined?(:UI)
|
73
|
+
Guard::UI.info(message, options)
|
74
|
+
else
|
75
|
+
$stdout.puts(message)
|
76
|
+
end
|
66
77
|
end
|
67
78
|
|
68
79
|
def self.warning(message, options = {})
|
69
|
-
Guard
|
80
|
+
if Guard.const_defined?(:UI)
|
81
|
+
Guard::UI.warning(message, options)
|
82
|
+
else
|
83
|
+
$stdout.puts(message)
|
84
|
+
end
|
70
85
|
end
|
71
86
|
|
72
87
|
def self.error(message, options = {})
|
73
|
-
Guard
|
88
|
+
if Guard.const_defined?(:UI)
|
89
|
+
Guard::UI.error(message, options)
|
90
|
+
else
|
91
|
+
$stderr.puts(message)
|
92
|
+
end
|
74
93
|
end
|
75
94
|
|
76
95
|
def self.debug(message, options = {})
|
77
|
-
Guard
|
96
|
+
if Guard.const_defined?(:UI)
|
97
|
+
Guard::UI.debug(message, options)
|
98
|
+
else
|
99
|
+
$stdout.puts(message)
|
100
|
+
end
|
78
101
|
end
|
79
102
|
|
80
103
|
def self.deprecation(message, options = {})
|
81
|
-
Guard
|
104
|
+
if Guard.const_defined?(:UI)
|
105
|
+
Guard::UI.deprecation(message, options)
|
106
|
+
else
|
107
|
+
$stdout.puts(message)
|
108
|
+
end
|
82
109
|
end
|
83
110
|
|
84
111
|
def self.notify(message, options = {})
|
85
|
-
Guard
|
112
|
+
if Guard.const_defined?(:UI)
|
113
|
+
Guard::Notifier.notify(message, options)
|
114
|
+
else
|
115
|
+
$stdout.puts(message)
|
116
|
+
end
|
86
117
|
end
|
87
118
|
end
|
88
119
|
end
|
data/lib/guard/compat/version.rb
CHANGED
@@ -0,0 +1,63 @@
|
|
1
|
+
# This test requires UI be not defined to simulate using plugin outside Guard
|
2
|
+
|
3
|
+
require 'guard/compat/plugin'
|
4
|
+
|
5
|
+
Guard.send(:remove_const, :UI) if Guard.const_defined?(:UI)
|
6
|
+
|
7
|
+
RSpec.describe Guard::Compat do
|
8
|
+
context 'when Guard is not loaded' do
|
9
|
+
describe '.color' do
|
10
|
+
it 'returns uncolored text' do
|
11
|
+
expect(Guard::Compat::UI.color('foo', 'red')).to eq('foo')
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '.color_enabled?' do
|
16
|
+
it 'returns false' do
|
17
|
+
expect(Guard::Compat::UI.color_enabled?).to be(false)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '.info' do
|
22
|
+
it 'outputs to stdout' do
|
23
|
+
expect($stdout).to receive(:puts).with('foo')
|
24
|
+
Guard::Compat::UI.info('foo')
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe '.warning' do
|
29
|
+
it 'outputs to stdout' do
|
30
|
+
expect($stdout).to receive(:puts).with('foo')
|
31
|
+
Guard::Compat::UI.warning('foo')
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe '.error' do
|
36
|
+
it 'outputs to stdout' do
|
37
|
+
expect($stderr).to receive(:puts).with('foo')
|
38
|
+
Guard::Compat::UI.error('foo')
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '.debug' do
|
43
|
+
it 'outputs to stdout' do
|
44
|
+
expect($stdout).to receive(:puts).with('foo')
|
45
|
+
Guard::Compat::UI.debug('foo')
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe '.deprecation' do
|
50
|
+
it 'outputs to stdout' do
|
51
|
+
expect($stdout).to receive(:puts).with('foo')
|
52
|
+
Guard::Compat::UI.deprecation('foo')
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe '.notify' do
|
57
|
+
it 'outputs to stdout' do
|
58
|
+
expect($stdout).to receive(:puts).with('foo')
|
59
|
+
Guard::Compat::UI.notify('foo')
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: guard-compat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cezary Baginski
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-12-
|
11
|
+
date: 2014-12-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -62,6 +62,7 @@ files:
|
|
62
62
|
- lib/guard/compat/version.rb
|
63
63
|
- spec/guard/compat/example_spec.rb
|
64
64
|
- spec/guard/compat/example_template_spec.rb
|
65
|
+
- spec/guard/compat/no_guard_spec.rb
|
65
66
|
- spec/spec_helper.rb
|
66
67
|
homepage: ''
|
67
68
|
licenses:
|
@@ -83,11 +84,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
83
84
|
version: '0'
|
84
85
|
requirements: []
|
85
86
|
rubyforge_project:
|
86
|
-
rubygems_version: 2.
|
87
|
+
rubygems_version: 2.4.3
|
87
88
|
signing_key:
|
88
89
|
specification_version: 4
|
89
90
|
summary: Tools for developing Guard compatible plugins
|
90
91
|
test_files:
|
91
92
|
- spec/guard/compat/example_spec.rb
|
92
93
|
- spec/guard/compat/example_template_spec.rb
|
94
|
+
- spec/guard/compat/no_guard_spec.rb
|
93
95
|
- spec/spec_helper.rb
|