Class: Pipely::Deploy::JSONDefinition
- Inherits:
-
Object
- Object
- Pipely::Deploy::JSONDefinition
- Defined in:
- lib/pipely/deploy/json_definition.rb
Overview
The JSON definition format expected by the CLI differs from the structure expected by the API. This class transforms a CLI-ready definition into the pipeline object hashes expected by the API.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(object) ⇒ JSONDefinition
constructor
A new instance of JSONDefinition.
- #to_api ⇒ Object
Constructor Details
#initialize(object) ⇒ JSONDefinition
Returns a new instance of JSONDefinition.
17 18 19 20 21 |
# File 'lib/pipely/deploy/json_definition.rb', line 17 def initialize(object) @json_fields = object.clone @id = @json_fields.delete(:id) @name = @json_fields.delete(:name) || @id end |
Class Method Details
.parse(definition) ⇒ Object
11 12 13 14 15 |
# File 'lib/pipely/deploy/json_definition.rb', line 11 def self.parse(definition) definition_objects = JSON.parse(definition, symbolize_names: true)[:objects] definition_objects.map { |object| new(object).to_api } end |
Instance Method Details
#to_api ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/pipely/deploy/json_definition.rb', line 23 def to_api { id: @id, name: @name, fields: fields } end |