remocon 0.4.2 → 0.4.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ba22438936a77cbe485e6bb7ae72b0f059d5f3fa
4
- data.tar.gz: 9ff3bbda91e0d622d99aef839558b6b834475a25
3
+ metadata.gz: fb155fff5f26310779b98af6f8b97e1ef9d61875
4
+ data.tar.gz: 41316049cc8a0e64ce00c4326842b5e8d2071aed
5
5
  SHA512:
6
- metadata.gz: 49795b41a9351d77fffe996ae612a8ce804bdc0e5610dabf32b13cc1e602dc71ad1baaf52a0041f62ea7f043f304b8bc683bacaad30ae37dadcdef9b103aa234
7
- data.tar.gz: 456bbde3f2091231fd43bbfcc38c2c605991f6586ad1edca5f4c72dfa60443e92965a29608fc8311c67f8dc89f6cd599b3dd9c5cc49a3772c1d1562604d020bf
6
+ metadata.gz: 58f9ad9ffc5d724499b8fd3e1820011012b562b3443970b5ffd04f9c81b3a8a5166b4366ce4289b2b472db8fde956d42d9b18eca0745ff62631ce26ba6a38dc5
7
+ data.tar.gz: 4bd5ad66b49fcf9a5534c0c62147896ec5ed61dabca8ac0d57abf3051dd344897b45799facdbe8967dbce909efd98e46b2ace6710bafd2ee979aadce60b9f4bc
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- remocon (0.4.2)
4
+ remocon (0.4.3)
5
5
  activesupport
6
6
  googleauth
7
7
  thor
@@ -6,10 +6,11 @@ module Remocon
6
6
  class RemoteConfig
7
7
  include Remocon::InterpreterHelper
8
8
 
9
- attr_reader :config
9
+ attr_reader :config, :cmd_opts
10
10
 
11
11
  def initialize(opts)
12
12
  @config = Remocon::Config.new(opts)
13
+ @cmd_opts = { validate_only: false }
13
14
  end
14
15
 
15
16
  def require_parameters_file_path
@@ -20,16 +21,15 @@ module Remocon
20
21
  config.conditions_file_path
21
22
  end
22
23
 
23
- def raw_conditions
24
- YAML.safe_load(File.open(require_conditions_file_path).read).map(&:with_indifferent_access)
24
+ def conditions_to_be_compared
25
+ JSON.parse(JSON.pretty_generate(condition_array.map { |c| c.skip_nil_values.stringify_values })).map(&:with_indifferent_access)
25
26
  end
26
27
 
27
- def raw_parameters
28
- YAML.safe_load(File.open(require_parameters_file_path).read).with_indifferent_access
28
+ def parameters_to_be_compared
29
+ JSON.parse(JSON.pretty_generate(parameter_hash.skip_nil_values.stringify_values)).with_indifferent_access
29
30
  end
30
31
  end
31
32
 
32
- include Remocon::InterpreterHelper
33
33
  include Remocon::ConditionSorter
34
34
  include Remocon::ParameterSorter
35
35
 
@@ -41,14 +41,6 @@ module Remocon
41
41
  @left = RemoteConfig.new(opts)
42
42
  end
43
43
 
44
- def require_parameters_file_path
45
- config.parameters_file_path
46
- end
47
-
48
- def require_conditions_file_path
49
- config.conditions_file_path
50
- end
51
-
52
44
  def run
53
45
  raw_json, etag = Remocon::Request.pull(config)
54
46
 
@@ -60,8 +52,8 @@ module Remocon
60
52
  parameters = raw_hash[:parameters] || {}
61
53
 
62
54
  if config.merge? && File.exist?(config.parameters_file_path) && File.exist?(config.parameters_file_path)
63
- unchanged_conditions, added_conditions, changed_conditions, = conditions_diff(left.raw_conditions, conditions)
64
- unchanged_parameters, added_parameters, changed_parameters, = parameters_diff(left.raw_parameters, parameters)
55
+ unchanged_conditions, added_conditions, changed_conditions, = conditions_diff(left.conditions_to_be_compared, conditions)
56
+ unchanged_parameters, added_parameters, changed_parameters, = parameters_diff(left.parameters_to_be_compared, parameters)
65
57
 
66
58
  conditions_yaml = JSON.parse(sort_conditions(unchanged_conditions + added_conditions + changed_conditions).to_json).to_yaml
67
59
  parameters_yaml = JSON.parse(sort_parameters(unchanged_parameters.merge(added_parameters).merge(changed_parameters)).to_json).to_yaml
@@ -89,12 +81,12 @@ module Remocon
89
81
 
90
82
  (right_names & left_names).each do |k|
91
83
  old = left.find { |c| c[:name] == k }
92
- new = Remocon::ConditionFileDumper.new(right.find { |c| c[:name] == k }).dump
84
+ new = right.find { |c| c[:name] == k }
93
85
 
94
86
  if old == new
95
87
  unchanged.push(old)
96
88
  else
97
- changed.push(new)
89
+ changed.push(Remocon::ConditionFileDumper.new(new).dump)
98
90
  end
99
91
  end
100
92
 
@@ -119,20 +111,20 @@ module Remocon
119
111
  unchanged = {}
120
112
 
121
113
  (right.keys & left.keys).each do |k|
122
- old = { k => left[k] }
123
- new = Remocon::ParameterFileDumper.new({ k => right[k] }).dump
114
+ # both of left and right is config json's format
115
+ # comparison should be done based on the format but dumped format should be returned
116
+ old = left[k]
117
+ new = right[k]
124
118
 
125
119
  if old == new
126
- unchanged.merge!(old)
120
+ unchanged.merge!(Remocon::ParameterFileDumper.new({ k => old }).dump)
127
121
  else
128
- changed.merge!(new)
122
+ changed.merge!(Remocon::ParameterFileDumper.new({ k => new }).dump)
129
123
  end
130
124
  end
131
125
 
132
- removed = {}
133
-
134
- removed_keys.each do |k|
135
- removed[k] = left[k]
126
+ removed = removed_keys.each_with_object({}) do |k, acc|
127
+ acc.merge!(Remocon::ParameterFileDumper.new({ k => left[k] }).dump)
136
128
  end
137
129
 
138
130
  [unchanged, added, changed, removed]
@@ -7,13 +7,9 @@ module Remocon
7
7
  end
8
8
 
9
9
  def validate
10
- return if [FalseClass, TrueClass].include?(@content.class)
11
-
12
- begin
13
- @bool_val = @content.to_s.to_boolean
14
- rescue ArgumentError => e
15
- raise ValidationError, e.message
16
- end
10
+ @bool_val = @content.to_s.to_boolean
11
+ rescue ArgumentError => e
12
+ raise ValidationError, e.message
17
13
  end
18
14
 
19
15
  def normalize
@@ -3,7 +3,7 @@
3
3
  class Hash
4
4
  def skip_nil_values
5
5
  dup.compact.each_with_object({}) do |(k, v), acc|
6
- next unless v
6
+ next if v.nil?
7
7
  acc[k] = case v
8
8
  when Hash
9
9
  v.skip_nil_values
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Remocon
4
- VERSION = "0.4.2"
4
+ VERSION = "0.4.3"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: remocon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jumpei Matsuda
8
8
  autorequire:
9
9
  bindir: cmd
10
10
  cert_chain: []
11
- date: 2018-08-16 00:00:00.000000000 Z
11
+ date: 2018-08-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport