app_builder 0.2.6 → 0.2.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/app_builder/environment.rb +23 -21
- data/lib/app_builder/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6f2c3eb1f29506c9d100320779e17513e7c32661209c48f849a31f5cba48bfb3
|
4
|
+
data.tar.gz: 68d348db9295814fcb9b351e7e36f97891ff7e501701d5dc661ace572e2e311c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d170c4d5b76988d117e46bce7f40ed5fc56a97cef5732a66c4960ebf5841bcf2e538e2b1245568ebd80b5d08a4a1f600fc3c25614ed2309919728d4c5d4dc58
|
7
|
+
data.tar.gz: bb8066f6826e2618c7ad5453a398b74c96e7f76a9ca3994775eb89b30d1bd77d6b2ddade6264e796aea35278d6353a201b59dccf3bceaae83d773613116c80e9
|
@@ -1,56 +1,58 @@
|
|
1
1
|
module AppBuilder
|
2
2
|
class Environment
|
3
3
|
attr_accessor :name
|
4
|
-
attr_reader :repo_path, :branch, :source_path
|
4
|
+
attr_reader :repo_path, :branch, :source_path, :source_type
|
5
5
|
|
6
6
|
def initialize(source_path, options = {})
|
7
7
|
@name = options[:name] || ENV.fetch("APP_ENV", "default")
|
8
8
|
@repo_path = options[:repo_path] || `git rev-parse --show-toplevel`.chomp
|
9
9
|
@branch = options[:branch] || ENV.fetch("TARGET_BRANCH", `git symbolic-ref --short HEAD`.chomp)
|
10
10
|
@source_path = source_path
|
11
|
-
@
|
11
|
+
@source_type = options.fetch(:source_type, :git) # :git (git show branch:path) or :path (File.read(path))
|
12
12
|
end
|
13
13
|
|
14
14
|
def create_file(template_path, output_path)
|
15
15
|
File.open(output_path, "w") do |f|
|
16
|
-
f.write(ERB.new(File.read(template_path)).result(
|
16
|
+
f.write(ERB.new(File.read(template_path)).result(binding))
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
-
def template_binding
|
21
|
-
env = source.fetch(name.to_s)
|
22
|
-
Class.new.tap { |klass|
|
23
|
-
klass.define_method(:env) { env }
|
24
|
-
}.instance_eval { binding }
|
25
|
-
end
|
26
|
-
|
27
20
|
def [](key)
|
28
21
|
hash.fetch(key.to_s, nil)
|
29
22
|
end
|
30
23
|
|
31
24
|
def to_hash
|
32
|
-
|
25
|
+
raw_source.fetch(name.to_s)
|
33
26
|
end
|
34
27
|
alias :hash :to_hash
|
35
28
|
|
36
|
-
def
|
29
|
+
def raw_source
|
37
30
|
@source ||= load_source
|
38
31
|
end
|
39
32
|
|
40
33
|
private
|
41
34
|
|
42
35
|
def load_source
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
}
|
49
|
-
).result(binding)
|
50
|
-
)
|
36
|
+
case source_type
|
37
|
+
when :git
|
38
|
+
raw_src = Dir.chdir(repo_path) { `git show #{branch}:#{source_path}` }
|
39
|
+
when :path
|
40
|
+
raw_src = File.read(source_path)
|
51
41
|
else
|
52
|
-
|
42
|
+
raise "Unknown source_type: #{source_type}"
|
53
43
|
end
|
44
|
+
|
45
|
+
YAML.load(ERB.new(raw_src).result(binding))
|
46
|
+
end
|
47
|
+
|
48
|
+
def method_missing(name, *args, &block)
|
49
|
+
super unless hash.has_key?(name.to_s)
|
50
|
+
|
51
|
+
hash.fetch(name.to_s)
|
52
|
+
end
|
53
|
+
|
54
|
+
def respond_to_missing?(name, include_private = false)
|
55
|
+
hash.has_key?(name.to_s)
|
54
56
|
end
|
55
57
|
end
|
56
58
|
end
|
data/lib/app_builder/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: app_builder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- i2bskn
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-07-
|
11
|
+
date: 2018-07-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: net-ssh
|