dply 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +0 -3
- data/lib/dply/app_config.rb +38 -0
- data/lib/dply/ext/hash.rb +23 -0
- data/lib/dply/task_dsl.rb +4 -0
- data/lib/dply/version.rb +1 -1
- data/spec/dply/bundle_spec.rb +1 -1
- data/spec/integration/git_flow_spec.rb +8 -0
- data/spec/test_data/elf/libecpg.so +0 -0
- data/spec/test_data/elf/rpath_libecpg.so +0 -0
- data/spec/test_data/sample_repo/application-override.yml +2 -0
- data/spec/test_data/sample_repo/application.yml +3 -0
- data/spec/test_data/sample_repo/dply/app.rb +6 -0
- data/spec/test_data/sample_repo/dply/config/test.erb +2 -0
- metadata +14 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1f29d96cf7879f2fdeae544b8786fc31f791d6426c45d37d3c096adce397f2af
|
4
|
+
data.tar.gz: 3ea7b2f1e64fcef2f81a81eecc9eda6f6709866d5818869b16c7c3447bec9215
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 99b236593f11eefae1d1ed9c0ad0d3c1a733662a6c2c2c4d3fe2e111fb3b8383bb21a5ea1b2ae926baa20a61ebe4459a446a938b7ad6f6b76823cc7b37fe20fa
|
7
|
+
data.tar.gz: 8327e1f35451fb78ec59a2d1acb8482eddf25cc75b5345af99df3e563bb9bd6299d33330158c8d258634e826e976ec58bdef75fe402c8e0c84a17069d17e0ac7
|
data/.gitignore
CHANGED
data/lib/dply/app_config.rb
CHANGED
@@ -1,17 +1,26 @@
|
|
1
1
|
require_relative 'task_dsl'
|
2
2
|
require_relative 'error'
|
3
3
|
require_relative 'logger'
|
4
|
+
require_relative 'ext/hash'
|
5
|
+
require 'erb'
|
6
|
+
require 'fileutils'
|
4
7
|
|
5
8
|
module Dply
|
6
9
|
class AppConfig
|
7
10
|
|
11
|
+
using HashExt
|
8
12
|
include Logger
|
9
13
|
|
10
14
|
def initialize
|
11
15
|
@tasks = {}
|
16
|
+
@config_map = {}
|
12
17
|
@namespace = nil
|
13
18
|
@inside_namespace = false
|
14
19
|
@config_read = false
|
20
|
+
@dsl_methods = self.class.instance_methods(false) + self.class.private_instance_methods(false)
|
21
|
+
def self.singleton_method_added(name)
|
22
|
+
raise Error, "overriding dsl method: :#{name} not allowed" if @dsl_methods.include? name
|
23
|
+
end
|
15
24
|
end
|
16
25
|
|
17
26
|
def run_task(name, optional: false)
|
@@ -28,6 +37,23 @@ module Dply
|
|
28
37
|
end
|
29
38
|
end
|
30
39
|
|
40
|
+
def render_config(override_file: nil)
|
41
|
+
config_data = load_yml "application.yml", optional: true
|
42
|
+
if override_file
|
43
|
+
data = load_yml override_file, optional: true
|
44
|
+
config_data.deep_merge! data
|
45
|
+
end
|
46
|
+
|
47
|
+
tmp_file = "tmp/config_render.tmp"
|
48
|
+
@config_map.each do |dest, src|
|
49
|
+
raise Error, %(error dest "#{dest}" is a directory) if File.directory? dest
|
50
|
+
template = File.read "dply/config/#{src}"
|
51
|
+
contents = ERB.new(template).result_with_hash(config_data)
|
52
|
+
File.write tmp_file, contents
|
53
|
+
FileUtils.mv tmp_file, dest
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
31
57
|
def load_config
|
32
58
|
return if @config_read
|
33
59
|
bundler_setup
|
@@ -66,6 +92,10 @@ module Dply
|
|
66
92
|
@inside_namespace = false
|
67
93
|
end
|
68
94
|
|
95
|
+
def config_map(map)
|
96
|
+
@config_map = map
|
97
|
+
end
|
98
|
+
|
69
99
|
def read_config(file, optional: false)
|
70
100
|
if not File.readable? file
|
71
101
|
raise Error, "#{file} not found" if not optional
|
@@ -104,5 +134,13 @@ module Dply
|
|
104
134
|
raise Error, "drakefile.rb or dply/ dir not present" if not exists
|
105
135
|
end
|
106
136
|
|
137
|
+
def load_yml(path, optional: false)
|
138
|
+
if not File.readable? path
|
139
|
+
raise Error, "error reading file #{path}" if not optional
|
140
|
+
return {}
|
141
|
+
end
|
142
|
+
YAML.safe_load(File.read(path)) || {}
|
143
|
+
end
|
144
|
+
|
107
145
|
end
|
108
146
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Dply
|
2
|
+
module HashExt
|
3
|
+
refine Hash do
|
4
|
+
|
5
|
+
def deep_merge!(other_hash, &block)
|
6
|
+
merge!(other_hash) do |key, this_val, other_val|
|
7
|
+
if this_val.is_a?(Hash) && other_val.is_a?(Hash)
|
8
|
+
this_val.deep_merge(other_val, &block)
|
9
|
+
elsif block_given?
|
10
|
+
block.call(key, this_val, other_val)
|
11
|
+
else
|
12
|
+
other_val
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def deep_merge(other_hash, &block)
|
18
|
+
dup.deep_merge!(other_hash, &block)
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/dply/task_dsl.rb
CHANGED
@@ -18,6 +18,10 @@ module Dply
|
|
18
18
|
super(command, env: extra_env, bundled_env: bundled_env, display: :arrow)
|
19
19
|
end
|
20
20
|
|
21
|
+
def render_config(override_file: nil)
|
22
|
+
@app_config.render_config(override_file: override_file)
|
23
|
+
end
|
24
|
+
|
21
25
|
def set_env(key, value)
|
22
26
|
ENV[key.to_s] = value.to_s
|
23
27
|
base_env[key.to_s] = value.to_s
|
data/lib/dply/version.rb
CHANGED
data/spec/dply/bundle_spec.rb
CHANGED
@@ -60,4 +60,12 @@ describe "git flow" do
|
|
60
60
|
system! "#{@drake} reload"
|
61
61
|
end
|
62
62
|
end
|
63
|
+
|
64
|
+
specify "config renderer works" do
|
65
|
+
Dir.chdir @deploy_dir do
|
66
|
+
expect(File).to exist("current/test.txt")
|
67
|
+
data = File.read "current/test.txt"
|
68
|
+
expect(data).to eq("asdf-override\n5432\n")
|
69
|
+
end
|
70
|
+
end
|
63
71
|
end
|
Binary file
|
Binary file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dply
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Neeraj
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-10-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby-elf
|
@@ -104,6 +104,7 @@ files:
|
|
104
104
|
- lib/dply/elf.rb
|
105
105
|
- lib/dply/env.rb
|
106
106
|
- lib/dply/error.rb
|
107
|
+
- lib/dply/ext/hash.rb
|
107
108
|
- lib/dply/ext/string.rb
|
108
109
|
- lib/dply/git.rb
|
109
110
|
- lib/dply/helper.rb
|
@@ -167,13 +168,18 @@ files:
|
|
167
168
|
- spec/test_data/bundle/no_gemfile/.gitkeep
|
168
169
|
- spec/test_data/command/test.rb
|
169
170
|
- spec/test_data/elf/elf
|
171
|
+
- spec/test_data/elf/libecpg.so
|
170
172
|
- spec/test_data/elf/libpgtypes.so.3
|
171
173
|
- spec/test_data/elf/not_elf
|
174
|
+
- spec/test_data/elf/rpath_libecpg.so
|
172
175
|
- spec/test_data/sample_repo/.dply.lock
|
173
176
|
- spec/test_data/sample_repo/Gemfile
|
174
177
|
- spec/test_data/sample_repo/Rakefile
|
175
178
|
- spec/test_data/sample_repo/app.rb
|
179
|
+
- spec/test_data/sample_repo/application-override.yml
|
180
|
+
- spec/test_data/sample_repo/application.yml
|
176
181
|
- spec/test_data/sample_repo/dply/app.rb
|
182
|
+
- spec/test_data/sample_repo/dply/config/test.erb
|
177
183
|
- spec/test_data/sample_repo/lib/libacl.so.1
|
178
184
|
- spec/test_data/sample_repo/pkgs.yml
|
179
185
|
- spec/webserver.rb
|
@@ -203,7 +209,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
203
209
|
version: '0'
|
204
210
|
requirements: []
|
205
211
|
rubyforge_project:
|
206
|
-
rubygems_version: 2.7.
|
212
|
+
rubygems_version: 2.7.6
|
207
213
|
signing_key:
|
208
214
|
specification_version: 4
|
209
215
|
summary: rake based deploy tool
|
@@ -234,13 +240,18 @@ test_files:
|
|
234
240
|
- spec/test_data/bundle/no_gemfile/.gitkeep
|
235
241
|
- spec/test_data/command/test.rb
|
236
242
|
- spec/test_data/elf/elf
|
243
|
+
- spec/test_data/elf/libecpg.so
|
237
244
|
- spec/test_data/elf/libpgtypes.so.3
|
238
245
|
- spec/test_data/elf/not_elf
|
246
|
+
- spec/test_data/elf/rpath_libecpg.so
|
239
247
|
- spec/test_data/sample_repo/.dply.lock
|
240
248
|
- spec/test_data/sample_repo/Gemfile
|
241
249
|
- spec/test_data/sample_repo/Rakefile
|
242
250
|
- spec/test_data/sample_repo/app.rb
|
251
|
+
- spec/test_data/sample_repo/application-override.yml
|
252
|
+
- spec/test_data/sample_repo/application.yml
|
243
253
|
- spec/test_data/sample_repo/dply/app.rb
|
254
|
+
- spec/test_data/sample_repo/dply/config/test.erb
|
244
255
|
- spec/test_data/sample_repo/lib/libacl.so.1
|
245
256
|
- spec/test_data/sample_repo/pkgs.yml
|
246
257
|
- spec/webserver.rb
|