Sha256: 7c78128150b8e201ac8ccb5cffa91dea26c17744b9c4143d8997e512a0ac4678
Contents?: true
Size: 1.33 KB
Versions: 19
Compression:
Stored size: 1.33 KB
Contents
module Shipit class TaskDefinition NotFound = Class.new(StandardError) class << self def load(payload) return unless payload.present? json = JSON.parse(payload) new(json.delete('id'), json) end def dump(definition) return unless definition.present? JSON.dump(definition.as_json) end end attr_reader :id, :action, :description, :steps, :checklist, :variables alias_method :to_param, :id def initialize(id, config) @id = id @action = config['action'] @description = config['description'] || '' @steps = config['steps'] || [] @variables = task_variables(config['variables'] || []) @checklist = config['checklist'] || [] @allow_concurrency = config['allow_concurrency'] || false end def allow_concurrency? @allow_concurrency end def as_json { id: id, action: action, description: description, steps: steps, variables: variables.map(&:to_h), checklist: checklist, allow_concurrency: allow_concurrency?, } end def filter_envs(env) EnvironmentVariables.with(env).permit(variables) end private def task_variables(config_variables) config_variables.map(&VariableDefinition.method(:new)) end end end
Version data entries
19 entries across 19 versions & 1 rubygems