guard-slimlint 1.1.2 → 1.2.1

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: fe50bcb5638910f5b742fc62891657e5757af270
4
- data.tar.gz: e3dd7e09a2cb2eee5fd6b4547d11aee6218d23b9
3
+ metadata.gz: 1a91163e1f2044c92b299d1e5e8816bffe65a249
4
+ data.tar.gz: 50cedaa71b1969f1c4bdb006883fc8750cfc38db
5
5
  SHA512:
6
- metadata.gz: 80a2eae52b816ae9a7defc2ea259511d54a20aa448361265617d99435cf49b7ec1800676b4f514b41f642f37ce2d62c6ecd96bf08ea1d044189f9ac325a2f263
7
- data.tar.gz: 7159a1dbdde8b7a06c5a8738b1c53f9dc4ce4c652e7a3c1dc7a3780752510ce44d17a8917ac8fc43697c972f5c0e156af381882e6d47e32f1380373515f2de6c
6
+ metadata.gz: bc59cbc42f957a5fb0fa968ae3898279b82b5b027e04381ce7f91a97d886aee1c3e61f045f6c86b360711634089ae63563551ead08e5cb3f418f3771b5ca62b5
7
+ data.tar.gz: 0d7cbf7a1d6c796e9d6ad91df04a7cb82c11b0fced7d294087dfd1f3c1a09397e7e8f816bfea6cae8ddf5cd25be7b5eb1b79604ab2a843ee0ea7e92f3eb9be22
data/Gemfile CHANGED
@@ -1,6 +1,4 @@
1
1
  source 'https://rubygems.org'
2
- group :development, :test do
3
- gem 'astrolabe'
4
- end
2
+
5
3
  # Specify your gem's dependencies in guard-slimlint.gemspec
6
4
  gemspec
@@ -0,0 +1,6 @@
1
+ # available options:
2
+ # notify_on:
3
+ # failure, success, both, none
4
+ guard :slimlint, notify_on: :success do
5
+ watch(/^.+(\.html\.slim)$/)
6
+ end
@@ -1,38 +1,70 @@
1
1
  require 'guard/compat/plugin'
2
2
  require 'colorize'
3
- require 'guard/slimlint/notifier'
4
3
 
5
4
  module Guard
6
5
  class SlimLint < Plugin
6
+ attr_accessor :notify_on
7
+
7
8
  def initialize(options = {})
9
+ @notify_on = options[:notify_on] ? options[:notify_on] : :failure
8
10
  super
9
11
  end
10
12
 
13
+ def start
14
+ run
15
+ end
16
+
11
17
  def run_all
12
18
  run
13
19
  end
14
20
 
15
- def start
21
+ def startguard
16
22
  run
17
23
  end
18
24
 
19
- def run_on_modifications(path)
20
- run(path)
25
+ def run_on_modifications(paths)
26
+ run(paths)
21
27
  end
22
28
 
23
- def run_on_additions(path)
24
- run(path)
29
+ def run_on_additions(paths)
30
+ run(paths)
25
31
  end
26
32
 
27
33
  private
28
34
 
29
- def run(path = ['.'])
30
- if system("slim-lint #{path.join(" ")}")
35
+ def run(paths = ['.'])
36
+ result = system "slim-lint #{paths.join(' ')}"
37
+ if result
31
38
  UI.info 'No Slim offences detected'.green
32
39
  else
33
40
  UI.info 'Slim offences has been detected'.red
34
- Notifier.notify(false, 'Slim offences detected')
35
41
  end
42
+ check_and_notify(result)
43
+ end
44
+
45
+ def notification_allowed?(result)
46
+ case notify_on
47
+ when :failure then !result
48
+ when :success then result
49
+ when :both then true
50
+ when :none then false
51
+ end
52
+ end
53
+
54
+ def check_and_notify(result)
55
+ notify(result) if notification_allowed?(result)
56
+ end
57
+
58
+ def image(result)
59
+ result ? :success : :failed
60
+ end
61
+
62
+ def message(result)
63
+ result ? 'No slim offences' : 'Slim offences detected'
64
+ end
65
+
66
+ def notify(result)
67
+ Notifier.notify(message(result), title: 'Slim-lint results', image: image(result))
36
68
  end
37
69
  end
38
70
  end
@@ -1,3 +1,6 @@
1
- guard :slimlint do
1
+ # available options:
2
+ # notify_on:
3
+ # failure, success, both, none
4
+ guard :slimlint, notify_on: :both do
2
5
  watch(/^.+(\.html\.slim)$/)
3
6
  end
@@ -1,5 +1,5 @@
1
1
  module Guard
2
2
  class SlimLintVersion
3
- VERSION = '1.1.2'
3
+ VERSION = '1.2.1'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guard-slimlint
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michal Gajowiak
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-01-25 00:00:00.000000000 Z
11
+ date: 2016-02-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -121,6 +121,7 @@ files:
121
121
  - ".travis.yml"
122
122
  - CODE_OF_CONDUCT.md
123
123
  - Gemfile
124
+ - Guardfile
124
125
  - LICENSE.txt
125
126
  - README.md
126
127
  - Rakefile
@@ -128,7 +129,6 @@ files:
128
129
  - bin/setup
129
130
  - guard-slimlint.gemspec
130
131
  - lib/guard/slimlint.rb
131
- - lib/guard/slimlint/notifier.rb
132
132
  - lib/guard/slimlint/templates/Guardfile
133
133
  - lib/guard/slimlint/version.rb
134
134
  homepage: https://github.com/mike927/guard-slimlint
@@ -1,19 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'guard/slimlint'
4
-
5
- module Guard
6
- class SlimLint < Plugin
7
- class Notifier
8
- class << self
9
- def image(result)
10
- result ? :success : :failed
11
- end
12
-
13
- def notify(result, message)
14
- Compat::UI.notify(message, title: 'Slimlint results!', image: image(result))
15
- end
16
- end
17
- end
18
- end
19
- end