guard-puppet-lint 0.1.1 → 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.
- data/Gemfile +1 -0
- data/Gemfile.lock +6 -4
- data/VERSION +1 -1
- data/guard-puppet-lint.gemspec +5 -2
- data/lib/guard-puppet-lint.rb +1 -0
- data/lib/guard/puppet-lint.rb +51 -7
- data/lib/guard/puppet-lint/templates/Guardfile +5 -3
- metadata +20 -6
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -3,20 +3,21 @@ GEM
|
|
3
3
|
specs:
|
4
4
|
ffi (1.0.11)
|
5
5
|
git (1.2.5)
|
6
|
-
guard (1.0.
|
6
|
+
guard (1.0.3)
|
7
7
|
ffi (>= 0.5.0)
|
8
|
-
thor (
|
8
|
+
thor (>= 0.14.6)
|
9
9
|
jeweler (1.8.3)
|
10
10
|
bundler (~> 1.0)
|
11
11
|
git (>= 1.2.5)
|
12
12
|
rake
|
13
13
|
rdoc
|
14
|
-
json (1.
|
14
|
+
json (1.7.3)
|
15
|
+
libnotify (0.7.2)
|
15
16
|
rake (0.9.2.2)
|
16
17
|
rcov (1.0.0)
|
17
18
|
rdoc (3.12)
|
18
19
|
json (~> 1.4)
|
19
|
-
thor (0.
|
20
|
+
thor (0.15.2)
|
20
21
|
|
21
22
|
PLATFORMS
|
22
23
|
ruby
|
@@ -24,4 +25,5 @@ PLATFORMS
|
|
24
25
|
DEPENDENCIES
|
25
26
|
guard
|
26
27
|
jeweler (~> 1.8.3)
|
28
|
+
libnotify
|
27
29
|
rcov
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/guard-puppet-lint.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "guard-puppet-lint"
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.2.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Alister Bulman"]
|
12
|
-
s.date = "2012-
|
12
|
+
s.date = "2012-05-20"
|
13
13
|
s.description = "As Puppet manifest files change, run puppet-lint on them"
|
14
14
|
s.email = "abulman@gmail.com"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -43,15 +43,18 @@ Gem::Specification.new do |s|
|
|
43
43
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
44
44
|
s.add_development_dependency(%q<jeweler>, ["~> 1.8.3"])
|
45
45
|
s.add_development_dependency(%q<rcov>, [">= 0"])
|
46
|
+
s.add_development_dependency(%q<libnotify>, [">= 0"])
|
46
47
|
s.add_development_dependency(%q<guard>, [">= 0"])
|
47
48
|
else
|
48
49
|
s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
|
49
50
|
s.add_dependency(%q<rcov>, [">= 0"])
|
51
|
+
s.add_dependency(%q<libnotify>, [">= 0"])
|
50
52
|
s.add_dependency(%q<guard>, [">= 0"])
|
51
53
|
end
|
52
54
|
else
|
53
55
|
s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
|
54
56
|
s.add_dependency(%q<rcov>, [">= 0"])
|
57
|
+
s.add_dependency(%q<libnotify>, [">= 0"])
|
55
58
|
s.add_dependency(%q<guard>, [">= 0"])
|
56
59
|
end
|
57
60
|
end
|
data/lib/guard-puppet-lint.rb
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
require 'guard/puppet-lint'
|
data/lib/guard/puppet-lint.rb
CHANGED
@@ -1,12 +1,32 @@
|
|
1
1
|
require 'guard'
|
2
2
|
require 'guard/guard'
|
3
3
|
require 'guard/watcher'
|
4
|
+
require 'puppet-lint'
|
5
|
+
|
6
|
+
class PuppetLint
|
7
|
+
|
8
|
+
attr_reader :messages
|
9
|
+
|
10
|
+
def clear_messages
|
11
|
+
@messages = []
|
12
|
+
end
|
13
|
+
|
14
|
+
def format_message(message)
|
15
|
+
@messages << (log_format % message)
|
16
|
+
end
|
17
|
+
end
|
4
18
|
|
5
19
|
module Guard
|
6
20
|
class Puppetlint < Guard
|
7
21
|
|
8
22
|
VERSION = '0.0.1'
|
9
23
|
|
24
|
+
def initialize(watchers = [], options = {})
|
25
|
+
options = { :syntax_check => true }.merge(options)
|
26
|
+
@linter = PuppetLint.new
|
27
|
+
super
|
28
|
+
end
|
29
|
+
|
10
30
|
# Calls #run_all if the :all_on_start option is present.
|
11
31
|
def start
|
12
32
|
run_all if options[:all_on_start]
|
@@ -17,17 +37,41 @@ module Guard
|
|
17
37
|
run_on_change(Watcher.match_files(self, Dir.glob('{,**/}*{,.*}').uniq))
|
18
38
|
end
|
19
39
|
|
40
|
+
def prepend_filename(msg, file)
|
41
|
+
if msg
|
42
|
+
msg.map {|x| "#{file}: #{x}"}
|
43
|
+
else
|
44
|
+
[]
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
20
48
|
# Print the result of the command(s), if there are results to be printed.
|
21
49
|
def run_on_change(res)
|
22
|
-
|
23
|
-
|
50
|
+
messages = []
|
51
|
+
res.each do |file|
|
52
|
+
file = File.join( options[:watchdir].to_s,file ) if options[:watchdir]
|
24
53
|
|
25
|
-
|
54
|
+
if options[:syntax_check]
|
55
|
+
parser_messages = `puppet parser validate #{file} --color=false`.split("\n")
|
56
|
+
parser_messages.reject! { |s| s =~ /puppet help parser validate/ }
|
57
|
+
parser_messages.map! { |s| s.gsub 'err: Could not parse for environment production:', '' }
|
58
|
+
|
59
|
+
messages += prepend_filename(parser_messages, file)
|
60
|
+
end
|
26
61
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
62
|
+
@linter.file = file
|
63
|
+
@linter.clear_messages
|
64
|
+
@linter.run
|
65
|
+
linter_msg = @linter.messages.reject { |s| !options[:show_warnings] && s =~ /WARNING/ }
|
66
|
+
messages += prepend_filename(linter_msg, file)
|
67
|
+
end
|
68
|
+
if messages.empty?
|
69
|
+
messages = ["Files are ok:"] + res
|
70
|
+
image = :success
|
71
|
+
else
|
72
|
+
image = :failed
|
73
|
+
end
|
74
|
+
Notifier.notify( messages.join("\n"), :title => "Puppet lint", :image => image )
|
31
75
|
end
|
32
76
|
end
|
33
77
|
end
|
@@ -1,7 +1,9 @@
|
|
1
1
|
# Add files and commands to this file, like the example:
|
2
2
|
# watch(%r{file/path}) { `command(s)` }
|
3
3
|
#
|
4
|
-
guard 'puppet-lint'
|
5
|
-
|
6
|
-
|
4
|
+
guard 'puppet-lint', :watchdir => Guard.options[:watchdir],
|
5
|
+
:show_warnings => false,
|
6
|
+
:syntax_check => true \
|
7
|
+
do
|
8
|
+
watch(/(.*).pp$/)
|
7
9
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: guard-puppet-lint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 2
|
9
|
+
- 0
|
10
|
+
version: 0.2.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Alister Bulman
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-
|
18
|
+
date: 2012-05-20 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
version_requirements: &id001 !ruby/object:Gem::Requirement
|
@@ -57,10 +57,24 @@ dependencies:
|
|
57
57
|
segments:
|
58
58
|
- 0
|
59
59
|
version: "0"
|
60
|
-
name:
|
60
|
+
name: libnotify
|
61
61
|
prerelease: false
|
62
62
|
type: :development
|
63
63
|
requirement: *id003
|
64
|
+
- !ruby/object:Gem::Dependency
|
65
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
hash: 3
|
71
|
+
segments:
|
72
|
+
- 0
|
73
|
+
version: "0"
|
74
|
+
name: guard
|
75
|
+
prerelease: false
|
76
|
+
type: :development
|
77
|
+
requirement: *id004
|
64
78
|
description: As Puppet manifest files change, run puppet-lint on them
|
65
79
|
email: abulman@gmail.com
|
66
80
|
executables: []
|