yamllint 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +18 -0
- data/README.md +2 -0
- data/lib/yamllint/cli.rb +3 -0
- data/lib/yamllint/linter.rb +15 -1
- data/lib/yamllint/rake_task.rb +10 -1
- data/lib/yamllint/version.rb +1 -1
- data/spec/cli_spec.rb +5 -0
- data/spec/data/wrong_extention.txt +0 -0
- data/spec/linter_spec.rb +4 -0
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e2385493452cd1aa83778ef91e6190cf579f6dba
|
4
|
+
data.tar.gz: 8a1e10518d95ab9ac3b488d7ba8c2f3c8bce0845
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 452d3f5093087b39915225f094c34956ff6d491d85630feefdcc7b8fe1ecc4ca3cac21dc5da27c7b47d2e2e04ff5f7ece0f02e1e55e011d7a522e5f736f58438
|
7
|
+
data.tar.gz: 95facbf3993b0267735f64e90b975d9dca09096c10b72245647aa259e538663c654495f008464fd52609da5ab0917ffd46a335ee7e48a1845a8409f36c8ecf7d
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
YamlLint gem CHANGELOG
|
2
|
+
======================
|
3
|
+
This file is used to list changes made in each version of the YamlLint gem.
|
4
|
+
|
5
|
+
v0.0.3 (2015-01-15)
|
6
|
+
-------------------
|
7
|
+
- **[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 extention verification
|
9
|
+
- add fail_on_error option to rake task
|
10
|
+
|
11
|
+
v0.0.2 (2015-01-15)
|
12
|
+
-------------------
|
13
|
+
- Fix rake_task filename
|
14
|
+
|
15
|
+
|
16
|
+
v0.0.1 (2015-01-15)
|
17
|
+
-------------------
|
18
|
+
- Initial gem publish
|
data/README.md
CHANGED
@@ -81,6 +81,8 @@ spec/data/spaces.yaml
|
|
81
81
|
$
|
82
82
|
```
|
83
83
|
|
84
|
+
Optionally add `t.fail_on_error = false` in the Rakefile definition to continue on to the next rake task even if YamlLint finds errors.
|
85
|
+
|
84
86
|
## Contributing
|
85
87
|
|
86
88
|
1. Fork it ( https://github.com/shortdudey123/yamllint/fork )
|
data/lib/yamllint/cli.rb
CHANGED
@@ -32,14 +32,17 @@ module YamlLint
|
|
32
32
|
linter = lint_files(files_to_check)
|
33
33
|
end
|
34
34
|
|
35
|
+
puts 'YamlLint found no errors' unless linter.errors?
|
35
36
|
return unless linter.errors?
|
36
37
|
linter.display_errors
|
38
|
+
puts "YAML lint found #{linter.errors_count} errors"
|
37
39
|
@kernel.exit(1)
|
38
40
|
end
|
39
41
|
|
40
42
|
def lint_files(files_to_check)
|
41
43
|
linter = YamlLint::Linter.new
|
42
44
|
begin
|
45
|
+
puts "Checking #{files_to_check.flatten.length} files"
|
43
46
|
linter.check_all(files_to_check)
|
44
47
|
rescue => e
|
45
48
|
@stderr.puts e.message
|
data/lib/yamllint/linter.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
require 'yaml'
|
2
2
|
require 'set'
|
3
|
-
require 'pry'
|
4
3
|
|
5
4
|
require 'yamllint/errors'
|
6
5
|
|
@@ -23,6 +22,11 @@ module YamlLint
|
|
23
22
|
fail FileNotFoundError, "#{path}: no such file" unless File.exist?(path)
|
24
23
|
|
25
24
|
valid = false
|
25
|
+
unless check_filename(path)
|
26
|
+
errors[path] = ['File extention must be .yaml or .yml']
|
27
|
+
return valid
|
28
|
+
end
|
29
|
+
|
26
30
|
File.open(path, 'r') do |f|
|
27
31
|
error_array = []
|
28
32
|
valid = check_data(f.read, error_array)
|
@@ -46,6 +50,10 @@ module YamlLint
|
|
46
50
|
!errors.empty?
|
47
51
|
end
|
48
52
|
|
53
|
+
def errors_count
|
54
|
+
errors.length
|
55
|
+
end
|
56
|
+
|
49
57
|
def display_errors
|
50
58
|
errors.each do |path, errors|
|
51
59
|
puts path
|
@@ -57,6 +65,12 @@ module YamlLint
|
|
57
65
|
|
58
66
|
private
|
59
67
|
|
68
|
+
def check_filename(filename)
|
69
|
+
extention = filename.split('.').last
|
70
|
+
return true if extention == 'yaml' || extention == 'yml'
|
71
|
+
false
|
72
|
+
end
|
73
|
+
|
60
74
|
def check_data(yaml_data, errors_array)
|
61
75
|
valid = check_not_empty(yaml_data, errors_array)
|
62
76
|
valid &&= check_syntax_valid(yaml_data, errors_array)
|
data/lib/yamllint/rake_task.rb
CHANGED
@@ -10,9 +10,11 @@ module YamlLint
|
|
10
10
|
class RakeTask < Rake::TaskLib
|
11
11
|
attr_accessor :name
|
12
12
|
attr_accessor :paths
|
13
|
+
attr_accessor :fail_on_error
|
13
14
|
|
14
15
|
def initialize(name = :yamllint)
|
15
16
|
@name = name
|
17
|
+
@fail_on_error = true
|
16
18
|
|
17
19
|
yield self if block_given?
|
18
20
|
|
@@ -25,14 +27,21 @@ module YamlLint
|
|
25
27
|
desc 'Run yamllint' unless ::Rake.application.last_comment
|
26
28
|
|
27
29
|
task(name) do
|
30
|
+
puts 'Running YamlLint...'
|
31
|
+
|
28
32
|
files_to_check = Rake::FileList.new(paths)
|
29
33
|
|
34
|
+
puts "Checking #{files_to_check.flatten.length} files"
|
35
|
+
|
30
36
|
linter = ::YamlLint::Linter.new
|
31
37
|
linter.check_all(files_to_check)
|
32
38
|
|
33
39
|
if linter.errors?
|
34
40
|
linter.display_errors
|
35
|
-
|
41
|
+
puts "YAML lint found #{linter.errors_count} errors"
|
42
|
+
abort('YamlLint failed!') if fail_on_error
|
43
|
+
else
|
44
|
+
puts 'YamlLint found no errors'
|
36
45
|
end
|
37
46
|
end
|
38
47
|
end
|
data/lib/yamllint/version.rb
CHANGED
data/spec/cli_spec.rb
CHANGED
@@ -41,6 +41,11 @@ 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 extention' do
|
45
|
+
yamllint spec_data('wrong_extention.txt')
|
46
|
+
assert_failing_with('File extention must be .yaml or .yml')
|
47
|
+
end
|
48
|
+
|
44
49
|
it 'should fail with a path that is unreadable' do
|
45
50
|
run_simple('mkdir -p tmp')
|
46
51
|
run_simple('touch tmp/unreadable_file.yaml')
|
File without changes
|
data/spec/linter_spec.rb
CHANGED
@@ -13,6 +13,10 @@ describe 'YamlLint::Linter' do
|
|
13
13
|
expect(linter.check(spec_data('valid_complex.yaml'))).to be(true)
|
14
14
|
end
|
15
15
|
|
16
|
+
it 'should be unhappy with an invalid YAML file extention' do
|
17
|
+
expect(linter.check(spec_data('wrong_extention.txt'))).to be(false)
|
18
|
+
end
|
19
|
+
|
16
20
|
it 'should be unhappy with an invalid YAML file' do
|
17
21
|
expect(linter.check(spec_data('invalid.yaml'))).to be(false)
|
18
22
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Grant Ridder
|
@@ -121,6 +121,7 @@ files:
|
|
121
121
|
- ".rubocop.yml"
|
122
122
|
- ".rubocop_todo.yml"
|
123
123
|
- ".travis.yml"
|
124
|
+
- CHANGELOG.md
|
124
125
|
- Gemfile
|
125
126
|
- LICENSE
|
126
127
|
- README.md
|
@@ -142,6 +143,7 @@ files:
|
|
142
143
|
- spec/data/valid.yaml
|
143
144
|
- spec/data/valid_complex.yaml
|
144
145
|
- spec/data/valid_complex.yml
|
146
|
+
- spec/data/wrong_extention.txt
|
145
147
|
- spec/linter_spec.rb
|
146
148
|
- spec/spec_helper.rb
|
147
149
|
- yamllint.gemspec
|
@@ -180,5 +182,6 @@ test_files:
|
|
180
182
|
- spec/data/valid.yaml
|
181
183
|
- spec/data/valid_complex.yaml
|
182
184
|
- spec/data/valid_complex.yml
|
185
|
+
- spec/data/wrong_extention.txt
|
183
186
|
- spec/linter_spec.rb
|
184
187
|
- spec/spec_helper.rb
|