Sha256: 872265dab29541692e7cbd64b4a406d9dc1e3c027c6ebddeae34fdf843c8bdd0
Contents?: true
Size: 1.6 KB
Versions: 7
Compression:
Stored size: 1.6 KB
Contents
module Shipit class TaskDefinition NotFound = Class.new(StandardError) class << self def load(payload) return if payload.blank? json = JSON.parse(payload) new(json.delete('id'), json) end def dump(definition) return if definition.blank? 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 @title = config['title'] end def render_title(env) if @title @title % env.symbolize_keys else action end end def allow_concurrency? @allow_concurrency end def as_json { id: id, action: action, title: @title, 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 def variables_with_defaults @variables_with_defaults ||= variables.select(&:default_provided?) end private def task_variables(config_variables) config_variables.map(&VariableDefinition.method(:new)) end end end
Version data entries
7 entries across 7 versions & 1 rubygems