kontent-jekyll 0.11.1 → 0.11.2

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.
@@ -1,88 +1,88 @@
1
- module Kentico
2
- module Kontent
3
- module Utils
4
- ##
5
- # Transforms any object into easily seriazible format.
6
- # OpenStruct is converted to hash and Symbol keys are transformed to string keys.
7
-
8
- def normalize_object(object)
9
- stringify_all_keys(to_hash(object))
10
- end
11
-
12
- private
13
-
14
- def open_struct_values_to_hash(struct)
15
- hash = {}
16
- struct.each_pair do |key, value|
17
- hash[key] = to_hash(value)
18
- end
19
- hash
20
- end
21
-
22
- def hash_values_to_hash(hash)
23
- hash.reduce({}) do |reduced, pair|
24
- key = pair[0]
25
- value = pair[1]
26
- new_pair = { key => to_hash(value) }
27
- reduced.merge(new_pair)
28
- end
29
- end
30
-
31
- def to_hash(object)
32
- case object
33
- when OpenStruct
34
- open_struct_values_to_hash object
35
- when Array
36
- array_values_to_hash object
37
- when Hash
38
- hash_values_to_hash object
39
- else
40
- object
41
- end
42
- end
43
-
44
- def stringify_all_keys_in_array(array)
45
- array.map do |item|
46
- case item
47
- when Hash then stringify_all_keys_in_hash item
48
- when Array then stringify_all_keys_in_array item
49
- else item end
50
- end
51
- end
52
-
53
- def stringify_all_keys_in_hash(hash)
54
- stringified_hash = {}
55
-
56
- hash.each do |k, v|
57
- stringified_hash[k.to_s] =
58
- case v
59
- when Array then stringify_all_keys_in_array v
60
- when Hash then stringify_all_keys_in_hash v
61
- else v
62
- end
63
- end
64
-
65
- stringified_hash
66
- end
67
-
68
- def stringify_all_keys(object)
69
- case object
70
- when Hash then stringify_all_keys_in_hash object
71
- when Array then stringify_all_keys_in_array object
72
- else object
73
- end
74
- end
75
-
76
- def array_values_to_hash(array)
77
- array.map do |item|
78
- case item
79
- when Array then array_values_to_hash item
80
- when Hash then hash_values_to_hash item
81
- when OpenStruct then open_struct_values_to_hash item
82
- else item
83
- end
84
- end
85
- end
86
- end
87
- end
1
+ module Kentico
2
+ module Kontent
3
+ module Utils
4
+ ##
5
+ # Transforms any object into easily seriazible format.
6
+ # OpenStruct is converted to hash and Symbol keys are transformed to string keys.
7
+
8
+ def normalize_object(object)
9
+ stringify_all_keys(to_hash(object))
10
+ end
11
+
12
+ private
13
+
14
+ def open_struct_values_to_hash(struct)
15
+ hash = {}
16
+ struct.each_pair do |key, value|
17
+ hash[key] = to_hash(value)
18
+ end
19
+ hash
20
+ end
21
+
22
+ def hash_values_to_hash(hash)
23
+ hash.reduce({}) do |reduced, pair|
24
+ key = pair[0]
25
+ value = pair[1]
26
+ new_pair = { key => to_hash(value) }
27
+ reduced.merge(new_pair)
28
+ end
29
+ end
30
+
31
+ def to_hash(object)
32
+ case object
33
+ when OpenStruct
34
+ open_struct_values_to_hash object
35
+ when Array
36
+ array_values_to_hash object
37
+ when Hash
38
+ hash_values_to_hash object
39
+ else
40
+ object
41
+ end
42
+ end
43
+
44
+ def stringify_all_keys_in_array(array)
45
+ array.map do |item|
46
+ case item
47
+ when Hash then stringify_all_keys_in_hash item
48
+ when Array then stringify_all_keys_in_array item
49
+ else item end
50
+ end
51
+ end
52
+
53
+ def stringify_all_keys_in_hash(hash)
54
+ stringified_hash = {}
55
+
56
+ hash.each do |k, v|
57
+ stringified_hash[k.to_s] =
58
+ case v
59
+ when Array then stringify_all_keys_in_array v
60
+ when Hash then stringify_all_keys_in_hash v
61
+ else v
62
+ end
63
+ end
64
+
65
+ stringified_hash
66
+ end
67
+
68
+ def stringify_all_keys(object)
69
+ case object
70
+ when Hash then stringify_all_keys_in_hash object
71
+ when Array then stringify_all_keys_in_array object
72
+ else object
73
+ end
74
+ end
75
+
76
+ def array_values_to_hash(array)
77
+ array.map do |item|
78
+ case item
79
+ when Array then array_values_to_hash item
80
+ when Hash then hash_values_to_hash item
81
+ when OpenStruct then open_struct_values_to_hash item
82
+ else item
83
+ end
84
+ end
85
+ end
86
+ end
87
+ end
88
88
  end
@@ -1,5 +1,5 @@
1
- module Kentico
2
- module Kontent
3
- VERSION = '0.11.1'
4
- end
5
- end
1
+ module Kentico
2
+ module Kontent
3
+ VERSION = '0.11.2'
4
+ end
5
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kontent-jekyll
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.1
4
+ version: 0.11.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - RadoslavK
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-01-06 00:00:00.000000000 Z
11
+ date: 2020-01-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -119,6 +119,7 @@ extra_rdoc_files: []
119
119
  files:
120
120
  - ".gitignore"
121
121
  - ".rspec"
122
+ - ".travis.yml"
122
123
  - Gemfile
123
124
  - Gemfile.lock
124
125
  - LICENSE