yamllint 0.0.3 → 0.0.4
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 +4 -4
- data/.coveralls.yml +1 -0
- data/.travis.yml +4 -0
- data/CHANGELOG.md +8 -2
- data/README.md +22 -1
- data/Rakefile +20 -4
- data/lib/yamllint/cli.rb +26 -8
- data/lib/yamllint/linter.rb +60 -32
- data/lib/yamllint/rake_task.rb +7 -1
- data/lib/yamllint/version.rb +2 -3
- data/lib/yamllint.rb +0 -1
- data/spec/cli_spec.rb +13 -3
- data/spec/data/custom_extension.eyaml +2 -0
- data/spec/data/valid_very_complex.yaml +22 -0
- data/spec/data/wrong_extension.txt +2 -0
- data/spec/linter_spec.rb +29 -2
- data/spec/spec_helper.rb +3 -0
- data/yamllint.gemspec +1 -0
- metadata +23 -8
- data/spec/data/overlapping_keys_complex.yaml +0 -7
- data/spec/data/valid_complex.yml +0 -112
- data/spec/data/wrong_extention.txt +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ae94dc3781c210160d5a36ddf4cd43cf0b8e947b
|
4
|
+
data.tar.gz: 4839ef892b6b0bab25e695c50bf49db96b619cc1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 133c438fb631b7dae2ba2d3fdce58146969815ea5dd96f04fb851a05142a7f7e839f2fe309403d9ea0219bb1797ff9b7984a46b8bdfbf6a1cc903ee8c7c59e46
|
7
|
+
data.tar.gz: d9f60cc006b7474918156553868d32d166cfe00bdacc80a7e3ebc08489499084bc0f4bef3e73b839c94c9f108ab72fdf49a57555dc1731f5faf244105b3e4656
|
data/.coveralls.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
service_name: travis-ci
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -2,17 +2,23 @@ YamlLint gem CHANGELOG
|
|
2
2
|
======================
|
3
3
|
This file is used to list changes made in each version of the YamlLint gem.
|
4
4
|
|
5
|
+
v0.0.4 (????-??-??)
|
6
|
+
-------------------
|
7
|
+
- Clean up code by extracting out complex_type_start
|
8
|
+
- Extract out valid extensions to an array
|
9
|
+
- Allow disabling of the file extension check
|
10
|
+
- Allow custom file extensions
|
11
|
+
|
5
12
|
v0.0.3 (2015-01-15)
|
6
13
|
-------------------
|
7
14
|
- **[ISSUE #1](https://github.com/shortdudey123/yamllint/issues/1)** - Add more verbose output
|
8
|
-
- **[ISSUE #2](https://github.com/shortdudey123/yamllint/issues/2)** - Add file
|
15
|
+
- **[ISSUE #2](https://github.com/shortdudey123/yamllint/issues/2)** - Add file extension verification
|
9
16
|
- add fail_on_error option to rake task
|
10
17
|
|
11
18
|
v0.0.2 (2015-01-15)
|
12
19
|
-------------------
|
13
20
|
- Fix rake_task filename
|
14
21
|
|
15
|
-
|
16
22
|
v0.0.1 (2015-01-15)
|
17
23
|
-------------------
|
18
24
|
- Initial gem publish
|
data/README.md
CHANGED
@@ -2,6 +2,9 @@
|
|
2
2
|
|
3
3
|
[](https://travis-ci.org/shortdudey123/yamllint)
|
4
4
|
[](https://rubygems.org/gems/yamllint)
|
5
|
+
[](https://coveralls.io/r/shortdudey123/yamllint?branch=master)
|
6
|
+
[](https://codeclimate.com/github/shortdudey123/yamllint)
|
7
|
+
[](https://gemnasium.com/shortdudey123/yamllint)
|
5
8
|
|
6
9
|
Checks YAML files for correct syntax. Currently it checks for:
|
7
10
|
|
@@ -49,6 +52,15 @@ spec/data/spaces.yaml
|
|
49
52
|
$
|
50
53
|
```
|
51
54
|
|
55
|
+
#### CLI options
|
56
|
+
|
57
|
+
| Short | Long | Description | Default |
|
58
|
+
| ------------- | ------------- | ------------- | ------------- |
|
59
|
+
| `-d` | `--disable-ext-check` | Disable file extension check | `false` |
|
60
|
+
| `-e` | `--extensions=` | Add more allowed extensions (comma delimited list) | `nil` |
|
61
|
+
| `-v` | `--version` | Print version and exit | `false` |
|
62
|
+
| `-h` | `--help` | Show help message | `false` |
|
63
|
+
|
52
64
|
### Rake task
|
53
65
|
|
54
66
|
You can integrate yamllint into your build process by adding a Rake task to your project
|
@@ -81,7 +93,16 @@ spec/data/spaces.yaml
|
|
81
93
|
$
|
82
94
|
```
|
83
95
|
|
84
|
-
|
96
|
+
#### Rake task options
|
97
|
+
|
98
|
+
Add these options similarly to the path option seen above.
|
99
|
+
|
100
|
+
| Option | Description | Default |
|
101
|
+
| ------------- | ------------- | ------------- | ------------- |
|
102
|
+
| `disable_ext_check` | Disable file extension check | `false` |
|
103
|
+
| `extensions` | Add more allowed extensions (list)| `nil` |
|
104
|
+
| `fail_on_error` | Continue on to the next rake task and don't fail even if YamlLint finds errors | `true` |
|
105
|
+
| `path` | List of files or paths to lint | `nil` |
|
85
106
|
|
86
107
|
## Contributing
|
87
108
|
|
data/Rakefile
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'bundler/gem_tasks'
|
2
2
|
require 'rubocop/rake_task'
|
3
|
-
|
4
3
|
require 'rspec/core/rake_task'
|
4
|
+
require 'yamllint/rake_task'
|
5
5
|
|
6
6
|
RSpec::Core::RakeTask.new(:spec)
|
7
7
|
|
@@ -12,8 +12,24 @@ end
|
|
12
12
|
|
13
13
|
desc 'rubocop compliancy checks'
|
14
14
|
RuboCop::RakeTask.new(:rubocop) do |t|
|
15
|
-
t.patterns = %w{
|
16
|
-
|
15
|
+
t.patterns = %w{ lib/**/*.rb lib/*.rb spec/*.rb }
|
16
|
+
end
|
17
|
+
|
18
|
+
desc 'yamllint rake test'
|
19
|
+
YamlLint::RakeTask.new do |t|
|
20
|
+
t.paths = %w{ spec/data/valid* }
|
21
|
+
end
|
22
|
+
|
23
|
+
desc 'yamllint rake test disabled file ext check'
|
24
|
+
YamlLint::RakeTask.new(:yamlling_disable_ext_check) do |t|
|
25
|
+
t.paths = %w{ spec/data/wrong_extension.txt }
|
26
|
+
t.disable_ext_check = true
|
27
|
+
end
|
28
|
+
|
29
|
+
desc 'yamllint rake test disabled file ext check'
|
30
|
+
YamlLint::RakeTask.new(:yamlling_custom_ext) do |t|
|
31
|
+
t.paths = %w{ spec/data/custom_extension.eyaml }
|
32
|
+
t.extensions = %w{ eyaml }
|
17
33
|
end
|
18
34
|
|
19
|
-
task default: [:rubocop, :spec]
|
35
|
+
task default: [:rubocop, :yamllint, :yamlling_disable_ext_check, :yamlling_custom_ext, :spec]
|
data/lib/yamllint/cli.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'trollop'
|
2
|
+
require 'pry'
|
2
3
|
|
3
4
|
module YamlLint
|
4
5
|
###
|
@@ -7,19 +8,20 @@ module YamlLint
|
|
7
8
|
class CLI
|
8
9
|
attr_reader :opts
|
9
10
|
|
11
|
+
# setup CLI options
|
10
12
|
def initialize(argv, stdin = STDIN, stdout = STDOUT, stderr = STDERR,
|
11
13
|
kernel = Kernel)
|
12
14
|
@argv, @stdin, @stdout, @stderr, @kernel = argv, stdin, stdout,
|
13
15
|
stderr, kernel
|
14
16
|
end
|
15
17
|
|
18
|
+
# Run the CLI command
|
16
19
|
def execute!
|
17
|
-
parse_options
|
20
|
+
files_to_check = parse_options.leftovers
|
18
21
|
|
19
|
-
|
20
|
-
|
21
|
-
no_yamls_to_check_msg
|
22
|
-
Trollop.die no_yamls_to_check_msg if files_to_check.empty?
|
22
|
+
no_yamls_to_check_msg = "Error: need at least one YAML file to check.\n"\
|
23
|
+
'Try --help for help.'
|
24
|
+
abort(no_yamls_to_check_msg) if files_to_check.empty?
|
23
25
|
lint(files_to_check)
|
24
26
|
end
|
25
27
|
|
@@ -40,7 +42,10 @@ module YamlLint
|
|
40
42
|
end
|
41
43
|
|
42
44
|
def lint_files(files_to_check)
|
43
|
-
|
45
|
+
ext = opts.extensions.split(',') unless opts.extensions.nil?
|
46
|
+
linter = YamlLint::Linter.new(disable_ext_check: opts.disable_ext_check,
|
47
|
+
extensions: ext
|
48
|
+
)
|
44
49
|
begin
|
45
50
|
puts "Checking #{files_to_check.flatten.length} files"
|
46
51
|
linter.check_all(files_to_check)
|
@@ -64,14 +69,27 @@ module YamlLint
|
|
64
69
|
linter
|
65
70
|
end
|
66
71
|
|
67
|
-
def
|
68
|
-
|
72
|
+
def setup_options
|
73
|
+
Trollop::Parser.new do
|
69
74
|
banner 'Usage: yamllint [options] file1.yaml [file2.yaml ...]'
|
70
75
|
version(YamlLint::VERSION)
|
71
76
|
|
72
77
|
banner ''
|
73
78
|
banner 'Options:'
|
79
|
+
opt :disable_ext_check, 'Disable file extension check', default: false
|
80
|
+
opt :extensions, 'Add more allowed extensions (comma delimited list)',
|
81
|
+
type: :string
|
74
82
|
end
|
75
83
|
end
|
84
|
+
|
85
|
+
def parse_options
|
86
|
+
p = setup_options
|
87
|
+
|
88
|
+
@opts = Trollop.with_standard_exception_handling p do
|
89
|
+
p.parse(@argv)
|
90
|
+
end
|
91
|
+
|
92
|
+
p
|
93
|
+
end
|
76
94
|
end
|
77
95
|
end
|
data/lib/yamllint/linter.rb
CHANGED
@@ -9,22 +9,38 @@ module YamlLint
|
|
9
9
|
#
|
10
10
|
class Linter
|
11
11
|
attr_reader :errors
|
12
|
-
|
13
|
-
|
12
|
+
attr_reader :valid_extensions
|
13
|
+
attr_reader :disable_extension_check
|
14
|
+
attr_reader :extensions
|
15
|
+
|
16
|
+
# Initilize the linter
|
17
|
+
# Params:
|
18
|
+
# +disable_ext_check+:: Disables file extension check (optional, false)
|
19
|
+
def initialize(opts = {})
|
14
20
|
@errors = {}
|
21
|
+
@valid_extensions = %w(yaml yml)
|
22
|
+
|
23
|
+
@disable_extension_check = opts[:disable_ext_check] || false
|
24
|
+
@extensions = opts[:extensions]
|
25
|
+
|
26
|
+
@valid_extensions += @extensions unless @extensions.nil?
|
15
27
|
end
|
16
28
|
|
29
|
+
# Check a list of files
|
17
30
|
def check_all(*files_to_check)
|
18
31
|
files_to_check.flatten.each { |f| check(f) }
|
19
32
|
end
|
20
33
|
|
34
|
+
# Check a single file
|
21
35
|
def check(path)
|
22
36
|
fail FileNotFoundError, "#{path}: no such file" unless File.exist?(path)
|
23
37
|
|
24
38
|
valid = false
|
25
|
-
unless
|
26
|
-
|
27
|
-
|
39
|
+
unless disable_extension_check
|
40
|
+
unless check_filename(path)
|
41
|
+
errors[path] = ['File extension must be .yaml or .yml']
|
42
|
+
return valid
|
43
|
+
end
|
28
44
|
end
|
29
45
|
|
30
46
|
File.open(path, 'r') do |f|
|
@@ -36,6 +52,7 @@ module YamlLint
|
|
36
52
|
valid
|
37
53
|
end
|
38
54
|
|
55
|
+
# Check an IO stream
|
39
56
|
def check_stream(io_stream)
|
40
57
|
yaml_data = io_stream.read
|
41
58
|
error_array = []
|
@@ -46,14 +63,17 @@ module YamlLint
|
|
46
63
|
valid
|
47
64
|
end
|
48
65
|
|
66
|
+
# Are there any lint errors found?
|
49
67
|
def errors?
|
50
68
|
!errors.empty?
|
51
69
|
end
|
52
70
|
|
71
|
+
# Return the number of lint errors found
|
53
72
|
def errors_count
|
54
73
|
errors.length
|
55
74
|
end
|
56
75
|
|
76
|
+
# Output the lint errors
|
57
77
|
def display_errors
|
58
78
|
errors.each do |path, errors|
|
59
79
|
puts path
|
@@ -65,21 +85,24 @@ module YamlLint
|
|
65
85
|
|
66
86
|
private
|
67
87
|
|
88
|
+
# Check file extension
|
68
89
|
def check_filename(filename)
|
69
|
-
|
70
|
-
return true if
|
90
|
+
extension = filename.split('.').last
|
91
|
+
return true if valid_extensions.include?(extension)
|
71
92
|
false
|
72
93
|
end
|
73
94
|
|
95
|
+
# Check the data in the file or stream
|
74
96
|
def check_data(yaml_data, errors_array)
|
75
|
-
valid = check_not_empty(yaml_data, errors_array)
|
76
|
-
valid &&= check_syntax_valid(yaml_data, errors_array)
|
77
|
-
valid &&= check_overlapping_keys(yaml_data, errors_array)
|
97
|
+
valid = check_not_empty?(yaml_data, errors_array)
|
98
|
+
valid &&= check_syntax_valid?(yaml_data, errors_array)
|
99
|
+
valid &&= check_overlapping_keys?(yaml_data, errors_array)
|
78
100
|
|
79
101
|
valid
|
80
102
|
end
|
81
103
|
|
82
|
-
|
104
|
+
# Check that the data is not empty
|
105
|
+
def check_not_empty?(yaml_data, errors_array)
|
83
106
|
if yaml_data.empty?
|
84
107
|
errors_array << 'The YAML should not be an empty string'
|
85
108
|
false
|
@@ -91,15 +114,13 @@ module YamlLint
|
|
91
114
|
end
|
92
115
|
end
|
93
116
|
|
94
|
-
|
117
|
+
# Check that the data is valid YAML
|
118
|
+
def check_syntax_valid?(yaml_data, errors_array)
|
95
119
|
YAML.load(yaml_data)
|
96
120
|
true
|
97
121
|
rescue YAML::SyntaxError => e
|
98
122
|
errors_array << e.message
|
99
123
|
false
|
100
|
-
rescue YAML::ParseError => e
|
101
|
-
errors_array << e.message
|
102
|
-
false
|
103
124
|
end
|
104
125
|
|
105
126
|
###
|
@@ -108,6 +129,7 @@ module YamlLint
|
|
108
129
|
class KeyOverlapDetector
|
109
130
|
attr_reader :overlapping_keys
|
110
131
|
|
132
|
+
# Setup class variables
|
111
133
|
def initialize
|
112
134
|
@seen_keys = Set.new
|
113
135
|
@key_components = []
|
@@ -117,6 +139,7 @@ module YamlLint
|
|
117
139
|
@array_positions = []
|
118
140
|
end
|
119
141
|
|
142
|
+
# Get the data and send it off for duplicate key validation
|
120
143
|
def parse(psych_parse_data)
|
121
144
|
data_start = psych_parse_data.handler.root.children[0].children[0]
|
122
145
|
hash_start('')
|
@@ -126,6 +149,7 @@ module YamlLint
|
|
126
149
|
|
127
150
|
private
|
128
151
|
|
152
|
+
# Recusively check for duplicate keys
|
129
153
|
def parse_recurse(psych_parse_data, is_sequence = false)
|
130
154
|
is_key = false
|
131
155
|
psych_parse_data.children.each do |n|
|
@@ -151,27 +175,21 @@ module YamlLint
|
|
151
175
|
hash_end(@last_key.last)
|
152
176
|
is_key = false
|
153
177
|
@last_key.pop
|
154
|
-
else
|
155
|
-
YamlLint.logger.debug { "Unknown (#{n.class})" }
|
156
178
|
end
|
157
179
|
end
|
158
180
|
end
|
159
181
|
|
182
|
+
# Setup a new hash
|
160
183
|
def hash_start(key)
|
161
184
|
YamlLint.logger.debug { "hash_start: #{key.inspect}" }
|
162
185
|
|
163
|
-
|
164
|
-
when :hash
|
165
|
-
@key_components.push(key)
|
166
|
-
when :array
|
167
|
-
@key_components.push(@array_positions.last)
|
168
|
-
@array_positions[-1] += 1
|
169
|
-
end
|
186
|
+
complex_type_start(key)
|
170
187
|
|
171
188
|
@complex_type.push(:hash)
|
172
189
|
check_for_overlap!
|
173
190
|
end
|
174
191
|
|
192
|
+
# Tear down a hash
|
175
193
|
def hash_end(key)
|
176
194
|
YamlLint.logger.debug { "hash_end: #{key.inspect}" }
|
177
195
|
|
@@ -179,22 +197,18 @@ module YamlLint
|
|
179
197
|
@complex_type.pop
|
180
198
|
end
|
181
199
|
|
200
|
+
# Setup a new array
|
182
201
|
def array_start(key)
|
183
202
|
YamlLint.logger.debug { "array_start: #{key.inspect}" }
|
184
203
|
|
185
|
-
|
186
|
-
when :hash
|
187
|
-
@key_components.push(key)
|
188
|
-
when :array
|
189
|
-
@key_components.push(@array_positions.last)
|
190
|
-
@array_positions[-1] += 1
|
191
|
-
end
|
204
|
+
complex_type_start(key)
|
192
205
|
|
193
206
|
@complex_type.push(:array)
|
194
207
|
@array_positions.push(0)
|
195
208
|
check_for_overlap!
|
196
209
|
end
|
197
210
|
|
211
|
+
# Tear down the array
|
198
212
|
def array_end(key)
|
199
213
|
YamlLint.logger.debug { "array_end: #{key.inspect}" }
|
200
214
|
|
@@ -203,6 +217,7 @@ module YamlLint
|
|
203
217
|
@array_positions.pop
|
204
218
|
end
|
205
219
|
|
220
|
+
# Add a key / value pair
|
206
221
|
def add_value(value, key)
|
207
222
|
YamlLint.logger.debug { "add_value: #{value.inspect}, #{key.inspect}" }
|
208
223
|
|
@@ -219,6 +234,7 @@ module YamlLint
|
|
219
234
|
end
|
220
235
|
end
|
221
236
|
|
237
|
+
# Check for key overlap
|
222
238
|
def check_for_overlap!
|
223
239
|
full_key = @key_components.dup
|
224
240
|
YamlLint.logger.debug { "Checking #{full_key.join('.')} for overlap" }
|
@@ -227,9 +243,21 @@ module YamlLint
|
|
227
243
|
YamlLint.logger.debug { "Overlapping key #{full_key.join('.')}" }
|
228
244
|
@overlapping_keys << full_key
|
229
245
|
end
|
246
|
+
|
247
|
+
# Setup common hash and array elements
|
248
|
+
def complex_type_start(key)
|
249
|
+
case @complex_type.last
|
250
|
+
when :hash
|
251
|
+
@key_components.push(key)
|
252
|
+
when :array
|
253
|
+
@key_components.push(@array_positions.last)
|
254
|
+
@array_positions[-1] += 1
|
255
|
+
end
|
256
|
+
end
|
230
257
|
end
|
231
258
|
|
232
|
-
|
259
|
+
# Check if there is overlapping key
|
260
|
+
def check_overlapping_keys?(yaml_data, errors_array)
|
233
261
|
overlap_detector = KeyOverlapDetector.new
|
234
262
|
data = Psych.parser.parse(yaml_data)
|
235
263
|
|
data/lib/yamllint/rake_task.rb
CHANGED
@@ -11,10 +11,14 @@ module YamlLint
|
|
11
11
|
attr_accessor :name
|
12
12
|
attr_accessor :paths
|
13
13
|
attr_accessor :fail_on_error
|
14
|
+
attr_accessor :disable_ext_check
|
15
|
+
attr_accessor :extensions
|
14
16
|
|
15
17
|
def initialize(name = :yamllint)
|
16
18
|
@name = name
|
17
19
|
@fail_on_error = true
|
20
|
+
@disable_ext_check = false
|
21
|
+
@extensions = nil
|
18
22
|
|
19
23
|
yield self if block_given?
|
20
24
|
|
@@ -23,6 +27,7 @@ module YamlLint
|
|
23
27
|
|
24
28
|
private
|
25
29
|
|
30
|
+
# Rake task
|
26
31
|
def define_task
|
27
32
|
desc 'Run yamllint' unless ::Rake.application.last_comment
|
28
33
|
|
@@ -33,7 +38,8 @@ module YamlLint
|
|
33
38
|
|
34
39
|
puts "Checking #{files_to_check.flatten.length} files"
|
35
40
|
|
36
|
-
linter = ::YamlLint::Linter.new
|
41
|
+
linter = ::YamlLint::Linter.new(disable_ext_check: disable_ext_check,
|
42
|
+
extensions: extensions)
|
37
43
|
linter.check_all(files_to_check)
|
38
44
|
|
39
45
|
if linter.errors?
|
data/lib/yamllint/version.rb
CHANGED
data/lib/yamllint.rb
CHANGED
data/spec/cli_spec.rb
CHANGED
@@ -41,9 +41,19 @@ describe 'yamllint' do
|
|
41
41
|
assert_failing_with('no such file')
|
42
42
|
end
|
43
43
|
|
44
|
-
it 'should fail with an invalid YAML file
|
45
|
-
yamllint spec_data('
|
46
|
-
assert_failing_with('File
|
44
|
+
it 'should fail with an invalid YAML file extension' do
|
45
|
+
yamllint spec_data('wrong_extension.txt')
|
46
|
+
assert_failing_with('File extension must be .yaml or .yml')
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'should pass with invalid file extension and extension check disabled' do
|
50
|
+
yamllint "-d #{spec_data('wrong_extension.txt')}"
|
51
|
+
assert_success(true)
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'should pass with custom extension' do
|
55
|
+
yamllint "-e eyaml #{spec_data('custom_extension.eyaml')}"
|
56
|
+
assert_success(true)
|
47
57
|
end
|
48
58
|
|
49
59
|
it 'should fail with a path that is unreadable' do
|
data/spec/linter_spec.rb
CHANGED
@@ -4,6 +4,10 @@ require 'yamllint/linter'
|
|
4
4
|
describe 'YamlLint::Linter' do
|
5
5
|
let(:linter) { YamlLint::Linter.new }
|
6
6
|
|
7
|
+
before do
|
8
|
+
allow(linter).to receive(:puts)
|
9
|
+
end
|
10
|
+
|
7
11
|
it 'should throw an exception if given a bogus path' do
|
8
12
|
expect { linter.check('/does/not/exist') }.to raise_error
|
9
13
|
end
|
@@ -11,10 +15,33 @@ describe 'YamlLint::Linter' do
|
|
11
15
|
it 'should be happy with a valid YAML file' do
|
12
16
|
expect(linter.check(spec_data('valid.yaml'))).to be(true)
|
13
17
|
expect(linter.check(spec_data('valid_complex.yaml'))).to be(true)
|
18
|
+
expect(linter.check(spec_data('valid_very_complex.yaml'))).to be(true)
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should have 0 error count with a valid YAML file' do
|
22
|
+
linter.check(spec_data('valid.yaml'))
|
23
|
+
expect(linter.errors_count).to eq(0)
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'should have 1 error count with a empty YAML file' do
|
27
|
+
linter.check(spec_data('empty.yaml'))
|
28
|
+
expect(linter.errors_count).to eq(1)
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should display errors for empty YAML file' do
|
32
|
+
linter.check(spec_data('empty.yaml'))
|
33
|
+
error_array = linter.display_errors
|
34
|
+
error_array_expected = ['The YAML should not be an empty string']
|
35
|
+
expect(error_array.first[1]).to eq(error_array_expected)
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'should be happy with a multiple valid YAML files' do
|
39
|
+
linter.check_all([spec_data('valid.yaml'), spec_data('valid_complex.yaml')])
|
40
|
+
expect(linter.errors?).to be(false)
|
14
41
|
end
|
15
42
|
|
16
|
-
it 'should be unhappy with an invalid YAML file
|
17
|
-
expect(linter.check(spec_data('
|
43
|
+
it 'should be unhappy with an invalid YAML file extension' do
|
44
|
+
expect(linter.check(spec_data('wrong_extension.txt'))).to be(false)
|
18
45
|
end
|
19
46
|
|
20
47
|
it 'should be unhappy with an invalid YAML file' do
|
data/spec/spec_helper.rb
CHANGED
data/yamllint.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yamllint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Grant Ridder
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-02-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: trollop
|
@@ -108,6 +108,20 @@ dependencies:
|
|
108
108
|
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: coveralls
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
111
125
|
description: Checks YAML files for correct syntax
|
112
126
|
email:
|
113
127
|
- shortdudey123@gmail.com
|
@@ -116,6 +130,7 @@ executables:
|
|
116
130
|
extensions: []
|
117
131
|
extra_rdoc_files: []
|
118
132
|
files:
|
133
|
+
- ".coveralls.yml"
|
119
134
|
- ".gitignore"
|
120
135
|
- ".rspec"
|
121
136
|
- ".rubocop.yml"
|
@@ -134,16 +149,16 @@ files:
|
|
134
149
|
- lib/yamllint/rake_task.rb
|
135
150
|
- lib/yamllint/version.rb
|
136
151
|
- spec/cli_spec.rb
|
152
|
+
- spec/data/custom_extension.eyaml
|
137
153
|
- spec/data/empty.yaml
|
138
154
|
- spec/data/invalid.yaml
|
139
155
|
- spec/data/overlapping_keys.yaml
|
140
|
-
- spec/data/overlapping_keys_complex.yaml
|
141
156
|
- spec/data/overlapping_keys_deep.yaml
|
142
157
|
- spec/data/spaces.yaml
|
143
158
|
- spec/data/valid.yaml
|
144
159
|
- spec/data/valid_complex.yaml
|
145
|
-
- spec/data/
|
146
|
-
- spec/data/
|
160
|
+
- spec/data/valid_very_complex.yaml
|
161
|
+
- spec/data/wrong_extension.txt
|
147
162
|
- spec/linter_spec.rb
|
148
163
|
- spec/spec_helper.rb
|
149
164
|
- yamllint.gemspec
|
@@ -173,15 +188,15 @@ specification_version: 4
|
|
173
188
|
summary: YAML lint checker
|
174
189
|
test_files:
|
175
190
|
- spec/cli_spec.rb
|
191
|
+
- spec/data/custom_extension.eyaml
|
176
192
|
- spec/data/empty.yaml
|
177
193
|
- spec/data/invalid.yaml
|
178
194
|
- spec/data/overlapping_keys.yaml
|
179
|
-
- spec/data/overlapping_keys_complex.yaml
|
180
195
|
- spec/data/overlapping_keys_deep.yaml
|
181
196
|
- spec/data/spaces.yaml
|
182
197
|
- spec/data/valid.yaml
|
183
198
|
- spec/data/valid_complex.yaml
|
184
|
-
- spec/data/
|
185
|
-
- spec/data/
|
199
|
+
- spec/data/valid_very_complex.yaml
|
200
|
+
- spec/data/wrong_extension.txt
|
186
201
|
- spec/linter_spec.rb
|
187
202
|
- spec/spec_helper.rb
|
data/spec/data/valid_complex.yml
DELETED
@@ -1,112 +0,0 @@
|
|
1
|
-
---
|
2
|
-
YAML: YAML Ain't Markup Language
|
3
|
-
|
4
|
-
What It Is: YAML is a human friendly data serialization
|
5
|
-
standard for all programming languages.
|
6
|
-
|
7
|
-
YAML Resources:
|
8
|
-
YAML 1.2 (3rd Edition): http://yaml.org/spec/1.2/spec.html
|
9
|
-
YAML 1.1 (2nd Edition): http://yaml.org/spec/1.1/
|
10
|
-
YAML 1.0 (1st Edition): http://yaml.org/spec/1.0/
|
11
|
-
YAML Issues Page: https://github.com/yaml/yaml/issues
|
12
|
-
YAML Mailing List: yaml-core@lists.sourceforge.net
|
13
|
-
YAML IRC Channel: "#yaml on irc.freenode.net"
|
14
|
-
YAML Cookbook (Ruby): http://yaml4r.sourceforge.net/cookbook/ (local)
|
15
|
-
YAML Reference Parser: http://yaml.org/ypaste/
|
16
|
-
|
17
|
-
Projects:
|
18
|
-
C/C++ Libraries:
|
19
|
-
- libyaml # "C" Fast YAML 1.1
|
20
|
-
- Syck # (dated) "C" YAML 1.0
|
21
|
-
- yaml-cpp # C++ YAML 1.2 implementation
|
22
|
-
Ruby:
|
23
|
-
- psych # libyaml wrapper (in Ruby core for 1.9.2)
|
24
|
-
- RbYaml # YAML 1.1 (PyYaml Port)
|
25
|
-
- yaml4r # YAML 1.0, standard library syck binding
|
26
|
-
Python:
|
27
|
-
- PyYaml # YAML 1.1, pure python and libyaml binding
|
28
|
-
- PySyck # YAML 1.0, syck binding
|
29
|
-
Java:
|
30
|
-
- JvYaml # Java port of RbYaml
|
31
|
-
- SnakeYAML # Java 5 / YAML 1.1
|
32
|
-
- YamlBeans # To/from JavaBeans
|
33
|
-
- JYaml # Original Java Implementation
|
34
|
-
Perl Modules:
|
35
|
-
- YAML # Pure Perl YAML Module
|
36
|
-
- YAML::XS # Binding to libyaml
|
37
|
-
- YAML::Syck # Binding to libsyck
|
38
|
-
- YAML::Tiny # A small YAML subset module
|
39
|
-
- PlYaml # Perl port of PyYaml
|
40
|
-
C#/.NET:
|
41
|
-
- yaml-net # YAML 1.1 library
|
42
|
-
- yatools.net # (in-progress) YAML 1.1 implementation
|
43
|
-
PHP:
|
44
|
-
- php-yaml # libyaml bindings (YAML 1.1)
|
45
|
-
- syck # syck bindings (YAML 1.0)
|
46
|
-
- spyc # yaml loader/dumper (YAML 1.?)
|
47
|
-
OCaml:
|
48
|
-
- ocaml-syck # YAML 1.0 via syck bindings
|
49
|
-
Javascript:
|
50
|
-
- JS-YAML # Native PyYAML port to JavaScript.
|
51
|
-
- JS-YAML Online# Browserified JS-YAML demo, to play with YAML in your browser.
|
52
|
-
Actionscript:
|
53
|
-
- as3yaml # port of JvYAML (1.1)
|
54
|
-
Haskell:
|
55
|
-
- YamlReference # Haskell 1.2 reference parser
|
56
|
-
Others:
|
57
|
-
- yamlvim (src) # YAML dumper/emitter in pure vimscript
|
58
|
-
|
59
|
-
Related Projects:
|
60
|
-
- Rx # Multi-Language Schemata Tool for JSON/YAML
|
61
|
-
- Kwalify # Ruby Schemata Tool for JSON/YAML
|
62
|
-
- yaml_vim # vim syntax files for YAML
|
63
|
-
- yatools.net # Visual Studio editor for YAML
|
64
|
-
- JSON # Official JSON Website
|
65
|
-
- Pygments # Python language Syntax Colorizer /w YAML support
|
66
|
-
|
67
|
-
News:
|
68
|
-
- 20-NOV-2011 -- JS-YAML, a JavaScript YAML parser by Alexey Zapparov and Vitaly Puzrin.
|
69
|
-
- 18-AUG-2010 -- Ruby 1.9.2 includes psych, a libyaml wrapper by Aaron Patterson.
|
70
|
-
- 17-AUG-2010 -- vimscript parser/emitter was created by Nikolay Pavlov.
|
71
|
-
- 01-OCT-2009 -- YAML 1.2 (3rd Edition) was patched.
|
72
|
-
- 21-JUL-2009 -- YAML 1.2 (3rd Edition) was released.
|
73
|
-
- 28-APR-2009 -- A new version of SnakeYAML was released.
|
74
|
-
- 01-APR-2009 -- The YAML 1.2 spec was planned to be finalized by the end of the month.
|
75
|
-
- 07-JAN-2009 -- Andrey Somov releases SnakeYAML, a 1.1 YAML Parser
|
76
|
-
- 03-JAN-2009 -- Burt Harris announced YAML for .NET and editor for Visual Studio
|
77
|
-
- 02-DEC-2008 -- Jesse Beder released YAML for C++
|
78
|
-
- 11-MAY-2008 -- Oren Ben-Kiki has released a new YAML 1.2 spec draft
|
79
|
-
- 29-NOV-2007 -- Alexey Zakhlestin has updated his Syck (YAML 1.0) binding for PHP
|
80
|
-
- 23-NOV-2007 -- Derek Wischusen has release Action Script 3 YAML 1.1
|
81
|
-
- 01-AUG-2006 -- Kirill Simonov has released libyaml, a parser and emitter in "C"
|
82
|
-
- 06-JUN-2006 -- Ola Bini is at it again, this time with a Java implementation
|
83
|
-
- 03-JUN-2006 -- Christophe Lambrechts and Jonathan Slenders announced a .NET parser
|
84
|
-
- 07-MAY-2006 -- Ola Bini released a pure-ruby YAML 1.1 parser and emitter
|
85
|
-
- 12-APR-2006 -- Kirill's YAML 1.1 parser for Python is now at PyYaml
|
86
|
-
- 05-FEB-2006 -- Spyc YAML for PHP is now at version 0.3
|
87
|
-
- 17-DEC-2005 -- Makoto Kuwata has released Kwalify 0.5, YAML/JSON schema validator
|
88
|
-
- 14-DEC-2005 -- Toby Ho has released Jyaml, a Java library for YAML based on Rolf Veen's work
|
89
|
-
- 30-AUG-2005 -- Kirill Simonov has produce a wonderful Python binding for Syck
|
90
|
-
- 08-APR-2005 -- As it turns out, YAML is a superset of the JSON serialization language
|
91
|
-
- 18-MAY-2005 -- Why has released version 0.55 of Syck
|
92
|
-
- 28-DEC-2004 -- Announcing YAML 1.1 Working Draft
|
93
|
-
- 01-OCT-2004 -- YAML for Cocoa was released by Will Thimbley
|
94
|
-
- 08-FEB-2004 -- Slaven Rezic announced a new version of his Javascript binding
|
95
|
-
- 29-JAN-2004 -- Ingy, Oren, and Clark spent 4 days hacking on the spec in Portland.
|
96
|
-
- 10-OCT-2003 -- The Syck implementation with bindings for Ruby, Python,
|
97
|
-
and PHP is now at version .41
|
98
|
-
- 26-APR-2003 -- Mike Orr has taken over the Pure Python development.
|
99
|
-
- 26-APR-2003 -- Brian Ingerson has created a FIT platform for Wiki-like testing.
|
100
|
-
- 24-JAN-2003 -- Updates to specification.
|
101
|
-
- 25-JUL-2002 -- Both the Ruby and Python parsers have made significant progress.
|
102
|
-
There is an article about YAML by Kendall Grant Clark at xml.com.
|
103
|
-
There is also a draft XML binding.
|
104
|
-
- 02-JUL-2002 -- Brian Ingerson will be giving a 45 minute presentation on YAML at the
|
105
|
-
O'Reilly Open Source Conference in San Diego on July 24th 2002.
|
106
|
-
- 01-FEB-2002 -- Brian's Perl implementation YAML.pm, has been updated with new documentation.
|
107
|
-
Included in this release is YSH, a test shell for learning how YAML works.
|
108
|
-
- 03-JAN-2002 -- YAML(tm) starts the new year with a new name YAML Ain't Markup Language.
|
109
|
-
- 17-MAY-2001 -- YAML now has a mailing list at SourceForge.
|
110
|
-
- 15-MAY-2001 -- YAML is started with a first pass specification.
|
111
|
-
# Maintained by Clark C. Evans
|
112
|
-
...
|
File without changes
|