yaml-ostruct 0.4.2 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/yaml/version.rb +1 -1
- data/lib/yaml/yaml_ostruct_impl.rb +22 -2
- metadata +9 -9
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 59c3e433860d99b053d5a297e14aae64e2c7d974
|
|
4
|
+
data.tar.gz: 45e4fa08cfaa323085f18fe37e10d4542438fea5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 28590ac5beb1476c87f6ed7f4a7207199ead19610b53af5593599e267031aa1ff2f9934631a2c3cb94deddc8b7fb12cba46a6ac8f369922ae5dc0bcfe6836198
|
|
7
|
+
data.tar.gz: 9d6c3ed7004d72e1f96968bdc3a59f3fcebe90ef8551f134645d5dc6655d21b238270015c96676d0fb244b5959983f791c8837d4ada9a87503389a715ce27f3f
|
data/lib/yaml/version.rb
CHANGED
|
@@ -10,11 +10,13 @@ module YamlOstruct
|
|
|
10
10
|
attr_reader :config
|
|
11
11
|
attr_accessor :omit_path
|
|
12
12
|
attr_accessor :deep_merge
|
|
13
|
+
attr_accessor :skip_error
|
|
13
14
|
|
|
14
15
|
def initialize(args = {})
|
|
15
16
|
@config = OpenStruct.new
|
|
16
17
|
@omit_path = args.fetch :omit_path, false
|
|
17
18
|
@deep_merge = args.fetch :deep_merge, false
|
|
19
|
+
@skip_error = args.fetch :skip_error, false
|
|
18
20
|
end
|
|
19
21
|
|
|
20
22
|
def delete(key)
|
|
@@ -48,7 +50,16 @@ module YamlOstruct
|
|
|
48
50
|
|
|
49
51
|
Find.find(dir) do |yaml_file|
|
|
50
52
|
next unless yaml_file =~ /.*\.yml$/ or yaml_file =~ /.*\.yaml$/
|
|
51
|
-
|
|
53
|
+
|
|
54
|
+
new_config = begin
|
|
55
|
+
YAML.load_file(yaml_file)
|
|
56
|
+
rescue StandardError => e
|
|
57
|
+
if @skip_error
|
|
58
|
+
nil
|
|
59
|
+
else
|
|
60
|
+
raise e
|
|
61
|
+
end
|
|
62
|
+
end
|
|
52
63
|
|
|
53
64
|
attr_name = File.basename(yaml_file, File.extname(yaml_file)).to_sym
|
|
54
65
|
if config.respond_to?(attr_name)
|
|
@@ -74,7 +85,16 @@ module YamlOstruct
|
|
|
74
85
|
|
|
75
86
|
extension = File.extname(file_name)
|
|
76
87
|
next unless extension == '.yml' or extension == '.yaml'
|
|
77
|
-
|
|
88
|
+
|
|
89
|
+
new_config = begin
|
|
90
|
+
YAML.load_file("#{dir}/#{file_name}")
|
|
91
|
+
rescue StandardError => e
|
|
92
|
+
if @skip_error
|
|
93
|
+
nil
|
|
94
|
+
else
|
|
95
|
+
raise e
|
|
96
|
+
end
|
|
97
|
+
end
|
|
78
98
|
config.send("#{File.basename(file_name, extension)}=", new_config.to_hashugar)
|
|
79
99
|
end
|
|
80
100
|
config
|
metadata
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: yaml-ostruct
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.5.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Daniel Han
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2018-10-19 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: hashugar
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
|
-
- - ~>
|
|
17
|
+
- - "~>"
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
19
|
version: '1.0'
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
|
-
- - ~>
|
|
24
|
+
- - "~>"
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
26
|
version: '1.0'
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: deep_merge
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
30
30
|
requirements:
|
|
31
|
-
- - ~>
|
|
31
|
+
- - "~>"
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
33
|
version: '1.0'
|
|
34
34
|
type: :runtime
|
|
35
35
|
prerelease: false
|
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
37
|
requirements:
|
|
38
|
-
- - ~>
|
|
38
|
+
- - "~>"
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
40
|
version: '1.0'
|
|
41
41
|
description: Read yaml files recursively from a given directory and return an OpenStruct
|
|
@@ -58,17 +58,17 @@ require_paths:
|
|
|
58
58
|
- lib
|
|
59
59
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
60
60
|
requirements:
|
|
61
|
-
- -
|
|
61
|
+
- - ">="
|
|
62
62
|
- !ruby/object:Gem::Version
|
|
63
63
|
version: 2.0.0
|
|
64
64
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
65
65
|
requirements:
|
|
66
|
-
- -
|
|
66
|
+
- - ">="
|
|
67
67
|
- !ruby/object:Gem::Version
|
|
68
68
|
version: '0'
|
|
69
69
|
requirements: []
|
|
70
70
|
rubyforge_project:
|
|
71
|
-
rubygems_version: 2.
|
|
71
|
+
rubygems_version: 2.5.1
|
|
72
72
|
signing_key:
|
|
73
73
|
specification_version: 4
|
|
74
74
|
summary: Read yaml files with path into an OpenStruct
|