253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
|
# File 'lib/openc3/models/tool_model.rb', line 253
def deploy(gem_path, variables, validate_only: false)
return unless @folder_name
variables["tool_name"] = @name
start_path = "/tools/#{@folder_name}/"
Dir.glob(gem_path + start_path + "**/*") do |filename|
next if filename == '.' or filename == '..' or File.directory?(filename)
key = filename.split(gem_path + '/tools/')[-1]
extension = filename.split('.')[-1]
content_type = Rack::Mime.mime_type(".#{extension}")
data = File.read(filename, mode: "rb")
erb_disabled = check_disable_erb(filename)
unless erb_disabled
data = ERB.new(data.(), trim_mode: "-").result(binding.set_variables(variables)) if data.is_printable?
end
unless validate_only
client = Bucket.getClient()
cache_control = BucketUtilities.get_cache_control(filename)
client.put_object(bucket: ENV['OPENC3_TOOLS_BUCKET'], content_type: content_type, cache_control: cache_control, key: key, body: data)
ConfigTopic.write({ kind: 'created', type: 'tool', name: @folder_name, plugin: @plugin }, scope: @scope)
end
end
end
|