puppet-syntax 1.1.1 → 1.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/CHANGELOG CHANGED
@@ -1,3 +1,6 @@
1
+ 2014-03-28 Release 1.2.0
2
+ - Optional support for Puppet's future parser.
3
+
1
4
  2014-03-17 Release 1.1.1
2
5
  - Ignore exit(1) from Puppet 3.4
3
6
  - Don't use hardcoded version of parser face.
data/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ [![Build Status](https://travis-ci.org/gds-operations/puppet-syntax.svg?branch=master)](https://travis-ci.org/gds-operations/puppet-syntax)
2
+
1
3
  # Puppet::Syntax
2
4
 
3
5
  Syntax checks for Puppet manifests, templates, and Hiera YAML.
@@ -48,6 +50,11 @@ Paths can be excluded with:
48
50
 
49
51
  PuppetSyntax.exclude_paths = ["vendor/**/*"]
50
52
 
53
+ When you are using a Puppet version greater then 3.2, you can select the future parse by specifying
54
+
55
+ PuppetSyntax.future_parser = true
56
+
57
+
51
58
  ## Installation
52
59
 
53
60
  Add this line to your application's Gemfile:
data/lib/puppet-syntax.rb CHANGED
@@ -5,10 +5,14 @@ require "puppet-syntax/hiera"
5
5
 
6
6
  module PuppetSyntax
7
7
  class << self
8
- attr_accessor :exclude_paths
8
+ attr_accessor :exclude_paths, :future_parser
9
9
 
10
10
  def exclude_paths
11
11
  @exclude_paths || []
12
12
  end
13
+
14
+ def future_parser
15
+ @future_parser || false
16
+ end
13
17
  end
14
18
  end
@@ -42,6 +42,7 @@ module PuppetSyntax
42
42
 
43
43
  private
44
44
  def validate_manifest(file)
45
+ Puppet[:parser] = 'future' if PuppetSyntax.future_parser
45
46
  Puppet::Face[:parser, :current].validate(file)
46
47
  end
47
48
  end
@@ -1,3 +1,3 @@
1
1
  module PuppetSyntax
2
- VERSION = "1.1.1"
2
+ VERSION = "1.2.0"
3
3
  end
@@ -22,6 +22,5 @@ Gem::Specification.new do |spec|
22
22
  spec.add_dependency "puppet", ">= 2.7.0"
23
23
 
24
24
  spec.add_development_dependency "bundler", "~> 1.3"
25
- spec.add_development_dependency "rake"
26
25
  spec.add_development_dependency "rspec"
27
26
  end
@@ -0,0 +1,3 @@
1
+ class module_with_future_syntax {
2
+ $a = $b = 10
3
+ }
@@ -54,4 +54,26 @@ describe PuppetSyntax::Manifests do
54
54
  res[1].should match(/Unrecognised escape sequence '\\\[' .* at line 3$/)
55
55
  res[2].should match(/Unrecognised escape sequence '\\\]' .* at line 3$/)
56
56
  end
57
+
58
+ if Puppet::Util::Package.versioncmp(Puppet.version, '3.2') >= 0
59
+ it 'should fail without setting future option to true on future manifest' do
60
+ PuppetSyntax.future_parser = false
61
+ files = fixture_manifests(['future_syntax.pp'])
62
+ res = subject.check(files)
63
+
64
+ res.should have(1).items
65
+ res[0].should match(/Syntax error at '='; expected '\}' .*:2$/)
66
+ end
67
+
68
+
69
+ it 'should pass with future option set to true on future manifest' do
70
+ PuppetSyntax.future_parser = true
71
+ files = fixture_manifests(['future_syntax.pp'])
72
+ res = subject.check(files)
73
+
74
+ res.should have(0).items
75
+ end
76
+ end
77
+
78
+
57
79
  end
@@ -9,4 +9,10 @@ describe PuppetSyntax do
9
9
  PuppetSyntax.exclude_paths = ["foo", "bar/baz"]
10
10
  PuppetSyntax.exclude_paths.should == ["foo", "bar/baz"]
11
11
  end
12
+
13
+ it 'should support future parser setting' do
14
+ PuppetSyntax.future_parser = true
15
+ PuppetSyntax.future_parser.should == true
16
+ end
17
+
12
18
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppet-syntax
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-03-17 00:00:00.000000000 Z
12
+ date: 2014-03-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -59,22 +59,6 @@ dependencies:
59
59
  - - ~>
60
60
  - !ruby/object:Gem::Version
61
61
  version: '1.3'
62
- - !ruby/object:Gem::Dependency
63
- name: rake
64
- requirement: !ruby/object:Gem::Requirement
65
- none: false
66
- requirements:
67
- - - ! '>='
68
- - !ruby/object:Gem::Version
69
- version: '0'
70
- type: :development
71
- prerelease: false
72
- version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
- requirements:
75
- - - ! '>='
76
- - !ruby/object:Gem::Version
77
- version: '0'
78
62
  - !ruby/object:Gem::Dependency
79
63
  name: rspec
80
64
  requirement: !ruby/object:Gem::Requirement
@@ -117,6 +101,7 @@ files:
117
101
  - spec/fixtures/hiera/hiera_good.yaml
118
102
  - spec/fixtures/test_module/manifests/fail_error.pp
119
103
  - spec/fixtures/test_module/manifests/fail_warning.pp
104
+ - spec/fixtures/test_module/manifests/future_syntax.pp
120
105
  - spec/fixtures/test_module/manifests/pass.pp
121
106
  - spec/fixtures/test_module/manifests/pass_storeconfigs.pp
122
107
  - spec/fixtures/test_module/templates/fail_error.erb
@@ -144,7 +129,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
144
129
  version: '0'
145
130
  segments:
146
131
  - 0
147
- hash: -1226069919684334403
132
+ hash: -2224316869698270261
148
133
  required_rubygems_version: !ruby/object:Gem::Requirement
149
134
  none: false
150
135
  requirements:
@@ -153,7 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
153
138
  version: '0'
154
139
  segments:
155
140
  - 0
156
- hash: -1226069919684334403
141
+ hash: -2224316869698270261
157
142
  requirements: []
158
143
  rubyforge_project:
159
144
  rubygems_version: 1.8.23
@@ -166,6 +151,7 @@ test_files:
166
151
  - spec/fixtures/hiera/hiera_good.yaml
167
152
  - spec/fixtures/test_module/manifests/fail_error.pp
168
153
  - spec/fixtures/test_module/manifests/fail_warning.pp
154
+ - spec/fixtures/test_module/manifests/future_syntax.pp
169
155
  - spec/fixtures/test_module/manifests/pass.pp
170
156
  - spec/fixtures/test_module/manifests/pass_storeconfigs.pp
171
157
  - spec/fixtures/test_module/templates/fail_error.erb