capistrano-ops 1.0.3 → 1.0.4

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: e7944bee1bc903f6dc873cac78ac255e7811341c1c8bf291de8cf0c2bc2a01a4
4
- data.tar.gz: 49afc833c49c3b2d01009c2a7f13fa5a59e04b70691d9baac51ac292f6101240
3
+ metadata.gz: 6028f991e964a7ce6f029c3878b1c36b322802df80013019de85c1f9f9220f9f
4
+ data.tar.gz: 1664aea997e5db3daa236ea04758cb68bd3b34262e29faa90fa41564b2e88aeb
5
5
  SHA512:
6
- metadata.gz: b02060e7adb1a90050839b35cb86e3e19d1b5a32b09b723ce9f10933afb99a347b9a83ed0cea99e344c972262ba01db9f455f668385c493f2cf919e29bd9a5ab
7
- data.tar.gz: d2e61ed960c9a4c37411b23e63f4e05faeb9047c613a1038ac38bf5eab5a5ae50d220dabec34c6f2bca539f9190180fc3d426e248273ecf27655dc5eb36bee4a
6
+ metadata.gz: 99aba98f09eee78b13851eec6ad35dd142fe1252903af6f3c5faf36260c02c693ef6245eddef8dfdefaac9965c9836b08de2620bf449716e47ad096380e26d3b
7
+ data.tar.gz: 69d303c90aad93e679ac797d90bf759f615e82431ef9a39008fad8c430aa66938cf1fd2b14dfb4249bc9c17bd8fbdf76786c00d0a1b226b3c588fe650024b1e8
@@ -56,20 +56,10 @@ module Capistrano
56
56
  end
57
57
  end
58
58
 
59
- def local_figaro_yml(env)
59
+ def local_figaro_yml(_env)
60
60
  @local_figaro_yml ||= YAML.load(ERB.new(File.read(figaro_yml_local_path)).result)
61
- local_figaro = {}
62
- deployment_env = fetch(:rails_env, env).to_s
63
-
64
- @local_figaro_yml.each do |key, value|
65
- if key == env
66
- local_figaro[deployment_env] = @local_figaro_yml[key]
67
- elsif !value.is_a?(Hash)
68
- local_figaro[key] = @local_figaro_yml[key]
69
- end
70
- end
71
61
 
72
- local_figaro
62
+ @local_figaro_yml || {}
73
63
  end
74
64
 
75
65
  def local_yaml
@@ -85,9 +75,18 @@ module Capistrano
85
75
  end
86
76
 
87
77
  def configs(yaml, env)
88
- stage_yml = yaml[env.to_s]&.sort.to_h
78
+ env_str = env.to_s
79
+ stage_yml = yaml[env_str]&.sort.to_h
89
80
  global_yml = remove_nested(yaml)&.sort.to_h
90
- [global_yml, stage_yml]
81
+
82
+ other_stages_yml = stages.each_with_object({}) do |f, hash|
83
+ f_str = f.to_s
84
+ next if f_str == env_str
85
+
86
+ hash[f_str] = yaml[f_str]&.sort.to_h
87
+ end.compact
88
+
89
+ [global_yml, stage_yml, other_stages_yml]
91
90
  end
92
91
 
93
92
  def remove_nested(hash)
@@ -10,12 +10,12 @@ namespace :figaro_yml do
10
10
  local = local_figaro_yml(figaro_yml_env)
11
11
 
12
12
  # Split into stage-specific and global configurations
13
- local_global_env, local_stage_env = configs(local, figaro_yml_env)
13
+ local_global_env, local_stage_env, _local_rest = configs(local, figaro_yml_env)
14
14
 
15
15
  on release_roles :all do
16
16
  # Read and parse remote application.yml
17
17
  remote = YAML.safe_load(capture("cat #{figaro_yml_remote_path}"))
18
- remote_global_env, remote_stage_env = configs(remote, figaro_yml_env)
18
+ remote_global_env, remote_stage_env, _remote_rest = configs(remote, figaro_yml_env)
19
19
 
20
20
  # Compare hashes and handle nil results with empty hashes
21
21
  differences_global = compare_hashes(local_global_env, remote_global_env)
@@ -8,11 +8,11 @@ namespace :figaro_yml do
8
8
  invoke 'figaro_yml:create_local'
9
9
  else
10
10
  local_yml = local_figaro_yml(figaro_yml_env)
11
- local_global, local_stage = configs(local_yml, figaro_yml_env)
11
+ local_global, local_stage, local_rest = configs(local_yml, figaro_yml_env)
12
12
  on release_roles :all do
13
13
  remote = capture "cat #{figaro_yml_remote_path}"
14
14
  remote_yml = YAML.safe_load(remote).sort.to_h
15
- remote_global, remote_stage = configs(remote_yml, figaro_yml_env)
15
+ remote_global, remote_stage, _remote_rest = configs(remote_yml, figaro_yml_env)
16
16
  differences_global = compare_hashes(remote_global, local_global || {})
17
17
  differences_stage = compare_hashes(remote_stage, local_stage || {})
18
18
 
@@ -29,10 +29,10 @@ namespace :figaro_yml do
29
29
  global_overwrite = ask_to_overwrite('Overwrite local application.yml globals') if differences_global
30
30
  puts 'Nothing written to local application.yml' unless stage_overwrite || global_overwrite
31
31
  exit unless stage_overwrite || global_overwrite
32
-
33
32
  # compose new yml
33
+
34
34
  composed_yml = {}
35
- composed_yml.merge!(local_yml) # local yml is always included to avoid losing any data
35
+ composed_yml.merge!(local_rest) # local yml is always included to avoid losing any data
36
36
  composed_yml.merge!(local_global) unless global_overwrite
37
37
  composed_yml.merge!(remote_global) if global_overwrite
38
38
  composed_yml[figaro_yml_env.to_s] = stage_overwrite ? remote_stage : local_stage
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Capistrano
4
4
  module Ops
5
- VERSION = '1.0.3'
5
+ VERSION = '1.0.4'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-ops
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Crusius
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-07-15 00:00:00.000000000 Z
11
+ date: 2024-08-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-s3