yaml_duplicate_checker 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/.rspec +3 -0
- data/.rubocop.yml +10 -0
- data/.travis.yml +7 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +61 -0
- data/README.md +50 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/exe/ydc +12 -0
- data/lib/yaml_duplicate_checker.rb +53 -0
- data/lib/yaml_duplicate_checker/version.rb +5 -0
- data/yaml_duplicate_checker.gemspec +41 -0
- metadata +130 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 9cdd15d7e6e9b2bfdee26b596baf1edda80ef2954198a770f495752989ac5be9
|
4
|
+
data.tar.gz: 75d21f6698933807c3de492b3c5ec2eda8f8e3c501f2a54f985d1cdece2e7cf8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2e6a2373671b6133670af1629c2e86fbc5b1790d31a9aaa2b67019ceaecc46cbc353f88fe1f89316ee3a033af25b19189f7fd5ea83504a3e80b53549ad6f0ac8
|
7
|
+
data.tar.gz: 22a984e092adcf798d0570c34cb41c8aa8924fb6cac23154036894d6671c2f78da3ba427bf8742a893aadc732cf077d0c88fafc16f522aa7dd3b83c3128c5e80
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
yaml_duplicate_checker (0.1.1)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
ast (2.4.0)
|
10
|
+
coderay (1.1.2)
|
11
|
+
diff-lcs (1.3)
|
12
|
+
jaro_winkler (1.5.2)
|
13
|
+
method_source (0.9.2)
|
14
|
+
parallel (1.13.0)
|
15
|
+
parser (2.6.0.0)
|
16
|
+
ast (~> 2.4.0)
|
17
|
+
powerpack (0.1.2)
|
18
|
+
pry (0.12.2)
|
19
|
+
coderay (~> 1.1.0)
|
20
|
+
method_source (~> 0.9.0)
|
21
|
+
psych (3.1.0)
|
22
|
+
rainbow (3.0.0)
|
23
|
+
rake (10.5.0)
|
24
|
+
rspec (3.8.0)
|
25
|
+
rspec-core (~> 3.8.0)
|
26
|
+
rspec-expectations (~> 3.8.0)
|
27
|
+
rspec-mocks (~> 3.8.0)
|
28
|
+
rspec-core (3.8.0)
|
29
|
+
rspec-support (~> 3.8.0)
|
30
|
+
rspec-expectations (3.8.2)
|
31
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
32
|
+
rspec-support (~> 3.8.0)
|
33
|
+
rspec-mocks (3.8.0)
|
34
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
35
|
+
rspec-support (~> 3.8.0)
|
36
|
+
rspec-support (3.8.0)
|
37
|
+
rubocop (0.65.0)
|
38
|
+
jaro_winkler (~> 1.5.1)
|
39
|
+
parallel (~> 1.10)
|
40
|
+
parser (>= 2.5, != 2.5.1.1)
|
41
|
+
powerpack (~> 0.1)
|
42
|
+
psych (>= 3.1.0)
|
43
|
+
rainbow (>= 2.2.2, < 4.0)
|
44
|
+
ruby-progressbar (~> 1.7)
|
45
|
+
unicode-display_width (~> 1.4.0)
|
46
|
+
ruby-progressbar (1.10.0)
|
47
|
+
unicode-display_width (1.4.1)
|
48
|
+
|
49
|
+
PLATFORMS
|
50
|
+
ruby
|
51
|
+
|
52
|
+
DEPENDENCIES
|
53
|
+
bundler (~> 1.17)
|
54
|
+
pry (~> 0.12)
|
55
|
+
rake (~> 10.0)
|
56
|
+
rspec (~> 3.0)
|
57
|
+
rubocop (~> 0.65)
|
58
|
+
yaml_duplicate_checker!
|
59
|
+
|
60
|
+
BUNDLED WITH
|
61
|
+
1.17.2
|
data/README.md
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# YamlDuplicateChecker
|
2
|
+
|
3
|
+
This gem check duplicates recursively abount yaml.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'yaml_duplicate_checker'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install yaml_duplicate_checker
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
```
|
24
|
+
ydc path/to/yaml/directory
|
25
|
+
```
|
26
|
+
|
27
|
+
`ydc` searches directories recursively.
|
28
|
+
|
29
|
+
If there is no duplicate, outputs nothing
|
30
|
+
|
31
|
+
If have duplicates, outputs like below
|
32
|
+
|
33
|
+
```
|
34
|
+
test1.key1:
|
35
|
+
test2.yaml:10
|
36
|
+
test1.yaml:2
|
37
|
+
```
|
38
|
+
|
39
|
+
`test1.key1` is a duplicate key.
|
40
|
+
`test2.yaml:10` and `test1.yaml:2` are path and line number where duplicate is occured.
|
41
|
+
|
42
|
+
## Development
|
43
|
+
|
44
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
45
|
+
|
46
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
47
|
+
|
48
|
+
## Contributing
|
49
|
+
|
50
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/yaml_duplicate_checker.
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "yaml_duplicate_checker"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/exe/ydc
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require_relative '../lib/yaml_duplicate_checker'
|
4
|
+
|
5
|
+
checker = YamlDuplicateChecker::Checker.new(ARGV[0])
|
6
|
+
checker.dup_list.each do |dup_key, dup_locations|
|
7
|
+
puts "#{dup_key}:"
|
8
|
+
dup_locations.each do |location|
|
9
|
+
puts " #{location}"
|
10
|
+
end
|
11
|
+
puts
|
12
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'yaml_duplicate_checker/version'
|
4
|
+
require 'yaml'
|
5
|
+
|
6
|
+
module YamlDuplicateChecker
|
7
|
+
# Yaml duplicate check class
|
8
|
+
# @abstract
|
9
|
+
# Use Checker#dup_list returns duplicate yaml key list
|
10
|
+
#
|
11
|
+
class Checker
|
12
|
+
def initialize(root)
|
13
|
+
@key_list = Hash.new { |h, v| h[v] = [] }
|
14
|
+
@root = root
|
15
|
+
check
|
16
|
+
end
|
17
|
+
|
18
|
+
def dup_list
|
19
|
+
@dup_list ||= @key_list.select { |_, v| v.size > 1 }
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def set_key_list(parsed_yaml, path, result_key = '')
|
25
|
+
parsed_yaml.each_slice(2) do |k, v|
|
26
|
+
unless v.mapping?
|
27
|
+
update_key_list(result_key, k, path)
|
28
|
+
next
|
29
|
+
end
|
30
|
+
|
31
|
+
next_key = result_key + format_key(k.value, result_key)
|
32
|
+
set_key_list(v.children, path, next_key)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def format_key(key, result_key)
|
37
|
+
result_key == '' ? key : ".#{key}"
|
38
|
+
end
|
39
|
+
|
40
|
+
def check
|
41
|
+
Dir.glob(["#{@root}/**/*.yaml", "#{@root}/**/*.yml"]).each do |yaml|
|
42
|
+
parsed_yaml = YAML.parse(File.open(yaml)).root.children
|
43
|
+
set_key_list(parsed_yaml, yaml)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def update_key_list(result_key, current_key, path)
|
48
|
+
dict_key = result_key + format_key(current_key.value, result_key)
|
49
|
+
location = "#{path[@root.size + 1..-1]}:#{current_key.start_line}"
|
50
|
+
@key_list[dict_key].push(location)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "yaml_duplicate_checker/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "yaml_duplicate_checker"
|
8
|
+
spec.version = YamlDuplicateChecker::VERSION
|
9
|
+
spec.authors = ["ippachi"]
|
10
|
+
spec.email = ["ivalice1218@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{check duplidate in yaml file}
|
13
|
+
spec.description = %q{check duplidate in yaml file}
|
14
|
+
spec.homepage = "https://github.com/ippachi/yaml_duplicate_checker"
|
15
|
+
|
16
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
17
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
18
|
+
if spec.respond_to?(:metadata)
|
19
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
20
|
+
spec.metadata["source_code_uri"] = "https://github.com/ippachi/yaml_duplicate_checker"
|
21
|
+
spec.metadata["changelog_uri"] = "https://github.com/ippachi/yaml_duplicate_checker/master/CHANGELOG.md"
|
22
|
+
else
|
23
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
24
|
+
"public gem pushes."
|
25
|
+
end
|
26
|
+
|
27
|
+
# Specify which files should be added to the gem when it is released.
|
28
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
29
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
30
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
31
|
+
end
|
32
|
+
spec.bindir = "exe"
|
33
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
34
|
+
spec.require_paths = ["lib"]
|
35
|
+
|
36
|
+
spec.add_development_dependency "bundler", "~> 1.17"
|
37
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
38
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
39
|
+
spec.add_development_dependency "pry", "~> 0.12"
|
40
|
+
spec.add_development_dependency "rubocop", "~> 0.65"
|
41
|
+
end
|
metadata
ADDED
@@ -0,0 +1,130 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: yaml_duplicate_checker
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- ippachi
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-02-19 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.17'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.17'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.12'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.12'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rubocop
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.65'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.65'
|
83
|
+
description: check duplidate in yaml file
|
84
|
+
email:
|
85
|
+
- ivalice1218@gmail.com
|
86
|
+
executables:
|
87
|
+
- ydc
|
88
|
+
extensions: []
|
89
|
+
extra_rdoc_files: []
|
90
|
+
files:
|
91
|
+
- ".gitignore"
|
92
|
+
- ".rspec"
|
93
|
+
- ".rubocop.yml"
|
94
|
+
- ".travis.yml"
|
95
|
+
- Gemfile
|
96
|
+
- Gemfile.lock
|
97
|
+
- README.md
|
98
|
+
- Rakefile
|
99
|
+
- bin/console
|
100
|
+
- bin/setup
|
101
|
+
- exe/ydc
|
102
|
+
- lib/yaml_duplicate_checker.rb
|
103
|
+
- lib/yaml_duplicate_checker/version.rb
|
104
|
+
- yaml_duplicate_checker.gemspec
|
105
|
+
homepage: https://github.com/ippachi/yaml_duplicate_checker
|
106
|
+
licenses: []
|
107
|
+
metadata:
|
108
|
+
homepage_uri: https://github.com/ippachi/yaml_duplicate_checker
|
109
|
+
source_code_uri: https://github.com/ippachi/yaml_duplicate_checker
|
110
|
+
changelog_uri: https://github.com/ippachi/yaml_duplicate_checker/master/CHANGELOG.md
|
111
|
+
post_install_message:
|
112
|
+
rdoc_options: []
|
113
|
+
require_paths:
|
114
|
+
- lib
|
115
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - ">="
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '0'
|
120
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
requirements: []
|
126
|
+
rubygems_version: 3.0.1
|
127
|
+
signing_key:
|
128
|
+
specification_version: 4
|
129
|
+
summary: check duplidate in yaml file
|
130
|
+
test_files: []
|