yaml-parser 1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +15 -0
  2. data/bin/yaml-parser +17 -0
  3. data/lib/yaml-parser.rb +37 -0
  4. metadata +45 -0
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ OTY1MzRhYTg5YmMxMzJlN2YxNzljZWFkMmJkMzAwM2E0OTM2ZDgzYQ==
5
+ data.tar.gz: !binary |-
6
+ ZjVjYWEyNTM4NjM4OTdhZWJkM2Y1Y2RiYzc5Y2U5MjU0NzA0ZjY4Zg==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ ZGY3MTEzMzVjZjliZGIyNTNmMDYxOTExMzEzNWYyYmMzODkzNTUxODY4YWNm
10
+ NWM5MDBhMmQyNjIzYWMwOGVmY2ZmNzk4M2NkZDIyMGZiNmM2ZjZkMzdiNjVk
11
+ NDRmOWE3MWUwMGMzYTc1MzRmZTNkNmQyOTZjYWY5NTVjYWIzNzQ=
12
+ data.tar.gz: !binary |-
13
+ OTZjZjZmZDJjMzM1OWFjMTNkYmZjNzcxMzQwMWIwODE5OGI3NjExMjlhNzMw
14
+ OTE3NTNjZDEwNDY0YTgyNmJkMjA3M2E0YjJmNTZkZWYwMjE3YTVjODY4YjE2
15
+ NDZmZDc0ZWEyMTI2NjM0ZDg2MDU2ZDc4NjI5NDY1ZGQ1NzJkZGU=
data/bin/yaml-parser ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative '../lib/yaml-parser.rb'
3
+
4
+ if ARGV[0].nil?
5
+ puts 'Usage: yaml-parser [path]'
6
+ exit 1
7
+ end
8
+
9
+ parser = YamlParser.new
10
+ files = parser.get_files(ARGV[0])
11
+ errors = parser.parse_files(files)
12
+
13
+ puts "Parsed #{files.length} yaml files. #{errors.length} error(s) found"
14
+ if errors.length != 0
15
+ errors.each { |error| warn error }
16
+ exit 1
17
+ end
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/env ruby
2
+ require 'yaml'
3
+ require 'pathname'
4
+
5
+ class YamlParser
6
+
7
+ def get_files(dir)
8
+ # Get all .yaml files from directory, return array
9
+ files = []
10
+
11
+ if File.file? dir
12
+ files << dir
13
+ return files
14
+ end
15
+
16
+ root = Pathname(dir)
17
+ Pathname(root).find do |path|
18
+ unless path == root
19
+ files << path if path.file? and path.extname == '.yaml'
20
+ end
21
+ end
22
+ files
23
+ end
24
+
25
+ def parse_files(files)
26
+ # Parse array of yaml files. Return array of parser errors
27
+ errors = []
28
+ files.each do |f|
29
+ begin
30
+ YAML.load_file(f)
31
+ rescue Exception => e
32
+ errors << e
33
+ end
34
+ end
35
+ errors
36
+ end
37
+ end
metadata ADDED
@@ -0,0 +1,45 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: yaml-parser
3
+ version: !ruby/object:Gem::Version
4
+ version: '1.0'
5
+ platform: ruby
6
+ authors:
7
+ - Johan Haals
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-09-12 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: YAML Parser
14
+ email: johan.haals@gmail.com
15
+ executables:
16
+ - yaml-parser
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - lib/yaml-parser.rb
21
+ - bin/yaml-parser
22
+ homepage: http://github.com/jhaals/yaml-parser
23
+ licenses: []
24
+ metadata: {}
25
+ post_install_message:
26
+ rdoc_options: []
27
+ require_paths:
28
+ - lib
29
+ required_ruby_version: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ required_rubygems_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ! '>='
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ requirements: []
40
+ rubyforge_project:
41
+ rubygems_version: 2.1.2
42
+ signing_key:
43
+ specification_version: 4
44
+ summary: Parse all yaml files in a directory and outputs errors
45
+ test_files: []