Class: Drone::Plugin

Inherits:
Object
  • Object
show all
Defined in:
lib/drone/plugin.rb

Overview

Plugin payload parser for Drone

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(input) {|parse| ... } ⇒ Drone::Plugin

Initialize the plugin parser

Parameters:

  • input (String)

    the JSON as a string to parse

Yields:



31
32
33
34
35
36
37
# File 'lib/drone/plugin.rb', line 31

def initialize(input)
  self.input = input

  yield(
    parse
  ) if block_given?
end

Instance Attribute Details

#inputObject

Returns the value of attribute input.



24
25
26
# File 'lib/drone/plugin.rb', line 24

def input
  @input
end

#resultObject

Returns the value of attribute result.



25
26
27
# File 'lib/drone/plugin.rb', line 25

def result
  @result
end

Instance Method Details

#parseDrone::Payload

Parse the provided payload

Returns:

Raises:



43
44
45
46
47
48
49
50
51
52
53
# File 'lib/drone/plugin.rb', line 43

def parse
  self.result ||= Payload.new.tap do |payload|
    PayloadRepresenter.new(
      payload
    ).from_json(
      input
    )
  end
rescue MultiJson::ParseError
  raise InvalidJsonError
end