remocon 0.4.1 → 0.4.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.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +6 -4
- data/lib/remocon/command/lib/interpreter_helper.rb +2 -5
- data/lib/remocon/command/pull_command.rb +2 -0
- data/lib/remocon/sorter/condition_sorter.rb +10 -12
- data/lib/remocon/sorter/parameter_sorter.rb +28 -12
- data/lib/remocon/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ba22438936a77cbe485e6bb7ae72b0f059d5f3fa
|
4
|
+
data.tar.gz: 9ff3bbda91e0d622d99aef839558b6b834475a25
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 49795b41a9351d77fffe996ae612a8ce804bdc0e5610dabf32b13cc1e602dc71ad1baaf52a0041f62ea7f043f304b8bc683bacaad30ae37dadcdef9b103aa234
|
7
|
+
data.tar.gz: 456bbde3f2091231fd43bbfcc38c2c605991f6586ad1edca5f4c72dfa60443e92965a29608fc8311c67f8dc89f6cd599b3dd9c5cc49a3772c1d1562604d020bf
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -2,10 +2,12 @@
|
|
2
2
|
|
3
3
|
# Remocon
|
4
4
|
|
5
|
-
*remocon* is a CLI for Firebase Remote Config via its REST API.
|
6
|
-
|
5
|
+
*remocon* is a CLI for Firebase Remote Config via its REST API. Conditions and parameters are managed by YAML files.
|
6
|
+
The goal of this gem is Remote Config as a Code. :)
|
7
7
|
|
8
|
-
*
|
8
|
+
*Now conditions cannot be updated via API so that you can modify only parameters.*
|
9
|
+
|
10
|
+
If you'd like to use this on CircleCI, you can use https://github.com/jmatsu/remocon-starter-kit .
|
9
11
|
|
10
12
|
## Usage
|
11
13
|
|
@@ -41,7 +43,7 @@ FIREBASE_PROJECT_ID and REMOTE_CONFIG_ACCESS_TOKEN are supported but they are de
|
|
41
43
|
|
42
44
|
### Edit configs on your local
|
43
45
|
|
44
|
-
Condition definitions and parameter definitions are separated. You
|
46
|
+
Condition definitions and parameter definitions are separated. You need to modify these files.
|
45
47
|
|
46
48
|
*parameters.yml*
|
47
49
|
|
@@ -2,9 +2,6 @@
|
|
2
2
|
|
3
3
|
module Remocon
|
4
4
|
module InterpreterHelper
|
5
|
-
include Remocon::ConditionSorter
|
6
|
-
include Remocon::ParameterSorter
|
7
|
-
|
8
5
|
def cmd_opts
|
9
6
|
raise NotImplementedError
|
10
7
|
end
|
@@ -25,7 +22,7 @@ module Remocon
|
|
25
22
|
end
|
26
23
|
|
27
24
|
def parameter_hash
|
28
|
-
@parameter_hash ||=
|
25
|
+
@parameter_hash ||= read_parameters.first
|
29
26
|
end
|
30
27
|
|
31
28
|
def read_conditions
|
@@ -36,7 +33,7 @@ module Remocon
|
|
36
33
|
end
|
37
34
|
|
38
35
|
def condition_array
|
39
|
-
@condition_array ||=
|
36
|
+
@condition_array ||= read_conditions.first
|
40
37
|
end
|
41
38
|
|
42
39
|
def condition_names
|
@@ -2,22 +2,20 @@
|
|
2
2
|
|
3
3
|
module Remocon
|
4
4
|
module ConditionSorter
|
5
|
-
CONDITION_KEYS = %
|
5
|
+
CONDITION_KEYS = %w(name expression tagColor).freeze
|
6
|
+
|
7
|
+
def comparator_of_condition_keys(left, right)
|
8
|
+
(CONDITION_KEYS.index(left) || 10_000) <=> (CONDITION_KEYS.index(right) || 10_000)
|
9
|
+
end
|
6
10
|
|
7
11
|
def sort_conditions(conditions)
|
8
12
|
conditions
|
9
|
-
.
|
10
|
-
.sort_by { |e| e[:name] }
|
13
|
+
.sort_by { |e| e["name"] || e[:name] }
|
11
14
|
.map do |e|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
(CONDITION_KEYS.index(a) || 10_000) <=> (CONDITION_KEYS.index(b) || 10_000)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
arr.each_with_object({}) { |(k, v), h| h[k] = v }.with_indifferent_access
|
15
|
+
e.stringify_keys
|
16
|
+
.sort { |(a, _), (b, _)| comparator_of_condition_keys(a, b) }
|
17
|
+
.each_with_object({}) { |(k, v), acc| acc[k] = v }
|
18
|
+
.with_indifferent_access
|
21
19
|
end
|
22
20
|
end
|
23
21
|
end
|
@@ -2,23 +2,39 @@
|
|
2
2
|
|
3
3
|
module Remocon
|
4
4
|
module ParameterSorter
|
5
|
-
PARAMETER_KEYS = %
|
5
|
+
PARAMETER_KEYS = %w(description value file normalizer conditions options).freeze
|
6
|
+
|
7
|
+
def comparator_of_parameter_keys(left, right)
|
8
|
+
PARAMETER_KEYS.index(left) <=> PARAMETER_KEYS.index(right)
|
9
|
+
end
|
6
10
|
|
7
11
|
def sort_parameters(parameters)
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
12
|
+
params = parameters.with_indifferent_access
|
13
|
+
|
14
|
+
params.keys.sort.each_with_object({}) do |key, acc|
|
15
|
+
param = params[key]
|
16
|
+
|
17
|
+
acc[key] = param
|
18
|
+
.stringify_keys
|
19
|
+
.sort { |(a, _), (b, _)| comparator_of_parameter_keys(a, b) }
|
20
|
+
.each_with_object({}) do |(inside_key, _), inside_acc|
|
21
|
+
if inside_key == "conditions"
|
22
|
+
inside_acc[inside_key] = sort_conditions_of_parameters(param[inside_key])
|
23
|
+
else
|
24
|
+
inside_acc[inside_key] = param[inside_key]
|
25
|
+
end
|
14
26
|
end
|
27
|
+
end.with_indifferent_access
|
28
|
+
end
|
15
29
|
|
16
|
-
|
17
|
-
|
18
|
-
|
30
|
+
def sort_conditions_of_parameters(conditions)
|
31
|
+
conditions.with_indifferent_access.to_a.each_with_object({}) do |(k, v), acc|
|
32
|
+
acc[k] = v.stringify_keys
|
33
|
+
.sort { |(a, _), (b, _)| comparator_of_parameter_keys(a, b) }
|
34
|
+
.each_with_object({}) do |(inside_key, _), inside_acc|
|
35
|
+
inside_acc[inside_key] = v[inside_key]
|
36
|
+
end
|
19
37
|
end
|
20
|
-
|
21
|
-
arr.each_with_object({}) { |hash, acc| acc.merge!(hash) }.with_indifferent_access
|
22
38
|
end
|
23
39
|
end
|
24
40
|
end
|
data/lib/remocon/version.rb
CHANGED
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.
|
4
|
+
version: 0.4.2
|
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-
|
11
|
+
date: 2018-08-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|