ach_flattenmeta 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/lib/ach_flattenmeta.rb +39 -0
- metadata +44 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 1d5ee28f9158651c97fe0c6a91045b0addc1292fd9c4b7c924e7b98351867170
|
4
|
+
data.tar.gz: 0c1bdc04172c6a549ec11697504c8555cc55213e334767ef7b41c71bfd08c53d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: bf6e51f72791554beacc3ee989d7278c42e6db4e38d8a26abdcb7d1488e16716b22995b82d2286a89f6c6663b571a9d5d58449a33a119be0fe9b7f67509faf9b
|
7
|
+
data.tar.gz: 47a2cd8f6713af582429b81f462bb9fb6709145552496d0f2379c8b3bad8965e4329e1c6242e40fc1c7f60d3a750ee0ab4ead67def9cc43ad8e8a09bae3cef15
|
@@ -0,0 +1,39 @@
|
|
1
|
+
class FlattenMeta
|
2
|
+
# First create a simple and flattened hash with
|
3
|
+
# k => { value, prio }
|
4
|
+
#
|
5
|
+
# This can be iterated over using each method provided
|
6
|
+
#
|
7
|
+
def initialize( os_version, node_environment, confhash)
|
8
|
+
@flatconf = Hash.new()
|
9
|
+
@os_version = os_version
|
10
|
+
@node_environment = node_environment
|
11
|
+
@confhash = confhash
|
12
|
+
end # initialize
|
13
|
+
|
14
|
+
def each
|
15
|
+
filter()
|
16
|
+
@flatconf.each { |k,v | yield k, v['value'] if v['active'] }
|
17
|
+
end # each
|
18
|
+
|
19
|
+
private
|
20
|
+
def filter()
|
21
|
+
@confhash.each do | location, data|
|
22
|
+
if (data['metadata']['environments'] & [@node_environment, 'all']).any? &&
|
23
|
+
(data['metadata']['platforms'] & [@os_version, 'all']).any?
|
24
|
+
|
25
|
+
prio = data['metadata']['priority']
|
26
|
+
active = data['metadata']['active']
|
27
|
+
|
28
|
+
data.each do | k, v |
|
29
|
+
next if k == 'metadata'
|
30
|
+
if @flatconf.key?(k)
|
31
|
+
@flatconf[k] = { 'value' => v, 'priority' => prio, 'active' => active } if @flatconf[k]['priority'] > prio
|
32
|
+
else
|
33
|
+
@flatconf[k] = { 'value' => v, 'priority' => prio, 'active' => active }
|
34
|
+
end # if
|
35
|
+
end #each
|
36
|
+
end # if
|
37
|
+
end # each
|
38
|
+
end # def
|
39
|
+
end # class
|
metadata
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ach_flattenmeta
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Rogier Jobse
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-07-26 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: A flattenmeta helper gem
|
14
|
+
email: rogier.jobse@xs4all.nl
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/ach_flattenmeta.rb
|
20
|
+
homepage: http://rubygems.org/gems/ach_flattenmeta
|
21
|
+
licenses:
|
22
|
+
- MIT
|
23
|
+
metadata: {}
|
24
|
+
post_install_message:
|
25
|
+
rdoc_options: []
|
26
|
+
require_paths:
|
27
|
+
- lib
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ">="
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
requirements: []
|
39
|
+
rubyforge_project:
|
40
|
+
rubygems_version: 2.7.6
|
41
|
+
signing_key:
|
42
|
+
specification_version: 4
|
43
|
+
summary: flattenmeta helper gem
|
44
|
+
test_files: []
|