yamllint 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +34 -0
- data/.rspec +1 -0
- data/.rubocop.yml +1 -0
- data/.rubocop_todo.yml +28 -0
- data/.travis.yml +6 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +90 -0
- data/Rakefile +19 -0
- data/bin/yamllint +8 -0
- data/lib/yamllint.rb +16 -0
- data/lib/yamllint/cli.rb +74 -0
- data/lib/yamllint/errors.rb +3 -0
- data/lib/yamllint/linter.rb +232 -0
- data/lib/yamllint/rake_tast.rb +40 -0
- data/lib/yamllint/version.rb +7 -0
- data/spec/cli_spec.rb +64 -0
- data/spec/data/empty.yaml +0 -0
- data/spec/data/invalid.yaml +1 -0
- data/spec/data/overlapping_keys.yaml +3 -0
- data/spec/data/overlapping_keys_complex.yaml +7 -0
- data/spec/data/overlapping_keys_deep.yaml +7 -0
- data/spec/data/spaces.yaml +1 -0
- data/spec/data/valid.yaml +10 -0
- data/spec/data/valid_complex.yaml +112 -0
- data/spec/data/valid_complex.yml +112 -0
- data/spec/linter_spec.rb +40 -0
- data/spec/spec_helper.rb +37 -0
- data/yamllint.gemspec +29 -0
- metadata +184 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5ccf1412af4fe00c2c7db531a1e9c20f72f934d5
|
4
|
+
data.tar.gz: 03e8922bf5ba374eb58fba1ba51a64ada6a5ed02
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9630dc14197ed3c907388245230729646c7aa0b89be5d3f6d23937b44a8841f2ea873eb9fc82552478f890793cbd3ff65376f7d6bccc45d4ab02b22683e5be00
|
7
|
+
data.tar.gz: d790f25607faad472dce8c251a7f8863b7b68dd1a5717970c5890f27b7821fb2030c3080d9e2a306487c3236303c8a62f9c73f7bf78847f4e2432f9dd9c46016
|
data/.gitignore
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/test/tmp/
|
9
|
+
/test/version_tmp/
|
10
|
+
/tmp/
|
11
|
+
|
12
|
+
## Specific to RubyMotion:
|
13
|
+
.dat*
|
14
|
+
.repl_history
|
15
|
+
build/
|
16
|
+
|
17
|
+
## Documentation cache and generated files:
|
18
|
+
/.yardoc/
|
19
|
+
/_yardoc/
|
20
|
+
/doc/
|
21
|
+
/rdoc/
|
22
|
+
|
23
|
+
## Environment normalisation:
|
24
|
+
/.bundle/
|
25
|
+
/lib/bundler/man/
|
26
|
+
|
27
|
+
# for a library or gem, you might want to ignore these files since the code is
|
28
|
+
# intended to run in multiple environments; otherwise, check them in:
|
29
|
+
Gemfile.lock
|
30
|
+
.ruby-version
|
31
|
+
.ruby-gemset
|
32
|
+
|
33
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
34
|
+
.rvmrc
|
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/.rubocop.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
inherit_from: .rubocop_todo.yml
|
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# This configuration was generated by `rubocop --auto-gen-config`
|
2
|
+
# on 2015-01-15 14:42:13 -0800 using RuboCop version 0.28.0.
|
3
|
+
# The point is for the user to remove these configuration records
|
4
|
+
# one by one as the offenses are removed from the code base.
|
5
|
+
# Note that changes in the inspected code, or installation of new
|
6
|
+
# versions of RuboCop, may require this file to be generated again.
|
7
|
+
|
8
|
+
# Offense count: 1
|
9
|
+
Metrics/AbcSize:
|
10
|
+
Max: 39
|
11
|
+
|
12
|
+
# Offense count: 1
|
13
|
+
# Configuration parameters: CountComments.
|
14
|
+
Metrics/ClassLength:
|
15
|
+
Max: 104
|
16
|
+
|
17
|
+
# Offense count: 1
|
18
|
+
Metrics/CyclomaticComplexity:
|
19
|
+
Max: 9
|
20
|
+
|
21
|
+
# Offense count: 3
|
22
|
+
# Configuration parameters: CountComments.
|
23
|
+
Metrics/MethodLength:
|
24
|
+
Max: 28
|
25
|
+
|
26
|
+
# Offense count: 1
|
27
|
+
Style/DoubleNegation:
|
28
|
+
Enabled: false
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Grant Ridder
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
22
|
+
|
data/README.md
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
# YamlLint
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/shortdudey123/yamllint.svg?branch=master)](https://travis-ci.org/shortdudey123/yamllint)
|
4
|
+
[![Gem Version](http://img.shields.io/gem/v/yamllint.svg)](https://rubygems.org/gems/yamllint)
|
5
|
+
|
6
|
+
Checks YAML files for correct syntax. Currently it checks for:
|
7
|
+
|
8
|
+
* Valid YAML syntax
|
9
|
+
* Overlapping key definitions in YAML files, where the last definition would win
|
10
|
+
|
11
|
+
This is a YAML version of [jsonlint](https://github.com/dougbarth/jsonlint)
|
12
|
+
|
13
|
+
## Installation
|
14
|
+
|
15
|
+
Add this line to your application's Gemfile:
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
gem 'yamllint'
|
19
|
+
```
|
20
|
+
|
21
|
+
And then execute:
|
22
|
+
|
23
|
+
$ bundle
|
24
|
+
|
25
|
+
Or install it yourself as:
|
26
|
+
|
27
|
+
$ gem install yamllint
|
28
|
+
|
29
|
+
## Usage
|
30
|
+
|
31
|
+
### CLI
|
32
|
+
|
33
|
+
You can run yamllint against a set of files in the command line. Any errors will be printed and the process will exit with a non-zero exit code.
|
34
|
+
|
35
|
+
```
|
36
|
+
$ yamllint spec/data/*
|
37
|
+
spec/data/empty.yaml
|
38
|
+
The YAML should not be an empty string
|
39
|
+
spec/data/invalid.yaml
|
40
|
+
(<unknown>): found character that cannot start any token while scanning for the next token at line 1 column 6
|
41
|
+
spec/data/overlapping_keys.yaml
|
42
|
+
The same key is defined more than once: foo
|
43
|
+
spec/data/overlapping_keys_complex.yaml
|
44
|
+
The same key is defined more than once: foo
|
45
|
+
spec/data/overlapping_keys_deep.yaml
|
46
|
+
The same key is defined more than once: foo
|
47
|
+
spec/data/spaces.yaml
|
48
|
+
The YAML should not just be spaces
|
49
|
+
$
|
50
|
+
```
|
51
|
+
|
52
|
+
### Rake task
|
53
|
+
|
54
|
+
You can integrate yamllint into your build process by adding a Rake task to your project
|
55
|
+
|
56
|
+
```ruby
|
57
|
+
require 'yamllint/rake_task'
|
58
|
+
YamlLint::RakeTask.new do |t|
|
59
|
+
t.paths = %w(
|
60
|
+
spec/**/*.yaml
|
61
|
+
)
|
62
|
+
end
|
63
|
+
```
|
64
|
+
|
65
|
+
Then run the rake task.
|
66
|
+
|
67
|
+
```
|
68
|
+
$ rake yamllint
|
69
|
+
spec/data/empty.yaml
|
70
|
+
The YAML should not be an empty string
|
71
|
+
spec/data/invalid.yaml
|
72
|
+
(<unknown>): found character that cannot start any token while scanning for the next token at line 1 column 6
|
73
|
+
spec/data/overlapping_keys.yaml
|
74
|
+
The same key is defined more than once: foo
|
75
|
+
spec/data/overlapping_keys_complex.yaml
|
76
|
+
The same key is defined more than once: foo
|
77
|
+
spec/data/overlapping_keys_deep.yaml
|
78
|
+
The same key is defined more than once: foo
|
79
|
+
spec/data/spaces.yaml
|
80
|
+
The YAML should not just be spaces
|
81
|
+
$
|
82
|
+
```
|
83
|
+
|
84
|
+
## Contributing
|
85
|
+
|
86
|
+
1. Fork it ( https://github.com/shortdudey123/yamllint/fork )
|
87
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
88
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
89
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
90
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rubocop/rake_task'
|
3
|
+
|
4
|
+
require 'rspec/core/rake_task'
|
5
|
+
|
6
|
+
RSpec::Core::RakeTask.new(:spec)
|
7
|
+
|
8
|
+
desc 'Run all linters on the codebase'
|
9
|
+
task :linters do
|
10
|
+
Rake::Task['rubocop'].invoke
|
11
|
+
end
|
12
|
+
|
13
|
+
desc 'rubocop compliancy checks'
|
14
|
+
RuboCop::RakeTask.new(:rubocop) do |t|
|
15
|
+
t.patterns = %w{ **/*.rb }
|
16
|
+
t.fail_on_error = false
|
17
|
+
end
|
18
|
+
|
19
|
+
task default: [:rubocop, :spec]
|
data/bin/yamllint
ADDED
data/lib/yamllint.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'logger'
|
2
|
+
|
3
|
+
require 'yamllint/version'
|
4
|
+
require 'yamllint/linter'
|
5
|
+
|
6
|
+
###
|
7
|
+
# = Overview
|
8
|
+
#
|
9
|
+
# YamlLint checks YAML files for correct syntax
|
10
|
+
module YamlLint
|
11
|
+
def self.logger
|
12
|
+
@logger ||= Logger.new(STDOUT).tap do |l|
|
13
|
+
l.level = Logger::INFO
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/yamllint/cli.rb
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'trollop'
|
2
|
+
|
3
|
+
module YamlLint
|
4
|
+
###
|
5
|
+
# CLI execution
|
6
|
+
#
|
7
|
+
class CLI
|
8
|
+
attr_reader :opts
|
9
|
+
|
10
|
+
def initialize(argv, stdin = STDIN, stdout = STDOUT, stderr = STDERR,
|
11
|
+
kernel = Kernel)
|
12
|
+
@argv, @stdin, @stdout, @stderr, @kernel = argv, stdin, stdout,
|
13
|
+
stderr, kernel
|
14
|
+
end
|
15
|
+
|
16
|
+
def execute!
|
17
|
+
parse_options
|
18
|
+
|
19
|
+
files_to_check = @argv
|
20
|
+
|
21
|
+
no_yamls_to_check_msg = 'nead at least one YAML file to check'
|
22
|
+
Trollop.die no_yamls_to_check_msg if files_to_check.empty?
|
23
|
+
lint(files_to_check)
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def lint(files_to_check)
|
29
|
+
if files_to_check == ['-']
|
30
|
+
linter = lint_stream
|
31
|
+
else
|
32
|
+
linter = lint_files(files_to_check)
|
33
|
+
end
|
34
|
+
|
35
|
+
return unless linter.errors?
|
36
|
+
linter.display_errors
|
37
|
+
@kernel.exit(1)
|
38
|
+
end
|
39
|
+
|
40
|
+
def lint_files(files_to_check)
|
41
|
+
linter = YamlLint::Linter.new
|
42
|
+
begin
|
43
|
+
linter.check_all(files_to_check)
|
44
|
+
rescue => e
|
45
|
+
@stderr.puts e.message
|
46
|
+
exit(1)
|
47
|
+
end
|
48
|
+
|
49
|
+
linter
|
50
|
+
end
|
51
|
+
|
52
|
+
def lint_stream
|
53
|
+
linter = YamlLint::Linter.new
|
54
|
+
begin
|
55
|
+
linter.check_stream(STDIN)
|
56
|
+
rescue => e
|
57
|
+
@stderr.puts e.message
|
58
|
+
exit(1)
|
59
|
+
end
|
60
|
+
|
61
|
+
linter
|
62
|
+
end
|
63
|
+
|
64
|
+
def parse_options
|
65
|
+
@opts = Trollop.options(@argv) do
|
66
|
+
banner 'Usage: yamllint [options] file1.yaml [file2.yaml ...]'
|
67
|
+
version(YamlLint::VERSION)
|
68
|
+
|
69
|
+
banner ''
|
70
|
+
banner 'Options:'
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,232 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require 'set'
|
3
|
+
require 'pry'
|
4
|
+
|
5
|
+
require 'yamllint/errors'
|
6
|
+
|
7
|
+
module YamlLint
|
8
|
+
###
|
9
|
+
# Runs the actual linting
|
10
|
+
#
|
11
|
+
class Linter
|
12
|
+
attr_reader :errors
|
13
|
+
|
14
|
+
def initialize
|
15
|
+
@errors = {}
|
16
|
+
end
|
17
|
+
|
18
|
+
def check_all(*files_to_check)
|
19
|
+
files_to_check.flatten.each { |f| check(f) }
|
20
|
+
end
|
21
|
+
|
22
|
+
def check(path)
|
23
|
+
fail FileNotFoundError, "#{path}: no such file" unless File.exist?(path)
|
24
|
+
|
25
|
+
valid = false
|
26
|
+
File.open(path, 'r') do |f|
|
27
|
+
error_array = []
|
28
|
+
valid = check_data(f.read, error_array)
|
29
|
+
errors[path] = error_array unless error_array.empty?
|
30
|
+
end
|
31
|
+
|
32
|
+
valid
|
33
|
+
end
|
34
|
+
|
35
|
+
def check_stream(io_stream)
|
36
|
+
yaml_data = io_stream.read
|
37
|
+
error_array = []
|
38
|
+
|
39
|
+
valid = check_data(yaml_data, error_array)
|
40
|
+
errors[''] = error_array unless error_array.empty?
|
41
|
+
|
42
|
+
valid
|
43
|
+
end
|
44
|
+
|
45
|
+
def errors?
|
46
|
+
!errors.empty?
|
47
|
+
end
|
48
|
+
|
49
|
+
def display_errors
|
50
|
+
errors.each do |path, errors|
|
51
|
+
puts path
|
52
|
+
errors.each do |err|
|
53
|
+
puts " #{err}"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
private
|
59
|
+
|
60
|
+
def check_data(yaml_data, errors_array)
|
61
|
+
valid = check_not_empty(yaml_data, errors_array)
|
62
|
+
valid &&= check_syntax_valid(yaml_data, errors_array)
|
63
|
+
valid &&= check_overlapping_keys(yaml_data, errors_array)
|
64
|
+
|
65
|
+
valid
|
66
|
+
end
|
67
|
+
|
68
|
+
def check_not_empty(yaml_data, errors_array)
|
69
|
+
if yaml_data.empty?
|
70
|
+
errors_array << 'The YAML should not be an empty string'
|
71
|
+
false
|
72
|
+
elsif yaml_data.strip.empty?
|
73
|
+
errors_array << 'The YAML should not just be spaces'
|
74
|
+
false
|
75
|
+
else
|
76
|
+
true
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def check_syntax_valid(yaml_data, errors_array)
|
81
|
+
YAML.load(yaml_data)
|
82
|
+
true
|
83
|
+
rescue YAML::SyntaxError => e
|
84
|
+
errors_array << e.message
|
85
|
+
false
|
86
|
+
rescue YAML::ParseError => e
|
87
|
+
errors_array << e.message
|
88
|
+
false
|
89
|
+
end
|
90
|
+
|
91
|
+
###
|
92
|
+
# Detects duplicate keys in Psych parsed data
|
93
|
+
#
|
94
|
+
class KeyOverlapDetector
|
95
|
+
attr_reader :overlapping_keys
|
96
|
+
|
97
|
+
def initialize
|
98
|
+
@seen_keys = Set.new
|
99
|
+
@key_components = []
|
100
|
+
@last_key = []
|
101
|
+
@overlapping_keys = Set.new
|
102
|
+
@complex_type = []
|
103
|
+
@array_positions = []
|
104
|
+
end
|
105
|
+
|
106
|
+
def parse(psych_parse_data)
|
107
|
+
data_start = psych_parse_data.handler.root.children[0].children[0]
|
108
|
+
hash_start('')
|
109
|
+
parse_recurse(data_start)
|
110
|
+
hash_end('')
|
111
|
+
end
|
112
|
+
|
113
|
+
private
|
114
|
+
|
115
|
+
def parse_recurse(psych_parse_data, is_sequence = false)
|
116
|
+
is_key = false
|
117
|
+
psych_parse_data.children.each do |n|
|
118
|
+
case n.class.to_s
|
119
|
+
when 'Psych::Nodes::Scalar'
|
120
|
+
is_key = !is_key unless is_sequence
|
121
|
+
@last_key.push(n.value) if is_key
|
122
|
+
add_value(n.value, @last_key.last) unless is_key
|
123
|
+
msg = "Scalar: #{n.value}, key: #{is_key}, last_key: #{@last_key}"
|
124
|
+
YamlLint.logger.debug { msg }
|
125
|
+
@last_key.pop if !is_key && !is_sequence
|
126
|
+
when 'Psych::Nodes::Sequence'
|
127
|
+
YamlLint.logger.debug { "Sequence: #{n.children}" }
|
128
|
+
array_start(@last_key.last)
|
129
|
+
parse_recurse(n, true)
|
130
|
+
array_end(@last_key.last)
|
131
|
+
is_key = false
|
132
|
+
@last_key.pop
|
133
|
+
when 'Psych::Nodes::Mapping'
|
134
|
+
YamlLint.logger.debug { "Mapping: #{n.children}" }
|
135
|
+
hash_start(@last_key.last)
|
136
|
+
parse_recurse(n)
|
137
|
+
hash_end(@last_key.last)
|
138
|
+
is_key = false
|
139
|
+
@last_key.pop
|
140
|
+
else
|
141
|
+
YamlLint.logger.debug { "Unknown (#{n.class})" }
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
def hash_start(key)
|
147
|
+
YamlLint.logger.debug { "hash_start: #{key.inspect}" }
|
148
|
+
|
149
|
+
case @complex_type.last
|
150
|
+
when :hash
|
151
|
+
@key_components.push(key)
|
152
|
+
when :array
|
153
|
+
@key_components.push(@array_positions.last)
|
154
|
+
@array_positions[-1] += 1
|
155
|
+
end
|
156
|
+
|
157
|
+
@complex_type.push(:hash)
|
158
|
+
check_for_overlap!
|
159
|
+
end
|
160
|
+
|
161
|
+
def hash_end(key)
|
162
|
+
YamlLint.logger.debug { "hash_end: #{key.inspect}" }
|
163
|
+
|
164
|
+
@key_components.pop
|
165
|
+
@complex_type.pop
|
166
|
+
end
|
167
|
+
|
168
|
+
def array_start(key)
|
169
|
+
YamlLint.logger.debug { "array_start: #{key.inspect}" }
|
170
|
+
|
171
|
+
case @complex_type.last
|
172
|
+
when :hash
|
173
|
+
@key_components.push(key)
|
174
|
+
when :array
|
175
|
+
@key_components.push(@array_positions.last)
|
176
|
+
@array_positions[-1] += 1
|
177
|
+
end
|
178
|
+
|
179
|
+
@complex_type.push(:array)
|
180
|
+
@array_positions.push(0)
|
181
|
+
check_for_overlap!
|
182
|
+
end
|
183
|
+
|
184
|
+
def array_end(key)
|
185
|
+
YamlLint.logger.debug { "array_end: #{key.inspect}" }
|
186
|
+
|
187
|
+
@key_components.pop
|
188
|
+
@complex_type.pop
|
189
|
+
@array_positions.pop
|
190
|
+
end
|
191
|
+
|
192
|
+
def add_value(value, key)
|
193
|
+
YamlLint.logger.debug { "add_value: #{value.inspect}, #{key.inspect}" }
|
194
|
+
|
195
|
+
case @complex_type.last
|
196
|
+
when :hash
|
197
|
+
@key_components.push(key)
|
198
|
+
check_for_overlap!
|
199
|
+
@key_components.pop
|
200
|
+
when :array
|
201
|
+
@key_components.push(@array_positions.last)
|
202
|
+
check_for_overlap!
|
203
|
+
@array_positions[-1] += 1
|
204
|
+
@key_components.pop
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
208
|
+
def check_for_overlap!
|
209
|
+
full_key = @key_components.dup
|
210
|
+
YamlLint.logger.debug { "Checking #{full_key.join('.')} for overlap" }
|
211
|
+
|
212
|
+
return if @seen_keys.add?(full_key)
|
213
|
+
YamlLint.logger.debug { "Overlapping key #{full_key.join('.')}" }
|
214
|
+
@overlapping_keys << full_key
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
218
|
+
def check_overlapping_keys(yaml_data, errors_array)
|
219
|
+
overlap_detector = KeyOverlapDetector.new
|
220
|
+
data = Psych.parser.parse(yaml_data)
|
221
|
+
|
222
|
+
overlap_detector.parse(data)
|
223
|
+
|
224
|
+
overlap_detector.overlapping_keys.each do |key|
|
225
|
+
err_meg = "The same key is defined more than once: #{key.join('.')}"
|
226
|
+
errors_array << err_meg
|
227
|
+
end
|
228
|
+
|
229
|
+
!!overlap_detector.overlapping_keys.empty?
|
230
|
+
end
|
231
|
+
end
|
232
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/tasklib'
|
3
|
+
|
4
|
+
require 'yamllint'
|
5
|
+
|
6
|
+
module YamlLint
|
7
|
+
###
|
8
|
+
# RakeTast execution
|
9
|
+
#
|
10
|
+
class RakeTask < Rake::TaskLib
|
11
|
+
attr_accessor :name
|
12
|
+
attr_accessor :paths
|
13
|
+
|
14
|
+
def initialize(name = :yamllint)
|
15
|
+
@name = name
|
16
|
+
|
17
|
+
yield self if block_given?
|
18
|
+
|
19
|
+
define_task
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def define_task
|
25
|
+
desc 'Run yamllint' unless ::Rake.application.last_comment
|
26
|
+
|
27
|
+
task(name) do
|
28
|
+
files_to_check = Rake::FileList.new(paths)
|
29
|
+
|
30
|
+
linter = ::YamlLint::Linter.new
|
31
|
+
linter.check_all(files_to_check)
|
32
|
+
|
33
|
+
if linter.errors?
|
34
|
+
linter.display_errors
|
35
|
+
abort('YAML lint found')
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/spec/cli_spec.rb
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'yamllint' do
|
4
|
+
it 'should print usage if run with no args' do
|
5
|
+
yamllint
|
6
|
+
assert_failing_with('Error')
|
7
|
+
end
|
8
|
+
|
9
|
+
it '-h should print usage' do
|
10
|
+
yamllint '-h'
|
11
|
+
assert_passing_with('Usage')
|
12
|
+
end
|
13
|
+
|
14
|
+
it '--help should print usage' do
|
15
|
+
yamllint '--help'
|
16
|
+
assert_passing_with('Usage')
|
17
|
+
end
|
18
|
+
|
19
|
+
it '-v should print its version' do
|
20
|
+
yamllint '-v'
|
21
|
+
assert_passing_with(YamlLint::VERSION)
|
22
|
+
end
|
23
|
+
|
24
|
+
it '--version should print its version' do
|
25
|
+
yamllint '--version'
|
26
|
+
assert_passing_with(YamlLint::VERSION)
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should exit successfully with good YAML' do
|
30
|
+
yamllint spec_data('valid.yaml')
|
31
|
+
assert_success(true)
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'should fail with bad YAML' do
|
35
|
+
yamllint spec_data('invalid.yaml')
|
36
|
+
assert_success(false)
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'should fail with a path that does not exist' do
|
40
|
+
yamllint '/does/not/exist'
|
41
|
+
assert_failing_with('no such file')
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'should fail with a path that is unreadable' do
|
45
|
+
run_simple('mkdir -p tmp')
|
46
|
+
run_simple('touch tmp/unreadable_file.yaml')
|
47
|
+
run_simple('chmod -r tmp/unreadable_file.yaml')
|
48
|
+
|
49
|
+
yamllint 'tmp/unreadable_file.yaml'
|
50
|
+
assert_failing_with('Permission denied')
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'should be able to lint good YAML from STDIN' do
|
54
|
+
run_interactive "#{yamllint_bin} -"
|
55
|
+
pipe_in_file(spec_data('valid.yaml')) && close_input
|
56
|
+
assert_success(true)
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'should be able to lint bad YAML from STDIN' do
|
60
|
+
run_interactive "#{yamllint_bin} -"
|
61
|
+
pipe_in_file(spec_data('invalid.yaml')) && close_input
|
62
|
+
assert_success(false)
|
63
|
+
end
|
64
|
+
end
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
foo: %bar
|
@@ -0,0 +1 @@
|
|
1
|
+
|
@@ -0,0 +1,112 @@
|
|
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
|
+
...
|
@@ -0,0 +1,112 @@
|
|
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
|
+
...
|
data/spec/linter_spec.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'yamllint/linter'
|
3
|
+
|
4
|
+
describe 'YamlLint::Linter' do
|
5
|
+
let(:linter) { YamlLint::Linter.new }
|
6
|
+
|
7
|
+
it 'should throw an exception if given a bogus path' do
|
8
|
+
expect { linter.check('/does/not/exist') }.to raise_error
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'should be happy with a valid YAML file' do
|
12
|
+
expect(linter.check(spec_data('valid.yaml'))).to be(true)
|
13
|
+
expect(linter.check(spec_data('valid_complex.yaml'))).to be(true)
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should be unhappy with an invalid YAML file' do
|
17
|
+
expect(linter.check(spec_data('invalid.yaml'))).to be(false)
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'should be unhappy with YAML that has overlapping keys' do
|
21
|
+
expect(linter.check(spec_data('overlapping_keys.yaml'))).to be(false)
|
22
|
+
expect(linter.check(spec_data('overlapping_keys_deep.yaml'))).to be(false)
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'should be able to check an IO stream' do
|
26
|
+
valid_stream = File.open(spec_data('valid.yaml'))
|
27
|
+
expect(linter.check_stream(valid_stream)).to be(true)
|
28
|
+
|
29
|
+
invalid_stream = File.open(spec_data('overlapping_keys.yaml'))
|
30
|
+
expect(linter.check_stream(invalid_stream)).to be(false)
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'should be unhappy with an empty YAML file' do
|
34
|
+
expect(linter.check(spec_data('empty.yaml'))).to be(false)
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'should be unhapy with a YAML file full of spaces' do
|
38
|
+
expect(linter.check(spec_data('spaces.yaml'))).to be(false)
|
39
|
+
end
|
40
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
|
3
|
+
require 'aruba'
|
4
|
+
require 'aruba/api'
|
5
|
+
|
6
|
+
require 'yamllint'
|
7
|
+
|
8
|
+
###
|
9
|
+
# Helper methods for spec tests
|
10
|
+
#
|
11
|
+
module SpecHelpers
|
12
|
+
def spec_data(data_path)
|
13
|
+
File.expand_path(File.join('spec/data', data_path))
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
###
|
18
|
+
# Helper methods for spec tests against the CLI
|
19
|
+
#
|
20
|
+
module CliSpecHelpers
|
21
|
+
def yamllint(args = nil)
|
22
|
+
run_simple("#{yamllint_bin} #{args}", false)
|
23
|
+
end
|
24
|
+
|
25
|
+
def yamllint_bin
|
26
|
+
File.expand_path('../../bin/yamllint', __FILE__)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
RSpec.configure do |config|
|
31
|
+
config.include SpecHelpers
|
32
|
+
config.include CliSpecHelpers
|
33
|
+
config.include Aruba::Api
|
34
|
+
|
35
|
+
config.run_all_when_everything_filtered = true
|
36
|
+
config.filter_run :focus
|
37
|
+
end
|
data/yamllint.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'yamllint/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "yamllint"
|
8
|
+
spec.version = YamlLint::VERSION
|
9
|
+
spec.authors = ["Grant Ridder"]
|
10
|
+
spec.email = ["shortdudey123@gmail.com"]
|
11
|
+
spec.summary = %q{YAML lint checker}
|
12
|
+
spec.description = %q{Checks YAML files for correct syntax}
|
13
|
+
spec.license = "MIT"
|
14
|
+
spec.homepage = ""
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency 'trollop', '~> 2'
|
22
|
+
|
23
|
+
spec.add_development_dependency 'bundler', '~> 1.7'
|
24
|
+
spec.add_development_dependency 'rake'
|
25
|
+
spec.add_development_dependency 'rspec'
|
26
|
+
spec.add_development_dependency 'aruba'
|
27
|
+
spec.add_development_dependency 'rubocop'
|
28
|
+
spec.add_development_dependency 'pry'
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,184 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: yamllint
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Grant Ridder
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-01-16 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: trollop
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.7'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.7'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: aruba
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rubocop
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: pry
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description: Checks YAML files for correct syntax
|
112
|
+
email:
|
113
|
+
- shortdudey123@gmail.com
|
114
|
+
executables:
|
115
|
+
- yamllint
|
116
|
+
extensions: []
|
117
|
+
extra_rdoc_files: []
|
118
|
+
files:
|
119
|
+
- ".gitignore"
|
120
|
+
- ".rspec"
|
121
|
+
- ".rubocop.yml"
|
122
|
+
- ".rubocop_todo.yml"
|
123
|
+
- ".travis.yml"
|
124
|
+
- Gemfile
|
125
|
+
- LICENSE
|
126
|
+
- README.md
|
127
|
+
- Rakefile
|
128
|
+
- bin/yamllint
|
129
|
+
- lib/yamllint.rb
|
130
|
+
- lib/yamllint/cli.rb
|
131
|
+
- lib/yamllint/errors.rb
|
132
|
+
- lib/yamllint/linter.rb
|
133
|
+
- lib/yamllint/rake_tast.rb
|
134
|
+
- lib/yamllint/version.rb
|
135
|
+
- spec/cli_spec.rb
|
136
|
+
- spec/data/empty.yaml
|
137
|
+
- spec/data/invalid.yaml
|
138
|
+
- spec/data/overlapping_keys.yaml
|
139
|
+
- spec/data/overlapping_keys_complex.yaml
|
140
|
+
- spec/data/overlapping_keys_deep.yaml
|
141
|
+
- spec/data/spaces.yaml
|
142
|
+
- spec/data/valid.yaml
|
143
|
+
- spec/data/valid_complex.yaml
|
144
|
+
- spec/data/valid_complex.yml
|
145
|
+
- spec/linter_spec.rb
|
146
|
+
- spec/spec_helper.rb
|
147
|
+
- yamllint.gemspec
|
148
|
+
homepage: ''
|
149
|
+
licenses:
|
150
|
+
- MIT
|
151
|
+
metadata: {}
|
152
|
+
post_install_message:
|
153
|
+
rdoc_options: []
|
154
|
+
require_paths:
|
155
|
+
- lib
|
156
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
157
|
+
requirements:
|
158
|
+
- - ">="
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: '0'
|
161
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
162
|
+
requirements:
|
163
|
+
- - ">="
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: '0'
|
166
|
+
requirements: []
|
167
|
+
rubyforge_project:
|
168
|
+
rubygems_version: 2.2.2
|
169
|
+
signing_key:
|
170
|
+
specification_version: 4
|
171
|
+
summary: YAML lint checker
|
172
|
+
test_files:
|
173
|
+
- spec/cli_spec.rb
|
174
|
+
- spec/data/empty.yaml
|
175
|
+
- spec/data/invalid.yaml
|
176
|
+
- spec/data/overlapping_keys.yaml
|
177
|
+
- spec/data/overlapping_keys_complex.yaml
|
178
|
+
- spec/data/overlapping_keys_deep.yaml
|
179
|
+
- spec/data/spaces.yaml
|
180
|
+
- spec/data/valid.yaml
|
181
|
+
- spec/data/valid_complex.yaml
|
182
|
+
- spec/data/valid_complex.yml
|
183
|
+
- spec/linter_spec.rb
|
184
|
+
- spec/spec_helper.rb
|