pipe_fitter 0.1.7 → 0.1.8
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/lib/pipe_fitter/pipeline.rb +37 -12
- data/lib/pipe_fitter/version.rb +1 -1
- data/lib/pipe_fitter/yaml_loader.rb +10 -4
- 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: 892c113ee708c1620229690aa80940b4cd2ec4df
|
4
|
+
data.tar.gz: ec8b73ebbd4f064f944ee640158782d76291b16d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a3801e39e26c40dd1dda5411d23fce072f3d95f56496b600dfc02a98f4ed29b0dc8f6732c8469bd6f089ec69c75fafc07eafb7e6c89af764cf08c8325ad4679
|
7
|
+
data.tar.gz: 8053e25626a894251dd2bb93b7c261728c64bac31fc6984d3847713114a02a11da0cc79732d02dc7d038718854c835349b1cf6af9bb1608644181aff33283bf9
|
data/lib/pipe_fitter/pipeline.rb
CHANGED
@@ -79,13 +79,6 @@ module PipeFitter
|
|
79
79
|
end
|
80
80
|
|
81
81
|
class PipelineBaseObjects
|
82
|
-
def initialize(objs)
|
83
|
-
@objs = case objs
|
84
|
-
when Array then objs.map { |obj| symbolize_keys(obj) }
|
85
|
-
else symbolize_keys(objs) || {}
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
82
|
def to_objs
|
90
83
|
case @objs
|
91
84
|
when Array then @objs.map { |obj| stringify_keys(obj) }
|
@@ -143,16 +136,27 @@ module PipeFitter
|
|
143
136
|
|
144
137
|
class PipelineObjects < PipelineBaseObjects
|
145
138
|
def self.create(api_res)
|
146
|
-
objs = (api_res || []).map(&:to_h).
|
139
|
+
objs = (api_res || []).map(&:to_h).map do |obj|
|
147
140
|
base = { id: obj[:id], name: obj[:name] }
|
148
141
|
fields = obj[:fields].inject({}) do |a, e|
|
149
142
|
update_hash(a, e[:key].to_sym, e[:string_value] || { ref: e[:ref_value] })
|
150
143
|
end
|
151
|
-
base.merge(fields
|
144
|
+
base.merge(fields)
|
152
145
|
end
|
153
146
|
new(objs)
|
154
147
|
end
|
155
148
|
|
149
|
+
KEY_ORDER = %i(id name).freeze
|
150
|
+
|
151
|
+
def initialize(objs)
|
152
|
+
@objs = (objs || []).map { |obj| symbolize_keys(obj) }
|
153
|
+
.sort_by { |obj| obj[:id] }.map do |obj|
|
154
|
+
obj.sort_by do |k, v|
|
155
|
+
[KEY_ORDER.index(k) || KEY_ORDER.size + 1, k.to_s, v.to_s]
|
156
|
+
end.to_h
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
156
160
|
def to_api_opts
|
157
161
|
@objs.map do |obj|
|
158
162
|
{ id: obj[:id], name: obj[:name], fields: split_object(obj, %i(id name)) }
|
@@ -162,15 +166,26 @@ module PipeFitter
|
|
162
166
|
|
163
167
|
class ParameterObjects < PipelineBaseObjects
|
164
168
|
def self.create(api_res)
|
165
|
-
objs = (api_res || []).map(&:to_h).
|
169
|
+
objs = (api_res || []).map(&:to_h).map do |obj|
|
166
170
|
base = { id: obj[:id] }
|
167
|
-
obj[:attributes].
|
171
|
+
obj[:attributes].inject(base) do |a, e|
|
168
172
|
update_hash(a, e[:key].to_sym, e[:string_value])
|
169
173
|
end
|
170
174
|
end
|
171
175
|
new(objs)
|
172
176
|
end
|
173
177
|
|
178
|
+
KEY_ORDER = %i(id).freeze
|
179
|
+
|
180
|
+
def initialize(objs)
|
181
|
+
@objs = (objs || []).map { |obj| symbolize_keys(obj) }
|
182
|
+
.sort_by { |obj| obj[:id] }.map do |obj|
|
183
|
+
obj.sort_by do |k, v|
|
184
|
+
[KEY_ORDER.index(k) || KEY_ORDER.size + 1, k.to_s, v.to_s]
|
185
|
+
end.to_h
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
174
189
|
def to_api_opts
|
175
190
|
@objs.map do |obj|
|
176
191
|
{ id: obj[:id], attributes: split_object(obj, %i(id)) }
|
@@ -180,12 +195,16 @@ module PipeFitter
|
|
180
195
|
|
181
196
|
class ParameterValues < PipelineBaseObjects
|
182
197
|
def self.create(api_res)
|
183
|
-
objs = (api_res || []).
|
198
|
+
objs = (api_res || []).map do |obj|
|
184
199
|
{ obj[:id].to_sym => obj[:string_value] }
|
185
200
|
end
|
186
201
|
new(objs)
|
187
202
|
end
|
188
203
|
|
204
|
+
def initialize(objs)
|
205
|
+
@objs = (objs || []).sort_by { |obj| obj.first[0] }
|
206
|
+
end
|
207
|
+
|
189
208
|
def to_api_opts
|
190
209
|
@objs.map do |e|
|
191
210
|
e.map do |k, v|
|
@@ -209,6 +228,12 @@ module PipeFitter
|
|
209
228
|
new(objs)
|
210
229
|
end
|
211
230
|
|
231
|
+
def initialize(objs)
|
232
|
+
@objs = symbolize_keys(objs || {}).sort_by do |k, v|
|
233
|
+
[DESCRIPTION_KEYS.index(k) || DESCRIPTION_KEYS.size + 1, k.to_s, v.to_s]
|
234
|
+
end.to_h
|
235
|
+
end
|
236
|
+
|
212
237
|
DESCRIPTION_KEYS = %i(name description tags uniqueId).freeze
|
213
238
|
|
214
239
|
def to_objs
|
data/lib/pipe_fitter/version.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require "yaml"
|
2
2
|
require "erb"
|
3
3
|
require "pathname"
|
4
|
+
require "tempfile"
|
4
5
|
|
5
6
|
module PipeFitter
|
6
7
|
class YamlLoader
|
@@ -10,7 +11,7 @@ module PipeFitter
|
|
10
11
|
|
11
12
|
def load(filename)
|
12
13
|
@search_path.unshift(Pathname.new(filename).dirname)
|
13
|
-
text = eval_erb(filename)
|
14
|
+
text = eval_erb(grep_v(filename, /^\s*#/))
|
14
15
|
YAML.load(text) || {}
|
15
16
|
rescue Psych::SyntaxError => e
|
16
17
|
text.split("\n").each_with_index do |l, i|
|
@@ -23,13 +24,18 @@ module PipeFitter
|
|
23
24
|
def include_template(filename, context = {})
|
24
25
|
dir = @search_path.find { |p| p.join(filename).exist? }
|
25
26
|
path = dir.nil? ? filename : dir.join(filename)
|
26
|
-
eval_erb(path
|
27
|
+
eval_erb(File.read(path), context)
|
28
|
+
.gsub("\n", "\n" + " " * (context[:indent] || 0))
|
27
29
|
end
|
28
30
|
|
29
31
|
private
|
30
32
|
|
31
|
-
def eval_erb(
|
32
|
-
ERB.new(
|
33
|
+
def eval_erb(data, context = {})
|
34
|
+
ERB.new(data, nil, "-").result(binding).strip
|
35
|
+
end
|
36
|
+
|
37
|
+
def grep_v(filename, pattern)
|
38
|
+
File.open(filename).select { |l| l !~ pattern }.join
|
33
39
|
end
|
34
40
|
end
|
35
41
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pipe_fitter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- masa21kik
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-06-
|
11
|
+
date: 2016-06-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk
|