yamlclean 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.editorconfig +12 -0
- data/.gitignore +1 -0
- data/.travis.yml +5 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +24 -0
- data/LICENSE.txt +21 -0
- data/README.md +41 -0
- data/Rakefile +10 -0
- data/bin/setup +8 -0
- data/bin/yamlclean +19 -0
- data/lib/yamlclean/version.rb +3 -0
- data/lib/yamlclean.rb +30 -0
- data/yamlclean.gemspec +29 -0
- metadata +114 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7fcc6602a56f8c64065bfe7ac93b5e6207aae728
|
4
|
+
data.tar.gz: c2799bcd40b95976bc563d3ce0710b9650ca840d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: cb8e6cee999a679f564031633e4f6b2142961ae80ad0f11f22d0917d9f5341e473c12d2764fcfbe9b1801df0caf7b1f9658bea4e53b31653b4f5c7d08b23e9e5
|
7
|
+
data.tar.gz: 65605b7aa7fbcf519940bcc7fce0ba8d15b99b0fb0c256fd169cf670792599f6d81b8fb5afb84a5fc6f1d1503d97b502d3634556b8454a84e03e1a96c6e0037d
|
data/.editorconfig
ADDED
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
pkg/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
yamlclean (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
minitest (5.9.0)
|
10
|
+
rake (10.5.0)
|
11
|
+
ya2yaml (0.31)
|
12
|
+
|
13
|
+
PLATFORMS
|
14
|
+
ruby
|
15
|
+
|
16
|
+
DEPENDENCIES
|
17
|
+
bundler (~> 1.13)
|
18
|
+
minitest (~> 5.0)
|
19
|
+
rake (~> 10.0)
|
20
|
+
ya2yaml
|
21
|
+
yamlclean!
|
22
|
+
|
23
|
+
BUNDLED WITH
|
24
|
+
1.13.1
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Sam Minnee
|
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
|
13
|
+
all 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
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
yamlclean
|
2
|
+
=========
|
3
|
+
|
4
|
+
[![Build Status](https://travis-ci.org/sminnee/yamlclean.svg?branch=master)](https://travis-ci.org/sminnee/yamlclean)
|
5
|
+
|
6
|
+
This simple ruby gem provides a command-line tool for cleaning up yaml files.
|
7
|
+
It's based on the ya2yaml library.
|
8
|
+
|
9
|
+
One notable use-case for this is to make Transifex translation files work with PHP's
|
10
|
+
yaml parsers. That's why I first wrote it. :-)
|
11
|
+
|
12
|
+
Installation
|
13
|
+
------------
|
14
|
+
|
15
|
+
$> sudo gem install yamlclean
|
16
|
+
|
17
|
+
Usage
|
18
|
+
-----
|
19
|
+
|
20
|
+
$> yamlclean input.yml > output.yml
|
21
|
+
|
22
|
+
Contributing and development
|
23
|
+
----------------------------
|
24
|
+
|
25
|
+
After checking out the code, you can run the tests as follows:
|
26
|
+
|
27
|
+
$> bundle install
|
28
|
+
$> bundle exec rake
|
29
|
+
|
30
|
+
You can compile and install the gem locally as follows:
|
31
|
+
|
32
|
+
$> bundle exec rake install
|
33
|
+
|
34
|
+
To publish a new release, first ensure that the correct version is listed in
|
35
|
+
`lib/yamlclean/version.rb`. Then run these commands:
|
36
|
+
|
37
|
+
$> bundle exec rake release
|
38
|
+
|
39
|
+
Note that the last command will require permissions to publish the gem. If you've
|
40
|
+
been contributing to this through pull requests and would like to be granted core
|
41
|
+
commit and publish access, let me know!
|
data/Rakefile
ADDED
data/bin/setup
ADDED
data/bin/yamlclean
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'yamlclean'
|
5
|
+
|
6
|
+
if ARGV.size < 1 then
|
7
|
+
puts "Usage: yamlclean (yaml filename)\n\n"
|
8
|
+
puts "Removes unusual syntax structures from yaml file. Outputs new yaml to stdout."
|
9
|
+
exit 1
|
10
|
+
end
|
11
|
+
|
12
|
+
begin
|
13
|
+
|
14
|
+
puts YamlClean.clean(ARGV[0])
|
15
|
+
|
16
|
+
rescue RuntimeError => err
|
17
|
+
$stderr.print "There was an error!\n" + err.message + "\n"
|
18
|
+
exit 1
|
19
|
+
end
|
data/lib/yamlclean.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require 'ya2yaml'
|
3
|
+
|
4
|
+
module YamlClean
|
5
|
+
def self.start()
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.clean(filename)
|
9
|
+
if !File.file?(filename) then
|
10
|
+
raise "File not found: " + filename
|
11
|
+
elsif !File.readable?(filename)
|
12
|
+
raise "Can't read file: " + filename
|
13
|
+
end
|
14
|
+
|
15
|
+
yamlString = IO.read(filename)
|
16
|
+
dirty = YAML.load(yamlString)
|
17
|
+
cleaned = dirty.ya2yaml(:syck_compatible => true)
|
18
|
+
|
19
|
+
# Remove trailing whitespace
|
20
|
+
cleaned = cleaned.gsub(/ +\n/, "\n")
|
21
|
+
|
22
|
+
# Remove unnecessary --- header
|
23
|
+
if(cleaned.scan(/^---$/).size == 1) then
|
24
|
+
cleaned = cleaned.gsub(/^---$\n?/, "")
|
25
|
+
end
|
26
|
+
|
27
|
+
return cleaned
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
data/yamlclean.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 'yamlclean/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "yamlclean"
|
8
|
+
spec.version = YamlClean::VERSION
|
9
|
+
spec.authors = ["Sam Minnee"]
|
10
|
+
spec.email = ["sam.minnee@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Clean yaml files}
|
13
|
+
spec.description = %q{Clean issues out of yaml files. Thanks to yamllint.com and ya2yaml}
|
14
|
+
spec.homepage = "http://github.com/sminnee/yamlclean"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
|
+
f.match(%r{^(test|spec|features)/})
|
19
|
+
end
|
20
|
+
spec.bindir = "bin"
|
21
|
+
spec.executables = [ "yamlclean" ]
|
22
|
+
spec.require_paths = ["lib"]
|
23
|
+
|
24
|
+
spec.add_development_dependency "ya2yaml"
|
25
|
+
|
26
|
+
spec.add_development_dependency "bundler", "~> 1.13"
|
27
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
28
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: yamlclean
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Sam Minnee
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-09-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: ya2yaml
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
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.13'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.13'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: minitest
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '5.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '5.0'
|
69
|
+
description: Clean issues out of yaml files. Thanks to yamllint.com and ya2yaml
|
70
|
+
email:
|
71
|
+
- sam.minnee@gmail.com
|
72
|
+
executables:
|
73
|
+
- yamlclean
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- .editorconfig
|
78
|
+
- .gitignore
|
79
|
+
- .travis.yml
|
80
|
+
- Gemfile
|
81
|
+
- Gemfile.lock
|
82
|
+
- LICENSE.txt
|
83
|
+
- README.md
|
84
|
+
- Rakefile
|
85
|
+
- bin/setup
|
86
|
+
- bin/yamlclean
|
87
|
+
- lib/yamlclean.rb
|
88
|
+
- lib/yamlclean/version.rb
|
89
|
+
- yamlclean.gemspec
|
90
|
+
homepage: http://github.com/sminnee/yamlclean
|
91
|
+
licenses:
|
92
|
+
- MIT
|
93
|
+
metadata: {}
|
94
|
+
post_install_message:
|
95
|
+
rdoc_options: []
|
96
|
+
require_paths:
|
97
|
+
- lib
|
98
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - '>='
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - '>='
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '0'
|
108
|
+
requirements: []
|
109
|
+
rubyforge_project:
|
110
|
+
rubygems_version: 2.0.14.1
|
111
|
+
signing_key:
|
112
|
+
specification_version: 4
|
113
|
+
summary: Clean yaml files
|
114
|
+
test_files: []
|