terraform_landscape 0.1.18 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 306ca967b3047b11062b571b5e9839ea1fb4d9e7f8edb3e4782f01dd78b52d1c
4
- data.tar.gz: 8ddc10200bea03580c889c12dfe2ea9301af8a4a011fd29cff155fccb560070d
3
+ metadata.gz: 238ce061acc60e402752059e8db87f6948db29b0c88ef4865b4f67405de76d49
4
+ data.tar.gz: 1a42681d106186e774a8a40d91eb7363b0076ee14de2b4bfe9263f28233024ee
5
5
  SHA512:
6
- metadata.gz: fe4496da96c56269be1cd9a671a864fbe5f008495f68b2ed73b58de05a509b74920c046db0be7169cc32ee2a72a87d0821e8e9f5a224c5bfaa3309136cb7f847
7
- data.tar.gz: '07407046298b9b37ee82fe4e3acb73af21689af22f946e4064b2aac86b7ae343c5f5528571dd401ea0efa583375fb378c918f146e6abeb0bd9133c6a1b4bec67'
6
+ metadata.gz: bfd3f019872030754bfd6a22876af12630ec0cab498d8d1d61c10f400eee9a5904fae8e6f53d0abb7411af3510f9211791bba469cfce41bae2c868564e05c6be
7
+ data.tar.gz: 6c01e25f7987eda2c7d710a7509e1e09587f70a97cb6064f20dcbb10adabf350cedb2be6af58a58f3862d15b73a9856fbbdb890878a94192a0f149be2e4b2a09
@@ -111,7 +111,8 @@ class TerraformLandscape::TerraformPlan # rubocop:disable Metrics/ClassLength
111
111
  # Can't JSON.parse an empty string, so handle it separately
112
112
  return '' if value.strip.empty?
113
113
 
114
- JSON.pretty_generate(JSON.parse(value),
114
+ sorted = recursive_sort(JSON.parse(value))
115
+ JSON.pretty_generate(sorted,
115
116
  {
116
117
  indent: ' ',
117
118
  space: ' ',
@@ -120,6 +121,19 @@ class TerraformLandscape::TerraformPlan # rubocop:disable Metrics/ClassLength
120
121
  })
121
122
  end
122
123
 
124
+ def recursive_sort(obj)
125
+ case obj
126
+ when Array
127
+ obj.map { |item| recursive_sort(item) }
128
+ when Hash
129
+ obj.keys.sort.each_with_object({}) do |key, hash|
130
+ hash[key] = recursive_sort(obj[key])
131
+ end
132
+ else
133
+ obj
134
+ end
135
+ end
136
+
123
137
  def display_diff(old, new, indent)
124
138
  @out.print Diffy::Diff.new(old, new, { context: @diff_context_lines })
125
139
  .to_s(String.disable_colorization ? :text : :color)
@@ -2,5 +2,5 @@
2
2
 
3
3
  # Defines the gem version.
4
4
  module TerraformLandscape
5
- VERSION = '0.1.18'.freeze
5
+ VERSION = '0.2.0'.freeze
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: terraform_landscape
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.18
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Coinbase
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-06-10 00:00:00.000000000 Z
12
+ date: 2018-07-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: colorize