yaml-sugar 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6ec99eba08db27289dfd851ee6a46f4c04decb90
4
+ data.tar.gz: be698fa65dde57ec174c86a29d36bab0a5e4e111
5
+ SHA512:
6
+ metadata.gz: e97fa623e70bb3dfc4c4d0d7c2c2920866412e53d5363ef0b38b2bd4f1e68ec0a5f3d7addf0fd4000ff2c86929e598919d6f05520d0766feff18451739aa602b
7
+ data.tar.gz: b6c97a01a06c3b071a967f415ae9c0da0af5ee3d2679a78097fb89e8cb38c9b830413a23bba8474d0b5edef6ca115b9e2c502527e52d2a11990c78e8d817e20b
@@ -0,0 +1,4 @@
1
+ # hash-config bundle version
2
+ module YamlSugar
3
+ VERSION = '0.0.1'.freeze
4
+ end
@@ -0,0 +1,33 @@
1
+ require 'deep_merge'
2
+ require 'find'
3
+ require 'hashugar'
4
+ require 'yaml'
5
+
6
+ # YamlSugar class
7
+ module YamlSugar
8
+ # Define on self, since it's a module method
9
+ def self.method_missing(method_sym, *_args)
10
+ config = {}
11
+ @yaml_files.each do |yaml|
12
+ if File.basename(yaml, File.extname(yaml)) == method_sym.to_s
13
+ config.deep_merge! YAML.load_file(yaml)
14
+ end
15
+ end
16
+
17
+ config = config.to_hashugar
18
+ self.class.instance_eval do
19
+ define_method(method_sym) { config }
20
+ end
21
+
22
+ config
23
+ end
24
+
25
+ def self.load(dir)
26
+ fail "Parametr #{dir} is not a valid directory" unless File.directory? dir
27
+
28
+ @yaml_files ||= []
29
+ Find.find(dir) do |path|
30
+ @yaml_files << File.join(Dir.pwd, path) if path =~ /.*\.yml$/ or path =~ /.*\.yaml$/
31
+ end
32
+ end
33
+ end
data/lib/yaml-sugar.rb ADDED
@@ -0,0 +1 @@
1
+ require 'yaml-sugar/yaml-sugar'
metadata ADDED
@@ -0,0 +1,102 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: yaml-sugar
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Daniel Han
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-04-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: hashugar
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: deep_merge
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '5.7'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '5.7'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Read yaml files recursively from a given directory and return an OpenStruct
70
+ email: hex0cter@gmail.com
71
+ executables: []
72
+ extensions: []
73
+ extra_rdoc_files: []
74
+ files:
75
+ - lib/yaml-sugar.rb
76
+ - lib/yaml-sugar/version.rb
77
+ - lib/yaml-sugar/yaml-sugar.rb
78
+ homepage: https://github.com/hex0cter
79
+ licenses:
80
+ - MIT
81
+ metadata: {}
82
+ post_install_message:
83
+ rdoc_options: []
84
+ require_paths:
85
+ - lib
86
+ required_ruby_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ required_rubygems_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ requirements: []
97
+ rubyforge_project:
98
+ rubygems_version: 2.5.1
99
+ signing_key:
100
+ specification_version: 4
101
+ summary: Read yaml into an OpenStruct
102
+ test_files: []